more wip SVP code
[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     *(u16 *)(svp->ram + (a&0x1fffe)) = d;
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->ram + (a&0x1fffe)) = d;
44
45   // debug: detect RAM clears..
46   CLEAR_DETECT(0x0221dc, 0x0221f0, "SVP RAM CLEAR (1)");
47   CLEAR_DETECT(0x02204c, 0x022068, "SVP RAM CLEAR (2)");
48   CLEAR_DETECT(0x021900, 0x021ff0, "SVP RAM CLEAR 300000-305fff");
49   clearing_ram = 0;
50
51   elprintf(EL_UIO, "SVP w%i: [%06x], %04x @%06x", realsize, a&0xffffff, d, SekPc);
52 }
53