mirror of
https://github.com/ZDoom/raze-gles.git
synced 2024-11-13 07:58:04 +00:00
Lunatic: Makefile tweaks, protect sprite[].picnum.
git-svn-id: https://svn.eduke32.com/eduke32@3248 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
parent
354a1a70ef
commit
b850d04f8d
5 changed files with 77 additions and 42 deletions
|
@ -158,12 +158,13 @@ ifneq (0,$(DISABLEINLINING))
|
||||||
endif
|
endif
|
||||||
|
|
||||||
MISCGAMEDEPS=
|
MISCGAMEDEPS=
|
||||||
|
MISCEDITORDEPS=
|
||||||
|
|
||||||
|
|
||||||
## Lunatic devel
|
## Lunatic devel
|
||||||
ifneq (0,$(LUNATIC))
|
ifneq (0,$(LUNATIC))
|
||||||
EDITOROBJS+= $(OBJ)/lunatic_m32.$o
|
EDITOROBJS+= $(OBJ)/lunatic_m32.$o $(OBJ)/luaJIT_BC_defs_common.$o
|
||||||
GAMEOBJS+= $(OBJ)/lunatic_game.$o
|
GAMEOBJS+= $(OBJ)/lunatic_game.$o $(OBJ)/luaJIT_BC_defs_common.$o
|
||||||
|
|
||||||
GAMEOBJS+= $(OBJ)/../lpeg.$o # TEMP
|
GAMEOBJS+= $(OBJ)/../lpeg.$o # TEMP
|
||||||
GAMEOBJS+= $(OBJ)/luaJIT_BC_con_lang.$o \
|
GAMEOBJS+= $(OBJ)/luaJIT_BC_con_lang.$o \
|
||||||
|
@ -188,7 +189,9 @@ ifneq (0,$(LUNATIC))
|
||||||
endif
|
endif
|
||||||
ifeq ($(PLATFORM),WINDOWS)
|
ifeq ($(PLATFORM),WINDOWS)
|
||||||
MISCGAMEDEPS+= $(SRC)/lunatic/eduke32.def
|
MISCGAMEDEPS+= $(SRC)/lunatic/eduke32.def
|
||||||
PRINTLDFLAGS+= $(SRC)/lunatic/eduke32.def
|
GAMELDFLAGS+= $(SRC)/lunatic/eduke32.def
|
||||||
|
MISCEDITORDEPS+= $(SRC)/lunatic/mapster32.def
|
||||||
|
EDITORLDFLAGS+= $(SRC)/lunatic/mapster32.def
|
||||||
endif
|
endif
|
||||||
ifeq ($(PLATFORM),LINUX)
|
ifeq ($(PLATFORM),LINUX)
|
||||||
GAMELDFLAGS+= -Wl,--dynamic-list=$(SRC)/lunatic/dynsymlist
|
GAMELDFLAGS+= -Wl,--dynamic-list=$(SRC)/lunatic/dynsymlist
|
||||||
|
@ -366,7 +369,7 @@ ifeq ($(PLATFORM),DARWIN)
|
||||||
cp -f "$(EDUKE32)" "EDuke32.app/Contents/MacOS/"
|
cp -f "$(EDUKE32)" "EDuke32.app/Contents/MacOS/"
|
||||||
endif
|
endif
|
||||||
|
|
||||||
$(MAPSTER32): $(EDITOROBJS) $(EOBJ)/$(ENGINELIB) $(EOBJ)/$(EDITORLIB) $(JAUDIOLIBDIR)/$(JAUDIOLIB)
|
$(MAPSTER32): $(EDITOROBJS) $(EOBJ)/$(ENGINELIB) $(EOBJ)/$(EDITORLIB) $(JAUDIOLIBDIR)/$(JAUDIOLIB) $(MISCEDITORDEPS)
|
||||||
$(LINK_STATUS)
|
$(LINK_STATUS)
|
||||||
if $(LINKER) -o $@ $^ $(OURLDFLAGS) $(EDITORLDFLAGS) $(OURLIBS) $(STATICSTDCPP) $(STDCPPLIB); then $(LINK_OK); else $(LINK_FAILED); fi
|
if $(LINKER) -o $@ $^ $(OURLDFLAGS) $(EDITORLDFLAGS) $(OURLIBS) $(STATICSTDCPP) $(STDCPPLIB); then $(LINK_OK); else $(LINK_FAILED); fi
|
||||||
ifeq (1,$(RELEASE))
|
ifeq (1,$(RELEASE))
|
||||||
|
@ -465,12 +468,15 @@ $(SRC)/lunatic/dynsymlist_osx: $(SRC)/lunatic/dynsymlist
|
||||||
#$(SRC)/lunatic/aliases_list: $(SRC)/lunatic/dynsymlist_osx
|
#$(SRC)/lunatic/aliases_list: $(SRC)/lunatic/dynsymlist_osx
|
||||||
# sed 's/_\([A-Za-z_][A-Za-z_0-9]*\)/_\1 \1/g' $< > $@
|
# sed 's/_\([A-Za-z_][A-Za-z_0-9]*\)/_\1 \1/g' $< > $@
|
||||||
|
|
||||||
# TODO: _m32
|
|
||||||
# List of exported symbols, Windows
|
# List of exported symbols, Windows
|
||||||
$(SRC)/lunatic/eduke32.def: $(SRC)/lunatic/dynsymlist
|
$(SRC)/lunatic/eduke32.def: $(SRC)/lunatic/dynsymlist
|
||||||
echo EXPORTS > $@
|
echo EXPORTS > $@
|
||||||
sed 's/[{};]//g' $< >> $@
|
sed 's/[{};]//g' $< >> $@
|
||||||
|
|
||||||
|
$(SRC)/lunatic/mapster32.def: $(SRC)/lunatic/dynsymlist_m32
|
||||||
|
echo EXPORTS > $@
|
||||||
|
sed 's/[{};]//g' $< >> $@
|
||||||
|
|
||||||
####
|
####
|
||||||
|
|
||||||
$(OBJ)/%.$o: Apple/%.m
|
$(OBJ)/%.$o: Apple/%.m
|
||||||
|
|
|
@ -42,7 +42,7 @@ end
|
||||||
|
|
||||||
-- load them!
|
-- load them!
|
||||||
local defs_c = require("defs_common")
|
local defs_c = require("defs_common")
|
||||||
|
local strip_const = defs_c.strip_const
|
||||||
|
|
||||||
---=== EDuke32 game definitions ===---
|
---=== EDuke32 game definitions ===---
|
||||||
|
|
||||||
|
@ -222,11 +222,6 @@ local DUKEPLAYER_STRUCT = [[
|
||||||
local randgen = require("randgen")
|
local randgen = require("randgen")
|
||||||
local geom = require("geom")
|
local geom = require("geom")
|
||||||
|
|
||||||
-- Converts a template struct definition to an internal, unrestricted one.
|
|
||||||
local function strip_const(structstr)
|
|
||||||
return string.gsub(structstr, "const ", "");
|
|
||||||
end
|
|
||||||
|
|
||||||
local ma_rand = randgen.new(true) -- initialize to "random" (time-based) seed
|
local ma_rand = randgen.new(true) -- initialize to "random" (time-based) seed
|
||||||
local ma_count = nil
|
local ma_count = nil
|
||||||
|
|
||||||
|
|
|
@ -6,6 +6,8 @@
|
||||||
local ffi = require("ffi")
|
local ffi = require("ffi")
|
||||||
local ffiC = ffi.C
|
local ffiC = ffi.C
|
||||||
|
|
||||||
|
local string = require("string")
|
||||||
|
|
||||||
local error = error
|
local error = error
|
||||||
local pairs = pairs
|
local pairs = pairs
|
||||||
local setmetatable = setmetatable
|
local setmetatable = setmetatable
|
||||||
|
@ -20,19 +22,41 @@ module(...)
|
||||||
|
|
||||||
|
|
||||||
--== Core engine structs ==--
|
--== Core engine structs ==--
|
||||||
|
local SPRITE_STRUCT = [[
|
||||||
|
{
|
||||||
|
int32_t x, y, z;
|
||||||
|
uint16_t cstat;
|
||||||
|
const int16_t picnum;
|
||||||
|
int8_t shade;
|
||||||
|
uint8_t pal, clipdist, filler;
|
||||||
|
uint8_t xrepeat, yrepeat;
|
||||||
|
int8_t xoffset, yoffset;
|
||||||
|
const int16_t sectnum, statnum;
|
||||||
|
int16_t ang, owner, xvel, yvel, zvel;
|
||||||
|
int16_t lotag, hitag, extra;
|
||||||
|
}
|
||||||
|
]]
|
||||||
|
|
||||||
|
-- Converts a template struct definition to an internal, unrestricted one.
|
||||||
|
function strip_const(structstr)
|
||||||
|
return string.gsub(structstr, "const ", "");
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
-- TODO: provide getters for unsigned {hi,lo}tag?
|
-- TODO: provide getters for unsigned {hi,lo}tag?
|
||||||
ffi.cdef[[
|
ffi.cdef([[
|
||||||
#pragma pack(push,1)
|
#pragma pack(push,1)
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
const int16_t wallptr, wallnum;
|
const int16_t wallptr, wallnum;
|
||||||
int32_t ceilingz, floorz;
|
int32_t ceilingz, floorz;
|
||||||
uint16_t ceilingstat, floorstat;
|
uint16_t ceilingstat, floorstat;
|
||||||
int16_t ceilingpicnum, ceilingheinum;
|
const int16_t ceilingpicnum;
|
||||||
|
int16_t ceilingheinum;
|
||||||
int8_t ceilingshade;
|
int8_t ceilingshade;
|
||||||
uint8_t ceilingpal, ceilingxpanning, ceilingypanning;
|
uint8_t ceilingpal, ceilingxpanning, ceilingypanning;
|
||||||
int16_t floorpicnum, floorheinum;
|
const int16_t floorpicnum;
|
||||||
|
int16_t floorheinum;
|
||||||
int8_t floorshade;
|
int8_t floorshade;
|
||||||
uint8_t floorpal, floorxpanning, floorypanning;
|
uint8_t floorpal, floorxpanning, floorypanning;
|
||||||
uint8_t visibility, filler;
|
uint8_t visibility, filler;
|
||||||
|
@ -44,25 +68,19 @@ typedef struct
|
||||||
int32_t x, y;
|
int32_t x, y;
|
||||||
const int16_t point2, nextwall, nextsector;
|
const int16_t point2, nextwall, nextsector;
|
||||||
uint16_t cstat;
|
uint16_t cstat;
|
||||||
int16_t picnum, overpicnum;
|
const int16_t picnum, overpicnum;
|
||||||
int8_t shade;
|
int8_t shade;
|
||||||
uint8_t pal, xrepeat, yrepeat, xpanning, ypanning;
|
uint8_t pal, xrepeat, yrepeat, xpanning, ypanning;
|
||||||
int16_t lotag, hitag, extra;
|
int16_t lotag, hitag, extra;
|
||||||
} walltype;
|
} walltype;
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
]].. SPRITE_STRUCT ..[[
|
||||||
int32_t x, y, z;
|
spritetype;
|
||||||
uint16_t cstat;
|
|
||||||
int16_t picnum;
|
typedef struct
|
||||||
int8_t shade;
|
]].. strip_const(SPRITE_STRUCT) ..[[
|
||||||
uint8_t pal, clipdist, filler;
|
spritetype_u_t;
|
||||||
uint8_t xrepeat, yrepeat;
|
|
||||||
int8_t xoffset, yoffset;
|
|
||||||
const int16_t sectnum, statnum;
|
|
||||||
int16_t ang, owner, xvel, yvel, zvel;
|
|
||||||
int16_t lotag, hitag, extra;
|
|
||||||
} spritetype;
|
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
const uint32_t mdanimtims;
|
const uint32_t mdanimtims;
|
||||||
|
@ -90,7 +108,7 @@ typedef struct {
|
||||||
char r,g,b,f;
|
char r,g,b,f;
|
||||||
} palette_t;
|
} palette_t;
|
||||||
#pragma pack(pop)
|
#pragma pack(pop)
|
||||||
]]
|
]])
|
||||||
|
|
||||||
local vec3_ct = ffi.typeof("vec3_t")
|
local vec3_ct = ffi.typeof("vec3_t")
|
||||||
local hitdata_ct = ffi.typeof("hitdata_t")
|
local hitdata_ct = ffi.typeof("hitdata_t")
|
||||||
|
@ -198,6 +216,21 @@ int32_t ksqrt(uint32_t num);
|
||||||
]]
|
]]
|
||||||
|
|
||||||
|
|
||||||
|
local spritetype_ptr_ct = ffi.typeof("spritetype_u_t *")
|
||||||
|
|
||||||
|
local spritetype_mt = {
|
||||||
|
__index = {
|
||||||
|
set_picnum = function(s, tilenum)
|
||||||
|
if (tilenum >= ffiC.MAXTILES+0ULL) then
|
||||||
|
error("attempt to set invalid picnum "..tilenum, 2)
|
||||||
|
end
|
||||||
|
ffi.cast(spritetype_ptr_ct, s).picnum = tilenum
|
||||||
|
end
|
||||||
|
},
|
||||||
|
}
|
||||||
|
ffi.metatype("spritetype", spritetype_mt)
|
||||||
|
|
||||||
|
|
||||||
---=== Restricted access to C variables from Lunatic ===---
|
---=== Restricted access to C variables from Lunatic ===---
|
||||||
|
|
||||||
-- set metatable and forbid setting it further
|
-- set metatable and forbid setting it further
|
||||||
|
@ -209,18 +242,18 @@ end
|
||||||
---- indirect C array access ----
|
---- indirect C array access ----
|
||||||
local sector_mt = {
|
local sector_mt = {
|
||||||
__index = function(tab, key)
|
__index = function(tab, key)
|
||||||
if (key >= 0 and key < ffiC.numsectors) then return ffiC.sector[key] end
|
if (key >= 0 and key < ffiC.numsectors) then return ffiC.sector[key] end
|
||||||
error('out-of-bounds sector[] read access', 2)
|
error('out-of-bounds sector[] read access', 2)
|
||||||
end,
|
end,
|
||||||
|
|
||||||
__newindex = function(tab, key, val) error('cannot write directly to sector[] struct', 2) end,
|
__newindex = function(tab, key, val) error('cannot write directly to sector[] struct', 2) end,
|
||||||
}
|
}
|
||||||
|
|
||||||
local wall_mt = {
|
local wall_mt = {
|
||||||
__index = function(tab, key)
|
__index = function(tab, key)
|
||||||
if (key >= 0 and key < ffiC.numwalls) then return ffiC.wall[key] end
|
if (key >= 0 and key < ffiC.numwalls) then return ffiC.wall[key] end
|
||||||
error('out-of-bounds wall[] read access', 2)
|
error('out-of-bounds wall[] read access', 2)
|
||||||
end,
|
end,
|
||||||
|
|
||||||
__newindex = function(tab, key, val) error('cannot write directly to wall[] struct', 2) end,
|
__newindex = function(tab, key, val) error('cannot write directly to wall[] struct', 2) end,
|
||||||
}
|
}
|
||||||
|
@ -230,14 +263,14 @@ function creategtab(ctab, maxidx, name)
|
||||||
local tab = {}
|
local tab = {}
|
||||||
local tmpmt = {
|
local tmpmt = {
|
||||||
__index = function(tab, key)
|
__index = function(tab, key)
|
||||||
if (key>=0 and key < maxidx) then
|
if (key>=0 and key < maxidx) then
|
||||||
return ctab[key]
|
return ctab[key]
|
||||||
end
|
end
|
||||||
error('out-of-bounds '..name..' read access', 2)
|
error('out-of-bounds '..name..' read access', 2)
|
||||||
end,
|
end,
|
||||||
__newindex = function(tab, key, val)
|
__newindex = function(tab, key, val)
|
||||||
error('cannot write directly to '..name, 2)
|
error('cannot write directly to '..name, 2)
|
||||||
end,
|
end,
|
||||||
}
|
}
|
||||||
|
|
||||||
return setmtonce(tab, tmpmt)
|
return setmtonce(tab, tmpmt)
|
||||||
|
|
|
@ -761,7 +761,7 @@ local Ci = {
|
||||||
/ ACS":set_move(%1)",
|
/ ACS":set_move(%1)",
|
||||||
|
|
||||||
cactor = cmd(D)
|
cactor = cmd(D)
|
||||||
/ SPS".picnum=%1", -- TODO: wrap, e.g. sprite[]:set_picnum(tilenum), bound check there
|
/ SPS":set_picnum(%1)",
|
||||||
count = cmd(D)
|
count = cmd(D)
|
||||||
/ ACS":set_count(%1)",
|
/ ACS":set_count(%1)",
|
||||||
cstator = cmd(D),
|
cstator = cmd(D),
|
||||||
|
|
|
@ -182,6 +182,7 @@ checkfail("do local bt=require'bittest'; bt.QWE=1; end", "modifying module table
|
||||||
-- the cdata returned by player[] can't be made into a pointer!
|
-- the cdata returned by player[] can't be made into a pointer!
|
||||||
checkfail("do local pl=player[0]; i=pl[1]; end")
|
checkfail("do local pl=player[0]; i=pl[1]; end")
|
||||||
checkfail("do local ud=gv.ud.camera; end", "dummy variable: read access forbidden") -- test for proper decl()
|
checkfail("do local ud=gv.ud.camera; end", "dummy variable: read access forbidden") -- test for proper decl()
|
||||||
|
checkfail("sprite[0]:set_picnum(-10)", "attempt to set invalid picnum")
|
||||||
|
|
||||||
printf('ceilingbunch of sector 0: %d', getbunch(0, gv.CEILING))
|
printf('ceilingbunch of sector 0: %d', getbunch(0, gv.CEILING))
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue