all repos — mgba @ e211869c921939b9d212bd85c5dad1259d85bbae

mGBA Game Boy Advance Emulator

DS GX: Add toon shading
Vicki Pfau vi@endrift.com
Wed, 26 Apr 2017 21:39:19 -0700
commit

e211869c921939b9d212bd85c5dad1259d85bbae

parent

cec4d48c8afb49e7e81e0e3e5eeeb7588331bc32

6 files changed, 49 insertions(+), 1 deletions(-)

jump to
M CHANGESCHANGES

@@ -1,3 +1,7 @@

+medusa alpha 3 (Future) +Features: + - DS GX: Toon shading + 0.6.0: (Future) Features: - GBA: Support printing debug strings from inside a game
M README.mdREADME.md

@@ -169,7 +169,6 @@ - Sound output capture

- Microphone - Graphics: - Edge marking/wireframe - - Toon shading - Highlight shading - Fog - Clear depth
M include/mgba/internal/ds/gx.hinclude/mgba/internal/ds/gx.h

@@ -148,6 +148,8 @@ void (*writeRegister)(struct DSGXRenderer* renderer, uint32_t address, uint16_t value);

uint16_t* tex[4]; uint16_t* texPal[6]; + + uint16_t* toonTable; }; struct DSGXLight {
M src/ds/gx.csrc/ds/gx.c

@@ -1307,6 +1307,7 @@ gx->renderer->deinit(gx->renderer);

gx->renderer = renderer; memcpy(gx->renderer->tex, gx->tex, sizeof(gx->renderer->tex)); memcpy(gx->renderer->texPal, gx->texPal, sizeof(gx->renderer->texPal)); + gx->renderer->toonTable = &gx->p->memory.io9[DS9_REG_TOON_TABLE_00 >> 1]; gx->renderer->init(gx->renderer); }
M src/ds/gx/software.csrc/ds/gx/software.c

@@ -263,6 +263,16 @@ wr = (r * ta + ep->cr * (63 - ta)) >> 6;

wg = (g * ta + ep->cg * (63 - ta)) >> 6; wb = (b * ta + ep->cb * (63 - ta)) >> 6; return _finishColor(wr, wg, wb, pa); + case 2: { + uint8_t tr, tg, tb; + _expandColor(renderer->d.toonTable[ep->cr >> 1], &tr, &tg, &tb); + // TODO: highlight mode + wr = ((r + 1) * (tr + 1) - 1) >> 6; + wg = ((g + 1) * (tg + 1) - 1) >> 6; + wb = ((b + 1) * (tb + 1) - 1) >> 6; + wa = ((ta + 1) * (pa + 1) - 1) >> 6; + return _finishColor(wr, wg, wb, pa); + } case 3: return _finishColor(r, g, b, pa); }
M src/ds/io.csrc/ds/io.c

@@ -821,6 +821,38 @@ case DS9_REG_SQRT_PARAM_3:

case DS9_REG_SQRT_RESULT_LO: case DS9_REG_SQRT_RESULT_HI: case DS_REG_POSTFLG: + case DS9_REG_TOON_TABLE_00: + case DS9_REG_TOON_TABLE_01: + case DS9_REG_TOON_TABLE_02: + case DS9_REG_TOON_TABLE_03: + case DS9_REG_TOON_TABLE_04: + case DS9_REG_TOON_TABLE_05: + case DS9_REG_TOON_TABLE_06: + case DS9_REG_TOON_TABLE_07: + case DS9_REG_TOON_TABLE_08: + case DS9_REG_TOON_TABLE_09: + case DS9_REG_TOON_TABLE_0A: + case DS9_REG_TOON_TABLE_0B: + case DS9_REG_TOON_TABLE_0C: + case DS9_REG_TOON_TABLE_0D: + case DS9_REG_TOON_TABLE_0E: + case DS9_REG_TOON_TABLE_0F: + case DS9_REG_TOON_TABLE_10: + case DS9_REG_TOON_TABLE_11: + case DS9_REG_TOON_TABLE_12: + case DS9_REG_TOON_TABLE_13: + case DS9_REG_TOON_TABLE_14: + case DS9_REG_TOON_TABLE_15: + case DS9_REG_TOON_TABLE_16: + case DS9_REG_TOON_TABLE_17: + case DS9_REG_TOON_TABLE_18: + case DS9_REG_TOON_TABLE_19: + case DS9_REG_TOON_TABLE_1A: + case DS9_REG_TOON_TABLE_1B: + case DS9_REG_TOON_TABLE_1C: + case DS9_REG_TOON_TABLE_1D: + case DS9_REG_TOON_TABLE_1E: + case DS9_REG_TOON_TABLE_1F: case DS9_REG_GXSTAT_LO: case DS9_REG_GXSTAT_HI: case DS9_REG_CLIPMTX_RESULT_00: