mirror of https://github.com/mgba-emu/mgba.git
GBA: Refine multiboot detection (fixes #2192)
This commit is contained in:
parent
5b26099eac
commit
91911fe092
1
CHANGES
1
CHANGES
|
@ -47,6 +47,7 @@ Misc:
|
|||
- Debugger: Save and restore CLI history
|
||||
- GB Video: Add default SGB border
|
||||
- GBA: Automatically skip BIOS if ROM has invalid logo
|
||||
- GBA: Refine multiboot detection (fixes mgba.io/i/2192)
|
||||
- GBA DMA: Enhanced logging (closes mgba.io/i/2454)
|
||||
- GBA Video: Implement layer placement for OpenGL renderer (fixes mgba.io/i/1962)
|
||||
- mGUI: Add margin to right-aligned menu text (fixes mgba.io/i/871)
|
||||
|
|
|
@ -672,6 +672,10 @@ bool GBAIsMB(struct VFile* vf) {
|
|||
}
|
||||
|
||||
uint32_t pc = GBA_MB_MAGIC_OFFSET;
|
||||
int wramAddrs = 0;
|
||||
int wramLoads = 0;
|
||||
int romAddrs = 0;
|
||||
int romLoads = 0;
|
||||
int i;
|
||||
for (i = 0; i < 80; ++i) {
|
||||
if (vf->read(vf, &signature, sizeof(signature)) != sizeof(signature)) {
|
||||
|
@ -679,6 +683,12 @@ bool GBAIsMB(struct VFile* vf) {
|
|||
}
|
||||
pc += 4;
|
||||
LOAD_32(opcode, 0, &signature);
|
||||
if ((opcode & ~0x7FF) == BASE_WORKING_RAM) {
|
||||
++wramAddrs;
|
||||
}
|
||||
if ((opcode & ~0x7FF) == BASE_CART0) {
|
||||
++romAddrs;
|
||||
}
|
||||
ARMDecodeARM(opcode, &info);
|
||||
if (info.mnemonic != ARM_MN_LDR) {
|
||||
continue;
|
||||
|
@ -700,10 +710,19 @@ bool GBAIsMB(struct VFile* vf) {
|
|||
break;
|
||||
}
|
||||
if ((immediate & ~0x7FF) == BASE_WORKING_RAM) {
|
||||
++wramLoads;
|
||||
}
|
||||
if ((immediate & ~0x7FF) == BASE_CART0) {
|
||||
++romLoads;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (romLoads + romAddrs > 2) {
|
||||
return false;
|
||||
}
|
||||
if (wramLoads + wramAddrs) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
// Found a libgba-linked cart...these are a bit harder to detect.
|
||||
return false;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue