Merge pull request #73 from retro-wertz/libretro_cleanup

Libretro cleanup and MBC3 RTC update
This commit is contained in:
hizzlekizzle 2019-08-10 08:33:02 -05:00 committed by GitHub
commit 36f3a739ed
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 405 additions and 360 deletions

View File

@ -195,6 +195,7 @@ int gbSynchronizeTicks = GBSYNCHRONIZE_CLOCK_TICKS;
// emulator features // emulator features
int gbBattery = 0; int gbBattery = 0;
int gbRumble = 0; int gbRumble = 0;
int gbRTCPresent = 0;
bool gbBatteryError = false; bool gbBatteryError = false;
int gbCaptureNumber = 0; int gbCaptureNumber = 0;
bool gbCapture = false; bool gbCapture = false;
@ -4360,8 +4361,6 @@ bool gbUpdateSizes()
memset(gbRam, gbRamFill, gbRamSize); memset(gbRam, gbRamFill, gbRamSize);
} }
gbBattery = gbRumble = 0;
switch (gbRomType) { switch (gbRomType) {
case 0x03: case 0x03:
case 0x06: case 0x06:
@ -4377,6 +4376,9 @@ bool gbUpdateSizes()
case 0xff: case 0xff:
gbBattery = 1; gbBattery = 1;
break; break;
default:
gbBattery = 0;
break;
} }
switch (gbRomType) { switch (gbRomType) {
@ -4384,6 +4386,21 @@ bool gbUpdateSizes()
case 0x1d: case 0x1d:
case 0x1e: case 0x1e:
gbRumble = 1; gbRumble = 1;
break;
default:
gbRumble = 0;
break;
}
switch (gbRomType) {
case 0x0f:
case 0x10: // mbc3
case 0xfd: // tama5
gbRTCPresent = 1;
break;
default:
gbRTCPresent = 0;
break;
} }
gbInit(); gbInit();

View File

@ -62,6 +62,7 @@ bool allowColorizerHack(void);
extern int gbHardware; extern int gbHardware;
extern int gbRomType; // gets type from header 0x147 extern int gbRomType; // gets type from header 0x147
extern int gbBattery; // enabled when gbRamSize != 0 extern int gbBattery; // enabled when gbRamSize != 0
extern int gbRTCPresent; // gbROM has RTC support
extern struct EmulatedSystem GBSystem; extern struct EmulatedSystem GBSystem;

View File

