mirror of
https://github.com/ZDoom/raze-gles.git
synced 2024-11-10 23:02:03 +00:00
Add automatic tracking to the sector[], wall[], sprite[] and tsprite[]
arrays; any write access to them will run the corresponding hook and write to the [sector/wall/sprite/tsprite]clean array. Note: tsprite and sprite use the same hook and require running a few more instructions per access in order to disambiguiate; this could be made more optimal (like the other arrays) by clearly separating the types in the game code. Note #2: taking a member's address currently marks it dirty because of tons of helper functions across the editor code. I don't know how many read-only accesses we have after taking a member address, but it could also be fixed with some finessing of the code. git-svn-id: https://svn.eduke32.com/eduke32@3138 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
parent
abc3fa4e8d
commit
a0dd0c85a5
7 changed files with 251 additions and 43 deletions
|
@ -243,6 +243,8 @@ ifneq (0,$(RELEASE))
|
|||
endif
|
||||
ifeq (0,$(DEBUGANYWAY))
|
||||
debug+= -fomit-frame-pointer -DNDEBUG
|
||||
else
|
||||
debug+= -DDEBUGGINGAIDS
|
||||
endif
|
||||
ifneq (0,$(LTO))
|
||||
BASELDFLAGS+= -flto
|
||||
|
|
|
@ -170,6 +170,38 @@ enum {
|
|||
# define EXTERN extern
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
static inline void sector_tracker_hook(unsigned int address);
|
||||
static inline void wall_tracker_hook(unsigned int address);
|
||||
static inline void sprite_tracker_hook(unsigned int address);
|
||||
|
||||
#define __TRACKER_NAME SectorTracker
|
||||
#define __TRACKER_GLOBAL_HOOK sector_tracker_hook
|
||||
#include "tracker.hpp"
|
||||
#undef __TRACKER_NAME
|
||||
#undef __TRACKER_GLOBAL_HOOK
|
||||
|
||||
#define __TRACKER_NAME WallTracker
|
||||
#define __TRACKER_GLOBAL_HOOK wall_tracker_hook
|
||||
#include "tracker.hpp"
|
||||
#undef __TRACKER_NAME
|
||||
#undef __TRACKER_GLOBAL_HOOK
|
||||
|
||||
#define __TRACKER_NAME SpriteTracker
|
||||
#define __TRACKER_GLOBAL_HOOK sprite_tracker_hook
|
||||
#include "tracker.hpp"
|
||||
#undef __TRACKER_NAME
|
||||
#undef __TRACKER_GLOBAL_HOOK
|
||||
|
||||
#define Tracker(Container, Type) Container##Tracker<Type>
|
||||
|
||||
#else
|
||||
|
||||
#define Tracker(Container, Type) Type
|
||||
|
||||
#endif // __cplusplus
|
||||
|
||||
#pragma pack(push,1)
|
||||
|
||||
//ceilingstat/floorstat:
|
||||
|
@ -193,17 +225,17 @@ enum {
|
|||
//40 bytes
|
||||
typedef struct
|
||||
{
|
||||
int16_t wallptr, wallnum;
|
||||
int32_t ceilingz, floorz;
|
||||
int16_t ceilingstat, floorstat;
|
||||
int16_t ceilingpicnum, ceilingheinum;
|
||||
int8_t ceilingshade;
|
||||
uint8_t ceilingpal, ceilingxpanning, ceilingypanning;
|
||||
int16_t floorpicnum, floorheinum;
|
||||
int8_t floorshade;
|
||||
uint8_t floorpal, floorxpanning, floorypanning;
|
||||
uint8_t visibility, filler;
|
||||
int16_t lotag, hitag, extra;
|
||||
Tracker(Sector, int16_t) wallptr, wallnum;
|
||||
Tracker(Sector, int32_t) ceilingz, floorz;
|
||||
Tracker(Sector, int16_t) ceilingstat, floorstat;
|
||||
Tracker(Sector, int16_t) ceilingpicnum, ceilingheinum;
|
||||
Tracker(Sector, int8_t) ceilingshade;
|
||||
Tracker(Sector, uint8_t) ceilingpal, ceilingxpanning, ceilingypanning;
|
||||
Tracker(Sector, int16_t) floorpicnum, floorheinum;
|
||||
Tracker(Sector, int8_t) floorshade;
|
||||
Tracker(Sector, uint8_t) floorpal, floorxpanning, floorypanning;
|
||||
Tracker(Sector, uint8_t) visibility, filler;
|
||||
Tracker(Sector, int16_t) lotag, hitag, extra;
|
||||
} sectortype;
|
||||
|
||||
//cstat:
|
||||
|
@ -223,12 +255,12 @@ typedef struct
|
|||
//32 bytes
|
||||
typedef struct
|
||||
{
|
||||
int32_t x, y;
|
||||
int16_t point2, nextwall, nextsector, cstat;
|
||||
int16_t picnum, overpicnum;
|
||||
int8_t shade;
|
||||
uint8_t pal, xrepeat, yrepeat, xpanning, ypanning;
|
||||
int16_t lotag, hitag, extra;
|
||||
Tracker(Wall, int32_t) x, y;
|
||||
Tracker(Wall, int16_t) point2, nextwall, nextsector, cstat;
|
||||
Tracker(Wall, int16_t) picnum, overpicnum;
|
||||
Tracker(Wall, int8_t) shade;
|
||||
Tracker(Wall, uint8_t) pal, xrepeat, yrepeat, xpanning, ypanning;
|
||||
Tracker(Wall, int16_t) lotag, hitag, extra;
|
||||
} walltype;
|
||||
|
||||
//cstat:
|
||||
|
@ -253,15 +285,15 @@ typedef struct
|
|||
//44 bytes
|
||||
typedef struct
|
||||
{
|
||||
int32_t x, y, z;
|
||||
int16_t cstat, picnum;
|
||||
int8_t shade;
|
||||
uint8_t pal, clipdist, filler;
|
||||
uint8_t xrepeat, yrepeat;
|
||||
int8_t xoffset, yoffset;
|
||||
int16_t sectnum, statnum;
|
||||
int16_t ang, owner, xvel, yvel, zvel;
|
||||
int16_t lotag, hitag, extra;
|
||||
Tracker(Sprite, int32_t) x, y, z;
|
||||
Tracker(Sprite, int16_t) cstat, picnum;
|
||||
Tracker(Sprite, int8_t) shade;
|
||||
Tracker(Sprite, uint8_t) pal, clipdist, filler;
|
||||
Tracker(Sprite, uint8_t) xrepeat, yrepeat;
|
||||
Tracker(Sprite, int8_t) xoffset, yoffset;
|
||||
Tracker(Sprite, int16_t) sectnum, statnum;
|
||||
Tracker(Sprite, int16_t) ang, owner, xvel, yvel, zvel;
|
||||
Tracker(Sprite, int16_t) lotag, hitag, extra;
|
||||
} spritetype;
|
||||
|
||||
typedef struct {
|
||||
|
@ -321,6 +353,53 @@ EXTERN spritetype sprite[MAXSPRITES];
|
|||
EXTERN spritetype tsprite[MAXSPRITESONSCREEN];
|
||||
#endif
|
||||
|
||||
EXTERN char sectorclean[MAXSECTORS + M32_FIXME_SECTORS];
|
||||
EXTERN char wallclean[MAXWALLS + M32_FIXME_WALLS];
|
||||
EXTERN char spriteclean[MAXSPRITES];
|
||||
EXTERN char tspriteclean[MAXSPRITESONSCREEN];
|
||||
|
||||
static inline void sector_tracker_hook(unsigned int address)
|
||||
{
|
||||
address -= (int)(sector);
|
||||
address /= sizeof(sectortype);
|
||||
|
||||
if (address > MAXSECTORS + M32_FIXME_SECTORS) return;
|
||||
|
||||
sectorclean[address] = 0;
|
||||
}
|
||||
|
||||
static inline void wall_tracker_hook(unsigned int address)
|
||||
{
|
||||
address -= (int)(wall);
|
||||
address /= sizeof(walltype);
|
||||
|
||||
if (address > MAXWALLS + M32_FIXME_WALLS) return;
|
||||
|
||||
wallclean[address] = 0;
|
||||
}
|
||||
|
||||
static inline void sprite_tracker_hook(unsigned int address)
|
||||
{
|
||||
if (address >= (int)(sprite) &&
|
||||
address < (int)(sprite) + MAXSPRITES * sizeof(spritetype))
|
||||
{
|
||||
address -= (int)(sprite);
|
||||
address /= sizeof(spritetype);
|
||||
|
||||
spriteclean[address] = 0;
|
||||
} else {
|
||||
address -= (int)(tsprite);
|
||||
address /= sizeof(spritetype);
|
||||
|
||||
if (address > MAXSPRITESONSCREEN) return;
|
||||
|
||||
tspriteclean[address] = 0;
|
||||
}
|
||||
|
||||
if (address > MAXSPRITES) return;
|
||||
|
||||
}
|
||||
|
||||
EXTERN int16_t maskwall[MAXWALLSB], maskwallcnt;
|
||||
EXTERN int16_t thewall[MAXWALLSB];
|
||||
EXTERN spritetype *tspriteptr[MAXSPRITESONSCREEN + 1];
|
||||
|
|
|
@ -6,20 +6,81 @@ class __TRACKER_NAME
|
|||
TrackedType TrackedValue;
|
||||
|
||||
public:
|
||||
TrackedType operator = (TrackedType);
|
||||
TrackedType operator = (__TRACKER_NAME<TrackedType>);
|
||||
TrackedType operator += (TrackedType);
|
||||
TrackedType operator += (__TRACKER_NAME<TrackedType>);
|
||||
inline TrackedType* operator & ()
|
||||
{
|
||||
__TRACKER_GLOBAL_HOOK((int)&this->TrackedValue);
|
||||
return &this->TrackedValue;
|
||||
}
|
||||
|
||||
operator TrackedType();
|
||||
inline TrackedType operator ++ ()
|
||||
{
|
||||
__TRACKER_GLOBAL_HOOK((int)&this->TrackedValue);
|
||||
return ++this->TrackedValue;
|
||||
}
|
||||
|
||||
inline TrackedType operator ++ (int)
|
||||
{
|
||||
__TRACKER_GLOBAL_HOOK((int)&this->TrackedValue);
|
||||
return this->TrackedValue++;
|
||||
}
|
||||
|
||||
inline TrackedType operator -- ()
|
||||
{
|
||||
__TRACKER_GLOBAL_HOOK((int)&this->TrackedValue);
|
||||
return --this->TrackedValue;
|
||||
}
|
||||
|
||||
inline TrackedType operator -- (int)
|
||||
{
|
||||
__TRACKER_GLOBAL_HOOK((int)&this->TrackedValue);
|
||||
return this->TrackedValue--;
|
||||
}
|
||||
|
||||
inline TrackedType operator = (TrackedType);
|
||||
inline TrackedType operator = (__TRACKER_NAME<TrackedType>);
|
||||
|
||||
inline TrackedType operator += (TrackedType);
|
||||
inline TrackedType operator += (__TRACKER_NAME<TrackedType>);
|
||||
|
||||
inline TrackedType operator -= (TrackedType);
|
||||
inline TrackedType operator -= (__TRACKER_NAME<TrackedType>);
|
||||
|
||||
inline TrackedType operator *= (TrackedType);
|
||||
inline TrackedType operator *= (__TRACKER_NAME<TrackedType>);
|
||||
|
||||
inline TrackedType operator /= (TrackedType);
|
||||
inline TrackedType operator /= (__TRACKER_NAME<TrackedType>);
|
||||
|
||||
inline TrackedType operator |= (TrackedType);
|
||||
inline TrackedType operator |= (__TRACKER_NAME<TrackedType>);
|
||||
|
||||
inline TrackedType operator &= (TrackedType);
|
||||
inline TrackedType operator &= (__TRACKER_NAME<TrackedType>);
|
||||
|
||||
inline TrackedType operator ^= (TrackedType);
|
||||
inline TrackedType operator ^= (__TRACKER_NAME<TrackedType>);
|
||||
|
||||
inline TrackedType operator <<= (TrackedType);
|
||||
inline TrackedType operator <<= (__TRACKER_NAME<TrackedType>);
|
||||
|
||||
inline TrackedType operator >>= (TrackedType);
|
||||
inline TrackedType operator >>= (__TRACKER_NAME<TrackedType>);
|
||||
|
||||
inline operator TrackedType() const;
|
||||
};
|
||||
|
||||
#ifndef __tracker_hpp
|
||||
#define __tracker_hpp
|
||||
|
||||
enum {
|
||||
__TRACKER_NOOP_RIGHTHAND_EQUAL = 0,
|
||||
__TRACKER_NOOP_RIGHTHAND_ZERO,
|
||||
__TRACKER_NOOP_RIGHTHAND_ONE,
|
||||
__TRACKER_NEVER,
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
#define __TRACKER_RIGHTHAND_TYPE __TRACKER_NAME<TrackedType> rightHand
|
||||
#define __TRACKER_RIGHTHAND rightHand.TrackedValue
|
||||
#include "tracker_operators.hpp"
|
||||
|
@ -33,7 +94,7 @@ enum {
|
|||
#undef __TRACKER_RIGHTHAND
|
||||
|
||||
template<typename TrackedType>
|
||||
__TRACKER_NAME<TrackedType>::operator TrackedType()
|
||||
__TRACKER_NAME<TrackedType>::operator TrackedType() const
|
||||
{
|
||||
return this->TrackedValue;
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
|
||||
template<typename TrackedType>
|
||||
TrackedType __TRACKER_NAME<TrackedType>::operator __TRACKER_OPERATOR (__TRACKER_RIGHTHAND_TYPE)
|
||||
inline TrackedType __TRACKER_NAME<TrackedType>::operator __TRACKER_OPERATOR (__TRACKER_RIGHTHAND_TYPE)
|
||||
{
|
||||
bool isNoop;
|
||||
|
||||
|
@ -11,6 +11,9 @@ TrackedType __TRACKER_NAME<TrackedType>::operator __TRACKER_OPERATOR (__TRACKER_
|
|||
case __TRACKER_NOOP_RIGHTHAND_ZERO:
|
||||
isNoop = __TRACKER_RIGHTHAND == 0;
|
||||
break;
|
||||
case __TRACKER_NOOP_RIGHTHAND_ONE:
|
||||
isNoop = __TRACKER_RIGHTHAND == 1;
|
||||
break;
|
||||
default:
|
||||
case __TRACKER_NEVER:
|
||||
isNoop = false;
|
||||
|
@ -19,10 +22,9 @@ TrackedType __TRACKER_NAME<TrackedType>::operator __TRACKER_OPERATOR (__TRACKER_
|
|||
|
||||
if (!isNoop) {
|
||||
|
||||
// hook here
|
||||
int TrackedAddress = (int)&this->TrackedValue;
|
||||
TrackedAddress += __TRACKER_GLOBAL_OFFSET;
|
||||
*((TrackedType*)TrackedAddress) = 1;
|
||||
__TRACKER_GLOBAL_HOOK((int)&this->TrackedValue);
|
||||
return (this->TrackedValue __TRACKER_OPERATOR __TRACKER_RIGHTHAND);
|
||||
} else {
|
||||
return this->TrackedValue;
|
||||
}
|
||||
}
|
|
@ -8,4 +8,52 @@
|
|||
#define __TRACKER_NOOP __TRACKER_NOOP_RIGHTHAND_ZERO
|
||||
#include "tracker_operator.hpp"
|
||||
#undef __TRACKER_OPERATOR
|
||||
#undef __TRACKER_NOOP
|
||||
#undef __TRACKER_NOOP
|
||||
|
||||
#define __TRACKER_OPERATOR -=
|
||||
#define __TRACKER_NOOP __TRACKER_NOOP_RIGHTHAND_ZERO
|
||||
#include "tracker_operator.hpp"
|
||||
#undef __TRACKER_OPERATOR
|
||||
#undef __TRACKER_NOOP
|
||||
|
||||
#define __TRACKER_OPERATOR *=
|
||||
#define __TRACKER_NOOP __TRACKER_NOOP_RIGHTHAND_ONE
|
||||
#include "tracker_operator.hpp"
|
||||
#undef __TRACKER_OPERATOR
|
||||
#undef __TRACKER_NOOP
|
||||
|
||||
#define __TRACKER_OPERATOR /=
|
||||
#define __TRACKER_NOOP __TRACKER_NOOP_RIGHTHAND_ONE
|
||||
#include "tracker_operator.hpp"
|
||||
#undef __TRACKER_OPERATOR
|
||||
#undef __TRACKER_NOOP
|
||||
|
||||
#define __TRACKER_OPERATOR |=
|
||||
#define __TRACKER_NOOP __TRACKER_NOOP_RIGHTHAND_ZERO
|
||||
#include "tracker_operator.hpp"
|
||||
#undef __TRACKER_OPERATOR
|
||||
#undef __TRACKER_NOOP
|
||||
|
||||
#define __TRACKER_OPERATOR &=
|
||||
#define __TRACKER_NOOP __TRACKER_NOOP_RIGHTHAND_EQUAL
|
||||
#include "tracker_operator.hpp"
|
||||
#undef __TRACKER_OPERATOR
|
||||
#undef __TRACKER_NOOP
|
||||
|
||||
#define __TRACKER_OPERATOR ^=
|
||||
#define __TRACKER_NOOP __TRACKER_NOOP_RIGHTHAND_ZERO
|
||||
#include "tracker_operator.hpp"
|
||||
#undef __TRACKER_OPERATOR
|
||||
#undef __TRACKER_NOOP
|
||||
|
||||
#define __TRACKER_OPERATOR <<=
|
||||
#define __TRACKER_NOOP __TRACKER_NOOP_RIGHTHAND_ZERO
|
||||
#include "tracker_operator.hpp"
|
||||
#undef __TRACKER_OPERATOR
|
||||
#undef __TRACKER_NOOP
|
||||
|
||||
#define __TRACKER_OPERATOR >>=
|
||||
#define __TRACKER_NOOP __TRACKER_NOOP_RIGHTHAND_ZERO
|
||||
#include "tracker_operator.hpp"
|
||||
#undef __TRACKER_OPERATOR
|
||||
#undef __TRACKER_NOOP
|
||||
|
|
|
@ -2206,11 +2206,14 @@ void fade_editor_screen(int32_t keepcol)
|
|||
|
||||
static void copy_some_wall_members(int16_t dst, int16_t src, int32_t reset_some)
|
||||
{
|
||||
// x y p2 nw ns cs p op sh pl xr yr xp yp lo hi ex
|
||||
static const walltype nullwall = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 8, 0, 0, 0, 0, -1 };
|
||||
static walltype nullwall;
|
||||
walltype *dstwal=&wall[dst];
|
||||
const walltype *srcwal = src >= 0 ? &wall[src] : &nullwall;
|
||||
|
||||
memset(&nullwall, 0, sizeof(nullwall));
|
||||
nullwall.yrepeat = 8;
|
||||
nullwall.extra = -1;
|
||||
|
||||
if (reset_some)
|
||||
{
|
||||
dstwal->cstat = srcwal->cstat;
|
||||
|
|
|
@ -3951,9 +3951,22 @@ int32_t A_InsertSprite(int32_t whatsect,int32_t s_x,int32_t s_y,int32_t s_z,int3
|
|||
{
|
||||
int32_t p, i = insertsprite(whatsect,s_ss);
|
||||
spritetype *s = &sprite[i];
|
||||
spritetype spr_temp = { s_x, s_y, s_z, 0, s_pn, s_s, 0, 0, 0, s_xr, s_yr, 0, 0,
|
||||
whatsect, s_ss, s_a, s_ow, s_ve, 0, s_zv, 0, 0, 0
|
||||
};
|
||||
spritetype spr_temp;
|
||||
|
||||
memset(&spr_temp, 0, sizeof(spritetype));
|
||||
spr_temp.x = s_x;
|
||||
spr_temp.y = s_y;
|
||||
spr_temp.z = s_z;
|
||||
spr_temp.picnum = s_pn;
|
||||
spr_temp.shade = s_s;
|
||||
spr_temp.xrepeat = s_xr;
|
||||
spr_temp.yrepeat = s_yr;
|
||||
spr_temp.sectnum = whatsect;
|
||||
spr_temp.statnum = s_ss;
|
||||
spr_temp.ang = s_a;
|
||||
spr_temp.owner = s_ow;
|
||||
spr_temp.xvel = s_ve;
|
||||
spr_temp.zvel = s_zv;
|
||||
|
||||
if (i < 0)
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue