diff options
author | Jens Arnold <amiconn@rockbox.org> | 2005-03-02 23:49:38 +0000 |
---|---|---|
committer | Jens Arnold <amiconn@rockbox.org> | 2005-03-02 23:49:38 +0000 |
commit | 384de102469fee4e0792df8fe38586d3206774ed (patch) | |
tree | ee5342103e17738acfb8421328ea7c57433f55e6 /apps/plugins/rockboy/fastmem.c | |
parent | 48dad47df98bdec632e8930b6a97359dc2c428f5 (diff) | |
download | rockbox-384de102469fee4e0792df8fe38586d3206774ed.tar.gz rockbox-384de102469fee4e0792df8fe38586d3206774ed.zip |
Rockboy - gameboy emulation for rockbox, based on gnuboy. Still a bit early, but already playable on iRiver H1xx and the simulators. The archos recorder version is currently rather slow...
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@6104 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/plugins/rockboy/fastmem.c')
-rw-r--r-- | apps/plugins/rockboy/fastmem.c | 138 |
1 files changed, 138 insertions, 0 deletions
diff --git a/apps/plugins/rockboy/fastmem.c b/apps/plugins/rockboy/fastmem.c new file mode 100644 index 0000000000..ffb0ed5371 --- /dev/null +++ b/apps/plugins/rockboy/fastmem.c | |||
@@ -0,0 +1,138 @@ | |||
1 | |||
2 | |||
3 | #include "rockmacros.h" | ||
4 | #include "fastmem.h" | ||
5 | |||
6 | |||
7 | #define D 0 /* direct */ | ||
8 | #define C 1 /* direct cgb-only */ | ||
9 | #define R 2 /* io register */ | ||
10 | #define S 3 /* sound register */ | ||
11 | #define W 4 /* wave pattern */ | ||
12 | |||
13 | #define F 0xFF /* fail */ | ||
14 | |||
15 | const byte himask[256]; | ||
16 | |||
17 | const byte hi_rmap[256] = | ||
18 | { | ||
19 | 0, 0, R, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, | ||
20 | S, S, S, S, S, S, S, S, S, S, S, S, S, S, S, S, | ||
21 | S, S, S, S, S, S, S, S, S, S, S, S, S, S, S, S, | ||
22 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, | ||
23 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, C, 0, C, | ||
24 | 0, C, C, C, C, C, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, | ||
25 | 0, 0, 0, 0, 0, 0, 0, 0, C, C, C, C, 0, 0, 0, 0, | ||
26 | C, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 | ||
27 | }; | ||
28 | |||
29 | const byte hi_wmap[256] = | ||
30 | { | ||
31 | R, R, R, R, R, R, R, R, R, R, R, R, R, R, R, R, | ||
32 | S, S, S, S, S, S, S, S, S, S, S, S, S, S, S, S, | ||
33 | S, S, S, S, S, S, S, S, S, S, S, S, S, S, S, S, | ||
34 | S, S, S, S, S, S, S, S, S, S, S, S, S, S, S, S, | ||
35 | R, R, R, R, R, R, R, R, R, R, R, R, 0, R, 0, R, | ||
36 | 0, C, C, C, C, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, | ||
37 | 0, 0, 0, 0, 0, 0, 0, 0, R, R, R, R, 0, 0, 0, 0, | ||
38 | R, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, | ||
39 | |||
40 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, | ||
41 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, | ||
42 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, | ||
43 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, | ||
44 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, | ||
45 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, | ||
46 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, | ||
47 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, R | ||
48 | }; | ||
49 | |||
50 | |||
51 | byte readb(int a) | ||
52 | { | ||
53 | byte *p = mbc.rmap[a>>12]; | ||
54 | if (p) return p[a]; | ||
55 | else return mem_read(a); | ||
56 | } | ||
57 | |||
58 | void writeb(int a, byte b) | ||
59 | { | ||
60 | byte *p = mbc.wmap[a>>12]; | ||
61 | if (p) p[a] = b; | ||
62 | else mem_write(a, b); | ||
63 | } | ||
64 | |||
65 | int readw(int a) | ||
66 | { | ||
67 | if ((a+1) & 0xfff) | ||
68 | { | ||
69 | byte *p = mbc.rmap[a>>12]; | ||
70 | if (p) | ||
71 | { | ||
72 | #ifdef LITTLE_ENDIAN | ||
73 | #ifndef ALLOW_UNALIGNED_IO | ||
74 | if (a&1) return p[a] | (p[a+1]<<8); | ||
75 | #endif | ||
76 | return *(word *)(p+a); | ||
77 | #else | ||
78 | return p[a] | (p[a+1]<<8); | ||
79 | #endif | ||
80 | } | ||
81 | } | ||
82 | return mem_read(a) | (mem_read(a+1)<<8); | ||
83 | } | ||
84 | |||
85 | void writew(int a, int w) | ||
86 | { | ||
87 | if ((a+1) & 0xfff) | ||
88 | { | ||
89 | byte *p = mbc.wmap[a>>12]; | ||
90 | if (p) | ||
91 | { | ||
92 | #ifdef LITTLE_ENDIAN | ||
93 | #ifndef ALLOW_UNALIGNED_IO | ||
94 | if (a&1) | ||
95 | { | ||
96 | p[a] = w; | ||
97 | p[a+1] = w >> 8; | ||
98 | return; | ||
99 | } | ||
100 | #endif | ||
101 | *(word *)(p+a) = w; | ||
102 | return; | ||
103 | #else | ||
104 | p[a] = w; | ||
105 | p[a+1] = w >> 8; | ||
106 | return; | ||
107 | #endif | ||
108 | } | ||
109 | } | ||
110 | mem_write(a, w); | ||
111 | mem_write(a+1, w>>8); | ||
112 | } | ||
113 | |||
114 | byte readhi(int a) | ||
115 | { | ||
116 | return readb(a | 0xff00); | ||
117 | } | ||
118 | |||
119 | void writehi(int a, byte b) | ||
120 | { | ||
121 | writeb(a | 0xff00, b); | ||
122 | } | ||
123 | |||
124 | #if 0 | ||
125 | byte readhi(int a) | ||
126 | { | ||
127 | byte (*rd)() = hi_read[a]; | ||
128 | return rd ? rd(a) : (ram.hi[a] | himask[a]); | ||
129 | } | ||
130 | |||
131 | void writehi(int a, byte b) | ||
132 | { | ||
133 | byte (*wr)() = hi_write[a]; | ||
134 | if (wr) wr(a, b); | ||
135 | else ram.hi[a] = b & ~himask[a]; | ||
136 | } | ||
137 | #endif | ||
138 | |||