From 0ae00ba860c06ed3229cac23a662754e7a50cabf Mon Sep 17 00:00:00 2001 From: helixhorned Date: Sun, 30 Mar 2014 13:53:05 +0000 Subject: [PATCH] Lunatic: add some shade/vis debugging functions. engine.lua: linearizeBasePal(), mapster32 only test/shadexfog.lua: create_depth_shtab(), create_vismarker_shtab() git-svn-id: https://svn.eduke32.com/eduke32@4404 1a8010ca-5511-0410-912e-c29ae57300e0 --- polymer/eduke32/source/lunatic/engine.lua | 22 ++++++++++++++ .../eduke32/source/lunatic/test/shadexfog.lua | 30 +++++++++++++++++++ 2 files changed, 52 insertions(+) diff --git a/polymer/eduke32/source/lunatic/engine.lua b/polymer/eduke32/source/lunatic/engine.lua index 259824c12..82af72fd3 100644 --- a/polymer/eduke32/source/lunatic/engine.lua +++ b/polymer/eduke32/source/lunatic/engine.lua @@ -6,6 +6,7 @@ local bcarray = require("bcarray") local assert = assert local error = error +local ipairs = ipairs local type = type local decl = assert(decl) -- comes from above (defs.ilua or defs_m32.lua) @@ -397,6 +398,27 @@ if (ismapster32) then end end end + + function engine.linearizeBasePal() + for _, begi in ipairs{0, 32, 96, 160} do + local ptr = C.basepaltable[0] + 3*begi + local refcol = ptr + 3*31 + + for i=0,30 do + for c=0,2 do + ptr[3*i + c] = i*refcol[c]/31 + end + end + end + + for _, begi in ipairs{128, 144, 192, 208, 224} do + local ptr = C.basepaltable[0] + 3*begi + + for i=0,3*15+2 do + ptr[i] = 0 + end + end + end end diff --git a/polymer/eduke32/source/lunatic/test/shadexfog.lua b/polymer/eduke32/source/lunatic/test/shadexfog.lua index f306ce053..d22d9e3df 100644 --- a/polymer/eduke32/source/lunatic/test/shadexfog.lua +++ b/polymer/eduke32/source/lunatic/test/shadexfog.lua @@ -133,6 +133,36 @@ end ---------- BASE SHADE TABLE TESTS ---------- +-- sht = shadexfog.create_depth_shtab([palnum]) +function shadexfog.create_depth_shtab(palnum) + local sht = engine.shadetab() + + for s=0,31 do + for i=0,255 do + sht[s][i] = s + end + end + + if (palnum) then + engine.setshadetab(palnum, sht) + end + return sht +end + +function shadexfog.create_vismarker_shtab(palnum) + local sht = engine.getshadetab(0) + + for i=0,255 do + sht[1][i] = 242 + sht[30][i] = 245 + end + + if (palnum) then + engine.setshadetab(palnum, sht) + end + return sht +end + -- Basic test of whether for a color index i corresponding to a color (r,g,b), -- getclosestcol() returns a color index ii corresponding to the same color. -- (In the Duke3D palette, there are duplicates, so the requirement i==ii is