-
Notifications
You must be signed in to change notification settings - Fork 0
/
hwyenc0.asm
313 lines (286 loc) · 6 KB
/
hwyenc0.asm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
;------------------------------------------------------------------------------
; H H IIIII GGG H H W W A Y Y
; H H I G G H H W W A A Y Y
; H H I G H H W W A A Y Y
; HHHHH I G GG HHHHH W W W A A Y
; H H I G G H H W W W AAAAA Y
; H H I G G H H W W W A A Y
; H H IIIII GGG H H W W A A Y
; EEEEE N N CCC OOO U U N N TTTTT EEEEE RRRR
; E N N C C O O U U N N T E R R
; E NN N C O O U U NN N T E R R
; EEEE N N N C O O U U N N N T EEEE RRRR
; E N NN C O O U U N NN T E R R
; E N N C C O O U U N N T E R R
; EEEEE N N CCC OOO UUU N N T EEEEE R R
; Costa Panayi, Vortex Software, 1985
; RM-TEAM, 2014, 2015, 2016
; nzeemin 2022 порт на Вектор-06Ц
;------------------------------------------------------------------------------
;----------------------------------------------------------------------------
.EXPORT Start
.EXPORT KeyLineEx, KeyLine0, KeyLine7, JoystickP
.EXPORT BorderColor, SetPaletteGame
;----------------------------------------------------------------------------
.org 100h
di
xra a
out 10h ; turn off the quasi-disk
lxi sp,0100h
lxi h,0C3F3h
shld 0
mov a,h
lxi h,RestartInt
shld 2
sta 38h
lxi h,KEYINT ; interrupt handler address
shld 38h+1
; Move encoded block from Start to 8000h, LZSASIZET+LZSASIZE1 bytes
lxi d,Start ; source addr
lxi b,08000h ; destination addr
lxi h,LZSASIZET+LZSASIZE1 ; size
inr h
Init_1:
ldax d
inx d
stax b
inx b
dcr l
jnz Init_1
dcr h
jnz Init_1
; Decompress the code and sprites from 08000h+LZSASIZET to Start
lxi d,08000h+LZSASIZET ; source addr
lxi b,Start ; destination addr
call dzx0
; Decompress 24K of the title screen from 8000h to A000h
lxi d,08000h ; source addr
lxi b,0A000h ; destination addr
call dzx0
RestartInt:
lxi sp,100h
mvi a, 88h
out 4 ; initialize R-Sound 2
; Joystick init
mvi a, 83h ; control byte
out 4 ; initialize the I/O controller
mvi a, 9Fh ; bits to check Joystick-P, both P1 and P2
out 5 ; set Joystick-P query bits
in 6 ; read Joystick-P initial value
sta KEYINT_J+1 ; store as xra instruction parameter
; Set palette for the title screen
lxi h, PaletteTitle+15
call SetPalette
; ei
jp Start
; Set game palette
SetPaletteGame:
lxi h, PaletteGame+15
; Programming the Palette
SetPalette:
ei
hlt
lxi d, 100Fh
PaletLoop:
mov a, e
out 2
mov a, m
out 0Ch
out 0Ch
out 0Ch
out 0Ch
out 0Ch
dcx h
out 0Ch
dcr e
out 0Ch
dcr d
out 0Ch
jnz PaletLoop
ret
;----------------------------------------------------------------------------
KEYINT:
push psw
mvi a, 8Ah
out 0
; Keyboard scan
in 1
ori 00011111b
sta KeyLineEx
mvi a, 0FEh
out 3
in 2
sta KeyLine0
; mvi a, 0FDh
; out 3
; in 2
; sta KeyLine1
; mvi a, 0DFh
; out 3
; in 2
; sta KeyLine5
; mvi a, 0BFh
; out 3
; in 2
; sta KeyLine6
mvi a, 07Fh
out 3
in 2
sta KeyLine7
; Joystick scan
in 6 ; read Joystick-P
KEYINT_J:
xri 0 ; XOR with initial value - mutable param!
cma
sta JoystickP ; save to analyze later
; Scrolling, screen mode, border
mvi a, 88h
out 0
mvi a, 2
out 1
mvi a, 0FFh
out 3 ; scrolling
lda BorderColor
ani 0Fh
out 2 ; screen mode and border
;
pop psw
ei
ret
KeyLineEx: .db 11111111b
KeyLine0: .db 11111111b
;KeyLine1: .db 11111111b
;KeyLine5: .db 11111111b
;KeyLine6: .db 11111111b
KeyLine7: .db 11111111b
JoystickP: .db 11111111b
BorderColor: .db 0 ; border color number 0..15
;----------------------------------------------------------------------------
ColorNone .equ 00000000b
ColorGame .equ 11111110b ; Color for game
ColorText .equ 10111111b ; Color for text
ColorBoth .equ 11111111b ; Color for game and text
; Palette colors, game
PaletteGame: ; Palette
.db ColorNone, ColorGame, ColorText, ColorBoth ; 0..3
.db ColorNone, ColorGame, ColorText, ColorBoth ; 4..7
.db ColorNone, ColorGame, ColorText, ColorBoth ; 8..11
.db ColorNone, ColorGame, ColorText, ColorBoth ; 12..15
; Palette colors, title screen
PaletteTitle:
.db $00,$30,$5B,$A4,$AD,$36,$F6,$FF
.db $00,$30,$5B,$A4,$AD,$36,$F6,$FF
;----------------------------------------------------------------------------
; ZX0 decompressor code by Ivan Gorodetsky
; https://github.com/ivagorRetrocomp/DeZX/blob/main/ZX0/8080/OLD_V1/dzx0_CLASSIC.asm
; input: de=compressed data start
; bc=uncompressed destination start
#ifdef BACKWARD
#define NEXT_HL dcx h
#define NEXT_DE dcx d
#define NEXT_BC dcx b
#else
#define NEXT_HL inx h
#define NEXT_DE inx d
#define NEXT_BC inx b
#endif
dzx0:
#ifdef BACKWARD
lxi h,1
push h
dcr l
#else
lxi h,0FFFFh
push h
inx h
#endif
mvi a,080h
dzx0_literals:
call dzx0_elias
call dzx0_ldir
jc dzx0_new_offset
call dzx0_elias
dzx0_copy:
xchg
xthl
push h
dad b
xchg
call dzx0_ldir
xchg
pop h
xthl
xchg
jnc dzx0_literals
dzx0_new_offset:
call dzx0_elias
#ifdef BACKWARD
inx sp
inx sp
dcr h
rz
dcr l
push psw
mov a,l
#else
mov h,a
pop psw
xra a
sub l
rz
push h
#endif
rar\ mov h,a
ldax d
rar\ mov l,a
NEXT_DE
#ifdef BACKWARD
inx h
#endif
xthl
mov a,h
lxi h,1
#ifdef BACKWARD
cc dzx0_elias_backtrack
#else
cnc dzx0_elias_backtrack
#endif
inx h
jmp dzx0_copy
dzx0_elias:
inr l
dzx0_elias_loop:
add a
jnz dzx0_elias_skip
ldax d
NEXT_DE
ral
dzx0_elias_skip:
#ifdef BACKWARD
rnc
#else
rc
#endif
dzx0_elias_backtrack:
dad h
add a
jnc dzx0_elias_loop
jmp dzx0_elias
dzx0_ldir:
push psw
dzx0_ldir1:
ldax d
stax b
NEXT_DE
NEXT_BC
dcx h
mov a,h
ora l
jnz dzx0_ldir1
pop psw
add a
ret
;----------------------------------------------------------------------------
Start:
.end
;----------------------------------------------------------------------------