all repos — mgba @ bc88f2369282b078ce011bf6c625ccc8693dcf89

mGBA Game Boy Advance Emulator

3DS: Update for new citro3d
Vicki Pfau vi@endrift.com
Sat, 19 May 2018 11:34:17 -0700
commit

bc88f2369282b078ce011bf6c625ccc8693dcf89

parent

7c058ea13ff03f78d0610944747ebfaabbd24bb4

2 files changed, 9 insertions(+), 17 deletions(-)

jump to
M src/platform/3ds/ctr-gpu.csrc/platform/3ds/ctr-gpu.c

@@ -133,7 +133,7 @@ activeTexture = texture;

C3D_TexBind(0, activeTexture); C3D_TexEnv* env = C3D_GetTexEnv(0); - C3D_TexEnvOp(env, C3D_Both, 0, 0, 0); + C3D_TexEnvInit(env); if (texture->fmt < GPU_LA8) { C3D_TexEnvSrc(env, C3D_Both, GPU_TEXTURE0, GPU_PRIMARY_COLOR, 0); C3D_TexEnvFunc(env, C3D_Both, GPU_MODULATE);

@@ -144,11 +144,11 @@ C3D_TexEnvFunc(env, C3D_RGB, GPU_REPLACE);

C3D_TexEnvFunc(env, C3D_Alpha, GPU_MODULATE); } env = C3D_GetTexEnv(1); - C3D_TexEnvOp(env, C3D_Both, 0, 0, 0); + C3D_TexEnvInit(env); C3D_TexEnvSrc(env, C3D_Both, GPU_PREVIOUS, 0, 0); C3D_TexEnvFunc(env, C3D_Both, GPU_REPLACE); env = C3D_GetTexEnv(2); - C3D_TexEnvOp(env, C3D_Both, 0, 0, 0); + C3D_TexEnvInit(env); C3D_TexEnvSrc(env, C3D_Both, GPU_PREVIOUS, 0, 0); C3D_TexEnvFunc(env, C3D_Both, GPU_REPLACE);

@@ -164,14 +164,14 @@ }

void ctrTextureMultiply(void) { C3D_TexEnv* env = C3D_GetTexEnv(1); - C3D_TexEnvOp(env, C3D_Both, 0, 0, 0); + C3D_TexEnvInit(env); C3D_TexEnvSrc(env, C3D_Both, GPU_PREVIOUS, GPU_TEXTURE0, 0); C3D_TexEnvFunc(env, C3D_Both, GPU_MODULATE); } void ctrTextureBias(u32 color) { C3D_TexEnv* env = C3D_GetTexEnv(2); - C3D_TexEnvOp(env, C3D_Both, 0, 0, 0); + C3D_TexEnvInit(env); C3D_TexEnvSrc(env, C3D_Both, GPU_PREVIOUS, GPU_CONSTANT, 0); C3D_TexEnvFunc(env, C3D_Both, GPU_ADD); C3D_TexEnvColor(env, color);
M src/platform/3ds/main.csrc/platform/3ds/main.c

@@ -87,7 +87,6 @@ // TODO: Move into context

static void* outputBuffer; static struct mAVStream stream; static int16_t* audioLeft = 0; -static int16_t* audioRight = 0; static size_t audioPos = 0; static C3D_Tex outputTexture; static ndspWaveBuf dspBuffer[DSP_BUFFERS];

@@ -127,8 +126,6 @@ upscaleBuffer = C3D_RenderTargetCreateFromTex(&upscaleBufferTex, GPU_TEXFACE_2D, 0, 0);

if (!upscaleBuffer) { return false; } - - C3D_RenderTargetSetClear(upscaleBuffer, C3D_CLEAR_COLOR, 0, 0); return ctrInitGpu(); }

@@ -183,6 +180,8 @@

static void _postAudioBuffer(struct mAVStream* stream, blip_t* left, blip_t* right); static void _drawStart(void) { + C3D_FrameBufClear(&bottomScreen[doubleBuffer]->frameBuf, C3D_CLEAR_COLOR, 0, 0); + C3D_FrameBufClear(&topScreen[doubleBuffer]->frameBuf, C3D_CLEAR_COLOR, 0, 0); } static void _frameStart(void) {

@@ -199,9 +198,6 @@ tickCounter = svcGetSystemTick();

} } C3D_FrameBegin(flags); - // Mark both buffers used to make sure they get cleared - C3D_FrameDrawOn(topScreen[doubleBuffer]); - C3D_FrameDrawOn(bottomScreen[doubleBuffer]); ctrStartFrame(); }

@@ -216,8 +212,6 @@ C3D_FrameEnd(GX_CMDLIST_FLUSH);

frameStarted = false; doubleBuffer ^= 1; - C3D_FrameBufClear(&bottomScreen[doubleBuffer]->frameBuf, C3D_CLEAR_COLOR, 0, 0); - C3D_FrameBufClear(&topScreen[doubleBuffer]->frameBuf, C3D_CLEAR_COLOR, 0, 0); } static int _batteryState(void) {

@@ -555,7 +549,7 @@

C3D_Tex* tex = &outputTexture; GSPGPU_FlushDataCache(outputBuffer, 256 * VIDEO_VERTICAL_PIXELS * 2); - C3D_SafeDisplayTransfer( + C3D_SyncDisplayTransfer( outputBuffer, GX_BUFFER_DIM(256, VIDEO_VERTICAL_PIXELS), tex->data, GX_BUFFER_DIM(256, 256), GX_TRANSFER_IN_FORMAT(GX_TRANSFER_FMT_RGB565) |

@@ -567,7 +561,6 @@ blip_clear(runner->core->getAudioChannel(runner->core, 0));

blip_clear(runner->core->getAudioChannel(runner->core, 1)); } - gspWaitForPPF(); _drawTex(runner->core, faded); }

@@ -584,13 +577,12 @@ memset(&newPixels[y * 256 + width], 0, (256 - width) * sizeof(color_t));

} GSPGPU_FlushDataCache(newPixels, 256 * height * sizeof(u32)); - C3D_SafeDisplayTransfer( + C3D_SyncDisplayTransfer( (u32*) newPixels, GX_BUFFER_DIM(256, height), tex->data, GX_BUFFER_DIM(256, 256), GX_TRANSFER_IN_FORMAT(GX_TRANSFER_FMT_RGB565) | GX_TRANSFER_OUT_FORMAT(GX_TRANSFER_FMT_RGB565) | GX_TRANSFER_OUT_TILED(1) | GX_TRANSFER_FLIP_VERT(1)); - gspWaitForPPF(); linearFree(newPixels); _drawTex(runner->core, faded);