@ -389,7 +389,7 @@ void mapperMBC3ROM(uint16_t address, uint8_t value)
gbDataMBC3.mapperRAMBank = value; gbDataMBC3.mapperRAMBank = value;
gbDataMBC3.mapperRAMAddress = tmpAddress; gbDataMBC3.mapperRAMAddress = tmpAddress;
} else { } else {
if (gbDataMBC3.mapperRAMEnable) { if (gbRTCPresent && gbDataMBC3.mapperRAMEnable) {
gbDataMBC3.mapperRAMBank = -1; gbDataMBC3.mapperRAMBank = -1;
gbDataMBC3.mapperClockRegister = value; gbDataMBC3.mapperClockRegister = value;
@ -397,16 +397,18 @@ void mapperMBC3ROM(uint16_t address, uint8_t value)
} }
break; break;
case 0x6000: // clock latch case 0x6000: // clock latch
if (gbDataMBC3.mapperClockLatch == 0 && value == 1) { if (gbRTCPresent) {
memoryUpdateMBC3Clock(); if (gbDataMBC3.mapperClockLatch == 0 && value == 1) {
gbDataMBC3.mapperLSeconds = gbDataMBC3.mapperSeconds; memoryUpdateMBC3Clock();
gbDataMBC3.mapperLMinutes = gbDataMBC3.mapperMinutes; gbDataMBC3.mapperLSeconds = gbDataMBC3.mapperSeconds;
gbDataMBC3.mapperLHours = gbDataMBC3.mapperHours; gbDataMBC3.mapperLMinutes = gbDataMBC3.mapperMinutes;
gbDataMBC3.mapperLDays = gbDataMBC3.mapperDays; gbDataMBC3.mapperLHours = gbDataMBC3.mapperHours;
gbDataMBC3.mapperLControl = gbDataMBC3.mapperControl; gbDataMBC3.mapperLDays = gbDataMBC3.mapperDays;
gbDataMBC3.mapperLControl = gbDataMBC3.mapperControl;
}
if (value == 0x00 || value == 0x01)
gbDataMBC3.mapperClockLatch = value;
} }
if (value == 0x00 || value == 0x01)
gbDataMBC3.mapperClockLatch = value;
break; break;
} }
} }
@ -415,12 +417,12 @@ void mapperMBC3ROM(uint16_t address, uint8_t value)
void mapperMBC3RAM(uint16_t address, uint8_t value) void mapperMBC3RAM(uint16_t address, uint8_t value)
{ {
if (gbDataMBC3.mapperRAMEnable) { if (gbDataMBC3.mapperRAMEnable) {
if (gbDataMBC3.mapperRAMBank != -1) { if (gbDataMBC3.mapperRAMBank >= 0) {
if (gbRamSize) { if (gbRamSize) {
gbMemoryMap[address >> 12][address & 0x0fff] = value; gbMemoryMap[address >> 12][address & 0x0fff] = value;
systemSaveUpdateCounter = SYSTEM_SAVE_UPDATED; systemSaveUpdateCounter = SYSTEM_SAVE_UPDATED;
} }
} else { } else if (gbRTCPresent) {
time(&gbDataMBC3.mapperLastTime); time(&gbDataMBC3.mapperLastTime);
switch (gbDataMBC3.mapperClockRegister) { switch (gbDataMBC3.mapperClockRegister) {
case 0x08: case 0x08:
@ -450,25 +452,25 @@ void mapperMBC3RAM(uint16_t address, uint8_t value)
uint8_t mapperMBC3ReadRAM(uint16_t address) uint8_t mapperMBC3ReadRAM(uint16_t address)
{ {
if (gbDataMBC3.mapperRAMEnable) { if (gbDataMBC3.mapperRAMEnable) {
if (gbDataMBC3.mapperRAMBank != -1) { if (gbDataMBC3.mapperRAMBank >= 0) {
return gbMemoryMap[address >> 12][address & 0x0fff]; return gbMemoryMap[address >> 12][address & 0x0fff];
} } else if (gbRTCPresent) {
switch (gbDataMBC3.mapperClockRegister) {
switch (gbDataMBC3.mapperClockRegister) { case 0x08:
case 0x08: return gbDataMBC3.mapperLSeconds;
return gbDataMBC3.mapperLSeconds; break;
break; case 0x09:
case 0x09: return gbDataMBC3.mapperLMinutes;
return gbDataMBC3.mapperLMinutes; break;
break; case 0x0a:
case 0x0a: return gbDataMBC3.mapperLHours;
return gbDataMBC3.mapperLHours; break;
break; case 0x0b:
case 0x0b: return gbDataMBC3.mapperLDays;
return gbDataMBC3.mapperLDays; break;
break; case 0x0c:
case 0x0c: return gbDataMBC3.mapperLControl;
return gbDataMBC3.mapperLControl; }
} }
} }

File diff suppressed because it is too large Load Diff

View File

@ -29,7 +29,7 @@ extern "C" {
struct retro_core_option_definition option_defs_us[] = { struct retro_core_option_definition option_defs_us[] = {
{ {
"vbam_solarsensor", "vbam_solarsensor",
"Solar sensor level", "Solar Sensor Level",
"Adjusts simulated solar level in Boktai games. L2/R2 buttons can also be used to quickly change levels.", "Adjusts simulated solar level in Boktai games. L2/R2 buttons can also be used to quickly change levels.",
{ {
{ "0", NULL }, { "0", NULL },
@ -49,7 +49,7 @@ struct retro_core_option_definition option_defs_us[] = {
}, },
{ {
"vbam_usebios", "vbam_usebios",
"Use BIOS file if available (Restart)", "Use Official BIOS (If Available)",
"Use official BIOS when available. Core needs to be restarted for changes to apply.", "Use official BIOS when available. Core needs to be restarted for changes to apply.",
{ {
{ "disabled", NULL }, { "disabled", NULL },
@ -60,7 +60,7 @@ struct retro_core_option_definition option_defs_us[] = {
}, },
{ {
"vbam_forceRTCenable", "vbam_forceRTCenable",
"Force enable RTC", "Force-Enable RTC",
"Forces the internal real-time clock to be enabled regardless of rom. Usuable for rom patches that requires clock to be enabled (aka Pokemon).", "Forces the internal real-time clock to be enabled regardless of rom. Usuable for rom patches that requires clock to be enabled (aka Pokemon).",
{ {
{ "disabled", NULL }, { "disabled", NULL },
@ -103,7 +103,7 @@ struct retro_core_option_definition option_defs_us[] = {
{ {
"vbam_palettes", "vbam_palettes",
"(GB) Color Palette", "(GB) Color Palette",
"Set Game Boy palettes.", "Set Game Boy palettes to use.",
{ {
{ "black and white", NULL }, { "black and white", NULL },
{ "blue sea", NULL }, { "blue sea", NULL },
@ -120,7 +120,7 @@ struct retro_core_option_definition option_defs_us[] = {
}, },
{ {
"vbam_gbHardware", "vbam_gbHardware",
"(GB) Emulated Hardware", "(GB) Emulated Hardware (Needs Restart)",
"Sets the Game Boy hardware type to emulate. Restart core to apply.", "Sets the Game Boy hardware type to emulate. Restart core to apply.",
{ {
{ "gbc", "Game Boy Color" }, { "gbc", "Game Boy Color" },
@ -293,9 +293,20 @@ struct retro_core_option_definition option_defs_us[] = {
}, },
"disabled" "disabled"
}, },
{
"vbam_show_advanced_options",
"Show Advanced Options",
"Show advanced options which can enable or disable sound channels and graphics layers.",
{
{ "disabled", NULL },
{ "enabled", NULL },
{ NULL, NULL },
},
"disabled"
},
{ {
"vbam_sound_1", "vbam_sound_1",
"Sound channel 1", "Sound Channel 1",
"Enables or disables tone & sweep sound channel.", "Enables or disables tone & sweep sound channel.",
{ {
{ "disabled", NULL }, { "disabled", NULL },
@ -304,9 +315,9 @@ struct retro_core_option_definition option_defs_us[] = {
}, },
"enabled" "enabled"
}, },
{ {
"vbam_sound_2", "vbam_sound_2",
"Sound channel 2", "Sound Channel 2",
"Enables or disables tone sound channel.", "Enables or disables tone sound channel.",
{ {
{ "disabled", NULL }, { "disabled", NULL },
@ -317,7 +328,7 @@ struct retro_core_option_definition option_defs_us[] = {
}, },
{ {
"vbam_sound_3", "vbam_sound_3",
"Sound channel 3", "Sound Channel 3",
"Enables or disables wave output sound channel.", "Enables or disables wave output sound channel.",
{ {
{ "disabled", NULL }, { "disabled", NULL },
@ -328,7 +339,7 @@ struct retro_core_option_definition option_defs_us[] = {
}, },
{ {
"vbam_sound_4", "vbam_sound_4",
"Sound channel 4", "Sound Channel 4",
"Enables or disables noise audio channel.", "Enables or disables noise audio channel.",
{ {
{ "disabled", NULL }, { "disabled", NULL },
@ -339,7 +350,7 @@ struct retro_core_option_definition option_defs_us[] = {
}, },
{ {
"vbam_sound_5", "vbam_sound_5",
"Sound DMA channel A", "Sound DMA Channel A",
"Enables or disables DMA sound channel A.", "Enables or disables DMA sound channel A.",
{ {
{ "disabled", NULL }, { "disabled", NULL },
@ -350,7 +361,7 @@ struct retro_core_option_definition option_defs_us[] = {
}, },
{ {
"vbam_sound_6", "vbam_sound_6",
"Sound DMA channel B", "Sound DMA Channel B",
"Enables or disables DMA sound channel B.", "Enables or disables DMA sound channel B.",
{ {
{ "disabled", NULL }, { "disabled", NULL },
@ -361,7 +372,7 @@ struct retro_core_option_definition option_defs_us[] = {
}, },
{ {
"vbam_layer_1", "vbam_layer_1",
"Show background layer 1", "Show Background Layer 1",
"Shows or hides background layer 1.", "Shows or hides background layer 1.",
{ {
{ "disabled", NULL }, { "disabled", NULL },
@ -372,7 +383,7 @@ struct retro_core_option_definition option_defs_us[] = {
}, },
{ {
"vbam_layer_2", "vbam_layer_2",
"Show background layer 2", "Show Background Layer 2",
"Shows or hides background layer 2.", "Shows or hides background layer 2.",
{ {
{ "disabled", NULL }, { "disabled", NULL },
@ -383,7 +394,7 @@ struct retro_core_option_definition option_defs_us[] = {
}, },
{ {
"vbam_layer_3", "vbam_layer_3",
"Show background layer 3", "Show Background Layer 3",
"Shows or hides background layer 3.", "Shows or hides background layer 3.",
{ {
{ "disabled", NULL }, { "disabled", NULL },
@ -394,7 +405,7 @@ struct retro_core_option_definition option_defs_us[] = {
}, },
{ {
"vbam_layer_4", "vbam_layer_4",
"Show background layer 4", "Show Background Layer 4",
"Shows or hides background layer 4.", "Shows or hides background layer 4.",
{ {
{ "disabled", NULL }, { "disabled", NULL },
@ -405,7 +416,7 @@ struct retro_core_option_definition option_defs_us[] = {
}, },
{ {
"vbam_layer_5", "vbam_layer_5",
"Show sprite layer", "Show Sprite Layer",
"Shows or hides sprite layer.", "Shows or hides sprite layer.",
{ {
{ "disabled", NULL }, { "disabled", NULL },
@ -416,7 +427,7 @@ struct retro_core_option_definition option_defs_us[] = {
}, },
{ {
"vbam_layer_6", "vbam_layer_6",
"Show window layer 1", "Show Window Layer 1",
"Shows or hides window layer 1.", "Shows or hides window layer 1.",
{ {
{ "disabled", NULL }, { "disabled", NULL },
@ -427,7 +438,7 @@ struct retro_core_option_definition option_defs_us[] = {
}, },
{ {
"vbam_layer_7", "vbam_layer_7",
"Show window layer 2", "Show Window Layer 2",
"Shows or hides window layer 2.", "Shows or hides window layer 2.",
{ {
{ "disabled", NULL }, { "disabled", NULL },
@ -438,7 +449,7 @@ struct retro_core_option_definition option_defs_us[] = {
}, },
{ {
"vbam_layer_8", "vbam_layer_8",
"Show sprite window layer", "Show Sprite Window Layer",
"Shows or hides sprite window layer.", "Shows or hides sprite window layer.",
{ {
{ "disabled", NULL }, { "disabled", NULL },