// This will hang the emu, but will prevent nasty crashes.\r
// note: 4 bytes are padded to every ROM\r
if (rom != NULL)\r
- *(u32 *)(rom+romsize) = CPU_BE2(0x4EFAFFFE);\r
+ *(u32 *)(rom+romsize) = CPU_BE2(0x6000FFFE);\r
\r
Pico.rom=rom;\r
Pico.romsize=romsize;\r
#endif\r
\r
#if defined(EMU_C68K)\r
-void cyclone_crashed(u32 pc, struct Cyclone *context)\r
+u32 cyclone_crashed(u32 pc, struct Cyclone *context)\r
{\r
- elprintf(EL_STATUS|EL_ANOMALY, "%c68k crash detected @ %06x",\r
- context == &PicoCpuCM68k ? 'm' : 's', pc);\r
+ // check for underlying ROM, in case of on-cart hw overlaying part of ROM\r
+ // NB assumes code isn't executed from the overlay, but I've never seen this\r
+ u32 pc24 = pc & 0xffffff;\r
+ if (pc24 >= Pico.romsize) {\r
+ // no ROM, so it's probably an illegal access\r
+ pc24 = Pico.romsize;\r
+ elprintf(EL_STATUS|EL_ANOMALY, "%c68k crash detected @ %06x",\r
+ context == &PicoCpuCM68k ? 'm' : 's', pc);\r
+ }\r
+\r
context->membase = (u32)Pico.rom;\r
- context->pc = (u32)Pico.rom + Pico.romsize;\r
+ context->pc = (u32)Pico.rom + pc24;\r
+\r
+ return context->pc;\r
}\r
#endif\r
\r