From 8bc5ec422285bb84b3d133830f4d5e0ecc5742bd Mon Sep 17 00:00:00 2001 From: Jeffrey Pfau Date: Sun, 5 May 2013 20:37:35 -0700 Subject: [PATCH] Roll out incorrect fix for Halt bug and apply proper fix --- src/gba/gba-bios.c | 1 + src/gba/gba.c | 10 ++++++++-- src/gba/hle-bios.c | 15 +++++++-------- src/gba/hle-bios.s | 2 -- 4 files changed, 16 insertions(+), 12 deletions(-) diff --git a/src/gba/gba-bios.c b/src/gba/gba-bios.c index 8c4108189..019783980 100644 --- a/src/gba/gba-bios.c +++ b/src/gba/gba-bios.c @@ -179,6 +179,7 @@ void GBASwi16(struct ARMBoard* board, int immediate) { if (!gba->cpu.gprs[0] && gba->memory.io[REG_IF >> 1] & gba->cpu.gprs[1]) { break; } + gba->memory.io[REG_IF >> 1] = 0; ARMRaiseSWI(&gba->cpu); break; case 0x6: diff --git a/src/gba/gba.c b/src/gba/gba.c index 110d753cd..0db7af372 100644 --- a/src/gba/gba.c +++ b/src/gba/gba.c @@ -337,17 +337,23 @@ int GBATestIRQ(struct GBA* gba) { } int GBAWaitForIRQ(struct GBA* gba) { + int irqs = gba->memory.io[REG_IF >> 1]; + int newIRQs = 0; + gba->memory.io[REG_IF >> 1] = 0; while (1) { if (gba->cpu.nextEvent == INT_MAX) { - return 0; + break; } else { gba->cpu.cycles = gba->cpu.nextEvent; GBAProcessEvents(&gba->board.d); if (gba->memory.io[REG_IF >> 1]) { - return 1; + newIRQs = gba->memory.io[REG_IF >> 1]; + break; } } } + gba->memory.io[REG_IF >> 1] = newIRQs | irqs; + return newIRQs; } int GBAHalt(struct GBA* gba) { diff --git a/src/gba/hle-bios.c b/src/gba/hle-bios.c index f055325a2..81661e62b 100644 --- a/src/gba/hle-bios.c +++ b/src/gba/hle-bios.c @@ -1,5 +1,6 @@ #include "hle-bios.h" +const unsigned int hleBiosLength = 216; const unsigned char hleBios[] = { 0x06, 0x00, 0x00, 0xea, 0xfe, 0xff, 0xff, 0xea, 0x05, 0x00, 0x00, 0xea, 0xfe, 0xff, 0xff, 0xea, 0xfe, 0xff, 0xff, 0xea, 0x00, 0x00, 0xa0, 0xe1, @@ -13,12 +14,10 @@ const unsigned char hleBios[] = { 0x04, 0xd0, 0x4d, 0xe2, 0xb0, 0x10, 0xcd, 0xe1, 0x01, 0x23, 0xa0, 0xe3, 0x02, 0x2c, 0x82, 0xe2, 0xb0, 0x00, 0xd2, 0xe1, 0xb2, 0x00, 0xcd, 0xe1, 0xb0, 0x10, 0xdd, 0xe1, 0x01, 0x10, 0x80, 0xe1, 0xb0, 0x10, 0xc2, 0xe1, - 0x00, 0x00, 0xe0, 0xe3, 0xb2, 0x00, 0xc2, 0xe1, 0x1f, 0x00, 0xa0, 0xe3, - 0x00, 0xf0, 0x29, 0xe1, 0x00, 0x00, 0x02, 0xef, 0xd3, 0x00, 0xa0, 0xe3, - 0x00, 0xf0, 0x29, 0xe1, 0x01, 0x03, 0xa0, 0xe3, 0xb8, 0x20, 0x50, 0xe1, - 0xb0, 0x10, 0xdd, 0xe1, 0x02, 0x10, 0x11, 0xe0, 0x02, 0x10, 0x21, 0x10, - 0xb8, 0x10, 0x40, 0x11, 0xb2, 0x00, 0xdd, 0xe1, 0x01, 0x13, 0xa0, 0xe3, - 0x02, 0x1c, 0x81, 0xe2, 0xb0, 0x00, 0xc1, 0xe1, 0xe6, 0xff, 0xff, 0x0a, - 0x04, 0xd0, 0x8d, 0xe2, 0x04, 0x80, 0xbd, 0xe8 + 0x1f, 0x00, 0xa0, 0xe3, 0x00, 0xf0, 0x29, 0xe1, 0x00, 0x00, 0x02, 0xef, + 0xd3, 0x00, 0xa0, 0xe3, 0x00, 0xf0, 0x29, 0xe1, 0x01, 0x03, 0xa0, 0xe3, + 0xb8, 0x20, 0x50, 0xe1, 0xb0, 0x10, 0xdd, 0xe1, 0x02, 0x10, 0x11, 0xe0, + 0x02, 0x10, 0x21, 0x10, 0xb8, 0x10, 0x40, 0x11, 0xb2, 0x00, 0xdd, 0xe1, + 0x01, 0x13, 0xa0, 0xe3, 0x02, 0x1c, 0x81, 0xe2, 0xb0, 0x00, 0xc1, 0xe1, + 0xe8, 0xff, 0xff, 0x0a, 0x04, 0xd0, 0x8d, 0xe2, 0x04, 0x80, 0xbd, 0xe8 }; -const unsigned int hleBiosLength = 224; diff --git a/src/gba/hle-bios.s b/src/gba/hle-bios.s index 92fe250ec..a0dcb1336 100644 --- a/src/gba/hle-bios.s +++ b/src/gba/hle-bios.s @@ -47,8 +47,6 @@ strh r0, [sp, #2] ldrh r1, [sp, #0] orr r1, r0, r1 strh r1, [r2, #0] -mov r0, #0xFFFFFFFF -strh r0, [r2, #2] mov r0, #0x1F msr cpsr, r0 swi #0x020000