1 // The SVP chip emulator
3 // (c) Copyright 2008, Grazvydas "notaz" Ignotas
4 // Free for non-commercial use.
6 // For commercial use, separate licencing terms must be obtained.
9 #include "../../PicoInt.h"
12 int PicoSVPCycles = 800; // cycles/line
14 static void PicoSVPReset(void)
16 elprintf(EL_SVP, "SVP reset");
18 memcpy(svp->iram_rom + 0x800, Pico.rom + 0x800, 0x20000 - 0x800);
19 ssp1601_reset(&svp->ssp1601);
23 static void PicoSVPLine(int count)
26 // OSC_NTSC / 3.0 / 60.0 / 262.0 ~= 1139
27 // OSC_PAL / 3.0 / 50.0 / 312.0 ~= 1137
28 ssp1601_run(PicoSVPCycles * count);
31 //if (Pico.m.frame_count == 13) PicoPad[0] |= 0xff;
35 static int PicoSVPDma(unsigned int source, int len, unsigned short **srcp, unsigned short **limitp)
37 if (source < Pico.romsize) // Rom
40 *srcp = (unsigned short *)(Pico.rom + (source&~1));
41 *limitp = (unsigned short *)(Pico.rom + Pico.romsize);
44 else if ((source & 0xfe0000) == 0x300000)
46 elprintf(EL_VDPDMA|EL_SVP, "SVP DmaSlow from %06x, len=%i", source, len);
49 *srcp = (unsigned short *)(svp->dram + source);
50 *limitp = (unsigned short *)(svp->dram + sizeof(svp->dram));
54 elprintf(EL_VDPDMA|EL_SVP|EL_ANOMALY, "SVP FIXME unhandled DmaSlow from %06x, len=%i", source, len);
60 void PicoSVPInit(void)
64 elprintf(EL_SVP, "SVP init");
66 tmp = realloc(Pico.rom, 0x200000 + sizeof(*svp));
69 elprintf(EL_STATUS|EL_SVP, "OOM for SVP data");
74 svp = (void *) ((char *)tmp + 0x200000);
75 memset(svp, 0, sizeof(*svp));
77 // init ok, setup hooks..
78 PicoRead16Hook = PicoSVPRead16;
79 PicoWrite8Hook = PicoSVPWrite8;
80 PicoWrite16Hook = PicoSVPWrite16;
81 PicoDmaHook = PicoSVPDma;
82 PicoResetHook = PicoSVPReset;
83 PicoLineHook = PicoSVPLine;