}\r
#endif\r
\r
+// BIOS faking for MSU-MD, checks for "SEGA" at 0x400100 to detect CD drive\r
+static u8 bios_id[4] = "SEGA";\r
+\r
+static u32 PicoReadM68k8_bios(u32 a)\r
+{\r
+ if ((a & 0xfffffc) == BASE+0x100) // CD detection by MSU\r
+ return bios_id[a&3];\r
+ return 0;\r
+}\r
+\r
+static u32 PicoReadM68k16_bios(u32 a)\r
+{\r
+ if ((a & 0xfffffc) == BASE+0x100) // CD detection by MSU\r
+ return (bios_id[a&2]<<8) | bios_id[(a&2)+1];\r
+ return 0;\r
+}\r
+\r
// RAM cart (400000 - 7fffff, optional)\r
static u32 PicoReadM68k8_ramc(u32 a)\r
{\r
u32 d = 0;\r
- if ((a & 0xf00001) == 0x400001) {\r
- if (Pico.sv.data != NULL)\r
- d = 3; // 64k cart\r
- return d;\r
- }\r
\r
- if ((a & 0xf00001) == 0x600001) {\r
- if (Pico.sv.data != NULL)\r
- d = Pico.sv.data[((a >> 1) & 0xffff) + 0x2000];\r
- return d;\r
- }\r
+ if (PicoIn.opt & POPT_EN_MCD_RAMCART) {\r
+ if ((a & 0xf00001) == 0x400001) {\r
+ if (Pico.sv.data != NULL)\r
+ d = 3; // 64k cart\r
+ return d;\r
+ }\r
+\r
+ if ((a & 0xf00001) == 0x600001) {\r
+ if (Pico.sv.data != NULL)\r
+ d = Pico.sv.data[((a >> 1) & 0xffff) + 0x2000];\r
+ return d;\r
+ }\r
\r
- if ((a & 0xf00001) == 0x700001)\r
- return Pico_mcd->m.bcram_reg;\r
+ if ((a & 0xf00001) == 0x700001)\r
+ return Pico_mcd->m.bcram_reg;\r
+ }\r
\r
elprintf(EL_UIO, "m68k unmapped r8 [%06x] @%06x", a, SekPc);\r
return d;\r
\r
static u32 PicoReadM68k16_ramc(u32 a)\r
{\r
- elprintf(EL_ANOMALY, "ramcart r16: [%06x] @%06x", a, SekPcS68k);\r
- if ((a & 0xfffffc) == BASE+0x100) // CD detection by MSU\r
- return (~a & 2) ? 0x5345 : 0x4741; // "SEGA"\r
+ elprintf(EL_ANOMALY, "ramcart r16: [%06x] @%06x", a, SekPc);\r
return PicoReadM68k8_ramc(a + 1);\r
}\r
\r
static void PicoWriteM68k8_ramc(u32 a, u32 d)\r
{\r
- if ((a & 0xf00001) == 0x600001) {\r
- if (Pico.sv.data != NULL && (Pico_mcd->m.bcram_reg & 1)) {\r
- Pico.sv.data[((a >> 1) & 0xffff) + 0x2000] = d;\r
- Pico.sv.changed = 1;\r
+ if (PicoIn.opt & POPT_EN_MCD_RAMCART) {\r
+ if ((a & 0xf00001) == 0x600001) {\r
+ if (Pico.sv.data != NULL && (Pico_mcd->m.bcram_reg & 1)) {\r
+ Pico.sv.data[((a >> 1) & 0xffff) + 0x2000] = d;\r
+ Pico.sv.changed = 1;\r
+ }\r
+ return;\r
}\r
- return;\r
- }\r
\r
- if ((a & 0xf00001) == 0x700001) {\r
- Pico_mcd->m.bcram_reg = d;\r
- return;\r
+ if ((a & 0xf00001) == 0x700001) {\r
+ Pico_mcd->m.bcram_reg = d;\r
+ return;\r
+ }\r
}\r
\r
elprintf(EL_UIO, "m68k unmapped w8 [%06x] %02x @%06x",\r
// setup default main68k map\r
PicoMemSetup();\r
\r
- // main68k map (BIOS mapped by PicoMemSetup()):\r
+ // main68k map (BIOS or MSU mapped by PicoMemSetup()):\r
+ if (Pico.romsize > 0x20000) {\r
+ // MSU cartridge. Fake BIOS detection\r
+ cpu68k_map_set(m68k_read8_map, 0x400000, 0x41ffff, PicoReadM68k8_bios, 1);\r
+ cpu68k_map_set(m68k_read16_map, 0x400000, 0x41ffff, PicoReadM68k16_bios, 1);\r
// RAM cart\r
- if (PicoIn.opt & POPT_EN_MCD_RAMCART) {\r
+ } else {\r
cpu68k_map_set(m68k_read8_map, 0x400000, 0x7fffff, PicoReadM68k8_ramc, 1);\r
cpu68k_map_set(m68k_read16_map, 0x400000, 0x7fffff, PicoReadM68k16_ramc, 1);\r
cpu68k_map_set(m68k_write8_map, 0x400000, 0x7fffff, PicoWriteM68k8_ramc, 1);\r
PIC_BT(m_m68k_read8_r0d)
m_m68k_read8_r00:
add r1, r1, #0x110000
- ldr r0, [r1, #0x30]
+ ldr r0, [r1, #0x30] @ Pico_mcd->s68k_regs
+ add r1, r1, #0x002200
+ ldr r1, [r1, #4] @ Pico_mcd->m.state_flags
and r0, r0, #0x04000000 @ we need irq2 mask state
mov r0, r0, lsr #19
+ and r1, r1, #0x00000100 @ irq2 pending
+ orr r0, r0, r1, lsr #8
bx lr
m_m68k_read8_r01:
add r1, r1, #0x110000
add r1, r1, #0x110000
ldr r0, [r1, #0x30]
add r1, r1, #0x002200
- ldrb r1, [r1, #2] @ Pico_mcd->m.busreq
+ ldrb r2, [r1, #2] @ Pico_mcd->m.busreq
+ ldr r1, [r1, #4]
and r0, r0, #0x04000000 @ we need irq2 mask state
- orr r0, r1, r0, lsr #11
+ orr r0, r2, r0, lsr #11
+ and r1, r1, #0x00000100 @ irq2 pending
+ orr r0, r1, r0
bx lr
m_m68k_read16_r02:
add r1, r1, #0x110000