Merge pull request #1 from Morilli/fix-unsupported-mapper-crash
fix crash/exit instead of returning error for unsupported mappers
This commit is contained in:
commit
d705ab178f
|
@ -142,7 +142,7 @@ class Core : private Cpu
|
|||
return 0;
|
||||
}
|
||||
|
||||
void open(Cart const *new_cart)
|
||||
const char *open(Cart const *new_cart)
|
||||
{
|
||||
close();
|
||||
init();
|
||||
|
@ -157,7 +157,7 @@ class Core : private Cpu
|
|||
if (mapper == nullptr)
|
||||
{
|
||||
fprintf(stderr, "Could not find mapper for code: %u\n", mapperCode);
|
||||
exit(-1);
|
||||
return "Unsupported mapper";
|
||||
}
|
||||
|
||||
// Assigning backwards pointers to cartdrige and emulator now
|
||||
|
@ -169,6 +169,8 @@ class Core : private Cpu
|
|||
cart = new_cart;
|
||||
memset(impl->unmapped_page, unmapped_fill, sizeof impl->unmapped_page);
|
||||
reset(true, true);
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
inline void serializeState(jaffarCommon::serializer::Base &serializer) const
|
||||
|
|
|
@ -78,16 +78,19 @@ inline void Emu::clear_sound_buf()
|
|||
sound_buf->clear();
|
||||
}
|
||||
|
||||
void Emu::set_cart(Cart const *new_cart)
|
||||
const char *Emu::set_cart(Cart const *new_cart)
|
||||
{
|
||||
auto_init();
|
||||
emu.open(new_cart);
|
||||
const char *error = emu.open(new_cart);
|
||||
if (error) return error;
|
||||
|
||||
channel_count_ = Apu::osc_count + emu.mapper->channel_count();
|
||||
sound_buf->set_channel_count(channel_count());
|
||||
set_equalizer(equalizer_);
|
||||
enable_sound(true);
|
||||
reset();
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void Emu::reset(bool full_reset, bool erase_battery_ram)
|
||||
|
@ -167,10 +170,10 @@ const char *Emu::emulate_frame(uint32_t joypad1, uint32_t joypad2, uint32_t arka
|
|||
|
||||
// Extras
|
||||
|
||||
void Emu::load_ines(const uint8_t *buffer)
|
||||
const char *Emu::load_ines(const uint8_t *buffer)
|
||||
{
|
||||
private_cart.load_ines(buffer);
|
||||
set_cart(&private_cart);
|
||||
return set_cart(&private_cart);
|
||||
}
|
||||
|
||||
void Emu::write_chr(void const *p, long count, long offset)
|
||||
|
|
Loading…
Reference in New Issue