Commit 2b143233 authored by Jordon Moss's avatar Jordon Moss
Browse files

Merge branch 'master' into oldmp_porting

parents 63ccbfe8 6ae3c831
......@@ -10,9 +10,9 @@ AllowAllParametersOfDeclarationOnNextLine: true
AllowShortBlocksOnASingleLine: true
AllowShortCaseLabelsOnASingleLine: true
AllowShortFunctionsOnASingleLine: false
AllowShortIfStatementsOnASingleLine: false
AllowShortIfStatementsOnASingleLine: false
AllowShortLambdasOnASingleLine: false
AllowShortLoopsOnASingleLine: false
AllowShortLoopsOnASingleLine: true
AlwaysBreakBeforeMultilineStrings: false
AlwaysBreakTemplateDeclarations: false
BinPackArguments: true
......@@ -40,7 +40,10 @@ MaxEmptyLinesToKeep: 2
NamespaceIndentation: None
PointerAlignment: Right
PointerBindsToType: false
# I'd like to set this but it's too slow for daily use...
# QualifierAlignment: Right
ReflowComments: false
RemoveBracesLLVM: true
SortIncludes: true
SortUsingDeclarations: true
SpaceAfterCStyleCast: false
......
......@@ -222,19 +222,17 @@ uint32_t constexpr FMT_WAVE_MAGIC = FMT_MAGIC('W','A','V','E');
static wavefmt_t FX_ReadFmt(char const * const ptr, uint32_t length)
{
if (length < 12)
if (length < 16)
return FMT_UNKNOWN;
auto const ptr32 = (uint32_t const *)ptr;
switch (B_LITTLE32(*ptr32))
switch (B_LITTLE32(*(uint32_t const *)ptr))
{
case FMT_OGG_MAGIC: return FMT_VORBIS;
case FMT_VOC_MAGIC: return FMT_VOC;
case FMT_FLAC_MAGIC: return FMT_FLAC;
case FMT_RIFF_MAGIC:
if (B_LITTLE32(ptr32[2]) == FMT_WAVE_MAGIC) return FMT_WAV;
if (B_LITTLE32(ptr32[2]) == FMT_CDXA_MAGIC) return FMT_XA;
if (B_LITTLE32(((uint32_t const *)ptr)[2]) == FMT_WAVE_MAGIC) return FMT_WAV;
if (B_LITTLE32(((uint32_t const *)ptr)[2]) == FMT_CDXA_MAGIC) return FMT_XA;
break;
default:
if (MV_IdentifyXMP(ptr, length)) return FMT_XMP;
......@@ -256,7 +254,7 @@ int FX_Play(char *ptr, uint32_t ptrlength, int loopstart, int loopend, int pitch
int handle = func[FX_ReadFmt(ptr, ptrlength)](ptr, ptrlength, loopstart, loopend, pitchoffset, vol, left, right, priority, volume, callbackval);
if (handle <= MV_Ok)
if (EDUKE32_PREDICT_FALSE(handle <= MV_Ok))
{
FX_SetErrorCode(FX_MultiVocError);
handle = FX_Warning;
......@@ -274,7 +272,7 @@ int FX_Play3D(char *ptr, uint32_t ptrlength, int loophow, int pitchoffset, int a
int handle = func[FX_ReadFmt(ptr, ptrlength)](ptr, ptrlength, loophow, pitchoffset, angle, distance, priority, volume, callbackval);
if (handle <= MV_Ok)
if (EDUKE32_PREDICT_FALSE(handle <= MV_Ok))
{
FX_SetErrorCode(FX_MultiVocError);
handle = FX_Warning;
......@@ -288,7 +286,7 @@ int FX_PlayRaw(char *ptr, uint32_t ptrlength, int rate, int pitchoffset, int vol
{
int handle = MV_PlayRAW(ptr, ptrlength, rate, NULL, NULL, pitchoffset, vol, left, right, priority, volume, callbackval);
if (handle <= MV_Ok)
if (EDUKE32_PREDICT_FALSE(handle <= MV_Ok))
{
FX_SetErrorCode(FX_MultiVocError);
handle = FX_Warning;
......@@ -302,7 +300,7 @@ int FX_PlayLoopedRaw(char *ptr, uint32_t ptrlength, char *loopstart, char *loope
{
int handle = MV_PlayRAW(ptr, ptrlength, rate, loopstart, loopend, pitchoffset, vol, left, right, priority, volume, callbackval);
if (handle <= MV_Ok)
if (EDUKE32_PREDICT_FALSE(handle <= MV_Ok))
{
FX_SetErrorCode(FX_MultiVocError);
handle = FX_Warning;
......@@ -317,7 +315,7 @@ int FX_StartDemandFeedPlayback(void (*function)(const char** ptr, uint32_t* leng
int handle = MV_StartDemandFeedPlayback(function, bitdepth, channels, rate,
pitchoffset, vol, left, right, priority, volume, callbackval, userdata);
if (handle <= MV_Ok)
if (EDUKE32_PREDICT_FALSE(handle <= MV_Ok))
{
FX_SetErrorCode(FX_MultiVocError);
handle = FX_Warning;
......@@ -332,7 +330,7 @@ int FX_StartDemandFeedPlayback3D(void (*function)(const char** ptr, uint32_t* le
int handle = MV_StartDemandFeedPlayback3D(function, bitdepth, channels, rate,
pitchoffset, angle, distance, priority, volume, callbackval, userdata);
if (handle <= MV_Ok)
if (EDUKE32_PREDICT_FALSE(handle <= MV_Ok))
{
FX_SetErrorCode(FX_MultiVocError);
handle = FX_Warning;
......
......@@ -33,7 +33,7 @@
#ifdef HAVE_VORBIS
#define BLOCKSIZE MV_MIXBUFFERSIZE
#define BLOCKSIZE 512
#define OGG_IMPL
#define VORBIS_IMPL
......@@ -94,23 +94,28 @@ static void MV_GetVorbisCommentLoops(VoiceNode *voice, vorbis_comment *vc)
}
}
}
auto vd = (vorbis_data *)voice->rawdataptr;
auto total = ov_pcm_total(&vd->vf, -1);
if (vc_loopstart != nullptr)
{
const ogg_int64_t ov_loopstart = Batol(vc_loopstart);
if (ov_loopstart >= 0) // a loop starting at 0 is valid
if ((unsigned)(ov_loopstart-1) <= total)
{
voice->Loop.Start = (const char *) (intptr_t) ov_loopstart;
voice->Loop.Size = 1;
}
else LOG_F(WARNING, "MV_GetVorbisCommentLoops: loop start is beyond end of data");
}
if (vc_loopend != nullptr)
{
if (voice->Loop.Size > 0)
{
const ogg_int64_t ov_loopend = Batol(vc_loopend);
if (ov_loopend > 0) // a loop ending at 0 is invalid
if ((unsigned)(ov_loopend-1) <= total)
voice->Loop.End = (const char *) (intptr_t) ov_loopend;
else LOG_F(WARNING, "MV_GetVorbisCommentLoops: loop end is beyond end of data");
}
}
if (vc_looplength != nullptr)
......@@ -120,6 +125,7 @@ static void MV_GetVorbisCommentLoops(VoiceNode *voice, vorbis_comment *vc)
const ogg_int64_t ov_looplength = Batol(vc_looplength);
if (ov_looplength > 0) // a loop of length 0 is invalid
voice->Loop.End = (const char *) ((intptr_t) ov_looplength + (intptr_t) voice->Loop.Start);
else LOG_F(WARNING, "MV_GetVorbisCommentLoops: loop length is zero");
}
}
}
......
......@@ -1001,6 +1001,15 @@ EXTERN char show2dsector[(MAXSECTORS+7)>>3];
EXTERN char show2dwall[(MAXWALLS+7)>>3];
EXTERN char show2dsprite[(MAXSPRITES+7)>>3];
struct classicht_t
{
intptr_t ptr;
vec2_16_t upscale;
char lock;
};
EXTERN classicht_t classicht[MAXTILES];
// 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
......@@ -1239,6 +1248,7 @@ void artClearMapArt(void);
void artSetupMapArt(const char *filename);
bool tileLoad(int16_t tilenume);
void tileLoadData(int16_t tilenume, int32_t dasiz, char *buffer);
intptr_t tileLoadScaled(int const picnum, vec2_16_t* upscale = nullptr);
int32_t tileGetCRC32(int16_t tileNum);
vec2_16_t tileGetSize(int16_t tileNum);
void artConvertRGB(palette_t *pic, uint8_t const *buf, int32_t bufsizx, int32_t sizx, int32_t sizy);
......
......@@ -52,7 +52,7 @@ private:
intptr_t m_baseAddress{};
int32_t m_totalSize{};
int32_t m_minBlockSize{};
int32_t m_alignment{};
int m_maxBlocks{};
int m_numBlocks{};
......
......@@ -90,6 +90,12 @@ typedef void (*gtk_container_set_border_width_ptr) (GtkContainer *container, gui
typedef GType (*gtk_dialog_get_type_ptr) (void) G_GNUC_CONST;
typedef gint (*gtk_dialog_run_ptr) (GtkDialog *dialog);
// gtkfixed.h
// TODO: Only needed to fix compilation for Kenbuild. Bring Kenbuild GTK window to parity with other windows, then remove this again.
typedef GType (*gtk_fixed_get_type_ptr) (void) G_GNUC_CONST;
typedef GtkWidget* (*gtk_fixed_new_ptr) (void);
typedef void (*gtk_fixed_put_ptr) (GtkFixed *fixed, GtkWidget *widget, gint x, gint y);
// gtkhbox.h
typedef GtkWidget* (*gtk_hbox_new_ptr) (gboolean homogeneous, gint spacing);
......@@ -223,6 +229,7 @@ typedef GtkWidget* (*gtk_widget_ref_ptr) (GtkWidget *widget);
typedef void (*gtk_widget_set_sensitive_ptr) (GtkWidget *widget, gboolean sensitive);
typedef void (*gtk_widget_set_size_request_ptr) (GtkWidget *widget, gint width, gint height);
typedef void (*gtk_widget_show_all_ptr) (GtkWidget *widget);
typedef void (*gtk_widget_show_ptr) (GtkWidget *widget);
typedef void (*gtk_widget_unref_ptr) (GtkWidget *widget);
// gtkwindow.h
......@@ -279,6 +286,9 @@ struct _dynamicgtksyms {
gtk_container_set_border_width_ptr gtk_container_set_border_width;
gtk_dialog_get_type_ptr gtk_dialog_get_type;
gtk_dialog_run_ptr gtk_dialog_run;
gtk_fixed_get_type_ptr gtk_fixed_get_type;
gtk_fixed_new_ptr gtk_fixed_new;
gtk_fixed_put_ptr gtk_fixed_put;
gtk_hbox_new_ptr gtk_hbox_new;
gtk_hbutton_box_new_ptr gtk_hbutton_box_new;
gtk_image_new_from_pixbuf_ptr gtk_image_new_from_pixbuf;
......@@ -365,6 +375,7 @@ struct _dynamicgtksyms {
gtk_widget_set_sensitive_ptr gtk_widget_set_sensitive;
gtk_widget_set_size_request_ptr gtk_widget_set_size_request;
gtk_widget_show_all_ptr gtk_widget_show_all;
gtk_widget_show_ptr gtk_widget_show;
gtk_widget_unref_ptr gtk_widget_unref;
gtk_window_add_accel_group_ptr gtk_window_add_accel_group;
gtk_window_get_type_ptr gtk_window_get_type;
......@@ -457,6 +468,12 @@ void dynamicgtk_uninit(void);
#define gtk_dialog_get_type dynamicgtksyms.gtk_dialog_get_type
#define gtk_dialog_run dynamicgtksyms.gtk_dialog_run
// gtkfixed.h
// TODO: Only needed to fix compilation for Kenbuild. Bring Kenbuild GTK window to parity with other windows, then remove this again.
#define gtk_fixed_get_type dynamicgtksyms.gtk_fixed_get_type
#define gtk_fixed_new dynamicgtksyms.gtk_fixed_new
#define gtk_fixed_put dynamicgtksyms.gtk_fixed_put
// gtkhbox.h
#define gtk_hbox_new dynamicgtksyms.gtk_hbox_new
......@@ -588,6 +605,7 @@ void dynamicgtk_uninit(void);
#define gtk_widget_set_sensitive dynamicgtksyms.gtk_widget_set_sensitive
#define gtk_widget_set_size_request dynamicgtksyms.gtk_widget_set_size_request
#define gtk_widget_show_all dynamicgtksyms.gtk_widget_show_all
#define gtk_widget_show dynamicgtksyms.gtk_widget_show
#define gtk_widget_unref dynamicgtksyms.gtk_widget_unref
// gtkwindow.h
......
......@@ -23,7 +23,8 @@ typedef struct hicreplc_t {
struct hicskybox_t *skybox;
vec2f_t scale;
float alphacut, specpower, specfactor;
char palnum, flags;
char palnum;
uint8_t flags;
} hicreplctyp;
typedef uint16_t polytintflags_t;
......@@ -124,6 +125,7 @@ enum
HICR_NODOWNSIZE = 16,
HICR_ARTIMMUNITY = 32,
HICR_INDEXED = 64,
HICR_NOCHT = 128,
};
// hictinting[].f / gloadtile_hi() and mdloadskin() <effect> arg bits
......
......@@ -19,6 +19,7 @@ enum loguru_verbosities_engine
LOG_INPUT,
LOG_NET,
LOG_PR,
LOG_MEM,
LOG_ENGINE_MAX,
LOG_DEBUG = INT8_MAX,
};
......
......@@ -1130,19 +1130,19 @@ LOGURU_ANONYMOUS_NAMESPACE_END
#if LOGURU_DEBUG_LOGGING
// Debug logging enabled:
#define DLOG_F(verbosity_name, ...) LOG_F(verbosity_name, __VA_ARGS__)
#define DVLOG_F(verbosity, ...) VLOG_F(verbosity, __VA_ARGS__)
#define DLOG_IF_F(verbosity_name, ...) LOG_IF_F(verbosity_name, __VA_ARGS__)
#define DVLOG_IF_F(verbosity, ...) VLOG_IF_F(verbosity, __VA_ARGS__)
#define DRAW_LOG_F(verbosity_name, ...) RAW_LOG_F(verbosity_name, __VA_ARGS__)
#define DRAW_VLOG_F(verbosity, ...) RAW_VLOG_F(verbosity, __VA_ARGS__)
#define DLOG_F(verbosity_name, ...) LOG_F(verbosity_name, __VA_ARGS__)
#define DVLOG_F(verbosity, ...) VLOG_F(verbosity, __VA_ARGS__)
#define DLOG_IF_F(verbosity_name, cond, ...) LOG_IF_F(verbosity_name, cond, __VA_ARGS__)
#define DVLOG_IF_F(verbosity, cond, ...) VLOG_IF_F(verbosity, cond, __VA_ARGS__)
#define DRAW_LOG_F(verbosity_name, ...) RAW_LOG_F(verbosity_name, __VA_ARGS__)
#define DRAW_VLOG_F(verbosity, ...) RAW_VLOG_F(verbosity, __VA_ARGS__)
#else
// Debug logging disabled:
// EDUKE32 MODIFICATION
#define DLOG_F(verbosity_name, ...) do {} while(0)
#define DVLOG_F(verbosity, ...) do {} while(0)
#define DLOG_IF_F(verbosity_name, ...) do {} while(0)
#define DVLOG_IF_F(verbosity, ...) do {} while(0)
#define DLOG_IF_F(verbosity_name, cond, ...) do {} while(0)
#define DVLOG_IF_F(verbosity, cond, ...) do {} while(0)
#define DRAW_LOG_F(verbosity_name, ...) do {} while(0)
#define DRAW_VLOG_F(verbosity, ...) do {} while(0)
// END EDUKE32 MODIFICATION
......
......@@ -42,69 +42,121 @@ extern int32_t reciptable[2048], fpuasm;
#define by(x) ((uint8_t)(x)) // byte cast
#define DIVTABLESIZE 16384
extern void initdivtables(void);
extern libdivide::libdivide_s64_t divtable64[DIVTABLESIZE];
extern libdivide::libdivide_s32_t divtable32[DIVTABLESIZE];
extern void initdivtables(void);
extern libdivide::libdivide_s64_branchfree_t bfdivtable64[DIVTABLESIZE];
extern libdivide::libdivide_s32_branchfree_t bfdivtable32[DIVTABLESIZE];
extern int64_t lastd_s64;
extern int64_t lastd_s64_b;
extern int32_t lastd_s32;
extern int32_t lastd_s32_b;
static inline uint32_t divideu32(uint32_t const n, uint32_t const d)
{
static libdivide::libdivide_u32_t udiv;
using namespace libdivide;
static libdivide_u32_t udiv;
static uint32_t lastd;
if (d == lastd)
goto skip;
if (d != lastd)
udiv = libdivide_u32_gen((lastd = d));
udiv = libdivide::libdivide_u32_gen((lastd = d));
skip:
return libdivide::libdivide_u32_do(n, &udiv);
return libdivide_u32_do(n, &udiv);
}
static inline uint64_t divideu64(uint64_t const n, uint64_t const d)
{
static libdivide::libdivide_u64_t udiv;
using namespace libdivide;
static libdivide_u64_t udiv;
static uint64_t lastd;
if (d == lastd)
goto skip;
if (d != lastd)
udiv = libdivide_u64_gen((lastd = d));
return libdivide_u64_do(n, &udiv);
}
static inline uint32_t divideu32_branchfree(uint32_t const n, uint32_t const d)
{
using namespace libdivide;
static libdivide_u32_branchfree_t udiv;
static uint32_t lastd;
if (d != lastd)
udiv = libdivide_u32_branchfree_gen((lastd = d));
udiv = libdivide::libdivide_u64_gen((lastd = d));
skip:
return libdivide::libdivide_u64_do(n, &udiv);
return libdivide_u32_branchfree_do(n, &udiv);
}
static inline uint64_t divideu64_branchfree(uint64_t const n, uint64_t const d)
{
using namespace libdivide;
static libdivide_u64_branchfree_t udiv;
static uint64_t lastd;
if (d != lastd)
udiv = libdivide_u64_branchfree_gen((lastd = d));
return libdivide_u64_branchfree_do(n, &udiv);
}
static inline int64_t tabledivide64(int64_t const n, int64_t const d)
{
static libdivide::libdivide_s64_t sdiv;
static int64_t lastd;
auto const dptr = ((uint64_t)d < DIVTABLESIZE) ? &divtable64[d] : &sdiv;
using namespace libdivide;
if (d == lastd || dptr != &sdiv)
goto skip;
if ((d != lastd_s64) & !((uint64_t)d < DIVTABLESIZE))
divtable64[0] = libdivide_s64_gen((lastd_s64 = d));
sdiv = libdivide::libdivide_s64_gen((lastd = d));
skip:
return libdivide::libdivide_s64_do(n, dptr);
return libdivide_s64_do(n, &divtable64[((uint64_t)d < DIVTABLESIZE) * d]);
}
static inline int32_t tabledivide32(int32_t const n, int32_t const d)
{
static libdivide::libdivide_s32_t sdiv;
static int32_t lastd;
auto const dptr = ((uint32_t)d < DIVTABLESIZE) ? &divtable32[d] : &sdiv;
using namespace libdivide;
if ((d != lastd_s32) & !((uint32_t)d < DIVTABLESIZE))
divtable32[0] = libdivide_s32_gen((lastd_s32 = d));
return libdivide_s32_do(n, &divtable32[((uint32_t)d < DIVTABLESIZE) * d]);
}
if (d == lastd || dptr != &sdiv)
goto skip;
static inline int64_t tabledivide64_branchfree(int64_t const n, int64_t const d)
{
using namespace libdivide;
sdiv = libdivide::libdivide_s32_gen((lastd = d));
skip:
return libdivide::libdivide_s32_do(n, dptr);
if ((d != lastd_s64_b) & !((uint64_t)d < DIVTABLESIZE))
bfdivtable64[0] = libdivide_s64_branchfree_gen((lastd_s64_b = d));
return libdivide_s64_branchfree_do(n, &bfdivtable64[((uint64_t)d < DIVTABLESIZE) * d]);
}
extern uint32_t divideu32_noinline(uint32_t n, uint32_t d);
extern uint64_t divideu64_noinline(uint64_t n, uint64_t d);
extern int32_t tabledivide32_noinline(int32_t n, int32_t d);
extern int64_t tabledivide64_noinline(int64_t n, int64_t d);
static inline int32_t tabledivide32_branchfree(int32_t const n, int32_t const d)
{
using namespace libdivide;
if ((d != lastd_s32_b) & !((uint32_t)d < DIVTABLESIZE))
bfdivtable32[0] = libdivide_s32_branchfree_gen((lastd_s32_b = d));
return libdivide_s32_branchfree_do(n, &bfdivtable32[((uint32_t)d < DIVTABLESIZE) * d]);
}
extern decltype(divideu32) *divideu32_noinline;
extern decltype(divideu64) *divideu64_noinline;
extern decltype(tabledivide32) *tabledivide32_noinline;
extern decltype(tabledivide64)* tabledivide64_noinline;
extern decltype(divideu32_branchfree)* divideu32_branchfree_noinline;
extern decltype(divideu64_branchfree)* divideu64_branchfree_noinline;
extern decltype(tabledivide32_branchfree) *tabledivide32_branchfree_noinline;
extern decltype(tabledivide64_branchfree) *tabledivide64_branchfree_noinline;
#ifdef GEKKO
static inline int32_t divscale(int32_t eax, int32_t ebx, int32_t ecx) { return dw(tabledivide64(ldexp(eax, ecx), ebx)); }
......
......@@ -3,6 +3,7 @@
#include "mio.hpp"
#include "polymost.h"
#include "mdsprite.h"
#ifdef __cplusplus
extern "C" {
......@@ -77,6 +78,9 @@ extern void texcache_setupmemcache(void);
extern void texcache_checkgarbage(void);
extern void texcache_setupindex(void);
extern voxmodel_t* voxcache_fetchvoxmodel(const char* const cacheid);
extern void voxcache_writevoxmodel(const char* const cacheid, voxmodel_t* vm);
#endif
#ifdef __cplusplus
......
......@@ -123,11 +123,17 @@ static int osdfunc_bucketlist(osdcmdptr_t UNUSED(parm))
uint32_t const missCount = (uint32_t)stats->missCount.load();
uint32_t const freeCount = (uint32_t)stats->freeCount.load();
LOG_F(INFO, "%12s: %u", "cache hit", cacheHitCount);
LOG_F(INFO, "%12s: %u", "hit", hitCount);
if (cacheHitCount)
LOG_F(INFO, "%12s: %u", "cache hit", cacheHitCount);
if (hitCount)
LOG_F(INFO, "%12s: %u", "hit", hitCount);
if (missCount)
LOG_F(INFO, "%12s: %s%u","miss", osd->draw.errorfmt, missCount);
LOG_F(INFO, "%12s: %u", "freed", freeCount);
if (freeCount)
LOG_F(INFO, "%12s: %u", "freed", freeCount);
uint32_t const useCount = cacheHitCount + hitCount + missCount - freeCount;
uint32_t const bucketBytesUsed = useCount * elementSize;
......@@ -150,7 +156,7 @@ static int osdfunc_heapinfo(osdcmdptr_t UNUSED(parm))
}
void engineSetupAllocator(void)
{
{
engineCreateAllocator();
#ifdef SMMALLOC_STATS_SUPPORT
......@@ -167,31 +173,18 @@ const char *engineVerbosityCallback(loguru::Verbosity verbosity)
if (gameVerbosityCallback)
{
auto str = gameVerbosityCallback(verbosity);
if (str != nullptr)
return str;
}
switch (verbosity)
{
default:
return nullptr;
case LOG_ENGINE:
return "ENG";
case LOG_GFX:
return "GFX";
case LOG_GL:
return "GL";
case LOG_ASS:
return "ASS";
case LOG_INPUT:
return "INPT";
case LOG_NET:
return "NET";
case LOG_PR:
return "PR";
case LOG_DEBUG:
return "DBG";
}
char const *s[] = { nullptr, "ENG", "GFX", "GL", "ASS", "INPT", "NET", "PR", "MEM" };
if ((unsigned)verbosity < ARRAY_SIZE(s))
return s[verbosity];
else if (verbosity == LOG_DEBUG)
return "DBG";
else return nullptr;
}
bool g_useLogCallback = true;
......
......@@ -8480,8 +8480,9 @@ CANCEL:
if (!EDITING_MAP_P())
{
if (map_undoredo(0)) printmessage16("Nothing to undo!");
else printmessage16("Revision %d undone",map_revision);
else printmessage16("Revision %d undone", map_revision);
}
else printmessage16("Can't undo or redo while editing!");
}
else if (ch == 'r' || ch == 'R')
{
......@@ -8491,6 +8492,7 @@ CANCEL:
if (map_undoredo(1)) printmessage16("Nothing to redo!");
else printmessage16("Restored revision %d", map_revision - 1);
}
else printmessage16("Can't undo or redo while editing!");
}
#endif
else if (ch == 'q' || ch == 'Q') //Q
......
......@@ -87,9 +87,9 @@ void cache1d::initBuffer(intptr_t dacachestart, uint32_t dacachesize, uint32_t m
m_baseAddress = ((uintptr_t)dacachestart + 15) & ~(uintptr_t)0xf;
m_totalSize = (dacachesize - (((uintptr_t)(dacachestart)) & 0xf)) & ~(uintptr_t)0xf;
m_maxBlocks = MINCACHEINDEXSIZE;
m_minBlockSize = minsize >= MINCACHEBLOCKSIZE ? minsize : Bgetpagesize();
m_index = (cacheindex_t *)Xaligned_alloc(m_minBlockSize, m_maxBlocks * sizeof(cacheindex_t));
m_maxBlocks = MINCACHEINDEXSIZE;
m_alignment = minsize >= MINCACHEBLOCKSIZE ? minsize : Bgetpagesize();
m_index = (cacheindex_t *)Xaligned_alloc(m_alignment, m_maxBlocks * sizeof(cacheindex_t));
reset();
......@@ -164,11 +164,11 @@ int32_t cache1d::findBlock(int32_t const newbytes, int32_t * const besto, int32_
void cache1d::tryHarder(int32_t const newbytes, int32_t *const besto, int32_t *const bestz)
{
LOG_F(WARNING, "Request for %dKB block exhausted cache!", newbytes >> 10);
LOG_F(WARNING, "Attempting to make it fit...");
LOG_F(ERROR, "Request for %dKB block exhausted cache!", newbytes >> 10);
LOG_F(ERROR, "Attempting to make it fit...");
if (m_minBlockSize > MINCACHEBLOCKSIZE)
m_minBlockSize >>= 1;
if (m_alignment > MINCACHEBLOCKSIZE)
m_alignment >>= 1;
int cnt = m_numBlocks - 1;
......@@ -187,7 +187,11 @@ void cache1d::allocateBlock(intptr_t* newhandle, int32_t newbytes, char* newlock
{
// Make all requests a multiple of the minimum block size
int const askedbytes = newbytes;
newbytes = (newbytes + m_minBlockSize-1) & ~(m_minBlockSize-1);
newbytes = (newbytes + m_alignment-1) & ~(m_alignment-1);
if (newbytes > nextPow2(askedbytes))
newbytes = nextPow2(askedbytes);
#ifdef DEBUGGINGAIDS
if (EDUKE32_PREDICT_FALSE(!newlockptr || *newlockptr == 0))
......@@ -298,26 +302,34 @@ void cache1d::report(void)
int32_t usedSize = 0;
int32_t unusable = 0;
inthashtable_t h_blocktotile = { nullptr, INTHASH_SIZE(m_maxBlocks) };
inthash_init(&h_blocktotile);