Move pow2char and pow2long to build.h and make them constexpr

git-svn-id: https://svn.eduke32.com/eduke32@7146 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
terminx 2018-11-18 18:05:26 +00:00
parent 786a0cc6a3
commit a6e60e9723
6 changed files with 18 additions and 25 deletions

View file

@ -792,8 +792,20 @@ EXTERN vec2s_t tilesiz[MAXTILES];
EXTERN char picsiz[MAXTILES];
EXTERN char walock[MAXTILES];
extern const char pow2char[8];
extern const int32_t pow2long[32];
extern const char pow2char_[];
static CONSTEXPR const char pow2char[8] = {1,2,4,8,16,32,64,128};
static CONSTEXPR const int32_t pow2long[32] =
{
1, 2, 4, 8,
16, 32, 64, 128,
256, 512, 1024, 2048,
4096, 8192, 16384, 32768,
65536, 131072, 262144, 524288,
1048576, 2097152, 4194304, 8388608,
16777216, 33554432, 67108864, 134217728,
268435456, 536870912, 1073741824, 2147483647
};
// picanm[].sf:
// |bit(1<<7)

View file

@ -40,9 +40,6 @@ EXTRN _bufplce : near
EXTRN _ebpbak : dword
EXTRN _espbak : dword
EXTRN _pow2char : near
EXTRN _pow2long : near
EXTRN _globaltilesizy : dword
; Some macros to help make cdecl calling easier to manage

View file

@ -50,8 +50,6 @@ SECTION .text
%define bufplce _bufplce
%define ebpbak _ebpbak
%define espbak _espbak
%define pow2char _pow2char
%define pow2long _pow2long
%define globaltilesizy _globaltilesizy
%define sethlinesizes _sethlinesizes
@ -202,9 +200,6 @@ SECTION .text
EXTERN ebpbak
EXTERN espbak
EXTERN pow2char
EXTERN pow2long
EXTERN globaltilesizy
GLOBAL sethlinesizes

View file

@ -168,20 +168,9 @@ static intptr_t slopalookup[16384]; // was 2048
static int32_t no_radarang2 = 0;
static int16_t radarang[1280], *radarang2;
const char ATTRIBUTE((used)) pow2char_[8] = {1,2,4,8,16,32,64,128};
uint16_t ATTRIBUTE((used)) sqrtable[4096], ATTRIBUTE((used)) shlookup[4096+256];
const char pow2char[8] = {1,2,4,8,16,32,64,128};
const int32_t pow2long[32] =
{
1, 2, 4, 8,
16, 32, 64, 128,
256, 512, 1024, 2048,
4096, 8192, 16384, 32768,
65536, 131072, 262144, 524288,
1048576, 2097152, 4194304, 8388608,
16777216, 33554432, 67108864, 134217728,
268435456, 536870912, 1073741824, 2147483647
};
char britable[16][256]; // JBF 20040207: full 8bit precision

View file

@ -362,7 +362,7 @@ skipit:
"shrl $3, %%eax\n\t" \
"andl $7, %%ebx\n\t" \
"movb " ASMSYM("gotpic") "(%%eax), %%dl\n\t" \
"movb " ASMSYM("pow2char") "(%%ebx), %%bl\n\t" \
"movb " ASMSYM("pow2char_") "(%%ebx), %%bl\n\t" \
"orb %%bl, %%dl\n\t" \
"movb %%dl, " ASMSYM("gotpic") "(%%eax)" \
: "=a" (__a) : "a" (__a) \

View file

@ -64,7 +64,7 @@ static FORCE_INLINE CONSTEXPR int32_t klrotl(int32_t i, int sh) { return (i >> (
static intptr_t kp_frameplace;
static int32_t kp_bytesperline, kp_xres, kp_yres;
static const int32_t pow2mask[32] =
static CONSTEXPR const int32_t pow2mask[32] =
{
0x00000000,0x00000001,0x00000003,0x00000007,
0x0000000f,0x0000001f,0x0000003f,0x0000007f,
@ -75,7 +75,7 @@ static const int32_t pow2mask[32] =
0x00ffffff,0x01ffffff,0x03ffffff,0x07ffffff,
0x0fffffff,0x1fffffff,0x3fffffff,0x7fffffff,
};
static const int32_t pow2long[32] =
static CONSTEXPR const int32_t pow2long[32] =
{
0x00000001,0x00000002,0x00000004,0x00000008,
0x00000010,0x00000020,0x00000040,0x00000080,