X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=Pico%2FPico%2FPico.c;h=fdd5f444922e4e8d67d9aa5d97c7e797b8ec146f;hb=d49b10c2f2c58e03a1be8b3b9e8bfc08703e0ce0;hp=9b4fa8a1e26af8c308e720f7c882cb2fe911112c;hpb=406c96c547a11046f63cb88bd0bc666003812608;p=picodrive.git diff --git a/Pico/Pico/Pico.c b/Pico/Pico/Pico.c index 9b4fa8a..fdd5f44 100644 --- a/Pico/Pico/Pico.c +++ b/Pico/Pico/Pico.c @@ -3,14 +3,48 @@ // x: 0x03c - 0x19d // y: 0x1fc - 0x2f7 // 0x2f8 - 0x3f3 -int PicoPicoPenPos[2] = { 0x3c, 0x200 }; -int PicoPicoPage = 0; // 0-6 +picohw_state PicoPicohw; + +static int prev_line_cnt_irq3 = 0, prev_line_cnt_irq5 = 0; + +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) { + prev_line_cnt_irq3 = PicoPicohw.line_counter; + // just a guess/hack, allows 101 Dalmantians to boot + elprintf(EL_ANOMALY, "irq3"); + SekInterrupt(3); + } +#endif + +#if 0 + if (PicoPicohw.line_counter - prev_line_cnt_irq5 > 512) { + prev_line_cnt_irq5 = PicoPicohw.line_counter; + elprintf(EL_ANOMALY, "irq5"); + SekInterrupt(5); + } +#endif +} PICO_INTERNAL int PicoInitPico(void) { elprintf(EL_STATUS, "Pico detected"); + PicoLineHook = PicoLineHookPico; + PicoAHW = PAHW_PICO; - PicoPicoPage = 0; + 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; return 0; }