int32 PCECD_Init() { if (!CDIF_Init()) return -1; CDDAVolumeSetting = (double)MDFN_GetSettingUI("pce.cddavolume"); if(CDDAVolumeSetting != 100) { MDFN_printf(_("CD-DA Volume: %d%%\n"), (int)CDDAVolumeSetting); } CDDAVolumeSetting /= 100; CurrentCDVolume = InitialCdVolume = 65536; VolumeStep = InitialCdVolume / 100; bFadeOut = FALSE; bFadeIn = FALSE; ADPCM_SetNotificationFunction(adpcm_state_notification_callback_function); SCSICD_Init(SCSICD_PCE, 1 * pce_overclocked, &sbuf[0], &sbuf[1], 126000 * MDFN_GetSettingUI("pce.cdspeed"), 7159091 * pce_overclocked, CDIRQ, StuffSubchannel); SyncCDVolume(); #ifdef WANT_DEBUGGER MDFNDBG_AddRegGroup(&PCECDRegsGroup); #endif return 0; }
bool MDFNI_StartAVRecord(const char *path, double SoundRate) { try { QTRecord::VideoSpec spec; memset(&spec, 0, sizeof(spec)); spec.SoundRate = SoundRate; spec.SoundChan = MDFNGameInfo->soundchan; spec.VideoWidth = MDFNGameInfo->lcm_width; spec.VideoHeight = MDFNGameInfo->lcm_height; spec.VideoCodec = MDFN_GetSettingI("qtrecord.vcodec"); spec.MasterClock = MDFNGameInfo->MasterClock; if(spec.VideoWidth < MDFN_GetSettingUI("qtrecord.w_double_threshold")) spec.VideoWidth *= 2; if(spec.VideoHeight < MDFN_GetSettingUI("qtrecord.h_double_threshold")) spec.VideoHeight *= 2; spec.AspectXAdjust = ((double)MDFNGameInfo->nominal_width * 2) / spec.VideoWidth; spec.AspectYAdjust = ((double)MDFNGameInfo->nominal_height * 2) / spec.VideoHeight; MDFN_printf("\n"); MDFN_printf(_("Starting QuickTime recording to file \"%s\":\n"), path); MDFN_indent(1); MDFN_printf(_("Video width: %u\n"), spec.VideoWidth); MDFN_printf(_("Video height: %u\n"), spec.VideoHeight); MDFN_printf(_("Video codec: %s\n"), MDFN_GetSettingS("qtrecord.vcodec").c_str()); if(spec.SoundRate && spec.SoundChan) { MDFN_printf(_("Sound rate: %u\n"), std::min<uint32>(spec.SoundRate, 64000)); MDFN_printf(_("Sound channels: %u\n"), spec.SoundChan); } else MDFN_printf(_("Sound: Disabled\n")); MDFN_indent(-1); MDFN_printf("\n"); qtrecorder = new QTRecord(path, spec); } catch(std::exception &e) { MDFND_PrintError(e.what()); return(false); } return(true); }
void MDFN_StateEvilBegin(void) { int x; std::string srwcompstring; if(!EvilEnabled) return; SRW_NUM = (int)MDFN_GetSettingUI("srwframes"); SRWCompressor = SRW_COMPRESSOR_MINILZO; srwcompstring = MDFN_GetSettingS("srwcompressor"); if(srwcompstring == "minilzo") SRWCompressor = SRW_COMPRESSOR_MINILZO; else if(srwcompstring == "quicklz") SRWCompressor = SRW_COMPRESSOR_QUICKLZ; else if(srwcompstring == "blz") SRWCompressor = SRW_COMPRESSOR_BLZ; bcs = (StateMemPacket *)calloc(SRW_NUM, sizeof(StateMemPacket)); bcspos = 0; for(x=0;x<SRW_NUM;x++) { bcs[x].data = NULL; bcs[x].compressed_len = 0; bcs[x].uncompressed_len = 0; memset(&bcs[x].MovieLove, 0, sizeof(StateMem)); } }
void PCE_InitCD(void) { PCECD_Settings cd_settings; memset(&cd_settings, 0, sizeof(PCECD_Settings)); cd_settings.CDDA_Volume = (double)MDFN_GetSettingUI("pce_fast.cddavolume") / 100; cd_settings.CD_Speed = MDFN_GetSettingUI("pce_fast.cdspeed"); cd_settings.ADPCM_Volume = (double)MDFN_GetSettingUI("pce_fast.adpcmvolume") / 100; cd_settings.ADPCM_LPF = MDFN_GetSettingB("pce_fast.adpcmlp"); if(cd_settings.CDDA_Volume != 1.0) MDFN_printf(_("CD-DA Volume: %d%%\n"), (int)(100 * cd_settings.CDDA_Volume)); if(cd_settings.ADPCM_Volume != 1.0) MDFN_printf(_("ADPCM Volume: %d%%\n"), (int)(100 * cd_settings.ADPCM_Volume)); PCECD_Init(&cd_settings, PCECDIRQCB, PCE_MASTER_CLOCK, pce_overclocked, sbuf); }
static void LoadCommonPre(void) { // FIXME: Make these globals less global! pce_overclocked = MDFN_GetSettingUI("pce_fast.ocmultiplier"); PCE_ACEnabled = MDFN_GetSettingB("pce_fast.arcadecard"); if(pce_overclocked > 1) MDFN_printf(_("CPU overclock: %dx\n"), pce_overclocked); if(MDFN_GetSettingUI("pce_fast.cdspeed") > 1) MDFN_printf(_("CD-ROM speed: %ux\n"), (unsigned int)MDFN_GetSettingUI("pce_fast.cdspeed")); memset(HuCPUFastMap, 0, sizeof(HuCPUFastMap)); for(int x = 0; x < 0x100; x++) { PCERead[x] = PCEBusRead; PCEWrite[x] = PCENullWrite; } MDFNMP_Init(1024, (1 << 21) / 1024); }
// Called from main thread void Netplay_MT_Draw(const MDFN_PixelFormat& pformat, const int32 screen_w, const int32 screen_h) { if(!viewable) return; if(!inputable) { if((int64)Time::MonoMS() >= (LastTextTime + PopupTime)) { viewable = 0; return; } } NetConsole.ShowPrompt(inputable); // { const unsigned fontid = MDFN_GetSettingUI("netplay.console.font"); const int32 lines = MDFN_GetSettingUI("netplay.console.lines"); int32 scale = MDFN_GetSettingUI("netplay.console.scale"); MDFN_Rect srect; MDFN_Rect drect; if(!scale) scale = std::min<int32>(std::max<int32>(1, screen_h / 500), std::max<int32>(1, screen_w / 500)); srect.x = srect.y = 0; srect.w = screen_w / scale; srect.h = GetFontHeight(fontid) * lines; drect.x = 0; drect.y = screen_h - (srect.h * scale); drect.w = srect.w * scale; drect.h = srect.h * scale; BlitRaw(NetConsole.Draw(pformat, srect.w, srect.h, fontid), &srect, &drect); } }
static void LoadCommonPre(void) { HuC6280_Init(); // FIXME: Make these globals less global! pce_overclocked = MDFN_GetSettingUI("pce_fast.ocmultiplier"); PCE_ACEnabled = MDFN_GetSettingB("pce_fast.arcadecard"); if(pce_overclocked > 1) MDFN_printf(_("CPU overclock: %dx\n"), pce_overclocked); if(MDFN_GetSettingUI("pce_fast.cdspeed") > 1) MDFN_printf(_("CD-ROM speed: %ux\n"), (unsigned int)MDFN_GetSettingUI("pce_fast.cdspeed")); for(int x = 0; x < 0x100; x++) { HuCPU.PCERead[x] = PCEBusRead; HuCPU.PCEWrite[x] = PCENullWrite; } MDFNMP_Init(1024, (1 << 21) / 1024); sbuf = new Blip_Buffer[2]; }
void MT_SetMovieStatus(StateStatusStruct *status) { if(MovieStatus) { if(MovieStatus->gfx) free(MovieStatus->gfx); free(MovieStatus); } MovieStatus = status; if(status) MovieShow = MDFND_GetTime() + MDFN_GetSettingUI("osd.state_display_time"); else MovieShow = 0; }
static void Emulate(EmulateSpecStruct* espec) { SOUND_Set68KActive(true); SOUND_SetClockRatio(0x80000000); SOUND_StartFrame(espec->SoundRate / espec->soundmultiplier, MDFN_GetSettingUI("ssfplay.resamp_quality")); espec->soundmultiplier = 1; SOUND_Update(588 * 512); espec->MasterCycles = 588 * 256; espec->SoundBufSize = SOUND_FlushOutput(espec->SoundBuf, espec->SoundBufMaxSize, espec->NeedSoundReverse); espec->NeedSoundReverse = false; SOUND_ResetTS(); if(!espec->skip) { espec->LineWidths[0] = ~0; Player_Draw(espec->surface, &espec->DisplayRect, 0, espec->SoundBuf, espec->SoundBufSize); } }
// Called from game thread int MDFND_NetworkConnect(void) { std::string remote_host = MDFN_GetSettingS("netplay.host"); unsigned int remote_port = MDFN_GetSettingUI("netplay.port"); if(Connection) { MDFND_NetworkClose(); } try { #ifdef HAVE_POSIX_SOCKETS Connection = new NetClient_POSIX(); #elif defined(WIN32) Connection = new NetClient_WS2(); #else throw MDFN_Error(0, _("Networking system API support not compiled in.")); #endif Connection->Connect(remote_host.c_str(), remote_port); } catch(std::exception &e) { PrintNetError("%s", e.what()); return(0); } PrintNetStatus(_("*** Sending initialization data to server.")); MDFNDnetplay = 1; if(!MDFNI_NetplayStart()) { MDFNDnetplay = 0; return(0); } PrintNetStatus(_("*** Connection established.")); return(1); }
bool Sound_Init(MDFNGI *gi) { SexyAL_DriverInfo CurDriver; NeedReInit = false; SoundRate = 0; memset(&format, 0, sizeof(format)); memset(&buffering, 0, sizeof(buffering)); Interface = new SexyAL(); format.sampformat = SEXYAL_FMT_PCMS16; assert(gi->soundchan); format.channels = gi->soundchan; format.revbyteorder = 0; format.noninterleaved = false; format.rate = gi->soundrate ? gi->soundrate : MDFN_GetSettingUI("sound.rate"); buffering.ms = MDFN_GetSettingUI("sound.buffer_time"); if(!buffering.ms) { buffering.overhead_kludge = true; buffering.ms = 7 + floor(0.5 + 1.5 * 1000.0 / gi->fps * (256 * 65536)); } else buffering.overhead_kludge = false; buffering.period_us = MDFN_GetSettingUI("sound.period_time"); std::string zedevice = MDFN_GetSettingS("sound.device"); std::string zedriver = MDFN_GetSettingS("sound.driver"); MDFNI_printf(_("\nInitializing sound...\n")); MDFN_indent(1); if(!Interface->FindDriver(&CurDriver, zedriver.c_str())) { std::vector<SexyAL_DriverInfo> DriverTypes = Interface->GetDriverList(); MDFN_printf(_("\nUnknown sound driver \"%s\". Compiled-in sound drivers:\n"), zedriver.c_str()); MDFN_indent(2); for(unsigned x = 0; x < DriverTypes.size(); x++) { MDFN_printf("%s\n", DriverTypes[x].short_name); } MDFN_indent(-2); MDFN_printf("\n"); delete Interface; Interface = NULL; MDFN_indent(-1); return(FALSE); } if(!strcasecmp(zedevice.c_str(), "default")) MDFNI_printf(_("Using \"%s\" audio driver with SexyAL's default device selection."), CurDriver.name); else MDFNI_printf(_("Using \"%s\" audio driver with device \"%s\":"), CurDriver.name, zedevice.c_str()); MDFN_indent(1); //RunSexyALTest(Interface, &buffering, zedevice.c_str(), CurDriver.type); //exit(1); if(!(Output=Interface->Open(zedevice.c_str(), &format, &buffering, CurDriver.type))) { MDFND_PrintError(_("Error opening a sound device.")); delete Interface; Interface = NULL; MDFN_indent(-2); return(FALSE); } if(format.rate < 22050 || format.rate > 192000) { MDFND_PrintError(_("Set rate is out of range [22050-192000]")); Sound_Kill(); MDFN_indent(-2); return(FALSE); } MDFNI_printf(_("\nBits: %u%s\nRate: %u\nChannels: %u%s\nByte order: CPU %s\nBuffer size: %u sample frames(%f ms)\n"), (format.sampformat>>4)*8, (format.sampformat == SEXYAL_FMT_PCMFLOAT) ? _(" (floating-point)") : "",format.rate,format.channels,format.noninterleaved ? _(" (non-interleaved) ") : "", format.revbyteorder?"Reversed":"Native", buffering.buffer_size, (double)buffering.buffer_size * 1000 / format.rate); MDFNI_printf(_("Latency: %u sample frames(%f ms)\n"), buffering.latency, (double)buffering.latency * 1000 / format.rate); if(buffering.period_size) { //int64_t pt_test_result = ((int64_t)buffering.period_size * (1000 * 1000) / format.rate); int64_t bt_test_result = ((int64_t)(buffering.bt_gran ? buffering.bt_gran : buffering.period_size) * (1000 * 1000) / format.rate); MDFNI_printf(_("Period size: %u sample frames(%f ms)\n"), buffering.period_size, (double)buffering.period_size * 1000 / format.rate); if(bt_test_result > 5333) { MDFN_indent(1); if(!buffering.bt_gran) MDFN_printf(_("Warning: Period time is too large(it should be <= ~5.333ms). Video will appear very jerky.\n")); else MDFN_printf(_("Warning: Buffer update timing granularity is too large(%f; it should be <= ~5.333ms). Video will appear very jerky.\n"), (double)buffering.bt_gran * 1000 / format.rate); MDFN_indent(-1); } } format.sampformat = SEXYAL_FMT_PCMS16; format.channels = gi->soundchan?gi->soundchan:1; format.revbyteorder = 0; format.noninterleaved = false; //format.rate=gi->soundrate?gi->soundrate:soundrate; Output->SetConvert(Output, &format); EmuModBufferSize = (500 * format.rate + 999) / 1000; EmuModBuffer = (int16 *)calloc(sizeof(int16) * format.channels, EmuModBufferSize); SoundRate = format.rate; MDFN_indent(-2); return(1); }
static void LoadCommon(void) { IsSGX |= MDFN_GetSettingB("pce_fast.forcesgx") ? 1 : 0; if(IsHES) IsSGX = 1; // Don't modify IsSGX past this point. VDC_Init(IsSGX); VDC_SetSettings(MDFN_GetSettingB("pce_fast.nospritelimit"), MDFN_GetSettingB("pce_fast.correct_aspect")); if(IsSGX) { MDFN_printf("SuperGrafx Emulation Enabled.\n"); HuCPU.PCERead[0xF8] = HuCPU.PCERead[0xF9] = HuCPU.PCERead[0xFA] = HuCPU.PCERead[0xFB] = BaseRAMReadSGX; HuCPU.PCEWrite[0xF8] = HuCPU.PCEWrite[0xF9] = HuCPU.PCEWrite[0xFA] = HuCPU.PCEWrite[0xFB] = BaseRAMWriteSGX; for(int x = 0xf8; x < 0xfb; x++) HuCPU.FastMap[x] = &BaseRAM[(x & 0x3) * 8192]; HuCPU.PCERead[0xFF] = IOReadSGX; } else { HuCPU.PCERead[0xF8] = BaseRAMRead; HuCPU.PCERead[0xF9] = HuCPU.PCERead[0xFA] = HuCPU.PCERead[0xFB] = BaseRAMRead_Mirrored; HuCPU.PCEWrite[0xF8] = BaseRAMWrite; HuCPU.PCEWrite[0xF9] = HuCPU.PCEWrite[0xFA] = HuCPU.PCEWrite[0xFB] = BaseRAMWrite_Mirrored; for(int x = 0xf8; x < 0xfb; x++) HuCPU.FastMap[x] = &BaseRAM[0]; HuCPU.PCERead[0xFF] = IORead; } MDFNMP_AddRAM(IsSGX ? 32768 : 8192, 0xf8 * 8192, BaseRAM); HuCPU.PCEWrite[0xFF] = IOWrite; psg = new PCEFast_PSG(sbuf); psg->SetVolume(1.0); if(PCE_IsCD) { unsigned int cdpsgvolume = MDFN_GetSettingUI("pce_fast.cdpsgvolume"); if(cdpsgvolume != 100) { MDFN_printf(_("CD PSG Volume: %d%%\n"), cdpsgvolume); } psg->SetVolume(0.678 * cdpsgvolume / 100); } PCEINPUT_Init(); PCE_Power(); MDFNGameInfo->LayerNames = IsSGX ? "BG0\0SPR0\0BG1\0SPR1\0" : "Background\0Sprites\0"; MDFNGameInfo->fps = (uint32)((double)7159090.90909090 / 455 / 263 * 65536 * 256); if(!IsHES) { // Clean this up: if(!MDFN_GetSettingB("pce_fast.correct_aspect")) MDFNGameInfo->fb_width = 682; MDFNGameInfo->nominal_width = MDFN_GetSettingB("pce_fast.correct_aspect") ? 288 : 341; MDFNGameInfo->nominal_height = MDFN_GetSettingUI("pce_fast.slend") - MDFN_GetSettingUI("pce_fast.slstart") + 1; MDFNGameInfo->lcm_width = MDFN_GetSettingB("pce_fast.correct_aspect") ? 1024 : 341; MDFNGameInfo->lcm_height = MDFNGameInfo->nominal_height; } }
int NetplayStart(const char *PortDeviceCache[16], const uint32 PortDataLenCache[16]) { try { const char *emu_id = PACKAGE " " MEDNAFEN_VERSION; const uint32 local_players = MDFN_GetSettingUI("netplay.localplayers"); const std::string nickname = MDFN_GetSettingS("netplay.nick"); const std::string game_key = MDFN_GetSettingS("netplay.gamekey"); const std::string connect_password = MDFN_GetSettingS("netplay.password"); login_data_t *ld = NULL; std::vector<uint8> sendbuf; MDFNnetplay = true; sendbuf.resize(4 + sizeof(login_data_t) + nickname.size() + strlen(emu_id)); MDFN_en32lsb(&sendbuf[0], sendbuf.size() - 4); ld = (login_data_t*)&sendbuf[4]; if(game_key != "") { md5_context md5; uint8 md5out[16]; md5.starts(); md5.update(MDFNGameInfo->MD5, 16); md5.update((uint8 *)game_key.c_str(), game_key.size()); md5.finish(md5out); memcpy(ld->gameid, md5out, 16); } else memcpy(ld->gameid, MDFNGameInfo->MD5, 16); if(connect_password != "") { md5_context md5; uint8 md5out[16]; md5.starts(); md5.update((uint8*)connect_password.c_str(), connect_password.size()); md5.finish(md5out); memcpy(ld->password, md5out, 16); } assert(MDFNGameInfo->InputInfo->InputPorts <= 16); ld->protocol_version = 3; // Set input device number thingies here. ld->total_controllers = MDFNGameInfo->InputInfo->InputPorts; // Total number of ports MDFN_en32lsb(ld->emu_name_len, strlen(emu_id)); // Controller data sizes. for(int x = 0; x < MDFNGameInfo->InputInfo->InputPorts; x++) ld->controller_data_size[x] = PortDataLenCache[x]; // Controller types for(int x = 0; x < MDFNGameInfo->InputInfo->InputPorts; x++) { unsigned ct = 0; for(int d = 0; d < MDFNGameInfo->InputInfo->Types[x].NumTypes; d++) { if(!strcasecmp(MDFNGameInfo->InputInfo->Types[x].DeviceInfo[d].ShortName, PortDeviceCache[x])) { ct = d; break; } } //printf("%d, 0x%02x\n", x, ct); ld->controller_type[x] = ct; } ld->local_players = local_players; if(nickname != "") memcpy(&sendbuf[4 + sizeof(login_data_t)], nickname.c_str(), nickname.size()); memcpy(&sendbuf[4 + sizeof(login_data_t) + nickname.size()], emu_id, strlen(emu_id)); MDFND_SendData(&sendbuf[0], sendbuf.size()); TotalInputStateSize = 0; for(int x = 0; x < MDFNGameInfo->InputInfo->InputPorts; x++) TotalInputStateSize += PortDataLenCache[x]; // Hack so the server can always encode its command data length properly(a matching "hack" exists in the server). if(TotalInputStateSize < 4) TotalInputStateSize = 4; TotalInputStateSize = TotalInputStateSize; LocalPlayersMask = 0; LocalInputStateSize = 0; Joined = false; // // // MDFN_FlushGameCheats(0); /* Save our pre-netplay cheats. */ if(MDFNMOV_IsPlaying()) /* Recording's ok during netplay, playback is not. */ MDFNMOV_Stop(); } catch(std::exception &e) { NetError("%s", e.what()); return(false); } //printf("%d\n", TotalInputStateSize); return(1); }
static int LoadCommon(void) { IsSGX |= MDFN_GetSettingB("pce_fast.forcesgx") ? 1 : 0; if(IsHES) IsSGX = 1; // Don't modify IsSGX past this point. VDC_Init(IsSGX); if(IsSGX) { MDFN_printf("SuperGrafx Emulation Enabled.\n"); PCERead[0xF8] = PCERead[0xF9] = PCERead[0xFA] = PCERead[0xFB] = BaseRAMReadSGX; PCEWrite[0xF8] = PCEWrite[0xF9] = PCEWrite[0xFA] = PCEWrite[0xFB] = BaseRAMWriteSGX; for(int x = 0xf8; x < 0xfb; x++) HuCPUFastMap[x] = BaseRAM - 0xf8 * 8192; PCERead[0xFF] = IOReadSGX; } else { PCERead[0xF8] = BaseRAMRead; PCERead[0xF9] = PCERead[0xFA] = PCERead[0xFB] = BaseRAMRead_Mirrored; PCEWrite[0xF8] = BaseRAMWrite; PCEWrite[0xF9] = PCEWrite[0xFA] = PCEWrite[0xFB] = BaseRAMWrite_Mirrored; for(int x = 0xf8; x < 0xfb; x++) HuCPUFastMap[x] = BaseRAM - x * 8192; PCERead[0xFF] = IORead; } MDFNMP_AddRAM(IsSGX ? 32768 : 8192, 0xf8 * 8192, BaseRAM); PCEWrite[0xFF] = IOWrite; HuC6280_Init(); psg = new PCE_PSG(&sbuf[0], &sbuf[1], PCE_PSG::REVISION_ENHANCED); //HUC6280A); //psg->init(&sbuf[0], &sbuf[1], PCE_PSG::REVISION_ENHANCED); psg->SetVolume(1.0); if(PCE_IsCD) { unsigned int cdpsgvolume = MDFN_GetSettingUI("pce_fast.cdpsgvolume"); if(cdpsgvolume != 100) { MDFN_printf(_("CD PSG Volume: %d%%\n"), cdpsgvolume); } psg->SetVolume(0.678 * cdpsgvolume / 100); } PCEINPUT_Init(); PCE_Power(); MDFNGameInfo->LayerNames = IsSGX ? "BG0\0SPR0\0BG1\0SPR1\0" : "Background\0Sprites\0"; MDFNGameInfo->fps = (uint32)((double)7159090.90909090 / 455 / 263 * 65536 * 256); // Clean this up: if(!MDFN_GetSettingB("pce_fast.correct_aspect")) MDFNGameInfo->fb_width = 682; if(!IsHES) { MDFNGameInfo->nominal_width = MDFN_GetSettingB("pce_fast.correct_aspect") ? 320 : 341; MDFNGameInfo->nominal_height = MDFN_GetSettingUI("pce_fast.slend") - MDFN_GetSettingUI("pce_fast.slstart") + 1; MDFNGameInfo->lcm_width = MDFN_GetSettingB("pce_fast.correct_aspect") ? 1024 : 341; MDFNGameInfo->lcm_height = MDFNGameInfo->nominal_height; } return(1); }
static void LoadCommonPost(const md_game_info &ginfo) { MDFN_printf(_("ROM: %dKiB\n"), (ginfo.rom_size + 1023) / 1024); MDFN_printf(_("ROM CRC32: 0x%08x\n"), ginfo.crc32); MDFN_printf(_("ROM MD5: 0x%s\n"), md5_context::asciistr(ginfo.md5, 0).c_str()); MDFN_printf(_("Header MD5: 0x%s\n"), md5_context::asciistr(ginfo.info_header_md5, 0).c_str()); MDFN_printf(_("Product Code: %s\n"), ginfo.product_code); MDFN_printf(_("Domestic name: %s\n"), ginfo.domestic_name); // TODO: Character set conversion(shift_jis -> utf-8) MDFN_printf(_("Overseas name: %s\n"), ginfo.overseas_name); MDFN_printf(_("Copyright: %s\n"), ginfo.copyright); if(ginfo.checksum == ginfo.checksum_real) MDFN_printf(_("Checksum: 0x%04x\n"), ginfo.checksum); else MDFN_printf(_("Checksum: 0x%04x\n Warning: calculated checksum(0x%04x) does not match\n"), ginfo.checksum, ginfo.checksum_real); MDFN_printf(_("Supported I/O devices:\n")); MDFN_indent(1); for(unsigned int iot = 0; iot < sizeof(IO_types) / sizeof(IO_type_t); iot++) { if(ginfo.io_support & (1 << IO_types[iot].id)) MDFN_printf(_("%s\n"), _(IO_types[iot].name)); } MDFN_indent(-1); MDFNMP_Init(8192, (1 << 24) / 8192); MDFNMP_AddRAM(65536, 0x7 << 21, work_ram); MDFNGameInfo->GameSetMD5Valid = FALSE; MDSound_Init(); MDFN_printf(_("Supported regions:\n")); MDFN_indent(1); if(ginfo.region_support & REGIONMASK_JAPAN_NTSC) MDFN_printf(_("Japan/Domestic NTSC\n")); if(ginfo.region_support & REGIONMASK_JAPAN_PAL) MDFN_printf(_("Japan/Domestic PAL\n")); if(ginfo.region_support & REGIONMASK_OVERSEAS_NTSC) MDFN_printf(_("Overseas NTSC\n")); if(ginfo.region_support & REGIONMASK_OVERSEAS_PAL) MDFN_printf(_("Overseas PAL\n")); MDFN_indent(-1); { const int region_setting = MDFN_GetSettingI("md.region"); const int reported_region_setting = MDFN_GetSettingI("md.reported_region"); // Default, in case the game doesn't support any regions! bool game_overseas = TRUE; bool game_pal = FALSE; bool overseas; bool pal; bool overseas_reported; bool pal_reported; // Preference order, TODO: Make it configurable if(ginfo.region_support & REGIONMASK_OVERSEAS_NTSC) { game_overseas = TRUE; game_pal = FALSE; } else if(ginfo.region_support & REGIONMASK_JAPAN_NTSC) { game_overseas = FALSE; game_pal = FALSE; } else if(ginfo.region_support & REGIONMASK_OVERSEAS_PAL) { game_overseas = TRUE; game_pal = TRUE; } else if(ginfo.region_support & REGIONMASK_JAPAN_PAL) // WTF? { game_overseas = FALSE; game_pal = TRUE; } if(region_setting == REGION_GAME) { overseas = game_overseas; pal = game_pal; } else { decode_region_setting(region_setting, overseas, pal); } if(reported_region_setting == REGION_GAME) { overseas_reported = game_overseas; pal_reported = game_pal; } else if(reported_region_setting == REGION_SAME) { overseas_reported = overseas; pal_reported = pal; } else { decode_region_setting(reported_region_setting, overseas_reported, pal_reported); } MDFN_printf("\n"); MDFN_printf(_("Active Region: %s %s\n"), overseas ? _("Overseas") : _("Domestic"), pal ? _("PAL") : _("NTSC")); MDFN_printf(_("Active Region Reported: %s %s\n"), overseas_reported ? _("Overseas") : _("Domestic"), pal_reported ? _("PAL") : _("NTSC")); system_init(overseas, pal, overseas_reported, pal_reported); if(pal) MDFNGameInfo->nominal_height = 240; else MDFNGameInfo->nominal_height = 224; MDFNGameInfo->MasterClock = MDFN_MASTERCLOCK_FIXED(pal ? CLOCK_PAL : CLOCK_NTSC); if(pal) MDFNGameInfo->fps = (int64)CLOCK_PAL * 65536 * 256 / (313 * 3420); else MDFNGameInfo->fps = (int64)CLOCK_NTSC * 65536 * 256 / (262 * 3420); //printf("%f\n", (double)MDFNGameInfo->fps / 65536 / 256); } if(MDFN_GetSettingB("md.correct_aspect")) { MDFNGameInfo->nominal_width = 292; MDFNGameInfo->lcm_width = 1280; } else { MDFNGameInfo->nominal_width = 320; MDFNGameInfo->lcm_width = 320; } MDFNGameInfo->lcm_height = MDFNGameInfo->nominal_height * 2; MDFNGameInfo->LayerNames = "BG0\0BG1\0OBJ\0"; // // { unsigned mtt = MDFN_GetSettingUI("md.input.multitap"); if(MDFN_GetSettingB("md.input.auto")) { for(auto const& e : InputDB) { if(e.crc32 == ginfo.crc32 && (!e.prod_code || !strcmp(e.prod_code, ginfo.product_code))) { MDFNGameInfo->DesiredInput.resize(8); for(unsigned n = e.max_players; n < 8; n++) // Particularly for Gauntlet 4. MDFNGameInfo->DesiredInput[n] = "none"; mtt = e.tap; break; } } } for(const auto* mte = MultiTap_List; mte->string; mte++) { if((unsigned)mte->number == mtt) { MDFN_printf(_("Active Multitap(s): %s\n"), mte->description); break; } } MDINPUT_SetMultitap(mtt); } // // system_reset(true); }
bool SoundBox_SetSoundRate(uint32 rate) { SoundEnabled = (bool)rate; if(FXres) { delete FXres; FXres = NULL; } if(rate > 0) { FXres = new OwlResampler(PCFX_MASTER_CLOCK / 12, rate, MDFN_GetSettingF("pcfx.resamp_rate_error"), 20, MDFN_GetSettingUI("pcfx.resamp_quality")); for(unsigned i = 0; i < 2; i++) FXres->ResetBufResampState(FXsbuf[i]); } RedoVolume(); return(TRUE); }
bool InitSound(MDFNGI *gi) { SoundRate = 0; memset(&format,0,sizeof(format)); memset(&buffering,0,sizeof(buffering)); Interface = (SexyAL *)SexyAL_Init(0); DriverTypes = Interface->EnumerateTypes(Interface); format.sampformat = SEXYAL_FMT_PCMS16; assert(gi->soundchan); format.channels = gi->soundchan; format.revbyteorder = 0; format.rate = gi->soundrate ? gi->soundrate : MDFN_GetSettingUI("sound.rate"); buffering.ms = MDFN_GetSettingUI("sound.buffer_time"); buffering.period_us = MDFN_GetSettingUI("sound.period_time"); std::string zedevice = MDFN_GetSettingS("sound.device"); std::string zedriver = MDFN_GetSettingS("sound.driver"); CurDriverIndex = -1; if(!strcasecmp(zedriver.c_str(), "default")) CurDriverIndex = 0; else { for(int x = 0; DriverTypes[x].short_name; x++) { if(!strcasecmp(zedriver.c_str(), DriverTypes[x].short_name)) { CurDriverIndex = x; break; } } } MDFNI_printf(_("\nInitializing sound...\n")); MDFN_indent(1); if(CurDriverIndex == -1) { MDFN_printf(_("\nUnknown sound driver \"%s\". Supported sound drivers:\n"), zedriver.c_str()); MDFN_indent(2); for(int x = 0; DriverTypes[x].short_name; x++) { MDFN_printf("%s\n", DriverTypes[x].short_name); } MDFN_indent(-2); MDFN_printf("\n"); Interface->Destroy(Interface); Interface = NULL; MDFN_indent(-1); return(FALSE); } MDFNI_printf(_("Using \"%s\" audio driver with device \"%s\":"),DriverTypes[CurDriverIndex].name, zedevice.c_str()); MDFN_indent(1); //RunSexyALTest(Interface, &buffering, zedevice.c_str(), DriverTypes[CurDriverIndex].type); //exit(1); if(!(Output=Interface->Open(Interface, zedevice.c_str(), &format, &buffering, DriverTypes[CurDriverIndex].type))) { MDFND_PrintError(_("Error opening a sound device.")); Interface->Destroy(Interface); Interface=0; MDFN_indent(-2); return(FALSE); } if(format.rate<8192 || format.rate > 48000) { MDFND_PrintError(_("Set rate is out of range [8192-48000]")); KillSound(); MDFN_indent(-2); return(FALSE); } MDFNI_printf(_("\nBits: %u\nRate: %u\nChannels: %u\nByte order: CPU %s\nBuffer size: %u sample frames(%f ms)\n"), (format.sampformat>>4)*8,format.rate,format.channels,format.revbyteorder?"Reversed":"Native", buffering.buffer_size, (double)buffering.buffer_size * 1000 / format.rate); MDFNI_printf(_("Latency: %u sample frames(%f ms)\n"), buffering.latency, (double)buffering.latency * 1000 / format.rate); if(buffering.period_size) { int64_t pt_test_result = ((int64_t)buffering.period_size * (1000 * 1000) / format.rate); MDFNI_printf(_("Period size: %u sample frames(%f ms)\n"), buffering.period_size, (double)buffering.period_size * 1000 / format.rate); if(pt_test_result > 5333) { MDFN_indent(1); MDFN_printf(_("Warning: Period time is too large(it should be <= ~5.333ms). Video will appear very jerky.\n")); MDFN_indent(-1); } } format.sampformat=SEXYAL_FMT_PCMS16; format.channels=gi->soundchan?gi->soundchan:1; format.revbyteorder=0; //format.rate=gi->soundrate?gi->soundrate:soundrate; Output->SetConvert(Output, &format); EmuModBufferSize = (500 * format.rate + 999) / 1000; EmuModBuffer = (int16 *)calloc(sizeof(int16) * format.channels, EmuModBufferSize); SoundRate = format.rate; MDFN_indent(-2); return(1); }