svp...
[picodrive.git] / Pico / carthw / svp / Memory.c
1 #include "../../PicoInt.h"
2
3 #ifndef UTYPES_DEFINED
4 typedef unsigned char  u8;
5 typedef unsigned short u16;
6 typedef unsigned int   u32;
7 #define UTYPES_DEFINED
8 #endif
9
10 #define CLEAR_DETECT(pc_start,pc_end,text) \
11   if (d == 0 && SekPc >= pc_start && SekPc < pc_end) \
12   { \
13     if (!clearing_ram) \
14       elprintf(EL_UIO, text); \
15     clearing_ram = 1; \
16     return; \
17   }
18
19 unsigned int PicoSVPRead16(unsigned int a, int realsize)
20 {
21   unsigned int d = 0;
22
23   if ((a & 0xfe0000) == 0x300000)
24     d = *(u16 *)(svp->dram + (a&0x1fffe));
25
26   elprintf(EL_UIO, "SVP r%i: [%06x] %04x @%06x", realsize, a&0xffffff, d, SekPc);
27
28   // if (a == 0x30fe02) d = 1;
29
30   return d;
31 }
32
33 void PicoSVPWrite8(unsigned int a, unsigned int d, int realsize)
34 {
35   elprintf(EL_UIO, "!!! SVP w%i: [%06x], %08x @%06x", realsize, a&0xffffff, d, SekPc);
36 }
37
38 void PicoSVPWrite16(unsigned int a, unsigned int d, int realsize)
39 {
40   static int clearing_ram = 0;
41
42   if ((a & 0xfe0000) == 0x300000)
43     *(u16 *)(svp->dram + (a&0x1fffe)) = d;
44
45   if (a == 0x30fe06 && d != 0)
46     svp->ssp1601.emu_status &= ~SSP_30FE06_WAIT;
47
48   if (a == 0x30fe08 && d != 0)
49     svp->ssp1601.emu_status &= ~SSP_30FE08_WAIT;
50
51   // debug: detect RAM clears..
52   CLEAR_DETECT(0x0221dc, 0x0221f0, "SVP RAM CLEAR (full) @ 0221C2");
53   CLEAR_DETECT(0x02204c, 0x022068, "SVP RAM CLEAR 300000-31ffbf (1) @ 022032");
54   CLEAR_DETECT(0x021900, 0x021ff0, "SVP RAM CLEAR 300000-305fff");
55   CLEAR_DETECT(0x0220b0, 0x0220cc, "SVP RAM CLEAR 300000-31ffbf (2) @ 022096");
56   clearing_ram = 0;
57
58   elprintf(EL_UIO, "SVP w%i: [%06x], %04x @%06x", realsize, a&0xffffff, d, SekPc);
59
60   // just guessing here
61        if (a == 0xa15002) svp->ssp1601.gr[SSP_XST].h = d;
62   else if (a == 0xa15006) svp->ssp1601.gr[SSP_PM0].h = d | (d << 1);
63 }
64