Mercurial > repos > ghero
annotate genesis.s68 @ 7:4ffd621f1d0c
Initialize VDP register 0 so it works on the Mega Everdrive. Temporarily disable the sprite stuff
author | Mike Pavone <pavone@retrodev.com> |
---|---|
date | Tue, 03 Sep 2013 09:37:53 -0700 |
parents | 97ec271a513f |
children | 997690aa0507 |
rev | line source |
---|---|
3 | 1 dc.l $0, start |
2 dc.l empty_handler | |
3 dc.l empty_handler | |
4 ;$10 | |
5 dc.l empty_handler | |
6 dc.l empty_handler | |
7 dc.l empty_handler | |
8 dc.l empty_handler | |
9 ;$20 | |
10 dc.l empty_handler | |
11 dc.l empty_handler | |
12 dc.l empty_handler | |
13 dc.l empty_handler | |
14 ;$30 | |
15 dc.l empty_handler | |
16 dc.l empty_handler | |
17 dc.l empty_handler | |
18 dc.l empty_handler | |
19 ;$40 | |
20 dc.l empty_handler | |
21 dc.l empty_handler | |
22 dc.l empty_handler | |
23 dc.l empty_handler | |
24 ;$50 | |
25 dc.l empty_handler | |
26 dc.l empty_handler | |
27 dc.l empty_handler | |
28 dc.l empty_handler | |
29 ;$60 | |
30 dc.l empty_handler | |
31 dc.l empty_handler | |
32 dc.l empty_handler | |
33 dc.l empty_handler | |
34 ;$70 | |
35 dc.l HINT | |
36 dc.l empty_handler | |
37 dc.l VINT | |
38 dc.l empty_handler | |
39 ;$80 | |
40 dc.l empty_handler | |
41 dc.l empty_handler | |
42 dc.l empty_handler | |
43 dc.l empty_handler | |
44 ;$90 | |
45 dc.l empty_handler | |
46 dc.l empty_handler | |
47 dc.l empty_handler | |
48 dc.l empty_handler | |
49 ;$A0 | |
50 dc.l empty_handler | |
51 dc.l empty_handler | |
52 dc.l empty_handler | |
53 dc.l empty_handler | |
54 ;$B0 | |
55 dc.l empty_handler | |
56 dc.l empty_handler | |
57 dc.l empty_handler | |
58 dc.l empty_handler | |
59 ;$C0 | |
60 dc.l empty_handler | |
61 dc.l empty_handler | |
62 dc.l empty_handler | |
63 dc.l empty_handler | |
64 ;$D0 | |
65 dc.l empty_handler | |
66 dc.l empty_handler | |
67 dc.l empty_handler | |
68 dc.l empty_handler | |
69 ;$E0 | |
70 dc.l empty_handler | |
71 dc.l empty_handler | |
72 dc.l empty_handler | |
73 dc.l empty_handler | |
74 ;$F0 | |
75 dc.l empty_handler | |
76 dc.l empty_handler | |
77 dc.l empty_handler | |
78 dc.l empty_handler | |
79 dc.b "SEGA" | |
80 empty_handler: | |
81 rte | |
82 start: | |
83 ;background and sprite test | |
84 | |
85 ButtonState equ $FFFFEFF0 | |
86 ButtonStateNew equ ButtonState+2 | |
87 PalAddress equ ButtonStateNew+2 | |
88 | |
89 CRAMXferSizeCmd equ $9308 | |
90 CRAMDMACmd equ $C0100080 | |
91 StaticColors equ 8 | |
92 | |
93 USE_HINT equ 0 | |
94 move.b #$40, $A10009 | |
95 move.l #$C00000, a4 | |
96 move.l #$c00004, a5 | |
97 | |
98 move.l #$0, a7 | |
99 | |
7
4ffd621f1d0c
Initialize VDP register 0 so it works on the Mega Everdrive. Temporarily disable the sprite stuff
Mike Pavone <pavone@retrodev.com>
parents:
3
diff
changeset
|
100 move.w #$8004, (a5) |
3 | 101 move.w #$8104, (a5) ;turn off display |
102 move.w #$8200, (a5) ;Table A = 0000 | |
103 move.w #$8400, (a5) ;Table B = 0000 | |
104 move.w #$857C, (a5) ;Sprite Table = F800 | |
105 move.w #$8B00, (a5) ;set full screen vertical and horizontal scrolling | |
106 move.w #$8C01, (a5) ;H40 mode, no shadow/hilight, no interlace | |
107 move.w #$8D3F, (a5) ;H Scroll = FC00 | |
108 move.w #$9001, (a5) ;64x32 scroll tables | |
109 | |
110 | |
111 | |
112 lea BgData(pc), a0 | |
113 move.w (a0)+, d0 ;size in words | |
114 move.w (a0)+, d1 ;width in cells | |
115 move.w (a0)+, d2 ;height in cells | |
116 move.w d2, d7 | |
117 | |
118 subq #1, d0 ;adjust for 68K dbra routine | |
119 move.w #$8f02, (a5) ;autoincrement = 2 | |
120 move.l #$50200000, (a5);beginning of background tile area | |
121 CopyTiles: | |
122 move.w (a0)+, (a4) ;copy tiles to VRAM | |
123 dbra d0, CopyTiles | |
124 | |
125 move.l #$40000000, d4 ;beginning of Plane A Name table | |
126 move.l #$00800000, d5 ;delta between lines | |
127 move.w #$81, d6 | |
128 subq #1, d1 | |
129 subq #1, d2 | |
130 move.w d1, d3 | |
131 WriteNamesY: | |
132 move.l d4, (a5) | |
133 move.w d3, d1 | |
134 | |
135 WriteNamesX: | |
136 move.w d6, (a4) | |
137 addq #1, d6 | |
138 dbra d1, WriteNamesX | |
139 | |
140 add.l d5, d4 | |
141 dbra d2, WriteNamesY | |
142 | |
143 move.l #$C0000000, (a5) ;setup writes to CRAM | |
144 moveq #(StaticColors-1), d0 ;copy first 12 colors (static pallete) | |
145 CopyColors: | |
146 move.w (a0)+, (a4) | |
147 dbra d0, CopyColors | |
148 | |
149 move.l a0, (PalAddress).w | |
150 | |
151 | |
152 move.l #$60000010, (a5) ;setup writes to VSRAM | |
153 move.w #$0, (a4) ;vscroll = 0 | |
154 | |
155 move.l #$7C000003, (a5) ;setup writes to HScroll Table FC00 | |
156 move.w #0, (a4) ;Plane A&B HScroll = 0; | |
157 move.w #0, (a4) ; | |
158 | |
159 move.l #$78000003, (a5) ;clear sprite table | |
160 move.l #0, (a4) | |
161 move.l #0, (a4) | |
162 | |
163 move.w #$8114, (a5) ;turn on DMA | |
164 | |
7
4ffd621f1d0c
Initialize VDP register 0 so it works on the Mega Everdrive. Temporarily disable the sprite stuff
Mike Pavone <pavone@retrodev.com>
parents:
3
diff
changeset
|
165 ;bsr InitSprites |
4ffd621f1d0c
Initialize VDP register 0 so it works on the Mega Everdrive. Temporarily disable the sprite stuff
Mike Pavone <pavone@retrodev.com>
parents:
3
diff
changeset
|
166 ;bsr AddSprite |
3 | 167 |
168 move.w #$0, (a0) | |
169 | |
7
4ffd621f1d0c
Initialize VDP register 0 so it works on the Mega Everdrive. Temporarily disable the sprite stuff
Mike Pavone <pavone@retrodev.com>
parents:
3
diff
changeset
|
170 ;bsr LoadSpritePal |
4ffd621f1d0c
Initialize VDP register 0 so it works on the Mega Everdrive. Temporarily disable the sprite stuff
Mike Pavone <pavone@retrodev.com>
parents:
3
diff
changeset
|
171 ;bsr InitFrameBigSprite |
3 | 172 moveq #0, d3 |
7
4ffd621f1d0c
Initialize VDP register 0 so it works on the Mega Everdrive. Temporarily disable the sprite stuff
Mike Pavone <pavone@retrodev.com>
parents:
3
diff
changeset
|
173 ;bsr ChangeFrameBigSprite |
3 | 174 |
175 | |
176 | |
177 move.l #CRAMDMACmd, d5 ;setup DMA command word | |
178 | |
179 move.w #CRAMXferSizeCmd, (a5) ;set Transfer length | |
180 move.w #$9400, (a5) | |
181 | |
182 move.w #$8114, d6 | |
183 move.w #$8174, d7 | |
184 | |
185 if USE_HINT | |
186 | |
187 move.w #$8014, (a5) | |
188 move.w #$8A00, (a5) ;HINT occurs on every line | |
189 endif | |
190 | |
191 move.w #$8174, (a5) | |
192 move #$2300, SR | |
193 | |
194 | |
195 Loop: | |
196 if USE_HINT | |
197 bra Loop | |
198 endif | |
199 WaitTop: | |
200 cmpi.b #$FF, 4(a5) | |
201 bne.s WaitTop | |
202 | |
203 LineDone: | |
204 move.b 4(a5), d0 | |
205 WaitNextLine: | |
206 cmp.b 4(a5), d0 | |
207 beq WaitNextLine | |
208 | |
209 | |
210 | |
211 HINT: | |
212 ;move.w d6, (a5) | |
213 ;move.l d5, (a5) ;start DMA | |
214 ;move.w d7, (a5) | |
215 move.l d6, (a5) | |
216 move.l d7, (a5) | |
217 move.w #CRAMXferSizeCmd, (a5) ;set Transfer length | |
218 move.w #$9400, (a5) | |
219 | |
220 if USE_HINT | |
221 rte | |
222 endif | |
223 | |
224 cmp.b #223, 4(a5) | |
225 beq WaitTop | |
226 | |
227 bra LineDone | |
228 | |
229 VINT: | |
230 if USE_HINT | |
231 move.w #$8144, (a5) | |
232 endif | |
7
4ffd621f1d0c
Initialize VDP register 0 so it works on the Mega Everdrive. Temporarily disable the sprite stuff
Mike Pavone <pavone@retrodev.com>
parents:
3
diff
changeset
|
233 ;bsr SpriteCopyVRAM |
3 | 234 |
235 bsr ReadPad | |
236 | |
7
4ffd621f1d0c
Initialize VDP register 0 so it works on the Mega Everdrive. Temporarily disable the sprite stuff
Mike Pavone <pavone@retrodev.com>
parents:
3
diff
changeset
|
237 ;bsr Player1Vint |
3 | 238 |
239 move.l (PalAddress).w, d7 ;setup DMA source address | |
240 move.w #$9500, d6 | |
241 ror.l #1, d7 | |
242 move.b d7, d6 | |
243 move.w d6, (a5) | |
244 ror.l #8, d7 | |
245 move.b d7, d6 | |
246 add.w #$100, d6 | |
247 move.w d6,(a5) | |
248 ror.l #8, d7 | |
249 move.b d7, d6 | |
250 add.w #$100, d6 | |
251 and.b #$7F, d6 | |
252 move.w d6,(a5) | |
253 | |
254 ;move.l d5, (a5) ;do DMA for first line | |
255 | |
256 move.w #CRAMXferSizeCmd, (a5) ;set Transfer length | |
257 move.w #$9400, (a5) | |
258 | |
259 move.w #$8114, d6 ;VDP commands to turn screen on and off during HBlank | |
260 swap d6 | |
261 swap d5 | |
262 move.w d5, d6 | |
263 swap d5 | |
264 move.w d5, d7 | |
265 swap d7 | |
266 move.w #$8174, d7 | |
267 if USE_HINT | |
268 move.w d7, (a5) | |
269 endif | |
270 rte | |
271 | |
272 LoadSpritePal: | |
273 move.l #$C0200000, (a5) | |
274 moveq #$F, d0 | |
275 lea SpriteData, a0 | |
276 PalLoop: | |
277 move.w (a0)+, (a4) | |
278 dbra d0, PalLoop | |
279 rts | |
280 | |
281 Player1Vint: | |
282 move.b (ButtonState).w, d2 | |
283 move.b (ButtonStateNew).w, d3 | |
284 | |
285 moveq #0, d0 | |
286 move.w d0, d1 | |
287 | |
288 btst #5, d2 | |
289 bne ScrollRight | |
290 | |
291 btst #7, d2 | |
292 bne ScrollLeft | |
293 | |
294 btst #4, d3 | |
295 bne IncrementFrame | |
296 | |
297 | |
298 btst #6, d3 | |
299 bne DecrementFrame | |
300 | |
301 btst #2, d2 | |
302 beq PlayerShipNotLeft | |
303 subq #1, d0 | |
304 PlayerShipNotLeft: | |
305 | |
306 btst #3, d2 | |
307 beq PlayerShipNotRight | |
308 addq #1, d0 | |
309 PlayerShipNotRight: | |
310 | |
311 btst #0, d2 | |
312 beq PlayerShipNotDown | |
313 subq #1, d1 | |
314 PlayerShipNotDown: | |
315 | |
316 btst #1, d2 | |
317 beq PlayerShipNotUp | |
318 addq #1, d1 | |
319 PlayerShipNotUp: | |
320 | |
321 bsr MoveBigSprite | |
322 | |
323 rts | |
324 IncrementFrame: | |
325 move.w (PlayerShipFrame), d3 | |
326 addq #1, d3 | |
327 move.w d3, (PlayerShipFrame) | |
328 bsr ChangeFrameBigSprite | |
329 | |
330 rts | |
331 | |
332 DecrementFrame: | |
333 | |
334 move.w (PlayerShipFrame), d3 | |
335 subq #1, d3 | |
336 move.w d3, (PlayerShipFrame) | |
337 bsr ChangeFrameBigSprite | |
338 | |
339 rts | |
340 | |
341 ScrollRight: | |
342 move.w (ScrollValue), d0 | |
343 subq #1, d0 | |
344 move.l #$7C000003, (a5) ;setup writes to HScroll Table FC00 | |
345 move.w d0, (a4) | |
346 move.w d0, (a4) | |
347 move.w d0, (ScrollValue) | |
348 | |
349 rts | |
350 | |
351 ScrollLeft: | |
352 move.w (ScrollValue), d0 | |
353 addq #1, d0 | |
354 move.l #$7C000003, (a5) ;setup writes to HScroll Table FC00 | |
355 move.w d0, (a4) | |
356 move.w d0, (a4) | |
357 move.w d0, (ScrollValue) | |
358 | |
359 rts | |
360 | |
361 include sprites.s68 | |
362 | |
363 PlayerShipFrame: | |
364 dc.w 0 | |
365 | |
366 | |
367 ScrollValue: | |
368 dc.w 0 | |
369 | |
370 ReadPad: | |
371 move.b #$FF, $a10003 ;set TH for controller A | |
372 move.b $a10003, d0 ;CBRLUD | |
373 andi.b #$3F, d0 | |
374 move.b #0, $a10003 | |
375 move.b $a10003, d1 ;SA00UD | |
376 andi.b #$30, d1 | |
377 lsl.b #2, d1 | |
378 or.b d1, d0 ;SACBRLUD | |
379 not.b d0 | |
380 move.b (ButtonState).w, d1 | |
381 eor.b d0, d1 | |
382 and.b d0, d1 | |
383 move.b d0, (ButtonState).w | |
384 move.b d1, (ButtonStateNew).w | |
385 | |
386 rts | |
387 | |
388 | |
389 SpriteData: | |
390 incbin bultest.bin | |
391 BgData: | |
392 incbin logo.bin | |
393 |