mirror of
https://github.com/ZDoom/raze-gles.git
synced 2024-11-10 23:02:03 +00:00
- more updating and bug in UpdatePicSize fixed.
This commit is contained in:
parent
0e165e40a3
commit
c3bc690e98
18 changed files with 61 additions and 154 deletions
|
@ -84,7 +84,7 @@ int tileInit(char a1, const char *a2)
|
|||
UNREFERENCED_PARAMETER(a1);
|
||||
if (artLoaded)
|
||||
return 1;
|
||||
artLoadFiles(a2 ? a2 : pzBaseFileName, MAXCACHE1DSIZE);
|
||||
TileFiles.artLoadFiles(a2 ? a2 : pzBaseFileName);
|
||||
for (int i = 0; i < kMaxTiles; i++)
|
||||
voxelIndex[i] = 0;
|
||||
|
||||
|
|
|
@ -833,15 +833,8 @@ EXTERN char show2dsector[(MAXSECTORS+7)>>3];
|
|||
EXTERN char show2dwall[(MAXWALLS+7)>>3];
|
||||
EXTERN char show2dsprite[(MAXSPRITES+7)>>3];
|
||||
|
||||
// In the editor, gotpic is only referenced from inline assembly;
|
||||
// the compiler needs that hint or building with LTO will discard it.
|
||||
#if !defined __clang__ && !defined NOASM
|
||||
# define GOTPIC_USED ATTRIBUTE((used))
|
||||
#else
|
||||
# define GOTPIC_USED
|
||||
#endif
|
||||
|
||||
EXTERN char GOTPIC_USED gotpic[(MAXTILES+7)>>3];
|
||||
EXTERN uint8_t gotpic[(MAXTILES+7)>>3];
|
||||
EXTERN char gotsector[(MAXSECTORS+7)>>3];
|
||||
|
||||
EXTERN char editorcolors[256];
|
||||
|
@ -1048,7 +1041,6 @@ int32_t artReadHeaderFromBuffer(uint8_t const *buf, artheader_t *local);
|
|||
int32_t artCheckUnitFileHeader(uint8_t const *buf, int32_t length);
|
||||
void artReadManifest(buildvfs_kfd fil, artheader_t const *local);
|
||||
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);
|
||||
|
@ -1100,7 +1092,6 @@ int32_t printext16(int32_t xpos, int32_t ypos, int16_t col, int16_t backcol,
|
|||
const char *name, char fontsize) ATTRIBUTE((nonnull(5)));
|
||||
void printext256(int32_t xpos, int32_t ypos, int16_t col, int16_t backcol,
|
||||
const char *name, char fontsize) ATTRIBUTE((nonnull(5)));
|
||||
void Buninitart(void);
|
||||
|
||||
////////// specialized rotatesprite wrappers for (very) often used cases //////////
|
||||
static FORCE_INLINE void rotatesprite(int32_t sx, int32_t sy, int32_t z, int16_t a, int16_t picnum,
|
||||
|
|
|
@ -18,68 +18,10 @@ extern char *kpzbuf;
|
|||
extern int32_t kpzbufsiz;
|
||||
extern int32_t kpzbufload(const char *);
|
||||
|
||||
void cacheInitBuffer(intptr_t dacachestart, int32_t dacachesize);
|
||||
void cacheInitBuffer(int32_t dacachesize);
|
||||
void cacheAllocateBlock(intptr_t *newhandle, int32_t newbytes, uint8_t *newlockptr);
|
||||
void cacheAgeEntries(void);
|
||||
|
||||
#ifdef USE_PHYSFS
|
||||
using buildvfs_kfd = PHYSFS_File *;
|
||||
#define buildvfs_kfd_invalid (nullptr)
|
||||
|
||||
extern int32_t pathsearchmode; // 0 = gamefs mode (default), 1 = localfs mode (editor's mode)
|
||||
|
||||
#define addsearchpath(a) addsearchpath_user(a, 0)
|
||||
static inline int32_t addsearchpath_user(const char *p, int32_t)
|
||||
{
|
||||
return PHYSFS_mount(p, NULL, 1) == 0 ? -1 : 0;
|
||||
}
|
||||
|
||||
static inline int32_t removesearchpath(const char *p)
|
||||
{
|
||||
return PHYSFS_unmount(p);
|
||||
}
|
||||
static inline void removesearchpaths_withuser(int32_t)
|
||||
{
|
||||
// TODO
|
||||
}
|
||||
|
||||
|
||||
int32_t findfrompath(const char *fn, char **where);
|
||||
buildvfs_kfd openfrompath(const char *fn, int32_t flags, int32_t mode);
|
||||
buildvfs_FILE fopenfrompath(const char *fn, const char *mode);
|
||||
|
||||
|
||||
extern int32_t numgroupfiles;
|
||||
void uninitgroupfile(void);
|
||||
|
||||
|
||||
static inline int initgroupfile(const char *filename)
|
||||
{
|
||||
return PHYSFS_mount(filename, NULL, 1) == 0 ? -1 : 0;
|
||||
}
|
||||
|
||||
|
||||
#define kread(fd, p, s) PHYSFS_readBytes((fd), (p), (s))
|
||||
#define kwrite(fd, p, s) PHYSFS_writeBytes((fd), (p), (s))
|
||||
#define kopen4load(fn, searchfirst) PHYSFS_openRead(fn)
|
||||
#define ktell(fd) PHYSFS_tell(fd)
|
||||
#define kfilelength(fd) PHYSFS_fileLength(fd)
|
||||
|
||||
|
||||
static inline void kclose(buildvfs_kfd handle)
|
||||
{
|
||||
PHYSFS_close(handle);
|
||||
}
|
||||
|
||||
#define kread_and_test(handle, buffer, leng) EDUKE32_PREDICT_FALSE(kread((handle), (buffer), (leng)) != (leng))
|
||||
extern int32_t klseek(buildvfs_kfd handle, int32_t offset, int32_t whence);
|
||||
#define klseek_and_test(handle, offset, whence) EDUKE32_PREDICT_FALSE(klseek((handle), (offset), (whence)) < 0)
|
||||
|
||||
static inline void krename(int32_t, int32_t, const char *)
|
||||
{
|
||||
}
|
||||
|
||||
#else
|
||||
using buildvfs_kfd = int32_t;
|
||||
#define buildvfs_kfd_invalid (-1)
|
||||
|
||||
|
@ -109,7 +51,6 @@ void kclose(buildvfs_kfd handle);
|
|||
|
||||
void krename(int32_t crcval, int32_t filenum, const char *newname);
|
||||
char const * kfileparent(int32_t handle);
|
||||
#endif
|
||||
|
||||
extern int32_t kpzbufloadfil(buildvfs_kfd);
|
||||
|
||||
|
|
|
@ -103,8 +103,8 @@ int32_t kpzbufload(char const * const filnam)
|
|||
#define MAXCACHEOBJECTS 16384
|
||||
|
||||
#if !defined DEBUG_ALLOCACHE_AS_MALLOC
|
||||
static int32_t cachesize = 0;
|
||||
static uint8_t zerochar = 0;
|
||||
static TArray<uint8_t> cache;
|
||||
static intptr_t cachestart = 0;
|
||||
static int32_t lockrecip[200];
|
||||
|
||||
|
@ -135,7 +135,7 @@ uint8_t toupperlookup[256] =
|
|||
static void reportandexit(const char *errormessage);
|
||||
|
||||
|
||||
void cacheInitBuffer(intptr_t dacachestart, int32_t dacachesize)
|
||||
void cacheInitBuffer(int32_t dacachesize)
|
||||
{
|
||||
#ifndef DEBUG_ALLOCACHE_AS_MALLOC
|
||||
int32_t i;
|
||||
|
@ -143,14 +143,11 @@ void cacheInitBuffer(intptr_t dacachestart, int32_t dacachesize)
|
|||
for (i=1; i<200; i++)
|
||||
lockrecip[i] = tabledivide32_noinline(1<<28, 200-i);
|
||||
|
||||
// we allocate this block with aligned_alloc, but I'm leaving this here in
|
||||
// case we run on any platforms that just implement it as regular malloc
|
||||
cache.Resize(dacachesize);
|
||||
|
||||
cachestart = ((uintptr_t)dacachestart+15)&~(uintptr_t)0xf;
|
||||
cachesize = (dacachesize-(((uintptr_t)(dacachestart))&0xf))&~(uintptr_t)0xf;
|
||||
|
||||
cac[0].leng = cachesize;
|
||||
cac[0].leng = cache.Size();
|
||||
cac[0].lock = &zerochar;
|
||||
cachestart = (intptr_t)cache.Data();
|
||||
cacnum = 1;
|
||||
|
||||
initprintf("Initialized %.1fM cache\n", (float)(dacachesize/1024.f/1024.f));
|
||||
|
@ -178,13 +175,13 @@ int32_t cacheFindBlock(int32_t newbytes, int32_t *besto, int32_t *bestz)
|
|||
{
|
||||
int32_t bestval = 0x7fffffff;
|
||||
|
||||
for (native_t z=cacnum-1, o1=cachesize; z>=0; z--)
|
||||
for (native_t z=cacnum-1, o1=cache.Size(); z>=0; z--)
|
||||
{
|
||||
o1 -= cac[z].leng;
|
||||
|
||||
int32_t const o2 = o1 + newbytes;
|
||||
|
||||
if (o2 > cachesize)
|
||||
if (o2 > cache.Size())
|
||||
continue;
|
||||
|
||||
int32_t daval = 0;
|
||||
|
@ -234,9 +231,9 @@ void cacheAllocateBlock(intptr_t* newhandle, int32_t newbytes, uint8_t* newlockp
|
|||
reportandexit("ALLOCACHE CALLED WITH LOCK OF 0!");
|
||||
#endif
|
||||
|
||||
if (EDUKE32_PREDICT_FALSE((unsigned)newbytes > (unsigned)cachesize))
|
||||
if ((unsigned)newbytes > (unsigned)cache.Size())
|
||||
{
|
||||
initprintf("Cachesize: %d\n",cachesize);
|
||||
initprintf("Cachesize: %u\n", cache.Size());
|
||||
initprintf("*Newhandle: 0x%" PRIxPTR ", Newbytes: %d, *Newlock: %d\n",(intptr_t)newhandle,newbytes,*newlockptr);
|
||||
reportandexit("BUFFER TOO BIG TO FIT IN CACHE!");
|
||||
}
|
||||
|
@ -353,7 +350,7 @@ static void reportandexit(const char *errormessage)
|
|||
j += cac[i].leng;
|
||||
}
|
||||
|
||||
initprintf("Cachesize = %d\n", cachesize);
|
||||
initprintf("Cachesize = %u\n", cache.Size());
|
||||
initprintf("Cacnum = %d\n", cacnum);
|
||||
initprintf("Cache length sum = %d\n", j);
|
||||
#endif
|
||||
|
|
|
@ -518,11 +518,6 @@ static int32_t defsparser(scriptfile *script)
|
|||
if (scriptfile_getsymbol(script,&tile)) break;
|
||||
if (scriptfile_getnumber(script,&col)) break;
|
||||
if (scriptfile_getnumber(script,&col2)) break;
|
||||
if ((uint32_t)tile < MAXTILES)
|
||||
{
|
||||
spritecol2d[tile][0] = col;
|
||||
spritecol2d[tile][1] = col2;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case T_2DCOL:
|
||||
|
|
|
@ -8258,8 +8258,6 @@ void engineUnInit(void)
|
|||
# endif
|
||||
#endif
|
||||
|
||||
Buninitart();
|
||||
|
||||
DO_FREE_AND_NULL(lookups);
|
||||
for (bssize_t i=0; i<DISTRECIPCACHESIZE; i++)
|
||||
ALIGNED_FREE_AND_NULL(distrecipcache[i].distrecip);
|
||||
|
|
|
@ -209,7 +209,6 @@ extern int32_t m32_numdebuglines;
|
|||
|
||||
static FORCE_INLINE void setgotpic(int32_t tilenume)
|
||||
{
|
||||
if (walock[tilenume] < 200) walock[tilenume] = 199;
|
||||
gotpic[tilenume>>3] |= pow2char[tilenume&7];
|
||||
}
|
||||
|
||||
|
|
|
@ -723,6 +723,11 @@ void initprintf(const char *f, ...)
|
|||
Bvsnprintf(buf, sizeof(buf), f, va);
|
||||
va_end(va);
|
||||
|
||||
#ifdef _WIN32
|
||||
if (IsDebuggerPresent())
|
||||
OutputDebugStringA(buf);
|
||||
#endif
|
||||
|
||||
initputs(buf);
|
||||
}
|
||||
|
||||
|
|
|
@ -26,8 +26,8 @@ EDUKE32_STATIC_ASSERT(MAXARTFILES_TOTAL <= 256);
|
|||
|
||||
static int32_t tilefileoffs[MAXTILES];
|
||||
|
||||
static vec2_16_t tilesizearray[MAXTILES];
|
||||
static uint8_t picsizearray[MAXTILES];
|
||||
vec2_16_t tilesizearray[MAXTILES];
|
||||
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;
|
||||
|
@ -567,49 +567,6 @@ static int32_t artReadIndexedFile(int32_t tilefilei)
|
|||
//
|
||||
// loadpics
|
||||
//
|
||||
int32_t artLoadFiles(const char *filename, int32_t askedsize)
|
||||
{
|
||||
TileFiles.LoadArtSet(filename);
|
||||
|
||||
#if 1
|
||||
Bstrncpyz(artfilenameformat, filename, sizeof(artfilenameformat));
|
||||
|
||||
Bmemset(&tilesizearray[0], 0, sizeof(vec2_16_t) * MAXTILES);
|
||||
Bmemset(picanm, 0, sizeof(picanm));
|
||||
|
||||
for (auto &rot : rottile)
|
||||
rot = { -1, -1 };
|
||||
|
||||
// artsize = 0;
|
||||
|
||||
for (int tilefilei=0; tilefilei<MAXARTFILES_BASE; tilefilei++)
|
||||
artReadIndexedFile(tilefilei);
|
||||
|
||||
Bmemset(gotpic, 0, sizeof(gotpic));
|
||||
|
||||
//cachesize = min((int32_t)((Bgetsysmemsize()/100)*60),max(artsize,askedsize));
|
||||
cachesize = (Bgetsysmemsize() <= (uint32_t)askedsize) ? (int32_t)((Bgetsysmemsize() / 100) * 60) : askedsize;
|
||||
pic = Xaligned_alloc(Bgetpagesize(), cachesize);
|
||||
cacheInitBuffer((intptr_t) pic, cachesize);
|
||||
|
||||
artUpdateManifest();
|
||||
|
||||
artfil = buildvfs_kfd_invalid;
|
||||
artfilnum = -1;
|
||||
artfilplc = 0L;
|
||||
#endif
|
||||
|
||||
for (unsigned i = 0; i < MAXTILES; i++)
|
||||
{
|
||||
auto tex = TileFiles.tiles[i];
|
||||
assert(tex);
|
||||
picanm[i] = tex->PicAnim;
|
||||
tilesizearray[i] = tex->GetSize();
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
const uint8_t* tilePtr(int num)
|
||||
{
|
||||
auto tex = TileFiles.tiles[num];
|
||||
|
@ -796,8 +753,8 @@ void tileCopySection(int32_t tilenume1, int32_t sx1, int32_t sy1, int32_t xsiz,
|
|||
xsiz2 = tilesiz[tilenume2].x; ysiz2 = tilesiz[tilenume2].y;
|
||||
if ((xsiz1 > 0) && (ysiz1 > 0) && (xsiz2 > 0) && (ysiz2 > 0))
|
||||
{
|
||||
if (tileptr[tilenume1] == 0) tileLoad(tilenume1);
|
||||
if (tiledata[tilenume2] == 0) tileLoad(tilenume2);
|
||||
tileLoad(tilenume1);
|
||||
if (tileData(tilenume2) == 0) return; // Error: Destination is not writable.
|
||||
|
||||
x1 = sx1;
|
||||
for (i=0; i<xsiz; i++)
|
||||
|
|
|
@ -236,7 +236,7 @@ void BuildFiles::CloseAllMapArt()
|
|||
//
|
||||
//===========================================================================
|
||||
|
||||
void BuildFiles::LoadArtFile(const char *fn, bool mapart, int firsttile)
|
||||
int BuildFiles::LoadArtFile(const char *fn, bool mapart, int firsttile)
|
||||
{
|
||||
auto old = FindFile(fn);
|
||||
if (old >= ArtFiles.Size()) // Do not process if already loaded.
|
||||
|
@ -264,6 +264,7 @@ void BuildFiles::LoadArtFile(const char *fn, bool mapart, int firsttile)
|
|||
else
|
||||
{
|
||||
//initprintf("%s: file not found\n", fn);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@ -273,6 +274,7 @@ void BuildFiles::LoadArtFile(const char *fn, bool mapart, int firsttile)
|
|||
//ArtFiles.Delete(old);
|
||||
//ArtFiles.Push(std::move(fd));
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
|
@ -326,6 +328,34 @@ FTexture* BuildFiles::ValidateCustomTile(int tilenum, int type)
|
|||
return replacement;
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
// global interface
|
||||
//
|
||||
//==========================================================================
|
||||
extern vec2_16_t tilesizearray[MAXTILES];
|
||||
extern uint8_t picsizearray[MAXTILES];
|
||||
|
||||
int32_t BuildFiles::artLoadFiles(const char* filename)
|
||||
{
|
||||
TileFiles.LoadArtSet(filename);
|
||||
memset(gotpic, 0, MAXTILES);
|
||||
cacheInitBuffer(MAXCACHE1DSIZE);
|
||||
|
||||
for (unsigned i = 0; i < MAXTILES; i++)
|
||||
{
|
||||
auto tex = TileFiles.tiles[i];
|
||||
assert(tex);
|
||||
picanm[i] = tex->PicAnim;
|
||||
tilesizearray[i] = tex->GetSize();
|
||||
picsizearray[i] = tex->PicSize;
|
||||
rottile[i] = { -1, -1 };
|
||||
}
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
// Creates a tile for displaying custom content
|
||||
|
|
|
@ -52,8 +52,7 @@ FImageTexture::FImageTexture(FImageSource *img, const char *name)
|
|||
mImage = img;
|
||||
if (img != nullptr)
|
||||
{
|
||||
Size.x = img->GetWidth();
|
||||
Size.y = img->GetHeight();
|
||||
SetSize(img->GetWidth(), img->GetHeight());
|
||||
|
||||
auto offsets = img->GetOffsets();
|
||||
PicAnim.xofs = offsets.first;
|
||||
|
|
|
@ -259,11 +259,10 @@ protected:
|
|||
void UpdatePicSize()
|
||||
{
|
||||
int j = 15;
|
||||
int size;
|
||||
|
||||
while ((j > 1) && ((1 << j) > Size.x))
|
||||
j--;
|
||||
size = j;
|
||||
PicSize = j;
|
||||
|
||||
j = 15;
|
||||
while ((j > 1) && ((1 << j) > Size.y))
|
||||
|
@ -278,7 +277,7 @@ protected:
|
|||
uint8_t bMasked = true; // Texture (might) have holes
|
||||
int8_t bTranslucent = -1; // Does this texture have an active alpha channel?
|
||||
bool skyColorDone = false;
|
||||
uint8_t PicSize; // A special piece of Build weirdness.
|
||||
uint8_t PicSize = 0; // A special piece of Build weirdness.
|
||||
UseType useType = Image;
|
||||
PalEntry FloorSkyColor;
|
||||
PalEntry CeilingSkyColor;
|
||||
|
@ -507,10 +506,11 @@ struct BuildFiles
|
|||
{
|
||||
return ArtFiles.FindEx([filename](const BuildArtFile* element) { return filename.CompareNoCase(element->filename) == 0; });
|
||||
}
|
||||
void LoadArtFile(const char* file, bool mapart = false, int firsttile = -1);
|
||||
int LoadArtFile(const char* file, bool mapart = false, int firsttile = -1);
|
||||
void CloseAllMapArt();
|
||||
void LoadArtSet(const char* filename);
|
||||
FTexture* ValidateCustomTile(int tilenum, int type);
|
||||
int32_t artLoadFiles(const char* filename);
|
||||
uint8_t *tileMakeWritable(int num);
|
||||
uint8_t *tileCreate(int tilenum, int width, int height);
|
||||
void tileSetExternal(int tilenum, int width, int height, uint8_t* data);
|
||||
|
|
|
@ -2458,8 +2458,6 @@ DETONATE:
|
|||
g_curViewscreen = -1;
|
||||
sprite[spriteNum].yvel = 0; // VIEWSCREEN_YVEL
|
||||
T1(spriteNum) = 0;
|
||||
|
||||
for (bssize_t ii = 0; ii < VIEWSCREENFACTOR; ii++) walock[TILE_VIEWSCR - ii] = 199;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -6115,7 +6115,7 @@ static void G_Startup(void)
|
|||
if (numplayers > 1)
|
||||
initprintf("Multiplayer initialized.\n");
|
||||
|
||||
if (artLoadFiles("tiles%03i.art",MAXCACHE1DSIZE) < 0)
|
||||
if (TileFiles.artLoadFiles("tiles%03i.art") < 0)
|
||||
G_GameExit("Failed loading art.");
|
||||
|
||||
cacheAllSounds();
|
||||
|
|
|
@ -7014,7 +7014,6 @@ void M_DisplayMenus(void)
|
|||
|
||||
if ((g_player[myconnectindex].ps->gm&MODE_MENU) == 0)
|
||||
{
|
||||
walock[TILE_LOADSHOT] = 1;
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -2217,8 +2217,6 @@ DETONATE:
|
|||
g_curViewscreen = -1;
|
||||
sprite[spriteNum].yvel = 0; // VIEWSCREEN_YVEL
|
||||
T1(spriteNum) = 0;
|
||||
|
||||
for (bssize_t ii = 0; ii < VIEWSCREENFACTOR; ii++) walock[TILE_VIEWSCR - ii] = 199;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -7518,7 +7518,7 @@ static void G_Startup(void)
|
|||
if (numplayers > 1)
|
||||
initprintf("Multiplayer initialized.\n");
|
||||
|
||||
if (artLoadFiles("tiles%03i.art",MAXCACHE1DSIZE) < 0)
|
||||
if (TileFiles.artLoadFiles("tiles%03i.art") < 0)
|
||||
G_GameExit("Failed loading art.");
|
||||
|
||||
// Make the fullscreen nuke logo background non-fullbright. Has to be
|
||||
|
|
|
@ -734,7 +734,7 @@ LoadImages(const char *filename)
|
|||
short ndx;
|
||||
FILE *fin;
|
||||
|
||||
if (artLoadFiles(filename, 32*1048576) == -1)
|
||||
if (TileFiles.LoadArtFile(filename) == -1)
|
||||
{
|
||||
TerminateGame();
|
||||
#ifdef RENDERTYPEWIN
|
||||
|
|
Loading…
Reference in a new issue