static void display_loading_rom_message(const char *name, rom_load_data *romdata) { char buffer[200]; if (name != NULL) sprintf(buffer, "Loading (%d%%)", 100 * romdata->romsloaded / romdata->romstotal); else sprintf(buffer, "Loading Complete"); ui_set_startup_text(buffer, FALSE); }
static void display_loading_rom_message(rom_load_data *romdata, const char *name) { char buffer[200]; // 2010-04, FP - FIXME: in MESS, load_software_part_region sometimes calls this with romstotalsize = 0! // as a temp workaround, I added a check for romstotalsize !=0. if (name != NULL && romdata->romstotalsize) sprintf(buffer, "Loading (%d%%)", (UINT32)(100 * (UINT64)romdata->romsloadedsize / (UINT64)romdata->romstotalsize)); else sprintf(buffer, "Loading Complete"); if (!ui_is_menu_active()) ui_set_startup_text(romdata->machine(), buffer, FALSE); }
static void decode_graphics(const gfx_decode *gfxdecodeinfo) { int totalgfx = 0, curgfx = 0; char buffer[200]; int i; /* count total graphics elements */ for (i = 0; i < MAX_GFX_ELEMENTS; i++) if (Machine->gfx[i]) totalgfx += Machine->gfx[i]->total_elements; /* loop over all elements */ for (i = 0; i < MAX_GFX_ELEMENTS; i++) if (Machine->gfx[i]) { /* if we have a valid region, decode it now */ if (gfxdecodeinfo[i].memory_region > REGION_INVALID) { UINT8 *region_base = memory_region(gfxdecodeinfo[i].memory_region); gfx_element *gfx = Machine->gfx[i]; int j; /* now decode the actual graphics */ for (j = 0; j < gfx->total_elements; j += 1024) { int num_to_decode = (j + 1024 < gfx->total_elements) ? 1024 : (gfx->total_elements - j); decodegfx(gfx, region_base + gfxdecodeinfo[i].start, j, num_to_decode); curgfx += num_to_decode; /* display some startup text */ sprintf(buffer, "Decoding (%d%%)", curgfx * 100 / totalgfx); ui_set_startup_text(buffer, FALSE); } } /* otherwise, clear the target region */ else memset(Machine->gfx[i]->gfxdata, 0, Machine->gfx[i]->char_modulo * Machine->gfx[i]->total_elements); } }
void running_machine::start() { // initialize basic can't-fail systems here config_init(*this); m_input = auto_alloc(*this, input_manager(*this)); output_init(*this); palette_init(*this); m_render = auto_alloc(*this, render_manager(*this)); generic_machine_init(*this); generic_sound_init(*this); // allocate a soft_reset timer m_soft_reset_timer = m_scheduler.timer_alloc(timer_expired_delegate(FUNC(running_machine::soft_reset), this)); // init the osd layer m_osd.init(*this); // create the video manager m_video = auto_alloc(*this, video_manager(*this)); ui_init(*this); // initialize the base time (needed for doing record/playback) ::time(&m_base_time); // initialize the input system and input ports for the game // this must be done before memory_init in order to allow specifying // callbacks based on input port tags time_t newbase = input_port_init(*this); if (newbase != 0) m_base_time = newbase; // intialize UI input ui_input_init(*this); // initialize the streams engine before the sound devices start m_sound = auto_alloc(*this, sound_manager(*this)); // first load ROMs, then populate memory, and finally initialize CPUs // these operations must proceed in this order rom_init(*this); memory_init(*this); watchdog_init(*this); // must happen after memory_init because this relies on generic.spriteram generic_video_init(*this); // allocate the gfx elements prior to device initialization gfx_init(*this); // initialize natural keyboard support inputx_init(*this); // initialize image devices image_init(*this); tilemap_init(*this); crosshair_init(*this); // initialize the debugger if ((debug_flags & DEBUG_FLAG_ENABLED) != 0) debugger_init(*this); // call the game driver's init function // this is where decryption is done and memory maps are altered // so this location in the init order is important ui_set_startup_text(*this, "Initializing...", true); // start up the devices const_cast<device_list &>(devicelist()).start_all(); // if we're coming in with a savegame request, process it now const char *savegame = options().state(); if (savegame[0] != 0) schedule_load(savegame); // if we're in autosave mode, schedule a load else if (options().autosave() && (m_system.flags & GAME_SUPPORTS_SAVE) != 0) schedule_load("auto"); // set up the cheat engine m_cheat = auto_alloc(*this, cheat_manager(*this)); // disallow save state registrations starting here m_save.allow_registration(false); }
void running_machine::start() { /* initialize basic can't-fail systems here */ fileio_init(this); config_init(this); input_init(this); output_init(this); state_init(this); state_save_allow_registration(this, true); palette_init(this); render_init(this); ui_init(this); generic_machine_init(this); generic_video_init(this); generic_sound_init(this); /* initialize the timers and allocate a soft_reset timer this must be done before cpu_init so that CPU's can allocate timers */ timer_init(this); m_soft_reset_timer = timer_alloc(this, static_soft_reset, NULL); /* init the osd layer */ osd_init(this); /* initialize the base time (needed for doing record/playback) */ time(&m_base_time); /* initialize the input system and input ports for the game this must be done before memory_init in order to allow specifying callbacks based on input port tags */ time_t newbase = input_port_init(this, m_game.ipt); if (newbase != 0) m_base_time = newbase; /* intialize UI input */ ui_input_init(this); /* initialize the streams engine before the sound devices start */ streams_init(this); /* first load ROMs, then populate memory, and finally initialize CPUs these operations must proceed in this order */ rom_init(this); memory_init(this); watchdog_init(this); /* allocate the gfx elements prior to device initialization */ gfx_init(this); /* initialize natural keyboard support */ inputx_init(this); /* initialize image devices */ image_init(this); /* start up the devices */ m_devicelist.start_all(); /* call the game driver's init function this is where decryption is done and memory maps are altered so this location in the init order is important */ ui_set_startup_text(this, "Initializing...", true); if (m_game.driver_init != NULL) (*m_game.driver_init)(this); /* finish image devices init process */ image_postdevice_init(this); /* start the video and audio hardware */ video_init(this); tilemap_init(this); crosshair_init(this); sound_init(this); /* initialize the debugger */ if ((debug_flags & DEBUG_FLAG_ENABLED) != 0) debugger_init(this); /* call the driver's _START callbacks */ if (m_config.m_machine_start != NULL) (*m_config.m_machine_start)(this); if (m_config.m_sound_start != NULL) (*m_config.m_sound_start)(this); if (m_config.m_video_start != NULL) (*m_config.m_video_start)(this); /* set up the cheat engine */ cheat_init(this); /* set up the hiscore engine */ hiscore_init(this); /* disallow save state registrations starting here */ state_save_allow_registration(this, false); }
void running_machine::start() { // initialize basic can't-fail systems here fileio_init(this); config_init(this); input_init(this); output_init(this); state_init(this); state_save_allow_registration(this, true); palette_init(this); render_init(this); ui_init(this); generic_machine_init(this); generic_video_init(this); generic_sound_init(this); // initialize the timers and allocate a soft_reset timer // this must be done before cpu_init so that CPU's can allocate timers timer_init(this); m_soft_reset_timer = timer_alloc(this, static_soft_reset, NULL); // init the osd layer osd_init(this); // initialize the base time (needed for doing record/playback) time(&m_base_time); // initialize the input system and input ports for the game // this must be done before memory_init in order to allow specifying // callbacks based on input port tags time_t newbase = input_port_init(this, m_game.ipt); if (newbase != 0) m_base_time = newbase; // intialize UI input ui_input_init(this); // initialize the streams engine before the sound devices start streams_init(this); // first load ROMs, then populate memory, and finally initialize CPUs // these operations must proceed in this order rom_init(this); memory_init(this); watchdog_init(this); // allocate the gfx elements prior to device initialization gfx_init(this); // initialize natural keyboard support inputx_init(this); // initialize image devices image_init(this); // start up the devices m_devicelist.start_all(); // call the game driver's init function // this is where decryption is done and memory maps are altered // so this location in the init order is important ui_set_startup_text(this, "Initializing...", true); if (m_game.driver_init != NULL) (*m_game.driver_init)(this); // finish image devices init process image_postdevice_init(this); // start the video and audio hardware video_init(this); tilemap_init(this); crosshair_init(this); sound_init(this); // initialize the debugger if ((debug_flags & DEBUG_FLAG_ENABLED) != 0) debugger_init(this); // call the driver's _START callbacks if (m_config.m_machine_start != NULL) (*m_config.m_machine_start)(this); if (m_config.m_sound_start != NULL) (*m_config.m_sound_start)(this); if (m_config.m_video_start != NULL) (*m_config.m_video_start)(this); // if we're coming in with a savegame request, process it now const char *savegame = options_get_string(&m_options, OPTION_STATE); if (savegame[0] != 0) schedule_load(savegame); // if we're in autosave mode, schedule a load else if (options_get_bool(&m_options, OPTION_AUTOSAVE) && (m_game.flags & GAME_SUPPORTS_SAVE) != 0) schedule_load("auto"); // set up the cheat engine if (options_get_bool(&m_options, OPTION_CHEAT)) cheat_init(this); // disallow save state registrations starting here state_save_allow_registration(this, false); }
static void init_machine(running_machine *machine) { mame_private *mame = machine->mame_data; int num; /* initialize basic can't-fail systems here */ cpuintrf_init(machine); sndintrf_init(machine); fileio_init(machine); config_init(machine); output_init(machine); state_init(machine); state_save_allow_registration(TRUE); drawgfx_init(machine); palette_init(machine); render_init(machine); ui_init(machine); generic_machine_init(machine); generic_video_init(machine); mame->rand_seed = 0x9d14abd7; /* initialize the base time (if not doing record/playback) */ if (!Machine->record_file && !Machine->playback_file) time(&mame->base_time); else mame->base_time = 0; /* init the osd layer */ if (osd_init(machine) != 0) fatalerror("osd_init failed"); /* initialize the input system */ /* this must be done before the input ports are initialized */ if (code_init(machine) != 0) fatalerror("code_init failed"); /* initialize the input ports for the game */ /* this must be done before memory_init in order to allow specifying */ /* callbacks based on input port tags */ if (input_port_init(machine, machine->gamedrv->ipt) != 0) fatalerror("input_port_init failed"); /* load the ROMs if we have some */ /* this must be done before memory_init in order to allocate memory regions */ rom_init(machine, machine->gamedrv->rom); /* initialize the timers and allocate a soft_reset timer */ /* this must be done before cpu_init so that CPU's can allocate timers */ timer_init(machine); mame->soft_reset_timer = timer_alloc(soft_reset); /* initialize the memory system for this game */ /* this must be done before cpu_init so that set_context can look up the opcode base */ if (memory_init(machine) != 0) fatalerror("memory_init failed"); /* now set up all the CPUs */ if (cpuexec_init(machine) != 0) fatalerror("cpuexec_init failed"); if (cpuint_init(machine) != 0) fatalerror("cpuint_init failed"); #ifdef MESS /* initialize the devices */ devices_init(machine); #endif /* start the save/load system */ saveload_init(machine); /* call the game driver's init function */ /* this is where decryption is done and memory maps are altered */ /* so this location in the init order is important */ ui_set_startup_text("Initializing...", TRUE); if (machine->gamedrv->driver_init != NULL) (*machine->gamedrv->driver_init)(machine); /* start the audio system */ if (sound_init(machine) != 0) fatalerror("sound_init failed"); /* start the video hardware */ if (video_init(machine) != 0) fatalerror("video_init failed"); /* start the cheat engine */ if (options.cheat) cheat_init(machine); /* call the driver's _START callbacks */ if (machine->drv->machine_start != NULL && (*machine->drv->machine_start)(machine) != 0) fatalerror("Unable to start machine emulation"); if (machine->drv->sound_start != NULL && (*machine->drv->sound_start)(machine) != 0) fatalerror("Unable to start sound emulation"); if (machine->drv->video_start != NULL && (*machine->drv->video_start)(machine) != 0) fatalerror("Unable to start video emulation"); /* free memory regions allocated with REGIONFLAG_DISPOSE (typically gfx roms) */ for (num = 0; num < MAX_MEMORY_REGIONS; num++) if (mame->mem_region[num].flags & ROMREGION_DISPOSE) free_memory_region(machine, num); #ifdef MAME_DEBUG /* initialize the debugger */ if (machine->debug_mode) mame_debug_init(machine); #endif }
void running_machine::start() { // initialize basic can't-fail systems here config_init(*this); m_input = auto_alloc(*this, input_manager(*this)); output_init(*this); palette_init(*this); m_render = auto_alloc(*this, render_manager(*this)); generic_machine_init(*this); // allocate a soft_reset timer m_soft_reset_timer = m_scheduler.timer_alloc(timer_expired_delegate(FUNC(running_machine::soft_reset), this)); // init the osd layer m_osd.init(*this); // create the video manager m_video = auto_alloc(*this, video_manager(*this)); ui_init(*this); // initialize the base time (needed for doing record/playback) ::time(&m_base_time); // initialize the input system and input ports for the game // this must be done before memory_init in order to allow specifying // callbacks based on input port tags time_t newbase = m_ioport.initialize(); if (newbase != 0) m_base_time = newbase; // intialize UI input ui_input_init(*this); // initialize the streams engine before the sound devices start m_sound = auto_alloc(*this, sound_manager(*this)); // first load ROMs, then populate memory, and finally initialize CPUs // these operations must proceed in this order rom_init(*this); m_memory.initialize(); // initialize the watchdog m_watchdog_timer = m_scheduler.timer_alloc(timer_expired_delegate(FUNC(running_machine::watchdog_fired), this)); if (config().m_watchdog_vblank_count != 0 && primary_screen != NULL) primary_screen->register_vblank_callback(vblank_state_delegate(FUNC(running_machine::watchdog_vblank), this)); save().save_item(NAME(m_watchdog_enabled)); save().save_item(NAME(m_watchdog_counter)); // allocate the gfx elements prior to device initialization gfx_init(*this); // initialize image devices image_init(*this); m_tilemap = auto_alloc(*this, tilemap_manager(*this)); crosshair_init(*this); network_init(*this); // initialize the debugger if ((debug_flags & DEBUG_FLAG_ENABLED) != 0) debugger_init(*this); // call the game driver's init function // this is where decryption is done and memory maps are altered // so this location in the init order is important ui_set_startup_text(*this, "Initializing...", true); // register callbacks for the devices, then start them add_notifier(MACHINE_NOTIFY_RESET, machine_notify_delegate(FUNC(running_machine::reset_all_devices), this)); add_notifier(MACHINE_NOTIFY_EXIT, machine_notify_delegate(FUNC(running_machine::stop_all_devices), this)); save().register_presave(save_prepost_delegate(FUNC(running_machine::presave_all_devices), this)); start_all_devices(); save().register_postload(save_prepost_delegate(FUNC(running_machine::postload_all_devices), this)); // if we're coming in with a savegame request, process it now const char *savegame = options().state(); if (savegame[0] != 0) schedule_load(savegame); // if we're in autosave mode, schedule a load else if (options().autosave() && (m_system.flags & GAME_SUPPORTS_SAVE) != 0) schedule_load("auto"); // set up the cheat engine m_cheat = auto_alloc(*this, cheat_manager(*this)); // allocate autoboot timer m_autoboot_timer = scheduler().timer_alloc(timer_expired_delegate(FUNC(running_machine::autoboot_callback), this)); // initialize lua m_lua_engine.initialize(); // disallow save state registrations starting here m_save.allow_registration(false); }
static void cps2_decrypt(const UINT32 *master_key, unsigned int upper_limit) { UINT16 *rom = (UINT16 *)memory_region(REGION_CPU1); int length = memory_region_length(REGION_CPU1); UINT16 *dec = auto_malloc(length); int i; UINT32 key1[4]; // expand master key to 1st FN 96-bit key expand_1st_key(key1, master_key); // add extra bits for s-boxes with less than 6 inputs key1[0] ^= BIT(key1[0], 1) << 4; key1[0] ^= BIT(key1[0], 2) << 5; key1[0] ^= BIT(key1[0], 8) << 11; key1[1] ^= BIT(key1[1], 0) << 5; key1[1] ^= BIT(key1[1], 8) << 11; key1[2] ^= BIT(key1[2], 1) << 5; key1[2] ^= BIT(key1[2], 8) << 11; for (i = 0; i < 0x10000; ++i) { int a; UINT16 seed; UINT32 subkey[2]; UINT32 key2[4]; if ((i & 0xff) == 0) { char loadingMessage[256]; // for displaying with UI sprintf(loadingMessage, "Decrypting %d%%", i*100/0x10000); ui_set_startup_text(loadingMessage,FALSE); } // pass the address through FN1 seed = feistel(i, fn1_groupA, fn1_groupB, fn1_r1_boxes, fn1_r2_boxes, fn1_r3_boxes, fn1_r4_boxes, key1[0], key1[1], key1[2], key1[3]); // expand the result to 64-bit expand_subkey(subkey, seed); // XOR with the master key subkey[0] ^= master_key[0]; subkey[1] ^= master_key[1]; // expand key to 2nd FN 96-bit key expand_2nd_key(key2, subkey); // add extra bits for s-boxes with less than 6 inputs key2[0] ^= BIT(key2[0], 0) << 5; key2[0] ^= BIT(key2[0], 6) << 11; key2[1] ^= BIT(key2[1], 0) << 5; key2[1] ^= BIT(key2[1], 1) << 4; key2[2] ^= BIT(key2[2], 2) << 5; key2[2] ^= BIT(key2[2], 3) << 4; key2[2] ^= BIT(key2[2], 7) << 11; key2[3] ^= BIT(key2[3], 1) << 5; // decrypt the opcodes for (a = i; a < length/2 && a < upper_limit/2; a += 0x10000) { dec[a] = feistel(rom[a], fn2_groupA, fn2_groupB, fn2_r1_boxes, fn2_r2_boxes, fn2_r3_boxes, fn2_r4_boxes, key2[0], key2[1], key2[2], key2[3]); } // copy the unencrypted part (not really needed) while (a < length/2) { dec[a] = rom[a]; a += 0x10000; } } memory_set_decrypted_region(0, 0x000000, length - 1, dec); m68k_set_encrypted_opcode_range(0,0,length); #if 0 { FILE *f; f = fopen("d:/s.rom","wb"); fwrite(rom,1,0x100000,f); fclose(f); f = fopen("d:/s.dec","wb"); fwrite(dec,1,0x100000,f); fclose(f); } #endif }