mirror of https://github.com/mgba-emu/mgba.git
All: Make FIXED_ROM_BUFFER an option instead of 3DS-only
This commit is contained in:
parent
9150a79efd
commit
b71ffe711c
1
CHANGES
1
CHANGES
|
@ -5,6 +5,7 @@ Bugfixes:
|
|||
Misc:
|
||||
- GBA Timer: Use global cycles for timers
|
||||
- GBA: Extend oddly-sized ROMs to full address space (fixes mgba.io/i/722)
|
||||
- All: Make FIXED_ROM_BUFFER an option instead of 3DS-only
|
||||
|
||||
0.6.0: (Future)
|
||||
Features:
|
||||
|
|
|
@ -255,6 +255,10 @@ if(DEFINED 3DS OR DEFINED PSP2 OR DEFINED WII)
|
|||
set(USE_SQLITE3 OFF)
|
||||
endif()
|
||||
|
||||
if(DEFINED 3DS OR DEFINED WII)
|
||||
add_definitions(-DFIXED_ROM_BUFFER)
|
||||
endif()
|
||||
|
||||
if(NOT M_CORE_GBA)
|
||||
set(USE_GDB_STUB OFF)
|
||||
endif()
|
||||
|
|
|
@ -42,7 +42,7 @@ static void GBStop(struct LR35902Core* cpu);
|
|||
|
||||
static void _enableInterrupts(struct mTiming* timing, void* user, uint32_t cyclesLate);
|
||||
|
||||
#ifdef _3DS
|
||||
#ifdef FIXED_ROM_BUFFER
|
||||
extern uint32_t* romBuffer;
|
||||
extern size_t romBufferSize;
|
||||
#endif
|
||||
|
@ -109,7 +109,7 @@ bool GBLoadROM(struct GB* gb, struct VFile* vf) {
|
|||
gb->pristineRomSize = vf->size(vf);
|
||||
vf->seek(vf, 0, SEEK_SET);
|
||||
gb->isPristine = true;
|
||||
#ifdef _3DS
|
||||
#ifdef FIXED_ROM_BUFFER
|
||||
if (gb->pristineRomSize <= romBufferSize) {
|
||||
gb->memory.rom = romBuffer;
|
||||
vf->read(vf, romBuffer, gb->pristineRomSize);
|
||||
|
@ -277,7 +277,7 @@ void GBUnloadROM(struct GB* gb) {
|
|||
}
|
||||
|
||||
if (gb->romVf) {
|
||||
#ifndef _3DS
|
||||
#ifndef FIXED_ROM_BUFFER
|
||||
gb->romVf->unmap(gb->romVf, gb->memory.rom, gb->pristineRomSize);
|
||||
#endif
|
||||
gb->romVf->close(gb->romVf);
|
||||
|
@ -326,7 +326,7 @@ void GBApplyPatch(struct GB* gb, struct Patch* patch) {
|
|||
return;
|
||||
}
|
||||
if (gb->romVf) {
|
||||
#ifndef _3DS
|
||||
#ifndef FIXED_ROM_BUFFER
|
||||
gb->romVf->unmap(gb->romVf, gb->memory.rom, gb->pristineRomSize);
|
||||
#endif
|
||||
gb->romVf->close(gb->romVf);
|
||||
|
|
|
@ -42,7 +42,7 @@ static bool _setSoftwareBreakpoint(struct ARMDebugger*, uint32_t address, enum E
|
|||
static bool _clearSoftwareBreakpoint(struct ARMDebugger*, uint32_t address, enum ExecutionMode mode, uint32_t opcode);
|
||||
|
||||
|
||||
#ifdef _3DS
|
||||
#ifdef FIXED_ROM_BUFFER
|
||||
extern uint32_t* romBuffer;
|
||||
extern size_t romBufferSize;
|
||||
#endif
|
||||
|
@ -120,7 +120,7 @@ void GBAUnloadROM(struct GBA* gba) {
|
|||
}
|
||||
|
||||
if (gba->romVf) {
|
||||
#ifndef _3DS
|
||||
#ifndef FIXED_ROM_BUFFER
|
||||
gba->romVf->unmap(gba->romVf, gba->memory.rom, gba->pristineRomSize);
|
||||
#endif
|
||||
gba->romVf->close(gba->romVf);
|
||||
|
@ -323,7 +323,7 @@ bool GBALoadROM(struct GBA* gba, struct VFile* vf) {
|
|||
gba->pristineRomSize = SIZE_CART0;
|
||||
}
|
||||
gba->isPristine = true;
|
||||
#ifdef _3DS
|
||||
#ifdef FIXED_ROM_BUFFER
|
||||
if (gba->pristineRomSize <= romBufferSize) {
|
||||
gba->memory.rom = romBuffer;
|
||||
vf->read(vf, romBuffer, gba->pristineRomSize);
|
||||
|
@ -344,7 +344,7 @@ bool GBALoadROM(struct GBA* gba, struct VFile* vf) {
|
|||
GBAVFameDetect(&gba->memory.vfame, gba->memory.rom, gba->memory.romSize);
|
||||
if (popcount32(gba->memory.romSize) != 1) {
|
||||
// This ROM is either a bad dump or homebrew. Emulate flash cart behavior.
|
||||
#ifndef _3DS
|
||||
#ifndef FIXED_ROM_BUFFER
|
||||
void* newRom = anonymousMemoryMap(SIZE_CART0);
|
||||
memcpy(newRom, gba->memory.rom, gba->pristineRomSize);
|
||||
gba->memory.rom = newRom;
|
||||
|
@ -404,7 +404,7 @@ void GBAApplyPatch(struct GBA* gba, struct Patch* patch) {
|
|||
return;
|
||||
}
|
||||
if (gba->romVf) {
|
||||
#ifndef _3DS
|
||||
#ifndef FIXED_ROM_BUFFER
|
||||
gba->romVf->unmap(gba->romVf, gba->memory.rom, gba->pristineRomSize);
|
||||
#endif
|
||||
gba->romVf->close(gba->romVf);
|
||||
|
|
|
@ -1553,7 +1553,7 @@ void _pristineCow(struct GBA* gba) {
|
|||
gba->cpu->memory.activeRegion = newRom;
|
||||
}
|
||||
if (gba->romVf) {
|
||||
#ifndef _3DS
|
||||
#ifndef FIXED_ROM_BUFFER
|
||||
gba->romVf->unmap(gba->romVf, gba->memory.rom, gba->memory.romSize);
|
||||
#endif
|
||||
gba->romVf->close(gba->romVf);
|
||||
|
|
|
@ -24,6 +24,7 @@
|
|||
#include <mgba-util/gui/file-select.h>
|
||||
#include <mgba-util/gui/font.h>
|
||||
#include <mgba-util/gui/menu.h>
|
||||
#include <mgba-util/memory.h>
|
||||
#include <mgba-util/vfs.h>
|
||||
|
||||
#define GCN1_INPUT 0x47434E31
|
||||
|
@ -114,6 +115,9 @@ static bool frameLimiter = true;
|
|||
static int scaleFactor;
|
||||
static unsigned corew, coreh;
|
||||
|
||||
uint32_t* romBuffer;
|
||||
size_t romBufferSize;
|
||||
|
||||
static void* framebuffer[2] = { 0, 0 };
|
||||
static int whichFb = 0;
|
||||
|
||||
|
@ -242,6 +246,10 @@ int main(int argc, char* argv[]) {
|
|||
AUDIO_RegisterDMACallback(_audioDMA);
|
||||
|
||||
memset(audioBuffer, 0, sizeof(audioBuffer));
|
||||
#ifdef FIXED_ROM_BUFFER
|
||||
romBufferSize = SIZE_CART0;
|
||||
romBuffer = anonymousMemoryMap(romBufferSize);
|
||||
#endif
|
||||
|
||||
#if !defined(COLOR_16_BIT) && !defined(COLOR_5_6_5)
|
||||
#error This pixel format is unsupported. Please use -DCOLOR_16-BIT -DCOLOR_5_6_5
|
||||
|
@ -510,6 +518,10 @@ int main(int argc, char* argv[]) {
|
|||
}
|
||||
mGUIDeinit(&runner);
|
||||
|
||||
#ifdef FIXED_ROM_BUFFER
|
||||
mappedMemoryFree(romBuffer, romBufferSize);
|
||||
#endif
|
||||
|
||||
free(fifo);
|
||||
free(texmem);
|
||||
free(rescaleTexmem);
|
||||
|
|
Loading…
Reference in New Issue