gba_memory.c - some cleanups

This commit is contained in:
twinaphex 2014-12-20 08:25:17 +01:00
parent ab96870240
commit 9fe97ba148
1 changed files with 3 additions and 19 deletions

View File

@ -535,9 +535,7 @@ void function_cc write_eeprom(u32 address, u32 value)
eeprom_counter = 0; eeprom_counter = 0;
if(eeprom_mode == EEPROM_ADDRESS_MODE) if(eeprom_mode == EEPROM_ADDRESS_MODE)
{
eeprom_mode = EEPROM_ADDRESS_FOOTER_MODE; eeprom_mode = EEPROM_ADDRESS_FOOTER_MODE;
}
else else
{ {
eeprom_mode = EEPROM_WRITE_MODE; eeprom_mode = EEPROM_WRITE_MODE;
@ -561,13 +559,9 @@ void function_cc write_eeprom(u32 address, u32 value)
case EEPROM_WRITE_FOOTER_MODE: case EEPROM_WRITE_FOOTER_MODE:
eeprom_counter = 0; eeprom_counter = 0;
if(eeprom_mode == EEPROM_ADDRESS_FOOTER_MODE) if(eeprom_mode == EEPROM_ADDRESS_FOOTER_MODE)
{
eeprom_mode = EEPROM_READ_HEADER_MODE; eeprom_mode = EEPROM_READ_HEADER_MODE;
}
else else
{
eeprom_mode = EEPROM_BASE_MODE; eeprom_mode = EEPROM_BASE_MODE;
}
break; break;
default: default:
@ -598,9 +592,7 @@ void function_cc write_eeprom(u32 address, u32 value)
#define read_open32() \ #define read_open32() \
if(!(reg[REG_CPSR] & 0x20)) \ if(!(reg[REG_CPSR] & 0x20)) \
{ \
value = read_memory32(reg[REG_PC] + 4); \ value = read_memory32(reg[REG_PC] + 4); \
} \
else \ else \
{ \ { \
u32 current_instruction = read_memory16(reg[REG_PC] + 2); \ u32 current_instruction = read_memory16(reg[REG_PC] + 2); \
@ -700,9 +692,7 @@ u32 function_cc read_eeprom(void)
case 0x0C: \ case 0x0C: \
/* gamepak ROM */ \ /* gamepak ROM */ \
if((address & 0x1FFFFFF) >= gamepak_size) \ if((address & 0x1FFFFFF) >= gamepak_size) \
{ \
value = 0; \ value = 0; \
} \
else \ else \
{ \ { \
read_memory_gamepak(type); \ read_memory_gamepak(type); \
@ -1640,9 +1630,7 @@ void function_cc write_backup(u32 address, u32 value)
if((address == 0x2AAA) && (value == 0x55) && if((address == 0x2AAA) && (value == 0x55) &&
(flash_command_position == 1)) (flash_command_position == 1))
{
flash_command_position = 2; flash_command_position = 2;
}
else else
{ {
if((flash_command_position == 2) && if((flash_command_position == 2) &&
@ -1737,7 +1725,7 @@ u32 rtc_status = 0x40;
u32 rtc_data_bytes; u32 rtc_data_bytes;
s32 rtc_bit_count; s32 rtc_bit_count;
u32 encode_bcd(u8 value) static u32 encode_bcd(u8 value)
{ {
return ((value / 10) << 4) | (value % 10); return ((value / 10) << 4) | (value % 10);
} }
@ -2039,13 +2027,9 @@ u16 function_cc read_memory16_signed(u32 address)
u16 value; u16 value;
if(address & 0x01) if(address & 0x01)
{
return (s8)read_memory8(address); return (s8)read_memory8(address);
}
else read_memory(16);
{
read_memory(16);
}
return value; return value;
} }