mirror of
https://github.com/ZDoom/raze-gles.git
synced 2024-12-26 03:30:46 +00:00
Lunatic: replace some allocations by static data, some translator fixes.
Fix 'setsprite' and 'music'. A good timing test for actors performance is the starfield of WGR2's E1L1 ("Nexus"). git-svn-id: https://svn.eduke32.com/eduke32@3558 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
parent
3b3bc6bc01
commit
f6d1af0532
4 changed files with 39 additions and 22 deletions
|
@ -1220,6 +1220,9 @@ function _canseespr(s1, s2)
|
||||||
return cansee(sprite[s1], sprite[s1].sectnum, sprite[s2], sprite[s2].sectnum) and 1 or 0
|
return cansee(sprite[s1], sprite[s1].sectnum, sprite[s2], sprite[s2].sectnum) and 1 or 0
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- TODO: replace ivec3 allocations with stores to a static ivec3, like in
|
||||||
|
-- updatesector*?
|
||||||
|
|
||||||
-- CON "hitscan" command
|
-- CON "hitscan" command
|
||||||
function _hitscan(x, y, z, sectnum, vx, vy, vz, cliptype)
|
function _hitscan(x, y, z, sectnum, vx, vy, vz, cliptype)
|
||||||
local srcv = geom.ivec3(x, y, z)
|
local srcv = geom.ivec3(x, y, z)
|
||||||
|
|
|
@ -1486,11 +1486,11 @@ do
|
||||||
|
|
||||||
local lineinfo
|
local lineinfo
|
||||||
concode, lineinfo = lunacon.compile(confn)
|
concode, lineinfo = lunacon.compile(confn)
|
||||||
assert(lineinfo)
|
|
||||||
|
|
||||||
if (concode == nil) then
|
if (concode == nil) then
|
||||||
error("Failure compiling CON code, exiting.", 0)
|
error("Failure compiling CON code, exiting.", 0)
|
||||||
end
|
end
|
||||||
|
assert(lineinfo)
|
||||||
|
|
||||||
-- Translate one Lua line number to a CON file name + line number
|
-- Translate one Lua line number to a CON file name + line number
|
||||||
local function transline(lnum)
|
local function transline(lnum)
|
||||||
|
@ -1735,7 +1735,7 @@ setfenv(0, _G)
|
||||||
if (concode) then
|
if (concode) then
|
||||||
local confunc, conerrmsg = loadstring(concode, "CON")
|
local confunc, conerrmsg = loadstring(concode, "CON")
|
||||||
if (confunc == nil) then
|
if (confunc == nil) then
|
||||||
error("Failure loading translated CON code: "..conerrmsg)
|
error("Failure loading translated CON code: "..conerrmsg, 0)
|
||||||
end
|
end
|
||||||
confunc()
|
confunc()
|
||||||
end
|
end
|
||||||
|
|
|
@ -859,22 +859,24 @@ end
|
||||||
|
|
||||||
-- TODO: should these rather be one function, and the specific kind of updating
|
-- TODO: should these rather be one function, and the specific kind of updating
|
||||||
-- controlled by an argument?
|
-- controlled by an argument?
|
||||||
|
local us_retsect = ffi.new("int16_t [1]")
|
||||||
|
|
||||||
function updatesector(pos, sectnum)
|
function updatesector(pos, sectnum)
|
||||||
local sect = ffi.new("int16_t [1]", sectnum)
|
us_retsect[0] = sectnum
|
||||||
ffiC.updatesector(pos.x, pos.y, sect)
|
ffiC.updatesector(pos.x, pos.y, us_retsect)
|
||||||
return sect[0]
|
return us_retsect[0]
|
||||||
end
|
end
|
||||||
|
|
||||||
function updatesectorbreadth(pos, sectnum)
|
function updatesectorbreadth(pos, sectnum)
|
||||||
local sect = ffi.new("int16_t [1]", sectnum)
|
us_retsect[0] = sectnum
|
||||||
ffiC.updatesectorbreadth(pos.x, pos.y, sect)
|
ffiC.updatesectorbreadth(pos.x, pos.y, us_retsect)
|
||||||
return sect[0]
|
return us_retsect[0]
|
||||||
end
|
end
|
||||||
|
|
||||||
function updatesectorz(pos, sectnum)
|
function updatesectorz(pos, sectnum)
|
||||||
local sect = ffi.new("int16_t [1]", sectnum)
|
us_retsect[0] = sectnum
|
||||||
ffiC.updatesectorz(pos.x, pos.y, pos.z, sect)
|
ffiC.updatesectorz(pos.x, pos.y, pos.z, us_retsect)
|
||||||
return sect[0]
|
return us_retsect[0]
|
||||||
end
|
end
|
||||||
|
|
||||||
function printf(fmt, ...)
|
function printf(fmt, ...)
|
||||||
|
|
|
@ -161,7 +161,14 @@ local function new_initial_codetab()
|
||||||
-- switch function table, indexed by global switch sequence number:
|
-- switch function table, indexed by global switch sequence number:
|
||||||
"local _SW = {};",
|
"local _SW = {};",
|
||||||
-- CON "states" (subroutines), gamevars and gamearrays (see mangle_name())
|
-- CON "states" (subroutines), gamevars and gamearrays (see mangle_name())
|
||||||
"local _F,_V,_A={},{},{};"
|
"local _F,_V,_A={},{},{};",
|
||||||
|
|
||||||
|
-- Static ivec3s so that no allocations need to be made.
|
||||||
|
"local _IVEC = { _geom.ivec3(), _geom.ivec3() }",
|
||||||
|
[[local function _IV(num, x, y, z)
|
||||||
|
local v=_IVEC[num]; v.x=x; v.y=y; v.z=z; return v;
|
||||||
|
end
|
||||||
|
]],
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -926,9 +933,14 @@ function Cmd.definesound(sndnum, fn, ...)
|
||||||
end
|
end
|
||||||
|
|
||||||
function Cmd.music(volnum, ...)
|
function Cmd.music(volnum, ...)
|
||||||
if (not (volnum >= 0 and volnum < conl.MAXVOLUMES+1)) then
|
if (volnum==0) then
|
||||||
-- NOTE: MAXVOLUMES is OK, since it's MapInfo[(MAXVOLUMES+1)*MAXLEVELS]
|
warnprintf("`music' for volume 0 not yet implemented")
|
||||||
errprintf("volume number is negative or exceeds MAXVOLUMES=%d", conl.MAXVOLUMES)
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
if (not (volnum >= 1 and volnum <= conl.MAXVOLUMES)) then
|
||||||
|
-- NOTE: Don't allow MAXVOLUMES+1 for now.
|
||||||
|
errprintf("volume number must be between 1 and MAXVOLUMES=%d", conl.MAXVOLUMES)
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -944,7 +956,7 @@ function Cmd.music(volnum, ...)
|
||||||
if (ffi) then
|
if (ffi) then
|
||||||
for i=1,#filenames do
|
for i=1,#filenames do
|
||||||
assert(type(filenames[i])=="string")
|
assert(type(filenames[i])=="string")
|
||||||
ffiC.C_DefineMusic(volnum, i-1, "/"..filenames[i])
|
ffiC.C_DefineMusic(volnum-1, i-1, "/"..filenames[i])
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -2031,7 +2043,7 @@ local Cinner = {
|
||||||
addweaponvar = cmd(R,R) -- NLCF
|
addweaponvar = cmd(R,R) -- NLCF
|
||||||
/ handle.addweapon,
|
/ handle.addweapon,
|
||||||
cansee = cmd(R,R,R,R,R,R,R,R,W)
|
cansee = cmd(R,R,R,R,R,R,R,R,W)
|
||||||
/ "%9=cansee(_geom.ivec3(%1,%2,%3),%4, _geom.ivec3(%5,%6,%7),%8) and 1 or 0",
|
/ "%9=cansee(_IV(1,%1,%2,%3),%4, _IV(2,%5,%6,%7),%8) and 1 or 0",
|
||||||
canseespr = cmd(R,R,W)
|
canseespr = cmd(R,R,W)
|
||||||
/ "%3=_con._canseespr(%1,%2)",
|
/ "%3=_con._canseespr(%1,%2)",
|
||||||
changespritesect = cmd(R,R)
|
changespritesect = cmd(R,R)
|
||||||
|
@ -2175,11 +2187,11 @@ local Cinner = {
|
||||||
ssp = cmd(R,R)
|
ssp = cmd(R,R)
|
||||||
/ handle.NYI,
|
/ handle.NYI,
|
||||||
setsprite = cmd(R,R,R,R)
|
setsprite = cmd(R,R,R,R)
|
||||||
/ "sprite[%1]:setpos(_geom.ivec3(%1,%2,%3))",
|
/ "sprite[%1]:setpos(_IV(1,%2,%3,%4))",
|
||||||
updatesector = cmd(R,R,W)
|
updatesector = cmd(R,R,W)
|
||||||
/ format("%%3=updatesector(_geom.ivec3(%%1,%%2),%s)", SPS".sectnum"),
|
/ format("%%3=updatesector(_IV(1,%%1,%%2,0),%s)", SPS".sectnum"),
|
||||||
updatesectorz = cmd(R,R,R,W)
|
updatesectorz = cmd(R,R,R,W)
|
||||||
/ format("%%4=updatesectorz(_geom.ivec3(%%1,%%2,%%3),%s)", SPS".sectnum"),
|
/ format("%%4=updatesectorz(_IV(1,%%1,%%2,%%3),%s)", SPS".sectnum"),
|
||||||
|
|
||||||
getactorangle = cmd(W)
|
getactorangle = cmd(W)
|
||||||
/ ("%1="..SPS".ang"),
|
/ ("%1="..SPS".ang"),
|
||||||
|
@ -2193,9 +2205,9 @@ local Cinner = {
|
||||||
/ "%1=_con._angtotarget(_aci)",
|
/ "%1=_con._angtotarget(_aci)",
|
||||||
|
|
||||||
getceilzofslope = cmd(R,R,R,W)
|
getceilzofslope = cmd(R,R,R,W)
|
||||||
/ "%4=sector[%1]:ceilingzat(_geom.ivec3(%2,%3))",
|
/ "%4=sector[%1]:ceilingzat(_IV(1,%2,%3,0))",
|
||||||
getflorzofslope = cmd(R,R,R,W)
|
getflorzofslope = cmd(R,R,R,W)
|
||||||
/ "%4=sector[%1]:floorzat(_geom.ivec3(%2,%3))",
|
/ "%4=sector[%1]:floorzat(_IV(1,%2,%3,0))",
|
||||||
getcurraddress = cmd(W)
|
getcurraddress = cmd(W)
|
||||||
/ handle.NYI, -- will never be
|
/ handle.NYI, -- will never be
|
||||||
getticks = cmd(W)
|
getticks = cmd(W)
|
||||||
|
|
Loading…
Reference in a new issue