Use a 4 bit buffer

pull/1916/head
Martin Boonk 2022-03-14 22:30:30 +01:00
parent 6f8a7b0534
commit ebce52ea13
2 changed files with 40 additions and 4 deletions

View File

@ -10,6 +10,36 @@ var endPerfLog = () => {};
var printPerfLog = () => print("Deactivated");
var resetPerfLog = () => {performanceLog = {};};
var colormap={
"#000":0,
"#00f":1,
"#0f0":2,
"#0ff":3,
"#f00":4,
"#f0f":5,
"#ff0":6,
"#fff":7
};
var palette = new Uint16Array([
0x0000, //black #000
0x001f, //blue #00f
0x07e0, //green #0f0
0x07ff, //cyan #0ff
0xf800, //red #f00
0xf81f, //magenta #f0f
0xffe0, //yellow #ff0
0xffff, //white #fff
0xffff, //white
0xffff, //white
0xffff, //white
0xffff, //white
0xffff, //white
0xffff, //white
0xffff, //white
0xffff, //white
])
var p0 = g;
var p1;

View File

@ -621,7 +621,7 @@
var lastSetColor;
var lastSetBgColor;
if (plane != 0) code += "if (!p" + plane + ") p" + plane + " = Graphics.createArrayBuffer(g.getWidth(),g.getHeight(),16,{msb:true});\n";
if (plane != 0) code += "if (!p" + plane + ") p" + plane + " = Graphics.createArrayBuffer(g.getWidth(),g.getHeight(),4,{msb:true});\n";
if (properties.Redraw && properties.Redraw.Clear){
if (wrapInTimeouts && plane != 0){
@ -646,7 +646,7 @@
if (addDebug()) code += 'print("Copying of plane ' + previousPlane + ' to display");'+"\n";
//code += "g.drawImage(p" + i + ".asImage());";
code += "p0.drawImage({width: p" + previousPlane + ".getWidth(), height: p" + previousPlane + ".getHeight(), bpp: p" + previousPlane + ".getBPP(), buffer: p" + previousPlane + ".buffer});\n";
code += "p0.drawImage({width: p" + previousPlane + ".getWidth(), height: p" + previousPlane + ".getHeight(), bpp: p" + previousPlane + ".getBPP(), buffer: p" + previousPlane + ".buffer, palette: palette});\n";
code += "drawingTime += Date.now() - ct;\n";
@ -716,11 +716,17 @@
var colorsetting = "";
if (c.value.ForegroundColor && lastSetColor != c.value.ForegroundColor){
lastSetColor = c.value.ForegroundColor;
colorsetting += planeName + ".setColor(\"" + c.value.ForegroundColor + "\");\n";
if (plane > 0)
colorsetting += planeName + ".setColor(colormap[\"" + c.value.ForegroundColor + "\"]);\n";
else
colorsetting += planeName + ".setColor(\"" + c.value.ForegroundColor + "\");\n";
}
if (c.value.BackgroundColor && lastSetBgColor != c.value.BackgroundColor){
lastSetBgColor = c.value.BackgroundColor;
colorsetting += planeName + ".setBgColor(\"" + c.value.BackgroundColor + "\");\n";
if (plane > 0)
colorsetting += planeName + ".setBgColor(colormap[\"" + c.value.BackgroundColor + "\"]);\n";
else
colorsetting += planeName + ".setBgColor(\"" + c.value.BackgroundColor + "\");\n";
}
if (addDebug()) code += 'print("Element condition is ' + condition + '");' + "\n";