void read_joy_responses(u8 resp[8*5]);
+void run_game(u16 mapper);
.endm
-.globl read_joy_responses /* u8 *rbuf */
+.global read_joy_responses /* u8 *rbuf */
read_joy_responses:
ldarg 0, 0, a1
movem.l d2-d7, -(sp)
rts
+.global run_game /* u16 mapper */
+run_game:
+ move.w #0x2700, sr
+ ldarg 0, 0, d7
+ move.l #0xa10000, a7
+ moveq.l #0x00, d1
+ move.b #0xff, d2
+ move.b d1, (0x0b,a7) /* CtrlB */
+ move.b d1, (0x0d,a7) /* CtrlC */
+ move.b d2, (0x0f,a7) /* TxDataA */
+ move.b d1, (0x13,a7) /* S-CtrlA */
+ move.b d2, (0x15,a7) /* TxDataB */
+ move.b d1, (0x19,a7) /* S-CtrlB */
+ move.b d2, (0x1b,a7) /* TxDataC */
+ move.b d1, (0x1f,a7) /* S-CtrlC */
+
+ move.l #0xff0000, a1
+ move.l #0x10000/4/4-1, %d0
+0:
+ move.l d1, (%a1)+
+ move.l d1, (%a1)+
+ move.l d1, (%a1)+
+ move.l d1, (%a1)+
+ dbra d0, 0b
+
+ lea (run_game_code,pc), a0
+ move.l #0xfff000, a1
+ move.l #(run_game_code_end - run_game_code)/2-1, d0
+0:
+ move.w (%a0)+, (%a1)+
+ dbra d0, 0b
+ jmp 0xfff000
+
+run_game_code:
+ move.w #0x3210, (0xA13006)
+
+ move.w d7, (0xA13010)
+ move.w #0, (0xA13000)
+
+ move.l (0x00), a7
+ move.l (0x04), a0
+ jmp (a0)
+run_game_code_end:
+
+
# vim:filetype=asmM68k:ts=4:sw=4:expandtab
#define APLANE (TILE_MEM_END + 0x1000)
#define BPLANE (TILE_MEM_END + 0x3000)
+#define read8(a) \
+ *((volatile u8 *) (a))
+#define read16(a) \
+ *((volatile u16 *) (a))
+#define read32(a) \
+ *((volatile u32 *) (a))
#define write16(a, d) \
*((volatile u16 *) (a)) = (d)
#define write32(a, d) \
return -1;
}
+#define MTYPE_OS 0
+#define MTYPE_MD 1
+#define MTYPE_SSF 2
+#define MTYPE_CD 3
+#define MTYPE_SMS 4
+#define MTYPE_10M 5
+#define MTYPE_32X 6
+
+static int do_run(OsRoutine *ed, u8 b3)
+{
+ u8 mapper = 0;
+
+ switch (b3)
+ {
+ case 's':
+ mapper = MTYPE_SMS | (7 << 4);
+ break;
+ case 'm':
+ mapper = MTYPE_MD;
+ break;
+ case 'o':
+ mapper = MTYPE_OS;
+ break;
+ case 'c':
+ mapper = MTYPE_CD;
+ break;
+ case '3':
+ mapper = MTYPE_32X;
+ break;
+ case 'M':
+ mapper = MTYPE_10M;
+ break;
+ default:
+ return -1;
+ }
+
+ while (read32(GFX_CTRL_PORT) & 2)
+ ;
+ ed->VDP_setReg(VDP_MODE1, 0x04);
+ ed->VDP_setReg(VDP_MODE2, 0x44);
+
+ ed->usbWriteByte('k');
+
+ run_game(mapper);
+ /* should not get here.. */
+
+ return -1;
+}
+
int main()
{
OsRoutine *ed;
u8 buf[16];
+ int len;
int i, d, ret;
ed = (OsRoutine *) *(u32 *)0x1A0;
/* note: relying on ED menu's font setup here.. */
+ printf("version: %02x\n", read8(0xa10001));
+ printf("ED os/fw: %x/%x\n\n", ed->osGetOsVersion(),
+ ed->osGetFirmVersion());
+
for (;;) {
if (!ed->usbRdReady()) {
asm volatile("stop #0x2000");
case 'T':
ed->usbWriteByte('k');
break;
+ case 'g':
+ len = ed->usbReadByte() * 128;
+ printf("loading %d bytes.. ", len * 512);
+ ed->usbWriteByte('k');
+ ed->usbReadDma((void *)0x200000, len);
+ ed->usbWriteByte('d');
+ printf("done\n");
+ break;
+ case 'r':
+ buf[2] = ed->usbReadByte();
+ ret = do_run(ed, buf[2]);
+ if (ret != 0) {
+ d = 3;
+ goto bad_input;
+ }
+ printf("run returned??\n");
+ break;
+
/* custom */
case 't':
buf[2] = ed->usbReadByte();
.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