1 // The SVP chip emulator, mem I/O stuff
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 "../../pico_int.h"
10 #include "../../memory.h"
13 // "cell arrange" 1: 390000-39ffff
14 else if ((a & 0xff0000) == 0x390000) {
15 // this is rewritten 68k code
16 unsigned int a1 = a >> 1;
17 a1 = (a1 & 0x7001) | ((a1 & 0x3e) << 6) | ((a1 & 0xfc0) >> 5);
18 d = ((u16 *)svp->dram)[a1];
21 // "cell arrange" 2: 3a0000-3affff
22 else if ((a & 0xff0000) == 0x3a0000) {
23 // this is rewritten 68k code
24 unsigned int a1 = a >> 1;
25 a1 = (a1 & 0x7801) | ((a1 & 0x1e) << 6) | ((a1 & 0x7e0) >> 4);
26 d = ((u16 *)svp->dram)[a1];
30 // IO/control area (0xa10000 - 0xa1ffff)
31 static u32 PicoRead16_svpr(u32 a)
36 if ((a & 0xfffff0) == 0xa15000) {
40 d = svp->ssp1601.gr[SSP_XST].h;
44 d = svp->ssp1601.gr[SSP_PM0].h;
45 svp->ssp1601.gr[SSP_PM0].h &= ~1;
49 #if EL_LOGMASK & EL_SVP
51 static int a15004_looping = 0;
52 if (a == 0xa15004 && (d & 1))
56 elprintf(EL_SVP, "SVP r%i: [%06x] %04x @%06x", realsize, a, d, SekPc);
58 if (a == 0xa15004 && !(d&1)) {
60 elprintf(EL_SVP, "SVP det TIGHT loop: a15004");
70 //if (a == 0x30fe02 && d == 0)
71 // elprintf(EL_ANOMALY, "SVP lag?");
73 return PicoRead16_io(a);
76 static void PicoWrite16_svpr(u32 a, u32 d)
78 elprintf(EL_SVP, "SVP w16: [%06x] %04x @%06x", a, d, SekPc);
80 if ((a & 0xfffff0) == 0xa15000) {
81 if (a == 0xa15000 || a == 0xa15002) {
83 svp->ssp1601.gr[SSP_XST].h = d;
84 svp->ssp1601.gr[SSP_PM0].h |= 2;
85 svp->ssp1601.emu_status &= ~SSP_WAIT_PM0;
87 //else if (a == 0xa15006) svp->ssp1601.gr[SSP_PM0].h = d | (d << 1);
88 // 0xa15006 probably has 'halt'
94 if (a == 0x30fe06 && d != 0)
95 svp->ssp1601.emu_status &= ~SSP_WAIT_30FE06;
97 if (a == 0x30fe08 && d != 0)
98 svp->ssp1601.emu_status &= ~SSP_WAIT_30FE08;
102 void PicoSVPMemSetup(void)
106 cpu68k_map_set(m68k_read8_map, 0x300000, 0x31ffff, svp->dram, 0);
107 cpu68k_map_set(m68k_read16_map, 0x300000, 0x31ffff, svp->dram, 0);
108 cpu68k_map_set(m68k_write8_map, 0x300000, 0x31ffff, svp->dram, 0);
109 cpu68k_map_set(m68k_write16_map, 0x300000, 0x31ffff, svp->dram, 0);
111 // DRAM (cell arrange) - TODO
114 cpu68k_map_set(m68k_read8_map, 0xa10000, 0xa1ffff, PicoRead8_io, 1); // PicoRead8_svpr
115 cpu68k_map_set(m68k_read16_map, 0xa10000, 0xa1ffff, PicoRead16_svpr, 1);
116 cpu68k_map_set(m68k_write8_map, 0xa10000, 0xa1ffff, PicoWrite8_io, 1); // PicoWrite8_svpr
117 cpu68k_map_set(m68k_write16_map, 0xa10000, 0xa1ffff, PicoWrite16_svpr, 1);