mirror of
https://github.com/DrBeef/Raze.git
synced 2025-01-19 15:40:58 +00:00
WIP: direct CON read/write access to structure members via pointer and offset instead of translation function. This is only enabled for wall and sector structure members in this commit.
git-svn-id: https://svn.eduke32.com/eduke32@7194 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
parent
076cc306f8
commit
eb546f111e
6 changed files with 177 additions and 193 deletions
|
@ -779,70 +779,82 @@ const char *EventNames[MAXEVENTS] =
|
|||
};
|
||||
|
||||
#if !defined LUNATIC
|
||||
#define LABEL_SETUP(struct, memb, idx) \
|
||||
#define LABEL_SETUP_UNMATCHED(struct, memb, name, idx) \
|
||||
{ \
|
||||
#memb, idx, sizeof(struct[0].memb) | (is_unsigned <decltype(struct[0].memb)>::value ? LABEL_UNSIGNED : 0), 0, \
|
||||
offsetof(std::remove_pointer <decltype(struct)>::type, memb) \
|
||||
name, idx, sizeof(struct[0].memb) | (is_unsigned <decltype(struct[0].memb)>::value ? LABEL_UNSIGNED : 0), 0, \
|
||||
offsetof(std::remove_pointer <decltype(&struct[0])>::type, memb) \
|
||||
}
|
||||
|
||||
const memberlabel_t SectorLabels[]=
|
||||
{
|
||||
{ "wallptr", SECTOR_WALLPTR, 0, 0, -1 },
|
||||
{ "wallnum", SECTOR_WALLNUM, 0, 0, -1 },
|
||||
{ "ceilingz", SECTOR_CEILINGZ, 0, 0, -1 },
|
||||
{ "ceilingzgoal", SECTOR_CEILINGZGOAL, 0, 0, -1 },
|
||||
{ "ceilingzvel", SECTOR_CEILINGZVEL, 0, 0, -1 },
|
||||
{ "floorz", SECTOR_FLOORZ, 0, 0, -1 },
|
||||
{ "floorzgoal", SECTOR_FLOORZGOAL, 0, 0, -1 },
|
||||
{ "floorzvel", SECTOR_FLOORZVEL, 0, 0, -1 },
|
||||
{ "ceilingstat", SECTOR_CEILINGSTAT, 0, 0, -1 },
|
||||
{ "floorstat", SECTOR_FLOORSTAT, 0, 0, -1 },
|
||||
{ "ceilingpicnum", SECTOR_CEILINGPICNUM, 0, 0, -1 },
|
||||
{ "ceilingslope", SECTOR_CEILINGSLOPE, 0, 0, -1 },
|
||||
{ "ceilingshade", SECTOR_CEILINGSHADE, 0, 0, -1 },
|
||||
{ "ceilingpal", SECTOR_CEILINGPAL, 0, 0, -1 },
|
||||
{ "ceilingxpanning", SECTOR_CEILINGXPANNING, 0, 0, -1 },
|
||||
{ "ceilingypanning", SECTOR_CEILINGYPANNING, 0, 0, -1 },
|
||||
{ "floorpicnum", SECTOR_FLOORPICNUM, 0, 0, -1 },
|
||||
{ "floorslope", SECTOR_FLOORSLOPE, 0, 0, -1 },
|
||||
{ "floorshade", SECTOR_FLOORSHADE, 0, 0, -1 },
|
||||
{ "floorpal", SECTOR_FLOORPAL, 0, 0, -1 },
|
||||
{ "floorxpanning", SECTOR_FLOORXPANNING, 0, 0, -1 },
|
||||
{ "floorypanning", SECTOR_FLOORYPANNING, 0, 0, -1 },
|
||||
{ "visibility", SECTOR_VISIBILITY, 0, 0, -1 },
|
||||
{ "fogpal", SECTOR_FOGPAL, 0, 0, -1 }, // formerly filler
|
||||
{ "alignto", SECTOR_FOGPAL, 0, 0, -1 }, // formerly filler
|
||||
{ "lotag", SECTOR_LOTAG, 0, 0, -1 },
|
||||
{ "hitag", SECTOR_HITAG, 0, 0, -1 },
|
||||
{ "extra", SECTOR_EXTRA, 0, 0, -1 },
|
||||
{ "ceilingbunch", SECTOR_CEILINGBUNCH, 0, 0, -1 },
|
||||
{ "floorbunch", SECTOR_FLOORBUNCH, 0, 0, -1 },
|
||||
{ "ulotag", SECTOR_ULOTAG, 0, 0, -1 },
|
||||
{ "uhitag", SECTOR_UHITAG, 0, 0, -1 },
|
||||
#define LABEL_SETUP(struct, memb, idx) LABEL_SETUP_UNMATCHED(struct, memb, #memb, idx)
|
||||
|
||||
const memberlabel_t SectorLabels[] = {
|
||||
{ "wallptr", SECTOR_WALLPTR, sizeof(sector[0].wallptr) | LABEL_WRITEFUNC, 0, offsetof(usectortype, wallptr) },
|
||||
LABEL_SETUP(sector, wallnum, SECTOR_WALLNUM),
|
||||
|
||||
LABEL_SETUP(sector, ceilingz, SECTOR_CEILINGZ),
|
||||
{ "ceilingzgoal", SECTOR_CEILINGZGOAL, 0, 0, -1 },
|
||||
{ "ceilingzvel", SECTOR_CEILINGZVEL, 0, 0, -1 },
|
||||
|
||||
LABEL_SETUP(sector, floorz, SECTOR_FLOORZ),
|
||||
{ "floorzgoal", SECTOR_FLOORZGOAL, 0, 0, -1 },
|
||||
{ "floorzvel", SECTOR_FLOORZVEL, 0, 0, -1 },
|
||||
|
||||
LABEL_SETUP(sector, ceilingstat, SECTOR_CEILINGSTAT),
|
||||
LABEL_SETUP(sector, floorstat, SECTOR_FLOORSTAT),
|
||||
|
||||
LABEL_SETUP(sector, ceilingpicnum, SECTOR_CEILINGPICNUM),
|
||||
{ "ceilingslope", SECTOR_CEILINGSLOPE, sizeof(sector[0].ceilingheinum), 0, offsetof(usectortype, ceilingheinum) },
|
||||
LABEL_SETUP(sector, ceilingshade, SECTOR_CEILINGSHADE),
|
||||
LABEL_SETUP(sector, ceilingpal, SECTOR_CEILINGPAL),
|
||||
LABEL_SETUP(sector, ceilingxpanning, SECTOR_CEILINGXPANNING),
|
||||
LABEL_SETUP(sector, ceilingypanning, SECTOR_CEILINGYPANNING),
|
||||
|
||||
LABEL_SETUP(sector, floorpicnum, SECTOR_FLOORPICNUM),
|
||||
{ "floorslope", SECTOR_FLOORSLOPE, sizeof(sector[0].floorheinum), 0, offsetof(usectortype, floorheinum) },
|
||||
LABEL_SETUP(sector, floorshade, SECTOR_FLOORSHADE),
|
||||
LABEL_SETUP(sector, floorpal, SECTOR_FLOORPAL),
|
||||
LABEL_SETUP(sector, floorxpanning, SECTOR_FLOORXPANNING),
|
||||
LABEL_SETUP(sector, floorypanning, SECTOR_FLOORYPANNING),
|
||||
|
||||
LABEL_SETUP(sector, visibility, SECTOR_VISIBILITY),
|
||||
LABEL_SETUP(sector, fogpal, SECTOR_FOGPAL),
|
||||
|
||||
LABEL_SETUP(sector, lotag, SECTOR_LOTAG),
|
||||
LABEL_SETUP(sector, hitag, SECTOR_HITAG),
|
||||
LABEL_SETUP(sector, extra, SECTOR_EXTRA),
|
||||
|
||||
{ "ceilingbunch", SECTOR_CEILINGBUNCH, 0, 0, -1 },
|
||||
{ "floorbunch", SECTOR_FLOORBUNCH, 0, 0, -1 },
|
||||
|
||||
{ "ulotag", SECTOR_ULOTAG, sizeof(sector[0].lotag) | LABEL_UNSIGNED, 0, offsetof(usectortype, lotag) },
|
||||
{ "uhitag", SECTOR_UHITAG, sizeof(sector[0].hitag) | LABEL_UNSIGNED, 0, offsetof(usectortype, hitag) },
|
||||
|
||||
};
|
||||
|
||||
const memberlabel_t WallLabels[]=
|
||||
{
|
||||
{ "x", WALL_X, 0, 0, -1 },
|
||||
{ "y", WALL_Y, 0, 0, -1 },
|
||||
{ "point2", WALL_POINT2, 0, 0, -1 },
|
||||
{ "nextwall", WALL_NEXTWALL, 0, 0, -1 },
|
||||
{ "nextsector", WALL_NEXTSECTOR, 0, 0, -1 },
|
||||
{ "cstat", WALL_CSTAT, 0, 0, -1 },
|
||||
{ "picnum", WALL_PICNUM, 0, 0, -1 },
|
||||
{ "overpicnum", WALL_OVERPICNUM, 0, 0, -1 },
|
||||
{ "shade", WALL_SHADE, 0, 0, -1 },
|
||||
{ "pal", WALL_PAL, 0, 0, -1 },
|
||||
{ "xrepeat", WALL_XREPEAT, 0, 0, -1 },
|
||||
{ "yrepeat", WALL_YREPEAT, 0, 0, -1 },
|
||||
{ "xpanning", WALL_XPANNING, 0, 0, -1 },
|
||||
{ "ypanning", WALL_YPANNING, 0, 0, -1 },
|
||||
{ "lotag", WALL_LOTAG, 0, 0, -1 },
|
||||
{ "hitag", WALL_HITAG, 0, 0, -1 },
|
||||
{ "extra", WALL_EXTRA, 0, 0, -1 },
|
||||
{ "ulotag", WALL_ULOTAG, 0, 0, -1 },
|
||||
{ "uhitag", WALL_UHITAG, 0, 0, -1 },
|
||||
{ "blend", WALL_BLEND, 0, 0, -1 },
|
||||
LABEL_SETUP(wall, x, WALL_X),
|
||||
LABEL_SETUP(wall, y, WALL_Y),
|
||||
LABEL_SETUP(wall, point2, WALL_POINT2),
|
||||
LABEL_SETUP(wall, nextwall, WALL_NEXTWALL),
|
||||
LABEL_SETUP(wall, nextsector, WALL_NEXTSECTOR),
|
||||
LABEL_SETUP(wall, cstat, WALL_CSTAT),
|
||||
LABEL_SETUP(wall, picnum, WALL_PICNUM),
|
||||
LABEL_SETUP(wall, overpicnum, WALL_OVERPICNUM),
|
||||
LABEL_SETUP(wall, shade, WALL_SHADE),
|
||||
LABEL_SETUP(wall, pal, WALL_PAL),
|
||||
LABEL_SETUP(wall, xrepeat, WALL_XREPEAT),
|
||||
LABEL_SETUP(wall, yrepeat, WALL_YREPEAT),
|
||||
LABEL_SETUP(wall, xpanning, WALL_XPANNING),
|
||||
LABEL_SETUP(wall, ypanning, WALL_YPANNING),
|
||||
LABEL_SETUP(wall, lotag, WALL_LOTAG),
|
||||
LABEL_SETUP(wall, hitag, WALL_HITAG),
|
||||
LABEL_SETUP(wall, extra, WALL_EXTRA),
|
||||
|
||||
{ "ulotag", WALL_ULOTAG, sizeof(wall[0].lotag) | LABEL_UNSIGNED, 0, offsetof(uwalltype, lotag) },
|
||||
{ "uhitag", WALL_UHITAG, sizeof(wall[0].hitag) | LABEL_UNSIGNED, 0, offsetof(uwalltype, hitag) },
|
||||
|
||||
{ "blend", WALL_BLEND, 0, 0, -1 },
|
||||
};
|
||||
|
||||
const memberlabel_t ActorLabels[]=
|
||||
|
@ -1142,7 +1154,6 @@ const memberlabel_t ProjectileLabels[]=
|
|||
|
||||
const memberlabel_t UserdefsLabels[]=
|
||||
{
|
||||
// { "<null>", 1, 0, 0, -1 },
|
||||
{ "god", USERDEFS_GOD, 0, 0, -1 },
|
||||
{ "warp_on", USERDEFS_WARP_ON, 0, 0, -1 },
|
||||
{ "cashman", USERDEFS_CASHMAN, 0, 0, -1 },
|
||||
|
@ -1376,7 +1387,7 @@ const tokenmap_t iter_tokens [] =
|
|||
{ "sprofstat", ITER_SPRITESOFSTATUS },
|
||||
{ "walofsec", ITER_WALLSOFSECTOR },
|
||||
};
|
||||
|
||||
#undef LABEL_SETUP
|
||||
#endif
|
||||
|
||||
char *bitptr; // pointer to bitmap of which bytecode positions contain pointers
|
||||
|
@ -3577,14 +3588,9 @@ DO_DEFSTATE:
|
|||
|
||||
if (tw == CON_USERACTOR)
|
||||
{
|
||||
if (j & 1)
|
||||
g_tile[*g_scriptPtr].flags |= SFLAG_BADGUY;
|
||||
|
||||
if (j & 2)
|
||||
g_tile[*g_scriptPtr].flags |= (SFLAG_BADGUY|SFLAG_BADGUYSTAYPUT);
|
||||
|
||||
if (j & 4)
|
||||
g_tile[*g_scriptPtr].flags |= SFLAG_ROTFIXED;
|
||||
if (j & 1) g_tile[*g_scriptPtr].flags |= SFLAG_BADGUY;
|
||||
if (j & 2) g_tile[*g_scriptPtr].flags |= (SFLAG_BADGUY|SFLAG_BADGUYSTAYPUT);
|
||||
if (j & 4) g_tile[*g_scriptPtr].flags |= SFLAG_ROTFIXED;
|
||||
}
|
||||
|
||||
for (j=0; j<4; j++)
|
||||
|
|
|
@ -52,6 +52,8 @@ enum
|
|||
#define LABEL_UNSIGNED 8
|
||||
#define LABEL_HASPARM2 16
|
||||
#define LABEL_ISSTRING 32
|
||||
#define LABEL_READFUNC 64
|
||||
#define LABEL_WRITEFUNC 128
|
||||
|
||||
#define VM_INSTMASK 0xfff
|
||||
|
||||
|
|
|
@ -4401,20 +4401,32 @@ GAMEEXEC_STATIC void VM_Execute(native_t loop)
|
|||
case CON_SETSECTOR:
|
||||
insptr++;
|
||||
{
|
||||
int const sectNum = (*insptr++ != g_thisActorVarID) ? Gv_GetVarX(*(insptr - 1)) : sprite[vm.spriteNum].sectnum;
|
||||
int const labelNum = *insptr++;
|
||||
int const sectNum = (*insptr++ != g_thisActorVarID) ? Gv_GetVarX(*(insptr - 1)) : sprite[vm.spriteNum].sectnum;
|
||||
int const labelNum = *insptr++;
|
||||
auto const §Label = SectorLabels[labelNum];
|
||||
int const newValue = Gv_GetVarX(*insptr++);
|
||||
|
||||
VM_SetSector(sectNum, labelNum, Gv_GetVarX(*insptr++));
|
||||
if (sectLabel.offset == -1 || sectLabel.flags & LABEL_WRITEFUNC)
|
||||
{
|
||||
VM_SetSector(sectNum, labelNum, Gv_GetVarX(*insptr++));
|
||||
continue;
|
||||
}
|
||||
|
||||
VM_SetStruct(sectLabel.flags, (intptr_t *)((char *)§or[sectNum] + sectLabel.offset), newValue);
|
||||
continue;
|
||||
}
|
||||
|
||||
case CON_GETSECTOR:
|
||||
insptr++;
|
||||
{
|
||||
int const sectNum = (*insptr++ != g_thisActorVarID) ? Gv_GetVarX(*(insptr - 1)) : sprite[vm.spriteNum].sectnum;
|
||||
int const labelNum = *insptr++;
|
||||
int const sectNum = (*insptr++ != g_thisActorVarID) ? Gv_GetVarX(*(insptr - 1)) : sprite[vm.spriteNum].sectnum;
|
||||
int const labelNum = *insptr++;
|
||||
auto const §Label = SectorLabels[labelNum];
|
||||
|
||||
Gv_SetVarX(*insptr++, VM_GetSector(sectNum, labelNum));
|
||||
Gv_SetVarX(*insptr++,
|
||||
(sectLabel.offset != -1 && (sectLabel.flags & LABEL_READFUNC) != LABEL_READFUNC)
|
||||
? VM_GetStruct(sectLabel.flags, (intptr_t *)((char *)§or[sectNum] + sectLabel.offset))
|
||||
: VM_GetSector(sectNum, labelNum));
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -4647,7 +4659,7 @@ GAMEEXEC_STATIC void VM_Execute(native_t loop)
|
|||
case CON_GETPROJECTILE:
|
||||
insptr++;
|
||||
{
|
||||
tw = Gv_GetVarX(*insptr++);
|
||||
tw = Gv_GetVarX(*insptr++);
|
||||
int const labelNum = *insptr++;
|
||||
Gv_SetVarX(*insptr++, VM_GetProjectile(tw, labelNum));
|
||||
continue;
|
||||
|
@ -4656,7 +4668,7 @@ GAMEEXEC_STATIC void VM_Execute(native_t loop)
|
|||
case CON_SETPROJECTILE:
|
||||
insptr++;
|
||||
{
|
||||
tw = Gv_GetVarX(*insptr++);
|
||||
tw = Gv_GetVarX(*insptr++);
|
||||
int const labelNum = *insptr++;
|
||||
VM_SetProjectile(tw, labelNum, Gv_GetVarX(*insptr++));
|
||||
continue;
|
||||
|
@ -4667,10 +4679,19 @@ GAMEEXEC_STATIC void VM_Execute(native_t loop)
|
|||
{
|
||||
tw = *insptr++;
|
||||
|
||||
int const wallNum = Gv_GetVarX(tw);
|
||||
int const labelNum = *insptr++;
|
||||
int const wallNum = Gv_GetVarX(tw);
|
||||
int const labelNum = *insptr++;
|
||||
auto const &wallLabel = WallLabels[labelNum];
|
||||
int const newValue = Gv_GetVarX(*insptr++);
|
||||
|
||||
if (wallLabel.offset == -1 || wallLabel.flags & LABEL_WRITEFUNC)
|
||||
{
|
||||
VM_SetWall(wallNum, labelNum, newValue);
|
||||
continue;
|
||||
}
|
||||
|
||||
VM_SetStruct(wallLabel.flags, (intptr_t *)((char *)&wall[wallNum] + wallLabel.offset), newValue);
|
||||
|
||||
VM_SetWall(wallNum, labelNum, Gv_GetVarX(*insptr++));
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -4679,10 +4700,15 @@ GAMEEXEC_STATIC void VM_Execute(native_t loop)
|
|||
{
|
||||
tw = *insptr++;
|
||||
|
||||
int const wallNum = Gv_GetVarX(tw);
|
||||
int const labelNum = *insptr++;
|
||||
int const wallNum = Gv_GetVarX(tw);
|
||||
int const labelNum = *insptr++;
|
||||
auto const &wallLabel = WallLabels[labelNum];
|
||||
|
||||
Gv_SetVarX(*insptr++,
|
||||
(wallLabel.offset != -1 && (wallLabel.flags & LABEL_READFUNC) != LABEL_READFUNC)
|
||||
? VM_GetStruct(wallLabel.flags, (intptr_t *)((char *)&wall[wallNum] + wallLabel.offset))
|
||||
: VM_GetWall(wallNum, labelNum));
|
||||
|
||||
Gv_SetVarX(*insptr++, VM_GetWall(wallNum, labelNum));
|
||||
continue;
|
||||
}
|
||||
|
||||
|
|
|
@ -34,7 +34,7 @@ int32_t __fastcall VM_GetPlayerInput(int const playerNum, int32_t labelNum);
|
|||
void __fastcall VM_SetPlayerInput(int const playerNum, int const labelNum, int32_t const newValue);
|
||||
int32_t __fastcall VM_GetWall(int const wallNum, int32_t labelNum);
|
||||
void __fastcall VM_SetWall(int const wallNum, int const labelNum, int32_t const newValue);
|
||||
int32_t __fastcall VM_GetSector(int const sectNum, int labelNum);
|
||||
int32_t __fastcall VM_GetSector(int const sectNum, int32_t labelNum);
|
||||
void __fastcall VM_SetSector(int const sectNum, int const labelNum, int32_t newValue);
|
||||
int32_t __fastcall VM_GetSprite(int const spriteNum, int32_t labelNum, int const lParm2);
|
||||
void __fastcall VM_SetSprite(int const spriteNum, int const labelNum, int const lParm2, int32_t const newValue);
|
||||
|
@ -969,8 +969,6 @@ void __fastcall VM_SetPlayerInput(int const playerNum, int const labelNum, int32
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
int32_t __fastcall VM_GetWall(int const wallNum, int32_t labelNum)
|
||||
{
|
||||
if (EDUKE32_PREDICT_FALSE((unsigned)wallNum >= (unsigned)numwalls))
|
||||
|
@ -979,31 +977,8 @@ int32_t __fastcall VM_GetWall(int const wallNum, int32_t labelNum)
|
|||
return -1;
|
||||
}
|
||||
|
||||
auto const &w = *(uwalltype *)&wall[wallNum];
|
||||
|
||||
switch (labelNum)
|
||||
{
|
||||
case WALL_X: labelNum = w.x; break;
|
||||
case WALL_Y: labelNum = w.y; break;
|
||||
case WALL_POINT2: labelNum = w.point2; break;
|
||||
case WALL_NEXTWALL: labelNum = w.nextwall; break;
|
||||
case WALL_NEXTSECTOR: labelNum = w.nextsector; break;
|
||||
case WALL_CSTAT: labelNum = w.cstat; break;
|
||||
case WALL_PICNUM: labelNum = w.picnum; break;
|
||||
case WALL_OVERPICNUM: labelNum = w.overpicnum; break;
|
||||
case WALL_SHADE: labelNum = w.shade; break;
|
||||
case WALL_PAL: labelNum = w.pal; break;
|
||||
case WALL_XREPEAT: labelNum = w.xrepeat; break;
|
||||
case WALL_YREPEAT: labelNum = w.yrepeat; break;
|
||||
case WALL_XPANNING: labelNum = w.xpanning; break;
|
||||
case WALL_YPANNING: labelNum = w.ypanning; break;
|
||||
|
||||
case WALL_LOTAG: labelNum = (int16_t)w.lotag; break;
|
||||
case WALL_HITAG: labelNum = (int16_t)w.hitag; break;
|
||||
case WALL_ULOTAG: labelNum = (uint16_t)w.lotag; break;
|
||||
case WALL_UHITAG: labelNum = (uint16_t)w.hitag; break;
|
||||
|
||||
case WALL_EXTRA: labelNum = w.extra; break;
|
||||
case WALL_BLEND:
|
||||
#ifdef NEW_MAP_FORMAT
|
||||
labelNum = w.blend;
|
||||
|
@ -1026,31 +1001,8 @@ void __fastcall VM_SetWall(int const wallNum, int const labelNum, int32_t const
|
|||
return;
|
||||
}
|
||||
|
||||
auto &w = wall[wallNum];
|
||||
|
||||
switch (labelNum)
|
||||
{
|
||||
case WALL_X: w.x = newValue; break;
|
||||
case WALL_Y: w.y = newValue; break;
|
||||
case WALL_POINT2: w.point2 = newValue; break;
|
||||
case WALL_NEXTWALL: w.nextwall = newValue; break;
|
||||
case WALL_NEXTSECTOR: w.nextsector = newValue; break;
|
||||
case WALL_CSTAT: w.cstat = newValue; break;
|
||||
case WALL_PICNUM: w.picnum = newValue; break;
|
||||
case WALL_OVERPICNUM: w.overpicnum = newValue; break;
|
||||
case WALL_SHADE: w.shade = newValue; break;
|
||||
case WALL_PAL: w.pal = newValue; break;
|
||||
case WALL_XREPEAT: w.xrepeat = newValue; break;
|
||||
case WALL_YREPEAT: w.yrepeat = newValue; break;
|
||||
case WALL_XPANNING: w.xpanning = newValue; break;
|
||||
case WALL_YPANNING: w.ypanning = newValue; break;
|
||||
|
||||
case WALL_LOTAG: w.lotag = (int16_t)newValue; break;
|
||||
case WALL_HITAG: w.hitag = (int16_t)newValue; break;
|
||||
case WALL_ULOTAG: w.lotag = (uint16_t)newValue; break;
|
||||
case WALL_UHITAG: w.hitag = (uint16_t)newValue; break;
|
||||
|
||||
case WALL_EXTRA: w.extra = newValue; break;
|
||||
case WALL_BLEND:
|
||||
#ifdef NEW_MAP_FORMAT
|
||||
w.blend = newValue;
|
||||
|
@ -1062,7 +1014,7 @@ void __fastcall VM_SetWall(int const wallNum, int const labelNum, int32_t const
|
|||
|
||||
}
|
||||
|
||||
int32_t __fastcall VM_GetSector(int const sectNum, int labelNum)
|
||||
int32_t __fastcall VM_GetSector(int const sectNum, int32_t labelNum)
|
||||
{
|
||||
if (EDUKE32_PREDICT_FALSE((unsigned)sectNum >= (unsigned)numsectors))
|
||||
{
|
||||
|
@ -1074,12 +1026,6 @@ int32_t __fastcall VM_GetSector(int const sectNum, int labelNum)
|
|||
|
||||
switch (labelNum)
|
||||
{
|
||||
case SECTOR_WALLPTR: labelNum = s.wallptr; break;
|
||||
case SECTOR_WALLNUM: labelNum = s.wallnum; break;
|
||||
|
||||
case SECTOR_CEILINGZ: labelNum = s.ceilingz; break;
|
||||
case SECTOR_FLOORZ: labelNum = s.floorz; break;
|
||||
|
||||
case SECTOR_CEILINGZVEL:
|
||||
labelNum = (GetAnimationGoal(&s.ceilingz) == -1) ? 0 : s.extra; break;
|
||||
case SECTOR_CEILINGZGOAL:
|
||||
|
@ -1091,28 +1037,6 @@ int32_t __fastcall VM_GetSector(int const sectNum, int labelNum)
|
|||
case SECTOR_FLOORZGOAL:
|
||||
labelNum = GetAnimationGoal(&s.floorz); break;
|
||||
|
||||
case SECTOR_CEILINGSTAT: labelNum = s.ceilingstat; break;
|
||||
case SECTOR_FLOORSTAT: labelNum = s.floorstat; break;
|
||||
case SECTOR_CEILINGPICNUM: labelNum = s.ceilingpicnum; break;
|
||||
case SECTOR_CEILINGSLOPE: labelNum = s.ceilingheinum; break;
|
||||
case SECTOR_CEILINGSHADE: labelNum = s.ceilingshade; break;
|
||||
case SECTOR_CEILINGPAL: labelNum = s.ceilingpal; break;
|
||||
case SECTOR_CEILINGXPANNING: labelNum = s.ceilingxpanning; break;
|
||||
case SECTOR_CEILINGYPANNING: labelNum = s.ceilingypanning; break;
|
||||
case SECTOR_FLOORPICNUM: labelNum = s.floorpicnum; break;
|
||||
case SECTOR_FLOORSLOPE: labelNum = s.floorheinum; break;
|
||||
case SECTOR_FLOORSHADE: labelNum = s.floorshade; break;
|
||||
case SECTOR_FLOORPAL: labelNum = s.floorpal; break;
|
||||
case SECTOR_FLOORXPANNING: labelNum = s.floorxpanning; break;
|
||||
case SECTOR_FLOORYPANNING: labelNum = s.floorypanning; break;
|
||||
case SECTOR_VISIBILITY: labelNum = s.visibility; break;
|
||||
case SECTOR_FOGPAL: labelNum = s.fogpal; break;
|
||||
case SECTOR_LOTAG: labelNum = (int16_t)s.lotag; break;
|
||||
case SECTOR_HITAG: labelNum = (int16_t)s.hitag; break;
|
||||
case SECTOR_ULOTAG: labelNum = (uint16_t)s.lotag; break;
|
||||
case SECTOR_UHITAG: labelNum = (uint16_t)s.hitag; break;
|
||||
case SECTOR_EXTRA: labelNum = s.extra; break;
|
||||
|
||||
case SECTOR_CEILINGBUNCH:
|
||||
case SECTOR_FLOORBUNCH:
|
||||
#ifdef YAX_ENABLE
|
||||
|
@ -1143,10 +1067,6 @@ void __fastcall VM_SetSector(int const sectNum, int const labelNum, int32_t newV
|
|||
case SECTOR_WALLPTR:
|
||||
setfirstwall(sectNum, newValue); break;
|
||||
|
||||
case SECTOR_WALLNUM: s.wallnum = newValue; break;
|
||||
case SECTOR_CEILINGZ: s.ceilingz = newValue; break;
|
||||
case SECTOR_FLOORZ: s.floorz = newValue; break;
|
||||
|
||||
case SECTOR_CEILINGZVEL:
|
||||
s.extra = newValue;
|
||||
if ((newValue = GetAnimationGoal(&s.ceilingz)) != -1)
|
||||
|
@ -1165,31 +1085,11 @@ void __fastcall VM_SetSector(int const sectNum, int const labelNum, int32_t newV
|
|||
}
|
||||
break;
|
||||
|
||||
case SECTOR_CEILINGSTAT: s.ceilingstat = newValue; break;
|
||||
case SECTOR_FLOORSTAT: s.floorstat = newValue; break;
|
||||
case SECTOR_CEILINGPICNUM: s.ceilingpicnum = newValue; break;
|
||||
case SECTOR_CEILINGSLOPE: s.ceilingheinum = newValue; break;
|
||||
case SECTOR_CEILINGSHADE: s.ceilingshade = newValue; break;
|
||||
case SECTOR_CEILINGPAL: s.ceilingpal = newValue; break;
|
||||
case SECTOR_CEILINGXPANNING: s.ceilingxpanning = newValue; break;
|
||||
case SECTOR_CEILINGYPANNING: s.ceilingypanning = newValue; break;
|
||||
case SECTOR_FLOORPICNUM: s.floorpicnum = newValue; break;
|
||||
case SECTOR_FLOORSLOPE: s.floorheinum = newValue; break;
|
||||
case SECTOR_FLOORSHADE: s.floorshade = newValue; break;
|
||||
case SECTOR_FLOORPAL: s.floorpal = newValue; break;
|
||||
case SECTOR_FLOORXPANNING: s.floorxpanning = newValue; break;
|
||||
case SECTOR_FLOORYPANNING: s.floorypanning = newValue; break;
|
||||
case SECTOR_VISIBILITY: s.visibility = newValue; break;
|
||||
case SECTOR_FOGPAL: s.fogpal = newValue; break;
|
||||
case SECTOR_LOTAG: s.lotag = (int16_t)newValue; break;
|
||||
case SECTOR_HITAG: s.hitag = (int16_t)newValue; break;
|
||||
case SECTOR_ULOTAG: s.lotag = (uint16_t)newValue; break;
|
||||
case SECTOR_UHITAG: s.hitag = (uint16_t)newValue; break;
|
||||
case SECTOR_EXTRA: s.extra = newValue; break;
|
||||
|
||||
case SECTOR_CEILINGBUNCH:
|
||||
case SECTOR_FLOORBUNCH:
|
||||
break;
|
||||
|
||||
default: EDUKE32_UNREACHABLE_SECTION(break);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -596,13 +596,13 @@ int __fastcall Gv_GetArrayValue(int const id, int index)
|
|||
|
||||
switch (aGameArrays[id].flags & GAMEARRAY_TYPE_MASK)
|
||||
{
|
||||
case 0: returnValue = (aGameArrays[id].pValues)[index]; break;
|
||||
case 0: returnValue = (aGameArrays[id].pValues)[index]; break;
|
||||
|
||||
case GAMEARRAY_INT16: returnValue = ((int16_t *)aGameArrays[id].pValues)[index]; break;
|
||||
case GAMEARRAY_INT8: returnValue = ((int8_t *)aGameArrays[id].pValues)[index]; break;
|
||||
case GAMEARRAY_INT8: returnValue = ((int8_t *)aGameArrays[id].pValues)[index]; break;
|
||||
|
||||
case GAMEARRAY_UINT16:returnValue = ((uint16_t *)aGameArrays[id].pValues)[index]; break;
|
||||
case GAMEARRAY_UINT8: returnValue = ((uint8_t *)aGameArrays[id].pValues)[index]; break;
|
||||
case GAMEARRAY_UINT16: returnValue = ((uint16_t *)aGameArrays[id].pValues)[index]; break;
|
||||
case GAMEARRAY_UINT8: returnValue = ((uint8_t *)aGameArrays[id].pValues)[index]; break;
|
||||
|
||||
case GAMEARRAY_BITMAP:returnValue = !!(((uint8_t *)aGameArrays[id].pValues)[index >> 3] & pow2char[index & 7]); break;
|
||||
}
|
||||
|
@ -748,13 +748,19 @@ special:
|
|||
case STRUCT_SECTOR:
|
||||
if (arrayIndexVar == g_thisActorVarID)
|
||||
arrayIndex = vm.pSprite->sectnum;
|
||||
|
||||
CHECK_INDEX(MAXSECTORS);
|
||||
returnValue = VM_GetSector(arrayIndex, labelNum);
|
||||
|
||||
returnValue = (SectorLabels[labelNum].offset != -1 && (SectorLabels[labelNum].flags & LABEL_READFUNC) == 0)
|
||||
? VM_GetStruct(SectorLabels[labelNum].flags, (intptr_t *)((char *)§or[arrayIndex] + SectorLabels[labelNum].offset))
|
||||
: VM_GetSector(arrayIndex, labelNum);
|
||||
break;
|
||||
|
||||
case STRUCT_WALL:
|
||||
CHECK_INDEX(MAXWALLS);
|
||||
returnValue = VM_GetWall(arrayIndex, labelNum);
|
||||
returnValue = (WallLabels[labelNum].offset != -1 && (WallLabels[labelNum].flags & LABEL_READFUNC) == 0)
|
||||
? VM_GetStruct(WallLabels[labelNum].flags, (intptr_t *)((char *)&wall[arrayIndex] + WallLabels[labelNum].offset))
|
||||
: VM_GetWall(arrayIndex, labelNum);
|
||||
break;
|
||||
|
||||
case STRUCT_USERDEF:
|
||||
|
@ -951,13 +957,19 @@ int __fastcall Gv_GetSpecialVarX(int gameVar)
|
|||
case STRUCT_SECTOR:
|
||||
if (arrayIndexVar == g_thisActorVarID)
|
||||
arrayIndex = vm.pSprite->sectnum;
|
||||
|
||||
CHECK_INDEX(MAXSECTORS, GVX_BADSECTOR);
|
||||
returnValue = VM_GetSector(arrayIndex, labelNum);
|
||||
|
||||
returnValue = (SectorLabels[labelNum].offset != -1 && (SectorLabels[labelNum].flags & LABEL_READFUNC) == 0)
|
||||
? VM_GetStruct(SectorLabels[labelNum].flags, (intptr_t *)((char *)§or[arrayIndex] + SectorLabels[labelNum].offset))
|
||||
: VM_GetSector(arrayIndex, labelNum);
|
||||
break;
|
||||
|
||||
case STRUCT_WALL:
|
||||
CHECK_INDEX(MAXWALLS, GVX_BADWALL);
|
||||
returnValue = VM_GetWall(arrayIndex, labelNum);
|
||||
returnValue = (WallLabels[labelNum].offset != -1 && (WallLabels[labelNum].flags & LABEL_READFUNC) == 0)
|
||||
? VM_GetStruct(WallLabels[labelNum].flags, (intptr_t *)((char *)&wall[arrayIndex] + WallLabels[labelNum].offset))
|
||||
: VM_GetWall(arrayIndex, labelNum);
|
||||
break;
|
||||
|
||||
case STRUCT_USERDEF:
|
||||
|
|
|
@ -158,6 +158,44 @@ void Gv_Init(void);
|
|||
void Gv_FinalizeWeaponDefaults(void);
|
||||
|
||||
#if !defined LUNATIC
|
||||
static inline int __fastcall VM_GetStruct(uint32_t const flags, intptr_t * const addr)
|
||||
{
|
||||
Bassert(flags & (LABEL_CHAR|LABEL_SHORT|LABEL_INT));
|
||||
|
||||
int returnValue = 0;
|
||||
|
||||
switch (flags & (LABEL_CHAR|LABEL_SHORT|LABEL_INT|LABEL_UNSIGNED))
|
||||
{
|
||||
case LABEL_CHAR: returnValue = *(int8_t *)addr; break;
|
||||
case LABEL_CHAR|LABEL_UNSIGNED: returnValue = *(uint8_t *)addr; break;
|
||||
|
||||
case LABEL_SHORT: returnValue = *(int16_t *)addr; break;
|
||||
case LABEL_SHORT|LABEL_UNSIGNED: returnValue = *(uint16_t *)addr; break;
|
||||
|
||||
case LABEL_INT: returnValue = *(int32_t *)addr; break;
|
||||
case LABEL_INT|LABEL_UNSIGNED: returnValue = *(uint32_t *)addr; break;
|
||||
}
|
||||
|
||||
return returnValue;
|
||||
}
|
||||
|
||||
static FORCE_INLINE void __fastcall VM_SetStruct(uint32_t const flags, intptr_t * const addr, int32_t newValue)
|
||||
{
|
||||
Bassert(flags & (LABEL_CHAR|LABEL_SHORT|LABEL_INT));
|
||||
|
||||
switch (flags & (LABEL_CHAR|LABEL_SHORT|LABEL_INT|LABEL_UNSIGNED))
|
||||
{
|
||||
case LABEL_CHAR: *(int8_t *)addr = newValue; break;
|
||||
case LABEL_CHAR|LABEL_UNSIGNED: *(uint8_t *)addr = newValue; break;
|
||||
|
||||
case LABEL_SHORT: *(int16_t *)addr = newValue; break;
|
||||
case LABEL_SHORT|LABEL_UNSIGNED: *(uint16_t *)addr = newValue; break;
|
||||
|
||||
case LABEL_INT: *(int32_t *)addr = newValue; break;
|
||||
case LABEL_INT|LABEL_UNSIGNED: *(uint32_t *)addr = newValue; break;
|
||||
}
|
||||
}
|
||||
|
||||
#define VM_GAMEVAR_OPERATOR(func, operator) \
|
||||
static FORCE_INLINE void __fastcall func(int const id, int32_t const operand) \
|
||||
{ \
|
||||
|
|
Loading…
Reference in a new issue