summaryrefslogtreecommitdiff
path: root/apps/codecs/libgme/gbs_cpu.c
diff options
context:
space:
mode:
Diffstat (limited to 'apps/codecs/libgme/gbs_cpu.c')
-rw-r--r--apps/codecs/libgme/gbs_cpu.c32
1 files changed, 16 insertions, 16 deletions
diff --git a/apps/codecs/libgme/gbs_cpu.c b/apps/codecs/libgme/gbs_cpu.c
index 998888fe72..1015dd5358 100644
--- a/apps/codecs/libgme/gbs_cpu.c
+++ b/apps/codecs/libgme/gbs_cpu.c
@@ -20,7 +20,7 @@ Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */
20 #define LOG_MEM( addr, str, data ) data 20 #define LOG_MEM( addr, str, data ) data
21#endif 21#endif
22 22
23int Read_mem( struct Gbs_Emu* this, addr_t addr ) 23int read_mem( struct Gbs_Emu* this, addr_t addr )
24{ 24{
25 int result = *Cpu_get_code( &this->cpu, addr ); 25 int result = *Cpu_get_code( &this->cpu, addr );
26 if ( (unsigned) (addr - io_addr) < io_size ) 26 if ( (unsigned) (addr - io_addr) < io_size )
@@ -29,19 +29,19 @@ int Read_mem( struct Gbs_Emu* this, addr_t addr )
29 return LOG_MEM( addr, ">", result ); 29 return LOG_MEM( addr, ">", result );
30} 30}
31 31
32static inline void Write_io_inline( struct Gbs_Emu* this, int offset, int data, int base ) 32static inline void write_io_inline( struct Gbs_Emu* this, int offset, int data, int base )
33{ 33{
34 if ( (unsigned) (offset - (io_addr - base)) < io_size ) 34 if ( (unsigned) (offset - (io_addr - base)) < io_size )
35 Apu_write_register( &this->apu, Time( this ), offset + base, data & 0xFF ); 35 Apu_write_register( &this->apu, Time( this ), offset + base, data & 0xFF );
36 else if ( (unsigned) (offset - (0xFF06 - base)) < 2 ) 36 else if ( (unsigned) (offset - (0xFF06 - base)) < 2 )
37 Update_timer( this ); 37 update_timer( this );
38 else if ( offset == io_base - base ) 38 else if ( offset == io_base - base )
39 this->ram [base - ram_addr + offset] = 0; // keep joypad return value 0 39 this->ram [base - ram_addr + offset] = 0; // keep joypad return value 0
40 else 40 else
41 this->ram [base - ram_addr + offset] = 0xFF; 41 this->ram [base - ram_addr + offset] = 0xFF;
42} 42}
43 43
44void Write_mem( struct Gbs_Emu* this, addr_t addr, int data ) 44void write_mem( struct Gbs_Emu* this, addr_t addr, int data )
45{ 45{
46 (void) LOG_MEM( addr, "<", data ); 46 (void) LOG_MEM( addr, "<", data );
47 47
@@ -52,11 +52,11 @@ void Write_mem( struct Gbs_Emu* this, addr_t addr, int data )
52 52
53 offset -= 0xE000 - ram_addr; 53 offset -= 0xE000 - ram_addr;
54 if ( (unsigned) offset < 0x1F80 ) 54 if ( (unsigned) offset < 0x1F80 )
55 Write_io_inline( this, offset, data, 0xE000 ); 55 write_io_inline( this, offset, data, 0xE000 );
56 } 56 }
57 else if ( (unsigned) (offset - (0x2000 - ram_addr)) < 0x2000 ) 57 else if ( (unsigned) (offset - (0x2000 - ram_addr)) < 0x2000 )
58 { 58 {
59 Set_bank( this, data & 0xFF ); 59 set_bank( this, data & 0xFF );
60 } 60 }
61#ifndef NDEBUG 61#ifndef NDEBUG
62 else if ( unsigned (addr - 0x8000) < 0x2000 || unsigned (addr - 0xE000) < 0x1F00 ) 62 else if ( unsigned (addr - 0x8000) < 0x2000 || unsigned (addr - 0xE000) < 0x1F00 )
@@ -66,21 +66,21 @@ void Write_mem( struct Gbs_Emu* this, addr_t addr, int data )
66#endif 66#endif
67} 67}
68 68
69static void Write_io_( struct Gbs_Emu* this, int offset, int data ) 69static void write_io_( struct Gbs_Emu* this, int offset, int data )
70{ 70{
71 Write_io_inline( this, offset, data, io_base ); 71 write_io_inline( this, offset, data, io_base );
72} 72}
73 73
74static inline void Write_io( struct Gbs_Emu* this, int offset, int data ) 74static inline void write_io( struct Gbs_Emu* this, int offset, int data )
75{ 75{
76 (void) LOG_MEM( offset + io_base, "<", data ); 76 (void) LOG_MEM( offset + io_base, "<", data );
77 77
78 this->ram [io_base - ram_addr + offset] = data; 78 this->ram [io_base - ram_addr + offset] = data;
79 if ( (unsigned) offset < 0x80 ) 79 if ( (unsigned) offset < 0x80 )
80 Write_io_( this, offset, data ); 80 write_io_( this, offset, data );
81} 81}
82 82
83static int Read_io( struct Gbs_Emu* this, int offset ) 83static int read_io( struct Gbs_Emu* this, int offset )
84{ 84{
85 int const io_base = 0xFF00; 85 int const io_base = 0xFF00;
86 int result = this->ram [io_base - ram_addr + offset]; 86 int result = this->ram [io_base - ram_addr + offset];
@@ -106,14 +106,14 @@ static int Read_io( struct Gbs_Emu* this, int offset )
106 check( out == Read_mem( emu, addr ) );\ 106 check( out == Read_mem( emu, addr ) );\
107} 107}
108 108
109#define READ_MEM( emu, addr ) Read_mem( emu, addr ) 109#define READ_MEM( emu, addr ) read_mem( emu, addr )
110#define WRITE_MEM( emu, addr, data ) Write_mem( emu, addr, data ) 110#define WRITE_MEM( emu, addr, data ) write_mem( emu, addr, data )
111 111
112#define WRITE_IO( emu, addr, data ) Write_io( emu, addr, data ) 112#define WRITE_IO( emu, addr, data ) write_io( emu, addr, data )
113#define READ_IO( emu, addr, out ) out = Read_io( emu, addr ) 113#define READ_IO( emu, addr, out ) out = read_io( emu, addr )
114 114
115#define CPU_BEGIN \ 115#define CPU_BEGIN \
116void Run_cpu( struct Gbs_Emu* this )\ 116void run_cpu( struct Gbs_Emu* this )\
117{ \ 117{ \
118 struct Gb_Cpu* cpu = &this->cpu; 118 struct Gb_Cpu* cpu = &this->cpu;
119 #include "gb_cpu_run.h" 119 #include "gb_cpu_run.h"