Style nits

This commit is contained in:
twinaphex 2014-12-10 15:47:19 +01:00
parent 1cd8bb5235
commit 7a0b0cba45
11 changed files with 62 additions and 97 deletions

View File

@ -365,7 +365,7 @@ void process_cheat_gs3(cheat_type *cheat)
} }
void process_cheats() void process_cheats(void)
{ {
u32 i; u32 i;

View File

@ -35,7 +35,7 @@ typedef struct
cheat_variant_enum cheat_variant; cheat_variant_enum cheat_variant;
} cheat_type; } cheat_type;
void process_cheats(); void process_cheats(void);
void add_cheats(char *cheats_filename); void add_cheats(char *cheats_filename);
#define MAX_CHEATS 16 #define MAX_CHEATS 16

22
cpu.c
View File

@ -99,7 +99,7 @@ int sort_tagged_element(const void *_a, const void *_b)
return (int)(b[1] - a[1]); return (int)(b[1] - a[1]);
} }
void print_register_usage() void print_register_usage(void)
{ {
u32 i; u32 i;
u64 arm_reg_freq_tagged[32]; u64 arm_reg_freq_tagged[32];
@ -4001,15 +4001,14 @@ void set_cpu_mode(cpu_mode_type new_mode)
u32 i; u32 i;
cpu_mode_type cpu_mode = reg[CPU_MODE]; cpu_mode_type cpu_mode = reg[CPU_MODE];
if(cpu_mode != new_mode) if(cpu_mode == new_mode)
{ return;
if(new_mode == MODE_FIQ) if(new_mode == MODE_FIQ)
{ {
for(i = 8; i < 15; i++) for(i = 8; i < 15; i++)
{
reg_mode[cpu_mode][i - 8] = reg[i]; reg_mode[cpu_mode][i - 8] = reg[i];
} }
}
else else
{ {
reg_mode[cpu_mode][5] = reg[REG_SP]; reg_mode[cpu_mode][5] = reg[REG_SP];
@ -4019,10 +4018,8 @@ void set_cpu_mode(cpu_mode_type new_mode)
if(cpu_mode == MODE_FIQ) if(cpu_mode == MODE_FIQ)
{ {
for(i = 8; i < 15; i++) for(i = 8; i < 15; i++)
{
reg[i] = reg_mode[new_mode][i - 8]; reg[i] = reg_mode[new_mode][i - 8];
} }
}
else else
{ {
reg[REG_SP] = reg_mode[new_mode][5]; reg[REG_SP] = reg_mode[new_mode][5];
@ -4031,7 +4028,6 @@ void set_cpu_mode(cpu_mode_type new_mode)
reg[CPU_MODE] = new_mode; reg[CPU_MODE] = new_mode;
} }
}
void raise_interrupt(irq_type irq_raised) void raise_interrupt(irq_type irq_raised)
{ {
@ -4119,29 +4115,23 @@ void execute_arm(u32 cycles)
alert: alert:
if(cpu_alert == CPU_ALERT_IRQ) if(cpu_alert == CPU_ALERT_IRQ)
{
cycles = cycles_remaining; cycles = cycles_remaining;
}
else else
{ {
collapse_flags(); collapse_flags();
while(reg[CPU_HALT_STATE] != CPU_ACTIVE) while(reg[CPU_HALT_STATE] != CPU_ACTIVE)
{
cycles = update_gba(); cycles = update_gba();
} }
} }
} }
}
void init_cpu() void init_cpu(void)
{ {
u32 i; u32 i;
for(i = 0; i < 16; i++) for(i = 0; i < 16; i++)
{
reg[i] = 0; reg[i] = 0;
}
reg[REG_SP] = 0x03007F00; reg[REG_SP] = 0x03007F00;
reg[REG_PC] = 0x08000000; reg[REG_PC] = 0x08000000;
@ -4161,9 +4151,7 @@ void move_reg(u32 *new_reg)
u32 i; u32 i;
for(i = 0; i < 32; i++) for(i = 0; i < 32; i++)
{
new_reg[i] = reg[i]; new_reg[i] = reg[i];
}
reg = new_reg; reg = new_reg;
} }

View File

@ -3615,7 +3615,7 @@ s32 translate_block_thumb(u32 pc, translation_region_type
return 0; return 0;
} }
void flush_translation_cache_ram() void flush_translation_cache_ram(void)
{ {
flush_ram_count++; flush_ram_count++;
/* printf("ram flush %d (pc %x), %x to %x, %x to %x\n", /* printf("ram flush %d (pc %x), %x to %x, %x to %x\n",
@ -3677,7 +3677,7 @@ void flush_translation_cache_ram()
ewram_code_max = 0xFFFFFFFF; ewram_code_max = 0xFFFFFFFF;
} }
void flush_translation_cache_rom() void flush_translation_cache_rom(void)
{ {
#ifndef PC_BUILD #ifndef PC_BUILD
invalidate_icache_region(rom_translation_cache, invalidate_icache_region(rom_translation_cache,
@ -3691,7 +3691,7 @@ void flush_translation_cache_rom()
memset(rom_branch_hash, 0, sizeof(rom_branch_hash)); memset(rom_branch_hash, 0, sizeof(rom_branch_hash));
} }
void flush_translation_cache_bios() void flush_translation_cache_bios(void)
{ {
#ifndef PC_BUILD #ifndef PC_BUILD
invalidate_icache_region(bios_translation_cache, invalidate_icache_region(bios_translation_cache,
@ -3708,7 +3708,7 @@ void flush_translation_cache_bios()
#define cache_dump_prefix "" #define cache_dump_prefix ""
void dump_translation_cache() void dump_translation_cache(void)
{ {
file_open(ram_cache, cache_dump_prefix "ram_cache.bin", write); file_open(ram_cache, cache_dump_prefix "ram_cache.bin", write);
file_write(ram_cache, ram_translation_cache, file_write(ram_cache, ram_translation_cache,

View File

@ -75,14 +75,9 @@
{ \ { \
gbc_sound_channel[2].wave_type = (value >> 5) & 0x01; \ gbc_sound_channel[2].wave_type = (value >> 5) & 0x01; \
gbc_sound_channel[2].wave_bank = (value >> 6) & 0x01; \ gbc_sound_channel[2].wave_bank = (value >> 6) & 0x01; \
if(value & 0x80) \
{ \
gbc_sound_channel[2].master_enable = 1; \
} \
else \
{ \
gbc_sound_channel[2].master_enable = 0; \ gbc_sound_channel[2].master_enable = 0; \
} \ if(value & 0x80) \
gbc_sound_channel[2].master_enable = 1; \
\ \
gbc_sound_update = 1; \ gbc_sound_update = 1; \
address16(io_registers, 0x70) = value; \ address16(io_registers, 0x70) = value; \
@ -94,14 +89,10 @@ static u32 gbc_sound_wave_volume[4] = { 0, 16384, 8192, 4096 };
{ \ { \
gbc_sound_channel[2].length_ticks = 256 - (value & 0xFF); \ gbc_sound_channel[2].length_ticks = 256 - (value & 0xFF); \
if((value >> 15) & 0x01) \ if((value >> 15) & 0x01) \
{ \
gbc_sound_channel[2].wave_volume = 12288; \ gbc_sound_channel[2].wave_volume = 12288; \
} \
else \ else \
{ \
gbc_sound_channel[2].wave_volume = \ gbc_sound_channel[2].wave_volume = \
gbc_sound_wave_volume[(value >> 13) & 0x03]; \ gbc_sound_wave_volume[(value >> 13) & 0x03]; \
} \
gbc_sound_update = 1; \ gbc_sound_update = 1; \
address16(io_registers, 0x72) = value; \ address16(io_registers, 0x72) = value; \
} \ } \
@ -191,17 +182,13 @@ static u32 gbc_sound_wave_volume[4] = { 0, 16384, 8192, 4096 };
if(value & 0x80) \ if(value & 0x80) \
{ \ { \
if(sound_on != 1) \ if(sound_on != 1) \
{ \
sound_on = 1; \ sound_on = 1; \
} \ } \
} \
else \ else \
{ \ { \
u32 i; \ u32 i; \
for(i = 0; i < 4; i++) \ for(i = 0; i < 4; i++) \
{ \
gbc_sound_channel[i].active_flag = 0; \ gbc_sound_channel[i].active_flag = 0; \
} \
sound_on = 0; \ sound_on = 0; \
} \ } \
address16(io_registers, 0x84) = \ address16(io_registers, 0x84) = \
@ -588,7 +575,7 @@ void function_cc write_eeprom(u32 address, u32 value)
u32 gamepak_index = address >> 15; \ u32 gamepak_index = address >> 15; \
u8 *map = memory_map_read[gamepak_index]; \ u8 *map = memory_map_read[gamepak_index]; \
\ \
if(map == NULL) \ if(!map) \
map = load_gamepak_page(gamepak_index & 0x3FF); \ map = load_gamepak_page(gamepak_index & 0x3FF); \
\ \
value = address##type(map, address & 0x7FFF) \ value = address##type(map, address & 0x7FFF) \
@ -724,9 +711,7 @@ u32 function_cc read_eeprom()
read_memory_gamepak(type); \ read_memory_gamepak(type); \
} \ } \
else \ else \
{ \
value = read_eeprom(); \ value = read_eeprom(); \
} \
\ \
break; \ break; \
\ \
@ -1734,7 +1719,7 @@ u32 encode_bcd(u8 value)
rtc_page_index = update_address >> 15; \ rtc_page_index = update_address >> 15; \
map = memory_map_read[rtc_page_index]; \ map = memory_map_read[rtc_page_index]; \
\ \
if(map == NULL) \ if(!map) \
map = load_gamepak_page(rtc_page_index & 0x3FF); \ map = load_gamepak_page(rtc_page_index & 0x3FF); \
\ \
address16(map, update_address & 0x7FFF) = _value \ address16(map, update_address & 0x7FFF) = _value \
@ -2215,7 +2200,7 @@ s32 parse_config_line(char *current_line, char *current_variable, char *current_
return -1; return -1;
line_ptr_new = strchr(line_ptr, ' '); line_ptr_new = strchr(line_ptr, ' ');
if(line_ptr_new == NULL) if(!line_ptr_new)
return -1; return -1;
*line_ptr_new = 0; *line_ptr_new = 0;
@ -2410,12 +2395,12 @@ u32 load_gamepak(const char *name)
gamepak_filename[sizeof(gamepak_filename) - 1] = 0; gamepak_filename[sizeof(gamepak_filename) - 1] = 0;
p = strrchr(gamepak_filename, PATH_SEPARATOR_CHAR); p = strrchr(gamepak_filename, PATH_SEPARATOR_CHAR);
if (p == NULL) if (!p)
p = gamepak_filename; p = gamepak_filename;
snprintf(backup_filename, sizeof(backup_filename), "%s/%s", save_path, p); snprintf(backup_filename, sizeof(backup_filename), "%s/%s", save_path, p);
p = strrchr(backup_filename, '.'); p = strrchr(backup_filename, '.');
if (p != NULL) if (p)
strcpy(p, ".sav"); strcpy(p, ".sav");
load_backup(backup_filename); load_backup(backup_filename);
@ -3088,9 +3073,7 @@ cpu_alert_type dma_transfer(dma_transfer_type *dma)
#define map_null(type, start, end) \ #define map_null(type, start, end) \
for(map_offset = start / 0x8000; map_offset < (end / 0x8000); \ for(map_offset = start / 0x8000; map_offset < (end / 0x8000); \
map_offset++) \ map_offset++) \
{ \
memory_map_##type[map_offset] = NULL; \ memory_map_##type[map_offset] = NULL; \
} \
#define map_ram_region(type, start, end, mirror_blocks, region) \ #define map_ram_region(type, start, end, mirror_blocks, region) \
for(map_offset = (start) / 0x8000; map_offset < \ for(map_offset = (start) / 0x8000; map_offset < \
@ -3171,9 +3154,7 @@ u8 *load_gamepak_page(u32 physical_index)
// If RTC is active page the RTC register bytes so they can be read // If RTC is active page the RTC register bytes so they can be read
if((rtc_state != RTC_DISABLED) && (physical_index == 0)) if((rtc_state != RTC_DISABLED) && (physical_index == 0))
{
memcpy(swap_location + 0xC4, rtc_registers, sizeof(rtc_registers)); memcpy(swap_location + 0xC4, rtc_registers, sizeof(rtc_registers));
}
return swap_location; return swap_location;
} }
@ -3206,7 +3187,7 @@ void init_memory_gamepak()
} }
} }
void init_gamepak_buffer() void init_gamepak_buffer(void)
{ {
// Try to initialize 32MB (this is mainly for non-PSP platforms) // Try to initialize 32MB (this is mainly for non-PSP platforms)
gamepak_rom = NULL; gamepak_rom = NULL;
@ -3214,13 +3195,13 @@ void init_gamepak_buffer()
gamepak_ram_buffer_size = 32 * 1024 * 1024; gamepak_ram_buffer_size = 32 * 1024 * 1024;
gamepak_rom = malloc(gamepak_ram_buffer_size); gamepak_rom = malloc(gamepak_ram_buffer_size);
if(gamepak_rom == NULL) if(!gamepak_rom)
{ {
// Try 16MB, for PSP, then lower in 2MB increments // Try 16MB, for PSP, then lower in 2MB increments
gamepak_ram_buffer_size = 16 * 1024 * 1024; gamepak_ram_buffer_size = 16 * 1024 * 1024;
gamepak_rom = malloc(gamepak_ram_buffer_size); gamepak_rom = malloc(gamepak_ram_buffer_size);
while(gamepak_rom == NULL) while(!gamepak_rom)
{ {
gamepak_ram_buffer_size -= (2 * 1024 * 1024); gamepak_ram_buffer_size -= (2 * 1024 * 1024);
gamepak_rom = malloc(gamepak_ram_buffer_size); gamepak_rom = malloc(gamepak_ram_buffer_size);
@ -3234,7 +3215,7 @@ void init_gamepak_buffer()
gamepak_ram_pages); gamepak_ram_pages);
} }
void init_memory() void init_memory(void)
{ {
u32 map_offset = 0; u32 map_offset = 0;
@ -3356,25 +3337,25 @@ void memory_term(void)
file_close(gamepak_file_large); file_close(gamepak_file_large);
} }
if (gamepak_memory_map != NULL) if (gamepak_memory_map)
{ {
free(gamepak_memory_map); free(gamepak_memory_map);
gamepak_memory_map = NULL; gamepak_memory_map = NULL;
} }
if (gamepak_rom != NULL) if (gamepak_rom)
{ {
free(gamepak_rom); free(gamepak_rom);
gamepak_rom = NULL; gamepak_rom = NULL;
} }
} }
void bios_region_read_allow() void bios_region_read_allow(void)
{ {
memory_map_read[0] = bios_rom; memory_map_read[0] = bios_rom;
} }
void bios_region_read_protect() void bios_region_read_protect(void)
{ {
memory_map_read[0] = NULL; memory_map_read[0] = NULL;
} }
@ -3472,9 +3453,7 @@ void memory_##type##_savestate(void) \
/* This is a hack, for now. */ \ /* This is a hack, for now. */ \
if((flash_bank_ptr < gamepak_backup) || \ if((flash_bank_ptr < gamepak_backup) || \
(flash_bank_ptr > (gamepak_backup + (1024 * 64)))) \ (flash_bank_ptr > (gamepak_backup + (1024 * 64)))) \
{ \
flash_bank_ptr = gamepak_backup; \ flash_bank_ptr = gamepak_backup; \
} \
} }
memory_savestate_builder(read) memory_savestate_builder(read)

View File

@ -178,12 +178,12 @@ u8 *memory_region(u32 address, u32 *memory_limit);
u32 load_gamepak(const char *name); u32 load_gamepak(const char *name);
u32 load_backup(char *name); u32 load_backup(char *name);
s32 load_bios(char *name); s32 load_bios(char *name);
void update_backup(); void update_backup(void);
void init_memory(); void init_memory(void);
void init_gamepak_buffer(); void init_gamepak_buffer(void);
void memory_term(void); void memory_term(void);
void bios_region_read_allow(); void bios_region_read_allow(void);
void bios_region_read_protect(); void bios_region_read_protect(void);
u8 *load_gamepak_page(u32 physical_index); u8 *load_gamepak_page(u32 physical_index);
extern u8 *gamepak_rom; extern u8 *gamepak_rom;

8
main.c
View File

@ -49,7 +49,7 @@ u32 oam_update_count = 0;
char main_path[512]; char main_path[512];
char save_path[512]; char save_path[512];
void trigger_ext_event(); void trigger_ext_event(void);
#define check_count(count_var) \ #define check_count(count_var) \
if(count_var < execute_cycles) \ if(count_var < execute_cycles) \
@ -96,7 +96,7 @@ void trigger_ext_event();
} \ } \
} \ } \
void init_main() void init_main(void)
{ {
u32 i; u32 i;
@ -124,7 +124,7 @@ void init_main()
u32 no_alpha = 0; u32 no_alpha = 0;
u32 update_gba() u32 update_gba(void)
{ {
irq_type irq_raised = IRQ_NONE; irq_type irq_raised = IRQ_NONE;
@ -274,7 +274,7 @@ u32 update_gba()
return execute_cycles; return execute_cycles;
} }
void reset_gba() void reset_gba(void)
{ {
init_main(); init_main();
init_memory(); init_memory();

6
main.h
View File

@ -73,10 +73,10 @@ extern u64 base_timestamp;
extern char main_path[512]; extern char main_path[512];
extern char save_path[512]; extern char save_path[512];
u32 update_gba(); u32 update_gba(void);
void reset_gba(); void reset_gba(void);
void init_main(); void init_main(void);
void game_name_ext(char *src, char *buffer, char *extension); void game_name_ext(char *src, char *buffer, char *extension);
void main_write_savestate(void); void main_write_savestate(void);

View File

@ -301,10 +301,8 @@ u32 gbc_sound_master_volume;
gs->envelope_ticks = gs->envelope_initial_ticks; \ gs->envelope_ticks = gs->envelope_initial_ticks; \
} \ } \
else \ else \
{ \
gs->envelope_ticks = envelope_ticks; \ gs->envelope_ticks = envelope_ticks; \
} \ } \
} \
#define update_tone_noenvelope() \ #define update_tone_noenvelope() \
@ -547,7 +545,7 @@ void init_noise_table(u32 *table, u32 period, u32 bit_length)
} }
} }
void reset_sound() void reset_sound(void)
{ {
direct_sound_struct *ds = direct_sound_channel; direct_sound_struct *ds = direct_sound_channel;
gbc_sound_struct *gs = gbc_sound_channel; gbc_sound_struct *gs = gbc_sound_channel;

View File

@ -122,6 +122,6 @@ void sound_read_savestate(void);
void render_audio(void); void render_audio(void);
void reset_sound(); void reset_sound(void);
#endif #endif

View File

@ -3140,7 +3140,7 @@ render_scanline_window_builder(bitmap);
static const u32 active_layers[6] = { 0x1F, 0x17, 0x1C, 0x14, 0x14, 0x14 }; static const u32 active_layers[6] = { 0x1F, 0x17, 0x1C, 0x14, 0x14, 0x14 };
void update_scanline() void update_scanline(void)
{ {
u32 pitch = get_screen_pitch(); u32 pitch = get_screen_pitch();
u32 dispcnt = io_registers[REG_DISPCNT]; u32 dispcnt = io_registers[REG_DISPCNT];