all repos — mgba @ b71ffe711c4ccb485b3b1171d65a4e1449640397

mGBA Game Boy Advance Emulator

All: Make FIXED_ROM_BUFFER an option instead of 3DS-only
Vicki Pfau vi@endrift.com
Sun, 09 Jul 2017 10:53:30 -0700
commit

b71ffe711c4ccb485b3b1171d65a4e1449640397

parent

9150a79efd85450df02ba70908dbfcc3f27924b2

6 files changed, 27 insertions(+), 10 deletions(-)

jump to
M CHANGESCHANGES

@@ -5,6 +5,7 @@ - GB Audio: Make audio unsigned with bias (fixes mgba.io/i/749)

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:
M CMakeLists.txtCMakeLists.txt

@@ -255,6 +255,10 @@ set(USE_DEBUGGERS OFF)

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()
M src/gb/gb.csrc/gb/gb.c

@@ -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 @@ gb->romVf = 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 @@ mappedMemoryFree(gb->memory.rom, GB_SIZE_CART_MAX);

} 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 @@ mappedMemoryFree(newRom, GB_SIZE_CART_MAX);

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);
M src/gba/gba.csrc/gba/gba.c

@@ -42,7 +42,7 @@ static bool _setSoftwareBreakpoint(struct ARMDebugger*, uint32_t address, enum ExecutionMode mode, uint32_t* opcode);

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 @@ mappedMemoryFree(gba->memory.rom, SIZE_CART0);

} 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 @@ if (gba->pristineRomSize > SIZE_CART0) {

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 @@ GBAHardwareInit(&gba->memory.hw, &((uint16_t*) gba->memory.rom)[GPIO_REG_DATA >> 1]);

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 @@ mappedMemoryFree(newRom, SIZE_CART0);

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);
M src/gba/memory.csrc/gba/memory.c

@@ -1553,7 +1553,7 @@ if (gba->cpu->memory.activeRegion == gba->memory.rom) {

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);
M src/platform/wii/main.csrc/platform/wii/main.c

@@ -24,6 +24,7 @@ #include <mgba-util/gui.h>

#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

@@ -113,6 +114,9 @@ static uint32_t referenceRetraceCount;

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 @@ AUDIO_SetDSPSampleRate(AI_SAMPLERATE_48KHZ);

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

@@ -509,6 +517,10 @@ } else {

mGUIRunloop(&runner); } mGUIDeinit(&runner); + +#ifdef FIXED_ROM_BUFFER + mappedMemoryFree(romBuffer, romBufferSize); +#endif free(fifo); free(texmem);