예제 #1
0
/**
 * vdraw_ddraw_reinit_gens_window(): Reinitialize the Gens window.
 * @return 0 on success; non-zero on error.
 */
int vdraw_ddraw_reinit_gens_window(void)
{
	// Clear the sound buffer.
	audio_clear_sound_buffer();
	
	// Stop DirectDraw.
	vdraw_ddraw_end();
	
	// Reinitialize the Gens window.
	gens_window_reinit();
	
	// Reinitialize DirectDraw.
	return vdraw_ddraw_init();
}
예제 #2
0
/**
 * Reset_Genesis(): Resets the Genesis.
 */
void Reset_Genesis(void)
{
	// Clear the sound buffer.
	audio_clear_sound_buffer();
	
	Controller_1_COM = Controller_2_COM = 0;
	Settings.Paused = 0;
	
	// If the ROM size is smaller than 2MB, enable SRAM.
	// Otherwise, disable SRAM.
	// TODO: Instead of hardcoding 2MB, use SRAM_Start.
	if (Rom_Size <= (2 * 1024 * 1024))
	{
		SRAM_ON = 1;
		SRAM_Write = 1;
	}
	else
	{
		SRAM_ON = 0;
		SRAM_Write = 0;
	}
	
	// Reset all CPUs and other components.
	M68K_Reset(0);
	Z80_Reset();
	VDP_Reset();
	YM2612_Reset();
	
	// Initialize the controller state.
	Init_Controllers();
	
	if (CPU_Mode)
		VDP_Status |= 1;
	else
		VDP_Status &= ~1;
	
	if (Auto_Fix_CS)
		ROM::fixChecksum();
}
예제 #3
0
/**
 * Init_Genesis_Bios(): Initialize the Genesis BIOS.
 * TODO: Fix this. It doesn't seem to work properly.
 */
void Init_Genesis_Bios(void)
{
	// TODO: Compressor support.
	FILE *f;
	
	// Clear the sound buffer.
	audio_clear_sound_buffer();
	
	// Clear the TMSS firmware buffer.
	memset(&Genesis_Rom[0], 0x00, sizeof(Genesis_Rom));
	
	ROM_ByteSwap_State &= ~ROM_BYTESWAPPED_MD_TMSS;
	if ((f = fopen(BIOS_Filenames.MD_TMSS, "rb")))
	{
		size_t n = fread(&Genesis_Rom[0], 1, sizeof(Genesis_Rom), f);
		fclose(f);
		be16_to_cpu_array(&Genesis_Rom[0], n);
		Rom_Size = n;
	}
	else
	{
		// No Genesis TMSS ROM.
		Rom_Size = sizeof(Genesis_Rom);
	}
	ROM_ByteSwap_State |= ROM_BYTESWAPPED_MD_TMSS;
	
	memcpy(Rom_Data, Genesis_Rom, Rom_Size);
	Game_Mode = 0;
	CPU_Mode = 0;
	VDP_Num_Vis_Lines = 224;
	
	// Set the clock frequencies.
	Set_Clock_Freq(0);
	
	// Reset the CPUs.
	M68K_Reset(0);
	Z80_Reset();
	VDP_Reset();
}
예제 #4
0
/**
 * Init_Genesis(): Initialize the Genesis with the specified ROM image.
 * @param MD_ROM ROM image struct.
 * @return 1 if successful.
 */
int Init_Genesis(ROM_t* MD_ROM)
{
	// Clear the sound buffer.
	audio_clear_sound_buffer();
	
	Flag_Clr_Scr = 1;
	Settings.Paused = Frame_Number = 0;
	SRAM_Start = SRAM_End = SRAM_ON = SRAM_Write = 0;
	Controller_1_COM = Controller_2_COM = 0;
#ifdef GENS_DEBUGGER
	STOP_DEBUGGING();
#endif

	
#if 0	// TODO: Replace with MDP "exclusive mode" later.
	if (!Kaillera_Client_Running)
#endif
	Init_Genesis_SRAM(MD_ROM);
	
	// Check what country code should be used.
	// TODO: Get rid of magic numbers.
	switch (Country)
	{
		default:
		case -1: // Autodetection.
			Detect_Country_Genesis(MD_ROM);
			break;
		
		case 0: // Japan (NTSC)
			Game_Mode = 0;
			CPU_Mode = 0;
			break;
		
		case 1: // US (NTSC)
			Game_Mode = 1;
			CPU_Mode = 0;
			break;
		
		case 2: // Europe (PAL)
			Game_Mode = 1;
			CPU_Mode = 1;
			break;
		
		case 3: // Japan (PAL)
			Game_Mode = 0;
			CPU_Mode = 1;
			break;
	}
	
	VDP_Num_Vis_Lines = 224;
	Gen_Version = 0x20 + 0x0;	// Version de la megadrive (0x0 - 0xF)
	
	// Byteswap the ROM data.
	be16_to_cpu_array(Rom_Data, Rom_Size);
	ROM_ByteSwap_State |= ROM_BYTESWAPPED_MD_ROM;
	
	// Reset all CPUs and other components.
	M68K_Reset(0);
	Z80_Reset();
	VDP_Reset();
	
	// Initialize the controller state.
	Init_Controllers();
	
	// Set clock rates depending on the CPU mode (NTSC / PAL).
	Set_Clock_Freq(0);
	
	// If auto-fix checksum is enabled, fix the ROM checksum.
	if (Auto_Fix_CS)
		ROM::fixChecksum();
	
	// Initialize sound.
	if (audio_get_enabled())
	{
		audio_end();
		
		if (audio_init(AUDIO_BACKEND_DEFAULT))
			audio_set_enabled(false);
		else
		{
			if (audio_play_sound)
				audio_play_sound();
		}
	}
	
	Reset_Update_Timers();
	
	// Set the appropriate frame update function pointers.
	Update_Frame = Do_Genesis_Frame;
	Update_Frame_Fast = Do_Genesis_Frame_No_VDP;
	
	return 1;
}