GBA Memory: Various AGBPrint fixes

This commit is contained in:
Vicki Pfau 2019-02-11 21:59:15 -08:00
parent 22531a1315
commit cab3a2272d
2 changed files with 8 additions and 2 deletions

View File

@ -7,6 +7,8 @@ Bugfixes:
- GBA BIOS: Fix multiboot entry point (fixes Magic Floor) - GBA BIOS: Fix multiboot entry point (fixes Magic Floor)
- Switch: Fix final cleanup (fixes mgba.io/i/1283) - Switch: Fix final cleanup (fixes mgba.io/i/1283)
- Qt: Fix tile and sprite views not always displaying at first - Qt: Fix tile and sprite views not always displaying at first
- GBA Memory: Fix a few AGBPrint crashes
- GBA Memory: Fix OOB ROM reads showing up as AGBPrint memory
Misc: Misc:
- GBA Savedata: EEPROM performance fixes - GBA Savedata: EEPROM performance fixes
- GBA Savedata: Automatically map 1Mbit Flash files as 1Mbit Flash - GBA Savedata: Automatically map 1Mbit Flash files as 1Mbit Flash

View File

@ -1647,6 +1647,10 @@ void _pristineCow(struct GBA* gba) {
} }
void GBAPrintFlush(struct GBA* gba) { void GBAPrintFlush(struct GBA* gba) {
if (!gba->memory.agbPrintBuffer) {
return;
}
char oolBuf[0x101]; char oolBuf[0x101];
size_t i; size_t i;
for (i = 0; gba->memory.agbPrintCtx.get != gba->memory.agbPrintCtx.put && i < 0x100; ++i) { for (i = 0; gba->memory.agbPrintCtx.get != gba->memory.agbPrintCtx.put && i < 0x100; ++i) {
@ -1688,8 +1692,8 @@ static void _agbPrintStore(struct GBA* gba, uint32_t address, int16_t value) {
static int16_t _agbPrintLoad(struct GBA* gba, uint32_t address) { static int16_t _agbPrintLoad(struct GBA* gba, uint32_t address) {
struct GBAMemory* memory = &gba->memory; struct GBAMemory* memory = &gba->memory;
int16_t value = 0xFFFF; int16_t value = address >> 1;
if (address < AGB_PRINT_TOP) { if (address < AGB_PRINT_TOP && memory->agbPrintBuffer) {
LOAD_16(value, address & (SIZE_AGB_PRINT - 1), memory->agbPrintBuffer); LOAD_16(value, address & (SIZE_AGB_PRINT - 1), memory->agbPrintBuffer);
} else if ((address & 0x00FFFFF8) == (AGB_PRINT_STRUCT & 0x00FFFFF8)) { } else if ((address & 0x00FFFFF8) == (AGB_PRINT_STRUCT & 0x00FFFFF8)) {
value = (&memory->agbPrintCtx.request)[(address & 7) >> 1]; value = (&memory->agbPrintCtx.request)[(address & 7) >> 1];