From 75f5449e9ae8eb8f5046360cf5b4637d53deb115 Mon Sep 17 00:00:00 2001 From: helixhorned Date: Tue, 31 Dec 2013 11:51:57 +0000 Subject: [PATCH] build.lua: add a flag toggling multiplication of the color components by 4. git-svn-id: https://svn.eduke32.com/eduke32@4235 1a8010ca-5511-0410-912e-c29ae57300e0 --- polymer/eduke32/source/lunatic/util/build.lua | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/polymer/eduke32/source/lunatic/util/build.lua b/polymer/eduke32/source/lunatic/util/build.lua index bf54f9bc6..4db852b31 100644 --- a/polymer/eduke32/source/lunatic/util/build.lua +++ b/polymer/eduke32/source/lunatic/util/build.lua @@ -127,10 +127,11 @@ local function doread(fh, basectype, numelts, dontclose) end -- Read base palette (i.e. first 768 bytes as R,G,B triplets) from a PALETTE.DAT. +-- : if true, don't multiply components by 4 -- Returns: -- on success: cdata (palette values scaled by 4) -- on failure: nil, -function read_basepal(filename) +function read_basepal(filename, noquad) local fh, errmsg = io.open(filename, "rb") if (fh == nil) then return nil, errmsg @@ -139,8 +140,10 @@ function read_basepal(filename) local palette, errmsg = doread(fh, "uint8_t", 768, true) fh:close() + local f = noquad and 1 or 4 + for i=0,768-1 do - palette[i] = 4*palette[i] + palette[i] = f*palette[i] end return palette, errmsg