summaryrefslogtreecommitdiff
path: root/apps/plugins/rockboy/mem.h
diff options
context:
space:
mode:
Diffstat (limited to 'apps/plugins/rockboy/mem.h')
-rw-r--r--apps/plugins/rockboy/mem.h80
1 files changed, 80 insertions, 0 deletions
diff --git a/apps/plugins/rockboy/mem.h b/apps/plugins/rockboy/mem.h
new file mode 100644
index 0000000000..7926e2eda9
--- /dev/null
+++ b/apps/plugins/rockboy/mem.h
@@ -0,0 +1,80 @@
1
2#ifndef __MEM_H__
3#define __MEM_H__
4
5
6#include "defs.h"
7
8
9
10#define MBC_NONE 0
11#define MBC_MBC1 1
12#define MBC_MBC2 2
13#define MBC_MBC3 3
14#define MBC_MBC5 5
15#define MBC_RUMBLE 15
16#define MBC_HUC1 0xC1
17#define MBC_HUC3 0xC3
18
19struct mbc
20{
21 int type;
22 int model;
23 int rombank;
24 int rambank;
25 int romsize;
26 int ramsize;
27 int enableram;
28 int batt;
29 byte *rmap[0x10], *wmap[0x10];
30};
31
32struct rom
33{
34 byte (*bank)[16384];
35 char name[20];
36};
37
38struct ram
39{
40 byte hi[256];
41 byte ibank[8][4096];
42 byte (*sbank)[8192];
43 int loaded;
44};
45
46
47extern struct mbc mbc;
48extern struct rom rom;
49extern struct ram ram;
50
51
52
53
54
55void mem_updatemap(void);
56void ioreg_write(byte r, byte b);
57void mbc_write(int a, byte b);
58void mem_write(int a, byte b);
59byte mem_read(int a);
60void mbc_reset(void);
61
62
63
64#define READB(a) ( mbc.rmap[(a)>>12] \
65? mbc.rmap[(a)>>12][(a)] \
66: mem_read((a)) )
67#define READW(a) ( READB((a)) | ((word)READB((a)+1)<<8) )
68
69#define WRITEB(a, b) ( mbc.wmap[(a)>>12] \
70? ( mbc.wmap[(a)>>12][(a)] = (b) ) \
71: ( mem_write((a), (b)), (b) ) )
72#define WRITEW(a, w) ( WRITEB((a), (w)&0xFF), WRITEB((a)+1, (w)>>8) )
73
74
75
76
77#endif
78
79
80