-*------------------------------------------------\r
-*\r
-* Get a random number. This routine\r
-* was found in TOS.\r
-*\r
-* Output\r
-* ------\r
-* d0 = random number\r
-*\r
-*------------------------------------------------\r
-\r
- .globl random\r
-\r
-random:\r
- move.l rand_num,%d0\r
- tst.l %d0\r
- bne .L1\r
- moveq #16,%d1\r
- lsl.l %d1,%d0\r
- or.l htimer,%d0\r
- move.l %d0,rand_num\r
-.L1:\r
- move.l #-1153374675,-(%sp)\r
- move.l rand_num,-(%sp)\r
- bsr lmul\r
- addq.w #8,%sp\r
- addq.l #1,%d0\r
- move.l %d0,rand_num\r
-\r
- lsr.l #8,%d0\r
- and.l #16777215,%d0\r
- rts\r
-\r
-\r
-*------------------------------------------------\r
-*\r
-* Copyright (c) 1988 by Sozobon, Limited. Author: Johann Ruegg\r
-*\r
-* Permission is granted to anyone to use this software for any purpose\r
-* on any computer system, and to redistribute it freely, with the\r
-* following restrictions:\r
-* 1) No charge may be made other than reasonable charges for reproduction.\r
-* 2) Modified versions must be clearly marked as such.\r
-* 3) The authors are not responsible for any harmful consequences\r
-* of using this software, even if they result from defects in it.\r
-*\r
-*------------------------------------------------\r
-\r
-ldiv:\r
- move.l 4(%a7),%d0\r
- bpl ld1\r
- neg.l %d0\r
-ld1:\r
- move.l 8(%a7),%d1\r
- bpl ld2\r
- neg.l %d1\r
- eor.b #0x80,4(%a7)\r
-ld2:\r
- bsr i_ldiv /* d0 = d0/d1 */\r
- tst.b 4(%a7)\r
- bpl ld3\r
- neg.l %d0\r
-ld3:\r
- rts\r
-\r
-lmul:\r
- move.l 4(%a7),%d0\r
- bpl lm1\r
- neg.l %d0\r
-lm1:\r
- move.l 8(%a7),%d1\r
- bpl lm2\r
- neg.l %d1\r
- eor.b #0x80,4(%a7)\r
-lm2:\r
- bsr i_lmul /* d0 = d0*d1 */\r
- tst.b 4(%a7)\r
- bpl lm3\r
- neg.l %d0\r
-lm3:\r
- rts\r
-\r
-lrem:\r
- move.l 4(%a7),%d0\r
- bpl lr1\r
- neg.l %d0\r
-lr1:\r
- move.l 8(%a7),%d1\r
- bpl lr2\r
- neg.l %d1\r
-lr2:\r
- bsr i_ldiv /* d1 = d0%d1 */\r
- move.l %d1,%d0\r
- tst.b 4(%a7)\r
- bpl lr3\r
- neg.l %d0\r
-lr3:\r
- rts\r
-\r
-ldivu:\r
- move.l 4(%a7),%d0\r
- move.l 8(%a7),%d1\r
- bsr i_ldiv\r
- rts\r
-\r
-lmulu:\r
- move.l 4(%a7),%d0\r
- move.l 8(%a7),%d1\r
- bsr i_lmul\r
- rts\r
-\r
-lremu:\r
- move.l 4(%a7),%d0\r
- move.l 8(%a7),%d1\r
- bsr i_ldiv\r
- move.l %d1,%d0\r
- rts\r
-*\r
-* A in d0, B in d1, return A*B in d0\r
-*\r
-i_lmul:\r
- move.l %d3,%a2 /* save d3 */\r
- move.w %d1,%d2\r
- mulu %d0,%d2 /* d2 = Al * Bl */\r
-\r
- move.l %d1,%d3\r
- swap %d3\r
- mulu %d0,%d3 /* d3 = Al * Bh */\r
-\r
- swap %d0\r
- mulu %d1,%d0 /* d0 = Ah * Bl */\r
-\r
- add.l %d3,%d0 /* d0 = (Ah*Bl + Al*Bh) */\r
- swap %d0\r
- clr.w %d0 /* d0 = (Ah*Bl + Al*Bh) << 16 */\r
-\r
- add.l %d2,%d0 /* d0 = A*B */\r
- move.l %a2,%d3 /* restore d3 */\r
- rts\r
-*\r
-*A in d0, B in d1, return A/B in d0, A%B in d1\r
-*\r
-i_ldiv:\r
- tst.l %d1\r
- bne nz1\r
-\r
-* divide by zero\r
-* divu #0,%d0 /* cause trap */\r
- move.l #0x80000000,%d0\r
- move.l %d0,%d1\r
- rts\r
-nz1:\r
- move.l %d3,%a2 /* save d3 */\r
- cmp.l %d1,%d0\r
- bhi norm\r
- beq is1\r
-* A<B, so ret 0, rem A\r
- move.l %d0,%d1\r
- clr.l %d0\r
- move.l %a2,%d3 /* restore d3 */\r
- rts\r
-* A==B, so ret 1, rem 0\r
-is1:\r
- moveq.l #1,%d0\r
- clr.l %d1\r
- move.l %a2,%d3 /* restore d3 */\r
- rts\r
-* A>B and B is not 0\r
-norm:\r
- cmp.l #1,%d1\r
- bne not1\r
-* B==1, so ret A, rem 0\r
- clr.l %d1\r
- move.l %a2,%d3 /* restore d3 */\r
- rts\r
-* check for A short (implies B short also)\r
-not1:\r
- cmp.l #0xffff,%d0\r
- bhi slow\r
-* A short and B short -- use 'divu'\r
- divu %d1,%d0 /* d0 = REM:ANS */\r
- swap %d0 /* d0 = ANS:REM */\r
- clr.l %d1\r
- move.w %d0,%d1 /* d1 = REM */\r
- clr.w %d0\r
- swap %d0\r
- move.l %a2,%d3 /* restore d3 */\r
- rts\r
-* check for B short\r
-slow:\r
- cmp.l #0xffff,%d1\r
- bhi slower\r
-* A long and B short -- use special stuff from gnu\r
- move.l %d0,%d2\r
- clr.w %d2\r
- swap %d2\r
- divu %d1,%d2 /* d2 = REM:ANS of Ahi/B */\r
- clr.l %d3\r
- move.w %d2,%d3 /* d3 = Ahi/B */\r
- swap %d3\r
-\r
- move.w %d0,%d2 /* d2 = REM << 16 + Alo */\r
- divu %d1,%d2 /* d2 = REM:ANS of stuff/B */\r
-\r
- move.l %d2,%d1\r
- clr.w %d1\r
- swap %d1 /* d1 = REM */\r
-\r
- clr.l %d0\r
- move.w %d2,%d0\r
- add.l %d3,%d0 /* d0 = ANS */\r
- move.l %a2,%d3 /* restore d3 */\r
- rts\r
-* A>B, B > 1\r
-slower:\r
- move.l #1,%d2\r
- clr.l %d3\r
-moreadj:\r
- cmp.l %d0,%d1\r
- bhs adj\r
- add.l %d2,%d2\r
- add.l %d1,%d1\r
- bpl moreadj\r
-* we shifted B until its >A or sign bit set\r
-* we shifted #1 (d2) along with it\r
-adj:\r
- cmp.l %d0,%d1\r
- bhi ltuns\r
- or.l %d2,%d3\r
- sub.l %d1,%d0\r
-ltuns:\r
- lsr.l #1,%d1\r
- lsr.l #1,%d2\r
- bne adj\r
-* d3=answer, d0=rem\r
- move.l %d0,%d1\r
- move.l %d3,%d0\r
- move.l %a2,%d3 /* restore d3 */\r
- rts\r
-*---------------------------------------------------------- \r
-*\r
-* Z80 Sound Driver\r
-*\r
-*---------------------------------------------------------- \r
-Z80Driver:\r
- dc.b 0xc3,0x46,0x00,0x00,0x00,0x00,0x00,0x00\r
- dc.b 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00\r
- dc.b 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00\r
- dc.b 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00\r
- dc.b 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00\r
- dc.b 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00\r
- dc.b 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00\r
- dc.b 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00\r
- dc.b 0x00,0x00,0x00,0x00,0x00,0x00,0xf3,0xed\r
- dc.b 0x56,0x31,0x00,0x20,0x3a,0x39,0x00,0xb7\r
- dc.b 0xca,0x4c,0x00,0x21,0x3a,0x00,0x11,0x40\r
- dc.b 0x00,0x01,0x06,0x00,0xed,0xb0,0x3e,0x00\r
- dc.b 0x32,0x39,0x00,0x3e,0xb4,0x32,0x02,0x40\r
- dc.b 0x3e,0xc0,0x32,0x03,0x40,0x3e,0x2b,0x32\r
- dc.b 0x00,0x40,0x3e,0x80,0x32,0x01,0x40,0x3a\r
- dc.b 0x43,0x00,0x4f,0x3a,0x44,0x00,0x47,0x3e\r
- dc.b 0x06,0x3d,0xc2,0x81,0x00,0x21,0x00,0x60\r
- dc.b 0x3a,0x41,0x00,0x07,0x77,0x3a,0x42,0x00\r
- dc.b 0x77,0x0f,0x77,0x0f,0x77,0x0f,0x77,0x0f\r
- dc.b 0x77,0x0f,0x77,0x0f,0x77,0x0f,0x77,0x3a\r
- dc.b 0x40,0x00,0x6f,0x3a,0x41,0x00,0xf6,0x80\r
- dc.b 0x67,0x3e,0x2a,0x32,0x00,0x40,0x7e,0x32\r
- dc.b 0x01,0x40,0x21,0x40,0x00,0x7e,0xc6,0x01\r
- dc.b 0x77,0x23,0x7e,0xce,0x00,0x77,0x23,0x7e\r
- dc.b 0xce,0x00,0x77,0x3a,0x39,0x00,0xb7,0xc2\r
- dc.b 0x4c,0x00,0x0b,0x78,0xb1,0xc2,0x7f,0x00\r
- dc.b 0x3a,0x45,0x00,0xb7,0xca,0x4c,0x00,0x3d\r
- dc.b 0x3a,0x45,0x00,0x06,0xff,0x0e,0xff,0xc3\r
- dc.b 0x7f,0x00\r
-Z80DriverEnd:\r
-\r
+* VBL:\r
+* addq.l #1,(vtimer).l\r
+* rte\r
+\r
+* Standard 32X startup code for MD side at 0x3F0\r
+ .org 0x3F0\r
+\r
+ .word 0x287C,0xFFFF,0xFFC0,0x23FC,0x0000,0x0000,0x00A1,0x5128\r
+ .word 0x46FC,0x2700,0x4BF9,0x00A1,0x0000,0x7001,0x0CAD,0x4D41\r
+ .word 0x5253,0x30EC,0x6600,0x03E6,0x082D,0x0007,0x5101,0x67F8\r
+ .word 0x4AAD,0x0008,0x6710,0x4A6D,0x000C,0x670A,0x082D,0x0000\r
+ .word 0x5101,0x6600,0x03B8,0x102D,0x0001,0x0200,0x000F,0x6706\r
+ .word 0x2B78,0x055A,0x4000,0x7200,0x2C41,0x4E66,0x41F9,0x0000\r
+ .word 0x04D4,0x6100,0x0152,0x6100,0x0176,0x47F9,0x0000,0x04E8\r
+ .word 0x43F9,0x00A0,0x0000,0x45F9,0x00C0,0x0011,0x3E3C,0x0100\r
+ .word 0x7000,0x3B47,0x1100,0x3B47,0x1200,0x012D,0x1100,0x66FA\r
+ .word 0x7425,0x12DB,0x51CA,0xFFFC,0x3B40,0x1200,0x3B40,0x1100\r
+ .word 0x3B47,0x1200,0x149B,0x149B,0x149B,0x149B,0x41F9,0x0000\r
+ .word 0x04C0,0x43F9,0x00FF,0x0000,0x22D8,0x22D8,0x22D8,0x22D8\r
+ .word 0x22D8,0x22D8,0x22D8,0x22D8,0x41F9,0x00FF,0x0000,0x4ED0\r
+ .word 0x1B7C,0x0001,0x5101,0x41F9,0x0000,0x06BC,0xD1FC,0x0088\r
+ .word 0x0000,0x4ED0,0x0404,0x303C,0x076C,0x0000,0x0000,0xFF00\r
+ .word 0x8137,0x0002,0x0100,0x0000,0xAF01,0xD91F,0x1127,0x0021\r
+ .word 0x2600,0xF977,0xEDB0,0xDDE1,0xFDE1,0xED47,0xED4F,0xD1E1\r
+ .word 0xF108,0xD9C1,0xD1E1,0xF1F9,0xF3ED,0x5636,0xE9E9,0x9FBF\r
+ .word 0xDFFF,0x4D41,0x5253,0x2049,0x6E69,0x7469,0x616C,0x2026\r
+ .word 0x2053,0x6563,0x7572,0x6974,0x7920,0x5072,0x6F67,0x7261\r
+ .word 0x6D20,0x2020,0x2020,0x2020,0x2020,0x2043,0x6172,0x7472\r
+ .word 0x6964,0x6765,0x2056,0x6572,0x7369,0x6F6E,0x2020,0x2020\r
+ .word 0x436F,0x7079,0x7269,0x6768,0x7420,0x5345,0x4741,0x2045\r
+ .word 0x4E54,0x4552,0x5052,0x4953,0x4553,0x2C4C,0x5444,0x2E20\r
+ .word 0x3139,0x3934,0x2020,0x2020,0x2020,0x2020,0x2020,0x2020\r
+ .word 0x2020,0x2020,0x2020,0x2020,0x2020,0x2020,0x2020,0x2020\r
+ .word 0x2020,0x2020,0x2020,0x524F,0x4D20,0x5665,0x7273,0x696F\r
+ .word 0x6E20,0x312E,0x3000,0x48E7,0xC040,0x43F9,0x00C0,0x0004\r
+ .word 0x3011,0x303C,0x8000,0x323C,0x0100,0x3E3C,0x0012,0x1018\r
+ .word 0x3280,0xD041,0x51CF,0xFFF8,0x4CDF,0x0203,0x4E75,0x48E7\r
+ .word 0x81C0,0x41F9,0x0000,0x063E,0x43F9,0x00C0,0x0004,0x3298\r
+ .word 0x3298,0x3298,0x3298,0x3298,0x3298,0x3298,0x2298,0x3341\r
+ .word 0xFFFC,0x3011,0x0800,0x0001,0x66F8,0x3298,0x3298,0x7000\r
+ .word 0x22BC,0xC000,0x0000,0x7E0F,0x3340,0xFFFC,0x3340,0xFFFC\r
+ .word 0x3340,0xFFFC,0x3340,0xFFFC,0x51CF,0xFFEE,0x22BC,0x4000\r
+ .word 0x0010,0x7E09,0x3340,0xFFFC,0x3340,0xFFFC,0x3340,0xFFFC\r
+ .word 0x3340,0xFFFC,0x51CF,0xFFEE,0x4CDF,0x0381,0x4E75,0x8114\r
+ .word 0x8F01,0x93FF,0x94FF,0x9500,0x9600,0x9780,0x4000,0x0080\r
+ .word 0x8104,0x8F02,0x48E7,0xC140,0x43F9,0x00A1,0x5180,0x08A9\r
+ .word 0x0007,0xFF80,0x66F8,0x3E3C,0x00FF,0x7000,0x7200,0x337C\r
+ .word 0x00FF,0x0004,0x3341,0x0006,0x3340,0x0008,0x4E71,0x0829\r
+ .word 0x0001,0x000B,0x66F8,0x0641,0x0100,0x51CF,0xFFE8,0x4CDF\r
+ .word 0x0283,0x4E75,0x48E7,0x8180,0x41F9,0x00A1,0x5200,0x08A8\r
+ .word 0x0007,0xFF00,0x66F8,0x3E3C,0x001F,0x20C0,0x20C0,0x20C0\r
+ .word 0x20C0,0x51CF,0xFFF6,0x4CDF,0x0181,0x4E75,0x41F9,0x00FF\r
+ .word 0x0000,0x3E3C,0x07FF,0x7000,0x20C0,0x20C0,0x20C0,0x20C0\r
+ .word 0x20C0,0x20C0,0x20C0,0x20C0,0x51CF,0xFFEE,0x3B7C,0x0000\r
+ .word 0x1200,0x7E0A,0x51CF,0xFFFE,0x43F9,0x00A1,0x5100,0x7000\r
+ .word 0x2340,0x0020,0x2340,0x0024,0x1B7C,0x0003,0x5101,0x2E79\r
+ .word 0x0088,0x0000,0x0891,0x0007,0x66FA,0x7000,0x3340,0x0002\r
+ .word 0x3340,0x0004,0x3340,0x0006,0x2340,0x0008,0x2340,0x000C\r
+ .word 0x3340,0x0010,0x3340,0x0030,0x3340,0x0032,0x3340,0x0038\r
+ .word 0x3340,0x0080,0x3340,0x0082,0x08A9,0x0000,0x008B,0x66F8\r
+ .word 0x6100,0xFF12,0x08E9,0x0000,0x008B,0x67F8,0x6100,0xFF06\r
+ .word 0x08A9,0x0000,0x008B,0x6100,0xFF3C,0x303C,0x0040,0x2229\r
+ .word 0x0020,0x0C81,0x5351,0x4552,0x6700,0x0092,0x303C,0x0080\r
+ .word 0x2229,0x0020,0x0C81,0x5344,0x4552,0x6700,0x0080,0x21FC\r
+ .word 0x0088,0x02A2,0x0070,0x303C,0x0002,0x7200,0x122D,0x0001\r
+ .word 0x1429,0x0080,0xE14A,0x8242,0x0801,0x000F,0x660A,0x0801\r
+ .word 0x0006,0x6700,0x0058,0x6008,0x0801,0x0006,0x6600,0x004E\r
+ .word 0x7020,0x41F9,0x0088,0x0000,0x3C28,0x018E,0x4A46,0x6700\r
+ .word 0x0010,0x3429,0x0028,0x0C42,0x0000,0x67F6,0xB446,0x662C\r
+ .word 0x7000,0x2340,0x0028,0x2340,0x002C,0x3E14,0x2C7C,0xFFFF\r
+ .word 0xFFC0,0x4CD6,0x7FF9,0x44FC,0x0000,0x6014,0x43F9,0x00A1\r
+ .word 0x5100,0x3340,0x0006,0x303C,0x8000,0x6004,0x44FC,0x0001\r