Pico version reg, irq3 handling changed
[picodrive.git] / Pico / Pico / Pico.c
CommitLineData
9037e45d 1#include "../PicoInt.h"
2
406c96c5 3// x: 0x03c - 0x19d
4// y: 0x1fc - 0x2f7
5// 0x2f8 - 0x3f3
d49b10c2 6picohw_state PicoPicohw;
7
8static int prev_line_cnt_irq3 = 0, prev_line_cnt_irq5 = 0;
9
10static void PicoLineHookPico(int count)
11{
d49b10c2 12 PicoPicohw.line_counter += count;
d49b10c2 13
1e6b5e39 14#if 1
15 if ((PicoPicohw.r12 & 0x4003) && PicoPicohw.line_counter - prev_line_cnt_irq3 > 200) {
d49b10c2 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);
1e6b5e39 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;
d49b10c2 29 }
30#endif
31
1e6b5e39 32 if ((PicoPicohw.line_counter & 3) == 0 || count > 10)
33 {
34 if (PicoPicohw.fifo_bytes > 0)
35 PicoPicohw.fifo_bytes--;
36 }
37
d49b10c2 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}
406c96c5 46
9037e45d 47PICO_INTERNAL int PicoInitPico(void)
48{
49 elprintf(EL_STATUS, "Pico detected");
d49b10c2 50 PicoLineHook = PicoLineHookPico;
51
9037e45d 52 PicoAHW = PAHW_PICO;
d49b10c2 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;
9037e45d 57
1e6b5e39 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
9037e45d 68 return 0;
69}
70