# HG changeset patch # User Michael Pavone # Date 1482184731 28800 # Node ID 45db303fc705eeb41d4f27562ed176e766735030 # Parent 7ab7c8fb34ba9fbd68379f6fa78a11c24c37da5b Restore 68K address logging functionality diff -r 7ab7c8fb34ba -r 45db303fc705 blastem.c --- a/blastem.c Mon Dec 19 13:46:58 2016 -0800 +++ b/blastem.c Mon Dec 19 13:58:51 2016 -0800 @@ -175,12 +175,11 @@ int width = -1; int height = -1; int debug = 0; - int ym_log = 0; + uint32_t opts = 0; int loaded = 0; system_type stype; uint8_t force_region = 0; char * romfname = NULL; - FILE *address_log = NULL; char * statefile = NULL; int rom_size, lock_on_size; uint16_t *cart = NULL, *lock_on = NULL; @@ -217,7 +216,7 @@ use_gl = 0; break; case 'l': - address_log = fopen("address.log", "w"); + opts |= OPT_ADDRESS_LOG; break; case 'v': info_message("blastem %s\n", BLASTEM_VERSION); @@ -247,7 +246,7 @@ force_no_terminal(); break; case 'y': - ym_log = 1; + opts |= YM_OPT_WAVE_LOG; break; case 'o': { i++; @@ -339,15 +338,12 @@ } rom_info info; - uint32_t ym_opts = (ym_log && !menu) ? YM_OPT_WAVE_LOG : 0; - current_system = alloc_config_system(stype, cart, rom_size, lock_on, lock_on_size, ym_opts, force_region, &info); + current_system = alloc_config_system(stype, cart, rom_size, lock_on, lock_on_size, menu ? 0 : opts, force_region, &info); setup_saves(romfname, &info, current_system); update_title(info.name); if (menu) { menu_context = current_system; } else { - //TODO: make this an option flag - //genesis->m68k->options->address_log = address_log; game_context = current_system; } @@ -374,7 +370,7 @@ fatal_error("Failed to open %s for reading\n", menu_context->next_rom); } //allocate new genesis context - game_context = alloc_config_system(stype, cart, rom_size, lock_on, lock_on_size, ym_opts,force_region, &info); + game_context = alloc_config_system(stype, cart, rom_size, lock_on, lock_on_size, opts,force_region, &info); menu_context->next_context = game_context; game_context->next_context = menu_context; setup_saves(menu_context->next_rom, &info, game_context); @@ -383,8 +379,6 @@ menu_context->next_rom = NULL; menu = 0; current_system = game_context; - //TODO: make this an option flag - //genesis->m68k->options->address_log = address_log; current_system->debugger_type = dtype; current_system->enter_debugger = start_in_debugger && menu == debug_target; current_system->start_context(current_system, statefile); diff -r 7ab7c8fb34ba -r 45db303fc705 genesis.c --- a/genesis.c Mon Dec 19 13:46:58 2016 -0800 +++ b/genesis.c Mon Dec 19 13:58:51 2016 -0800 @@ -882,7 +882,7 @@ free(gen->lock_on); } -genesis_context *alloc_init_genesis(rom_info *rom, void *main_rom, void *lock_on, uint32_t ym_opts, uint8_t force_region) +genesis_context *alloc_init_genesis(rom_info *rom, void *main_rom, void *lock_on, uint32_t system_opts, uint8_t force_region) { static memmap_chunk z80_map[] = { { 0x0000, 0x4000, 0x1FFF, 0, 0, MMAP_READ | MMAP_WRITE | MMAP_CODE, NULL, NULL, NULL, NULL, NULL }, @@ -913,7 +913,7 @@ uint32_t lowpass_cutoff = lowpass_cutoff_str ? atoi(lowpass_cutoff_str) : DEFAULT_LOWPASS_CUTOFF; gen->ym = malloc(sizeof(ym2612_context)); - ym_init(gen->ym, render_sample_rate(), gen->master_clock, MCLKS_PER_YM, render_audio_buffer(), ym_opts, lowpass_cutoff); + ym_init(gen->ym, render_sample_rate(), gen->master_clock, MCLKS_PER_YM, render_audio_buffer(), system_opts, lowpass_cutoff); gen->psg = malloc(sizeof(psg_context)); psg_init(gen->psg, render_sample_rate(), gen->master_clock, MCLKS_PER_PSG, render_audio_buffer(), lowpass_cutoff); @@ -968,6 +968,7 @@ opts->gen.flags |= M68K_OPT_BROKEN_READ_MODIFY; gen->m68k = init_68k_context(opts, NULL); gen->m68k->system = gen; + opts->address_log = (system_opts & OPT_ADDRESS_LOG) ? fopen("address.log", "w") : NULL; return gen; } diff -r 7ab7c8fb34ba -r 45db303fc705 genesis.h --- a/genesis.h Mon Dec 19 13:46:58 2016 -0800 +++ b/genesis.h Mon Dec 19 13:58:51 2016 -0800 @@ -55,7 +55,7 @@ uint16_t read_dma_value(uint32_t address); uint16_t get_open_bus_value(); m68k_context * sync_components(m68k_context *context, uint32_t address); -genesis_context *alloc_config_genesis(void *rom, uint32_t rom_size, void *lock_on, uint32_t lock_on_size, uint32_t ym_opts, uint8_t force_region, rom_info *info_out); +genesis_context *alloc_config_genesis(void *rom, uint32_t rom_size, void *lock_on, uint32_t lock_on_size, uint32_t system_opts, uint8_t force_region, rom_info *info_out); #endif //GENESIS_H_ diff -r 7ab7c8fb34ba -r 45db303fc705 system.h --- a/system.h Mon Dec 19 13:46:58 2016 -0800 +++ b/system.h Mon Dec 19 13:58:51 2016 -0800 @@ -43,6 +43,8 @@ system_type type; }; +#define OPT_ADDRESS_LOG (1U << 31U) + system_type detect_system_type(uint8_t *rom, long filesize); system_header *alloc_config_system(system_type stype, void *rom, uint32_t rom_size, void *lock_on, uint32_t lock_on_size, uint32_t opts, uint8_t force_region, rom_info *info_out);