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