megaed-sv: implement ROM load/run
[megadrive.git] / megaed-sv / sega_gcc.s
index 42e3d5f..0702158 100644 (file)
         .ascii "                         "\r
         .ascii "JUE             "\r
 \r
-/* magic ED app init */\r
 RST:\r
+       move.w          #0x2700, sr\r
+/* magic ED app init */\r
        move.w #0x0000, (0xA13006)\r
        jmp init_ed.l\r
 init_ed:\r
-       move.w #0x210f, (0xA13006)\r
+/* relocate to bank a, so that other ROMs can be loaded */\r
+       move.w #0x0a0f, (0xA13006)\r
+       movea.l #0x100000, %a0\r
+       movea.l #0x200000, %a1\r
+       move.l #0x100000/4/4-1, %d0\r
+0:\r
+       move.l (a0)+, (a1)+\r
+       move.l (a0)+, (a1)+\r
+       move.l (a0)+, (a1)+\r
+       move.l (a0)+, (a1)+\r
+       dbra %d0, 0b\r
+\r
+       move.w #0x10af, (0xA13006)\r
        move.l #HBL, (0x70)\r
        move.l #VBL, (0x78)\r
 \r
-       moveq   #0,%d0\r
-       movea.l %d0,%a7\r
-       move    %a7,%usp\r
+       moveq   #0, %d0\r
+       movea.l %d0, %a7\r
+       move    %a7, %usp\r
+       move.w  #0x2000, sr\r
        bra     main\r
 \r
 INT:\r