-
Notifications
You must be signed in to change notification settings - Fork 1
/
memory.h
72 lines (63 loc) · 1.74 KB
/
memory.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
/*
* UAE - The Unusable Amiga Emulator
*
* memory management v0.1
*
* (c) 1995 Bernd Schmidt
*/
const int chipmem_size = 512;
const int fastmem_size = 1024;
const int bogomem_size = 256; // C00000 crap mem
class address64k {
public:
virtual UWORD wget(UWORD addr) = 0;
virtual void wput(UWORD addr, UWORD value) = 0;
virtual UBYTE bget(UWORD addr) = 0;
virtual void bput(UWORD addr, UBYTE value) = 0;
};
class ram64k: public address64k {
protected:
UWORD ram[32768];
public:
virtual UWORD wget(UWORD addr);
virtual void wput(UWORD addr, UWORD value);
virtual UBYTE bget(UWORD addr);
virtual void bput(UWORD addr, UBYTE value);
};
class custom64k: public address64k {
struct cchipaddr {
UWORD (*get)();
void (*put)(UWORD);
};
static cchipaddr *cchiptable;
struct custom_func {
UWORD addr;
cchipaddr fptrs;
};
static custom_func functable[];
public:
custom64k();
virtual UWORD wget(UWORD addr);
virtual void wput(UWORD addr, UWORD value);
virtual UBYTE bget(UWORD addr);
virtual void bput(UWORD addr, UBYTE value);
};
class cia64k: public address64k {
public:
virtual UWORD wget(UWORD addr);
virtual void wput(UWORD addr, UWORD value);
virtual UBYTE bget(UWORD addr);
virtual void bput(UWORD addr, UBYTE value);
};
class amigamemory {
private:
address64k *banks[256]; // memory size is restricted to 16M
public:
amigamemory();
~amigamemory();
UWORD get_word(CPTR addr) { return banks[addr>>16]->wget(addr & 0xffff); }
UBYTE get_byte(CPTR addr) { return banks[addr>>16]->bget(addr & 0xffff); }
void put_word(CPTR a,UWORD w) { banks[a>>16]->wput(a & 0xffff, w); }
void put_byte(CPTR a,UBYTE b) { banks[a>>16]->bput(a & 0xffff, b); }
};
extern amigamemory mem;