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
This commit is contained in:
helixhorned 2013-04-05 17:53:03 +00:00
parent 512b9286fe
commit 49290a090c
5 changed files with 16 additions and 13 deletions

View file

@ -101,7 +101,11 @@ function new(basetype, numelts, showname, typename, rng, mtadd)
local bcarray_t = ffi.typeof(cdeclstr, ffi.typeof(basetype)); local bcarray_t = ffi.typeof(cdeclstr, ffi.typeof(basetype));
bcarray_t = ffi.metatype(bcarray_t, mt) 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 if (typename ~= nil) then
-- Register the type name in the global namespace. -- Register the type name in the global namespace.

View file

@ -659,7 +659,7 @@ local PlayerLabels = {
palette = PL".palette", palette = PL".palette",
-- NOTE the special case: -- NOTE the special case:
pals = PL"._pals.col[%s]", pals = PL"._pals[%s]",
pals_time = PL"._pals.f", pals_time = PL"._pals.f",
name = {}, name = {},

View file

@ -25,6 +25,8 @@ local tonumber = tonumber
local tostring = tostring local tostring = tostring
local type = type local type = type
require("jit.opt").start("maxmcode=10240") -- in KiB
-- The "gv" global will provide access to C global *scalars* and safe functions. -- 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 -- 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. -- without their declarations, they will be sitting there like a stone.

View file

@ -20,7 +20,7 @@ if (bit.band(ffiC._DEBUG_LUNATIC, 2)~=0) then
end end
if (bit.band(ffiC._DEBUG_LUNATIC, 8)~=0) then 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 elseif (bit.band(ffiC._DEBUG_LUNATIC, 4)~=0) then
require("v").on() require("v").on()
end end
@ -154,10 +154,8 @@ ffi.typeof(SPRITE_STRUCT))
-- Define the "palette_t" type, which for us has .{r,g,b} fields and a -- Define the "palette_t" type, which for us has .{r,g,b} fields and a
-- bound-checking array of length 3 overlaid. -- bound-checking array of length 3 overlaid.
-- TODO: bcarray really should allow to simply declare the struct with local rgbarray_t = require("bcarray").new("uint8_t", 3, "RGB array", "palette_t",
-- passed member names instead of "hidden" ones... because wrapping it { "r", "g", "b", "f" })
-- in a union like this is doing things inside-out really.
local rgbarray_t = require("bcarray").new("uint8_t", 3, "RGB array")
ffi.cdef("typedef union { \ ffi.cdef("typedef union { \
struct { uint8_t r, g, b, f; }; \ struct { uint8_t r, g, b, f; }; \
$ col; \ $ col; \
@ -870,13 +868,12 @@ function cansee(pos1,sect1, pos2,sect2)
return (ret~=0) return (ret~=0)
end end
ffi.cdef[[ local neartag_ret_ct = ffi.typeof[[
typedef struct { const struct {
int32_t sector, wall, sprite; int32_t sector, wall, sprite;
int32_t dist; 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 local function newar() return ffi.new("int16_t [1]") end
-- TODO: make tagsearch something more convenient -- TODO: make tagsearch something more convenient

View file

@ -216,7 +216,7 @@ gameevent("PROCESSINPUT",
) )
-- test event chaining -- test event chaining
gameevent("JUMP", gameevent("JUMP", actor.FLAGS.chain_beg,
function(actori, playeri, dist) function(actori, playeri, dist)
local ps = player[playeri] local ps = player[playeri]
print("I'm first!") print("I'm first!")
@ -231,7 +231,7 @@ gameevent("JUMP",
-- Test of INTERNAL member _pals. -- Test of INTERNAL member _pals.
-- NOTE: setting colors partially is bad! E.g. after an item is -- NOTE: setting colors partially is bad! E.g. after an item is
-- picked up, col[0] and col[1] remain and tint everything greenish. -- 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 ps._pals.f = 30
end end
) )