Skip to content

Commit

Permalink
- Move some game settings logic around.
Browse files Browse the repository at this point in the history
  • Loading branch information
Extrems committed Aug 19, 2024
1 parent 869f452 commit 8b88506
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 60 deletions.
72 changes: 55 additions & 17 deletions cube/swiss/source/config/config.c
Original file line number Diff line number Diff line change
Expand Up @@ -1152,27 +1152,65 @@ int config_init(void (*progress_indicator)(char*, int, int)) {
}

SwissSettings backup;
static char gameVModePalEntries[][4] = {"DLSP", "G3FD", "G3FF", "G3FP", "G3FS", "GLRD", "GLRF", "GLRP", "GM8P", "GSWD", "GSWF", "GSWI", "GSWP", "GSWS"};

void config_load_current(ConfigEntry *config) {
void config_load_current(ConfigEntry *entry) {
wait_network();
// load settings for this game to current settings
memcpy(&backup, &swissSettings, sizeof(SwissSettings));
swissSettings.gameVMode = config->gameVMode;
swissSettings.forceHScale = config->forceHScale;
swissSettings.forceVOffset = config->forceVOffset;
swissSettings.forceVFilter = config->forceVFilter;
swissSettings.forceVJitter = config->forceVJitter;
swissSettings.disableDithering = config->disableDithering;
swissSettings.forceAnisotropy = config->forceAnisotropy;
swissSettings.forceWidescreen = config->forceWidescreen;
swissSettings.forcePollRate = config->forcePollRate;
swissSettings.invertCStick = config->invertCStick;
swissSettings.swapCStick = config->swapCStick;
swissSettings.triggerLevel = config->triggerLevel;
swissSettings.emulateAudioStream = config->emulateAudioStream;
swissSettings.emulateReadSpeed = config->emulateReadSpeed;
swissSettings.emulateEthernet = config->emulateEthernet;
swissSettings.preferCleanBoot = config->preferCleanBoot;
swissSettings.gameVMode = entry->gameVMode;
swissSettings.forceHScale = entry->forceHScale;
swissSettings.forceVOffset = entry->forceVOffset;
swissSettings.forceVFilter = entry->forceVFilter;
swissSettings.forceVJitter = entry->forceVJitter;
swissSettings.disableDithering = entry->disableDithering;
swissSettings.forceAnisotropy = entry->forceAnisotropy;
swissSettings.forceWidescreen = entry->forceWidescreen;
swissSettings.fontEncode = entry->region == 'J';
swissSettings.forcePollRate = entry->forcePollRate;
swissSettings.invertCStick = entry->invertCStick;
swissSettings.swapCStick = entry->swapCStick;
swissSettings.triggerLevel = entry->triggerLevel;
swissSettings.emulateAudioStream = entry->emulateAudioStream;
swissSettings.emulateReadSpeed = entry->emulateReadSpeed;
swissSettings.emulateEthernet = entry->emulateEthernet;
swissSettings.preferCleanBoot = entry->preferCleanBoot;

if(entry->region != 'P')
swissSettings.sramLanguage = SYS_LANG_ENGLISH;

if(entry->region == 'P')
swissSettings.sramVideo = SYS_VIDEO_PAL;
else if(swissSettings.sramVideo == SYS_VIDEO_PAL)
swissSettings.sramVideo = SYS_VIDEO_NTSC;

if(swissSettings.gameVMode > 0 && swissSettings.disableVideoPatches < 2) {
swissSettings.sram60Hz = in_range(swissSettings.gameVMode, 1, 7);
swissSettings.sramProgressive = in_range(swissSettings.gameVMode, 4, 7) || in_range(swissSettings.gameVMode, 11, 14);

if(swissSettings.sram60Hz) {
for(int i = 0; i < sizeof(gameVModePalEntries) / sizeof(*gameVModePalEntries); i++) {
if(!strncmp(entry->game_id, gameVModePalEntries[i], 4)) {
swissSettings.gameVMode += 7;
break;
}
}
}
if(swissSettings.sramProgressive && !getDTVStatus())
swissSettings.gameVMode = 0;
if(swissSettings.sramVideo == SYS_VIDEO_PAL && !swissSettings.sram60Hz)
swissSettings.sramProgressive = 0;
} else if(swissSettings.sramProgressive) {
if(swissSettings.sramVideo == SYS_VIDEO_PAL) {
swissSettings.sramProgressive = 0;
swissSettings.gameVMode = -2;
} else
swissSettings.gameVMode = -1;
} else
swissSettings.gameVMode = 0;

if(!strncmp(entry->game_id, "GB3E", 4))
swissSettings.sramProgressive = 0;
}

void config_unload_current() {
Expand Down
3 changes: 2 additions & 1 deletion cube/swiss/source/config/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ typedef struct {
char game_name[64 + 1];
char comment[128 + 1];
char status[32 + 1];
char region;
int gameVMode;
int forceHScale;
short forceVOffset;
Expand All @@ -33,7 +34,7 @@ int config_update_global(bool checkConfigDevice);
int config_update_recent(bool checkConfigDevice);
int config_init(void (*progress_indicator)(char*, int, int));
void config_parse_args(int argc, char *argv[]);
void config_load_current(ConfigEntry *config);
void config_load_current(ConfigEntry *entry);
void config_unload_current();

#endif
Expand Down
43 changes: 1 addition & 42 deletions cube/swiss/source/swiss.c
Original file line number Diff line number Diff line change
Expand Up @@ -73,51 +73,9 @@ int needsRefresh = 0;
int current_view_start = 0;
int current_view_end = 0;

char *DiscIDNoNTSC[] = {"DLSP64", "G3FD69", "G3FF69", "G3FP69", "G3FS69", "GLRD64", "GLRF64", "GLRP64", "GM8P01", "GSWD64", "GSWF64", "GSWI64", "GSWP64", "GSWS64"};

/* re-init video for a given game */
void ogc_video__reset()
{
char* gameID = (char*)&GCMDisk;
char region = wodeRegionToChar(GCMDisk.RegionCode);
int i;

swissSettings.fontEncode = region == 'J';
if(region != 'P')
swissSettings.sramLanguage = SYS_LANG_ENGLISH;
if(region == 'P')
swissSettings.sramVideo = SYS_VIDEO_PAL;
else if(swissSettings.sramVideo == SYS_VIDEO_PAL)
swissSettings.sramVideo = SYS_VIDEO_NTSC;

if(swissSettings.gameVMode > 0 && swissSettings.disableVideoPatches < 2) {
swissSettings.sram60Hz = in_range(swissSettings.gameVMode, 1, 7);
swissSettings.sramProgressive = in_range(swissSettings.gameVMode, 4, 7) || in_range(swissSettings.gameVMode, 11, 14);

if(swissSettings.sram60Hz) {
for(i = 0; i < sizeof(DiscIDNoNTSC)/sizeof(char*); i++) {
if(!strncmp(gameID, DiscIDNoNTSC[i], 6)) {
swissSettings.gameVMode += 7;
break;
}
}
}
if(swissSettings.sramProgressive && !getDTVStatus())
swissSettings.gameVMode = 0;
if(swissSettings.sramVideo == SYS_VIDEO_PAL && !swissSettings.sram60Hz)
swissSettings.sramProgressive = 0;
} else if(swissSettings.sramProgressive) {
if(swissSettings.sramVideo == SYS_VIDEO_PAL) {
swissSettings.sramProgressive = 0;
swissSettings.gameVMode = -2;
} else
swissSettings.gameVMode = -1;
} else
swissSettings.gameVMode = 0;

if(!strncmp(gameID, "GB3E51", 6))
swissSettings.sramProgressive = 0;

/* set TV mode for current game */
switch(swissSettings.gameVMode) {
case -2:
Expand Down Expand Up @@ -2029,6 +1987,7 @@ void load_game() {
ConfigEntry *config = calloc(1, sizeof(ConfigEntry));
memcpy(config->game_id, &GCMDisk.ConsoleID, 4);
memcpy(config->game_name, GCMDisk.GameName, 64);
config->region = wodeRegionToChar(GCMDisk.RegionCode);
config->forceCleanBoot = is_diag_disc(&GCMDisk);
config_find(config);

Expand Down

0 comments on commit 8b88506

Please sign in to comment.