all repos — mgba @ c12b8e6e6db57c76a4e3622e10d25e93e43c9abc

mGBA Game Boy Advance Emulator

Merge branch 'master' into qt
Jeffrey Pfau jeffrey@endrift.com
Sat, 18 Oct 2014 01:06:35 -0700
commit

c12b8e6e6db57c76a4e3622e10d25e93e43c9abc

parent

2b012ef0bccfcc294d1c27efa69665430a35eb32

M CMakeLists.txtCMakeLists.txt

@@ -75,7 +75,7 @@ set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${PGO_POST_FLAGS}")

set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} ${PGO_POST_FLAGS}") endif() -add_definitions(-DBINARY_NAME="${BINARY_NAME}" -DPROJECT_NAME="${PROJECT_NAME}") +add_definitions(-DBINARY_NAME="${BINARY_NAME}" -DPROJECT_NAME="${PROJECT_NAME}" -DPROJECT_VERSION="${LIB_VERSION_STRING}") # Feature dependencies find_feature(USE_CLI_DEBUGGER "libedit")
M src/gba/gba-audio.csrc/gba/gba-audio.c

@@ -40,6 +40,8 @@ audio->ch3 = (struct GBAAudioChannel3) { .bank = { .bank = 0 } };

audio->ch4 = (struct GBAAudioChannel4) { .envelope = { .nextStep = INT_MAX } }; audio->chA.dmaSource = 0; audio->chB.dmaSource = 0; + audio->chA.sample = 0; + audio->chB.sample = 0; audio->eventDiff = 0; audio->nextSample = 0; audio->sampleRate = 0x8000;

@@ -672,13 +674,13 @@ return timing;

} static int _applyBias(struct GBAAudio* audio, int sample) { - sample += audio->bias; + sample += GBARegisterSOUNDBIASGetBias(audio->soundbias); if (sample >= 0x400) { sample = 0x3FF; } else if (sample < 0) { sample = 0; } - return (sample - audio->bias) << 6; + return (sample - GBARegisterSOUNDBIASGetBias(audio->soundbias)) << 6; } static void _sample(struct GBAAudio* audio) {
M src/gba/gba-audio.hsrc/gba/gba-audio.h

@@ -157,6 +157,10 @@ DECL_BIT(GBARegisterSOUNDCNT_X, PlayingCh3, 2);

DECL_BIT(GBARegisterSOUNDCNT_X, PlayingCh4, 3); DECL_BIT(GBARegisterSOUNDCNT_X, Enable, 7); +DECL_BITFIELD(GBARegisterSOUNDBIAS, uint16_t); +DECL_BITS(GBARegisterSOUNDBIAS, Bias, 0, 10); +DECL_BITS(GBARegisterSOUNDBIAS, Resolution, 14, 2); + struct GBAAudio { struct GBA* p;

@@ -200,14 +204,7 @@ bool enable;

unsigned sampleRate; - union { - struct { - unsigned bias : 10; - unsigned : 4; - unsigned resolution : 2; - }; - uint16_t soundbias; - }; + GBARegisterSOUNDBIAS soundbias; int32_t nextEvent; int32_t eventDiff;
M src/gba/gba-thread.csrc/gba/gba-thread.c

@@ -126,6 +126,8 @@ #endif

if (threadContext->audioBuffers) { GBAAudioResizeBuffer(&gba.audio, threadContext->audioBuffers); + } else { + threadContext->audioBuffers = GBA_AUDIO_SAMPLES; } if (threadContext->renderer) {

@@ -577,7 +579,7 @@ bool GBASyncDrawingFrame(struct GBASync* sync) {

return sync->videoFrameSkip <= 0; } -void GBASyncProduceAudio(struct GBASync* sync, int wait) { +void GBASyncProduceAudio(struct GBASync* sync, bool wait) { if (sync->audioWait && wait) { // TODO loop properly in event of spurious wakeups ConditionWait(&sync->audioRequiredCond, &sync->audioBufferMutex);
M src/gba/gba-thread.hsrc/gba/gba-thread.h

@@ -121,7 +121,7 @@ bool GBASyncWaitFrameStart(struct GBASync* sync, int frameskip);

void GBASyncWaitFrameEnd(struct GBASync* sync); bool GBASyncDrawingFrame(struct GBASync* sync); -void GBASyncProduceAudio(struct GBASync* sync, int wait); +void GBASyncProduceAudio(struct GBASync* sync, bool wait); void GBASyncLockAudio(struct GBASync* sync); void GBASyncUnlockAudio(struct GBASync* sync); void GBASyncConsumeAudio(struct GBASync* sync);
M src/gba/gba.csrc/gba/gba.c

@@ -626,6 +626,10 @@ void GBAGetGameCode(struct GBA* gba, char* out) {

memcpy(out, &((struct GBACartridge*) gba->memory.rom)->id, 4); } +void GBAGetGameTitle(struct GBA* gba, char* out) { + memcpy(out, &((struct GBACartridge*) gba->memory.rom)->title, 12); +} + void GBAHitStub(struct ARMCore* cpu, uint32_t opcode) { struct GBA* gba = (struct GBA*) cpu->master; enum GBALogLevel level = GBA_LOG_FATAL;
M src/gba/gba.hsrc/gba/gba.h

@@ -151,6 +151,7 @@ void GBAApplyPatch(struct GBA* gba, struct Patch* patch);

bool GBAIsROM(struct VFile* vf); void GBAGetGameCode(struct GBA* gba, char* out); +void GBAGetGameTitle(struct GBA* gba, char* out); __attribute__((format (printf, 3, 4))) void GBALog(struct GBA* gba, enum GBALogLevel level, const char* format, ...);
M src/platform/sdl/sdl-events.csrc/platform/sdl/sdl-events.c

@@ -171,9 +171,8 @@ case SDLK_F6:

case SDLK_F7: case SDLK_F8: case SDLK_F9: - case SDLK_F10: GBAThreadInterrupt(context); - GBASaveState(context->gba, context->stateDir, event->keysym.sym - SDLK_F1, true); + GBASaveState(context->gba, context->stateDir, event->keysym.sym - SDLK_F1 + 1, true); GBAThreadContinue(context); break; default:

@@ -190,9 +189,8 @@ case SDLK_F6:

case SDLK_F7: case SDLK_F8: case SDLK_F9: - case SDLK_F10: GBAThreadInterrupt(context); - GBALoadState(context->gba, context->stateDir, event->keysym.sym - SDLK_F1); + GBALoadState(context->gba, context->stateDir, event->keysym.sym - SDLK_F1 + 1); GBAThreadContinue(context); break; default: