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));
bcarray_t = ffi.metatype(bcarray_t, mt)
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.

View File

@ -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 = {},

View File

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

View File

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

View File

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