Respect TPP1 feature flags for rumble and RTC
This commit is contained in:
parent
763de9d2e0
commit
80f422d0ca
@ -1523,7 +1523,9 @@ static bool mbc(GB_gameboy_t *gb, char *arguments, char *modifiers, const debugg
|
|||||||
const GB_cartridge_t *cartridge = gb->cartridge_type;
|
const GB_cartridge_t *cartridge = gb->cartridge_type;
|
||||||
|
|
||||||
if (cartridge->has_ram) {
|
if (cartridge->has_ram) {
|
||||||
GB_log(gb, "Cartridge includes%s RAM: $%x bytes\n", cartridge->has_battery? " battery-backed": "", gb->mbc_ram_size);
|
bool has_battery = gb->cartridge_type->has_battery &&
|
||||||
|
(gb->cartridge_type->mbc_type != GB_TPP1 || (gb->rom[0x153] & 8));
|
||||||
|
GB_log(gb, "Cartridge includes%s RAM: $%x bytes\n", has_battery? " battery-backed": "", gb->mbc_ram_size);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
GB_log(gb, "No cartridge RAM\n");
|
GB_log(gb, "No cartridge RAM\n");
|
||||||
@ -1565,7 +1567,8 @@ static bool mbc(GB_gameboy_t *gb, char *arguments, char *modifiers, const debugg
|
|||||||
GB_log(gb, "No MBC\n");
|
GB_log(gb, "No MBC\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cartridge->has_rumble) {
|
if (gb->cartridge_type->has_rumble &&
|
||||||
|
(gb->cartridge_type->mbc_type != GB_TPP1 || (gb->rom[0x153] & 1))) {
|
||||||
GB_log(gb, "Cart contains a Rumble Pak\n");
|
GB_log(gb, "Cart contains a Rumble Pak\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -609,6 +609,8 @@ typedef union {
|
|||||||
int GB_save_battery_size(GB_gameboy_t *gb)
|
int GB_save_battery_size(GB_gameboy_t *gb)
|
||||||
{
|
{
|
||||||
if (!gb->cartridge_type->has_battery) return 0; // Nothing to save.
|
if (!gb->cartridge_type->has_battery) return 0; // Nothing to save.
|
||||||
|
if (gb->cartridge_type->mbc_type == GB_TPP1 && !(gb->rom[0x153] & 8)) return 0; // Nothing to save.
|
||||||
|
|
||||||
if (gb->mbc_ram_size == 0 && !gb->cartridge_type->has_rtc) return 0; /* Claims to have battery, but has no RAM or RTC */
|
if (gb->mbc_ram_size == 0 && !gb->cartridge_type->has_rtc) return 0; /* Claims to have battery, but has no RAM or RTC */
|
||||||
|
|
||||||
if (gb->cartridge_type->mbc_type == GB_HUC3) {
|
if (gb->cartridge_type->mbc_type == GB_HUC3) {
|
||||||
@ -621,6 +623,7 @@ int GB_save_battery_size(GB_gameboy_t *gb)
|
|||||||
int GB_save_battery_to_buffer(GB_gameboy_t *gb, uint8_t *buffer, size_t size)
|
int GB_save_battery_to_buffer(GB_gameboy_t *gb, uint8_t *buffer, size_t size)
|
||||||
{
|
{
|
||||||
if (!gb->cartridge_type->has_battery) return 0; // Nothing to save.
|
if (!gb->cartridge_type->has_battery) return 0; // Nothing to save.
|
||||||
|
if (gb->cartridge_type->mbc_type == GB_TPP1 && !(gb->rom[0x153] & 8)) return 0; // Nothing to save.
|
||||||
if (gb->mbc_ram_size == 0 && !gb->cartridge_type->has_rtc) return 0; /* Claims to have battery, but has no RAM or RTC */
|
if (gb->mbc_ram_size == 0 && !gb->cartridge_type->has_rtc) return 0; /* Claims to have battery, but has no RAM or RTC */
|
||||||
|
|
||||||
if (size < GB_save_battery_size(gb)) return EIO;
|
if (size < GB_save_battery_size(gb)) return EIO;
|
||||||
@ -678,6 +681,7 @@ int GB_save_battery_to_buffer(GB_gameboy_t *gb, uint8_t *buffer, size_t size)
|
|||||||
int GB_save_battery(GB_gameboy_t *gb, const char *path)
|
int GB_save_battery(GB_gameboy_t *gb, const char *path)
|
||||||
{
|
{
|
||||||
if (!gb->cartridge_type->has_battery) return 0; // Nothing to save.
|
if (!gb->cartridge_type->has_battery) return 0; // Nothing to save.
|
||||||
|
if (gb->cartridge_type->mbc_type == GB_TPP1 && !(gb->rom[0x153] & 8)) return 0; // Nothing to save.
|
||||||
if (gb->mbc_ram_size == 0 && !gb->cartridge_type->has_rtc) return 0; /* Claims to have battery, but has no RAM or RTC */
|
if (gb->mbc_ram_size == 0 && !gb->cartridge_type->has_rtc) return 0; /* Claims to have battery, but has no RAM or RTC */
|
||||||
FILE *f = fopen(path, "wb");
|
FILE *f = fopen(path, "wb");
|
||||||
if (!f) {
|
if (!f) {
|
||||||
|
@ -15,7 +15,8 @@ void GB_handle_rumble(GB_gameboy_t *gb)
|
|||||||
if (gb->rumble_mode == GB_RUMBLE_DISABLED) {
|
if (gb->rumble_mode == GB_RUMBLE_DISABLED) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (gb->cartridge_type->has_rumble) {
|
if (gb->cartridge_type->has_rumble &&
|
||||||
|
(gb->cartridge_type->mbc_type != GB_TPP1 || (gb->rom[0x153] & 1))) {
|
||||||
if (gb->rumble_on_cycles + gb->rumble_off_cycles) {
|
if (gb->rumble_on_cycles + gb->rumble_off_cycles) {
|
||||||
gb->rumble_callback(gb, gb->rumble_on_cycles / (double)(gb->rumble_on_cycles + gb->rumble_off_cycles));
|
gb->rumble_callback(gb, gb->rumble_on_cycles / (double)(gb->rumble_on_cycles + gb->rumble_off_cycles));
|
||||||
gb->rumble_on_cycles = gb->rumble_off_cycles = 0;
|
gb->rumble_on_cycles = gb->rumble_off_cycles = 0;
|
||||||
|
Loading…
Reference in New Issue
Block a user