-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmemems.c
47 lines (35 loc) · 1007 Bytes
/
memems.c
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
#include "compiler.h"
#include "cpucore.h"
#include "pccore.h"
#include "iocore.h"
#include "memems.h"
REG8 MEMCALL memems_rd8(UINT32 address) {
return(CPU_EMSPTR[(address >> 14) & 3][LOW14(address)]);
}
REG16 MEMCALL memems_rd16(UINT32 address) {
const UINT8 *ptr;
REG16 ret;
if ((address & 0x3fff) != 0x3fff) {
ptr = CPU_EMSPTR[(address >> 14) & 3] + LOW14(address);
return(LOADINTELWORD(ptr));
}
else {
ret = CPU_EMSPTR[(address >> 14) & 3][0x3fff];
ret += CPU_EMSPTR[((address + 1) >> 14) & 3][0] << 8;
return(ret);
}
}
void MEMCALL memems_wr8(UINT32 address, REG8 value) {
CPU_EMSPTR[(address >> 14) & 3][LOW14(address)] = (UINT8)value;
}
void MEMCALL memems_wr16(UINT32 address, REG16 value) {
UINT8 *ptr;
if ((address & 0x3fff) != 0x3fff) {
ptr = CPU_EMSPTR[(address >> 14) & 3] + LOW14(address);
STOREINTELWORD(ptr, value);
}
else {
CPU_EMSPTR[(address >> 14) & 3][0x3fff] = (UINT8)value;
CPU_EMSPTR[((address + 1) >> 14) & 3][0] = (UINT8)(value >> 8);
}
}