X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=Pico%2FPico%2FPico.c;h=1230728f8a7f4334eaf38c514906a54ac7be5b18;hb=ee4f03ae8612ca281935871c897ef3a7f4d499ca;hp=ece6d64c4a6031b0c90af67b3bf8d0761e6a6b33;hpb=ef4eb506de324df73bcda06f027a20349c69d05f;p=picodrive.git diff --git a/Pico/Pico/Pico.c b/Pico/Pico/Pico.c index ece6d64..1230728 100644 --- a/Pico/Pico/Pico.c +++ b/Pico/Pico/Pico.c @@ -6,7 +6,20 @@ 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; // fifo bytes/line. FIXME: other rates, modes +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 = 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; + PicoPicoPCMRerate(rate); +} static void PicoLinePico(int count) { @@ -16,16 +29,8 @@ 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"); - 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 @@ -43,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 @@ -58,7 +73,7 @@ static void PicoResetPico(void) PicoPicohw.xpcm_ptr = PicoPicohw.xpcm_buffer; } -PICO_INTERNAL int PicoInitPico(void) +PICO_INTERNAL void PicoInitPico(void) { elprintf(EL_STATUS, "Pico detected"); PicoLineHook = PicoLinePico; @@ -66,8 +81,8 @@ PICO_INTERNAL int PicoInitPico(void) PicoAHW = PAHW_PICO; memset(&PicoPicohw, 0, sizeof(PicoPicohw)); - PicoPicohw.pen_pos[0] = 0x03c + 352/2; - PicoPicohw.pen_pos[1] = 0x200 + 252/2; + PicoPicohw.pen_pos[0] = 0x03c + 320/2; + PicoPicohw.pen_pos[1] = 0x200 + 240/2; prev_line_cnt_irq3 = prev_line_cnt_irq5 = 0; // map version register @@ -78,7 +93,5 @@ PICO_INTERNAL int PicoInitPico(void) case 2: PicoPicohw.r1 = 0x40; break; case 3: PicoPicohw.r1 = 0x20; break; } - - return 0; }