testpico: adjust for irixxxx's PD, 32x disable
[megadrive.git] / testpico / asmtools.S
index a2c40fd..811f35d 100644 (file)
@@ -73,6 +73,8 @@ write_and_read1:
 #ifndef PICO
     move.w      d0, (a0)
 #else
+    /* different timing due to extra fetch of offset, */
+    /* less troulesome to emulate */
     movea.l     a0, a1
     subq.l      #1, a1
     move.w      d0, 1(a1)
@@ -99,6 +101,11 @@ move_sr_and_read:
     move.w      (a0), d0
     rts
 
+.global read_sr
+read_sr:
+    move.w      sr, d0
+    rts
+
 .global memcpy_ /* void *dst, const void *src, u16 size */
 memcpy_:
     ldarg       0, 0, a0
@@ -186,7 +193,7 @@ test_vcnt_vb:
     move.l      d4, (a2)+   /* *ram++ = count */
 
     movem.l     (sp)+, d2-d7/a2
-       rts
+    rts
 
 .global test_hint
 test_hint:
@@ -199,7 +206,7 @@ test_hint:
 0:
     move.w      d0, (0xf004).w    /* 12 */
     move.w      (sp)+, d0         /*  8 */
-    rte                           /* 20 114 */
+    rte                           /* 20 114+44 */
 .global test_hint_end
 test_hint_end:
 
@@ -218,6 +225,55 @@ test_vint:
 .global test_vint_end
 test_vint_end:
 
+.global x32x_enable
+x32x_enable:
+    movea.l     #0xa15100, a0
+    movea.l     #0xa15122, a1
+    move.w      #1, (a0)          /* ADEN */
+# wait for min(20_sh2_cycles, pll_setup_time)
+# pll time is unclear, icd_mars.prg mentions 10ms which sounds
+# way too much. Hope 40 68k cycles is enough
+    move.w      #40/10, d0
+0:
+    dbra        d0, 0b
+    move.w      #3, (a0)          /* ADEN, nRES */
+0:
+    move.w      #0xffff, d0       /* waste some cycles */
+    tst.w       (a1)
+    beq         0b                /* master BIOS busy */
+
+0:                                /* for slave, use a limit, as it */
+    tst.w       4(a1)             /* won't respond on master error. */
+    dbne        d0, 0b            /* slave BIOS busy */
+
+    or.w        #1, 6(a0)         /* RV */
+    rts
+.global x32x_enable_end
+x32x_enable_end:
+
+.global x32x_disable
+x32x_disable:
+    movea.l     #0xa15100, a0
+    move.w      #1, (a0)          /* ADEN (reset sh2) */
+    move.w      #0, (a0)          /* adapter disable, reset sh2 */
+    move.w      #1, d0
+0:
+    dbra        d0, 0b
+    move.w      #2, (a0)          /* nRES - sh2s should see no ADEN and sleep */
+    rts
+.global x32x_disable_end
+x32x_disable_end:
+
+.global test_32x_b_c0
+test_32x_b_c0:
+    ldarg       0, 0, a1
+    ldargw      1, 0, d0
+    jsr         (0xc0).l          /* move.b d0, (a1); RV=0 */
+    bset        #0, (0xa15107).l  /* RV=1 */
+    rts
+.global test_32x_b_c0_end
+test_32x_b_c0_end:
+
 # some nastyness from Fatal Rewind
 .global test_h_v_2
 test_h_v_2:
@@ -285,7 +341,7 @@ test_f:
     test_lb_s   d4, a0
     test_lb_s   d5, a0
     movem.l     (sp)+, d2-d7/a2
-       rts
+    rts
 
 .global test_hb
 test_hb:
@@ -320,6 +376,6 @@ test_hb:
     test_lb_s   d6, a1
     test_lb_s   d7, a1
     movem.l     (sp)+, d2-d7
-       rts
+    rts
 
 # vim:filetype=asmM68k:ts=4:sw=4:expandtab