DS GX: Add toon shading

This commit is contained in:
Vicki Pfau 2017-04-26 21:39:19 -07:00
parent cec4d48c8a
commit e211869c92
6 changed files with 49 additions and 1 deletions

View File

@ -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

View File

@ -169,7 +169,6 @@ Missing features on DS are
- Microphone
- Graphics:
- Edge marking/wireframe
- Toon shading
- Highlight shading
- Fog
- Clear depth

View File

@ -148,6 +148,8 @@ struct DSGXRenderer {
uint16_t* tex[4];
uint16_t* texPal[6];
uint16_t* toonTable;
};
struct DSGXLight {

View File

@ -1307,6 +1307,7 @@ void DSGXAssociateRenderer(struct DSGX* gx, struct DSGXRenderer* 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);
}

View File

@ -263,6 +263,16 @@ static color_t _lookupColor(struct DSGXSoftwareRenderer* renderer, struct DSGXSo
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);
}

View File

@ -821,6 +821,38 @@ uint16_t DS9IORead(struct DS* ds, uint32_t address) {
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: