Skip to content

Commit

Permalink
- Add option to disable a memory card slot.
Browse files Browse the repository at this point in the history
  • Loading branch information
Extrems committed Dec 18, 2024
1 parent e5cf58f commit eaae0e2
Show file tree
Hide file tree
Showing 6 changed files with 69 additions and 12 deletions.
3 changes: 2 additions & 1 deletion cube/swiss/include/swiss.h
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,9 @@ typedef struct {
int pauseAVOutput;
int emulateAudioStream;
int emulateReadSpeed;
int emulateMemoryCard;
int emulateEthernet;
int emulateMemoryCard;
int disableMemoryCard;
int preferCleanBoot;
s8 sramHOffset;
u8 sramLanguage;
Expand Down
27 changes: 24 additions & 3 deletions cube/swiss/source/config/config.c
Original file line number Diff line number Diff line change
Expand Up @@ -209,8 +209,9 @@ int config_update_global(bool checkConfigDevice) {
fprintf(fp, "Digital Trigger Level=%hhu\r\n", swissSettings.triggerLevel);
fprintf(fp, "Emulate Audio Streaming=%s\r\n", emulateAudioStreamStr[swissSettings.emulateAudioStream]);
fprintf(fp, "Emulate Read Speed=%s\r\n", emulateReadSpeedStr[swissSettings.emulateReadSpeed]);
fprintf(fp, "Emulate Memory Card=%s\r\n", swissSettings.emulateMemoryCard ? "Yes":"No");
fprintf(fp, "Emulate Broadband Adapter=%s\r\n", swissSettings.emulateEthernet ? "Yes":"No");
fprintf(fp, "Emulate Memory Card=%s\r\n", swissSettings.emulateMemoryCard ? "Yes":"No");
fprintf(fp, "Disable Memory Card=%s\r\n", disableMemoryCardStr[swissSettings.disableMemoryCard]);
fprintf(fp, "Prefer Clean Boot=%s\r\n", swissSettings.preferCleanBoot ? "Yes":"No");
fprintf(fp, "RetroTINK-4K Profile=%i\r\n", swissSettings.rt4kProfile);
fprintf(fp, "#!!Swiss Settings End!!\r\n\r\n");
Expand Down Expand Up @@ -285,6 +286,7 @@ int config_update_game(ConfigEntry* entry, bool checkConfigDevice) {
if(entry->emulateAudioStream != swissSettings.emulateAudioStream) fprintf(fp, "Emulate Audio Streaming=%s\r\n", emulateAudioStreamStr[entry->emulateAudioStream]);
if(entry->emulateReadSpeed != swissSettings.emulateReadSpeed) fprintf(fp, "Emulate Read Speed=%s\r\n", emulateReadSpeedStr[entry->emulateReadSpeed]);
if(entry->emulateEthernet != swissSettings.emulateEthernet) fprintf(fp, "Emulate Broadband Adapter=%s\r\n", entry->emulateEthernet ? "Yes":"No");
if(entry->disableMemoryCard != swissSettings.disableMemoryCard) fprintf(fp, "Disable Memory Card=%s\r\n", disableMemoryCardStr[entry->disableMemoryCard]);
if(entry->preferCleanBoot != swissSettings.preferCleanBoot) fprintf(fp, "Prefer Clean Boot=%s\r\n", entry->preferCleanBoot ? "Yes":"No");
if(entry->rt4kProfile != swissSettings.rt4kProfile) fprintf(fp, "RetroTINK-4K Profile=%i\r\n", entry->rt4kProfile);
fclose(fp);
Expand Down Expand Up @@ -326,6 +328,7 @@ void config_defaults(ConfigEntry *entry) {
entry->emulateAudioStream = swissSettings.emulateAudioStream;
entry->emulateReadSpeed = swissSettings.emulateReadSpeed;
entry->emulateEthernet = swissSettings.emulateEthernet;
entry->disableMemoryCard = swissSettings.disableMemoryCard;
entry->preferCleanBoot = swissSettings.preferCleanBoot;
entry->rt4kProfile = swissSettings.rt4kProfile;

Expand Down Expand Up @@ -737,11 +740,19 @@ void config_parse_global(char *configData) {
}
}
}
else if(!strcmp("Emulate Broadband Adapter", name)) {
swissSettings.emulateEthernet = !strcmp("Yes", value);
}
else if(!strcmp("Emulate Memory Card", name)) {
swissSettings.emulateMemoryCard = !strcmp("Yes", value);
}
else if(!strcmp("Emulate Broadband Adapter", name)) {
swissSettings.emulateEthernet = !strcmp("Yes", value);
else if(!strcmp("Disable Memory Card", name)) {
for(int i = 0; i < 3; i++) {
if(!strcmp(disableMemoryCardStr[i], value)) {
swissSettings.disableMemoryCard = i;
break;
}
}
}
else if(!strcmp("Prefer Clean Boot", name)) {
swissSettings.preferCleanBoot = !strcmp("Yes", value);
Expand Down Expand Up @@ -1102,6 +1113,14 @@ void config_parse_game(char *configData, ConfigEntry *entry) {
else if(!strcmp("Emulate Broadband Adapter", name)) {
entry->emulateEthernet = !strcmp("Yes", value);
}
else if(!strcmp("Disable Memory Card", name)) {
for(int i = 0; i < 3; i++) {
if(!strcmp(disableMemoryCardStr[i], value)) {
entry->disableMemoryCard = i;
break;
}
}
}
else if(!strcmp("Prefer Clean Boot", name)) {
entry->preferCleanBoot = !strcmp("Yes", value);
}
Expand Down Expand Up @@ -1205,6 +1224,7 @@ void config_load_current(ConfigEntry *entry) {
swissSettings.emulateAudioStream = entry->emulateAudioStream;
swissSettings.emulateReadSpeed = entry->emulateReadSpeed;
swissSettings.emulateEthernet = entry->emulateEthernet;
swissSettings.disableMemoryCard = entry->disableMemoryCard;
swissSettings.preferCleanBoot = entry->preferCleanBoot;
swissSettings.rt4kProfile = entry->rt4kProfile;

Expand Down Expand Up @@ -1265,6 +1285,7 @@ void config_unload_current() {
swissSettings.emulateAudioStream = backup.emulateAudioStream;
swissSettings.emulateReadSpeed = backup.emulateReadSpeed;
swissSettings.emulateEthernet = backup.emulateEthernet;
swissSettings.disableMemoryCard = backup.disableMemoryCard;
swissSettings.preferCleanBoot = backup.preferCleanBoot;
swissSettings.sramLanguage = backup.sramLanguage;
swissSettings.sramVideo = backup.sramVideo;
Expand Down
1 change: 1 addition & 0 deletions cube/swiss/source/config/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ typedef struct {
int emulateAudioStream;
int emulateReadSpeed;
int emulateEthernet;
int disableMemoryCard;
int forceCleanBoot;
int preferCleanBoot;
int rt4kProfile;
Expand Down
22 changes: 18 additions & 4 deletions cube/swiss/source/gui/settings.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ char *disableMCPGameIDStr[] = {"No", "Slot A", "Slot B", "Slot A&B"};
char *disableVideoPatchesStr[] = {"None", "Game", "All"};
char *emulateAudioStreamStr[] = {"Off", "Auto", "On"};
char *emulateReadSpeedStr[] = {"No", "Yes", "Wii"};
char *disableMemoryCardStr[] = {"No", "Slot A", "Slot B"};
char *igrTypeStr[] = {"Disabled", "Reboot", "Apploader"};
char *aveCompatStr[] = {"CMPV-DOL", "GCVideo", "AVE-RVL", "AVE N-DOL", "AVE P-DOL"};
char *fileBrowserStr[] = {"Standard", "Fullwidth", "Carousel"};
Expand Down Expand Up @@ -101,6 +102,7 @@ static char *tooltips_game[PAGE_GAME_MAX+1] = {
"Emulate Audio Streaming:\n\nAudio streaming is a hardware feature that allows a compressed\naudio track to be played in the background by the disc drive.\n\nEmulation is necessary for devices not attached to the\nDVD Interface, or for those not implementing it regardless.",
"Emulate Read Speed:\n\nNo - Start transfer immediately (default)\nYes - Delay transfer to simulate the GameCube disc drive\nWii - Delay transfer to simulate the Wii disc drive\n\nThis is necessary to avoid programming mistakes obfuscated\nby the original medium, or for speedrunning.",
"Emulate Broadband Adapter:\n\nOnly available with the File Service Protocol or an initialised\nETH2GC/GCNET module, where memory constraints permit.\n\nPackets not destined for the hypervisor are forwarded to\nthe virtual MAC. The virtual MAC address is the same as\nthe physical MAC. The physical MAC/PHY retain their\nconfiguration from Swiss, including link speed.",
"Disable Memory Card:\n\nSome games misbehave when unexpected devices are present\nin the memory card slots. When selected, the device will be\nhidden from the game if present at boot time.",
"Prefer Clean Boot:\n\nWhen enabled, the GameCube will be reset and the game\nbooted through normal processes with no changes applied.\nRegion restrictions may be applicable.\n\nOnly available to devices attached to the DVD Interface.",
"RetroTINK-4K Profile:\n\nPresses a profile button through a configured ser2net TCP\nconnection to the RetroTINK-4K's serial port."
};
Expand Down Expand Up @@ -285,9 +287,9 @@ uiDrawObj_t* settings_draw_page(int page_num, int option, ConfigEntry *gameConfi
drawSettingEntryString(page, &page_y_ofs, "Boot through IPL:", bs2BootStr[swissSettings.bs2Boot], option == SET_BS2BOOT, true);
drawSettingEntryBoolean(page, &page_y_ofs, "Boot without prompts:", swissSettings.autoBoot, option == SET_AUTOBOOT, true);
drawSettingEntryBoolean(page, &page_y_ofs, "Emulate Memory Card:", swissSettings.emulateMemoryCard, option == SET_EMULATE_MEMCARD, emulatedMemoryCard);
drawSettingEntryString(page, &page_y_ofs, "Disable MemCard PRO GameID:", disableMCPGameIDStr[swissSettings.disableMCPGameID], option == SET_ENABLE_MCPGAMEID, true);
drawSettingEntryString(page, &page_y_ofs, "Disable MemCard PRO GameID:", disableMCPGameIDStr[swissSettings.disableMCPGameID], option == SET_DISABLE_MCPGAMEID, true);
drawSettingEntryBoolean(page, &page_y_ofs, "Force Video Active:", swissSettings.forceVideoActive, option == SET_FORCE_VIDACTIVE, enabledVideoPatches);
drawSettingEntryString(page, &page_y_ofs, "Disable Video Patches:", disableVideoPatchesStr[swissSettings.disableVideoPatches], option == SET_ENABLE_VIDPATCH, true);
drawSettingEntryString(page, &page_y_ofs, "Disable Video Patches:", disableVideoPatchesStr[swissSettings.disableVideoPatches], option == SET_DISABLE_VIDPATCH, true);
drawSettingEntryBoolean(page, &page_y_ofs, "Pause for resolution change:", swissSettings.pauseAVOutput, option == SET_PAUSE_AVOUTPUT, true);
drawSettingEntryBoolean(page, &page_y_ofs, "Auto-load cheats:", swissSettings.autoCheats, option == SET_ALL_CHEATS, true);
drawSettingEntryBoolean(page, &page_y_ofs, "WiiRD debugging:", swissSettings.wiirdDebug, option == SET_WIIRDDBG, dbgEnable);
Expand Down Expand Up @@ -324,6 +326,7 @@ uiDrawObj_t* settings_draw_page(int page_num, int option, ConfigEntry *gameConfi
drawSettingEntryString(page, &page_y_ofs, "Emulate Audio Streaming:", emulateAudioStreamStr[swissSettings.emulateAudioStream], option == SET_DEFAULT_AUDIO_STREAM, emulatedAudioStream);
drawSettingEntryString(page, &page_y_ofs, "Emulate Read Speed:", emulateReadSpeedStr[swissSettings.emulateReadSpeed], option == SET_DEFAULT_READ_SPEED, emulatedReadSpeed);
drawSettingEntryBoolean(page, &page_y_ofs, "Emulate Broadband Adapter:", swissSettings.emulateEthernet, option == SET_DEFAULT_EMULATE_ETHERNET, emulatedEthernet);
drawSettingEntryString(page, &page_y_ofs, "Disable Memory Card:", disableMemoryCardStr[swissSettings.disableMemoryCard], option == SET_DEFAULT_DISABLE_MEMCARD, true);
drawSettingEntryBoolean(page, &page_y_ofs, "Prefer Clean Boot:", swissSettings.preferCleanBoot, option == SET_DEFAULT_CLEAN_BOOT, enabledCleanBoot);
drawSettingEntryNumeric(page, &page_y_ofs, "RetroTINK-4K Profile:", swissSettings.rt4kProfile, option == SET_DEFAULT_RT4K_PROFILE, rt4kEnable);
drawSettingEntryString(page, &page_y_ofs, "Reset to defaults", NULL, option == SET_DEFAULT_DEFAULTS, true);
Expand Down Expand Up @@ -362,6 +365,7 @@ uiDrawObj_t* settings_draw_page(int page_num, int option, ConfigEntry *gameConfi
drawSettingEntryString(page, &page_y_ofs, "Emulate Audio Streaming:", emulateAudioStreamStr[gameConfig->emulateAudioStream], option == SET_AUDIO_STREAM, emulatedAudioStream);
drawSettingEntryString(page, &page_y_ofs, "Emulate Read Speed:", emulateReadSpeedStr[gameConfig->emulateReadSpeed], option == SET_READ_SPEED, emulatedReadSpeed);
drawSettingEntryBoolean(page, &page_y_ofs, "Emulate Broadband Adapter:", gameConfig->emulateEthernet, option == SET_EMULATE_ETHERNET, emulatedEthernet);
drawSettingEntryString(page, &page_y_ofs, "Disable Memory Card:", disableMemoryCardStr[gameConfig->disableMemoryCard], option == SET_DISABLE_MEMCARD, true);
drawSettingEntryBoolean(page, &page_y_ofs, "Prefer Clean Boot:", gameConfig->preferCleanBoot, option == SET_CLEAN_BOOT, enabledCleanBoot);
drawSettingEntryNumeric(page, &page_y_ofs, "RetroTINK-4K Profile:", gameConfig->rt4kProfile, option == SET_RT4K_PROFILE, rt4kEnable);
drawSettingEntryString(page, &page_y_ofs, "Reset to defaults", NULL, option == SET_DEFAULTS, true);
Expand All @@ -388,6 +392,7 @@ uiDrawObj_t* settings_draw_page(int page_num, int option, ConfigEntry *gameConfi
drawSettingEntryString(page, &page_y_ofs, "Emulate Audio Streaming:", emulateAudioStreamStr[swissSettings.emulateAudioStream], option == SET_AUDIO_STREAM, false);
drawSettingEntryString(page, &page_y_ofs, "Emulate Read Speed:", emulateReadSpeedStr[swissSettings.emulateReadSpeed], option == SET_READ_SPEED, false);
drawSettingEntryBoolean(page, &page_y_ofs, "Emulate Broadband Adapter:", swissSettings.emulateEthernet, option == SET_EMULATE_ETHERNET, false);
drawSettingEntryString(page, &page_y_ofs, "Disable Memory Card:", disableMemoryCardStr[swissSettings.disableMemoryCard], option == SET_DISABLE_MEMCARD, false);
drawSettingEntryBoolean(page, &page_y_ofs, "Prefer Clean Boot:", swissSettings.preferCleanBoot, option == SET_CLEAN_BOOT, false);
drawSettingEntryNumeric(page, &page_y_ofs, "RetroTINK-4K Profile:", swissSettings.rt4kProfile, option == SET_DEFAULT_RT4K_PROFILE, false);
drawSettingEntryString(page, &page_y_ofs, "Reset to defaults", NULL, option == SET_DEFAULTS, false);
Expand Down Expand Up @@ -603,15 +608,15 @@ void settings_toggle(int page, int option, int direction, ConfigEntry *gameConfi
if(devices[DEVICE_CUR] == NULL || (devices[DEVICE_CUR]->emulable & EMU_MEMCARD))
swissSettings.emulateMemoryCard ^= 1;
break;
case SET_ENABLE_MCPGAMEID:
case SET_DISABLE_MCPGAMEID:
swissSettings.disableMCPGameID += direction;
swissSettings.disableMCPGameID = (swissSettings.disableMCPGameID + 4) % 4;
break;
case SET_FORCE_VIDACTIVE:
if(swissSettings.disableVideoPatches < 2)
swissSettings.forceVideoActive ^= 1;
break;
case SET_ENABLE_VIDPATCH:
case SET_DISABLE_VIDPATCH:
swissSettings.disableVideoPatches += direction;
swissSettings.disableVideoPatches = (swissSettings.disableVideoPatches + 3) % 3;
break;
Expand Down Expand Up @@ -726,6 +731,10 @@ void settings_toggle(int page, int option, int direction, ConfigEntry *gameConfi
if(devices[DEVICE_CUR] == NULL || (devices[DEVICE_CUR]->emulable & EMU_ETHERNET))
swissSettings.emulateEthernet ^= 1;
break;
case SET_DEFAULT_DISABLE_MEMCARD:
swissSettings.disableMemoryCard += direction;
swissSettings.disableMemoryCard = (swissSettings.disableMemoryCard + 3) % 3;
break;
case SET_DEFAULT_CLEAN_BOOT:
if(devices[DEVICE_CUR] == NULL || (devices[DEVICE_CUR]->location & LOC_DVD_CONNECTOR))
swissSettings.preferCleanBoot ^= 1;
Expand Down Expand Up @@ -753,6 +762,7 @@ void settings_toggle(int page, int option, int direction, ConfigEntry *gameConfi
swissSettings.emulateAudioStream = 1;
swissSettings.emulateReadSpeed = 0;
swissSettings.emulateEthernet = 0;
swissSettings.disableMemoryCard = 0;
swissSettings.preferCleanBoot = 0;
swissSettings.rt4kProfile = 0;
}
Expand Down Expand Up @@ -844,6 +854,10 @@ void settings_toggle(int page, int option, int direction, ConfigEntry *gameConfi
if(devices[DEVICE_CUR] == NULL || (devices[DEVICE_CUR]->emulable & EMU_ETHERNET))
gameConfig->emulateEthernet ^= 1;
break;
case SET_DISABLE_MEMCARD:
gameConfig->disableMemoryCard += direction;
gameConfig->disableMemoryCard = (gameConfig->disableMemoryCard + 3) % 3;
break;
case SET_CLEAN_BOOT:
if(devices[DEVICE_CUR] == NULL || (devices[DEVICE_CUR]->location & LOC_DVD_CONNECTOR))
gameConfig->preferCleanBoot ^= 1;
Expand Down
7 changes: 5 additions & 2 deletions cube/swiss/source/gui/settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,9 @@ enum SETTINGS_GAME_GLOBAL {
SET_BS2BOOT,
SET_AUTOBOOT,
SET_EMULATE_MEMCARD,
SET_ENABLE_MCPGAMEID,
SET_DISABLE_MCPGAMEID,
SET_FORCE_VIDACTIVE,
SET_ENABLE_VIDPATCH,
SET_DISABLE_VIDPATCH,
SET_PAUSE_AVOUTPUT,
SET_ALL_CHEATS,
SET_WIIRDDBG,
Expand Down Expand Up @@ -107,6 +107,7 @@ enum SETTINGS_GAME_DEFAULTS {
SET_DEFAULT_AUDIO_STREAM,
SET_DEFAULT_READ_SPEED,
SET_DEFAULT_EMULATE_ETHERNET,
SET_DEFAULT_DISABLE_MEMCARD,
SET_DEFAULT_CLEAN_BOOT,
SET_DEFAULT_RT4K_PROFILE,
SET_DEFAULT_DEFAULTS,
Expand All @@ -133,6 +134,7 @@ enum SETTINGS_GAME {
SET_AUDIO_STREAM,
SET_READ_SPEED,
SET_EMULATE_ETHERNET,
SET_DISABLE_MEMCARD,
SET_CLEAN_BOOT,
SET_RT4K_PROFILE,
SET_DEFAULTS,
Expand All @@ -155,6 +157,7 @@ extern char *disableMCPGameIDStr[];
extern char *disableVideoPatchesStr[];
extern char *emulateAudioStreamStr[];
extern char *emulateReadSpeedStr[];
extern char *disableMemoryCardStr[];
extern char *igrTypeStr[];
extern char *aveCompatStr[];
extern char *fileBrowserStr[];
Expand Down
21 changes: 19 additions & 2 deletions cube/swiss/source/swiss.c
Original file line number Diff line number Diff line change
Expand Up @@ -2130,13 +2130,30 @@ void load_game() {
fileToPatch->type = PATCH_BS2;
}

s32 exi_channel = EXI_CHANNEL_MAX;
s32 exi_device = EXI_DEVICE_MAX;
switch(swissSettings.disableMemoryCard) {
case 1:
if(EXI_Probe(EXI_CHANNEL_0)) {
exi_channel = EXI_CHANNEL_0;
exi_device = EXI_DEVICE_0;
}
break;
case 2:
if(EXI_Probe(EXI_CHANNEL_1)) {
exi_channel = EXI_CHANNEL_1;
exi_device = EXI_DEVICE_0;
}
break;
}

*(vu8*)VAR_CURRENT_DISC = disc2File && disc2File == fileToPatch->file;
*(vu8*)VAR_SECOND_DISC = !!disc2File;
*(vu8*)VAR_DRIVE_PATCHED = drive_status == DEBUG_MODE;
*(vu8*)VAR_EMU_READ_SPEED = swissSettings.emulateReadSpeed;
*(vu32**)VAR_EXI_REGS = NULL;
*(vu8*)VAR_EXI_SLOT = (EXI_DEVICE_MAX << 6) | (EXI_CHANNEL_MAX << 4) | (EXI_DEVICE_MAX << 2) | EXI_CHANNEL_MAX;
*(vu8*)VAR_EXI_CPR = (EXI_CHANNEL_MAX << 6) | EXI_SPEED1MHZ;
*(vu8*)VAR_EXI_SLOT = (exi_device << 6) | (exi_channel << 4) | (exi_device << 2) | exi_channel;
*(vu8*)VAR_EXI_CPR = (exi_channel << 6) | EXI_SPEED1MHZ;
*(vu8*)VAR_SD_SHIFT = 0;
*(vu8*)VAR_IGR_TYPE = swissSettings.igrType | (tgcFile.magic == TGC_MAGIC ? 0x80:0x00);
*(vu32**)VAR_FRAG_LIST = NULL;
Expand Down

0 comments on commit eaae0e2

Please sign in to comment.