diff --git a/source/blood/src/blood.cpp b/source/blood/src/blood.cpp index 826286614..f900b7a80 100644 --- a/source/blood/src/blood.cpp +++ b/source/blood/src/blood.cpp @@ -390,49 +390,6 @@ void PreloadTiles(void) G_HandleAsync(); } -#ifdef USE_OPENGL -void PrecacheExtraTextureMaps(int nTile) -{ - // PRECACHE - if (useprecache && bpp > 8) - { - for (int type = 0; type < 2 && !KB_KeyPressed(sc_Space); type++) - { - if (TestBitString(precachehightile[type], nTile)) - { - for (int k = 0; k < MAXPALOOKUPS - RESERVEDPALS && !KB_KeyPressed(sc_Space); k++) - { - // this is the CROSSHAIR_PAL, see screens.cpp - if (k == MAXPALOOKUPS - RESERVEDPALS - 1) - break; -#ifdef POLYMER - if (videoGetRenderMode() != REND_POLYMER || !polymer_havehighpalookup(0, k)) -#endif - polymost_precache(nTile, k, type); - } - -#ifdef USE_GLEXT - if (r_detailmapping) - polymost_precache(nTile, DETAILPAL, type); - - if (r_glowmapping) - polymost_precache(nTile, GLOWPAL, type); -#endif -#ifdef POLYMER - if (videoGetRenderMode() == REND_POLYMER) - { - if (pr_specularmapping) - polymost_precache(nTile, SPECULARPAL, type); - - if (pr_normalmapping) - polymost_precache(nTile, NORMALPAL, type); - } -#endif - } - } - } -} -#endif void PreloadCache(void) { @@ -454,10 +411,12 @@ void PreloadCache(void) { if (TestBitString(gotpic, i)) { - tileCache(i); + // For the hardware renderer precaching the raw pixel data is pointless. + if (videoGetRenderMode() < REND_POLYMOST) + tileLoad(i); #ifdef USE_OPENGL - PrecacheExtraTextureMaps(i); + if (useprecache) PrecacheHardwareTextures(i); #endif MUSIC_Update(); @@ -1459,10 +1418,8 @@ void ParseOptions(void) { if (OptArgc < 1) ThrowError("Missing argument"); - uint32_t j = strtoul(OptArgv[0], NULL, 0); - MAXCACHE1DSIZE = j<<10; - initprintf("Cache size: %dkB\n", j); - break; + // No longer supported. + break; } case 35: if (OptArgc < 1) @@ -2168,9 +2125,6 @@ static int parsedefinitions_game(scriptfile *pScript, int firstPass) if (scriptfile_getnumber(pScript, &cacheSize) || !firstPass) break; - - if (cacheSize > 0) - MAXCACHE1DSIZE = cacheSize << 10; } break; case T_INCLUDE: @@ -2596,39 +2550,13 @@ void ScanINIFiles(void) } } -bool LoadArtFile(const char *pzFile) -{ - int hFile = kopen4loadfrommod(pzFile, 0); - if (hFile == -1) - { - initprintf("Can't open extra art file:\"%s\"\n", pzFile); - return false; - } - artheader_t artheader; - int nStatus = artReadHeader(hFile, pzFile, &artheader); - if (nStatus != 0) - { - kclose(hFile); - initprintf("Error reading extra art file:\"%s\"\n", pzFile); - return false; - } - for (int i = artheader.tilestart; i <= artheader.tileend; i++) - tileDelete(i); - artReadManifest(hFile, &artheader); - artPreloadFile(hFile, &artheader); - for (int i = artheader.tilestart; i <= artheader.tileend; i++) - tileUpdatePicSiz(i); - kclose(hFile); - return true; -} - void LoadExtraArts(void) { if (!pINISelected->pDescription) return; for (int i = 0; i < pINISelected->pDescription->nArts; i++) { - LoadArtFile(pINISelected->pDescription->pzArts[i]); + TileFiles.LoadArtFile(pINISelected->pDescription->pzArts[i]); } } diff --git a/source/blood/src/blood.h b/source/blood/src/blood.h index 640b816f2..400ff52af 100644 --- a/source/blood/src/blood.h +++ b/source/blood/src/blood.h @@ -78,7 +78,6 @@ void PreloadCache(void); void StartLevel(GAMEOPTIONS *gameOptions); void ProcessFrame(void); void ScanINIFiles(void); -bool LoadArtFile(const char *pzFile); void LoadExtraArts(void); bool DemoRecordStatus(void); bool VanillaMode(void); diff --git a/source/blood/src/common_game.h b/source/blood/src/common_game.h index 55cc0a6e0..6a08378e3 100644 --- a/source/blood/src/common_game.h +++ b/source/blood/src/common_game.h @@ -723,22 +723,22 @@ inline int QRandom2(int a1) template inline void SetBitString(T *pArray, int nIndex) { - static_assert(sizeof(T) == 1, ""); + static_assert(sizeof(T) == 1, "Bit array element too large"); pArray[nIndex>>3] |= 1<<(nIndex&7); } template inline void ClearBitString(T *pArray, int nIndex) { - static_assert(sizeof(T) == 1, ""); + static_assert(sizeof(T) == 1, "Bit array element too large"); pArray[nIndex >> 3] &= ~(1 << (nIndex & 7)); } template inline char TestBitString(T *pArray, int nIndex) { - static_assert(sizeof(T) == 1, ""); - return pArray[nIndex>>3] & (1<<(nIndex&7)); + static_assert(sizeof(T) == 1, "Bit array element too large"); + return pArray[nIndex>>3] & (1<<(nIndex&7)); } // This is to override the namepace prioritization without altering the actual calls. diff --git a/source/blood/src/config.cpp b/source/blood/src/config.cpp index 89929230c..c1a4b1f20 100644 --- a/source/blood/src/config.cpp +++ b/source/blood/src/config.cpp @@ -724,12 +724,6 @@ int CONFIG_ReadSetup(void) SCRIPT_GetNumber(scripthandle, "Setup", "ForceSetup", &gSetup.forcesetup); SCRIPT_GetNumber(scripthandle, "Setup", "NoAutoLoad", &gSetup.noautoload); - int32_t cachesize; - SCRIPT_GetNumber(scripthandle, "Setup", "CacheSize", &cachesize); - - if (cachesize > MAXCACHE1DSIZE) - MAXCACHE1DSIZE = cachesize; - if (gNoSetup == 0 && g_modDir[0] == '/') { struct Bstat st; @@ -846,7 +840,6 @@ void CONFIG_WriteSetup(uint32_t flags) //SCRIPT_PutNumber(scripthandle, "Misc", "Executions", ud.executions, FALSE, FALSE); - SCRIPT_PutNumber(scripthandle, "Setup", "CacheSize", MAXCACHE1DSIZE, FALSE, FALSE); SCRIPT_PutNumber(scripthandle, "Setup", "ConfigVersion", BYTEVERSION, FALSE, FALSE); SCRIPT_PutNumber(scripthandle, "Setup", "ForceSetup", gSetup.forcesetup, FALSE, FALSE); SCRIPT_PutNumber(scripthandle, "Setup", "NoAutoLoad", gSetup.noautoload, FALSE, FALSE); diff --git a/source/blood/src/fire.cpp b/source/blood/src/fire.cpp index edaa5f8f1..60f0690a1 100644 --- a/source/blood/src/fire.cpp +++ b/source/blood/src/fire.cpp @@ -67,10 +67,8 @@ void DoFireFrame(void) { memcpy(FrameBuffer+16896+i*128, SeedBuffer[nRand], 128); } - CellularFrame(FrameBuffer, 128, 132); - tileLoadTile(2342); - tileMakeWritable(2342); - auto pData = tileData(2342); + CellularFrame(FrameBuffer, 128, 132); + auto pData = TileFiles.tileMakeWritable(2342); char *pSource = FrameBuffer; int x = fireSize; do diff --git a/source/blood/src/tile.cpp b/source/blood/src/tile.cpp index c3605f086..dbba5c6b7 100644 --- a/source/blood/src/tile.cpp +++ b/source/blood/src/tile.cpp @@ -79,8 +79,6 @@ short voxelIndex[kMaxTiles]; const char *pzBaseFileName = "TILES%03i.ART"; //"TILES%03i.ART"; -int32_t MAXCACHE1DSIZE = (96*1024*1024); - int tileInit(char a1, const char *a2) { UNREFERENCED_PARAMETER(a1); diff --git a/source/blood/src/tile.h b/source/blood/src/tile.h index 667c2c4c3..51c24dc60 100644 --- a/source/blood/src/tile.h +++ b/source/blood/src/tile.h @@ -53,8 +53,6 @@ extern short voxelIndex[kMaxTiles]; extern int nPrecacheCount; extern char precachehightile[2][(MAXTILES+7)>>3]; -extern int32_t MAXCACHE1DSIZE; - void qloadvoxel(int32_t nVoxel); int tileInit(char a1, const char *a2); #ifdef USE_OPENGL diff --git a/source/blood/src/view.cpp b/source/blood/src/view.cpp index 2d8ee18a8..af09fa6e1 100644 --- a/source/blood/src/view.cpp +++ b/source/blood/src/view.cpp @@ -3688,13 +3688,8 @@ void viewSetCrosshairColor(int32_t r, int32_t g, int32_t b) CrosshairColors.g = g; CrosshairColors.b = b; - tileMakeWritable(kCrosshairTile); - tileLoad(kCrosshairTile); - - if (!tilePtr(kCrosshairTile)) - return; - - auto ptr = tileData(kCrosshairTile); + auto ptr = TileFiles.tileMakeWritable(kCrosshairTile); + if (!ptr) return; int32_t ii = tilesiz[kCrosshairTile].x * tilesiz[kCrosshairTile].y; diff --git a/source/build/include/build.h b/source/build/include/build.h index a722880ef..e9657f971 100644 --- a/source/build/include/build.h +++ b/source/build/include/build.h @@ -1058,7 +1058,6 @@ 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); @@ -1325,6 +1324,7 @@ void polymostSet2dView(void); // sets up GL for 2D drawing void polymost_glreset(void); void polymost_precache(int32_t dapicnum, int32_t dapalnum, int32_t datype); +void PrecacheHardwareTextures(int nTile); typedef uint16_t polytintflags_t; diff --git a/source/build/src/polymost.cpp b/source/build/src/polymost.cpp index 43c7abaec..f8198f836 100644 --- a/source/build/src/polymost.cpp +++ b/source/build/src/polymost.cpp @@ -819,6 +819,8 @@ static void polymost_drawpoly(vec2f_t const * const dpxy, int32_t const n, int32 if (method & DAMETH_MASKPROPS) { + // Fixme: Alpha test on shaders must be done differently. + // Also: Consider a texture's alpha threshold. float const al = alphahackarray[globalpicnum] != 0 ? alphahackarray[globalpicnum] * (1.f/255.f) : (pth->hicr && pth->hicr->alphacut >= 0.f ? pth->hicr->alphacut : 0.f); @@ -5772,3 +5774,17 @@ void polymost_precache(int32_t dapicnum, int32_t dapalnum, int32_t datype) mdloadskin((md2model_t *)models[mid], 0, dapalnum, i); } +void PrecacheHardwareTextures(int nTile) +{ + // PRECACHE + // This really *really* needs improvement on the game side - the entire precaching logic has no clue about the different needs of a hardware renderer. + + polymost_precache(nTile, 0, 1); + + if (r_detailmapping) + polymost_precache(nTile, DETAILPAL, 1); + + if (r_glowmapping) + polymost_precache(nTile, GLOWPAL, 1); + +} diff --git a/source/build/src/tiles.cpp b/source/build/src/tiles.cpp index 60de98bae..fd569bde4 100644 --- a/source/build/src/tiles.cpp +++ b/source/build/src/tiles.cpp @@ -619,17 +619,12 @@ const uint8_t* tilePtr(int num) } uint8_t* tileData(int num) { - // Q: Should this automatically make the tile writable? + auto tex = TileFiles.tiles[num]; + assert(tex); + if (tex->GetWritableBuffer()) return tex->GetWritableBuffer(); return tiledata[num]; } -void tileMakeWritable(int num) -{ - // This won't be so simple anymore with a real texture manager backing this. - tiledata[num] = TileFiles.tileMakeWritable(num); - tilesizearray[num] = TileFiles.tiles[num]->GetSize(); -} - // // loadtile // diff --git a/source/common/textures/textures.h b/source/common/textures/textures.h index 6df32a70d..e35fc141f 100644 --- a/source/common/textures/textures.h +++ b/source/common/textures/textures.h @@ -72,7 +72,7 @@ enum ECreateTexBufferFlags enum { - //MAXCACHE1DSIZE = (50 * 1024 * 1024), + MAXCACHE1DSIZE = (50 * 1024 * 1024), MAXTILES = 30720, MAXUSERTILES = (MAXTILES-16) // reserve 16 tiles at the end diff --git a/source/duke3d/src/anim.cpp b/source/duke3d/src/anim.cpp index b92b95b5c..4b6b7a1f9 100644 --- a/source/duke3d/src/anim.cpp +++ b/source/duke3d/src/anim.cpp @@ -430,6 +430,7 @@ int32_t Anim_Play(const char *fn) return 0; int32_t length = kfilelength(handle); + TArray buffer(length + 1, true); if (length <= 4) { @@ -438,9 +439,7 @@ int32_t Anim_Play(const char *fn) } anim->animlock = 255; - - if (!anim->animbuf) - cacheAllocateBlock((intptr_t *)&anim->animbuf, length + 1, &anim->animlock); + anim->animbuf = buffer.Data(); kread(handle, anim->animbuf, length); kclose(handle); @@ -572,6 +571,7 @@ end_anim_restore_gl: #endif end_anim: I_ClearAllInput(); + anim->animbuf = nullptr; ANIM_FreeAnim(); tileDelete(TILE_ANIM); diff --git a/source/duke3d/src/cmdline.cpp b/source/duke3d/src/cmdline.cpp index b3f7ef9ac..afd13125e 100644 --- a/source/duke3d/src/cmdline.cpp +++ b/source/duke3d/src/cmdline.cpp @@ -523,10 +523,8 @@ void G_CheckCommandLine(int32_t argc, char const * const * argv) { if (argc > i+1) { - uint32_t j = Batol(argv[i+1]); - MAXCACHE1DSIZE = j<<10; - initprintf("Cache size: %dkB\n", j); i++; + // No longer supported. } i++; continue; diff --git a/source/duke3d/src/config.cpp b/source/duke3d/src/config.cpp index 33ba88eb3..55a5c563c 100644 --- a/source/duke3d/src/config.cpp +++ b/source/duke3d/src/config.cpp @@ -833,12 +833,6 @@ int CONFIG_ReadSetup(void) SCRIPT_GetNumber(ud.config.scripthandle, "Setup", "ForceSetup", &ud.setup.forcesetup); SCRIPT_GetNumber(ud.config.scripthandle, "Setup", "NoAutoLoad", &ud.setup.noautoload); - int32_t cachesize; - SCRIPT_GetNumber(ud.config.scripthandle, "Setup", "CacheSize", &cachesize); - - if (cachesize > MAXCACHE1DSIZE) - MAXCACHE1DSIZE = cachesize; - if (g_noSetup == 0 && g_modDir[0] == '/') { SCRIPT_GetString(ud.config.scripthandle, "Setup","ModDir",&g_modDir[0]); @@ -968,7 +962,6 @@ void CONFIG_WriteSetup(uint32_t flags) SCRIPT_PutNumber(ud.config.scripthandle, "Misc", "Executions", ud.executions, FALSE, FALSE); - SCRIPT_PutNumber(ud.config.scripthandle, "Setup", "CacheSize", MAXCACHE1DSIZE, FALSE, FALSE); SCRIPT_PutNumber(ud.config.scripthandle, "Setup", "ConfigVersion", BYTEVERSION_EDUKE32, FALSE, FALSE); SCRIPT_PutNumber(ud.config.scripthandle, "Setup", "ForceSetup", ud.setup.forcesetup, FALSE, FALSE); SCRIPT_PutNumber(ud.config.scripthandle, "Setup", "NoAutoLoad", ud.setup.noautoload, FALSE, FALSE); diff --git a/source/duke3d/src/game.cpp b/source/duke3d/src/game.cpp index 0b6530f05..366529315 100644 --- a/source/duke3d/src/game.cpp +++ b/source/duke3d/src/game.cpp @@ -98,15 +98,6 @@ static const char *defaultrtsfilename[GAMECOUNT] = { "DUKE.RTS", "NAM.RTS", "NAP int32_t g_Shareware = 0; -// This was 32 for a while, but I think lowering it to 24 will help things like the Dingoo. -// Ideally, we would look at our memory usage on our most cramped platform and figure out -// how much of that is needed for the underlying OS and things like SDL instead of guessing -#ifndef GEKKO -int32_t MAXCACHE1DSIZE = (96*1024*1024); -#else -int32_t MAXCACHE1DSIZE = (8*1024*1024); -#endif - int32_t tempwallptr; static int32_t nonsharedtimer; @@ -1106,7 +1097,6 @@ void G_DrawRooms(int32_t playerNum, int32_t smoothRatio) if (videoGetRenderMode() == REND_CLASSIC) { renderRestoreTarget(); -// walock[TILE_SAVESHOT] = 1; } #ifdef USE_OPENGL else @@ -1154,7 +1144,6 @@ void G_DrawRooms(int32_t playerNum, int32_t smoothRatio) tiltZoom >>= tiltcs; // JBF 20030807 rotatesprite_win(160 << 16, 100 << 16, tiltZoom, tang + 512, TILE_TILT, 0, 0, 4 + 2 + 64 + 1024); - walock[TILE_TILT] = 1; } } } @@ -5370,9 +5359,6 @@ static int parsedefinitions_game(scriptfile *pScript, int firstPass) if (scriptfile_getnumber(pScript, &cacheSize) || !firstPass) break; - - if (cacheSize > 0) - MAXCACHE1DSIZE = cacheSize << 10; } break; case T_INCLUDE: diff --git a/source/duke3d/src/game.h b/source/duke3d/src/game.h index 62f90867d..ed24c2c79 100644 --- a/source/duke3d/src/game.h +++ b/source/duke3d/src/game.h @@ -343,7 +343,6 @@ extern int32_t ticrandomseed; extern int32_t vote_map; extern int32_t voting; -extern int32_t MAXCACHE1DSIZE; //extern int8_t cheatbuf[MAXCHEATLEN],cheatbuflen; #define CROSSHAIR_PAL (MAXPALOOKUPS-RESERVEDPALS-1) diff --git a/source/duke3d/src/gamevars.h b/source/duke3d/src/gamevars.h index 8deb7adce..970eee591 100644 --- a/source/duke3d/src/gamevars.h +++ b/source/duke3d/src/gamevars.h @@ -89,10 +89,11 @@ enum GamearrayFlags_t GAMEARRAY_UINT8 = GAMEARRAY_INT8 | GAMEARRAY_UNSIGNED, GAMEARRAY_BITMAP = 0x00100000, GAMEARRAY_WARN = 0x00200000, + GAMEARRAY_FUNC = 0x00400000, GAMEARRAY_SIZE_MASK = GAMEARRAY_INT8 | GAMEARRAY_INT16 | GAMEARRAY_BITMAP, GAMEARRAY_STORAGE_MASK = GAMEARRAY_INT8 | GAMEARRAY_INT16 | GAMEARRAY_BITMAP | GAMEARRAY_STRIDE2, - GAMEARRAY_TYPE_MASK = GAMEARRAY_UNSIGNED | GAMEARRAY_INT8 | GAMEARRAY_INT16 | GAMEARRAY_BITMAP, + GAMEARRAY_TYPE_MASK = GAMEARRAY_UNSIGNED | GAMEARRAY_INT8 | GAMEARRAY_INT16 | GAMEARRAY_BITMAP | GAMEARRAY_FUNC, }; #pragma pack(push,1) diff --git a/source/duke3d/src/menus.cpp b/source/duke3d/src/menus.cpp index 04740bfa1..5c8170b60 100644 --- a/source/duke3d/src/menus.cpp +++ b/source/duke3d/src/menus.cpp @@ -4548,7 +4548,6 @@ void Menu_Close(uint8_t playerID) actor[g_curViewscreen].t_data[0] = (int32_t) totalclock; } - walock[TILE_SAVESHOT] = 1; G_UpdateScreenArea(); S_PauseSounds(false); } diff --git a/source/duke3d/src/premap.cpp b/source/duke3d/src/premap.cpp index 328e636c0..1d7fa3189 100644 --- a/source/duke3d/src/premap.cpp +++ b/source/duke3d/src/premap.cpp @@ -412,49 +412,7 @@ static void G_DoLoadScreen(const char *statustext, int percent) } } -#ifdef USE_OPENGL -static void cacheExtraTextureMaps(int tileNum) -{ - // PRECACHE - if (ud.config.useprecache && bpp > 8) - { - for (int type = 0; type < 2 && !KB_KeyPressed(sc_Space); type++) - { - if (precachehightile[type][tileNum >> 3] & pow2char[tileNum & 7]) - { - for (int k = 0; k < MAXPALOOKUPS - RESERVEDPALS && !KB_KeyPressed(sc_Space); k++) - { - // this is the CROSSHAIR_PAL, see screens.cpp - if (k == MAXPALOOKUPS - RESERVEDPALS - 1) - break; -#ifdef POLYMER - if (videoGetRenderMode() != REND_POLYMER || !polymer_havehighpalookup(0, k)) -#endif - polymost_precache(tileNum, k, type); - } -#ifdef USE_GLEXT - if (r_detailmapping) - polymost_precache(tileNum, DETAILPAL, type); - - if (r_glowmapping) - polymost_precache(tileNum, GLOWPAL, type); -#endif -#ifdef POLYMER - if (videoGetRenderMode() == REND_POLYMER) - { - if (pr_specularmapping) - polymost_precache(tileNum, SPECULARPAL, type); - - if (pr_normalmapping) - polymost_precache(tileNum, NORMALPAL, type); - } -#endif - } - } - } -} -#endif void G_CacheMapData(void) { @@ -505,10 +463,12 @@ void G_CacheMapData(void) else if ((gotpic[i>>3] & pow2char[i&7]) != pow2char[i&7]) continue; - tileCache(i); + // For the hardware renderer precaching the raw pixel data is pointless. + if (videoGetRenderMode() < REND_POLYMOST) + tileLoad(i); #ifdef USE_OPENGL - cacheExtraTextureMaps(i); + if (ud.config.useprecache) PrecacheHardwareTextures(i); #endif MUSIC_Update(); diff --git a/source/duke3d/src/screens.cpp b/source/duke3d/src/screens.cpp index 713fe6a9e..7dedd9792 100644 --- a/source/duke3d/src/screens.cpp +++ b/source/duke3d/src/screens.cpp @@ -134,10 +134,7 @@ void G_SetCrosshairColor(int32_t r, int32_t g, int32_t b) if (g_crosshairSum == r+(g<<8)+(b<<16)) return; - tileLoad(CROSSHAIR); - tileMakeWritable(CROSSHAIR); - - auto ptr = tileData(CROSSHAIR); + auto ptr = TileFiles.tileMakeWritable(CROSSHAIR); if (!ptr) return; if (!DefaultCrosshairColors.f) diff --git a/source/duke3d/src/sector.cpp b/source/duke3d/src/sector.cpp index 15274f3b0..e34a3af88 100644 --- a/source/duke3d/src/sector.cpp +++ b/source/duke3d/src/sector.cpp @@ -435,10 +435,8 @@ void G_AnimateCamSprite(int smoothRatio) int const viewscrShift = G_GetViewscreenSizeShift((uspriteptr_t)&sprite[spriteNum]); int const viewscrTile = TILE_VIEWSCR - viewscrShift; - if (tileData(viewscrTile) == 0) + if (tileData(viewscrTile) ==nullptr) tileCreate(viewscrTile, tilesiz[PN(spriteNum)].x << viewscrShift, tilesiz[PN(spriteNum)].y << viewscrShift); - else - walock[viewscrTile] = 199; G_SetupCamTile(OW(spriteNum), viewscrTile, smoothRatio); #ifdef POLYMER diff --git a/source/rr/src/actors.cpp b/source/rr/src/actors.cpp index c2f71d596..12e7bbc5b 100644 --- a/source/rr/src/actors.cpp +++ b/source/rr/src/actors.cpp @@ -3694,7 +3694,7 @@ ACTOR_STATIC int A_CheckPins(int16_t const sectNum) if (tag != 0) { int const tileNumber = LANEPICS + tag + 1; - tileMakeWritable(tileNumber); + TileFiles.tileMakeWritable(tileNumber); tileCopySection(LANEPICS+1, 0, 0, 128, 64, tileNumber, 0, 0); for (int pin = 0; pin < 10; pin++) @@ -3787,7 +3787,7 @@ ACTOR_STATIC void A_ResetPins(int16_t sect) if (tag != 0) { int const tileNumber = LANEPICS + tag + 1; - tileMakeWritable(tileNumber); + TileFiles.tileMakeWritable(tileNumber); tileCopySection(LANEPICS+1, 0, 0, 128, 64, tileNumber, 0, 0); for (int pin = 0; pin < 10; pin++) @@ -3846,7 +3846,7 @@ void A_ResetLanePics(void) for (int tag = 1; tag <= 4; tag++) { int const tileNumber = LANEPICS + tag + 1; - tileMakeWritable(tileNumber); + TileFiles.tileMakeWritable(tileNumber); tileCopySection(LANEPICS + 1, 0, 0, 128, 64, tileNumber, 0, 0); for (int pin = 0; pin < 10; pin++) diff --git a/source/rr/src/anim.cpp b/source/rr/src/anim.cpp index 8c3540cfa..4ec98daf7 100644 --- a/source/rr/src/anim.cpp +++ b/source/rr/src/anim.cpp @@ -460,6 +460,7 @@ int32_t Anim_Play(const char *fn) return 0; int32_t length = kfilelength(handle); + TArray buffer(length + 1, true); if (length <= 4) { @@ -467,10 +468,7 @@ int32_t Anim_Play(const char *fn) goto end_anim; } - anim->animlock = 1; - - if (!anim->animbuf) - cacheAllocateBlock((intptr_t *)&anim->animbuf, length + 1, &anim->animlock); + anim->animbuf = buffer.Data(); tileCreate(TILE_ANIM, 200, 320); @@ -592,10 +590,9 @@ end_anim_restore_gl: #endif end_anim: I_ClearAllInput(); + anim->animbuf = nullptr; ANIM_FreeAnim(); tileDelete(TILE_ANIM); - walock[TILE_ANIM] = 1; - anim->animlock = 0; return !running; } diff --git a/source/rr/src/cmdline.cpp b/source/rr/src/cmdline.cpp index 86f3fac07..31f7ce3d0 100644 --- a/source/rr/src/cmdline.cpp +++ b/source/rr/src/cmdline.cpp @@ -500,10 +500,8 @@ void G_CheckCommandLine(int32_t argc, char const * const * argv) { if (argc > i+1) { - uint32_t j = Batol(argv[i+1]); - MAXCACHE1DSIZE = j<<10; - initprintf("Cache size: %dkB\n", j); - i++; + // No longer supported. + i++; } i++; continue; diff --git a/source/rr/src/config.cpp b/source/rr/src/config.cpp index 7ce12dbbe..fd8804f22 100644 --- a/source/rr/src/config.cpp +++ b/source/rr/src/config.cpp @@ -678,9 +678,6 @@ int32_t CONFIG_ReadSetup(void) SCRIPT_GetNumber(ud.config.scripthandle, "Setup", "NoAutoLoad", &ud.setup.noautoload); SCRIPT_GetNumber(ud.config.scripthandle, "Setup", "CacheSize", &dummy); - if (dummy > MAXCACHE1DSIZE) - MAXCACHE1DSIZE = dummy; - if (g_noSetup == 0 && g_modDir[0] == '/') { struct Bstat st; diff --git a/source/rr/src/game.cpp b/source/rr/src/game.cpp index 4bcd5a958..5ca8dad40 100644 --- a/source/rr/src/game.cpp +++ b/source/rr/src/game.cpp @@ -90,15 +90,6 @@ const char *defaultrtsfilename[GAMECOUNT] = { "DUKE.RTS", "REDNECK.RTS", "REDNEC int32_t g_Shareware = 0; -// This was 32 for a while, but I think lowering it to 24 will help things like the Dingoo. -// Ideally, we would look at our memory usage on our most cramped platform and figure out -// how much of that is needed for the underlying OS and things like SDL instead of guessing -#ifndef GEKKO -int32_t MAXCACHE1DSIZE = (96*1024*1024); -#else -int32_t MAXCACHE1DSIZE = (8*1024*1024); -#endif - int32_t tempwallptr; static int32_t nonsharedtimer; @@ -1488,7 +1479,6 @@ void G_DrawRooms(int32_t playerNum, int32_t smoothRatio) if (videoGetRenderMode() == REND_CLASSIC) { renderRestoreTarget(); -// walock[TILE_SAVESHOT] = 1; } #ifdef USE_OPENGL else @@ -1536,7 +1526,6 @@ void G_DrawRooms(int32_t playerNum, int32_t smoothRatio) tiltZoom >>= tiltcs; // JBF 20030807 rotatesprite_win(160 << 16, 100 << 16, tiltZoom, tang + 512, TILE_TILT, 0, 0, 4 + 2 + 64 + 1024); - walock[TILE_TILT] = 199; } } } @@ -5052,7 +5041,7 @@ default_case1: t->xrepeat += 10; t->yrepeat += 9; } - else if (g_curViewscreen == i && display_mirror != 3 && tileData(viewscrTile) && walock[viewscrTile] > 200) + else if (g_curViewscreen == i && display_mirror != 3 && tileData(viewscrTile)) { // this exposes a sprite sorting issue which needs to be debugged further... #if 0 @@ -6866,9 +6855,6 @@ static int parsedefinitions_game(scriptfile *pScript, int firstPass) if (scriptfile_getnumber(pScript, &cacheSize) || !firstPass) break; - - if (cacheSize > 0) - MAXCACHE1DSIZE = cacheSize << 10; } break; case T_INCLUDE: diff --git a/source/rr/src/game.h b/source/rr/src/game.h index 2ef6d5033..1b323a8c0 100644 --- a/source/rr/src/game.h +++ b/source/rr/src/game.h @@ -306,7 +306,6 @@ extern int32_t ticrandomseed; extern int32_t vote_map; extern int32_t voting; -extern int32_t MAXCACHE1DSIZE; //extern int8_t cheatbuf[MAXCHEATLEN],cheatbuflen; #define CROSSHAIR_PAL (MAXPALOOKUPS-RESERVEDPALS-1) diff --git a/source/rr/src/menus.cpp b/source/rr/src/menus.cpp index a3822c171..cfd0d7dc2 100644 --- a/source/rr/src/menus.cpp +++ b/source/rr/src/menus.cpp @@ -4870,7 +4870,6 @@ void Menu_Close(uint8_t playerID) actor[g_curViewscreen].t_data[0] = (int32_t) totalclock; } - walock[TILE_SAVESHOT] = 199; G_UpdateScreenArea(); if (!ud.pause_on) @@ -7604,7 +7603,6 @@ void M_DisplayMenus(void) if ((g_player[myconnectindex].ps->gm&MODE_MENU) == 0) { - walock[TILE_LOADSHOT] = 1; return; } diff --git a/source/rr/src/premap.cpp b/source/rr/src/premap.cpp index d502a2931..8fa56e2b7 100644 --- a/source/rr/src/premap.cpp +++ b/source/rr/src/premap.cpp @@ -615,48 +615,14 @@ void G_CacheMapData(void) } if (gotpic[i>>3] & pow2char[i&7]) { - tileCache(i); + // For the hardware renderer precaching the raw pixel data is pointless. + if (videoGetRenderMode() < REND_POLYMOST) + tileLoad(i); #ifdef USE_OPENGL -// PRECACHE - if (ud.config.useprecache && bpp > 8) - { - int32_t k,type; - - for (type=0; type<=1; type++) - if (precachehightile[type][i>>3] & pow2char[i&7]) - { - k = 0; - for (k=0; k buffer; const char *ANIMname[] = { @@ -238,8 +239,7 @@ unsigned char *LoadAnm(short anim_num) ANIMnum = anim_num; // lock it - walock[ANIM_TILE(ANIMnum)] = 219; - + if (anm_ptr[anim_num] == 0) { handle = kopen4load(ANIMname[ANIMnum], 0); @@ -247,7 +247,8 @@ unsigned char *LoadAnm(short anim_num) return NULL; length = kfilelength(handle); - cacheAllocateBlock((intptr_t *) &anm_ptr[anim_num], length + sizeof(anim_t), &walock[ANIM_TILE(ANIMnum)]); + buffer.Resize(length + sizeof(anim_t)); + anm_ptr[anim_num] = (anim_t*)buffer.Data(); animbuf = (unsigned char *)((intptr_t)anm_ptr[anim_num] + sizeof(anim_t)); kread(handle, animbuf, length); @@ -387,6 +388,5 @@ ENDOFANIMLOOP: KB_FlushKeyboardQueue(); KB_ClearKeysDown(); ANIM_FreeAnim(); - walock[ANIM_TILE(ANIMnum)] = 1; } END_SW_NS diff --git a/source/sw/src/cache.cpp b/source/sw/src/cache.cpp index cf0dadc7b..f8ff86f4f 100644 --- a/source/sw/src/cache.cpp +++ b/source/sw/src/cache.cpp @@ -633,8 +633,14 @@ void DoTheCache(void) { if ((TEST(gotpic[i>>3], 1<<(i&7))) && (!tilePtr(i))) { - tileLoad(i); - cnt++; + // For the hardware renderer precaching the raw pixel data is pointless. + if (videoGetRenderMode() < REND_POLYMOST) + tileLoad(i); +#ifdef USE_OPENGL + /*if (useprecache)*/ PrecacheHardwareTextures(i); +#endif + + cnt++; if (!(cnt&7)) { AnimateCacheCursor(); diff --git a/source/sw/src/draw.cpp b/source/sw/src/draw.cpp index 8b10d8f12..3260c6241 100644 --- a/source/sw/src/draw.cpp +++ b/source/sw/src/draw.cpp @@ -2676,12 +2676,10 @@ DrawCompass(PLAYERp pp) void ScreenTileLock(void) { - walock[SAVE_SCREEN_TILE] = CACHE_LOCK_MAX; } void ScreenTileUnLock(void) { - walock[SAVE_SCREEN_TILE] = CACHE_UNLOCK_MAX; } int diff --git a/source/sw/src/game.cpp b/source/sw/src/game.cpp index 62311e6f3..4a9815161 100644 --- a/source/sw/src/game.cpp +++ b/source/sw/src/game.cpp @@ -5833,9 +5833,6 @@ SHOWSPRITE: } -extern int tilefileoffs[MAXTILES]; //offset into the -extern char tilefilenum[MAXTILES]; //0-11 - #if RANDOM_DEBUG int diff --git a/source/sw/src/save.cpp b/source/sw/src/save.cpp index 72067ed69..5ab20bc4c 100644 --- a/source/sw/src/save.cpp +++ b/source/sw/src/save.cpp @@ -666,7 +666,10 @@ int SaveGame(short save_num) MWRITE(palette,sizeof(palette),1,fil); MWRITE(palette_data,sizeof(palette_data),1,fil); MWRITE(&gs,sizeof(gs),1,fil); - MWRITE(picanm,sizeof(picanm),1,fil); + for (int i = 0; i < MAXTILES; i++) + { + MWRITE(&picanm[i], sizeof(picanm[i]), 1, fil); + } MWRITE(&LevelSecrets,sizeof(LevelSecrets),1,fil); @@ -1182,7 +1185,10 @@ int LoadGame(short save_num) //COVERsetbrightness(gs.Brightness,(char *)palette_data); - MREAD(picanm,sizeof(picanm),1,fil); + for (int i = 0; i < MAXTILES; i++) + { + MREAD(&picanm[i], sizeof(picanm[i]), 1, fil); + } MREAD(&LevelSecrets,sizeof(LevelSecrets),1,fil);