#define POPT_EN_SVP_DRC (1<<17)\r
#define POPT_DIS_SPRITE_LIM (1<<18)\r
extern int PicoOpt; // bitfield\r
+#define PAHW_MCD (1<<0)\r
+#define PAHW_32X (1<<1)\r
+#define PAHW_SVP (1<<2)\r
+#define PAHW_PICO (1<<3)\r
+extern int PicoAHW; // Pico active hw\r
extern int PicoVer;\r
-extern int PicoSkipFrame; // skip rendering frame, but still do sound (if enabled) and emulation stuff\r
+extern int PicoSkipFrame; // skip rendering frame, but still do sound (if enabled) and emulation stuff\r
extern int PicoRegionOverride; // override the region detection 0: auto, 1: Japan NTSC, 2: Japan PAL, 4: US, 8: Europe\r
-extern int PicoAutoRgnOrder; // packed priority list of regions, for example 0x148 means this detection order: EUR, USA, JAP\r
+extern int PicoAutoRgnOrder; // packed priority list of regions, for example 0x148 means this detection order: EUR, USA, JAP\r
extern int PicoSVPCycles;\r
int PicoInit(void);\r
void PicoExit(void);\r
int pen_pos[2];\r
int page;\r
// internal\r
- int fifo_bytes; // free bytes in FIFO\r
+ int fifo_bytes; // bytes in FIFO\r
+ int fifo_bytes_prev;\r
int fifo_line_bytes; // float part, << 16\r
int line_counter;\r
unsigned short r1, r12;\r
}
}
-// elprintf(EL_UIO, "r8 : %06x, %02x @%06x", a&0xffffff, (u8)d, SekPc);
+ //elprintf(EL_UIO, "r8 : %06x, %02x @%06x", a&0xffffff, (u8)d, SekPc);
end:
elprintf(EL_IO, "r8 : %06x, %02x @%06x", a&0xffffff, (u8)d, SekPc);
d = (PicoPicohw.fifo_bytes > 0x3f) ? 0 : (0x3f - PicoPicohw.fifo_bytes);
else if (a == 0x800012)
d = PicoPicohw.fifo_bytes == 0 ? 0x8000 : 0; // guess
+ else
+ elprintf(EL_UIO, "r16: %06x, %04x @%06x", a&0xffffff, d, SekPc);
- elprintf(EL_UIO, "r16: %06x, %04x @%06x", a&0xffffff, d, SekPc);
+ //elprintf(EL_UIO, "r16: %06x, %04x @%06x", a&0xffffff, d, SekPc);
end:
elprintf(EL_IO, "r16: %06x, %04x @%06x", a&0xffffff, d, SekPc);
// -----------------------------------------------------------------
// Write Ram
+/*
void dump(u16 w)
{
- FILE *f = fopen("dump.bin", "a");
- fwrite(&w, 1, 2, f);
- fclose(f);
+ static FILE *f[0x10] = { NULL, };
+ char fname[32];
+ int num = PicoPicohw.r12 & 0xf;
+
+ sprintf(fname, "ldump%i.bin", num);
+ if (f[num] == NULL)
+ f[num] = fopen(fname, "wb");
+ fwrite(&w, 1, 2, f[num]);
+ //fclose(f);
}
-
+*/
static void PicoWritePico8(u32 a,u8 d)
{
return;
}
- elprintf(EL_UIO, "w8 : %06x, %02x @%06x", a&0xffffff, d, SekPc);
+ switch (a & 0x1f) {
+ case 0x19: case 0x1b: case 0x1d: case 0x1f: break; // 'S' 'E' 'G' 'A'
+ default:
+ elprintf(EL_UIO, "w8 : %06x, %02x @%06x", a&0xffffff, d, SekPc);
+ break;
+ }
+ //elprintf(EL_UIO, "w8 : %06x, %02x @%06x", a&0xffffff, d, SekPc);
}
static void PicoWritePico16(u32 a,u16 d)
*PicoPicohw.xpcm_ptr++ = d;
}
else if (PicoPicohw.xpcm_ptr == PicoPicohw.xpcm_buffer + XPCM_BUFFER_SIZE) {
- elprintf(EL_ANOMALY, "xpcm_buffer overflow!");
+ elprintf(EL_ANOMALY|EL_PICOHW, "xpcm_buffer overflow!");
PicoPicohw.xpcm_ptr++;
}
}
if (r12_old != d)
PicoReratePico();
}
+ else
+ elprintf(EL_UIO, "w16: %06x, %04x", a&0xffffff, d);
- elprintf(EL_UIO, "w16: %06x, %04x", a&0xffffff, d);
+ //elprintf(EL_UIO, "w16: %06x, %04x", a&0xffffff, d);
}
static void PicoWritePico32(u32 a,u32 d)
static int prev_line_cnt_irq3 = 0, prev_line_cnt_irq5 = 0;
static int fifo_bytes_line = (16000<<16)/60/262/2;
+static const int guessed_rates[] = { 8000, 14000, 12000, 14000, 16000, 18000, 16000, 16000 }; // ?
+
+#define PICOHW_FIFO_IRQ_THRESHOLD 12
+
PICO_INTERNAL void PicoReratePico(void)
{
- int rate = (PicoPicohw.r12 & 0xf) ? 16000 : 8000;
+ int rate = guessed_rates[PicoPicohw.r12 & 7];
if (Pico.m.pal)
fifo_bytes_line = (rate<<16)/50/312/2;
else fifo_bytes_line = (rate<<16)/60/262/2;
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);
+ elprintf(EL_PICOHW, "irq3");
SekInterrupt(3);
- PicoPicohw.fifo_bytes--;
return;
}
#endif
else
PicoPicohw.fifo_line_bytes = 0;
+#if 1
+ if (PicoPicohw.fifo_bytes_prev >= PICOHW_FIFO_IRQ_THRESHOLD &&
+ PicoPicohw.fifo_bytes < PICOHW_FIFO_IRQ_THRESHOLD) {
+ prev_line_cnt_irq3 = PicoPicohw.line_counter; // ?
+ elprintf(EL_PICOHW, "irq3, fb=%i", PicoPicohw.fifo_bytes);
+ SekInterrupt(3);
+ }
+ PicoPicohw.fifo_bytes_prev = PicoPicohw.fifo_bytes;
+#endif
+
#if 0
if (PicoPicohw.line_counter - prev_line_cnt_irq5 > 512) {
prev_line_cnt_irq5 = PicoPicohw.line_counter;
- elprintf(EL_ANOMALY, "irq5");
+ elprintf(EL_PICOHW, "irq5");
SekInterrupt(5);
}
#endif
int di = lim - src;
memmove(PicoPicohw.xpcm_buffer, src, di);
PicoPicohw.xpcm_ptr = PicoPicohw.xpcm_buffer + di;
- elprintf(EL_STATUS, "xpcm update: over %i", di);
+ elprintf(EL_PICOHW, "xpcm update: over %i", di);
// adjust fifo
PicoPicohw.fifo_bytes = di;
return;
}
- elprintf(EL_STATUS, "xpcm update: under %i", length);
+ elprintf(EL_PICOHW, "xpcm update: under %i", length);
PicoPicohw.xpcm_ptr = PicoPicohw.xpcm_buffer;
end:
\r
// ---------------------------------------------------------\r
\r
-// Pico active hw\r
-#define PAHW_MCD (1<<0)\r
-#define PAHW_32X (1<<1)\r
-#define PAHW_SVP (1<<2)\r
-#define PAHW_PICO (1<<3)\r
-extern int PicoAHW;\r
-\r
// main oscillator clock which controls timing\r
#define OSC_NTSC 53693100\r
// seems to be accurate, see scans from http://www.hot.ee/tmeeco/\r
#define EL_IO 0x00001000 /* all i/o */\r
#define EL_CDPOLL 0x00002000 /* MCD: log poll detection */\r
#define EL_SVP 0x00004000 /* SVP stuff */\r
+#define EL_PICOHW 0x00008000 /* Pico stuff */\r
\r
#define EL_STATUS 0x40000000 /* status messages */\r
#define EL_ANOMALY 0x80000000 /* some unexpected conditions (during emulation) */\r