From 9023198e237f02e9e758e65d45ce8d2599eb810a Mon Sep 17 00:00:00 2001 From: otya128 Date: Mon, 19 Dec 2016 23:21:25 +0900 Subject: [PATCH] Implement Graphic2.gloadPalette --- SMILEBASIC/graphic.d | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/SMILEBASIC/graphic.d b/SMILEBASIC/graphic.d index ab529bf..288c8b6 100644 --- a/SMILEBASIC/graphic.d +++ b/SMILEBASIC/graphic.d @@ -315,6 +315,11 @@ class Graphic GraphicFBO gfbo = (cast(GraphicFBO)this); gfbo.gloadPalette(x, y, w, h, array, palette, copymode); } + if (cast(Graphic2)this) + { + Graphic2 g = (cast(Graphic2)this); + g.gloadPalette(x, y, w, h, array, palette, copymode); + } } int[2] gprios = [511, 511]; @@ -1220,4 +1225,23 @@ class Graphic2 : Graphic gloadTempl(x, y, w, h, array, flag, copymode); } + void gloadPalette(T, T2)(int x, int y, int w, int h, T[] array, T2[] palette, int copymode) + if ((is(T == int) || is(T == double)) && (is(T2 == int) || is(T2 == double))) + { + int arrayH = h, arrayW = w; + int sx, sy; + if (clipXYWH(writeArea[petitcom.displaynum], x, y, w, h, sx, sy, w, h)) + return; + for (int iy = sy; iy < h; iy++) + { + for (int ix = sx; ix < w; ix++) + { + auto c = cast(int)palette[cast(int)array[iy * arrayW + ix]]; + c = convertColor(c); + if (copymode || c >> 24) + *(buffer + (iy + y) * width + (x + ix)) = c; + } + } + df = true; + } }