Show a better message if the game crashes
This commit is contained in:
@@ -3,8 +3,7 @@
|
||||
#include <string.h>
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include <assert.h>
|
||||
|
||||
#include "../types.h"
|
||||
#include "cart.h"
|
||||
#include "snes.h"
|
||||
|
||||
@@ -72,6 +71,8 @@ void cart_write(Cart* cart, uint8_t bank, uint16_t adr, uint8_t val) {
|
||||
}
|
||||
}
|
||||
|
||||
void DumpCpuHistory();
|
||||
|
||||
static uint8_t cart_readLorom(Cart* cart, uint8_t bank, uint16_t adr) {
|
||||
if(((bank >= 0x70 && bank < 0x7e) || bank >= 0xf0) && adr < 0x8000 && cart->ramSize > 0) {
|
||||
// banks 70-7e and f0-ff, adr 0000-7fff
|
||||
@@ -82,7 +83,9 @@ static uint8_t cart_readLorom(Cart* cart, uint8_t bank, uint16_t adr) {
|
||||
// adr 8000-ffff in all banks or all addresses in banks 40-7f and c0-ff
|
||||
return cart->rom[((bank << 15) | (adr & 0x7fff)) & (cart->romSize - 1)];
|
||||
}
|
||||
assert(0);
|
||||
printf("While trying to read from 0x%x\n", bank << 16 | adr);
|
||||
DumpCpuHistory();
|
||||
Die("The game crashed in cart_readLorom");
|
||||
return cart->snes->openBus;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user