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
This commit is contained in:
helixhorned 2014-03-30 13:53:05 +00:00
parent e7d0c0abcb
commit 0ae00ba860
2 changed files with 52 additions and 0 deletions

View file

@ -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

View file

@ -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