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