Skip to content

Commit

Permalink
clut buffer updates
Browse files Browse the repository at this point in the history
  • Loading branch information
phoddie committed Dec 31, 2021
1 parent c9ab6db commit a808e40
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 10 deletions.
6 changes: 3 additions & 3 deletions modules/drivers/ili9341/modIli9341.c
Original file line number Diff line number Diff line change
Expand Up @@ -357,12 +357,12 @@ void xs_ILI9341_set_clut(xsMachine *the)
{
#if kCommodettoBitmapFormat == kCommodettoBitmapCLUT16
spiDisplay sd = xsmcGetHostData(xsThis);
void data;
void *data;
xsUnsignedValue dataSize;

xsmcGetHostBuffer(xsArg(0), &data, &dataSize);
xsmcGetBufferReadable(xsArg(0), &data, &dataSize);
if (dataSize > sizeof(sd->clut))
xsUnknownError("invalild");
xsUnknownError("invalid");

c_memmove(sd->clut, data, dataSize);
sd->haveCLUT = 1;
Expand Down
21 changes: 14 additions & 7 deletions modules/piu/MC/piuView.c
Original file line number Diff line number Diff line change
Expand Up @@ -1167,7 +1167,7 @@ void PiuApplication_animateColors(xsMachine* the)
PiuColorRecord color;
PocoColor colors[16];
xsIntegerValue i = 0;
xsVars(2);
xsVars(3);
while (i < 16) {
xsVar(0) = xsGetAt(xsArg(0), xsInteger(i));
PiuColorDictionary(the, &xsVar(0), &color);
Expand All @@ -1176,10 +1176,17 @@ void PiuApplication_animateColors(xsMachine* the)
}
xsVar(0) = xsReference((*view)->screen);
xsVar(1) = xsNewHostObject(NULL);
xsSetHostData(xsVar(1), colors);
xsVar(1) = xsCall1(xsVar(0), xsID_animateColors, xsVar(1));
if (xsTest(xsVar(1)))
PiuViewInvalidate(view, NULL);
xsSetHostBuffer(xsVar(1), colors, 16 * 2);
xsTry {
xsVar(2) = xsCall1(xsVar(0), xsID_animateColors, xsVar(1));
xsSetHostBuffer(xsVar(1), NULL, 0);
if (xsTest(xsVar(2)))
PiuViewInvalidate(view, NULL);
}
xsCatch {
xsSetHostBuffer(xsVar(1), NULL, 0);
xsThrow(xsException);
}
#endif
}

Expand All @@ -1191,7 +1198,7 @@ void PiuApplication_get_clut(xsMachine* the)
Poco poco = (*view)->poco;
xsVars(1);
xsResult = xsNewHostObject(NULL);
xsSetHostData(xsResult, poco->clut);
xsSetHostBuffer(xsResult, poco->clut, 16 * 2);
#endif
}

Expand All @@ -1205,7 +1212,7 @@ void PiuApplication_set_clut(xsMachine* the)
xsVars(2);
xsVar(0) = xsReference((*view)->screen);
xsVar(1) = xsNewHostObject(NULL);
xsSetHostData(xsVar(1), (16 * 16 * 16) + (16 * 2) + (uint8_t *)poco->clut);
xsSetHostBuffer(xsVar(1), (16 * 16 * 16) + (16 * 2) + (uint8_t *)poco->clut, 16 * 2);
xsSet(xsVar(0), xsID_clut, xsVar(1));
PiuViewInvalidate(view, NULL);
#endif
Expand Down

0 comments on commit a808e40

Please sign in to comment.