1 *-------------------------------------------------------
\r
3 * Sega startup code for the GNU Assembler
\r
5 * Sega startup code for the Sozobon C compiler
\r
6 * Written by Paul W. Lee
\r
7 * Modified from Charles Coty's code
\r
9 *-------------------------------------------------------
\r
12 dc.l INT,INT,INT,INT,INT,INT,INT
\r
13 dc.l INT,INT,INT,INT,INT,INT,INT,INT
\r
14 dc.l INT,INT,INT,INT,INT,INT,INT,INT
\r
15 dc.l INT,INT,INT,HBL,INT,VBL,INT,INT
\r
16 dc.l INT,INT,INT,INT,INT,INT,INT,INT
\r
17 dc.l INT,INT,INT,INT,INT,INT,INT,INT
\r
18 dc.l INT,INT,INT,INT,INT,INT,INT,INT
\r
19 dc.l INT,INT,INT,INT,INT,INT,INT
\r
20 .ascii "SEGA GENESIS "
\r
21 .ascii "notaz's Shadow / Hilight test "
\r
22 .ascii "NOTAZ'S SHADOW HILIGHT TEST "
\r
23 .ascii "GM 00000000-00"
\r
26 .byte 0x00,0x00,0x00,0x00,0x00,0x02,0x00,0x00
\r
27 .byte 0x00,0xff,0x00,0x00,0xff,0xff,0xff,0xff
\r
40 movem.w (%a5)+,%d5-%d7
\r
41 movem.l (%a5)+,%a0-%a4
\r
42 * Check Version Number
\r
43 move.b -0x10ff(%a1),%d0
\r
46 * Sega Security Code (SEGA)
\r
47 move.l #0x53454741,0x2f00(%a1)
\r
60 move.l (%a5)+,(%a4)
\r
67 * Put initial values into a00000
\r
70 move.b (%a5)+,(%a0)+
\r
78 move.l (%a5)+,(%a4)
\r
79 move.l (%a5)+,(%a4)
\r
80 * Put initial values into c00000
\r
85 move.l (%a5)+,(%a4)
\r
86 * Put initial values into c00000
\r
91 * Put initial values into c00011
\r
94 move.b (%a5)+,0x0011(%a3)
\r
97 movem.l (%a6),%d0-%d7/%a0-%a6
\r
102 dc.w 0x8000, 0x3fff, 0x0100, 0x00a0, 0x0000, 0x00a1, 0x1100, 0x00a1
\r
103 dc.w 0x1200, 0x00c0, 0x0000, 0x00c0, 0x0004, 0x0414, 0x302c, 0x0754
\r
104 dc.w 0x0000, 0x0000, 0x0000, 0x812b, 0x0001, 0x0100, 0x00ff, 0xff00
\r
105 dc.w 0x0080, 0x4000, 0x0080, 0xaf01, 0xd91f, 0x1127, 0x0021, 0x2600
\r
106 dc.w 0xf977, 0xedb0, 0xdde1, 0xfde1, 0xed47, 0xed4f, 0xd1e1, 0xf108
\r
107 dc.w 0xd9c1, 0xd1e1, 0xf1f9, 0xf3ed, 0x5636, 0xe9e9, 0x8104, 0x8f01
\r
108 dc.w 0xc000, 0x0000, 0x4000, 0x0010, 0x9fbf, 0xdfff
\r
113 * set stack pointer
\r
120 * clear Genesis RAM
\r
123 clrram: move.w #0,(%a0)+
\r
127 *----------------------------------------------------------
\r
129 * Load driver into the Z80 memory
\r
131 *----------------------------------------------------------
\r
134 move.w #0x100,0xa11100
\r
136 move.w #0x100,0xa11200
\r
140 move.l #Z80DriverEnd,%d0
\r
141 move.l #Z80Driver,%d1
\r
144 move.b (%a0)+,(%a1)+
\r
149 move.w #0x0,0xa11100
\r
151 *----------------------------------------------------------
\r
158 /* addq.l #1,htimer */
\r
162 /* addq.l #1,vtimer */
\r
167 *------------------------------------------------
\r
169 * Get a random number. This routine
\r
170 * was found in TOS.
\r
174 * d0 = random number
\r
176 *------------------------------------------------
\r
181 move.l rand_num,%d0
\r
187 move.l %d0,rand_num
\r
189 move.l #-1153374675,-(%sp)
\r
190 move.l rand_num,-(%sp)
\r
194 move.l %d0,rand_num
\r
197 and.l #16777215,%d0
\r
201 *------------------------------------------------
\r
203 * Copyright (c) 1988 by Sozobon, Limited. Author: Johann Ruegg
\r
205 * Permission is granted to anyone to use this software for any purpose
\r
206 * on any computer system, and to redistribute it freely, with the
\r
207 * following restrictions:
\r
208 * 1) No charge may be made other than reasonable charges for reproduction.
\r
209 * 2) Modified versions must be clearly marked as such.
\r
210 * 3) The authors are not responsible for any harmful consequences
\r
211 * of using this software, even if they result from defects in it.
\r
213 *------------------------------------------------
\r
225 bsr i_ldiv /* d0 = d0/d1 */
\r
242 bsr i_lmul /* d0 = d0*d1 */
\r
258 bsr i_ldiv /* d1 = d0%d1 */
\r
285 * A in d0, B in d1, return A*B in d0
\r
288 move.l %d3,%a2 /* save d3 */
\r
290 mulu %d0,%d2 /* d2 = Al * Bl */
\r
294 mulu %d0,%d3 /* d3 = Al * Bh */
\r
297 mulu %d1,%d0 /* d0 = Ah * Bl */
\r
299 add.l %d3,%d0 /* d0 = (Ah*Bl + Al*Bh) */
\r
301 clr.w %d0 /* d0 = (Ah*Bl + Al*Bh) << 16 */
\r
303 add.l %d2,%d0 /* d0 = A*B */
\r
304 move.l %a2,%d3 /* restore d3 */
\r
307 *A in d0, B in d1, return A/B in d0, A%B in d1
\r
314 * divu #0,%d0 /* cause trap */
\r
315 move.l #0x80000000,%d0
\r
319 move.l %d3,%a2 /* save d3 */
\r
323 * A<B, so ret 0, rem A
\r
326 move.l %a2,%d3 /* restore d3 */
\r
328 * A==B, so ret 1, rem 0
\r
332 move.l %a2,%d3 /* restore d3 */
\r
334 * A>B and B is not 0
\r
338 * B==1, so ret A, rem 0
\r
340 move.l %a2,%d3 /* restore d3 */
\r
342 * check for A short (implies B short also)
\r
346 * A short and B short -- use 'divu'
\r
347 divu %d1,%d0 /* d0 = REM:ANS */
\r
348 swap %d0 /* d0 = ANS:REM */
\r
350 move.w %d0,%d1 /* d1 = REM */
\r
353 move.l %a2,%d3 /* restore d3 */
\r
355 * check for B short
\r
359 * A long and B short -- use special stuff from gnu
\r
363 divu %d1,%d2 /* d2 = REM:ANS of Ahi/B */
\r
365 move.w %d2,%d3 /* d3 = Ahi/B */
\r
368 move.w %d0,%d2 /* d2 = REM << 16 + Alo */
\r
369 divu %d1,%d2 /* d2 = REM:ANS of stuff/B */
\r
373 swap %d1 /* d1 = REM */
\r
377 add.l %d3,%d0 /* d0 = ANS */
\r
378 move.l %a2,%d3 /* restore d3 */
\r
390 * we shifted B until its >A or sign bit set
\r
391 * we shifted #1 (d2) along with it
\r
401 * d3=answer, d0=rem
\r
404 move.l %a2,%d3 /* restore d3 */
\r
406 *----------------------------------------------------------
\r
410 *----------------------------------------------------------
\r
412 dc.b 0xc3,0x46,0x00,0x00,0x00,0x00,0x00,0x00
\r
413 dc.b 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
\r
414 dc.b 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
\r
415 dc.b 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
\r
416 dc.b 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
\r
417 dc.b 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
\r
418 dc.b 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
\r
419 dc.b 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
\r
420 dc.b 0x00,0x00,0x00,0x00,0x00,0x00,0xf3,0xed
\r
421 dc.b 0x56,0x31,0x00,0x20,0x3a,0x39,0x00,0xb7
\r
422 dc.b 0xca,0x4c,0x00,0x21,0x3a,0x00,0x11,0x40
\r
423 dc.b 0x00,0x01,0x06,0x00,0xed,0xb0,0x3e,0x00
\r
424 dc.b 0x32,0x39,0x00,0x3e,0xb4,0x32,0x02,0x40
\r
425 dc.b 0x3e,0xc0,0x32,0x03,0x40,0x3e,0x2b,0x32
\r
426 dc.b 0x00,0x40,0x3e,0x80,0x32,0x01,0x40,0x3a
\r
427 dc.b 0x43,0x00,0x4f,0x3a,0x44,0x00,0x47,0x3e
\r
428 dc.b 0x06,0x3d,0xc2,0x81,0x00,0x21,0x00,0x60
\r
429 dc.b 0x3a,0x41,0x00,0x07,0x77,0x3a,0x42,0x00
\r
430 dc.b 0x77,0x0f,0x77,0x0f,0x77,0x0f,0x77,0x0f
\r
431 dc.b 0x77,0x0f,0x77,0x0f,0x77,0x0f,0x77,0x3a
\r
432 dc.b 0x40,0x00,0x6f,0x3a,0x41,0x00,0xf6,0x80
\r
433 dc.b 0x67,0x3e,0x2a,0x32,0x00,0x40,0x7e,0x32
\r
434 dc.b 0x01,0x40,0x21,0x40,0x00,0x7e,0xc6,0x01
\r
435 dc.b 0x77,0x23,0x7e,0xce,0x00,0x77,0x23,0x7e
\r
436 dc.b 0xce,0x00,0x77,0x3a,0x39,0x00,0xb7,0xc2
\r
437 dc.b 0x4c,0x00,0x0b,0x78,0xb1,0xc2,0x7f,0x00
\r
438 dc.b 0x3a,0x45,0x00,0xb7,0xca,0x4c,0x00,0x3d
\r
439 dc.b 0x3a,0x45,0x00,0x06,0xff,0x0e,0xff,0xc3
\r