fix FS#8187 - charging breaks sleep timer. Now if the timer goes off and the player...
[Rockbox.git] / apps / plugins / rockboy / fastmem.c
blob9092f68fed5d4c6e1f4961438094421df9b95fa6
3 #include "rockmacros.h"
4 #include "fastmem.h"
6 byte readb(int a)
8 byte *p = mbc.rmap[a>>12];
9 if (p) return p[a];
10 else return mem_read(a);
13 void writeb(int a, byte b)
15 byte *p = mbc.wmap[a>>12];
16 if (p) p[a] = b;
17 else mem_write(a, b);
20 int readw(int a)
22 if ((a+1) & 0xfff)
24 byte *p = mbc.rmap[a>>12];
25 if (p)
27 #ifdef ROCKBOX_LITTLE_ENDIAN
28 #ifndef ALLOW_UNALIGNED_IO
29 if (a&1) return p[a] | (p[a+1]<<8);
30 #endif
31 return *(word *)(p+a);
32 #else
33 return p[a] | (p[a+1]<<8);
34 #endif
37 return mem_read(a) | (mem_read(a+1)<<8);
40 void writew(int a, int w)
42 if ((a+1) & 0xfff)
44 byte *p = mbc.wmap[a>>12];
45 if (p)
47 #ifdef ROCKBOX_LITTLE_ENDIAN
48 #ifndef ALLOW_UNALIGNED_IO
49 if (a&1)
51 p[a] = w;
52 p[a+1] = w >> 8;
53 return;
55 #endif
56 *(word *)(p+a) = w;
57 return;
58 #else
59 p[a] = w;
60 p[a+1] = w >> 8;
61 return;
62 #endif
65 mem_write(a, w);
66 mem_write(a+1, w>>8);
69 byte readhi(int a)
71 return readb(a | 0xff00);
74 void writehi(int a, byte b)
76 writeb(a | 0xff00, b);