testpico: 32x reset + other tests
[megadrive.git] / testpico / sega_gcc.s
index 1e0116a..52c9f8a 100644 (file)
@@ -23,9 +23,12 @@ exc_tab:
     .ascii "src: https://github.com/notaz/megadrive/" /* 1c8 */\r
     .ascii "JUE             "                         /* 1f0 */\r
 \r
+# 32X reset vector (880200)\r
+    bra     RST32X\r
+\r
 # mystery landing area for reset with 32X on and RV=1\r
 # 2c8 - 304 in multiples of 4\r
-.rept 0x1c0/2\r
+.rept 0x1bc/2\r
     illegal\r
 .endr\r
 \r
@@ -139,6 +142,23 @@ RST:
 #VBL:\r
 #    rte\r
 \r
+RST32X:\r
+    lea     ram_rv_switch, %a0\r
+    movea.l #0xff0100, %a1\r
+    lea     ram_rv_switch_end, %a2\r
+0:\r
+    move.l  (%a0)+, (%a1)+\r
+    cmp.l   %a2, %a0\r
+    blt.s   0b\r
+    jmp     (0xff0100).l\r
+\r
+ram_rv_switch:\r
+    move.l  (0x880004).l, %a0\r
+    bset    #0, (0xa15107).l  /* RV=1 */\r
+    nop                       /* just in case */\r
+    jmp     (%a0)\r
+ram_rv_switch_end:\r
+\r
 pre_exception:\r
     move.w  #0x2700, %sr\r
     movem.l %d0-%d7/%a0-%a7,-(%sp)\r
@@ -152,7 +172,7 @@ pre_exception:
 .macro exc_stub num\r
 exc\num:\r
     move.w #0x\num, -(%sp)\r
-    jmp pre_exception\r
+    bra pre_exception\r
 .endm\r
 \r
 exc_stub 02\r