PicoReset();\r
}\r
\r
-int PicoReset(void)\r
+PICO_INTERNAL void PicoDetectRegion(void)\r
{\r
- unsigned int region=0;\r
- int support=0,hw=0,i=0;\r
+ int support=0, hw=0, i;\r
unsigned char pal=0;\r
- unsigned char sram_reg=Pico.m.sram_reg; // must be preserved\r
-\r
- if (Pico.romsize<=0) return 1;\r
-\r
- /* must call now, so that banking is reset, and correct vectors get fetched */\r
- if (PicoResetHook) PicoResetHook();\r
-\r
- PicoMemReset();\r
- SekReset();\r
- // s68k doesn't have the TAS quirk, so we just globally set normal TAS handler in MCD mode (used by Batman games).\r
- SekSetRealTAS(PicoAHW & PAHW_MCD);\r
- SekCycleCntT=0;\r
\r
- if (PicoAHW & PAHW_MCD)\r
- // needed for MCD to reset properly, probably some bug hides behind this..\r
- memset(Pico.ioports,0,sizeof(Pico.ioports));\r
- emustatus = 0;\r
-\r
- Pico.m.dirtyPal = 1;\r
-\r
- if(PicoRegionOverride)\r
+ if (PicoRegionOverride)\r
{\r
support = PicoRegionOverride;\r
}\r
else\r
{\r
// Read cartridge region data:\r
- region=PicoRead32(0x1f0);\r
+ int region=PicoRead32(0x1f0);\r
\r
for (i=0;i<4;i++)\r
{\r
\r
Pico.m.hardware=(unsigned char)(hw|0x20); // No disk attached\r
Pico.m.pal=pal;\r
- Pico.video.status = 0x3408 | pal; // 'always set' bits | vblank | pal\r
+}\r
+\r
+int PicoReset(void)\r
+{\r
+ unsigned char sram_reg=Pico.m.sram_reg; // must be preserved\r
+\r
+ if (Pico.romsize<=0) return 1;\r
+\r
+ /* must call now, so that banking is reset, and correct vectors get fetched */\r
+ if (PicoResetHook) PicoResetHook();\r
+\r
+ PicoMemReset();\r
+ SekReset();\r
+ // s68k doesn't have the TAS quirk, so we just globally set normal TAS handler in MCD mode (used by Batman games).\r
+ SekSetRealTAS(PicoAHW & PAHW_MCD);\r
+ SekCycleCntT=0;\r
+\r
+ if (PicoAHW & PAHW_MCD)\r
+ // needed for MCD to reset properly, probably some bug hides behind this..\r
+ memset(Pico.ioports,0,sizeof(Pico.ioports));\r
+ emustatus = 0;\r
+\r
+ Pico.m.dirtyPal = 1;\r
+\r
+ PicoDetectRegion();\r
+ Pico.video.status = 0x3408 | Pico.m.pal; // 'always set' bits | vblank | pal\r
\r
PsndReset(); // pal must be known here\r
\r
// internal\r
int fifo_bytes;\r
int line_counter;\r
+ unsigned int r1, r12;\r
} picohw_state;\r
extern picohw_state PicoPicohw;\r
\r
{
switch (a & 0x1f)
{
+ case 0x01: d = PicoPicohw.r1; break;
case 0x03:
d = PicoPad[0]&0x1f; // d-pad
d |= (PicoPad[0]&0x20) << 2; // red button -> C
// if (a == 0x800010) dump(d);
if (a == 0x800010) PicoPicohw.fifo_bytes += 2;
+ if (a == 0x800012) PicoPicohw.r12 = d;
elprintf(EL_UIO, "w16: %06x, %04x", a&0xffffff, d);
}
static void PicoLineHookPico(int count)
{
-
PicoPicohw.line_counter += count;
- if ((PicoPicohw.line_counter & 0xf) == 0 || count > 10)
- {
- if (PicoPicohw.fifo_bytes > 0)
- PicoPicohw.fifo_bytes--;
- }
-#if 0
- if (PicoPicohw.line_counter - prev_line_cnt_irq3 > 200) {
+#if 1
+ if ((PicoPicohw.r12 & 0x4003) && PicoPicohw.line_counter - prev_line_cnt_irq3 > 200) {
prev_line_cnt_irq3 = PicoPicohw.line_counter;
// just a guess/hack, allows 101 Dalmantians to boot
elprintf(EL_ANOMALY, "irq3");
SekInterrupt(3);
+ return;
+ }
+
+ if (PicoPicohw.fifo_bytes == 16) {
+ prev_line_cnt_irq3 = PicoPicohw.line_counter;
+ elprintf(EL_ANOMALY, "irq3, fb=%i", PicoPicohw.fifo_bytes);
+ SekInterrupt(3);
+ PicoPicohw.fifo_bytes--;
+ return;
}
#endif
+ if ((PicoPicohw.line_counter & 3) == 0 || count > 10)
+ {
+ if (PicoPicohw.fifo_bytes > 0)
+ PicoPicohw.fifo_bytes--;
+ }
+
#if 0
if (PicoPicohw.line_counter - prev_line_cnt_irq5 > 512) {
prev_line_cnt_irq5 = PicoPicohw.line_counter;
PicoPicohw.pen_pos[1] = 0x200 + 252/2;
prev_line_cnt_irq3 = 0, prev_line_cnt_irq5 = 0;
+ // map version register
+ PicoDetectRegion();
+ elprintf(EL_STATUS, "a %x", Pico.m.hardware);
+ switch (Pico.m.hardware >> 6) {
+ case 0: PicoPicohw.r1 = 0x00; break;
+ case 1: PicoPicohw.r1 = 0x00; break;
+ case 2: PicoPicohw.r1 = 0x40; break;
+ case 3: PicoPicohw.r1 = 0x20; break;
+ }
+
return 0;
}
extern int z80startCycle, z80stopCycle; // in 68k cycles\r
extern void (*PicoResetHook)(void);\r
extern void (*PicoLineHook)(int count);\r
-PICO_INTERNAL int CheckDMA(void);\r
+PICO_INTERNAL int CheckDMA(void);\r
+PICO_INTERNAL void PicoDetectRegion(void);\r
\r
// cd/Pico.c\r
PICO_INTERNAL int PicoInitMCD(void);\r
case 0x19: current_keys |= GP2X_VOL_UP;break; // w
case 0x2d: log_io_clear(); break; // k
case 0x2e: log_io_dump(); break; // l
+ case 0x17: { // tab
+ extern int PicoReset(void);
+ PicoReset();
+ break;
+ }
}
return 0;