f53f286a |
1 | #include "../../PicoInt.h" |
2 | |
f8ef8ff7 |
3 | svp_t *svp = NULL; |
0ffefdb8 |
4 | int PicoSVPCycles = 800; // cycles/line |
f8ef8ff7 |
5 | |
017512f2 |
6 | static void PicoSVPReset(void) |
7 | { |
8 | elprintf(EL_SVP, "SVP reset"); |
9 | |
5de27868 |
10 | memcpy(svp->iram_rom + 0x800, Pico.rom + 0x800, 0x20000 - 0x800); |
017512f2 |
11 | ssp1601_reset(&svp->ssp1601); |
12 | } |
13 | |
14 | |
0ffefdb8 |
15 | static void PicoSVPLine(int count) |
017512f2 |
16 | { |
17 | // ??? |
18 | // OSC_NTSC / 3.0 / 60.0 / 262.0 ~= 1139 |
19 | // OSC_PAL / 3.0 / 50.0 / 312.0 ~= 1137 |
0ffefdb8 |
20 | ssp1601_run(PicoSVPCycles * count); |
d26dc685 |
21 | |
22 | // test mode |
23 | //if (Pico.m.frame_count == 13) PicoPad[0] |= 0xff; |
017512f2 |
24 | } |
25 | |
26 | |
5de27868 |
27 | static int PicoSVPDma(unsigned int source, int len, unsigned short **srcp, unsigned short **limitp) |
017512f2 |
28 | { |
50483b53 |
29 | if (source < Pico.romsize) { // Rom |
30 | source -= 2; |
31 | *srcp = (unsigned short *)(Pico.rom + (source&~1)); |
32 | *limitp = (unsigned short *)(Pico.rom + Pico.romsize); |
33 | return 1; |
34 | } |
35 | else if ((source & 0xfe0000) == 0x300000) |
017512f2 |
36 | { |
5de27868 |
37 | elprintf(EL_VDPDMA|EL_SVP, "SVP DmaSlow from %06x, len=%i", source, len); |
017512f2 |
38 | source &= 0x1fffe; |
30752975 |
39 | source -= 2; |
5de27868 |
40 | *srcp = (unsigned short *)(svp->dram + source); |
41 | *limitp = (unsigned short *)(svp->dram + sizeof(svp->dram)); |
017512f2 |
42 | return 1; |
43 | } |
d26dc685 |
44 | else |
45 | elprintf(EL_VDPDMA|EL_SVP|EL_ANOMALY, "SVP FIXME unhandled DmaSlow from %06x, len=%i", source, len); |
017512f2 |
46 | |
47 | return 0; |
48 | } |
49 | |
50 | |
f53f286a |
51 | void PicoSVPInit(void) |
52 | { |
f8ef8ff7 |
53 | void *tmp; |
54 | |
017512f2 |
55 | elprintf(EL_SVP, "SVP init"); |
f8ef8ff7 |
56 | |
57 | tmp = realloc(Pico.rom, 0x200000 + sizeof(*svp)); |
58 | if (tmp == NULL) |
59 | { |
017512f2 |
60 | elprintf(EL_STATUS|EL_SVP, "OOM for SVP data"); |
f8ef8ff7 |
61 | return; |
62 | } |
63 | |
64 | Pico.rom = tmp; |
65 | svp = (void *) ((char *)tmp + 0x200000); |
66 | memset(svp, 0, sizeof(*svp)); |
67 | |
68 | // init ok, setup hooks.. |
69 | PicoRead16Hook = PicoSVPRead16; |
70 | PicoWrite8Hook = PicoSVPWrite8; |
71 | PicoWrite16Hook = PicoSVPWrite16; |
72 | PicoDmaHook = PicoSVPDma; |
017512f2 |
73 | PicoResetHook = PicoSVPReset; |
74 | PicoLineHook = PicoSVPLine; |
f53f286a |
75 | } |
76 | |