more wip SVP code
[picodrive.git] / Pico / carthw / svp / svp.c
CommitLineData
f53f286a 1#include "../../PicoInt.h"
2
f8ef8ff7 3svp_t *svp = NULL;
4
f53f286a 5void PicoSVPInit(void)
6{
f8ef8ff7 7 void *tmp;
8
9 elprintf(0xffff, "SVP init");
10
11 tmp = realloc(Pico.rom, 0x200000 + sizeof(*svp));
12 if (tmp == NULL)
13 {
14 elprintf(EL_STATUS, "OOM for SVP data");
15 return;
16 }
17
18 Pico.rom = tmp;
19 svp = (void *) ((char *)tmp + 0x200000);
20 memset(svp, 0, sizeof(*svp));
21
22 // init ok, setup hooks..
23 PicoRead16Hook = PicoSVPRead16;
24 PicoWrite8Hook = PicoSVPWrite8;
25 PicoWrite16Hook = PicoSVPWrite16;
26 PicoDmaHook = PicoSVPDma;
27}
28
29
30void PicoSVPReset(void)
31{
32 elprintf(0xffff, "SVP reset");
33
34 ssp1601_reset(&svp->ssp1601);
35}
36
37
38int PicoSVPDma(unsigned int source, unsigned short **srcp, unsigned short **limitp)
39{
40 if ((source & 0xfe0000) == 0x300000)
41 {
42 elprintf(EL_VDPDMA|0xffff, "SVP DmaSlow from %06x", source);
43 source &= 0x1fffe;
44 *srcp = (unsigned short *)(svp->ram + source);
45 *limitp = (unsigned short *)(svp->ram + sizeof(svp->ram));
46 return 1;
47 }
48
49 return 0;
f53f286a 50}
51