mirror of
https://github.com/ZDoom/raze-gles.git
synced 2024-12-25 03:00:46 +00:00
Lunatic: g_tile access, rudimentary system gamearray support for the translator.
The only operation for which proper code is generated is reading a single value from a system gamearray. git-svn-id: https://svn.eduke32.com/eduke32@3562 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
parent
7a58a818ca
commit
c02199be48
4 changed files with 40 additions and 7 deletions
|
@ -372,9 +372,9 @@ typedef
|
|||
projectile_t;
|
||||
|
||||
typedef struct {
|
||||
uint32_t flags;
|
||||
int32_t cacherange;
|
||||
projectile_t defproj;
|
||||
uint32_t flags; // XXX: do we want to have this accessible at game time?
|
||||
const int32_t _cacherange;
|
||||
const projectile_t _defproj;
|
||||
} tiledata_t;
|
||||
|
||||
typedef struct {
|
||||
|
@ -675,6 +675,10 @@ player_static_members.INPUT_EXT_BITS = defs_c.conststruct
|
|||
INPUT_TURN_RIGHT = 32,
|
||||
}
|
||||
|
||||
local tile_static_members = {}
|
||||
tile_static_members.sizx = defs_c.creategtab(ffiC.tilesizx, ffiC.MAXTILES, "tilesizx[]")
|
||||
tile_static_members.sizy = defs_c.creategtab(ffiC.tilesizy, ffiC.MAXTILES, "tilesizy[]")
|
||||
|
||||
-- XXX: error message will say "g_player_ps"
|
||||
player = setmtonce({}, defs_c.GenStructMetatable("g_player_ps", "playerswhenstarted", player_static_members))
|
||||
|
||||
|
@ -682,6 +686,7 @@ player = setmtonce({}, defs_c.GenStructMetatable("g_player_ps", "playerswhenstar
|
|||
actor = defs_c.creategtab(ffiC.actor, ffiC.MAXSPRITES, "actor[]")
|
||||
|
||||
local projectile = defs_c.creategtab(ffiC.ProjectileData, ffiC.MAXTILES, "projectile[]")
|
||||
local g_tile = setmtonce({}, defs_c.GenStructMetatable("g_tile", "MAXTILES", tile_static_members))
|
||||
|
||||
--== Custom operations for BUILD data structures ==--
|
||||
-- Among other things, declares struct action and struct move, and their
|
||||
|
@ -1462,6 +1467,7 @@ G_.gameactor = our_gameactor
|
|||
G_.player = player
|
||||
G_.actor = actor
|
||||
G_.projectile = projectile
|
||||
G_.g_tile = g_tile
|
||||
|
||||
|
||||
---=== Lunatic interpreter setup ===---
|
||||
|
|
|
@ -249,6 +249,7 @@ const int32_t rendmode;
|
|||
const int16_t headspritesect[MAXSECTORS+1], headspritestat[MAXSTATUS+1];
|
||||
const int16_t prevspritesect[MAXSPRITES], prevspritestat[MAXSPRITES];
|
||||
const int16_t nextspritesect[MAXSPRITES], nextspritestat[MAXSPRITES];
|
||||
const int16_t tilesizx[MAXTILES], tilesizy[MAXTILES];
|
||||
|
||||
const int16_t headsectbunch[2][MAXBUNCHES], nextsectbunch[2][MAXSECTORS];
|
||||
|
||||
|
|
|
@ -77,6 +77,7 @@ end
|
|||
|
||||
local inf = 1/0
|
||||
local NaN = 0/0
|
||||
local MAXTILES = (ffiC and ffiC.MAXTILES or 30720)
|
||||
|
||||
-- Last keyword position, for error diagnosis.
|
||||
local g_lastkwpos = nil
|
||||
|
@ -286,7 +287,10 @@ local function reset_codegen()
|
|||
g_switchCode = nil
|
||||
g_switchCount = 0
|
||||
g_gamevar = new_initial_gvartab()
|
||||
g_gamearray = {}
|
||||
g_gamearray = {
|
||||
tilesizx = { name="g_tile.sizx", size=MAXTILES, sysp=true },
|
||||
tilesizy = { name="g_tile.sizy", size=MAXTILES, sysp=true },
|
||||
}
|
||||
|
||||
g_have_file = {}
|
||||
g_curcode = new_initial_codetab()
|
||||
|
@ -463,7 +467,7 @@ end
|
|||
|
||||
-- returns: OK?
|
||||
local function check_tilenum(tilenum)
|
||||
if (not (tilenum >= 0 and tilenum < (ffiC and ffiC.MAXTILES or 30720))) then
|
||||
if (not (tilenum >= 0 and tilenum < MAXTILES)) then
|
||||
errprintf("invalid tile number %d", tilenum)
|
||||
return false
|
||||
end
|
||||
|
@ -989,7 +993,10 @@ function Cmd.gamearray(identifier, initsize)
|
|||
|
||||
local oga = g_gamearray[identifier]
|
||||
if (oga) then
|
||||
if (initsize ~= oga.size) then
|
||||
if (oga.sysp) then
|
||||
errprintf("attempt to define system gamearray `%s'", identifier)
|
||||
return
|
||||
elseif (initsize ~= oga.size) then
|
||||
errprintf("duplicate gamearray definition `%s' has different size", identifier)
|
||||
return
|
||||
else
|
||||
|
@ -2030,6 +2037,7 @@ local Cinner = {
|
|||
/ handle.NYI,
|
||||
|
||||
-- array stuff
|
||||
-- TODO: handle system gamearrays. Right now, the generated code will be wrong.
|
||||
copy = sp1 * tok.gamearray * arraypat * sp1 * tok.gamearray * arraypat * sp1 * tok.rvar
|
||||
/ "%1:copyto(%2,%3,%4,%5)",
|
||||
setarray = sp1 * tok.gamearray * arraypat * sp1 * tok.rvar
|
||||
|
|
|
@ -55,7 +55,7 @@ onevent EVENT_ENTERLEVEL
|
|||
qsprintf 117 /*<-*/ 117 /*args:*/ 115
|
||||
userquote 117 // result: "X" .. 12 x "012345678|" .. "012345" (= total length 127 = MAXQUOTELEN-1)
|
||||
|
||||
// 32 %d (or %ld) conversion
|
||||
// 32 %d (or %ld) conversions
|
||||
redefinequote 117 %ld|%d|%ld|%d|%ld|%ld|%d|%ld|%d|%ld/%ld|%d|%ld|%d|%ld|%ld|%d|%ld|%d|%ld/%ld|%d|%ld|%d|%ld|%ld|%d|%ld|%d|%ld/%d/%d
|
||||
// string shorter than MAXQUOTELEN-1:
|
||||
qsprintf 116 /*<-*/ 117 /*args:*/ 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
|
||||
|
@ -87,3 +87,21 @@ onevent EVENT_ENTERLEVEL
|
|||
qsprintf 400 /*<-*/ 400 /*args:*/ 401 402 403 404 405 406
|
||||
userquote 400
|
||||
endevent
|
||||
|
||||
// Following code by Hendricks266, from
|
||||
// http://forums.duke4.net/topic/1382-duke-64-mod-thread/page__view__findpost__p__150497
|
||||
gamevar temp 0 0
|
||||
gamevar x 0 0
|
||||
|
||||
definequote 666 This quote sucks
|
||||
|
||||
onevent EVENT_DISPLAYREST
|
||||
qstrlen temp 666
|
||||
setvarvar x tilesizx[STARTALPHANUM] // rough approximation
|
||||
mulvarvar x temp
|
||||
divvar x 2
|
||||
addvar x 160 // put your centered position here
|
||||
gametext STARTALPHANUM x 30 666 0 0 16 0 0 xdim ydim
|
||||
endevent
|
||||
|
||||
//////////
|
||||
|
|
Loading…
Reference in a new issue