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