summaryrefslogtreecommitdiff
path: root/apps/codecs/libgme/hes_cpu_io.h
diff options
context:
space:
mode:
Diffstat (limited to 'apps/codecs/libgme/hes_cpu_io.h')
-rw-r--r--apps/codecs/libgme/hes_cpu_io.h72
1 files changed, 72 insertions, 0 deletions
diff --git a/apps/codecs/libgme/hes_cpu_io.h b/apps/codecs/libgme/hes_cpu_io.h
new file mode 100644
index 0000000000..6b49c69e22
--- /dev/null
+++ b/apps/codecs/libgme/hes_cpu_io.h
@@ -0,0 +1,72 @@
1
2#include "hes_emu.h"
3
4#include "blargg_source.h"
5
6int Cpu_read( struct Hes_Emu* this, hes_addr_t addr )
7{
8 check( addr <= 0xFFFF );
9 int result = *Cpu_get_code( &this->cpu, addr );
10 if ( this->cpu.mmr [addr >> page_shift] == 0xFF )
11 result = Emu_cpu_read( this, addr );
12 return result;
13}
14
15void Cpu_write( struct Hes_Emu* this, hes_addr_t addr, int data )
16{
17 check( addr <= 0xFFFF );
18 byte* out = this->write_pages [addr >> page_shift];
19 addr &= page_size - 1;
20 if ( out )
21 out [addr] = data;
22 else if ( this->cpu.mmr [addr >> page_shift] == 0xFF )
23 Emu_cpu_write( this, addr, data );
24}
25
26#define CPU_READ_FAST( emu, addr, time, out ) \
27 CPU_READ_FAST_( emu, addr, time, out )
28
29#define CPU_READ_FAST_( emu, addr, time, out ) \
30{\
31 out = READ_PROG( addr );\
32 if ( emu->cpu.mmr [addr >> page_shift] == 0xFF )\
33 {\
34 FLUSH_TIME();\
35 out = Emu_cpu_read( emu, addr );\
36 CACHE_TIME();\
37 }\
38}
39
40#define CPU_WRITE_FAST( emu, addr, data, time ) \
41 CPU_WRITE_FAST_( emu, addr, data, time )
42
43#define CPU_WRITE_FAST_( emu, addr, data, time ) \
44{\
45 byte* out = emu->write_pages [addr >> page_shift];\
46 addr &= page_size - 1;\
47 if ( out )\
48 {\
49 out [addr] = data;\
50 }\
51 else if ( emu->cpu.mmr [addr >> page_shift] == 0xFF )\
52 {\
53 FLUSH_TIME();\
54 Emu_cpu_write( emu, addr, data );\
55 CACHE_TIME();\
56 }\
57}
58
59#define CPU_READ( emu, addr, time ) \
60 Cpu_read( emu, addr )
61
62#define CPU_WRITE( emu, addr, data, time ) \
63 Cpu_write( emu, addr, data )
64
65#define CPU_WRITE_VDP( emu, addr, data, time ) \
66 Cpu_write_vdp( emu, addr, data )
67
68#define CPU_SET_MMR( emu, page, bank ) \
69 Emu_cpu_set_mmr( emu, page, bank )
70
71#define CPU_DONE( emu, time, result_out ) \
72 result_out = Cpu_done( emu )