mirror of
https://github.com/ZDoom/raze-gles.git
synced 2024-11-11 07:11:39 +00:00
LunaCON: gen. cleaner code, make actor[].movflag internal, update listglobals.sh
git-svn-id: https://svn.eduke32.com/eduke32@3646 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
parent
edcef5c3ec
commit
e638c38c35
5 changed files with 52 additions and 37 deletions
|
@ -366,7 +366,7 @@ local SX = function(memb) return "spriteext[%s]"..memb end
|
|||
|
||||
-- Generate code to access a signed member as unsigned.
|
||||
local function s2u(label)
|
||||
return "(_bit.band("..label.."+65536,65535))"
|
||||
return "(_band("..label.."+65536,65535))"
|
||||
end
|
||||
|
||||
local function S2U(label)
|
||||
|
@ -408,7 +408,7 @@ local ActorLabels = {
|
|||
htang = AC".ang",
|
||||
htextra = AC".extra",
|
||||
htowner = { AC".owner", AC":set_owner(%%s)" },
|
||||
htmovflag = AC".movflag",
|
||||
htmovflag = AC"._movflag",
|
||||
httempang = AC".tempang",
|
||||
htactorstayput = AC".actorstayput",
|
||||
htdispicnum = { AC".dispicnum" },
|
||||
|
@ -813,7 +813,7 @@ for member, code in pairs(ProjectileLabels) do
|
|||
end
|
||||
end
|
||||
|
||||
local UD = function(memb) return "gv._ud"..memb end
|
||||
local UD = function(memb) return "_gv._ud"..memb end
|
||||
local UDRO = function(memb) return { UD(memb) } end
|
||||
|
||||
-- NOTE: Only members that actually encountered in existing mods are added here.
|
||||
|
|
|
@ -157,7 +157,7 @@ __attribute__((packed)) struct {
|
|||
const int16_t picnum;
|
||||
int16_t ang, extra;
|
||||
const int16_t owner;
|
||||
int16_t movflag,tempang,timetosleep; //6b
|
||||
int16_t _movflag,tempang,timetosleep; //6b
|
||||
|
||||
int16_t actorstayput;
|
||||
const int16_t dispicnum;
|
||||
|
|
|
@ -6,7 +6,10 @@ if [ -z "$1" ]; then
|
|||
exit 1;
|
||||
fi
|
||||
|
||||
# Lua 5.2 required to parse ::label:: / goto generated by LunaCON.
|
||||
LUAC=luac
|
||||
|
||||
# Strip LuaJIT specific syntax
|
||||
sed -r -e "s/[0-9]+U?LL/0/g" "$1" | luac -p -l - | grep "$2ETGLOBAL" |
|
||||
sed -r -e "s/[0-9]+U?LL/0/g" "$1" | $LUAC -p -l - | grep "$2ETTABUP.*; _ENV " |
|
||||
# mark where the new module environment starts
|
||||
sed -e "s/; module/; module ____________________/"
|
||||
|
|
|
@ -163,17 +163,25 @@ local function new_initial_codetab()
|
|||
-- NOTE: Keep this one line per line to not confuse the Lua->CON line
|
||||
-- mapping system.
|
||||
return {
|
||||
"local _con, _bit, _math = require'con', require'bit', require'math';",
|
||||
"local _xmath, _geom = require'xmath', require'geom';",
|
||||
"local sector, sprite, actor, player = sector, sprite, actor, player;",
|
||||
"local gameactor, gameevent, _gv = gameactor, gameevent, gv;",
|
||||
"local updatesector, updatesectorz, cansee = updatesector, updatesectorz, cansee;",
|
||||
"local print = print;",
|
||||
-- Requires.
|
||||
"local _con, _bit, _math = require'con', require'bit', require'math'",
|
||||
"local _xmath, _geom = require'xmath', require'geom'",
|
||||
|
||||
-- switch function table, indexed by global switch sequence number:
|
||||
"local _SW = {};",
|
||||
-- Cache globals into locals.
|
||||
"local sector, sprite, wall, spriteext, atsprite = sector, sprite, wall, spriteext, atsprite",
|
||||
"local actor, player, projectile = actor, player, projectile",
|
||||
"local gameactor, gameevent, _gv = gameactor, gameevent, gv",
|
||||
"local updatesector, updatesectorz, cansee = updatesector, updatesectorz, cansee",
|
||||
"local print, printf = print, printf",
|
||||
|
||||
-- Cache a couple of often-used functions.
|
||||
"local _band, _bor, _bxor = _bit.band, _bit.bor, _bit.bxor",
|
||||
"local _lsh, _rsh, _arsh = _bit.lshift, _bit.rshift, _bit.arshift",
|
||||
|
||||
-- Switch function table, indexed by global switch sequence number:
|
||||
"local _SW = {}",
|
||||
-- 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() }",
|
||||
|
@ -400,7 +408,11 @@ local BAD_ID_CHARS1 = "_/\\*-+?" -- allowed following identifier chars
|
|||
-- Return the Lua code by which the CON object <name> is referenced in the
|
||||
-- translated code.
|
||||
local function mangle_name(name, prefix)
|
||||
return format("_%s[%q]", prefix, name)
|
||||
if (name:match("^[A-Za-z_][A-Za-z_0-9]*$")) then
|
||||
return format("_%s.%s", prefix, name)
|
||||
else
|
||||
return format("_%s[%q]", prefix, name)
|
||||
end
|
||||
end
|
||||
|
||||
function on.state_begin_Cmt(_subj, _pos, statename)
|
||||
|
@ -1735,7 +1747,7 @@ local handle =
|
|||
end,
|
||||
|
||||
rotatesprite16 = function(...) -- (orientation|ROTATESPRITE_FULL16)
|
||||
return format("_con.rotatesprite(%s,%s,%s,%s,%s,%s,%s,_bit.bor(%s,2048),0,%s,%s,%s,%s)", ...)
|
||||
return format("_con.rotatesprite(%s,%s,%s,%s,%s,%s,%s,_bor(%s,2048),0,%s,%s,%s,%s)", ...)
|
||||
end,
|
||||
|
||||
rotatespritea = function(...)
|
||||
|
@ -1854,9 +1866,9 @@ local Cinner = {
|
|||
mulvarvar = varvaropf "*",
|
||||
divvarvar = varvaropf "_con._div",
|
||||
modvarvar = varvaropf "_con._mod",
|
||||
andvarvar = varvaropf "_bit.band",
|
||||
orvarvar = varvaropf "_bit.bor",
|
||||
xorvarvar = varvaropf "_bit.bxor",
|
||||
andvarvar = varvaropf "_band",
|
||||
orvarvar = varvaropf "_bor",
|
||||
xorvarvar = varvaropf "_bxor",
|
||||
randvarvar = varvarop / "%1=_con._rand(%2)",
|
||||
|
||||
setvar = varop / "%1=%2",
|
||||
|
@ -1865,12 +1877,12 @@ local Cinner = {
|
|||
mulvar = varopf "*",
|
||||
divvar = varopf "_con._div",
|
||||
modvar = varopf "_con._mod",
|
||||
andvar = varopf "_bit.band",
|
||||
orvar = varopf "_bit.bor",
|
||||
xorvar = varopf "_bit.bxor",
|
||||
andvar = varopf "_band",
|
||||
orvar = varopf "_bor",
|
||||
xorvar = varopf "_bxor",
|
||||
randvar = varop / "%1=_con._rand(%2)",
|
||||
shiftvarl = varopf "_bit.lshift",
|
||||
shiftvarr = varopf "_bit.arshift",
|
||||
shiftvarl = varopf "_lsh",
|
||||
shiftvarr = varopf "_arsh",
|
||||
|
||||
--- 2. Math operations
|
||||
sqrt = cmd(R,W)
|
||||
|
@ -1901,7 +1913,7 @@ local Cinner = {
|
|||
count = cmd(D)
|
||||
/ ACS":set_count(%1)",
|
||||
cstator = cmd(D)
|
||||
/ (SPS".cstat=_bit.bor(%1,"..SPS".cstat)"),
|
||||
/ (SPS".cstat=_bor(%1,"..SPS".cstat)"),
|
||||
cstat = cmd(D)
|
||||
/ SPS".cstat=%1",
|
||||
clipdist = cmd(D)
|
||||
|
@ -2331,11 +2343,11 @@ local Cinner = {
|
|||
getactorangle = cmd(W)
|
||||
/ ("%1="..SPS".ang"),
|
||||
setactorangle = cmd(R)
|
||||
/ SPS".ang=_bit.band(%1,2047)",
|
||||
/ SPS".ang=_band(%1,2047)",
|
||||
getplayerangle = cmd(W)
|
||||
/ ("%1="..PLS".ang"),
|
||||
setplayerangle = cmd(R)
|
||||
/ PLS".ang=_bit.band(%1,2047)",
|
||||
/ PLS".ang=_band(%1,2047)",
|
||||
getangletotarget = cmd(W)
|
||||
/ "%1=_con._angtotarget(_aci)",
|
||||
|
||||
|
@ -2378,7 +2390,7 @@ local Cif = {
|
|||
ifwasweapon = cmd(D)
|
||||
/ ACS".picnum==%1",
|
||||
ifgapzl = cmd(D) -- factor into a con.* function?
|
||||
/ format("_bit.arshift(%s-%s,8)<%%1", ACS".floorz", ACS".ceilingz"),
|
||||
/ format("_arsh(%s-%s,8)<%%1", ACS".floorz", ACS".ceilingz"),
|
||||
iffloordistl = cmd(D)
|
||||
/ format("(%s-%s)<=256*%%1", ACS".floorz", SPS".z"),
|
||||
ifceilingdistl = cmd(D)
|
||||
|
@ -2405,11 +2417,11 @@ local Cif = {
|
|||
ifvarn = cmd(R,D)
|
||||
/ "%1~=%2",
|
||||
ifvarand = cmd(R,D)
|
||||
/ "_bit.band(%1,%2)~=0",
|
||||
/ "_band(%1,%2)~=0",
|
||||
ifvaror = cmd(R,D)
|
||||
/ "_bit.bor(%1,%2)~=0",
|
||||
/ "_bor(%1,%2)~=0",
|
||||
ifvarxor = cmd(R,D)
|
||||
/ "_bit.bxor(%1,%2)~=0",
|
||||
/ "_bxor(%1,%2)~=0",
|
||||
ifvareither = cmd(R,D)
|
||||
/ "%1~=0 or %2~=0",
|
||||
|
||||
|
@ -2422,11 +2434,11 @@ local Cif = {
|
|||
ifvarvarn = cmd(R,R)
|
||||
/ "%1~=%2",
|
||||
ifvarvarand = cmd(R,R)
|
||||
/ "_bit.band(%1,%2)~=0",
|
||||
/ "_band(%1,%2)~=0",
|
||||
ifvarvaror = cmd(R,R)
|
||||
/ "_bit.bor(%1,%2)~=0",
|
||||
/ "_bor(%1,%2)~=0",
|
||||
ifvarvarxor = cmd(R,R)
|
||||
/ "_bit.bxor(%1,%2)~=0",
|
||||
/ "_bxor(%1,%2)~=0",
|
||||
ifvarvareither = cmd(R,R)
|
||||
/ "%1~=0 or %2~=0",
|
||||
|
||||
|
@ -2442,12 +2454,12 @@ local Cif = {
|
|||
ifrespawn = cmd()
|
||||
/ format("_con._checkrespawn(%s)", SPS""),
|
||||
ifoutside = cmd()
|
||||
/ format("_bit.band(sector[%s].ceilingstat,1)~=0", SPS".sectnum"),
|
||||
/ format("_band(sector[%s].ceilingstat,1)~=0", SPS".sectnum"),
|
||||
ifonwater = cmd()
|
||||
/ format("sector[%s].lotag==1 and _math.abs(%s-sector[%s].floorz)<32*256",
|
||||
SPS".sectnum", SPS".z", SPS".sectnum"),
|
||||
ifnotmoving = cmd()
|
||||
/ "_bit.band(actor[_aci].movflag,49152)>16384",
|
||||
/ "_band(actor[_aci]._movflag,49152)>16384",
|
||||
ifnosounds = cmd()
|
||||
/ "not _con._ianysound()",
|
||||
ifmultiplayer = cmd()
|
||||
|
|
|
@ -97,7 +97,7 @@ void El_PrintTimes(void)
|
|||
buf[n] = ' ';
|
||||
buf[maxlen] = 0;
|
||||
|
||||
OSD_Printf(" [%s]={ %8d, %9.3f, %9.3f },\n",
|
||||
OSD_Printf(" [%s]={ %8d, %10.3f, %10.3f },\n",
|
||||
buf, g_eventCalls[i], g_eventTotalMs[i],
|
||||
1000*g_eventTotalMs[i]/g_eventCalls[i]);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue