mirror of
https://github.com/ZDoom/Raze.git
synced 2024-11-15 08:51:24 +00:00
- sanitized walock.
Sorry, but having a globally writable pointer to every texture is just insane and makes any functional management impossible. This is merely a preparation for adding a real texture manager. That cannot be done if any code can write over the data at will. For that, it now has to make the texture writable first or create a writable empty texture.
This commit is contained in:
parent
3621aae3f0
commit
fbc22e0125
31 changed files with 185 additions and 193 deletions
|
@ -455,8 +455,7 @@ void PreloadCache(void)
|
|||
{
|
||||
if (TestBitString(gotpic, i))
|
||||
{
|
||||
if (waloff[i] == 0)
|
||||
tileLoad((int16_t)i);
|
||||
tileCache(i);
|
||||
|
||||
#ifdef USE_OPENGL
|
||||
PrecacheExtraTextureMaps(i);
|
||||
|
|
|
@ -216,8 +216,7 @@ void credPlaySmk(const char *_pzSMK, const char *_pzWAV, int nWav)
|
|||
Smacker_GetFrameSize(hSMK, nWidth, nHeight);
|
||||
uint8_t palette[768];
|
||||
tileDelete(kSMKTile);
|
||||
tileCreate(kSMKTile, nWidth, nHeight);
|
||||
auto pFrame = (uint8_t*)waloff[kSMKTile];
|
||||
auto pFrame = tileCreate(kSMKTile, nWidth, nHeight);
|
||||
if (!pFrame)
|
||||
{
|
||||
Smacker_Close(hSMK);
|
||||
|
|
|
@ -68,13 +68,15 @@ void DoFireFrame(void)
|
|||
memcpy(FrameBuffer+16896+i*128, SeedBuffer[nRand], 128);
|
||||
}
|
||||
CellularFrame(FrameBuffer, 128, 132);
|
||||
char *pData = tileLoadTile(2342);
|
||||
tileLoadTile(2342);
|
||||
tileMakeWritable(2342);
|
||||
auto pData = tileData(2342);
|
||||
char *pSource = FrameBuffer;
|
||||
int x = fireSize;
|
||||
do
|
||||
{
|
||||
int y = fireSize;
|
||||
char *pDataBak = pData;
|
||||
auto pDataBak = pData;
|
||||
do
|
||||
{
|
||||
*pData = gCLU[*pSource];
|
||||
|
|
|
@ -510,7 +510,7 @@ int VectorScan(spritetype *pSprite, int nOffset, int nZOffset, int dx, int dy, i
|
|||
width2 += nOffset + tilesiz[nPicnum].x / 2;
|
||||
if (width2 >= 0 && width2 < tilesiz[nPicnum].x)
|
||||
{
|
||||
char *pData = tileLoadTile(nPicnum);
|
||||
auto pData = tileLoadTile(nPicnum);
|
||||
if (pData[width2*tilesiz[nPicnum].y+height2] != (char)255)
|
||||
return 3;
|
||||
}
|
||||
|
@ -591,7 +591,7 @@ int VectorScan(spritetype *pSprite, int nOffset, int nZOffset, int dx, int dy, i
|
|||
nOffset &= nSizY - 1;
|
||||
else
|
||||
nOffset %= nSizY;
|
||||
char *pData = tileLoadTile(nPicnum);
|
||||
auto pData = tileLoadTile(nPicnum);
|
||||
int nPixel;
|
||||
if (potY)
|
||||
nPixel = (nHOffset<<(picsiz[nPicnum]>>4)) + nOffset;
|
||||
|
|
|
@ -142,20 +142,20 @@ void tileProcessGLVoxels(void)
|
|||
}
|
||||
#endif
|
||||
|
||||
char * tileLoadTile(int nTile)
|
||||
const uint8_t * tileLoadTile(int nTile)
|
||||
{
|
||||
if (!waloff[nTile]) tileLoad(nTile);
|
||||
return (char*)waloff[nTile];
|
||||
tileCache(nTile);
|
||||
return (const uint8_t*)tilePtr(nTile);
|
||||
}
|
||||
|
||||
char * tileAllocTile(int nTile, int x, int y, int ox, int oy)
|
||||
uint8_t * tileAllocTile(int nTile, int x, int y, int ox, int oy)
|
||||
{
|
||||
dassert(nTile >= 0 && nTile < kMaxTiles);
|
||||
char *p = (char*)tileCreate(nTile, x, y);
|
||||
uint8_t *p = tileCreate(nTile, x, y);
|
||||
dassert(p != NULL);
|
||||
picanm[nTile].xofs = ClipRange(ox, -127, 127);
|
||||
picanm[nTile].yofs = ClipRange(oy, -127, 127);
|
||||
return (char*)waloff[nTile];
|
||||
return p;
|
||||
}
|
||||
|
||||
void tilePreloadTile(int nTile)
|
||||
|
|
|
@ -60,8 +60,8 @@ int tileInit(char a1, const char *a2);
|
|||
#ifdef USE_OPENGL
|
||||
void tileProcessGLVoxels(void);
|
||||
#endif
|
||||
char * tileLoadTile(int nTile);
|
||||
char * tileAllocTile(int nTile, int x, int y, int ox, int oy);
|
||||
const uint8_t * tileLoadTile(int nTile);
|
||||
uint8_t * tileAllocTile(int nTile, int x, int y, int ox, int oy);
|
||||
void tilePreloadTile(int nTile);
|
||||
void tilePrecacheTile(int nTile, int nType = 1);
|
||||
char tileGetSurfType(int hit);
|
||||
|
|
|
@ -1726,7 +1726,7 @@ void viewInit(void)
|
|||
lensTable[i] = B_LITTLE32(lensTable[i]);
|
||||
}
|
||||
#endif
|
||||
char *data = tileAllocTile(4077, kLensSize, kLensSize, 0, 0);
|
||||
uint8_t *data = tileAllocTile(4077, kLensSize, kLensSize, 0, 0);
|
||||
memset(data, 255, kLensSize*kLensSize);
|
||||
gGameMessageMgr.SetState(gMessageState);
|
||||
gGameMessageMgr.SetCoordinates(1, 1);
|
||||
|
@ -2841,9 +2841,10 @@ void viewSetErrorMessage(const char *pMessage)
|
|||
|
||||
void DoLensEffect(void)
|
||||
{
|
||||
char *d = (char*)waloff[4077];
|
||||
// To investigate whether this can be implemented as a shader effect.
|
||||
auto d = tileData(4077);
|
||||
dassert(d != NULL);
|
||||
char *s = (char*)waloff[4079];
|
||||
auto s = tilePtr(4079);
|
||||
dassert(s != NULL);
|
||||
for (int i = 0; i < kLensSize*kLensSize; i++, d++)
|
||||
if (lensTable[i] >= 0)
|
||||
|
@ -3225,8 +3226,7 @@ void viewDrawScreen(void)
|
|||
if (videoGetRenderMode() == REND_CLASSIC)
|
||||
{
|
||||
int vr = viewingrange;
|
||||
walock[TILTBUFFER] = 255;
|
||||
if (!waloff[TILTBUFFER])
|
||||
if (!tileData(TILTBUFFER))
|
||||
{
|
||||
tileAllocTile(TILTBUFFER, 640, 640, 0, 0);
|
||||
}
|
||||
|
@ -3268,7 +3268,7 @@ void viewDrawScreen(void)
|
|||
}
|
||||
PLAYER *pOther = &gPlayer[i];
|
||||
//othercameraclock = gGameClock;
|
||||
if (!waloff[4079])
|
||||
if (!tileData(4079))
|
||||
{
|
||||
tileAllocTile(4079, 128, 128, 0, 0);
|
||||
}
|
||||
|
@ -3439,7 +3439,7 @@ RORHACK:
|
|||
{
|
||||
if (videoGetRenderMode() == REND_CLASSIC)
|
||||
{
|
||||
dassert(waloff[ TILTBUFFER ] != 0);
|
||||
dassert(tileData(TILTBUFFER) != 0);
|
||||
renderRestoreTarget();
|
||||
int vrc = 64+4+2+1024;
|
||||
if (bDelirium)
|
||||
|
@ -3761,12 +3761,13 @@ void viewSetCrosshairColor(int32_t r, int32_t g, int32_t b)
|
|||
CrosshairColors.g = g;
|
||||
CrosshairColors.b = b;
|
||||
|
||||
tileMakeWritable(kCrosshairTile);
|
||||
tileLoad(kCrosshairTile);
|
||||
|
||||
if (!waloff[kCrosshairTile])
|
||||
if (!tilePtr(kCrosshairTile))
|
||||
return;
|
||||
|
||||
char *ptr = (char *)waloff[kCrosshairTile];
|
||||
auto ptr = tileData(kCrosshairTile);
|
||||
|
||||
int32_t ii = tilesiz[kCrosshairTile].x * tilesiz[kCrosshairTile].y;
|
||||
|
||||
|
|
|
@ -847,7 +847,6 @@ typedef struct {
|
|||
EXTERN picanm_t picanm[MAXTILES];
|
||||
typedef struct { int16_t newtile; int16_t owner; } rottile_t;
|
||||
EXTERN rottile_t rottile[MAXTILES];
|
||||
EXTERN intptr_t waloff[MAXTILES]; // stores pointers to cache -- SA
|
||||
|
||||
EXTERN int32_t windowpos, windowx, windowy;
|
||||
|
||||
|
@ -1086,15 +1085,19 @@ void artPreloadFile(buildvfs_kfd fil, artheader_t const *local);
|
|||
int32_t artLoadFiles(const char *filename, int32_t askedsize);
|
||||
void artClearMapArt(void);
|
||||
void artSetupMapArt(const char *filename);
|
||||
bool tileCache(int tilenume);
|
||||
const uint8_t* tilePtr(int num); // read-only
|
||||
uint8_t* tileData(int num); // writable.
|
||||
bool tileLoad(int16_t tilenume);
|
||||
void tileLoadData(int16_t tilenume, int32_t dasiz, char *buffer);
|
||||
int32_t tileCRC(int16_t tileNum);
|
||||
void tileUpdatePicSiz(int32_t picnum);
|
||||
void tileMakeWritable(int num);
|
||||
|
||||
int32_t qloadkvx(int32_t voxindex, const char *filename);
|
||||
void vox_undefine(int32_t const);
|
||||
intptr_t tileCreate(int16_t tilenume, int32_t xsiz, int32_t ysiz);
|
||||
intptr_t tileSetExternal(int16_t tilenume, int32_t xsiz, int32_t ysiz, const uint8_t* data);
|
||||
uint8_t *tileCreate(int16_t tilenume, int32_t xsiz, int32_t ysiz);
|
||||
void tileSetExternal(int16_t tilenume, int32_t xsiz, int32_t ysiz, uint8_t* data);
|
||||
void tileCopySection(int32_t tilenume1, int32_t sx1, int32_t sy1, int32_t xsiz, int32_t ysiz, int32_t tilenume2, int32_t sx2, int32_t sy2);
|
||||
void squarerotatetile(int16_t tilenume);
|
||||
|
||||
|
|
|
@ -2530,17 +2530,14 @@ restart_grand:
|
|||
{
|
||||
tileUpdatePicnum(&tilenum, 0);
|
||||
|
||||
if (!waloff[tilenum])
|
||||
tileLoad(tilenum);
|
||||
|
||||
if (waloff[tilenum])
|
||||
if (tileCache(tilenum))
|
||||
{
|
||||
// daz-intz > 0 && daz-intz < k
|
||||
int32_t xtex = mulscale16(ucoefup16, tilesiz[tilenum].x);
|
||||
int32_t vcoefup16 = 65536-divscale16(daz-intz, k);
|
||||
int32_t ytex = mulscale16(vcoefup16, tilesiz[tilenum].y);
|
||||
|
||||
const char *texel = (char *)(waloff[tilenum] + tilesiz[tilenum].y*xtex + ytex);
|
||||
auto texel = (tilePtr(tilenum) + tilesiz[tilenum].y*xtex + ytex);
|
||||
if (*texel == 255)
|
||||
continue;
|
||||
}
|
||||
|
|
|
@ -1854,7 +1854,7 @@ static WSHELPER_DECL void calc_bufplc(intptr_t *bufplc, int32_t lw, vec2_16_t ts
|
|||
// Bassert(i >= 0 && i < tilesiz[globalpicnum].x*tilesiz[globalpicnum].y);
|
||||
|
||||
// Address is at the first row of tile storage (which is column-major).
|
||||
*bufplc = waloff[globalpicnum] + i;
|
||||
*bufplc = (intptr_t)tilePtr(globalpicnum) + i;
|
||||
}
|
||||
|
||||
static WSHELPER_DECL void calc_vplcinc_wall(uint32_t *vplc, int32_t *vinc, inthi_t sw, int32_t y1v)
|
||||
|
@ -1911,7 +1911,7 @@ static void maskwallscan(int32_t x1, int32_t x2, int32_t saturatevplc)
|
|||
|
||||
setgotpic(globalpicnum);
|
||||
|
||||
if (waloff[globalpicnum] == 0) tileLoad(globalpicnum);
|
||||
tileCache(globalpicnum);
|
||||
|
||||
tweak_tsizes(&tsiz);
|
||||
|
||||
|
@ -2633,9 +2633,10 @@ static int32_t setup_globals_cf1(usectorptr_t sec, int32_t pal, int32_t zd,
|
|||
tileUpdatePicnum(&globalpicnum, 0);
|
||||
setgotpic(globalpicnum);
|
||||
if ((tilesiz[globalpicnum].x <= 0) || (tilesiz[globalpicnum].y <= 0)) return 1;
|
||||
if (waloff[globalpicnum] == 0) tileLoad(globalpicnum);
|
||||
tileCache(globalpicnum);
|
||||
|
||||
globalbufplc = waloff[globalpicnum];
|
||||
|
||||
globalbufplc = (intptr_t)tilePtr(globalpicnum);
|
||||
|
||||
globalshade = shade;
|
||||
globvis = globalcisibility;
|
||||
|
@ -2928,7 +2929,8 @@ static void wallscan(int32_t x1, int32_t x2,
|
|||
if ((uwal[x1] > ydimen) && (uwal[x2] > ydimen)) return;
|
||||
if ((dwal[x1] < 0) && (dwal[x2] < 0)) return;
|
||||
|
||||
if (waloff[globalpicnum] == 0) tileLoad(globalpicnum);
|
||||
tileCache(globalpicnum);
|
||||
|
||||
|
||||
tweak_tsizes(&tsiz);
|
||||
|
||||
|
@ -3149,7 +3151,8 @@ static void transmaskwallscan(int32_t x1, int32_t x2, int32_t saturatevplc)
|
|||
if ((tilesiz[globalpicnum].x <= 0) || (tilesiz[globalpicnum].y <= 0))
|
||||
return;
|
||||
|
||||
if (waloff[globalpicnum] == 0) tileLoad(globalpicnum);
|
||||
tileCache(globalpicnum);
|
||||
|
||||
|
||||
setuptvlineasm(globalshiftval, saturatevplc);
|
||||
|
||||
|
@ -3448,7 +3451,8 @@ static void fgrouscan(int32_t dax1, int32_t dax2, int32_t sectnum, char dastat)
|
|||
tileUpdatePicnum(&globalpicnum, sectnum);
|
||||
setgotpic(globalpicnum);
|
||||
if ((tilesiz[globalpicnum].x <= 0) || (tilesiz[globalpicnum].y <= 0)) return;
|
||||
if (waloff[globalpicnum] == 0) tileLoad(globalpicnum);
|
||||
tileCache(globalpicnum);
|
||||
|
||||
|
||||
wal = (uwalltype *)&wall[sec->wallptr];
|
||||
wxi = wall[wal->point2].x - wal->x;
|
||||
|
@ -3536,7 +3540,7 @@ static void fgrouscan(int32_t dax1, int32_t dax2, int32_t sectnum, char dastat)
|
|||
intptr_t fj = FP_OFF(palookup[globalpal]);
|
||||
|
||||
setupslopevlin_alsotrans((picsiz[globalpicnum]&15) + ((picsiz[globalpicnum]>>4)<<8),
|
||||
waloff[globalpicnum],-ylookup[1]);
|
||||
(intptr_t)tilePtr(globalpicnum),-ylookup[1]);
|
||||
|
||||
l = Blrintf((globalzd)*(1.f/65536.f));
|
||||
|
||||
|
@ -3739,7 +3743,8 @@ static void grouscan(int32_t dax1, int32_t dax2, int32_t sectnum, char dastat)
|
|||
tileUpdatePicnum(&globalpicnum, sectnum);
|
||||
setgotpic(globalpicnum);
|
||||
if ((tilesiz[globalpicnum].x <= 0) || (tilesiz[globalpicnum].y <= 0)) return;
|
||||
if (waloff[globalpicnum] == 0) tileLoad(globalpicnum);
|
||||
tileCache(globalpicnum);
|
||||
|
||||
|
||||
wal = (uwallptr_t)&wall[sec->wallptr];
|
||||
wx = wall[wal->point2].x - wal->x;
|
||||
|
@ -3822,7 +3827,7 @@ static void grouscan(int32_t dax1, int32_t dax2, int32_t sectnum, char dastat)
|
|||
j = FP_OFF(palookup[globalpal]);
|
||||
|
||||
setupslopevlin_alsotrans((picsiz[globalpicnum]&15) + ((picsiz[globalpicnum]>>4)<<8),
|
||||
waloff[globalpicnum],-ylookup[1]);
|
||||
(intptr_t)tilePtr(globalpicnum),-ylookup[1]);
|
||||
|
||||
l = (globalzd>>16);
|
||||
|
||||
|
@ -5957,9 +5962,10 @@ draw_as_face_sprite:
|
|||
globalpicnum = tilenum;
|
||||
if ((unsigned)globalpicnum >= (unsigned)MAXTILES) globalpicnum = 0;
|
||||
|
||||
if (waloff[globalpicnum] == 0) tileLoad(globalpicnum);
|
||||
tileCache(globalpicnum);
|
||||
|
||||
setgotpic(globalpicnum);
|
||||
globalbufplc = waloff[globalpicnum];
|
||||
globalbufplc = (intptr_t)tilePtr(globalpicnum);
|
||||
|
||||
globvis = mulscale16(globalhisibility,viewingrange);
|
||||
if (sec->visibility != 0) globvis = mulscale4(globvis, (uint8_t)(sec->visibility+16));
|
||||
|
@ -6991,9 +6997,9 @@ static void dorotatesprite(int32_t sx, int32_t sy, int32_t z, int16_t a, int16_t
|
|||
nextv = v;
|
||||
}
|
||||
|
||||
if (waloff[picnum] == 0) tileLoad(picnum);
|
||||
tileCache(picnum);
|
||||
setgotpic(picnum);
|
||||
bufplc = waloff[picnum];
|
||||
bufplc = (intptr_t)tilePtr(picnum);
|
||||
|
||||
if (palookup[dapalnum] == NULL) dapalnum = 0;
|
||||
palookupoffs = FP_OFF(palookup[dapalnum]) + (getpalookup(0, dashade)<<8);
|
||||
|
@ -8470,7 +8476,6 @@ int32_t renderDrawRoomsQ16(int32_t daposx, int32_t daposy, int32_t daposz,
|
|||
tileSetSize(tile.newtile, siz.x, siz.y);
|
||||
|
||||
tileLoad(tile.newtile);
|
||||
// Bassert(waloff[tile.newtile]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -9286,8 +9291,9 @@ void renderDrawMapView(int32_t dax, int32_t day, int32_t zoome, int16_t ang)
|
|||
tileUpdatePicnum(&globalpicnum, s);
|
||||
setgotpic(globalpicnum);
|
||||
if ((tilesiz[globalpicnum].x <= 0) || (tilesiz[globalpicnum].y <= 0)) continue;
|
||||
if (waloff[globalpicnum] == 0) tileLoad(globalpicnum);
|
||||
globalbufplc = waloff[globalpicnum];
|
||||
tileCache(globalpicnum);
|
||||
|
||||
globalbufplc = (intptr_t)tilePtr(globalpicnum);
|
||||
globalshade = max(min<int>(sec->floorshade,numshades-1),0);
|
||||
globvis = globalhisibility;
|
||||
if (sec->visibility != 0) globvis = mulscale4(globvis, (uint8_t)(sec->visibility+16));
|
||||
|
@ -9411,8 +9417,9 @@ void renderDrawMapView(int32_t dax, int32_t day, int32_t zoome, int16_t ang)
|
|||
tileUpdatePicnum(&globalpicnum, s);
|
||||
setgotpic(globalpicnum);
|
||||
if ((tilesiz[globalpicnum].x <= 0) || (tilesiz[globalpicnum].y <= 0)) continue;
|
||||
if (waloff[globalpicnum] == 0) tileLoad(globalpicnum);
|
||||
globalbufplc = waloff[globalpicnum];
|
||||
tileCache(globalpicnum);
|
||||
|
||||
globalbufplc = (intptr_t)tilePtr(globalpicnum);
|
||||
|
||||
// 'loading' the tile doesn't actually guarantee that it's there afterwards.
|
||||
// This can really happen when drawing the second frame of a floor-aligned
|
||||
|
@ -10507,19 +10514,6 @@ void videoNextPage(void)
|
|||
{
|
||||
permfifotype *per;
|
||||
|
||||
//char snotbuf[32];
|
||||
//j = 0; k = 0;
|
||||
//for(i=0;i<4096;i++)
|
||||
// if (waloff[i] != 0)
|
||||
// {
|
||||
// sprintf(snotbuf,"%d-%d",i,tilesizx[i]*tilesizy[i]);
|
||||
// printext256((j>>5)*40+32,(j&31)*6,walock[i]>>3,-1,snotbuf,1);
|
||||
// k += tilesizx[i]*tilesizy[i];
|
||||
// j++;
|
||||
// }
|
||||
//sprintf(snotbuf,"Total: %d",k);
|
||||
//printext256((j>>5)*40+32,(j&31)*6,31,-1,snotbuf,1);
|
||||
|
||||
if (in3dmode())
|
||||
{
|
||||
videoBeginDrawing(); //{{{
|
||||
|
@ -12131,7 +12125,7 @@ void renderSetTarget(int16_t tilenume, int32_t xsiz, int32_t ysiz)
|
|||
tileDelete(tilenume);
|
||||
tileCreate(tilenume, xsiz, ysiz);
|
||||
bakxsiz[setviewcnt] = xdim; bakysiz[setviewcnt] = ydim;
|
||||
bakframeplace[setviewcnt] = frameplace; frameplace = waloff[tilenume];
|
||||
bakframeplace[setviewcnt] = frameplace; frameplace = (intptr_t)tilePtr(tilenume);
|
||||
bakwindowxy1[setviewcnt] = windowxy1;
|
||||
bakwindowxy2[setviewcnt] = windowxy2;
|
||||
|
||||
|
@ -12203,26 +12197,28 @@ void squarerotatetile(int16_t tilenume)
|
|||
if (siz != tilesiz[tilenume].y)
|
||||
return;
|
||||
|
||||
char *ptr1, *ptr2;
|
||||
uint8_t *ptr1, *ptr2;
|
||||
auto p = tileData(tilenume);
|
||||
if (!p) return; // safety precaution, this may only be called on writable tiles for camera textures.
|
||||
|
||||
for (bssize_t i=siz-1, j; i>=3; i-=4)
|
||||
{
|
||||
ptr2 = ptr1 = (char *) (waloff[tilenume]+i*(siz+1));
|
||||
ptr2 = ptr1 = (p+i*(siz+1));
|
||||
swapchar(--ptr1, (ptr2 -= siz));
|
||||
for (j=(i>>1)-1; j>=0; --j)
|
||||
swapchar2((ptr1 -= 2), (ptr2 -= (siz<<1)), siz);
|
||||
|
||||
ptr2 = ptr1 = (char *) (waloff[tilenume]+(i-1)*(siz+1));
|
||||
ptr2 = ptr1 = (p+(i-1)*(siz+1));
|
||||
for (j=((i-1)>>1)-1; j>=0; --j)
|
||||
swapchar2((ptr1 -= 2), (ptr2 -= (siz<<1)), siz);
|
||||
|
||||
ptr2 = ptr1 = (char *) (waloff[tilenume]+(i-2)*(siz+1));
|
||||
ptr2 = ptr1 = (p+(i-2)*(siz+1));
|
||||
swapchar(--ptr1, (ptr2 -= siz));
|
||||
|
||||
for (j=((i-2)>>1)-1; j>=0; --j)
|
||||
swapchar2((ptr1 -= 2), (ptr2 -= (siz<<1)), siz);
|
||||
|
||||
ptr2 = ptr1 = (char *) (waloff[tilenume]+(i-3)*(siz+1));
|
||||
ptr2 = ptr1 = (p+(i-3)*(siz+1));
|
||||
|
||||
for (j=((i-3)>>1)-1; j>=0; --j)
|
||||
swapchar2((ptr1 -= 2), (ptr2 -= (siz<<1)), siz);
|
||||
|
|
|
@ -646,11 +646,6 @@ static void polymost_drawpoly(vec2f_t const * const dpxy, int32_t const n, int32
|
|||
setgotpic(globalpicnum);
|
||||
vec2_t tsiz = { tilesize.x, tilesize.y };
|
||||
|
||||
if (!waloff[globalpicnum])
|
||||
{
|
||||
tileLoad(globalpicnum);
|
||||
}
|
||||
|
||||
Bassert(n <= MAX_DRAWPOLY_VERTS);
|
||||
|
||||
int j = 0;
|
||||
|
@ -713,7 +708,7 @@ static void polymost_drawpoly(vec2f_t const * const dpxy, int32_t const n, int32
|
|||
return;
|
||||
}
|
||||
|
||||
if (!waloff[globalpicnum])
|
||||
if (!tilePtr(globalpicnum))
|
||||
{
|
||||
tsiz.x = tsiz.y = 1;
|
||||
GLInterface.SetColorMask(false); //Hack to update Z-buffer for invalid mirror textures
|
||||
|
@ -900,14 +895,6 @@ static void polymost_drawpoly(vec2f_t const * const dpxy, int32_t const n, int32
|
|||
GLInterface.SetMatrix(Matrix_Detail, &identity);
|
||||
}
|
||||
|
||||
if (videoGetRenderMode() != REND_POLYMOST)
|
||||
{
|
||||
if (!waloff[globalpicnum])
|
||||
GLInterface.SetColorMask(true);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (skyzbufferhack && skyzbufferhack_pass == 0)
|
||||
{
|
||||
vec3d_t const bxtex = xtex, bytex = ytex, botex = otex;
|
||||
|
@ -920,7 +907,7 @@ static void polymost_drawpoly(vec2f_t const * const dpxy, int32_t const n, int32
|
|||
skyzbufferhack_pass--;
|
||||
}
|
||||
|
||||
if (!waloff[globalpicnum])
|
||||
if (!tilePtr(globalpicnum))
|
||||
GLInterface.SetColorMask(true);
|
||||
}
|
||||
|
||||
|
|
|
@ -115,10 +115,10 @@ void gloadtile_art(int32_t dapic, int32_t dameth, pthtyp* pth, int32_t doalloc)
|
|||
//POGOTODO: npoty
|
||||
char npoty = 0;
|
||||
|
||||
//POGOTODO: if !glinfo.texnpot, then we could allocate a texture of the pow2 size, and then populate the subportion using buffersubdata func
|
||||
tileCache(globalpicnum);
|
||||
|
||||
uint8_t* p = (uint8_t*)waloff[dapic];
|
||||
if (!waloff[dapic])
|
||||
const uint8_t* p = tilePtr(dapic);
|
||||
if (!p)
|
||||
{
|
||||
static uint8_t pix = 255;
|
||||
siz.x = siz.y = 1;
|
||||
|
|
|
@ -31,6 +31,8 @@ static uint8_t picsizearray[MAXTILES];
|
|||
// These may only be manipulated through a function interface so that the backing texture objects can be adjusted or replaced.
|
||||
const vec2_16_t* const tilesiz = tilesizearray;
|
||||
const uint8_t* const picsiz = picsizearray;
|
||||
static const uint8_t *tileptr[MAXTILES]; // points to tile data -. may be constant
|
||||
static uint8_t* tiledata[MAXTILES]; // points to modifiable tile data - only set by tileCreate!
|
||||
|
||||
|
||||
// Backup tilefilenum[] and tilefileoffs[]. These get allocated only when
|
||||
|
@ -40,7 +42,7 @@ static int32_t *g_bakTileFileOffs;
|
|||
static vec2_16_t *g_bakTileSiz;
|
||||
static char *g_bakPicSiz;
|
||||
static char *g_bakWalock;
|
||||
static intptr_t *g_bakWaloff;
|
||||
static const uint8_t *g_bakWaloff;
|
||||
static picanm_t *g_bakPicAnm;
|
||||
static char * g_bakFakeTile;
|
||||
static char ** g_bakFakeTileData;
|
||||
|
@ -111,7 +113,7 @@ void artClearMapArt(void)
|
|||
{
|
||||
// XXX: OK way to free it? Better: cache1d API. CACHE1D_FREE
|
||||
walock[i] = 1;
|
||||
waloff[i] = 0;
|
||||
tileptr[i] = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -121,7 +123,7 @@ void artClearMapArt(void)
|
|||
RESTORE_MAPART_ARRAY(tilesizearray, g_bakTileSiz);
|
||||
RESTORE_MAPART_ARRAY(picsizearray, g_bakPicSiz);
|
||||
RESTORE_MAPART_ARRAY(walock, g_bakWalock);
|
||||
RESTORE_MAPART_ARRAY(waloff, g_bakWaloff);
|
||||
//RESTORE_MAPART_ARRAY(tileptr, g_bakWaloff);
|
||||
RESTORE_MAPART_ARRAY(picanm, g_bakPicAnm);
|
||||
RESTORE_MAPART_ARRAY(faketile, g_bakFakeTile);
|
||||
|
||||
|
@ -170,7 +172,7 @@ void artSetupMapArt(const char *filename)
|
|||
ALLOC_MAPART_ARRAY(tilesizearray, g_bakTileSiz);
|
||||
ALLOC_MAPART_ARRAY(picsizearray, g_bakPicSiz);
|
||||
ALLOC_MAPART_ARRAY(walock, g_bakWalock);
|
||||
ALLOC_MAPART_ARRAY(waloff, g_bakWaloff);
|
||||
//ALLOC_MAPART_ARRAY(tileptr, g_bakWaloff);
|
||||
ALLOC_MAPART_ARRAY(picanm, g_bakPicAnm);
|
||||
ALLOC_MAPART_ARRAY(faketile, g_bakFakeTile);
|
||||
ALLOC_MAPART_ARRAY(faketiledata, g_bakFakeTileData);
|
||||
|
@ -255,7 +257,8 @@ static void tileSoftDelete(int32_t const tile)
|
|||
|
||||
// CACHE1D_FREE
|
||||
walock[tile] = 1;
|
||||
waloff[tile] = 0;
|
||||
tileptr[tile] = nullptr;
|
||||
tiledata[tile] = nullptr;
|
||||
|
||||
faketile[tile>>3] &= ~pow2char[tile&7];
|
||||
picanm[tile] = {};
|
||||
|
@ -537,8 +540,9 @@ static int32_t artReadIndexedFile(int32_t tilefilei)
|
|||
}
|
||||
|
||||
// Free existing tiles from the cache1d. CACHE1D_FREE
|
||||
Bmemset(&waloff[local.tilestart], 0, local.numtiles*sizeof(intptr_t));
|
||||
Bmemset(&walock[local.tilestart], 1, local.numtiles*sizeof(walock[0]));
|
||||
Bmemset(&tileptr[local.tilestart], 0, local.numtiles*sizeof(uint8_t*));
|
||||
Bmemset(&tiledata[local.tilestart], 0, local.numtiles * sizeof(uint8_t*));
|
||||
Bmemset(&walock[local.tilestart], 1, local.numtiles*sizeof(walock[0]));
|
||||
}
|
||||
|
||||
artReadManifest(fil, &local);
|
||||
|
@ -607,6 +611,23 @@ int32_t artLoadFiles(const char *filename, int32_t askedsize)
|
|||
return 0;
|
||||
}
|
||||
|
||||
const uint8_t* tilePtr(int num)
|
||||
{
|
||||
return tileptr[num];
|
||||
}
|
||||
uint8_t* tileData(int num)
|
||||
{
|
||||
// Q: Should this automatically make the tile writable?
|
||||
return tiledata[num];
|
||||
}
|
||||
|
||||
void tileMakeWritable(int num)
|
||||
{
|
||||
// This won't be so simple anymore with a real texture manager backing this.
|
||||
tileCache(num);
|
||||
walock[num] = 255; // disable caching.
|
||||
tiledata[num] = (uint8_t*)tileptr[num];
|
||||
}
|
||||
|
||||
//
|
||||
// loadtile
|
||||
|
@ -619,16 +640,25 @@ bool tileLoad(int16_t tileNum)
|
|||
if (dasiz <= 0) return 0;
|
||||
|
||||
// Allocate storage if necessary.
|
||||
if (waloff[tileNum] == 0)
|
||||
if (tileptr[tileNum] == nullptr)
|
||||
{
|
||||
walock[tileNum] = 199;
|
||||
cacheAllocateBlock(&waloff[tileNum], dasiz, &walock[tileNum]);
|
||||
intptr_t handle;
|
||||
cacheAllocateBlock(&handle, dasiz, &walock[tileNum]);
|
||||
tileptr[tileNum] = (const uint8_t*)handle;
|
||||
}
|
||||
|
||||
tileLoadData(tileNum, dasiz, (char *) waloff[tileNum]);
|
||||
tileLoadData(tileNum, dasiz, (char *)tileptr[tileNum]);
|
||||
|
||||
|
||||
return (waloff[tileNum] != 0 && tilesiz[tileNum].x > 0 && tilesiz[tileNum].y > 0);
|
||||
return (tileptr[tileNum] != nullptr && tilesiz[tileNum].x > 0 && tilesiz[tileNum].y > 0);
|
||||
}
|
||||
|
||||
bool tileCache(int tilenume)
|
||||
{
|
||||
if ((unsigned)tilenume >= (unsigned)MAXTILES) return false;
|
||||
if (!tileptr[tilenume]) return tileLoad(tilenume);
|
||||
return true;
|
||||
}
|
||||
|
||||
void tileMaybeRotate(int16_t tilenume)
|
||||
|
@ -636,8 +666,8 @@ void tileMaybeRotate(int16_t tilenume)
|
|||
auto &rot = rottile[tilenume];
|
||||
auto &siz = tilesiz[rot.owner];
|
||||
|
||||
auto src = (char *)waloff[rot.owner];
|
||||
auto dst = (char *)waloff[tilenume];
|
||||
auto src = (char *)tileptr[rot.owner];
|
||||
auto dst = (char *)tileptr[tilenume];
|
||||
|
||||
// the engine has a squarerotatetile() we could call, but it mirrors at the same time
|
||||
for (int x = 0; x < siz.x; ++x)
|
||||
|
@ -658,10 +688,10 @@ void tileLoadData(int16_t tilenume, int32_t dasiz, char *buffer)
|
|||
|
||||
if (owner != -1)
|
||||
{
|
||||
if (!waloff[owner])
|
||||
if (!tileptr[owner])
|
||||
tileLoad(owner);
|
||||
|
||||
if (waloff[tilenume])
|
||||
if (tileptr[tilenume])
|
||||
tileMaybeRotate(tilenume);
|
||||
|
||||
return;
|
||||
|
@ -738,7 +768,7 @@ int32_t tileCRC(int16_t tileNum)
|
|||
//
|
||||
// allocatepermanenttile
|
||||
//
|
||||
intptr_t tileCreate(int16_t tilenume, int32_t xsiz, int32_t ysiz)
|
||||
uint8_t *tileCreate(int16_t tilenume, int32_t xsiz, int32_t ysiz)
|
||||
{
|
||||
if (xsiz <= 0 || ysiz <= 0 || (unsigned) tilenume >= MAXTILES)
|
||||
return 0;
|
||||
|
@ -746,27 +776,27 @@ intptr_t tileCreate(int16_t tilenume, int32_t xsiz, int32_t ysiz)
|
|||
int const dasiz = xsiz*ysiz;
|
||||
|
||||
walock[tilenume] = 255;
|
||||
cacheAllocateBlock(&waloff[tilenume], dasiz, &walock[tilenume]);
|
||||
intptr_t handle;
|
||||
cacheAllocateBlock(&handle, dasiz, &walock[tilenume]);
|
||||
tileptr[tilenume] = tiledata[tilenume] = (uint8_t*)handle;
|
||||
|
||||
tileSetSize(tilenume, xsiz, ysiz);
|
||||
picanm[tilenume] = {};
|
||||
|
||||
return waloff[tilenume];
|
||||
return tiledata[tilenume];
|
||||
}
|
||||
|
||||
intptr_t tileSetExternal(int16_t tilenume, int32_t xsiz, int32_t ysiz, const uint8_t *data)
|
||||
void tileSetExternal(int16_t tilenume, int32_t xsiz, int32_t ysiz, uint8_t *data)
|
||||
{
|
||||
if (xsiz <= 0 || ysiz <= 0 || (unsigned)tilenume >= MAXTILES)
|
||||
return 0;
|
||||
return;
|
||||
|
||||
int const dasiz = xsiz * ysiz;
|
||||
|
||||
walock[tilenume] = 255;
|
||||
waloff[tilenume] = (intptr_t)data;
|
||||
tileptr[tilenume] = tiledata[tilenume] = data;
|
||||
tileSetSize(tilenume, xsiz, ysiz);
|
||||
picanm[tilenume] = {};
|
||||
|
||||
return waloff[tilenume];
|
||||
}
|
||||
|
||||
|
||||
|
@ -776,15 +806,14 @@ intptr_t tileSetExternal(int16_t tilenume, int32_t xsiz, int32_t ysiz, const uin
|
|||
void tileCopySection(int32_t tilenume1, int32_t sx1, int32_t sy1, int32_t xsiz, int32_t ysiz,
|
||||
int32_t tilenume2, int32_t sx2, int32_t sy2)
|
||||
{
|
||||
char *ptr1, *ptr2, dat;
|
||||
int32_t xsiz1, ysiz1, xsiz2, ysiz2, i, j, x1, y1, x2, y2;
|
||||
|
||||
xsiz1 = tilesiz[tilenume1].x; ysiz1 = tilesiz[tilenume1].y;
|
||||
xsiz2 = tilesiz[tilenume2].x; ysiz2 = tilesiz[tilenume2].y;
|
||||
if ((xsiz1 > 0) && (ysiz1 > 0) && (xsiz2 > 0) && (ysiz2 > 0))
|
||||
{
|
||||
if (waloff[tilenume1] == 0) tileLoad(tilenume1);
|
||||
if (waloff[tilenume2] == 0) tileLoad(tilenume2);
|
||||
if (tileptr[tilenume1] == 0) tileLoad(tilenume1);
|
||||
if (tiledata[tilenume2] == 0) tileLoad(tilenume2);
|
||||
|
||||
x1 = sx1;
|
||||
for (i=0; i<xsiz; i++)
|
||||
|
@ -796,9 +825,9 @@ void tileCopySection(int32_t tilenume1, int32_t sx1, int32_t sy1, int32_t xsiz,
|
|||
y2 = sy2+j;
|
||||
if ((x2 >= 0) && (y2 >= 0) && (x2 < xsiz2) && (y2 < ysiz2))
|
||||
{
|
||||
ptr1 = (char *) (waloff[tilenume1] + x1*ysiz1 + y1);
|
||||
ptr2 = (char *) (waloff[tilenume2] + x2*ysiz2 + y2);
|
||||
dat = *ptr1;
|
||||
auto ptr1 = tilePtr(tilenume1) + x1 * ysiz1 + y1;
|
||||
auto ptr2 = tileData(tilenume2) + x2 * ysiz2 + y2;
|
||||
auto dat = *ptr1;
|
||||
if (dat != 255)
|
||||
*ptr2 = *ptr1;
|
||||
}
|
||||
|
|
|
@ -500,9 +500,7 @@ int32_t Anim_Play(const char *fn)
|
|||
|
||||
i = VM_OnEventWithReturn(EVENT_PRECUTSCENE, g_player[screenpeek].ps->i, screenpeek, i);
|
||||
|
||||
walock[TILE_ANIM] = 255;
|
||||
waloff[TILE_ANIM] = (intptr_t)ANIM_DrawFrame(i);
|
||||
tileSetSize(TILE_ANIM, 200, 320);
|
||||
tileSetExternal(TILE_ANIM, 200, 320, ANIM_DrawFrame(i));
|
||||
tileInvalidate(TILE_ANIM, 0, 1 << 4); // JBF 20031228
|
||||
|
||||
if (VM_OnEventWithReturn(EVENT_SKIPCUTSCENE, g_player[screenpeek].ps->i, screenpeek, I_GeneralTrigger()))
|
||||
|
@ -576,9 +574,7 @@ end_anim:
|
|||
I_ClearAllInput();
|
||||
ANIM_FreeAnim();
|
||||
|
||||
tileSetSize(TILE_ANIM, 0, 0);
|
||||
walock[TILE_ANIM] = 0;
|
||||
waloff[TILE_ANIM] = 0;
|
||||
tileDelete(TILE_ANIM);
|
||||
|
||||
// this is the lock for anim->animbuf
|
||||
anim->animlock = 1;
|
||||
|
|
|
@ -719,8 +719,7 @@ static void G_ReadGLFrame(void)
|
|||
const int32_t xf = divscale16(ydim*4/3, 320);
|
||||
const int32_t yf = divscale16(ydim, 200); // (ydim<<16)/200
|
||||
|
||||
tileCreate(TILE_SAVESHOT, 200, 320);
|
||||
char* const pic = (char*)waloff[TILE_SAVESHOT];
|
||||
auto pic = tileCreate(TILE_SAVESHOT, 200, 320);
|
||||
|
||||
if (!frame)
|
||||
{
|
||||
|
@ -848,9 +847,7 @@ void G_DrawRooms(int32_t playerNum, int32_t smoothRatio)
|
|||
|
||||
if (g_screenCapture)
|
||||
{
|
||||
walock[TILE_SAVESHOT] = 199;
|
||||
if (waloff[TILE_SAVESHOT] == 0)
|
||||
cacheAllocateBlock(&waloff[TILE_SAVESHOT],200*320,&walock[TILE_SAVESHOT]);
|
||||
tileCreate(TILE_SAVESHOT, 200, 320);
|
||||
|
||||
if (videoGetRenderMode() == REND_CLASSIC)
|
||||
renderSetTarget(TILE_SAVESHOT, 200, 320);
|
||||
|
@ -908,9 +905,7 @@ void G_DrawRooms(int32_t playerNum, int32_t smoothRatio)
|
|||
const int32_t viewtilexsiz = (tang&1023) ? tiltcx : tiltcy;
|
||||
const int32_t viewtileysiz = tiltcx;
|
||||
|
||||
walock[TILE_TILT] = 255;
|
||||
if (waloff[TILE_TILT] == 0)
|
||||
cacheAllocateBlock(&waloff[TILE_TILT], maxTiltSize, &walock[TILE_TILT]);
|
||||
tileCreate(TILE_TILT, tiltcx, tiltcx);
|
||||
|
||||
renderSetTarget(TILE_TILT, viewtilexsiz, viewtileysiz);
|
||||
|
||||
|
@ -3873,7 +3868,7 @@ void G_DoSpriteAnimations(int32_t ourx, int32_t oury, int32_t ourz, int32_t oura
|
|||
t->xrepeat += 10;
|
||||
t->yrepeat += 9;
|
||||
}
|
||||
else if (g_curViewscreen == i && display_mirror != 3 && waloff[viewscrTile])
|
||||
else if (g_curViewscreen == i && display_mirror != 3 && tileData(viewscrTile))
|
||||
{
|
||||
// this exposes a sprite sorting issue which needs to be debugged further...
|
||||
#if 0
|
||||
|
|
|
@ -2391,7 +2391,7 @@ static void Menu_PreDraw(MenuID_t cm, MenuEntry_t *entry, const vec2_t origin)
|
|||
|
||||
if (msv.brief.isValid())
|
||||
{
|
||||
if (waloff[TILE_LOADSHOT])
|
||||
if (tilePtr(TILE_LOADSHOT))
|
||||
rotatesprite_fs(origin.x + (101<<16), origin.y + (97<<16), 65536>>1,512,TILE_LOADSHOT, msv.isOldVer?16:-32, 0,4+10+64);
|
||||
|
||||
if (msv.isOldVer)
|
||||
|
@ -2456,7 +2456,7 @@ static void Menu_PreDraw(MenuID_t cm, MenuEntry_t *entry, const vec2_t origin)
|
|||
|
||||
if (msv.brief.isValid())
|
||||
{
|
||||
if (waloff[TILE_LOADSHOT])
|
||||
if (tilePtr(TILE_LOADSHOT))
|
||||
rotatesprite_fs(origin.x + (101<<16), origin.y + (97<<16), 65536>>1,512,TILE_LOADSHOT, msv.isOldVer?16:-32, 0,4+10+64);
|
||||
|
||||
if (msv.isOldVer)
|
||||
|
|
|
@ -505,8 +505,7 @@ void G_CacheMapData(void)
|
|||
else if ((gotpic[i>>3] & pow2char[i&7]) != pow2char[i&7])
|
||||
continue;
|
||||
|
||||
if (waloff[i] == 0)
|
||||
tileLoad((int16_t)i);
|
||||
tileCache(i);
|
||||
|
||||
#ifdef USE_OPENGL
|
||||
cacheExtraTextureMaps(i);
|
||||
|
|
|
@ -317,7 +317,7 @@ int32_t G_LoadSaveHeaderNew(char const *fn, savehead_t *saveh)
|
|||
tileCreate(TILE_LOADSHOT, 200, 320);
|
||||
if (screenshotofs)
|
||||
{
|
||||
if (kdfread_LZ4((char *)waloff[TILE_LOADSHOT], 320, 200, fil) != 200)
|
||||
if (kdfread_LZ4(tileData(TILE_LOADSHOT), 320, 200, fil) != 200)
|
||||
{
|
||||
OSD_Printf("G_LoadSaveHeaderNew(): failed reading screenshot in \"%s\"\n", fn);
|
||||
goto corrupt;
|
||||
|
@ -329,14 +329,14 @@ int32_t G_LoadSaveHeaderNew(char const *fn, savehead_t *saveh)
|
|||
if (G_ModDirSnprintf(scrbuf, sizeof(scrbuf), "%s.raw", fn) == 0)
|
||||
{
|
||||
buildvfs_FILE scrfil = buildvfs_fopen_write(scrbuf);
|
||||
buildvfs_fwrite((char *)waloff[TILE_LOADSHOT], 320, 200, scrfil);
|
||||
buildvfs_fwrite(tileData(TILE_LOADSHOT), 320, 200, scrfil);
|
||||
buildvfs_fclose(scrfil);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
Bmemset((char *)waloff[TILE_LOADSHOT], 0, 320*200);
|
||||
Bmemset(tileData(TILE_LOADSHOT), 0, 320*200);
|
||||
}
|
||||
tileInvalidate(TILE_LOADSHOT, 0, 255);
|
||||
|
||||
|
@ -1747,12 +1747,12 @@ int32_t sv_saveandmakesnapshot(buildvfs_FILE fil, char const *name, int8_t spot,
|
|||
// for savegames, the file offset after the screenshot goes here;
|
||||
// for demos, we keep it 0 to signify that we didn't save one
|
||||
buildvfs_fwrite("\0\0\0\0", 4, 1, fil);
|
||||
if (spot >= 0 && waloff[TILE_SAVESHOT])
|
||||
if (spot >= 0 && tileData(TILE_SAVESHOT))
|
||||
{
|
||||
int32_t ofs;
|
||||
|
||||
// write the screenshot compressed
|
||||
dfwrite_LZ4((char *)waloff[TILE_SAVESHOT], 320, 200, fil);
|
||||
dfwrite_LZ4(tileData(TILE_SAVESHOT), 320, 200, fil);
|
||||
|
||||
// write the current file offset right after the header
|
||||
ofs = buildvfs_ftell(fil);
|
||||
|
|
|
@ -102,10 +102,8 @@ void G_GetCrosshairColor(void)
|
|||
|
||||
tileLoad(CROSSHAIR);
|
||||
|
||||
if (!waloff[CROSSHAIR])
|
||||
return;
|
||||
|
||||
char const *ptr = (char const *) waloff[CROSSHAIR];
|
||||
auto ptr = tilePtr(CROSSHAIR);
|
||||
if (!ptr) return;
|
||||
|
||||
// find the brightest color in the original 8-bit tile
|
||||
int32_t ii = tilesiz[CROSSHAIR].x * tilesiz[CROSSHAIR].y;
|
||||
|
@ -137,9 +135,10 @@ void G_SetCrosshairColor(int32_t r, int32_t g, int32_t b)
|
|||
return;
|
||||
|
||||
tileLoad(CROSSHAIR);
|
||||
tileMakeWritable(CROSSHAIR);
|
||||
|
||||
if (!waloff[CROSSHAIR])
|
||||
return;
|
||||
auto ptr = tileData(CROSSHAIR);
|
||||
if (!ptr) return;
|
||||
|
||||
if (!DefaultCrosshairColors.f)
|
||||
G_GetCrosshairColor();
|
||||
|
@ -149,8 +148,6 @@ void G_SetCrosshairColor(int32_t r, int32_t g, int32_t b)
|
|||
CrosshairColors.g = g;
|
||||
CrosshairColors.b = b;
|
||||
|
||||
char *ptr = (char *) waloff[CROSSHAIR];
|
||||
|
||||
int32_t ii = tilesiz[CROSSHAIR].x * tilesiz[CROSSHAIR].y;
|
||||
|
||||
Bassert(ii > 0);
|
||||
|
|
|
@ -385,7 +385,6 @@ static void G_SetupCamTile(int spriteNum, int tileNum, int smoothRatio)
|
|||
vec3_t const camera = G_GetCameraPosition(spriteNum, smoothRatio);
|
||||
int const saveMirror = display_mirror;
|
||||
|
||||
//if (waloff[wn] == 0) loadtile(wn);
|
||||
renderSetTarget(tileNum, tilesiz[tileNum].y, tilesiz[tileNum].x);
|
||||
|
||||
int const noDraw = VM_OnEventWithReturn(EVENT_DISPLAYROOMSCAMERATILE, spriteNum, playerNum, 0);
|
||||
|
@ -436,7 +435,7 @@ void G_AnimateCamSprite(int smoothRatio)
|
|||
int const viewscrShift = G_GetViewscreenSizeShift((uspriteptr_t)&sprite[spriteNum]);
|
||||
int const viewscrTile = TILE_VIEWSCR - viewscrShift;
|
||||
|
||||
if (waloff[viewscrTile] == 0)
|
||||
if (tileData(viewscrTile) == 0)
|
||||
tileCreate(viewscrTile, tilesiz[PN(spriteNum)].x << viewscrShift, tilesiz[PN(spriteNum)].y << viewscrShift);
|
||||
else
|
||||
walock[viewscrTile] = 199;
|
||||
|
|
|
@ -3694,6 +3694,7 @@ ACTOR_STATIC int A_CheckPins(int16_t const sectNum)
|
|||
if (tag != 0)
|
||||
{
|
||||
int const tileNumber = LANEPICS + tag + 1;
|
||||
tileMakeWritable(tileNumber);
|
||||
tileCopySection(LANEPICS+1, 0, 0, 128, 64, tileNumber, 0, 0);
|
||||
|
||||
for (int pin = 0; pin < 10; pin++)
|
||||
|
@ -3786,7 +3787,8 @@ ACTOR_STATIC void A_ResetPins(int16_t sect)
|
|||
if (tag != 0)
|
||||
{
|
||||
int const tileNumber = LANEPICS + tag + 1;
|
||||
tileCopySection(LANEPICS+1, 0, 0, 128, 64, tileNumber, 0, 0);
|
||||
tileMakeWritable(tileNumber);
|
||||
tileCopySection(LANEPICS+1, 0, 0, 128, 64, tileNumber, 0, 0);
|
||||
|
||||
for (int pin = 0; pin < 10; pin++)
|
||||
{
|
||||
|
@ -3844,7 +3846,8 @@ void A_ResetLanePics(void)
|
|||
for (int tag = 1; tag <= 4; tag++)
|
||||
{
|
||||
int const tileNumber = LANEPICS + tag + 1;
|
||||
tileCopySection(LANEPICS + 1, 0, 0, 128, 64, tileNumber, 0, 0);
|
||||
tileMakeWritable(tileNumber);
|
||||
tileCopySection(LANEPICS + 1, 0, 0, 128, 64, tileNumber, 0, 0);
|
||||
|
||||
for (int pin = 0; pin < 10; pin++)
|
||||
{
|
||||
|
|
|
@ -522,7 +522,7 @@ int32_t Anim_Play(const char *fn)
|
|||
if (totalclock < ototalclock - 1)
|
||||
continue;
|
||||
|
||||
waloff[TILE_ANIM] = (intptr_t)ANIM_DrawFrame(i);
|
||||
tileSetExternal(TILE_ANIM, 200, 320, ANIM_DrawFrame(i));
|
||||
tileInvalidate(TILE_ANIM, 0, 1 << 4); // JBF 20031228
|
||||
|
||||
if (I_CheckAllInput())
|
||||
|
@ -593,6 +593,7 @@ end_anim_restore_gl:
|
|||
end_anim:
|
||||
I_ClearAllInput();
|
||||
ANIM_FreeAnim();
|
||||
tileDelete(TILE_ANIM);
|
||||
walock[TILE_ANIM] = 1;
|
||||
anim->animlock = 0;
|
||||
|
||||
|
|
|
@ -919,8 +919,7 @@ static void G_ReadGLFrame(void)
|
|||
const int32_t xf = divscale16(ydim*4/3, 320);
|
||||
const int32_t yf = divscale16(ydim, 200); // (ydim<<16)/200
|
||||
|
||||
tileCreate(TILE_SAVESHOT, 200, 320);
|
||||
char* const pic = (char*)waloff[TILE_SAVESHOT];
|
||||
auto pic = tileCreate(TILE_SAVESHOT, 200, 320);
|
||||
|
||||
if (!frame)
|
||||
{
|
||||
|
@ -1045,9 +1044,7 @@ void G_DrawRooms(int32_t playerNum, int32_t smoothRatio)
|
|||
|
||||
if (g_screenCapture)
|
||||
{
|
||||
walock[TILE_SAVESHOT] = 199;
|
||||
if (waloff[TILE_SAVESHOT] == 0)
|
||||
cacheAllocateBlock(&waloff[TILE_SAVESHOT],200*320,&walock[TILE_SAVESHOT]);
|
||||
tileCreate(TILE_SAVESHOT, 200, 320);
|
||||
|
||||
if (videoGetRenderMode() == REND_CLASSIC)
|
||||
renderSetTarget(TILE_SAVESHOT, 200, 320);
|
||||
|
@ -1105,11 +1102,9 @@ void G_DrawRooms(int32_t playerNum, int32_t smoothRatio)
|
|||
const int32_t viewtilexsiz = (tang&1023) ? tiltcx : tiltcy;
|
||||
const int32_t viewtileysiz = tiltcx;
|
||||
|
||||
walock[TILE_TILT] = 255;
|
||||
if (waloff[TILE_TILT] == 0)
|
||||
cacheAllocateBlock(&waloff[TILE_TILT], maxTiltSize, &walock[TILE_TILT]);
|
||||
tileCreate(TILE_TILT, tiltcx, tiltcx);
|
||||
|
||||
renderSetTarget(TILE_TILT, viewtilexsiz, viewtileysiz);
|
||||
renderSetTarget(TILE_TILT, viewtilexsiz, viewtileysiz);
|
||||
|
||||
if ((tang&1023) == 512)
|
||||
{
|
||||
|
@ -5057,7 +5052,7 @@ default_case1:
|
|||
t->xrepeat += 10;
|
||||
t->yrepeat += 9;
|
||||
}
|
||||
else if (g_curViewscreen == i && display_mirror != 3 && waloff[viewscrTile] && walock[viewscrTile] > 200)
|
||||
else if (g_curViewscreen == i && display_mirror != 3 && tileData(viewscrTile) && walock[viewscrTile] > 200)
|
||||
{
|
||||
// this exposes a sprite sorting issue which needs to be debugged further...
|
||||
#if 0
|
||||
|
|
|
@ -590,7 +590,7 @@ void G_CacheMapData(void)
|
|||
{
|
||||
tloadtile(sector[i].floorpicnum, 0);
|
||||
tloadtile(sector[i].ceilingpicnum, 0);
|
||||
if (sector[i].ceilingpicnum == LA) // JBF 20040509: if( waloff[sector[i].ceilingpicnum] == LA) WTF?!?!?!?
|
||||
if (sector[i].ceilingpicnum == LA) // JBF 20040509: if( w aloff[sector[i].ceilingpicnum] == LA) WTF?!?!?!?
|
||||
{
|
||||
tloadtile(LA+1, 0);
|
||||
tloadtile(LA+2, 0);
|
||||
|
@ -615,8 +615,7 @@ void G_CacheMapData(void)
|
|||
}
|
||||
if (gotpic[i>>3] & pow2char[i&7])
|
||||
{
|
||||
if (waloff[i] == 0)
|
||||
tileLoad((int16_t)i);
|
||||
tileCache(i);
|
||||
|
||||
#ifdef USE_OPENGL
|
||||
// PRECACHE
|
||||
|
@ -1476,7 +1475,7 @@ static void prelevel(char g)
|
|||
|
||||
if (sector[i].ceilingstat&1)
|
||||
{
|
||||
if (waloff[sector[i].ceilingpicnum] == 0)
|
||||
if (tilePtr(sector[i].ceilingpicnum) == 0)
|
||||
{
|
||||
if (sector[i].ceilingpicnum == LA)
|
||||
for (bsize_t j = 0; j < 5; j++)
|
||||
|
|
|
@ -297,7 +297,7 @@ int32_t G_LoadSaveHeaderNew(char const *fn, savehead_t *saveh)
|
|||
tileCreate(TILE_LOADSHOT, 200, 320);
|
||||
if (screenshotofs)
|
||||
{
|
||||
if (kdfread_LZ4((char *)waloff[TILE_LOADSHOT], 320, 200, fil) != 200)
|
||||
if (kdfread_LZ4(tileData(TILE_LOADSHOT), 320, 200, fil) != 200)
|
||||
{
|
||||
OSD_Printf("G_LoadSaveHeaderNew(): failed reading screenshot in \"%s\"\n", fn);
|
||||
goto corrupt;
|
||||
|
@ -305,7 +305,7 @@ int32_t G_LoadSaveHeaderNew(char const *fn, savehead_t *saveh)
|
|||
}
|
||||
else
|
||||
{
|
||||
Bmemset((char *)waloff[TILE_LOADSHOT], 0, 320*200);
|
||||
Bmemset(tileData(TILE_LOADSHOT), 0, 320*200);
|
||||
}
|
||||
tileInvalidate(TILE_LOADSHOT, 0, 255);
|
||||
|
||||
|
@ -1422,12 +1422,12 @@ int32_t sv_saveandmakesnapshot(FILE *fil, char const *name, int8_t spot, int8_t
|
|||
// for savegames, the file offset after the screenshot goes here;
|
||||
// for demos, we keep it 0 to signify that we didn't save one
|
||||
fwrite("\0\0\0\0", 4, 1, fil);
|
||||
if (spot >= 0 && waloff[TILE_SAVESHOT])
|
||||
if (spot >= 0 && tileData(TILE_SAVESHOT))
|
||||
{
|
||||
int32_t ofs;
|
||||
|
||||
// write the screenshot compressed
|
||||
dfwrite_LZ4((char *)waloff[TILE_SAVESHOT], 320, 200, fil);
|
||||
dfwrite_LZ4(tileData(TILE_SAVESHOT), 320, 200, fil);
|
||||
|
||||
// write the current file offset right after the header
|
||||
ofs = ftell(fil);
|
||||
|
|
|
@ -96,12 +96,10 @@ void G_GetCrosshairColor(void)
|
|||
if (DefaultCrosshairColors.f)
|
||||
return;
|
||||
|
||||
tileLoad(CROSSHAIR);
|
||||
tileLoad(CROSSHAIR);
|
||||
|
||||
if (!waloff[CROSSHAIR])
|
||||
return;
|
||||
|
||||
char const *ptr = (char const *) waloff[CROSSHAIR];
|
||||
auto ptr = tilePtr(CROSSHAIR);
|
||||
if (!ptr) return;
|
||||
|
||||
// find the brightest color in the original 8-bit tile
|
||||
int32_t ii = tilesiz[CROSSHAIR].x * tilesiz[CROSSHAIR].y;
|
||||
|
@ -130,9 +128,10 @@ void G_SetCrosshairColor(int32_t r, int32_t g, int32_t b)
|
|||
return;
|
||||
|
||||
tileLoad(CROSSHAIR);
|
||||
tileMakeWritable(CROSSHAIR);
|
||||
|
||||
if (!waloff[CROSSHAIR])
|
||||
return;
|
||||
auto ptr = tileData(CROSSHAIR);
|
||||
if (!ptr) return;
|
||||
|
||||
if (!DefaultCrosshairColors.f)
|
||||
G_GetCrosshairColor();
|
||||
|
@ -142,8 +141,6 @@ void G_SetCrosshairColor(int32_t r, int32_t g, int32_t b)
|
|||
CrosshairColors.g = g;
|
||||
CrosshairColors.b = b;
|
||||
|
||||
char *ptr = (char *) waloff[CROSSHAIR];
|
||||
|
||||
int32_t ii = tilesiz[CROSSHAIR].x * tilesiz[CROSSHAIR].y;
|
||||
|
||||
Bassert(ii > 0);
|
||||
|
|
|
@ -502,7 +502,6 @@ static void G_SetupCamTile(int spriteNum, int tileNum, int smoothRatio)
|
|||
vec3_t const camera = G_GetCameraPosition(spriteNum, smoothRatio);
|
||||
int const saveMirror = display_mirror;
|
||||
|
||||
//if (waloff[wn] == 0) loadtile(wn);
|
||||
renderSetTarget(tileNum, tilesiz[tileNum].y, tilesiz[tileNum].x);
|
||||
|
||||
yax_preparedrawrooms();
|
||||
|
@ -542,7 +541,7 @@ void G_AnimateCamSprite(int smoothRatio)
|
|||
int const viewscrShift = G_GetViewscreenSizeShift((const uspritetype *)&sprite[spriteNum]);
|
||||
int const viewscrTile = TILE_VIEWSCR - viewscrShift;
|
||||
|
||||
if (waloff[viewscrTile] == 0)
|
||||
if (tileData(viewscrTile) == 0)
|
||||
tileCreate(viewscrTile, tilesiz[PN(spriteNum)].x << viewscrShift, tilesiz[PN(spriteNum)].y << viewscrShift);
|
||||
else
|
||||
walock[viewscrTile] = 255;
|
||||
|
@ -5213,7 +5212,7 @@ void G_Thunder(void)
|
|||
if ((gotpic[RRTILE2577>>3]&(1<<(RRTILE2577&7))))
|
||||
{
|
||||
gotpic[RRTILE2577>>3] &= ~(1<<(RRTILE2577&7));
|
||||
if (waloff[RRTILE2577] != 0)
|
||||
if (tilePtr(RRTILE2577) != 0) // why does this on texture load state???
|
||||
{
|
||||
g_visibility = 256;
|
||||
if (krand2() > 65000)
|
||||
|
@ -5246,7 +5245,7 @@ void G_Thunder(void)
|
|||
if ((gotpic[RRTILE2562>>3]&(1<<(RRTILE2562&7))))
|
||||
{
|
||||
gotpic[RRTILE2562>>3] &= ~(1<<(RRTILE2562&7));
|
||||
if (waloff[RRTILE2562] != 0)
|
||||
if (tilePtr(RRTILE2562) != 0) // why does this on texture load state???
|
||||
{
|
||||
if (krand2() > 65000)
|
||||
{
|
||||
|
|
|
@ -631,7 +631,7 @@ void DoTheCache(void)
|
|||
|
||||
for (i = 0; i < MAXTILES; i++)
|
||||
{
|
||||
if ((TEST(gotpic[i>>3], 1<<(i&7))) && (!waloff[i]))
|
||||
if ((TEST(gotpic[i>>3], 1<<(i&7))) && (!tilePtr(i)))
|
||||
{
|
||||
tileLoad(i);
|
||||
cnt++;
|
||||
|
|
|
@ -2454,6 +2454,7 @@ drawscreen(PLAYERp pp)
|
|||
// Only animate lava if its picnum is on screen
|
||||
// gotpic is a bit array where the tile number's bit is set
|
||||
// whenever it is drawn (ceilings, walls, sprites, etc.)
|
||||
#if 0 // This needs a different implementation.
|
||||
if ((gotpic[SLIME >> 3] & (1 << (SLIME & 7))) > 0)
|
||||
{
|
||||
gotpic[SLIME >> 3] &= ~(1 << (SLIME & 7));
|
||||
|
@ -2461,6 +2462,7 @@ drawscreen(PLAYERp pp)
|
|||
if (waloff[SLIME])
|
||||
movelava((char *) waloff[SLIME]);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
i = pp->cursectnum;
|
||||
|
|
|
@ -487,10 +487,7 @@ JS_InitMirrors(void)
|
|||
void drawroomstotile(int daposx, int daposy, int daposz,
|
||||
short daang, int dahoriz, short dacursectnum, short tilenume)
|
||||
{
|
||||
if (waloff[tilenume] == 0)
|
||||
tileLoad(tilenume);
|
||||
|
||||
PRODUCTION_ASSERT(waloff[tilenume]);
|
||||
tileCreate(tilenume, tilesiz[tilenume].x, tilesiz[tilenume].y);
|
||||
|
||||
renderSetTarget(tilenume, tilesiz[tilenume].x, tilesiz[tilenume].y);
|
||||
|
||||
|
|
|
@ -1313,7 +1313,7 @@ void
|
|||
ScreenSave(MFILE_WRITE fout)
|
||||
{
|
||||
// int num;
|
||||
MWRITE((void *)waloff[SAVE_SCREEN_TILE], SAVE_SCREEN_XSIZE * SAVE_SCREEN_YSIZE, 1, fout);
|
||||
MWRITE((void *)tileData(SAVE_SCREEN_TILE), SAVE_SCREEN_XSIZE * SAVE_SCREEN_YSIZE, 1, fout);
|
||||
// ASSERT(num == 1);
|
||||
}
|
||||
|
||||
|
@ -1324,7 +1324,7 @@ ScreenLoad(MFILE_READ fin)
|
|||
|
||||
renderSetTarget(SAVE_SCREEN_TILE, SAVE_SCREEN_YSIZE, SAVE_SCREEN_XSIZE);
|
||||
|
||||
num = MREAD((void *)waloff[SAVE_SCREEN_TILE], SAVE_SCREEN_XSIZE * SAVE_SCREEN_YSIZE, 1, fin);
|
||||
num = MREAD(tileData(SAVE_SCREEN_TILE), SAVE_SCREEN_XSIZE * SAVE_SCREEN_YSIZE, 1, fin);
|
||||
|
||||
renderRestoreTarget();
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue