some Pico adjustments

git-svn-id: file:///home/notaz/opt/svn/PicoDrive@447 be3aeb3a-fb24-0410-a615-afba39da0efa
This commit is contained in:
notaz 2008-05-18 15:56:52 +00:00
parent 213c16adcb
commit fa22af4caf
5 changed files with 55 additions and 32 deletions

View file

@ -48,10 +48,15 @@ void mp3_update(int *buffer, int length, int stereo);
#define POPT_EN_SVP_DRC (1<<17)
#define POPT_DIS_SPRITE_LIM (1<<18)
extern int PicoOpt; // bitfield
#define PAHW_MCD (1<<0)
#define PAHW_32X (1<<1)
#define PAHW_SVP (1<<2)
#define PAHW_PICO (1<<3)
extern int PicoAHW; // Pico active hw
extern int PicoVer;
extern int PicoSkipFrame; // skip rendering frame, but still do sound (if enabled) and emulation stuff
extern int PicoSkipFrame; // skip rendering frame, but still do sound (if enabled) and emulation stuff
extern int PicoRegionOverride; // override the region detection 0: auto, 1: Japan NTSC, 2: Japan PAL, 4: US, 8: Europe
extern int PicoAutoRgnOrder; // packed priority list of regions, for example 0x148 means this detection order: EUR, USA, JAP
extern int PicoAutoRgnOrder; // packed priority list of regions, for example 0x148 means this detection order: EUR, USA, JAP
extern int PicoSVPCycles;
int PicoInit(void);
void PicoExit(void);
@ -77,7 +82,8 @@ typedef struct
int pen_pos[2];
int page;
// internal
int fifo_bytes; // free bytes in FIFO
int fifo_bytes; // bytes in FIFO
int fifo_bytes_prev;
int fifo_line_bytes; // float part, << 16
int line_counter;
unsigned short r1, r12;

View file

@ -50,7 +50,7 @@ static u32 PicoReadPico8(u32 a)
}
}
// 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);
@ -76,8 +76,10 @@ static u32 PicoReadPico16(u32 a)
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);
@ -109,13 +111,20 @@ end:
// -----------------------------------------------------------------
// 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)
{
@ -132,7 +141,13 @@ 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)
@ -154,7 +169,7 @@ 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++;
}
}
@ -164,8 +179,10 @@ static void PicoWritePico16(u32 a,u16 d)
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)

View file

@ -8,9 +8,13 @@ picohw_state PicoPicohw;
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;
@ -25,18 +29,10 @@ static void PicoLinePico(int count)
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");
elprintf(EL_PICOHW, "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.fifo_bytes > 0)
@ -52,10 +48,20 @@ static void PicoLinePico(int count)
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

View file

@ -93,13 +93,13 @@ PICO_INTERNAL void PicoPicoPCMUpdate(short *buffer, int length, int stereo)
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:

View file

@ -211,13 +211,6 @@ extern struct DrZ80 drZ80;
// ---------------------------------------------------------
// Pico active hw
#define PAHW_MCD (1<<0)
#define PAHW_32X (1<<1)
#define PAHW_SVP (1<<2)
#define PAHW_PICO (1<<3)
extern int PicoAHW;
// main oscillator clock which controls timing
#define OSC_NTSC 53693100
// seems to be accurate, see scans from http://www.hot.ee/tmeeco/
@ -525,6 +518,7 @@ PICO_INTERNAL void z80_exit(void);
#define EL_IO 0x00001000 /* all i/o */
#define EL_CDPOLL 0x00002000 /* MCD: log poll detection */
#define EL_SVP 0x00004000 /* SVP stuff */
#define EL_PICOHW 0x00008000 /* Pico stuff */
#define EL_STATUS 0x40000000 /* status messages */
#define EL_ANOMALY 0x80000000 /* some unexpected conditions (during emulation) */