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