svp. does some output now
[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
5de27868 9 memcpy(svp->iram_rom + 0x800, Pico.rom + 0x800, 0x20000 - 0x800);
017512f2 10 ssp1601_reset(&svp->ssp1601);
11}
12
13
14static 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);
d26dc685 20
21 // test mode
22 //if (Pico.m.frame_count == 13) PicoPad[0] |= 0xff;
23 // pushing start
24 //if (Pico.m.frame_count & 4) PicoPad[0] |= 0x80;
017512f2 25}
26
27
5de27868 28static int PicoSVPDma(unsigned int source, int len, unsigned short **srcp, unsigned short **limitp)
017512f2 29{
30 if ((source & 0xfe0000) == 0x300000)
31 {
5de27868 32 elprintf(EL_VDPDMA|EL_SVP, "SVP DmaSlow from %06x, len=%i", source, len);
017512f2 33 source &= 0x1fffe;
30752975 34 source -= 2;
5de27868 35 *srcp = (unsigned short *)(svp->dram + source);
36 *limitp = (unsigned short *)(svp->dram + sizeof(svp->dram));
017512f2 37 return 1;
38 }
d26dc685 39 else
40 elprintf(EL_VDPDMA|EL_SVP|EL_ANOMALY, "SVP FIXME unhandled DmaSlow from %06x, len=%i", source, len);
017512f2 41
42 return 0;
43}
44
45
f53f286a 46void PicoSVPInit(void)
47{
f8ef8ff7 48 void *tmp;
49
017512f2 50 elprintf(EL_SVP, "SVP init");
f8ef8ff7 51
52 tmp = realloc(Pico.rom, 0x200000 + sizeof(*svp));
53 if (tmp == NULL)
54 {
017512f2 55 elprintf(EL_STATUS|EL_SVP, "OOM for SVP data");
f8ef8ff7 56 return;
57 }
58
59 Pico.rom = tmp;
60 svp = (void *) ((char *)tmp + 0x200000);
61 memset(svp, 0, sizeof(*svp));
62
63 // init ok, setup hooks..
64 PicoRead16Hook = PicoSVPRead16;
65 PicoWrite8Hook = PicoSVPWrite8;
66 PicoWrite16Hook = PicoSVPWrite16;
67 PicoDmaHook = PicoSVPDma;
017512f2 68 PicoResetHook = PicoSVPReset;
69 PicoLineHook = PicoSVPLine;
f53f286a 70}
71