From 49290a090c815f9a0eb7c5289aa0a056f100f27a Mon Sep 17 00:00:00 2001 From: helixhorned Date: Fri, 5 Apr 2013 17:53:03 +0000 Subject: [PATCH] Lunatic: make palette_t a bcarray-generated type, various tweaks. - Increase LuaJIT max. machine code limit to 10 MiB git-svn-id: https://svn.eduke32.com/eduke32@3641 1a8010ca-5511-0410-912e-c29ae57300e0 --- polymer/eduke32/source/lunatic/bcarray.lua | 6 +++++- polymer/eduke32/source/lunatic/con_lang.lua | 2 +- polymer/eduke32/source/lunatic/defs.ilua | 2 ++ polymer/eduke32/source/lunatic/defs_common.lua | 15 ++++++--------- polymer/eduke32/source/lunatic/test.elua | 4 ++-- 5 files changed, 16 insertions(+), 13 deletions(-) diff --git a/polymer/eduke32/source/lunatic/bcarray.lua b/polymer/eduke32/source/lunatic/bcarray.lua index 5b249ddd5..85b704505 100644 --- a/polymer/eduke32/source/lunatic/bcarray.lua +++ b/polymer/eduke32/source/lunatic/bcarray.lua @@ -101,7 +101,11 @@ function new(basetype, numelts, showname, typename, rng, mtadd) local bcarray_t = ffi.typeof(cdeclstr, ffi.typeof(basetype)); bcarray_t = ffi.metatype(bcarray_t, mt) - assert(ffi.sizeof(bcarray_t) == ffi.sizeof(basetype)*numelts) + if (not (rng and rng.getu32==nil)) then + -- When passing a member name table, it is allowed to have a different + -- number of named members than array elements. + assert(ffi.sizeof(bcarray_t) == ffi.sizeof(basetype)*numelts) + end if (typename ~= nil) then -- Register the type name in the global namespace. diff --git a/polymer/eduke32/source/lunatic/con_lang.lua b/polymer/eduke32/source/lunatic/con_lang.lua index 80981d157..332c8917b 100644 --- a/polymer/eduke32/source/lunatic/con_lang.lua +++ b/polymer/eduke32/source/lunatic/con_lang.lua @@ -659,7 +659,7 @@ local PlayerLabels = { palette = PL".palette", -- NOTE the special case: - pals = PL"._pals.col[%s]", + pals = PL"._pals[%s]", pals_time = PL"._pals.f", name = {}, diff --git a/polymer/eduke32/source/lunatic/defs.ilua b/polymer/eduke32/source/lunatic/defs.ilua index 36303fd6d..33765e495 100644 --- a/polymer/eduke32/source/lunatic/defs.ilua +++ b/polymer/eduke32/source/lunatic/defs.ilua @@ -25,6 +25,8 @@ local tonumber = tonumber local tostring = tostring local type = type +require("jit.opt").start("maxmcode=10240") -- in KiB + -- The "gv" global will provide access to C global *scalars* and safe functions. -- NOTE: This exposes C library functions from e.g. the global C namespace, but -- without their declarations, they will be sitting there like a stone. diff --git a/polymer/eduke32/source/lunatic/defs_common.lua b/polymer/eduke32/source/lunatic/defs_common.lua index 5833048b8..a56355367 100644 --- a/polymer/eduke32/source/lunatic/defs_common.lua +++ b/polymer/eduke32/source/lunatic/defs_common.lua @@ -20,7 +20,7 @@ if (bit.band(ffiC._DEBUG_LUNATIC, 2)~=0) then end if (bit.band(ffiC._DEBUG_LUNATIC, 8)~=0) then - require("dump").on("T") -- raw text output + require("dump").on("+rs") elseif (bit.band(ffiC._DEBUG_LUNATIC, 4)~=0) then require("v").on() end @@ -154,10 +154,8 @@ ffi.typeof(SPRITE_STRUCT)) -- Define the "palette_t" type, which for us has .{r,g,b} fields and a -- bound-checking array of length 3 overlaid. --- TODO: bcarray really should allow to simply declare the struct with --- passed member names instead of "hidden" ones... because wrapping it --- in a union like this is doing things inside-out really. -local rgbarray_t = require("bcarray").new("uint8_t", 3, "RGB array") +local rgbarray_t = require("bcarray").new("uint8_t", 3, "RGB array", "palette_t", + { "r", "g", "b", "f" }) ffi.cdef("typedef union { \ struct { uint8_t r, g, b, f; }; \ $ col; \ @@ -870,13 +868,12 @@ function cansee(pos1,sect1, pos2,sect2) return (ret~=0) end -ffi.cdef[[ -typedef struct { +local neartag_ret_ct = ffi.typeof[[ +const struct { int32_t sector, wall, sprite; int32_t dist; -} neartag_ret_t; +} ]] -local neartag_ret_ct = ffi.typeof("const neartag_ret_t") local function newar() return ffi.new("int16_t [1]") end -- TODO: make tagsearch something more convenient diff --git a/polymer/eduke32/source/lunatic/test.elua b/polymer/eduke32/source/lunatic/test.elua index 53dfe1ff5..9e002a96f 100644 --- a/polymer/eduke32/source/lunatic/test.elua +++ b/polymer/eduke32/source/lunatic/test.elua @@ -216,7 +216,7 @@ gameevent("PROCESSINPUT", ) -- test event chaining -gameevent("JUMP", +gameevent("JUMP", actor.FLAGS.chain_beg, function(actori, playeri, dist) local ps = player[playeri] print("I'm first!") @@ -231,7 +231,7 @@ gameevent("JUMP", -- Test of INTERNAL member _pals. -- NOTE: setting colors partially is bad! E.g. after an item is -- picked up, col[0] and col[1] remain and tint everything greenish. - ps._pals.col[2] = 20 + ps._pals[2] = 20 ps._pals.f = 30 end )