mirror of https://github.com/mgba-emu/mgba.git
DS GX: Add color modulation
This commit is contained in:
parent
c29dd3c1d3
commit
9b5bda237a
|
@ -47,6 +47,16 @@ DECL_BITS(DSGXTexParams, Format, 26, 3);
|
|||
DECL_BIT(DSGXTexParams, 0Transparent, 29);
|
||||
DECL_BITS(DSGXTexParams, CoordTfMode, 30, 2);
|
||||
|
||||
DECL_BITFIELD(DSGXPolygonAttrs, uint32_t);
|
||||
DECL_BIT(DSGXPolygonAttrs, Light0, 0);
|
||||
DECL_BIT(DSGXPolygonAttrs, Light1, 1);
|
||||
DECL_BIT(DSGXPolygonAttrs, Light2, 2);
|
||||
DECL_BIT(DSGXPolygonAttrs, Light3, 3);
|
||||
DECL_BITS(DSGXPolygonAttrs, Mode, 4, 2);
|
||||
DECL_BIT(DSGXPolygonAttrs, FrontFace, 6);
|
||||
DECL_BIT(DSGXPolygonAttrs, BackFace, 7);
|
||||
// TODO
|
||||
|
||||
enum DSGXCommand {
|
||||
DS_GX_CMD_NOP = 0,
|
||||
DS_GX_CMD_MTX_MODE = 0x10,
|
||||
|
|
|
@ -20,6 +20,7 @@ struct DSGXSoftwarePolygon {
|
|||
uint16_t* texBase;
|
||||
uint16_t* palBase;
|
||||
int texFormat;
|
||||
int blendFormat;
|
||||
int texW;
|
||||
int texH;
|
||||
};
|
||||
|
|
|
@ -109,9 +109,20 @@ static color_t _lookupColor(struct DSGXSoftwareEndpoint* ep, struct DSGXSoftware
|
|||
return FLAG_UNWRITTEN;
|
||||
}
|
||||
uint8_t r, g, b;
|
||||
unsigned wr, wg, wb;
|
||||
texel = poly->palBase[texel];
|
||||
_expandColor(texel, &r, &g, &b);
|
||||
switch (poly->blendFormat) {
|
||||
case 1:
|
||||
default:
|
||||
// TODO: Alpha
|
||||
return _finishColor(r, g, b);
|
||||
case 0:
|
||||
wr = ((r + 1) * (ep->cr + 1) - 1) >> 6;
|
||||
wg = ((g + 1) * (ep->cg + 1) - 1) >> 6;
|
||||
wb = ((b + 1) * (ep->cb + 1) - 1) >> 6;
|
||||
return _finishColor(wr, wg, wb);
|
||||
}
|
||||
}
|
||||
|
||||
static int _edgeSort(const void* a, const void* b) {
|
||||
|
@ -285,6 +296,7 @@ static void DSGXSoftwareRendererSetRAM(struct DSGXRenderer* renderer, struct DSG
|
|||
struct DSGXSoftwareEdge* edge = DSGXSoftwareEdgeListAppend(&softwareRenderer->activeEdges);
|
||||
poly->poly = &polys[i];
|
||||
poly->texFormat = DSGXTexParamsGetFormat(poly->poly->texParams);
|
||||
poly->blendFormat = DSGXPolygonAttrsGetMode(poly->poly->polyParams);
|
||||
poly->texW = 8 << DSGXTexParamsGetSSize(poly->poly->texParams);
|
||||
poly->texH = 8 << DSGXTexParamsGetTSize(poly->poly->texParams);
|
||||
switch (poly->texFormat) {
|
||||
|
|
Loading…
Reference in New Issue