X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=Pico%2FPico%2FPico.c;h=ece6d64c4a6031b0c90af67b3bf8d0761e6a6b33;hb=ef4eb506de324df73bcda06f027a20349c69d05f;hp=e1133c0113ead240365472feec8831ed2a809700;hpb=1e6b5e39f45341524d90a4c71776e92a6d2d6fe5;p=picodrive.git diff --git a/Pico/Pico/Pico.c b/Pico/Pico/Pico.c index e1133c0..ece6d64 100644 --- a/Pico/Pico/Pico.c +++ b/Pico/Pico/Pico.c @@ -6,8 +6,9 @@ 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 void PicoLineHookPico(int count) +static void PicoLinePico(int count) { PicoPicohw.line_counter += count; @@ -29,11 +30,18 @@ static void PicoLineHookPico(int count) } #endif - if ((PicoPicohw.line_counter & 3) == 0 || count > 10) + if (PicoPicohw.fifo_bytes > 0) { - if (PicoPicohw.fifo_bytes > 0) - PicoPicohw.fifo_bytes--; + PicoPicohw.fifo_line_bytes += fifo_bytes_line * count; + if (PicoPicohw.fifo_line_bytes >= (1<<16)) { + PicoPicohw.fifo_bytes -= PicoPicohw.fifo_line_bytes >> 16; + PicoPicohw.fifo_line_bytes &= 0xffff; + if (PicoPicohw.fifo_bytes < 0) + PicoPicohw.fifo_bytes = 0; + } } + else + PicoPicohw.fifo_line_bytes = 0; #if 0 if (PicoPicohw.line_counter - prev_line_cnt_irq5 > 512) { @@ -44,20 +52,26 @@ static void PicoLineHookPico(int count) #endif } +static void PicoResetPico(void) +{ + PicoPicoPCMReset(); + PicoPicohw.xpcm_ptr = PicoPicohw.xpcm_buffer; +} + PICO_INTERNAL int PicoInitPico(void) { elprintf(EL_STATUS, "Pico detected"); - PicoLineHook = PicoLineHookPico; + PicoLineHook = PicoLinePico; + PicoResetHook = PicoResetPico; PicoAHW = PAHW_PICO; memset(&PicoPicohw, 0, sizeof(PicoPicohw)); PicoPicohw.pen_pos[0] = 0x03c + 352/2; PicoPicohw.pen_pos[1] = 0x200 + 252/2; - prev_line_cnt_irq3 = 0, prev_line_cnt_irq5 = 0; + prev_line_cnt_irq3 = 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;