예제 #1
0
파일: gb.c 프로젝트: BelmonduS/rin
void gb_destroy()
{
	if(rom_get_loaded())
	{
		//jfile_free(env_game_thread,rom_image);
		//rom_image = NULL;
		rom_init();
	}
}
예제 #2
0
파일: emu.c 프로젝트: ghaflims/attmptemu
void emu_init(char* args){
	hal_init();
//	mem_init();
// init the ppu before rom otherwise set_mirroring will not work
	ppu_init();
	rom_init();
	readrom(args);
	cpu_init(&cpu);
	
	cpu_reset(&cpu);
	emu_running = true;
}
예제 #3
0
파일: emu.c 프로젝트: ghaflims/attmptemu
void exec_loop(){
	mem_init();
	rom_init();
	readrom("nestest.nes");
	cpu_init(&cpu);
	cpu_reset(&cpu);
	ppu_init();
	cpu_exec(&cpu,18);
	cpu_trigger_nmi(&cpu);
	cpu_exec(&cpu,30);
		//check for interrupts
		//mem_dump(mem,8);
		//test = 0;
		//printf("test = %d",test);
}
예제 #4
0
/* Called when a new block is started to initialise its internal state */
libspectrum_error
libspectrum_tape_init_block( libspectrum_tape_block *block )
{
  switch( block->type ) {

  case LIBSPECTRUM_TAPE_BLOCK_ROM:
    return rom_init( &(block->types.rom) );
  case LIBSPECTRUM_TAPE_BLOCK_TURBO:
    return turbo_init( &(block->types.turbo) );
  case LIBSPECTRUM_TAPE_BLOCK_PURE_TONE:
    block->types.pure_tone.edge_count = block->types.pure_tone.pulses;
    break;
  case LIBSPECTRUM_TAPE_BLOCK_PULSES:
    block->types.pulses.edge_count = 0;
    break;
  case LIBSPECTRUM_TAPE_BLOCK_PURE_DATA:
    return pure_data_init( &(block->types.pure_data) );

  /* These blocks need no initialisation */
  case LIBSPECTRUM_TAPE_BLOCK_PAUSE:
  case LIBSPECTRUM_TAPE_BLOCK_GROUP_START:
  case LIBSPECTRUM_TAPE_BLOCK_GROUP_END:
  case LIBSPECTRUM_TAPE_BLOCK_JUMP:
  case LIBSPECTRUM_TAPE_BLOCK_LOOP_START:
  case LIBSPECTRUM_TAPE_BLOCK_LOOP_END:
  case LIBSPECTRUM_TAPE_BLOCK_SELECT:
  case LIBSPECTRUM_TAPE_BLOCK_STOP48:
  case LIBSPECTRUM_TAPE_BLOCK_COMMENT:
  case LIBSPECTRUM_TAPE_BLOCK_MESSAGE:
  case LIBSPECTRUM_TAPE_BLOCK_ARCHIVE_INFO:
  case LIBSPECTRUM_TAPE_BLOCK_HARDWARE:
  case LIBSPECTRUM_TAPE_BLOCK_CUSTOM:
    return LIBSPECTRUM_ERROR_NONE;

  default:
    libspectrum_print_error(
      "libspectrum_tape_init_block: unknown block type 0x%02x\n",
      block->type
    );
    return LIBSPECTRUM_ERROR_LOGIC;
  }

  return LIBSPECTRUM_ERROR_NONE;
}
예제 #5
0
void *vga_init()
{
        vga_t *vga = malloc(sizeof(vga_t));
        memset(vga, 0, sizeof(vga_t));

        rom_init(&vga->bios_rom, "roms/ibm_vga.bin", 0xc0000, 0x8000, 0x7fff, 0x2000, MEM_MAPPING_EXTERNAL);

        svga_init(&vga->svga, vga, 1 << 18, /*256kb*/
                   NULL,
                   vga_in, vga_out,
                   NULL,
                   NULL);

        io_sethandler(0x03c0, 0x0020, vga_in, NULL, NULL, vga_out, NULL, NULL, vga);

        vga->svga.bpp = 8;
        vga->svga.miscout = 1;
        
        return vga;
}
예제 #6
0
파일: gb.c 프로젝트: BelmonduS/rin
void gb_init(void)
{
	lcd_init();
	rom_init();
	apu_init();// ROMより後に作られたし
	mbc_init();
	cpu_init();
	sgb_init();
	cheat_init();
	
	apu_reset();
	mbc_reset();
	//target=NULL;
	
	renderer_init();

	gb_reset();

	hook_ext=false;
	use_gba=false;
}
예제 #7
0
파일: rom.c 프로젝트: knusbaum/gameboy
int rom_load(const char *filename)
{
#ifdef _WIN32
	HANDLE f, map;
#else
	int f;
	size_t length;
	struct stat st;
#endif
	unsigned char *bytes;

#ifdef _WIN32
	f = CreateFile(filename, GENERIC_READ, FILE_SHARE_READ, NULL,
		OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);

	if(f == INVALID_HANDLE_VALUE)
		return 0;

	map = CreateFileMapping(f, NULL, PAGE_READONLY, 0, 0, NULL);
	if(!map)
		return 0;

	bytes = MapViewOfFile(map, FILE_MAP_READ, 0, 0, 0);
	if(!bytes)
		return 0;
#else
	f = open(filename, O_RDONLY);
	if(f == -1)
		return 0;
	if(fstat(f, &st) == -1)
		return 0;

	bytes = mmap(NULL, st.st_size, PROT_READ, MAP_PRIVATE, f, 0);
	if(!bytes)
		return 0;
#endif
	return rom_init(bytes);
}
예제 #8
0
void gb_init(void)
{
	lcd_init();
	rom_init();
	apu_init();// ROMより後に作られたし
	mbc_init();
	cpu_init();
	sgb_init();
	#ifdef CHEAT_SUPPORT
		cheat_init();
	#endif
	
	apu_reset();
	mbc_reset();
	//target=NULL;
	
	gbe_init();

	gb_reset();

	hook_ext=false;
	use_gba=false;
}
예제 #9
0
파일: ps1.c 프로젝트: Wack0/PCem-X
void ps1mb_init()
{
        io_sethandler(0x0091, 0x0001, ps1_read, NULL, NULL, ps1_write, NULL, NULL, NULL);
        io_sethandler(0x0092, 0x0001, ps1_read, NULL, NULL, ps1_write, NULL, NULL, NULL);
        io_sethandler(0x0094, 0x0001, ps1_read, NULL, NULL, ps1_write, NULL, NULL, NULL);
        io_sethandler(0x0102, 0x0004, ps1_read, NULL, NULL, ps1_write, NULL, NULL, NULL);
        io_sethandler(0x0190, 0x0001, ps1_read, NULL, NULL, ps1_write, NULL, NULL, NULL);
        io_sethandler(0x0320, 0x0001, ps1_read, NULL, NULL, ps1_write, NULL, NULL, NULL);
        io_sethandler(0x0322, 0x0001, ps1_read, NULL, NULL, ps1_write, NULL, NULL, NULL);
        io_sethandler(0x0324, 0x0001, ps1_read, NULL, NULL, ps1_write, NULL, NULL, NULL);
        
        rom_init(&ps1_high_rom,
                                "roms/ibmps1es/f80000.bin",
                                0xf80000,
                                0x80000,
                                0x7ffff,
                                0,
                                MEM_MAPPING_EXTERNAL);
/*        rom_init_interleaved(&ps1_high_rom,
                                "roms/ibmps1es/ibm_1057757_24-05-90.bin",
                                "roms/ibmps1es/ibm_1057757_29-15-90.bin",
                                0xfc0000,
                                0x40000,
                                0x3ffff,
                                0,
                                MEM_MAPPING_EXTERNAL);*/
        ps1_190 = 0;
        
        lpt1_remove();
        lpt2_remove();
        lpt1_init(0x3bc);
        
        serial1_remove();
        serial2_remove();
        
        memset(&ps1_hd, 0, sizeof(ps1_hd));
}
예제 #10
0
파일: machine.c 프로젝트: bdidier/MAME-OS-X
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);
}
예제 #11
0
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);
}
예제 #12
0
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);
}
예제 #13
0
파일: mame.c 프로젝트: broftkd/mess-cvs
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
}
예제 #14
0
/* Called when a new block is started to initialise its internal state */
libspectrum_error
libspectrum_tape_block_init( libspectrum_tape_block *block,
                             libspectrum_tape_block_state *state )
{
  if( !block ) return LIBSPECTRUM_ERROR_NONE;

  switch( libspectrum_tape_block_type( block ) ) {

  case LIBSPECTRUM_TAPE_BLOCK_ROM:
    return rom_init( &(block->types.rom), &(state->block_state.rom) );
  case LIBSPECTRUM_TAPE_BLOCK_TURBO:
    return turbo_init( &(block->types.turbo), &(state->block_state.turbo) );
  case LIBSPECTRUM_TAPE_BLOCK_PURE_TONE:
    state->block_state.pure_tone.edge_count = block->types.pure_tone.pulses;
    break;
  case LIBSPECTRUM_TAPE_BLOCK_PULSES:
    state->block_state.pulses.edge_count = 0;
    break;
  case LIBSPECTRUM_TAPE_BLOCK_PURE_DATA:
    return pure_data_init( &(block->types.pure_data),
                           &(state->block_state.pure_data) );
  case LIBSPECTRUM_TAPE_BLOCK_RAW_DATA:
    raw_data_init( &(block->types.raw_data), &(state->block_state.raw_data) );
    return LIBSPECTRUM_ERROR_NONE;
  case LIBSPECTRUM_TAPE_BLOCK_GENERALISED_DATA:
    return generalised_data_init( &(block->types.generalised_data),
                                  &(state->block_state.generalised_data) );
  case LIBSPECTRUM_TAPE_BLOCK_RLE_PULSE:
    state->block_state.rle_pulse.index = 0;
    return LIBSPECTRUM_ERROR_NONE;
  case LIBSPECTRUM_TAPE_BLOCK_PULSE_SEQUENCE:
    state->block_state.pulse_sequence.index = 0;
    state->block_state.pulse_sequence.pulse_count = 0;
    state->block_state.pulse_sequence.level = -1;
    return LIBSPECTRUM_ERROR_NONE;
  case LIBSPECTRUM_TAPE_BLOCK_DATA_BLOCK:
    return data_block_init( &(block->types.data_block),
                            &(state->block_state.data_block) );

  /* These blocks need no initialisation */
  case LIBSPECTRUM_TAPE_BLOCK_PAUSE:
  case LIBSPECTRUM_TAPE_BLOCK_GROUP_START:
  case LIBSPECTRUM_TAPE_BLOCK_GROUP_END:
  case LIBSPECTRUM_TAPE_BLOCK_JUMP:
  case LIBSPECTRUM_TAPE_BLOCK_LOOP_START:
  case LIBSPECTRUM_TAPE_BLOCK_LOOP_END:
  case LIBSPECTRUM_TAPE_BLOCK_SELECT:
  case LIBSPECTRUM_TAPE_BLOCK_STOP48:
  case LIBSPECTRUM_TAPE_BLOCK_SET_SIGNAL_LEVEL:
  case LIBSPECTRUM_TAPE_BLOCK_COMMENT:
  case LIBSPECTRUM_TAPE_BLOCK_MESSAGE:
  case LIBSPECTRUM_TAPE_BLOCK_ARCHIVE_INFO:
  case LIBSPECTRUM_TAPE_BLOCK_HARDWARE:
  case LIBSPECTRUM_TAPE_BLOCK_CUSTOM:
    return LIBSPECTRUM_ERROR_NONE;

  default:
    libspectrum_print_error(
      LIBSPECTRUM_ERROR_LOGIC,
      "libspectrum_tape_init_block: unknown block type 0x%02x",
      block->type
    );
    return LIBSPECTRUM_ERROR_LOGIC;
  }

  return LIBSPECTRUM_ERROR_NONE;
}
예제 #15
0
파일: machine.c 프로젝트: fesh0r/old-mame
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);
}
예제 #16
0
파일: main.c 프로젝트: lokedhs/ostis
int main(int argc, char *argv[])
{
  int c;
  struct state *state = NULL;
#if TEST_BUILD
  struct test_case *test_case;
#endif
  prefs_init();

  while(1) {
    int option_index = 0;
    static struct option long_options[] = {
      {"cart",                  required_argument, 0, OPT_CART },
      {"force-extreme-disasm",  no_argument,       0, OPT_FORCE_EXTREME_DISASM },
      {"crop-screen",           no_argument,       0, OPT_CROP_SCREEN },
      {"loglevels" ,            required_argument, 0, OPT_LOGLEVELS },
      {"audio-device" ,         required_argument, 0, OPT_AUDIO_DEVICE },
#if TEST_BUILD
      {"test-case",             required_argument, 0, OPT_TEST_MODE},
#endif
      {0,                       0,                 0, 0 }
    };
    c = getopt_long(argc, argv, "a:b:c:t:s:hdpyVAMvq", long_options, &option_index);
    if(c == -1) break;

    switch(c) {
    case 'a':
      prefs_set("diskimage", optarg);
      break;
    case 'b':
      prefs_set("diskimage2", optarg);
      break;
    case 'c':
      prefs_set("hdimage", optarg);
      break;
    case 't':
      prefs_set("tosimage", optarg);
      break;
    case 's':
      prefs_set("stateimage", optarg);
      break;
    case OPT_CART:
      prefs_set("cartimage", optarg);
      break;
    case OPT_FORCE_EXTREME_DISASM:
      cprint_all = 1;
      break;
    case OPT_CROP_SCREEN:
      crop_screen = 1;
      break;
    case OPT_LOGLEVELS:
      diag_set_module_levels(optarg);
      break;
    case OPT_AUDIO_DEVICE:
      if(!strncmp("list", optarg, 4)) {
        audio_device = -1;
      } else {
        audio_device = atoi(optarg);
      }
      break;
#if TEST_BUILD
    case OPT_TEST_MODE:
      test_case_name = xstrdup(optarg);
      test_mode = 1;
      break;
#endif
    case 'd':
      debugger = 1;
      break;
    case 'p':
      ppmoutput = 1;
      break;
    case 'y':
      psgoutput = 1;
      break;
    case 'v':
      verbosity++;
      break;
    case 'q':
      verbosity = MAX(1, verbosity-1);
      break;
    case 'V':
      vsync_delay = 1;
      break;
    case 'A':
      play_audio = 1;
      break;
    case 'M':
      monitor_sm124 = 1;
      break;
    case 'h':
    default:
      printf("Usage: %s [-AdMpqvVy] [-a diskimage1] [-b diskimage2] [-c hdimage] [-t tosimage] [-s stateimage]\n",
	     argv[0]);
      exit(-1);
      break;
    }
  }

  /* Do not crop screen while debugging */
  if(debugger) {
    crop_screen = 0;
  }
  
  if((prefs.diskimage == NULL) && (argv[optind] != NULL))
    prefs_set("diskimage", argv[optind]);

  SDL_Init(SDL_INIT_VIDEO|SDL_INIT_JOYSTICK|SDL_INIT_AUDIO);

#if TEST_BUILD
  if(test_mode) {
    test_case = test_init(test_case_name);
    if(test_case) {
      if(test_case->cartridge_name) {
        prefs_set("cartimage", test_case->cartridge_name);
      }
      if(test_case->floppy_name) {
        prefs_set("diskimage", test_case->floppy_name);
      }
    } else {
      printf("DEBUG: Could not load test case %s\n", test_case_name);
      exit(-3);
    }
  }
#endif
  
  /* Must run before hardware module inits */
  mmu_init();

  /* This must also be run before hardware modules.
     It gives a dummy area for some memory regions to not
     cause bus errors */
  mmu_fallback_init(); 

  /* Actual hardware */
  ram_init();
  rom_init();
  cpu_init();
  if(prefs.cartimage) {
    cartridge_init(prefs.cartimage);
  } else {
    cartridge_init(NULL);
  }
  psg_init();
  midi_init();
  acia_init();
  ikbd_init();
#if INCLUDE_RTC
  rtc_init();
#endif
  dma_init();
  fdc_init();
  hdc_init(prefs.hdimage);
  mfp_init();
  screen_disable(0);
  glue_init();
  shifter_init();
  if(debugger) {
    debug_init();
    cpu_halt_for_debug();
  }
  screen_init();
  
  floppy_init(prefs.diskimage, prefs.diskimage2);

  if(prefs.stateimage) {
    state = state_load(prefs.stateimage);
  }

  if(state != NULL)
    state_restore(state);

  memset(&reset, 0, sizeof reset);
  reset.sa_sigaction = reset_action;
  sigaction(SIGHUP, &reset, NULL);

  while(cpu_run(CPU_RUN));
  return 0;
}