diff --git a/core/build.h b/core/build.h index 54c88682e..a10081393 100755 --- a/core/build.h +++ b/core/build.h @@ -333,7 +333,6 @@ #define RAM_SIZE_MAX (32*1024*1024) #define VRAM_SIZE_MAX (16*1024*1024) #define ARAM_SIZE_MAX (8*1024*1024) -#define BUILD_DREAMCAST 1 #define GD_CLOCK 33868800 //GDROM XTAL -- 768fs diff --git a/core/cfg/cl.cpp b/core/cfg/cl.cpp index c36221e32..2e8d9e03f 100644 --- a/core/cfg/cl.cpp +++ b/core/cfg/cl.cpp @@ -111,7 +111,7 @@ int showhelp(wchar** arg,int cl) bool ParseCommandLine(int argc,wchar* argv[]) { - cfgSetVirtual("config", "image", ""); + settings.imgread.ImagePath[0] = '\0'; int cl=argc-2; wchar** arg=argv+1; while(cl>=0) @@ -136,7 +136,7 @@ bool ParseCommandLine(int argc,wchar* argv[]) || stricmp(extension, ".gdi") == 0 || stricmp(extension, ".cue") == 0)) { INFO_LOG(COMMON, "Using '%s' as cd image", *arg); - cfgSetVirtual("config", "image", *arg); + strcpy(settings.imgread.ImagePath, *arg); } else if (extension && stricmp(extension, ".elf") == 0) { @@ -147,7 +147,7 @@ bool ParseCommandLine(int argc,wchar* argv[]) else { INFO_LOG(COMMON, "Using '%s' as rom", *arg); - cfgSetVirtual("config", "image", *arg); + strcpy(settings.imgread.ImagePath, *arg); } } arg++; diff --git a/core/hw/gdrom/gdrom_response.cpp b/core/hw/gdrom/gdrom_response.cpp index d88166348..c4f2f59a4 100644 --- a/core/hw/gdrom/gdrom_response.cpp +++ b/core/hw/gdrom/gdrom_response.cpp @@ -7,7 +7,7 @@ Some of these were copy-pasted, some i captured on my own, can't recall what-when ;p */ -u16 reply_a1[] = +extern const u16 reply_a1[] = { 0x2020,0x0020,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x4553,0x2020,0x2020,0x2020,0x2020,0x2020,0x2020,0x2020, @@ -16,7 +16,7 @@ u16 reply_a1[] = 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000 }; -u16 reply_71[] = +extern const u16 reply_71[] = { 0x0b96,0xf045,0xff7e,0x063d,0x7d4d,0xbf10,0x0007,0xcf73,0x009c,0x0cbc,0xaf1c,0x301c,0xa7e7,0xa803,0x0098,0x0fbd,0x5bbd,0x50aa,0x3923, 0x1031,0x690e,0xe513,0xd200,0x660d,0xbf54,0xfd5f,0x7437,0x5bf4,0x0022,0x09c6,0xca0f,0xe893,0xaba4,0x6100,0x2e0e,0x4be1,0x8b76,0xa56a, @@ -48,4 +48,4 @@ u16 reply_71[] = }; -u32 reply_71_sz=sizeof(reply_71); +extern const u32 reply_71_sz = sizeof(reply_71); diff --git a/core/hw/gdrom/gdromv3.cpp b/core/hw/gdrom/gdromv3.cpp index 758137ac6..0ba77f87b 100644 --- a/core/hw/gdrom/gdromv3.cpp +++ b/core/hw/gdrom/gdromv3.cpp @@ -97,7 +97,7 @@ void libCore_CDDA_Sector(s16* sector) memset(sector,0,2352); } } -void gd_spi_pio_end(u8* buffer,u32 len,gd_states next_state=gds_pio_end); +void gd_spi_pio_end(const u8* buffer, u32 len, gd_states next_state = gds_pio_end); void gd_process_spi_cmd(); void gd_process_ata_cmd(); @@ -333,7 +333,7 @@ void libCore_gdrom_disc_change() } //This handles the work of setting up the pio regs/state :) -void gd_spi_pio_end(u8* buffer, u32 len, gd_states next_state) +void gd_spi_pio_end(const u8* buffer, u32 len, gd_states next_state) { verify(len<0xFFFF); pio_buff.index=0; @@ -412,7 +412,7 @@ void gd_process_ata_cmd() case ATA_IDENTIFY_DEV: printf_ata("ATA_IDENTIFY_DEV"); - gd_spi_pio_end((u8*)&reply_a1[packet_cmd.data_8[2]>>1],packet_cmd.data_8[4]); + gd_spi_pio_end((const u8*)&reply_a1[packet_cmd.data_8[2] >> 1], packet_cmd.data_8[4]); break; case ATA_SET_FEATURES: @@ -505,6 +505,9 @@ void gd_process_spi_cmd() printf_spicmd("SPI_TEST_UNIT"); GDStatus.CHECK=SecNumber.Status==GD_BUSY; // Drive is ready ;) +// sns_key=0; +// sns_asc=0; +// sns_ascq=0; gd_set_state(gds_procpacketdone); break; @@ -526,11 +529,8 @@ void gd_process_spi_cmd() else if(readcmd.head ||readcmd.subh || readcmd.other || (!readcmd.data)) // assert WARN_LOG(GDROM, "GDROM: *FIXME* ADD MORE CD READ SETTINGS %d %d %d %d 0x%01X",readcmd.head,readcmd.subh,readcmd.other,readcmd.data,readcmd.expdtype); - u32 start_sector = GetFAD(&readcmd.b[2],readcmd.prmtype); - u32 sector_count = (readcmd.b[8]<<16) | (readcmd.b[9]<<8) | (readcmd.b[10]); - - read_params.start_sector=start_sector; - read_params.remaining_sectors=sector_count; + read_params.start_sector = GetFAD(&readcmd.b[2], readcmd.prmtype); + read_params.remaining_sectors = (readcmd.b[8] << 16) | (readcmd.b[9] << 8) | (readcmd.b[10]); read_params.sector_type = sector_type;//yeah i know , not really many types supported... printf_spicmd("SPI_CD_READ - Sector=%d Size=%d/%d DMA=%d",read_params.start_sector,read_params.remaining_sectors,read_params.sector_type,Features.CDRead.DMA); @@ -579,9 +579,9 @@ void gd_process_spi_cmd() { printf_spicmd("SPI : unknown ? [0x71]"); //printf("SPI : unknown ? [0x71]\n"); - extern u32 reply_71_sz; + extern const u32 reply_71_sz; - gd_spi_pio_end((u8*)&reply_71[0],reply_71_sz);//uCount + gd_spi_pio_end((const u8*)&reply_71[0], reply_71_sz);//uCount if (libGDR_GetDiscType()==GdRom || libGDR_GetDiscType()==CdRom_XA) @@ -703,7 +703,7 @@ void gd_process_spi_cmd() } else { - die("SPI_CD_SEEK : not known parameter.."); + die("SPI_CD_PLAY : not known parameter.."); } cdda.repeats=packet_cmd.data_8[6]&0xF; DEBUG_LOG(GDROM, "cdda.StartAddr=%d",cdda.StartAddr.FAD); @@ -799,7 +799,7 @@ u32 ReadMem_gdrom(u32 Addr, u32 sz) return GDStatus.full | (1<<4); case GD_ALTSTAT_Read: - printf_rm("GDROM: Read From AltStatus (v=%X)",GDStatus.full); +// printf_rm("GDROM: Read From AltStatus (v=%X)",GDStatus.full); return GDStatus.full | (1<<4); case GD_BYCTLLO : @@ -854,7 +854,7 @@ u32 ReadMem_gdrom(u32 Addr, u32 sz) return IntReason.full; case GD_SECTNUM: - printf_rm("GDROM: Read from SecNumber Register (v=%X)", SecNumber.full); +// printf_rm("GDROM: Read from SecNumber Register (v=%X)", SecNumber.full); return SecNumber.full; default: @@ -967,9 +967,7 @@ static int getGDROMTicks() int GDRomschd(int i, int c, int j) { if(!(SB_GDST&1) || !(SB_GDEN &1) || (read_buff.cache_size==0 && read_params.remaining_sectors==0)) - { return 0; - } //SB_GDST=0; @@ -987,10 +985,8 @@ int GDRomschd(int i, int c, int j) //if we don't have any more sectors to read if (read_params.remaining_sectors == 0) - { //make sure we don't underrun the cache :) len = min(len, read_buff.cache_size); - } len = min(len, (u32)10240); // do we need to do this for GDROM DMA? @@ -1020,9 +1016,7 @@ int GDRomschd(int i, int c, int j) //transfer up to len bytes if (buff_size>len) - { buff_size=len; - } WriteMemBlock_nommu_ptr(src,(u32*)&read_buff.cache[read_buff.cache_index], buff_size); read_buff.cache_index+=buff_size; read_buff.cache_size-=buff_size; diff --git a/core/hw/gdrom/gdromv3.h b/core/hw/gdrom/gdromv3.h index eeba937d5..33f50e861 100644 --- a/core/hw/gdrom/gdromv3.h +++ b/core/hw/gdrom/gdromv3.h @@ -252,12 +252,11 @@ extern GD_HardwareInfo_t GD_HardwareInfo; #define GD_OPEN 0x06 // Tray is open #define GD_NODISC 0x07 // No disc #define GD_RETRY 0x08 // Read retry in progress (option) -#define GD_ERROR 0x09 // Reading of disc TOC failed (state does not allow access) +#define GD_ERROR 0x09 // Reading of disc TOC failed (state does not allow access) //Response strings -extern u16 reply_a1[]; -extern u16 reply_71[]; - +extern const u16 reply_a1[]; +extern const u16 reply_71[]; #define GD_IMPEDHI0_Read 0x005F7000 // (R) These are all #define GD_IMPEDHI4_Read 0x005F7004 // (R) RData bus high imped diff --git a/core/imgread/ImgReader.cpp b/core/imgread/ImgReader.cpp index 5de3e3f12..199a35c4c 100644 --- a/core/imgread/ImgReader.cpp +++ b/core/imgread/ImgReader.cpp @@ -29,12 +29,15 @@ void libGDR_GetToc(u32* toc,u32 area) u32 libGDR_GetTrackNumber(u32 sector, u32& elapsed) { - for (int i = 0; i < disc->tracks.size(); i++) - if (disc->tracks[i].StartFAD <= sector && (sector <= disc->tracks[i].EndFAD || disc->tracks[i].EndFAD == 0)) - { - elapsed = sector - disc->tracks[i].StartFAD; - return i + 1; - } + if (disc != NULL) + { + for (int i = 0; i < disc->tracks.size(); i++) + if (disc->tracks[i].StartFAD <= sector && (sector <= disc->tracks[i].EndFAD || disc->tracks[i].EndFAD == 0)) + { + elapsed = sector - disc->tracks[i].StartFAD; + return i + 1; + } + } elapsed = 0; return 0xAA; } diff --git a/core/imgread/common.cpp b/core/imgread/common.cpp index 96fc03de4..801a344e8 100644 --- a/core/imgread/common.cpp +++ b/core/imgread/common.cpp @@ -27,12 +27,8 @@ u8 q_subchannel[96]; static void PatchRegion_0(u8* sector, int size) { -#ifndef NOT_REICAST - if (settings.imgread.PatchRegion==0) + if (!settings.imgread.PatchRegion) return; -#else - return; -#endif u8* usersect=sector; @@ -48,12 +44,8 @@ static void PatchRegion_0(u8* sector, int size) static void PatchRegion_6(u8* sector, int size) { -#ifndef NOT_REICAST - if (settings.imgread.PatchRegion==0) + if (!settings.imgread.PatchRegion) return; -#else - return; -#endif u8* usersect=sector; @@ -156,38 +148,14 @@ bool InitDrive_(wchar* fn) INFO_LOG(GDROM, "gdrom: Failed to open image \"%s\"", fn); NullDriveDiscType = NoDisk; //no disc :) } -#ifndef NOT_REICAST libCore_gdrom_disc_change(); -#endif return disc != NULL; } -#ifndef NOT_REICAST bool InitDrive(u32 fileflags) { - if (settings.imgread.LoadDefaultImage) - { - INFO_LOG(GDROM, "Loading default image \"%s\"", settings.imgread.DefaultImage); - if (!InitDrive_(settings.imgread.DefaultImage)) - { - msgboxf("Default image \"%s\" failed to load",MBX_ICONERROR,settings.imgread.DefaultImage); - return false; - } - else - return true; - } - - // FIXME: Data loss if buffer is too small - wchar fn[512]; - fn[0] = '\0'; - -#ifdef BUILD_DREAMCAST - int gfrv=GetFile(fn,0,fileflags); -#else - int gfrv=0; -#endif - if (gfrv == 0) + if (settings.imgread.ImagePath[0] == '\0') { NullDriveDiscType=NoDisk; gd_setdisc(); @@ -196,12 +164,8 @@ bool InitDrive(u32 fileflags) sns_key=0x6; return true; } - else if (gfrv == -1) - { - return false; - } - if (!InitDrive_(fn)) + if (!InitDrive_(settings.imgread.ImagePath)) { //msgboxf("Selected image failed to load",MBX_ICONERROR); NullDriveDiscType = NoDisk; @@ -209,12 +173,18 @@ bool InitDrive(u32 fileflags) sns_asc = 0x29; sns_ascq = 0x00; sns_key = 0x6; - return true; - } - else - { - return true; } + return true; +} + +void DiscOpenLid() +{ + TermDrive(); + NullDriveDiscType = Open; + gd_setdisc(); + sns_asc = 0x29; + sns_ascq = 0x00; + sns_key = 0x6; } bool DiscSwap(u32 fileflags) @@ -223,40 +193,15 @@ bool DiscSwap(u32 fileflags) sns_asc = 0x28; sns_ascq = 0x00; sns_key = 0x6; - if (settings.imgread.LoadDefaultImage) - { - INFO_LOG(GDROM, "Loading default image \"%s\"", settings.imgread.DefaultImage); - if (!InitDrive_(settings.imgread.DefaultImage)) - { - msgboxf("Default image \"%s\" failed to load",MBX_ICONERROR,settings.imgread.DefaultImage); - return false; - } - else - return true; - } - // FIXME: Data loss if buffer is too small - wchar fn[512]; - fn[0] = '\0'; - - -#ifdef BUILD_DREAMCAST - int gfrv=GetFile(fn,0,fileflags); -#else - int gfrv=0; -#endif - if (gfrv == 0) + if (settings.imgread.ImagePath[0] == '\0') { NullDriveDiscType = Open; gd_setdisc(); return true; } - else if (gfrv == -1) - { - return false; - } - if (!InitDrive_(fn)) + if (!InitDrive_(settings.imgread.ImagePath)) { //msgboxf("Selected image failed to load",MBX_ICONERROR); NullDriveDiscType = Open; @@ -265,7 +210,6 @@ bool DiscSwap(u32 fileflags) return true; } -#endif void TermDrive() { diff --git a/core/imgread/common.h b/core/imgread/common.h index 4031912e0..702b0ffbb 100644 --- a/core/imgread/common.h +++ b/core/imgread/common.h @@ -86,6 +86,7 @@ bool ConvertSector(u8* in_buff , u8* out_buff , int from , int to,int sector); bool InitDrive(u32 fileflags=0); void TermDrive(); bool DiscSwap(u32 fileflags=0); +void DiscOpenLid(); extern signed int sns_asc; extern signed int sns_ascq; extern signed int sns_key; diff --git a/core/input/gamepad_device.cpp b/core/input/gamepad_device.cpp index 10c9ab69f..77fbc257f 100644 --- a/core/input/gamepad_device.cpp +++ b/core/input/gamepad_device.cpp @@ -185,7 +185,7 @@ bool GamepadDevice::gamepad_axis_input(u32 code, int value) return false; // Radial dead zone // FIXME compute both axes at the same time - if ((float)(v * v + *other_axis * *other_axis) < _dead_zone * _dead_zone * 128.f * 128.f * 2.f) + if ((float)(v * v + *other_axis * *other_axis) < _dead_zone * _dead_zone * 128.f * 128.f) { *this_axis = 0; *other_axis = 0; @@ -309,7 +309,7 @@ static FILE *get_record_input(bool write) return NULL; if (!write && !cfgLoadBool("record", "replay_input", false)) return NULL; - string game_dir = cfgLoadStr("config", "image", ""); + string game_dir = settings.imgread.ImagePath; size_t slash = game_dir.find_last_of("/"); size_t dot = game_dir.find_last_of("."); string input_file = "scripts/" + game_dir.substr(slash + 1, dot - slash) + "input"; diff --git a/core/nullDC.cpp b/core/nullDC.cpp index df7b3dd90..12496a6cb 100755 --- a/core/nullDC.cpp +++ b/core/nullDC.cpp @@ -344,10 +344,13 @@ void LoadSpecialSettings() } if (!strcmp("DYNAMIC GOLF", naomi_game_id) || !strcmp("SHOOTOUT POOL", naomi_game_id) + || !strcmp("SHOOTOUT POOL MEDAL", naomi_game_id) || !strcmp("OUTTRIGGER JAPAN", naomi_game_id) || !strcmp("CRACKIN'DJ ver JAPAN", naomi_game_id) || !strcmp("CRACKIN'DJ PART2 ver JAPAN", naomi_game_id) - || !strcmp("KICK '4' CASH", naomi_game_id)) + || !strcmp("KICK '4' CASH", naomi_game_id) + || !strcmp("DRIVE", naomi_game_id) // Waiwai drive + || !strcmp("BASS FISHING SIMULATOR VER.A", naomi_game_id)) { INFO_LOG(BOOT, "Enabling JVS rotary encoders for game %s", naomi_game_id); settings.input.JammaSetup = 2; @@ -552,7 +555,9 @@ static int get_game_platform(const char *path) void dc_start_game(const char *path) { if (path != NULL) - cfgSetVirtual("config", "image", path); + strcpy(settings.imgread.ImagePath, path); + else + settings.imgread.ImagePath[0] = 0; dc_init(); @@ -1053,7 +1058,7 @@ static void cleanup_serialize(void *data) static string get_savestate_file_path() { - string state_file = cfgLoadStr("config", "image", "noname.chd"); + string state_file = settings.imgread.ImagePath; size_t lastindex = state_file.find_last_of('/'); #ifdef _WIN32 size_t lastindex2 = state_file.find_last_of('\\'); diff --git a/core/reios/gdrom_hle.cpp b/core/reios/gdrom_hle.cpp index 348f2c33b..4840784d5 100644 --- a/core/reios/gdrom_hle.cpp +++ b/core/reios/gdrom_hle.cpp @@ -15,6 +15,7 @@ #include "hw/gdrom/gdromv3.h" #include "hw/holly/holly_intc.h" #include "reios.h" +#include "imgread/common.h" #ifdef _MSC_VER #undef min @@ -147,6 +148,25 @@ static void GDCC_HLE_GETSCD() { DEBUG_LOG(REIOS, "GDROM: GETSCD format %x size %x dest %08x", format, size, dest); + if (libGDR_GetDiscType() == Open || libGDR_GetDiscType() == NoDisk) + { + gd_hle_state.status = BIOS_ERROR; + gd_hle_state.result[0] = 2; // ? + return; + } + if (sns_asc != 0) + { + // Helps D2 detect the disk change + gd_hle_state.status = BIOS_ERROR; + gd_hle_state.result[0] = sns_key; + gd_hle_state.result[1] = sns_asc; + gd_hle_state.result[1] = 0x18; // ? + gd_hle_state.result[1] = sns_ascq; // ? + sns_key = 0; + sns_asc = 0; + sns_ascq = 0; + return; + } if (cdda.playing) gd_hle_state.cur_sector = cdda.CurrAddr.FAD; u8 scd[100]; @@ -632,27 +652,43 @@ void gdrom_hle_op() break; case GDROM_CHECK_DRIVE: - // Checks the general condition of the drive. - // - // Args: - // r4 = pointer to two 32 bit integers, to receive the drive status. The first is the current drive status, the second is the type of disc inserted (if any). - // 0 Drive is busy - // 1 Drive is paused - // 2 Drive is in standby - // 3 Drive is playing - // 4 Drive is seeking - // 5 Drive is scanning - // 6 Drive lid is open - // 7 Lid is closed, but there is no disc - // - // Returns: zero if successful, nonzero if failure - WriteMem32(r[4] + 0, (gd_hle_state.status == BIOS_DATA_AVAIL || SecNumber.Status == GD_PLAY) ? 3 : 1); - if (memcmp(ip_meta.disk_type, "GD-ROM", sizeof(ip_meta.disk_type)) == 0) - WriteMem32(r[4] + 4, GdRom); - else - WriteMem32(r[4] + 4, libGDR_GetDiscType()); - debugf("GDROM: HLE GDROM_CHECK_DRIVE r4:%X -> %x %x", r[4], ReadMem32(r[4]), ReadMem32(r[4] + 4)); - r[0] = 0; + { + // Checks the general condition of the drive. + // + // Args: + // r4 = pointer to two 32 bit integers, to receive the drive status. The first is the current drive status, the second is the type of disc inserted (if any). + // 0 Drive is busy + // 1 Drive is paused + // 2 Drive is in standby + // 3 Drive is playing + // 4 Drive is seeking + // 5 Drive is scanning + // 6 Drive lid is open + // 7 Lid is closed, but there is no disc + // + // Returns: zero if successful, nonzero if failure + u32 discType = libGDR_GetDiscType(); + switch (discType) + { + case Open: + WriteMem32(r[4], 6); + WriteMem32(r[4] + 4, 0); + break; + case NoDisk: + WriteMem32(r[4], 7); + WriteMem32(r[4] + 4, 0); + break; + default: + WriteMem32(r[4], (gd_hle_state.status == BIOS_DATA_AVAIL || SecNumber.Status == GD_PLAY) ? 3 : 1); + if (memcmp(ip_meta.disk_type, "GD-ROM", sizeof(ip_meta.disk_type)) == 0) + WriteMem32(r[4] + 4, GdRom); + else + WriteMem32(r[4] + 4, discType); + break; + } + debugf("GDROM: HLE GDROM_CHECK_DRIVE r4:%X -> %x %x", r[4], ReadMem32(r[4]), ReadMem32(r[4] + 4)); + r[0] = 0; + } break; case GDROM_ABORT_COMMAND: diff --git a/core/rend/gui.cpp b/core/rend/gui.cpp index b641e4df9..2a65cd896 100644 --- a/core/rend/gui.cpp +++ b/core/rend/gui.cpp @@ -36,7 +36,7 @@ #include "gui_android.h" #include "version.h" #include "oslib/audiostream.h" - +#include "imgread/common.h" extern void dc_loadstate(); extern void dc_savestate(); @@ -300,7 +300,7 @@ static void gui_start_game(const std::string& path) error_msg = ex.reason; gui_state = Main; game_started = false; - cfgSetVirtual("config", "image", ""); + settings.imgread.ImagePath[0] = '\0'; cfgSetVirtual("reios", "ElfFile", ""); } } @@ -348,10 +348,18 @@ static void gui_display_commands() } ImGui::NextColumn(); - if (ImGui::Button("Restart", ImVec2(150 * scaling, 50 * scaling))) + const char *disk_label = libGDR_GetDiscType() == Open ? "Insert Disk" : "Eject Disk"; + if (ImGui::Button(disk_label, ImVec2(150 * scaling, 50 * scaling))) { - gui_state = ClosedNoResume; - gui_start_game(cfgLoadStr("config", "image", "")); + if (libGDR_GetDiscType() == Open) + { + gui_state = SelectDisk; + } + else + { + DiscOpenLid(); + gui_state = Closed; + } } ImGui::NextColumn(); if (ImGui::Button("Exit", ImVec2(150 * scaling, 50 * scaling))) @@ -359,7 +367,7 @@ static void gui_display_commands() // Exit to main menu gui_state = Main; game_started = false; - cfgSetVirtual("config", "image", ""); + settings.imgread.ImagePath[0] = '\0'; } ImGui::End(); @@ -1471,10 +1479,12 @@ static void gui_display_content() ImGui::SameLine(0, 32 * scaling); filter.Draw("Filter"); } - - ImGui::SameLine(ImGui::GetContentRegionAvailWidth() - ImGui::CalcTextSize("Settings").x - ImGui::GetStyle().FramePadding.x * 2.0f /*+ ImGui::GetStyle().ItemSpacing.x*/); - if (ImGui::Button("Settings"))//, ImVec2(0, 30 * scaling))) - gui_state = Settings; + if (gui_state != SelectDisk) + { + ImGui::SameLine(ImGui::GetContentRegionAvailWidth() - ImGui::CalcTextSize("Settings").x - ImGui::GetStyle().FramePadding.x * 2.0f /*+ ImGui::GetStyle().ItemSpacing.x*/); + if (ImGui::Button("Settings"))//, ImVec2(0, 30 * scaling))) + gui_state = Settings; + } ImGui::PopStyleVar(); fetch_game_list(); @@ -1488,22 +1498,44 @@ static void gui_display_content() if (ImGui::Selectable("Dreamcast BIOS")) { gui_state = ClosedNoResume; - cfgSetVirtual("config", "image", ""); + settings.imgread.ImagePath[0] = '\0'; gui_start_game(""); } ImGui::PopID(); - for (auto& game : game_list) + for (const auto& game : game_list) + { + if (gui_state == SelectDisk) + { + std::string::size_type dotpos = game.name.find_last_of('.'); + if (dotpos == std::string::npos || dotpos == game.name.size() - 1) + continue; + std::string extension = game.name.substr(dotpos); + if (stricmp(extension.c_str(), ".gdi") && stricmp(extension.c_str(), ".chd") + && stricmp(extension.c_str(), ".cdi") && stricmp(extension.c_str(), ".cue")) + // Only dreamcast disks + continue; + } if (filter.PassFilter(game.name.c_str())) { ImGui::PushID(game.path.c_str()); if (ImGui::Selectable(game.name.c_str())) { - gui_state = ClosedNoResume; - gui_start_game(game.path); + if (gui_state == SelectDisk) + { + strcpy(settings.imgread.ImagePath, game.path.c_str()); + DiscSwap(0); + gui_state = Closed; + } + else + { + gui_start_game(game.path); + gui_state = ClosedNoResume; + } } ImGui::PopID(); } + } ImGui::PopStyleVar(); } ImGui::EndChild(); @@ -1560,7 +1592,7 @@ void gui_display_ui() case Main: //gui_display_demo(); { - std::string game_file = cfgLoadStr("config", "image", ""); + std::string game_file = settings.imgread.ImagePath; if (!game_file.empty()) { gui_state = ClosedNoResume; @@ -1587,6 +1619,9 @@ void gui_display_ui() gui_display_vjoy_commands(screen_width, screen_height, scaling); #endif break; + case SelectDisk: + gui_display_content(); + break; } if (gui_state == Closed) diff --git a/core/rend/gui.h b/core/rend/gui.h index a40d3c89c..8281611c0 100644 --- a/core/rend/gui.h +++ b/core/rend/gui.h @@ -33,7 +33,7 @@ extern u32 vmu_lcd_data[8][48 * 32]; extern bool vmu_lcd_status[8]; extern bool vmu_lcd_changed[8]; -typedef enum { Closed, Commands, Settings, ClosedNoResume, Main, Onboarding, VJoyEdit, VJoyEditCommands } GuiState; +typedef enum { Closed, Commands, Settings, ClosedNoResume, Main, Onboarding, VJoyEdit, VJoyEditCommands, SelectDisk } GuiState; extern GuiState gui_state; void ImGui_Impl_NewFrame(); diff --git a/core/stdclass.cpp b/core/stdclass.cpp index 0aa618747..bd3facb7c 100644 --- a/core/stdclass.cpp +++ b/core/stdclass.cpp @@ -112,7 +112,7 @@ string get_readonly_data_path(const string& filename) string get_game_save_prefix() { - string save_file = cfgLoadStr("config", "image", ""); + string save_file = settings.imgread.ImagePath; size_t lastindex = save_file.find_last_of('/'); #ifdef _WIN32 size_t lastindex2 = save_file.find_last_of("\\"); @@ -125,7 +125,7 @@ string get_game_save_prefix() string get_game_basename() { - string game_dir = cfgLoadStr("config", "image", ""); + string game_dir = settings.imgread.ImagePath; size_t lastindex = game_dir.find_last_of('.'); if (lastindex != -1) game_dir = game_dir.substr(0, lastindex); @@ -134,7 +134,7 @@ string get_game_basename() string get_game_dir() { - string game_dir = cfgLoadStr("config", "image", ""); + string game_dir = settings.imgread.ImagePath; size_t lastindex = game_dir.find_last_of('/'); #ifdef _WIN32 size_t lastindex2 = game_dir.find_last_of("\\"); diff --git a/core/types.h b/core/types.h index 18da2ae32..cb4fe8a69 100644 --- a/core/types.h +++ b/core/types.h @@ -503,8 +503,7 @@ struct settings_t struct { bool PatchRegion; - bool LoadDefaultImage; - char DefaultImage[512]; + char ImagePath[512]; } imgread; struct