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 = 1000; // 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 ssp1601_run(PicoSVPCycles * count);
29 //if (Pico.m.frame_count == 13) PicoPad[0] |= 0xff;
33 static int PicoSVPDma(unsigned int source, int len, unsigned short **srcp, unsigned short **limitp)
35 if (source < Pico.romsize) // Rom
38 *srcp = (unsigned short *)(Pico.rom + (source&~1));
39 *limitp = (unsigned short *)(Pico.rom + Pico.romsize);
42 else if ((source & 0xfe0000) == 0x300000)
44 elprintf(EL_VDPDMA|EL_SVP, "SVP DmaSlow from %06x, len=%i", source, len);
47 *srcp = (unsigned short *)(svp->dram + source);
48 *limitp = (unsigned short *)(svp->dram + sizeof(svp->dram));
52 elprintf(EL_VDPDMA|EL_SVP|EL_ANOMALY, "SVP FIXME unhandled DmaSlow from %06x, len=%i", source, len);
58 void PicoSVPInit(void)
62 elprintf(EL_SVP, "SVP init");
64 tmp = realloc(Pico.rom, 0x200000 + sizeof(*svp));
67 elprintf(EL_STATUS|EL_SVP, "OOM for SVP data");
72 svp = (void *) ((char *)tmp + 0x200000);
73 memset(svp, 0, sizeof(*svp));
75 // init ok, setup hooks..
76 PicoRead16Hook = PicoSVPRead16;
77 PicoWrite8Hook = PicoSVPWrite8;
78 PicoWrite16Hook = PicoSVPWrite16;
79 PicoDmaHook = PicoSVPDma;
80 PicoResetHook = PicoSVPReset;
81 PicoLineHook = PicoSVPLine;