all repos — mgba @ e159029e48902a642c39d427345951c388d93da5

mGBA Game Boy Advance Emulator

Wii: Reduce texture sizes
Jeffrey Pfau jeffrey@endrift.com
Thu, 01 Sep 2016 01:24:41 -0700
commit

e159029e48902a642c39d427345951c388d93da5

parent

80b97e747c4b1e286e24d40a2477eaddd314b095

1 files changed, 24 insertions(+), 19 deletions(-)

jump to
M src/platform/wii/main.csrc/platform/wii/main.c

@@ -30,6 +30,9 @@ #define GCN2_INPUT 0x47434E32

#define WIIMOTE_INPUT 0x5749494D #define CLASSIC_INPUT 0x57494943 +#define TEX_W 256 +#define TEX_H 160 + static void _mapKey(struct mInputMap* map, uint32_t binding, int nativeKey, enum GBAKey key) { mInputBindKey(map, binding, __builtin_ctz(nativeKey), key); }

@@ -280,12 +283,12 @@ guMtxTransApply(model, model, 0.0f, 0.0f, -6.0f);

guMtxConcat(view, model, modelview); GX_LoadPosMtxImm(modelview, GX_PNMTX0); - texmem = memalign(32, 256 * 256 * BYTES_PER_PIXEL); - memset(texmem, 0, 256 * 256 * BYTES_PER_PIXEL); - GX_InitTexObj(&tex, texmem, 256, 256, GX_TF_RGB565, GX_CLAMP, GX_CLAMP, GX_FALSE); - rescaleTexmem = memalign(32, 512 * 512 * BYTES_PER_PIXEL); - memset(rescaleTexmem, 0, 512 * 512 * BYTES_PER_PIXEL); - GX_InitTexObj(&rescaleTex, rescaleTexmem, 512, 512, GX_TF_RGB565, GX_CLAMP, GX_CLAMP, GX_FALSE); + texmem = memalign(32, TEX_W * TEX_H * BYTES_PER_PIXEL); + memset(texmem, 0, TEX_W * TEX_H * BYTES_PER_PIXEL); + GX_InitTexObj(&tex, texmem, TEX_W, TEX_H, GX_TF_RGB565, GX_CLAMP, GX_CLAMP, GX_FALSE); + rescaleTexmem = memalign(32, TEX_W * TEX_H * 4 * BYTES_PER_PIXEL); + memset(rescaleTexmem, 0, TEX_W * TEX_H * 4 * BYTES_PER_PIXEL); + GX_InitTexObj(&rescaleTex, rescaleTexmem, TEX_W * 2, TEX_H * 2, GX_TF_RGB565, GX_CLAMP, GX_CLAMP, GX_FALSE); GX_InitTexObjFilterMode(&rescaleTex, GX_LINEAR, GX_LINEAR); VIDEO_SetPostRetraceCallback(_retraceCallback);

@@ -685,8 +688,8 @@ desc = (struct mInputAxis) { GBA_KEY_UP, GBA_KEY_DOWN, 0x20, -0x20 };

mInputBindAxis(&runner->core->inputMap, GCN1_INPUT, 1, &desc); mInputBindAxis(&runner->core->inputMap, CLASSIC_INPUT, 1, &desc); - outputBuffer = memalign(32, 256 * 256 * BYTES_PER_PIXEL); - runner->core->setVideoBuffer(runner->core, outputBuffer, 256); + outputBuffer = memalign(32, TEX_W * TEX_H * BYTES_PER_PIXEL); + runner->core->setVideoBuffer(runner->core, outputBuffer, TEX_W); runner->core->setAudioBufferSize(runner->core, SAMPLES);

@@ -787,7 +790,7 @@ texdest[2 + x * 4 + y * 64] = texsrc[128 + x + y * 64];

texdest[3 + x * 4 + y * 64] = texsrc[192 + x + y * 64]; } } - DCFlushRange(texdest, 256 * 256 * BYTES_PER_PIXEL); + DCFlushRange(texdest, TEX_W * TEX_H * BYTES_PER_PIXEL); if (faded) { GX_SetBlendMode(GX_BM_BLEND, GX_BL_SRCALPHA, GX_BL_INVSRCALPHA, GX_LO_NOOP);

@@ -798,7 +801,8 @@ GX_InvalidateTexAll();

GX_LoadTexObj(&tex, GX_TEXMAP0); GX_SetVtxAttrFmt(GX_VTXFMT0, GX_VA_TEX0, GX_TEX_ST, GX_S16, 0); - s16 vertSize = 256; + s16 vertWidth = TEX_W; + s16 vertHeight = TEX_H; if (filterMode == FM_LINEAR_2x) { Mtx44 proj;

@@ -806,15 +810,15 @@ guOrtho(proj, 0, vmode->efbHeight, 0, vmode->fbWidth, 0, 300);

GX_LoadProjectionMtx(proj, GX_ORTHOGRAPHIC); GX_Begin(GX_QUADS, GX_VTXFMT0, 4); - GX_Position2s16(0, 512); + GX_Position2s16(0, TEX_H * 2); GX_Color1u32(0xFFFFFFFF); GX_TexCoord2s16(0, 1); - GX_Position2s16(512, 512); + GX_Position2s16(TEX_W * 2, TEX_H * 2); GX_Color1u32(0xFFFFFFFF); GX_TexCoord2s16(1, 1); - GX_Position2s16(512, 0); + GX_Position2s16(TEX_W * 2, 0); GX_Color1u32(0xFFFFFFFF); GX_TexCoord2s16(1, 0);

@@ -823,14 +827,15 @@ GX_Color1u32(0xFFFFFFFF);

GX_TexCoord2s16(0, 0); GX_End(); - GX_SetTexCopySrc(0, 0, 512, 512); - GX_SetTexCopyDst(512, 512, GX_TF_RGB565, GX_FALSE); + GX_SetTexCopySrc(0, 0, TEX_W * 2, TEX_H * 2); + GX_SetTexCopyDst(TEX_W * 2, TEX_H * 2, GX_TF_RGB565, GX_FALSE); GX_CopyTex(rescaleTexmem, GX_TRUE); GX_LoadTexObj(&rescaleTex, GX_TEXMAP0); } if (screenMode == SM_PA) { - vertSize *= scaleFactor; + vertWidth *= scaleFactor; + vertHeight *= scaleFactor; } if (screenMode == SM_PA) {

@@ -840,15 +845,15 @@ _reproj2(corew, coreh);

} GX_Begin(GX_QUADS, GX_VTXFMT0, 4); - GX_Position2s16(0, vertSize); + GX_Position2s16(0, vertHeight); GX_Color1u32(color); GX_TexCoord2s16(0, 1); - GX_Position2s16(vertSize, vertSize); + GX_Position2s16(vertWidth, vertHeight); GX_Color1u32(color); GX_TexCoord2s16(1, 1); - GX_Position2s16(vertSize, 0); + GX_Position2s16(vertWidth, 0); GX_Color1u32(color); GX_TexCoord2s16(1, 0);