mirror of https://github.com/mgba-emu/mgba.git
GBA BIOS: Improve HLE BIOS timing
This commit is contained in:
parent
7ea3728165
commit
8a8b4add91
1
CHANGES
1
CHANGES
|
@ -8,6 +8,7 @@ Emulation fixes:
|
||||||
- GBA: Fix multiboot entry point while skipping BIOS
|
- GBA: Fix multiboot entry point while skipping BIOS
|
||||||
- GBA BIOS: Fix undefined instruction HLE behavior
|
- GBA BIOS: Fix undefined instruction HLE behavior
|
||||||
- GBA BIOS: Implement dummy sound driver calls
|
- GBA BIOS: Implement dummy sound driver calls
|
||||||
|
- GBA BIOS: Improve HLE BIOS timing
|
||||||
- GBA DMA: Linger last DMA on bus (fixes mgba.io/i/301 and mgba.io/i/1320)
|
- GBA DMA: Linger last DMA on bus (fixes mgba.io/i/301 and mgba.io/i/1320)
|
||||||
- GBA Memory: Misaligned SRAM writes are ignored
|
- GBA Memory: Misaligned SRAM writes are ignored
|
||||||
- GBA Memory: Improve gamepak prefetch timing
|
- GBA Memory: Improve gamepak prefetch timing
|
||||||
|
|
|
@ -431,8 +431,8 @@ void GBASwi16(struct ARMCore* cpu, int immediate) {
|
||||||
_RegisterRamReset(gba);
|
_RegisterRamReset(gba);
|
||||||
break;
|
break;
|
||||||
case GBA_SWI_HALT:
|
case GBA_SWI_HALT:
|
||||||
GBAHalt(gba);
|
ARMRaiseSWI(cpu);
|
||||||
break;
|
return;
|
||||||
case GBA_SWI_STOP:
|
case GBA_SWI_STOP:
|
||||||
GBAStop(gba);
|
GBAStop(gba);
|
||||||
break;
|
break;
|
||||||
|
@ -442,7 +442,7 @@ void GBASwi16(struct ARMCore* cpu, int immediate) {
|
||||||
case GBA_SWI_INTR_WAIT:
|
case GBA_SWI_INTR_WAIT:
|
||||||
// IntrWait
|
// IntrWait
|
||||||
ARMRaiseSWI(cpu);
|
ARMRaiseSWI(cpu);
|
||||||
break;
|
return;
|
||||||
case GBA_SWI_DIV:
|
case GBA_SWI_DIV:
|
||||||
_Div(gba, cpu->gprs[0], cpu->gprs[1]);
|
_Div(gba, cpu->gprs[0], cpu->gprs[1]);
|
||||||
break;
|
break;
|
||||||
|
@ -472,7 +472,7 @@ void GBASwi16(struct ARMCore* cpu, int immediate) {
|
||||||
mLOG(GBA_BIOS, GAME_ERROR, "Misaligned CpuSet destination");
|
mLOG(GBA_BIOS, GAME_ERROR, "Misaligned CpuSet destination");
|
||||||
}
|
}
|
||||||
ARMRaiseSWI(cpu);
|
ARMRaiseSWI(cpu);
|
||||||
break;
|
return;
|
||||||
case GBA_SWI_GET_BIOS_CHECKSUM:
|
case GBA_SWI_GET_BIOS_CHECKSUM:
|
||||||
cpu->gprs[0] = GBA_BIOS_CHECKSUM;
|
cpu->gprs[0] = GBA_BIOS_CHECKSUM;
|
||||||
cpu->gprs[1] = 1;
|
cpu->gprs[1] = 1;
|
||||||
|
@ -577,7 +577,7 @@ void GBASwi16(struct ARMCore* cpu, int immediate) {
|
||||||
break;
|
break;
|
||||||
case GBA_SWI_SOUND_DRIVER_GET_JUMP_LIST:
|
case GBA_SWI_SOUND_DRIVER_GET_JUMP_LIST:
|
||||||
ARMRaiseSWI(cpu);
|
ARMRaiseSWI(cpu);
|
||||||
break;
|
return;
|
||||||
default:
|
default:
|
||||||
mLOG(GBA_BIOS, STUB, "Stub software interrupt: %02X", immediate);
|
mLOG(GBA_BIOS, STUB, "Stub software interrupt: %02X", immediate);
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,38 +3,44 @@
|
||||||
#include <mgba/internal/gba/memory.h>
|
#include <mgba/internal/gba/memory.h>
|
||||||
|
|
||||||
const uint8_t hleBios[SIZE_BIOS] = {
|
const uint8_t hleBios[SIZE_BIOS] = {
|
||||||
0x06, 0x00, 0x00, 0xea, 0x58, 0x00, 0x00, 0xea, 0x0b, 0x00, 0x00, 0xea,
|
0x06, 0x00, 0x00, 0xea, 0x66, 0x00, 0x00, 0xea, 0x0b, 0x00, 0x00, 0xea,
|
||||||
0xfe, 0xff, 0xff, 0xea, 0xfe, 0xff, 0xff, 0xea, 0x00, 0x00, 0xa0, 0xe1,
|
0xfe, 0xff, 0xff, 0xea, 0xfe, 0xff, 0xff, 0xea, 0x00, 0x00, 0xa0, 0xe1,
|
||||||
0x4b, 0x00, 0x00, 0xea, 0xfe, 0xff, 0xff, 0xea, 0x02, 0x03, 0xa0, 0xe3,
|
0x59, 0x00, 0x00, 0xea, 0xfe, 0xff, 0xff, 0xea, 0x02, 0x03, 0xa0, 0xe3,
|
||||||
0x03, 0x10, 0xd0, 0xe5, 0xea, 0x00, 0x51, 0xe3, 0x14, 0x01, 0x9f, 0x15,
|
0x03, 0x10, 0xd0, 0xe5, 0xea, 0x00, 0x51, 0xe3, 0x4c, 0x01, 0x9f, 0x15,
|
||||||
0x10, 0xff, 0x2f, 0xe1, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf0, 0x29, 0xe1,
|
0x10, 0xff, 0x2f, 0xe1, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf0, 0x29, 0xe1,
|
||||||
0x00, 0x00, 0x5d, 0xe3, 0x01, 0xd3, 0xa0, 0x03, 0x20, 0xd0, 0x4d, 0x02,
|
0x00, 0x00, 0x5d, 0xe3, 0x01, 0xd3, 0xa0, 0x03, 0x20, 0xd0, 0x4d, 0x02,
|
||||||
0x00, 0x58, 0x2d, 0xe9, 0x02, 0xb0, 0x5e, 0xe5, 0x9c, 0xc0, 0xa0, 0xe3,
|
0x00, 0x58, 0x2d, 0xe9, 0x02, 0xb0, 0x5e, 0xe5, 0xd4, 0xc0, 0xa0, 0xe3,
|
||||||
0x0b, 0xb1, 0x9c, 0xe7, 0x00, 0x00, 0x5b, 0xe3, 0x00, 0xc0, 0x4f, 0xe1,
|
0x0b, 0xb1, 0x9c, 0xe7, 0x00, 0x00, 0x5b, 0xe3, 0x00, 0xc0, 0x4f, 0xe1,
|
||||||
0x00, 0x10, 0x2d, 0xe9, 0x80, 0xc0, 0x0c, 0xe2, 0x1f, 0xc0, 0x8c, 0xe3,
|
0x00, 0x10, 0x2d, 0xe9, 0x80, 0xc0, 0x0c, 0xe2, 0x1f, 0xc0, 0x8c, 0xe3,
|
||||||
0x0c, 0xf0, 0x29, 0xe1, 0x00, 0x40, 0x2d, 0xe9, 0x0f, 0xe0, 0xa0, 0xe1,
|
0x0c, 0xf0, 0x29, 0xe1, 0x00, 0x40, 0x2d, 0xe9, 0x00, 0x00, 0xa0, 0xe1,
|
||||||
0x1b, 0xff, 0x2f, 0x11, 0x00, 0x40, 0xbd, 0xe8, 0x93, 0xf0, 0x29, 0xe3,
|
0x00, 0x00, 0xa0, 0xe1, 0x00, 0x00, 0xa0, 0xe1, 0x00, 0x00, 0xa0, 0xe1,
|
||||||
0x00, 0x10, 0xbd, 0xe8, 0x0c, 0xf0, 0x69, 0xe1, 0x00, 0x58, 0xbd, 0xe8,
|
0x00, 0x00, 0xa0, 0xe1, 0x00, 0x00, 0xa0, 0xe1, 0x00, 0x00, 0xa0, 0xe1,
|
||||||
0x0e, 0xf0, 0xb0, 0xe1, 0x00, 0x00, 0x00, 0x00, 0x04, 0x20, 0xa0, 0xe3,
|
0x00, 0x00, 0xa0, 0xe1, 0x00, 0x00, 0xa0, 0xe1, 0x00, 0x00, 0xa0, 0xe1,
|
||||||
0x78, 0x01, 0x00, 0x00, 0x78, 0x01, 0x00, 0x00, 0x78, 0x01, 0x00, 0x00,
|
0x0f, 0xe0, 0xa0, 0xe1, 0x1b, 0xff, 0x2f, 0x11, 0x00, 0x00, 0xa0, 0xe1,
|
||||||
0x78, 0x01, 0x00, 0x00, 0x84, 0x01, 0x00, 0x00, 0x7c, 0x01, 0x00, 0x00,
|
0x00, 0x00, 0xa0, 0xe1, 0x00, 0x00, 0xa0, 0xe1, 0x00, 0x00, 0xa0, 0xe1,
|
||||||
0x78, 0x01, 0x00, 0x00, 0x78, 0x01, 0x00, 0x00, 0x78, 0x01, 0x00, 0x00,
|
0x00, 0x40, 0xbd, 0xe8, 0x93, 0xf0, 0x29, 0xe3, 0x00, 0x10, 0xbd, 0xe8,
|
||||||
0x78, 0x01, 0x00, 0x00, 0x78, 0x01, 0x00, 0x00, 0xcc, 0x01, 0x00, 0x00,
|
0x0c, 0xf0, 0x69, 0xe1, 0x00, 0x58, 0xbd, 0xe8, 0x0e, 0xf0, 0xb0, 0xe1,
|
||||||
0x60, 0x02, 0x00, 0x00, 0x78, 0x01, 0x00, 0x00, 0x78, 0x01, 0x00, 0x00,
|
0x00, 0x00, 0x00, 0x00, 0x04, 0x20, 0xa0, 0xe3, 0xb0, 0x01, 0x00, 0x00,
|
||||||
0x78, 0x01, 0x00, 0x00, 0x78, 0x01, 0x00, 0x00, 0x78, 0x01, 0x00, 0x00,
|
0xb0, 0x01, 0x00, 0x00, 0xb4, 0x01, 0x00, 0x00, 0xb0, 0x01, 0x00, 0x00,
|
||||||
0x78, 0x01, 0x00, 0x00, 0x78, 0x01, 0x00, 0x00, 0x78, 0x01, 0x00, 0x00,
|
0xcc, 0x01, 0x00, 0x00, 0xc4, 0x01, 0x00, 0x00, 0xb0, 0x01, 0x00, 0x00,
|
||||||
0x78, 0x01, 0x00, 0x00, 0x78, 0x01, 0x00, 0x00, 0x78, 0x01, 0x00, 0x00,
|
0xb0, 0x01, 0x00, 0x00, 0xb0, 0x01, 0x00, 0x00, 0xb0, 0x01, 0x00, 0x00,
|
||||||
0x78, 0x01, 0x00, 0x00, 0x78, 0x01, 0x00, 0x00, 0x78, 0x01, 0x00, 0x00,
|
0xb0, 0x01, 0x00, 0x00, 0x14, 0x02, 0x00, 0x00, 0xa8, 0x02, 0x00, 0x00,
|
||||||
0x78, 0x01, 0x00, 0x00, 0x78, 0x01, 0x00, 0x00, 0x78, 0x01, 0x00, 0x00,
|
0xb0, 0x01, 0x00, 0x00, 0xb0, 0x01, 0x00, 0x00, 0xb0, 0x01, 0x00, 0x00,
|
||||||
0x78, 0x01, 0x00, 0x00, 0x78, 0x01, 0x00, 0x00, 0x78, 0x01, 0x00, 0x00,
|
0xb0, 0x01, 0x00, 0x00, 0xb0, 0x01, 0x00, 0x00, 0xb0, 0x01, 0x00, 0x00,
|
||||||
0x78, 0x01, 0x00, 0x00, 0x78, 0x01, 0x00, 0x00, 0x78, 0x01, 0x00, 0x00,
|
0xb0, 0x01, 0x00, 0x00, 0xb0, 0x01, 0x00, 0x00, 0xb0, 0x01, 0x00, 0x00,
|
||||||
0x78, 0x01, 0x00, 0x00, 0x78, 0x01, 0x00, 0x00, 0x78, 0x01, 0x00, 0x00,
|
0xb0, 0x01, 0x00, 0x00, 0xb0, 0x01, 0x00, 0x00, 0xb0, 0x01, 0x00, 0x00,
|
||||||
0x78, 0x01, 0x00, 0x00, 0x78, 0x01, 0x00, 0x00, 0x78, 0x01, 0x00, 0x00,
|
0xb0, 0x01, 0x00, 0x00, 0xb0, 0x01, 0x00, 0x00, 0xb0, 0x01, 0x00, 0x00,
|
||||||
0xb8, 0x02, 0x00, 0x00, 0xc0, 0x00, 0x00, 0x02, 0x0f, 0x50, 0x2d, 0xe9,
|
0xb0, 0x01, 0x00, 0x00, 0xb0, 0x01, 0x00, 0x00, 0xb0, 0x01, 0x00, 0x00,
|
||||||
0x01, 0x03, 0xa0, 0xe3, 0x00, 0xe0, 0x8f, 0xe2, 0x04, 0xf0, 0x10, 0xe5,
|
0xb0, 0x01, 0x00, 0x00, 0xb0, 0x01, 0x00, 0x00, 0xb0, 0x01, 0x00, 0x00,
|
||||||
0x0f, 0x50, 0xbd, 0xe8, 0x04, 0xf0, 0x5e, 0xe2, 0x00, 0x00, 0x00, 0x00,
|
0xb0, 0x01, 0x00, 0x00, 0xb0, 0x01, 0x00, 0x00, 0xb0, 0x01, 0x00, 0x00,
|
||||||
0x02, 0xc0, 0x5e, 0xe5, 0x04, 0xf0, 0x5e, 0xe2, 0x00, 0x00, 0x00, 0x00,
|
0xb0, 0x01, 0x00, 0x00, 0xb0, 0x01, 0x00, 0x00, 0xb0, 0x01, 0x00, 0x00,
|
||||||
0x04, 0xe0, 0xa0, 0x03, 0x1e, 0xff, 0x2f, 0xe1, 0x01, 0x00, 0xa0, 0xe3,
|
0xb0, 0x01, 0x00, 0x00, 0xb0, 0x01, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00,
|
||||||
|
0xc0, 0x00, 0x00, 0x02, 0x0f, 0x50, 0x2d, 0xe9, 0x01, 0x03, 0xa0, 0xe3,
|
||||||
|
0x00, 0xe0, 0x8f, 0xe2, 0x04, 0xf0, 0x10, 0xe5, 0x0f, 0x50, 0xbd, 0xe8,
|
||||||
|
0x04, 0xf0, 0x5e, 0xe2, 0x00, 0x00, 0x00, 0x00, 0x02, 0xc0, 0x5e, 0xe5,
|
||||||
|
0x04, 0xf0, 0x5e, 0xe2, 0x00, 0x00, 0x00, 0x00, 0x04, 0xe0, 0xa0, 0x03,
|
||||||
|
0x1e, 0xff, 0x2f, 0xe1, 0x00, 0x20, 0xa0, 0xe3, 0x01, 0xc3, 0xa0, 0xe3,
|
||||||
|
0x01, 0x23, 0xcc, 0xe5, 0x1e, 0xff, 0x2f, 0xe1, 0x01, 0x00, 0xa0, 0xe3,
|
||||||
0x01, 0x10, 0xa0, 0xe3, 0x0c, 0x40, 0x2d, 0xe9, 0x01, 0xc3, 0xa0, 0xe3,
|
0x01, 0x10, 0xa0, 0xe3, 0x0c, 0x40, 0x2d, 0xe9, 0x01, 0xc3, 0xa0, 0xe3,
|
||||||
0x00, 0x00, 0x50, 0xe3, 0x00, 0x00, 0xa0, 0xe3, 0x01, 0x20, 0xa0, 0xe3,
|
0x00, 0x00, 0x50, 0xe3, 0x00, 0x00, 0xa0, 0xe3, 0x01, 0x20, 0xa0, 0xe3,
|
||||||
0x03, 0x00, 0x00, 0x0a, 0xb8, 0x30, 0x5c, 0xe1, 0x01, 0x30, 0xc3, 0xe1,
|
0x03, 0x00, 0x00, 0x0a, 0xb8, 0x30, 0x5c, 0xe1, 0x01, 0x30, 0xc3, 0xe1,
|
||||||
|
@ -66,5 +72,5 @@ const uint8_t hleBios[SIZE_BIOS] = {
|
||||||
0x01, 0x70, 0xa0, 0xe1, 0x01, 0x80, 0xa0, 0xe1, 0x01, 0x90, 0xa0, 0xe1,
|
0x01, 0x70, 0xa0, 0xe1, 0x01, 0x80, 0xa0, 0xe1, 0x01, 0x90, 0xa0, 0xe1,
|
||||||
0x01, 0xa0, 0xa0, 0xe1, 0xfa, 0x07, 0xa0, 0xe8, 0xfa, 0x07, 0xa0, 0xe8,
|
0x01, 0xa0, 0xa0, 0xe1, 0xfa, 0x07, 0xa0, 0xe8, 0xfa, 0x07, 0xa0, 0xe8,
|
||||||
0xfa, 0x07, 0xa0, 0xe8, 0xfa, 0x07, 0xa0, 0xe8, 0x00, 0x10, 0xa0, 0xe3,
|
0xfa, 0x07, 0xa0, 0xe8, 0xfa, 0x07, 0xa0, 0xe8, 0x00, 0x10, 0xa0, 0xe3,
|
||||||
0xf0, 0x07, 0xbd, 0xe8, 0x1e, 0xff, 0x2f, 0xe1, 0x78, 0x01, 0x00, 0x00
|
0xf0, 0x07, 0xbd, 0xe8, 0x1e, 0xff, 0x2f, 0xe1, 0xb0, 0x01, 0x00, 0x00
|
||||||
};
|
};
|
||||||
|
|
|
@ -40,8 +40,22 @@ and r12, #0x80
|
||||||
orr r12, #0x1F
|
orr r12, #0x1F
|
||||||
msr cpsr, r12
|
msr cpsr, r12
|
||||||
stmfd sp!, {lr}
|
stmfd sp!, {lr}
|
||||||
|
nop
|
||||||
|
nop
|
||||||
|
nop
|
||||||
|
nop
|
||||||
|
nop
|
||||||
|
nop
|
||||||
|
nop
|
||||||
|
nop
|
||||||
|
nop
|
||||||
|
nop
|
||||||
mov lr, pc
|
mov lr, pc
|
||||||
bxne r11
|
bxne r11
|
||||||
|
nop
|
||||||
|
nop
|
||||||
|
nop
|
||||||
|
nop
|
||||||
ldmfd sp!, {lr}
|
ldmfd sp!, {lr}
|
||||||
msr cpsr, #0x93
|
msr cpsr, #0x93
|
||||||
ldmfd sp!, {r12}
|
ldmfd sp!, {r12}
|
||||||
|
@ -116,7 +130,6 @@ subs pc, lr, #4
|
||||||
@ Unimplemented
|
@ Unimplemented
|
||||||
SoftReset:
|
SoftReset:
|
||||||
RegisterRamReset:
|
RegisterRamReset:
|
||||||
Halt:
|
|
||||||
Stop:
|
Stop:
|
||||||
Div:
|
Div:
|
||||||
DivArm:
|
DivArm:
|
||||||
|
@ -156,6 +169,12 @@ SoundDriverVsyncOn:
|
||||||
NopCall:
|
NopCall:
|
||||||
bx lr
|
bx lr
|
||||||
|
|
||||||
|
Halt:
|
||||||
|
mov r2, #0
|
||||||
|
mov r12, #0x04000000
|
||||||
|
strb r2, [r12, #0x301]
|
||||||
|
bx lr
|
||||||
|
|
||||||
VBlankIntrWait:
|
VBlankIntrWait:
|
||||||
mov r0, #1
|
mov r0, #1
|
||||||
mov r1, #1
|
mov r1, #1
|
||||||
|
|
Loading…
Reference in New Issue