-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathHSCROLL.a99
329 lines (306 loc) · 7.39 KB
/
HSCROLL.a99
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
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
DEF RUNTST
REF VMBW,VWTR
REF VDPWA,VDPWD
*
REF MP01HD ; Map Header
*
REF FIXDCL,FIXDCD,FIXDCG ; Colors
REF FIXDPT,FIXDPD,FIXDPG ; Patterns
REF FIXDHD
REF FIXDRW,FIXDRD,FIXDRG ; Screen Image
* A program to test shifting the screen left and right
* This scroll method involves defining grops of 8 characters
* Each character in the group is pixel-shifted by one
* relative to the earlier character.
*
* Use this file together with HSCROLLDAT and FIXEDDAT
* Addresses
USRISR EQU >83C4 Address defining address of interupt routine
*
SPRTBL EQU >1000 Address of Sprite Pattern Table
CLRTBL EQU >380 Address of Color Table
PTNTBL EQU >800 Address of Charater Pattern Table
SCNPG1 EQU >0 Address of Page 1 of the screen image table
SCNPG2 EQU >400 Address of Page 2 of the screen image table
*
* Data used for page flips
*
VDPRG2 DATA >0200 Current value of VDP register 2
ADDRG2 DATA 1 Add this to Reg 2 to flip screen image page
VDPRG5 DATA >0506 Current value of VDP register 5
ADDRG5 DATA >E Add this to REg 5 to flip sprite attribute page
MAPWD DATA 0 Width of current map
MAPXT DATA 0 Width of current map - >20 (screen width)
* Timer stuff
TIMER DATA 0 A number that imgrements every 1/60 second
SCRLTM DATA 5 When this value is <= TIMER, scroll left or right
WAITTM DATA 2 Amount of time to wait between scrolls
EIGHT BYTE 8
MINSCL BYTE 0 Minimum scrollable character
EVEN
* Used to create shifted version of characters
PATBUF BSS 64
PATEND
RUNTST
* Initialize Game
BL @INTGAM
* Draw fixed portion of image
BL @DRWFXD
* Initialize Scrollable map
LI R10,MP01HD
BL @INTMAP
* Initialize scroll position data
BL @INTPOS
* Wait to scroll horizontally
WAITLP LIMI 2
LIMI 0
MOV @SCRLTM,R0
S @TIMER,R0
JGT WAITLP
* Set next timer
A @WAITTM,@SCRLTM
* Scroll left or right
BL @SCROLL
* Copy map to VDP with scrolling
LI R0,>60
LI R10,MP01HD
BL @DRWMAP
BL @FLIPPG
* Start over
JMP WAITLP
*
* Initialize game
*
INTGAM
* Define the interupt routine
LI R0,TIMINT
MOV R0,@USRISR
* Move Sprite Descriptor Table to >1000
LI R0,>0602
BLWP @VWTR
* Set background color
LI R0,>0701
BLWP @VWTR
RT
*
* Draw fixed portion of screen
*
DRWFXD MOV R11,@FXDRT
* Write character patterns for non-scrolling characters
LI R0,PTNTBL
LI R1,FIXDPT
LI R2,FIXDPG
BLWP @VMBW
* Write color definitions
LI R0,CLRTBL
LI R1,FIXDCL
LI R2,FIXDCG
BLWP @VMBW
* Write non-scrolling characters to both pages
BL @WRSCRN
NEG @ADDRG2
BL @WRSCRN
NEG @ADDRG2
*
MOV @FXDRT,R11
RT
FXDRT DATA 0
* Write non-scrolling characters to screen
WRSCRN
CLR R0
MOV @ADDRG2,@ADDRG2
JLT SCRN0
LI R0,SCNPG2
SCRN0 LI R1,FIXDRW
LI R2,FIXDRG
BLWP @VMBW
RT
*
* Initialize Map
*
* R10 - Address of map header
MAPCOL EQU 0
MAPROW EQU 2
MAPSIZ EQU 4
COLORB EQU 6
COLORD EQU 8
COLORG EQU 10
PATRNB EQU 12
PATRND EQU 14
PATRNG EQU 16
SPRITB EQU 18
SPRITD EQU 20
SPRITG EQU 22
SCRENB EQU 24
SCREND EQU 26
SCRENG EQU 28
INTMAP
* Record map width values
MOV *R10,R0
MOV R0,@MAPWD
AI R0,-32
MOV R0,@MAPXT
* Record minimum scrollable character
MOV @PATRNB(10),R0
MOV *R0,R0
SWPB R0
MOVB R0,@MINSCL
* Write color definitions
SRL R0,11 Find value of minimum scrollable character / 8
AI R0,CLRTBL
MOV @COLORB(10),R1
MOV @COLORG(10),R2
BLWP @VMBW
* Write sprite pattern definitions
LI R0,SPRTBL
MOV @SPRITB(10),R1
MOV @SPRITG(10),R2
BLWP @VMBW
* Write character patterns from >60
* We are copying portions of 16-pixel characters
* to 8-pixel characters
* R3 - VDP address
* R4 - address of leftmost 8 pixels
* R5 - address of rightmost 8 pixels
* R7 - 16 pixels
* R8 - address of end of pattern data
MOVB @MINSCL,R3
SWPB R3
SLA R3,3
AI R3,PTNTBL R3 = first char code * 8 + pattern table address
MOV @PATRNB(10),R4
AI R4,2
MOV @PATRNB(10),R5
AI R5,10
MOV @PATRND(10),R8
CHAR0 LI R6,PATBUF
CHAR1 MOVB *R5+,R7
SWPB R7
MOVB *R4+,R7
CHAR2 MOVB R7,*R6
SLA R7,1
AI R6,8
CI R6,PATEND
JL CHAR2
AI R6,PATBUF-PATEND+1
CI R6,PATBUF+8
JL CHAR1
MOV R3,R0
LI R1,PATBUF
LI R2,PATEND-PATBUF
BLWP @VMBW
AI R3,8*8
AI R4,8
AI R5,8
C R4,R8
JL CHAR0
RT
*
* Initialize Scroll Position values
*
INTPOS
* Store column scroll amount in R6
CLR R6
* Store pixel scroll amount in R3 (left-most byte)
LI R3,>0100
* Store scroll direction in R4 and R5
* always either positive or negative 1.
LI R4,>0100
LI R5,>0001
RT
*
* Update scroll positions
*
SCROLL MOV R5,R5
JLT SLEFT
* R4 and R5 are expected to hold +1
SRIGHT AB R4,R3
CB R3,@EIGHT
JL PAINT
CLR R3
A R5,R6
C R6,@MAPXT
JL PAINT
DEC R6
LI R3,>0700
NEG R4
NEG R5
JMP PAINT
* R4 and R5 are expected to hold -1
SLEFT AB R4,R3
JGT PAINT
JEQ PAINT
LI R3,>0700
A R5,R6
JGT PAINT
JEQ PAINT
CLR R6
CLR R3
NEG R4
NEG R5
PAINT RT
*
* Draw the scrollable map
*
* R0 - Screen location to write to
* R3 - Pixel Scroll Amount
* R4 - left-most byte is scroll direction
* R5 - right-most scroll position
* R6 - Column Scroll Amount
* R10 - Address of map header
DRWMAP MOV R11,@DRWRT
BL @INTCHR
* Store end of map in R8
MOV @SCREND(10),R8
* Store position in map in R9
MOV @SCRENB(10),R9
A R6,R9
HSCRL LIMI 2
LIMI 0
LI R7,>20
HSCRL1 MOVB *R9,R1
CB R1,@MINSCL
JL HSCRL2
AB R3,R1
HSCRL2 MOVB R1,@VDPWD
INC R9
DEC R7
JNE HSCRL1
*
A @MAPXT,R9 Increase R9 to equal address of next row
C R9,R8
JL HSCRL
*
MOV @DRWRT,R11
RT
DRWRT DATA 0
*
* Specify the initial screen position to write to.
*
INTCHR MOV @ADDRG2,@ADDRG2
JLT ITCHR0
AI R0,SCNPG2
ITCHR0 ORI R0,>4000 Set write bit to true
SWPB R0
MOVB R0,@VDPWA
SWPB R0
MOVB R0,@VDPWA
RT
*
* Flip Page
*
FLIPPG
* Flip page for screen image table
A @ADDRG2,@VDPRG2
NEG @ADDRG2
MOV @VDPRG2,R0
BLWP @VWTR
* Flip page for sprite attribute list
* A @ADDRG5,@VDPRG5
* NEG @ADDRG5
* MOV @VDPRG5,R0
* BLWP @VWTR
RT
TIMINT INC @TIMER
RT
END