| 1 | #include "../PicoInt.h" |
| 2 | |
| 3 | // x: 0x03c - 0x19d |
| 4 | // y: 0x1fc - 0x2f7 |
| 5 | // 0x2f8 - 0x3f3 |
| 6 | picohw_state PicoPicohw; |
| 7 | |
| 8 | static int prev_line_cnt_irq3 = 0, prev_line_cnt_irq5 = 0; |
| 9 | |
| 10 | static void PicoLineHookPico(int count) |
| 11 | { |
| 12 | PicoPicohw.line_counter += count; |
| 13 | |
| 14 | #if 1 |
| 15 | if ((PicoPicohw.r12 & 0x4003) && PicoPicohw.line_counter - prev_line_cnt_irq3 > 200) { |
| 16 | prev_line_cnt_irq3 = PicoPicohw.line_counter; |
| 17 | // just a guess/hack, allows 101 Dalmantians to boot |
| 18 | elprintf(EL_ANOMALY, "irq3"); |
| 19 | SekInterrupt(3); |
| 20 | return; |
| 21 | } |
| 22 | |
| 23 | if (PicoPicohw.fifo_bytes == 16) { |
| 24 | prev_line_cnt_irq3 = PicoPicohw.line_counter; |
| 25 | elprintf(EL_ANOMALY, "irq3, fb=%i", PicoPicohw.fifo_bytes); |
| 26 | SekInterrupt(3); |
| 27 | PicoPicohw.fifo_bytes--; |
| 28 | return; |
| 29 | } |
| 30 | #endif |
| 31 | |
| 32 | if ((PicoPicohw.line_counter & 3) == 0 || count > 10) |
| 33 | { |
| 34 | if (PicoPicohw.fifo_bytes > 0) |
| 35 | PicoPicohw.fifo_bytes--; |
| 36 | } |
| 37 | |
| 38 | #if 0 |
| 39 | if (PicoPicohw.line_counter - prev_line_cnt_irq5 > 512) { |
| 40 | prev_line_cnt_irq5 = PicoPicohw.line_counter; |
| 41 | elprintf(EL_ANOMALY, "irq5"); |
| 42 | SekInterrupt(5); |
| 43 | } |
| 44 | #endif |
| 45 | } |
| 46 | |
| 47 | PICO_INTERNAL int PicoInitPico(void) |
| 48 | { |
| 49 | elprintf(EL_STATUS, "Pico detected"); |
| 50 | PicoLineHook = PicoLineHookPico; |
| 51 | |
| 52 | PicoAHW = PAHW_PICO; |
| 53 | memset(&PicoPicohw, 0, sizeof(PicoPicohw)); |
| 54 | PicoPicohw.pen_pos[0] = 0x03c + 352/2; |
| 55 | PicoPicohw.pen_pos[1] = 0x200 + 252/2; |
| 56 | prev_line_cnt_irq3 = 0, prev_line_cnt_irq5 = 0; |
| 57 | |
| 58 | // map version register |
| 59 | PicoDetectRegion(); |
| 60 | elprintf(EL_STATUS, "a %x", Pico.m.hardware); |
| 61 | switch (Pico.m.hardware >> 6) { |
| 62 | case 0: PicoPicohw.r1 = 0x00; break; |
| 63 | case 1: PicoPicohw.r1 = 0x00; break; |
| 64 | case 2: PicoPicohw.r1 = 0x40; break; |
| 65 | case 3: PicoPicohw.r1 = 0x20; break; |
| 66 | } |
| 67 | |
| 68 | return 0; |
| 69 | } |
| 70 | |