mirror of
https://github.com/ZDoom/qzdoom-gpl.git
synced 2024-11-29 15:12:11 +00:00
This commit is contained in:
commit
c48b528824
16 changed files with 132 additions and 521 deletions
|
@ -1,121 +0,0 @@
|
|||
// "Build Engine & Tools" Copyright (c) 1993-1997 Ken Silverman
|
||||
// Ken Silverman's official web site: "http://www.advsys.net/ken"
|
||||
// See the included license file "BUILDLIC.TXT" for license info.
|
||||
//
|
||||
// This file is based on pragmas.h from Ken Silverman's original Build
|
||||
// source code release but is meant for use with any compiler and does not
|
||||
// rely on any inline assembly.
|
||||
//
|
||||
|
||||
#if _MSC_VER
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#if defined(__GNUC__) && !defined(__forceinline)
|
||||
#define __forceinline __inline__ __attribute__((always_inline))
|
||||
#endif
|
||||
|
||||
static __forceinline SDWORD Scale (SDWORD a, SDWORD b, SDWORD c)
|
||||
{
|
||||
return (SDWORD)(((SQWORD)a*b)/c);
|
||||
}
|
||||
|
||||
static __forceinline SDWORD MulScale1 (SDWORD a, SDWORD b) { return (SDWORD)(((SQWORD)a * b) >> 1); }
|
||||
static __forceinline SDWORD MulScale2 (SDWORD a, SDWORD b) { return (SDWORD)(((SQWORD)a * b) >> 2); }
|
||||
static __forceinline SDWORD MulScale3 (SDWORD a, SDWORD b) { return (SDWORD)(((SQWORD)a * b) >> 3); }
|
||||
static __forceinline SDWORD MulScale4 (SDWORD a, SDWORD b) { return (SDWORD)(((SQWORD)a * b) >> 4); }
|
||||
static __forceinline SDWORD MulScale5 (SDWORD a, SDWORD b) { return (SDWORD)(((SQWORD)a * b) >> 5); }
|
||||
static __forceinline SDWORD MulScale6 (SDWORD a, SDWORD b) { return (SDWORD)(((SQWORD)a * b) >> 6); }
|
||||
static __forceinline SDWORD MulScale7 (SDWORD a, SDWORD b) { return (SDWORD)(((SQWORD)a * b) >> 7); }
|
||||
static __forceinline SDWORD MulScale8 (SDWORD a, SDWORD b) { return (SDWORD)(((SQWORD)a * b) >> 8); }
|
||||
static __forceinline SDWORD MulScale9 (SDWORD a, SDWORD b) { return (SDWORD)(((SQWORD)a * b) >> 9); }
|
||||
static __forceinline SDWORD MulScale10 (SDWORD a, SDWORD b) { return (SDWORD)(((SQWORD)a * b) >> 10); }
|
||||
static __forceinline SDWORD MulScale11 (SDWORD a, SDWORD b) { return (SDWORD)(((SQWORD)a * b) >> 11); }
|
||||
static __forceinline SDWORD MulScale12 (SDWORD a, SDWORD b) { return (SDWORD)(((SQWORD)a * b) >> 12); }
|
||||
static __forceinline SDWORD MulScale13 (SDWORD a, SDWORD b) { return (SDWORD)(((SQWORD)a * b) >> 13); }
|
||||
static __forceinline SDWORD MulScale14 (SDWORD a, SDWORD b) { return (SDWORD)(((SQWORD)a * b) >> 14); }
|
||||
static __forceinline SDWORD MulScale15 (SDWORD a, SDWORD b) { return (SDWORD)(((SQWORD)a * b) >> 15); }
|
||||
static __forceinline SDWORD MulScale16 (SDWORD a, SDWORD b) { return (SDWORD)(((SQWORD)a * b) >> 16); }
|
||||
static __forceinline SDWORD MulScale17 (SDWORD a, SDWORD b) { return (SDWORD)(((SQWORD)a * b) >> 17); }
|
||||
static __forceinline SDWORD MulScale18 (SDWORD a, SDWORD b) { return (SDWORD)(((SQWORD)a * b) >> 18); }
|
||||
static __forceinline SDWORD MulScale19 (SDWORD a, SDWORD b) { return (SDWORD)(((SQWORD)a * b) >> 19); }
|
||||
static __forceinline SDWORD MulScale20 (SDWORD a, SDWORD b) { return (SDWORD)(((SQWORD)a * b) >> 20); }
|
||||
static __forceinline SDWORD MulScale21 (SDWORD a, SDWORD b) { return (SDWORD)(((SQWORD)a * b) >> 21); }
|
||||
static __forceinline SDWORD MulScale22 (SDWORD a, SDWORD b) { return (SDWORD)(((SQWORD)a * b) >> 22); }
|
||||
static __forceinline SDWORD MulScale23 (SDWORD a, SDWORD b) { return (SDWORD)(((SQWORD)a * b) >> 23); }
|
||||
static __forceinline SDWORD MulScale24 (SDWORD a, SDWORD b) { return (SDWORD)(((SQWORD)a * b) >> 24); }
|
||||
static __forceinline SDWORD MulScale25 (SDWORD a, SDWORD b) { return (SDWORD)(((SQWORD)a * b) >> 25); }
|
||||
static __forceinline SDWORD MulScale26 (SDWORD a, SDWORD b) { return (SDWORD)(((SQWORD)a * b) >> 26); }
|
||||
static __forceinline SDWORD MulScale27 (SDWORD a, SDWORD b) { return (SDWORD)(((SQWORD)a * b) >> 27); }
|
||||
static __forceinline SDWORD MulScale28 (SDWORD a, SDWORD b) { return (SDWORD)(((SQWORD)a * b) >> 28); }
|
||||
static __forceinline SDWORD MulScale29 (SDWORD a, SDWORD b) { return (SDWORD)(((SQWORD)a * b) >> 29); }
|
||||
static __forceinline SDWORD MulScale30 (SDWORD a, SDWORD b) { return (SDWORD)(((SQWORD)a * b) >> 30); }
|
||||
static __forceinline SDWORD MulScale31 (SDWORD a, SDWORD b) { return (SDWORD)(((SQWORD)a * b) >> 31); }
|
||||
static __forceinline SDWORD MulScale32 (SDWORD a, SDWORD b) { return (SDWORD)(((SQWORD)a * b) >> 32); }
|
||||
|
||||
static __forceinline DWORD UMulScale16 (DWORD a, DWORD b) { return (DWORD)(((QWORD)a * b) >> 16); }
|
||||
|
||||
static __forceinline SDWORD DMulScale1 (SDWORD a, SDWORD b, SDWORD c, SDWORD d) { return (SDWORD)(((SQWORD)a*b + (SQWORD)c*d) >> 1); }
|
||||
static __forceinline SDWORD DMulScale2 (SDWORD a, SDWORD b, SDWORD c, SDWORD d) { return (SDWORD)(((SQWORD)a*b + (SQWORD)c*d) >> 2); }
|
||||
static __forceinline SDWORD DMulScale3 (SDWORD a, SDWORD b, SDWORD c, SDWORD d) { return (SDWORD)(((SQWORD)a*b + (SQWORD)c*d) >> 3); }
|
||||
static __forceinline SDWORD DMulScale4 (SDWORD a, SDWORD b, SDWORD c, SDWORD d) { return (SDWORD)(((SQWORD)a*b + (SQWORD)c*d) >> 4); }
|
||||
static __forceinline SDWORD DMulScale5 (SDWORD a, SDWORD b, SDWORD c, SDWORD d) { return (SDWORD)(((SQWORD)a*b + (SQWORD)c*d) >> 5); }
|
||||
static __forceinline SDWORD DMulScale6 (SDWORD a, SDWORD b, SDWORD c, SDWORD d) { return (SDWORD)(((SQWORD)a*b + (SQWORD)c*d) >> 6); }
|
||||
static __forceinline SDWORD DMulScale7 (SDWORD a, SDWORD b, SDWORD c, SDWORD d) { return (SDWORD)(((SQWORD)a*b + (SQWORD)c*d) >> 7); }
|
||||
static __forceinline SDWORD DMulScale8 (SDWORD a, SDWORD b, SDWORD c, SDWORD d) { return (SDWORD)(((SQWORD)a*b + (SQWORD)c*d) >> 8); }
|
||||
static __forceinline SDWORD DMulScale9 (SDWORD a, SDWORD b, SDWORD c, SDWORD d) { return (SDWORD)(((SQWORD)a*b + (SQWORD)c*d) >> 9); }
|
||||
static __forceinline SDWORD DMulScale10 (SDWORD a, SDWORD b, SDWORD c, SDWORD d) { return (SDWORD)(((SQWORD)a*b + (SQWORD)c*d) >> 10); }
|
||||
static __forceinline SDWORD DMulScale11 (SDWORD a, SDWORD b, SDWORD c, SDWORD d) { return (SDWORD)(((SQWORD)a*b + (SQWORD)c*d) >> 11); }
|
||||
static __forceinline SDWORD DMulScale12 (SDWORD a, SDWORD b, SDWORD c, SDWORD d) { return (SDWORD)(((SQWORD)a*b + (SQWORD)c*d) >> 12); }
|
||||
static __forceinline SDWORD DMulScale13 (SDWORD a, SDWORD b, SDWORD c, SDWORD d) { return (SDWORD)(((SQWORD)a*b + (SQWORD)c*d) >> 13); }
|
||||
static __forceinline SDWORD DMulScale14 (SDWORD a, SDWORD b, SDWORD c, SDWORD d) { return (SDWORD)(((SQWORD)a*b + (SQWORD)c*d) >> 14); }
|
||||
static __forceinline SDWORD DMulScale15 (SDWORD a, SDWORD b, SDWORD c, SDWORD d) { return (SDWORD)(((SQWORD)a*b + (SQWORD)c*d) >> 15); }
|
||||
static __forceinline SDWORD DMulScale16 (SDWORD a, SDWORD b, SDWORD c, SDWORD d) { return (SDWORD)(((SQWORD)a*b + (SQWORD)c*d) >> 16); }
|
||||
static __forceinline SDWORD DMulScale17 (SDWORD a, SDWORD b, SDWORD c, SDWORD d) { return (SDWORD)(((SQWORD)a*b + (SQWORD)c*d) >> 17); }
|
||||
static __forceinline SDWORD DMulScale18 (SDWORD a, SDWORD b, SDWORD c, SDWORD d) { return (SDWORD)(((SQWORD)a*b + (SQWORD)c*d) >> 18); }
|
||||
static __forceinline SDWORD DMulScale19 (SDWORD a, SDWORD b, SDWORD c, SDWORD d) { return (SDWORD)(((SQWORD)a*b + (SQWORD)c*d) >> 19); }
|
||||
static __forceinline SDWORD DMulScale20 (SDWORD a, SDWORD b, SDWORD c, SDWORD d) { return (SDWORD)(((SQWORD)a*b + (SQWORD)c*d) >> 20); }
|
||||
static __forceinline SDWORD DMulScale21 (SDWORD a, SDWORD b, SDWORD c, SDWORD d) { return (SDWORD)(((SQWORD)a*b + (SQWORD)c*d) >> 21); }
|
||||
static __forceinline SDWORD DMulScale22 (SDWORD a, SDWORD b, SDWORD c, SDWORD d) { return (SDWORD)(((SQWORD)a*b + (SQWORD)c*d) >> 22); }
|
||||
static __forceinline SDWORD DMulScale23 (SDWORD a, SDWORD b, SDWORD c, SDWORD d) { return (SDWORD)(((SQWORD)a*b + (SQWORD)c*d) >> 23); }
|
||||
static __forceinline SDWORD DMulScale24 (SDWORD a, SDWORD b, SDWORD c, SDWORD d) { return (SDWORD)(((SQWORD)a*b + (SQWORD)c*d) >> 24); }
|
||||
static __forceinline SDWORD DMulScale25 (SDWORD a, SDWORD b, SDWORD c, SDWORD d) { return (SDWORD)(((SQWORD)a*b + (SQWORD)c*d) >> 25); }
|
||||
static __forceinline SDWORD DMulScale26 (SDWORD a, SDWORD b, SDWORD c, SDWORD d) { return (SDWORD)(((SQWORD)a*b + (SQWORD)c*d) >> 26); }
|
||||
static __forceinline SDWORD DMulScale27 (SDWORD a, SDWORD b, SDWORD c, SDWORD d) { return (SDWORD)(((SQWORD)a*b + (SQWORD)c*d) >> 27); }
|
||||
static __forceinline SDWORD DMulScale28 (SDWORD a, SDWORD b, SDWORD c, SDWORD d) { return (SDWORD)(((SQWORD)a*b + (SQWORD)c*d) >> 28); }
|
||||
static __forceinline SDWORD DMulScale29 (SDWORD a, SDWORD b, SDWORD c, SDWORD d) { return (SDWORD)(((SQWORD)a*b + (SQWORD)c*d) >> 29); }
|
||||
static __forceinline SDWORD DMulScale30 (SDWORD a, SDWORD b, SDWORD c, SDWORD d) { return (SDWORD)(((SQWORD)a*b + (SQWORD)c*d) >> 30); }
|
||||
static __forceinline SDWORD DMulScale31 (SDWORD a, SDWORD b, SDWORD c, SDWORD d) { return (SDWORD)(((SQWORD)a*b + (SQWORD)c*d) >> 31); }
|
||||
static __forceinline SDWORD DMulScale32 (SDWORD a, SDWORD b, SDWORD c, SDWORD d) { return (SDWORD)(((SQWORD)a*b + (SQWORD)c*d) >> 32); }
|
||||
|
||||
static inline SDWORD DivScale2 (SDWORD a, SDWORD b) { return (SDWORD)(((SQWORD)a << 2) / b); }
|
||||
static inline SDWORD DivScale3 (SDWORD a, SDWORD b) { return (SDWORD)(((SQWORD)a << 3) / b); }
|
||||
static inline SDWORD DivScale4 (SDWORD a, SDWORD b) { return (SDWORD)(((SQWORD)a << 4) / b); }
|
||||
static inline SDWORD DivScale5 (SDWORD a, SDWORD b) { return (SDWORD)(((SQWORD)a << 5) / b); }
|
||||
static inline SDWORD DivScale6 (SDWORD a, SDWORD b) { return (SDWORD)(((SQWORD)a << 6) / b); }
|
||||
static inline SDWORD DivScale7 (SDWORD a, SDWORD b) { return (SDWORD)(((SQWORD)a << 7) / b); }
|
||||
static inline SDWORD DivScale8 (SDWORD a, SDWORD b) { return (SDWORD)(((SQWORD)a << 8) / b); }
|
||||
static inline SDWORD DivScale9 (SDWORD a, SDWORD b) { return (SDWORD)(((SQWORD)a << 9) / b); }
|
||||
static inline SDWORD DivScale10 (SDWORD a, SDWORD b) { return (SDWORD)(((SQWORD)a << 10) / b); }
|
||||
static inline SDWORD DivScale11 (SDWORD a, SDWORD b) { return (SDWORD)(((SQWORD)a << 11) / b); }
|
||||
static inline SDWORD DivScale12 (SDWORD a, SDWORD b) { return (SDWORD)(((SQWORD)a << 12) / b); }
|
||||
static inline SDWORD DivScale13 (SDWORD a, SDWORD b) { return (SDWORD)(((SQWORD)a << 13) / b); }
|
||||
static inline SDWORD DivScale14 (SDWORD a, SDWORD b) { return (SDWORD)(((SQWORD)a << 14) / b); }
|
||||
static inline SDWORD DivScale15 (SDWORD a, SDWORD b) { return (SDWORD)(((SQWORD)a << 15) / b); }
|
||||
static inline SDWORD DivScale16 (SDWORD a, SDWORD b) { return (SDWORD)(((SQWORD)a << 16) / b); }
|
||||
static inline SDWORD DivScale17 (SDWORD a, SDWORD b) { return (SDWORD)(((SQWORD)a << 17) / b); }
|
||||
static inline SDWORD DivScale18 (SDWORD a, SDWORD b) { return (SDWORD)(((SQWORD)a << 18) / b); }
|
||||
static inline SDWORD DivScale19 (SDWORD a, SDWORD b) { return (SDWORD)(((SQWORD)a << 19) / b); }
|
||||
static inline SDWORD DivScale20 (SDWORD a, SDWORD b) { return (SDWORD)(((SQWORD)a << 20) / b); }
|
||||
static inline SDWORD DivScale21 (SDWORD a, SDWORD b) { return (SDWORD)(((SQWORD)a << 21) / b); }
|
||||
static inline SDWORD DivScale22 (SDWORD a, SDWORD b) { return (SDWORD)(((SQWORD)a << 22) / b); }
|
||||
static inline SDWORD DivScale23 (SDWORD a, SDWORD b) { return (SDWORD)(((SQWORD)a << 23) / b); }
|
||||
static inline SDWORD DivScale24 (SDWORD a, SDWORD b) { return (SDWORD)(((SQWORD)a << 24) / b); }
|
||||
static inline SDWORD DivScale25 (SDWORD a, SDWORD b) { return (SDWORD)(((SQWORD)a << 25) / b); }
|
||||
static inline SDWORD DivScale26 (SDWORD a, SDWORD b) { return (SDWORD)(((SQWORD)a << 26) / b); }
|
||||
static inline SDWORD DivScale27 (SDWORD a, SDWORD b) { return (SDWORD)(((SQWORD)a << 27) / b); }
|
||||
static inline SDWORD DivScale28 (SDWORD a, SDWORD b) { return (SDWORD)(((SQWORD)a << 28) / b); }
|
||||
static inline SDWORD DivScale29 (SDWORD a, SDWORD b) { return (SDWORD)(((SQWORD)a << 29) / b); }
|
||||
static inline SDWORD DivScale30 (SDWORD a, SDWORD b) { return (SDWORD)(((SQWORD)a << 30) / b); }
|
||||
static inline SDWORD DivScale31 (SDWORD a, SDWORD b) { return (SDWORD)(((SQWORD)a << 31) / b); }
|
||||
|
|
@ -374,7 +374,7 @@ public:
|
|||
static FileWriter *Open(const char *filename);
|
||||
|
||||
virtual size_t Write(const void *buffer, size_t len);
|
||||
size_t Printf(const char *fmt, ...);
|
||||
size_t Printf(const char *fmt, ...) GCCPRINTF(2,3);
|
||||
|
||||
protected:
|
||||
|
||||
|
|
|
@ -718,7 +718,7 @@ public:
|
|||
|
||||
#include "t_fs.h"
|
||||
|
||||
void script_error(const char *s, ...);
|
||||
void script_error(const char *s, ...) GCCPRINTF(1,2);
|
||||
void FS_EmulateCmd(char * string);
|
||||
|
||||
extern AActor *trigger_obj;
|
||||
|
|
176
src/gccinlines.h
176
src/gccinlines.h
|
@ -1,176 +0,0 @@
|
|||
// "Build Engine & Tools" Copyright (c) 1993-1997 Ken Silverman
|
||||
// Ken Silverman's official web site: "http://www.advsys.net/ken"
|
||||
// See the included license file "BUILDLIC.TXT" for license info.
|
||||
//
|
||||
// This file is based on pragmas.h from Ken Silverman's original Build
|
||||
// source code release but is meant for use with GCC instead of Watcom C.
|
||||
//
|
||||
// Some of the inline assembly has been turned into C code, because
|
||||
// modern compilers are smart enough to produce code at least as good as
|
||||
// Ken's inline assembly.
|
||||
//
|
||||
|
||||
// I can come up with several different operand constraints for the
|
||||
// following that work just fine when used all by themselves, but
|
||||
// when I concatenate them together so that the compiler can choose
|
||||
// between them, I get the following (but only if enough parameters
|
||||
// are passed as the result of some operations instead of as
|
||||
// variables/constants--e.g. DMulScale16 (a*2, b*2, c*2, d*2) instead of
|
||||
// DMulScale16 (a, b, c, d)):
|
||||
//
|
||||
// `asm' operand requires impossible reload
|
||||
//
|
||||
// Why?
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
#ifndef alloca
|
||||
// MinGW does not seem to come with alloca defined.
|
||||
#define alloca __builtin_alloca
|
||||
#endif
|
||||
|
||||
static inline SDWORD Scale (SDWORD a, SDWORD b, SDWORD c)
|
||||
{
|
||||
SDWORD result, dummy;
|
||||
|
||||
asm volatile
|
||||
("imull %3\n\t"
|
||||
"idivl %4"
|
||||
: "=a,a,a,a,a,a" (result),
|
||||
"=&d,&d,&d,&d,d,d" (dummy)
|
||||
: "a,a,a,a,a,a" (a),
|
||||
"m,r,m,r,d,d" (b),
|
||||
"r,r,m,m,r,m" (c)
|
||||
: "cc"
|
||||
);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
#define MAKECONSTMulScale(s) \
|
||||
static inline SDWORD MulScale##s (SDWORD a, SDWORD b) { return ((SQWORD)a * b) >> s; }
|
||||
|
||||
MAKECONSTMulScale(1)
|
||||
MAKECONSTMulScale(2)
|
||||
MAKECONSTMulScale(3)
|
||||
MAKECONSTMulScale(4)
|
||||
MAKECONSTMulScale(5)
|
||||
MAKECONSTMulScale(6)
|
||||
MAKECONSTMulScale(7)
|
||||
MAKECONSTMulScale(8)
|
||||
MAKECONSTMulScale(9)
|
||||
MAKECONSTMulScale(10)
|
||||
MAKECONSTMulScale(11)
|
||||
MAKECONSTMulScale(12)
|
||||
MAKECONSTMulScale(13)
|
||||
MAKECONSTMulScale(14)
|
||||
MAKECONSTMulScale(15)
|
||||
MAKECONSTMulScale(16)
|
||||
MAKECONSTMulScale(17)
|
||||
MAKECONSTMulScale(18)
|
||||
MAKECONSTMulScale(19)
|
||||
MAKECONSTMulScale(20)
|
||||
MAKECONSTMulScale(21)
|
||||
MAKECONSTMulScale(22)
|
||||
MAKECONSTMulScale(23)
|
||||
MAKECONSTMulScale(24)
|
||||
MAKECONSTMulScale(25)
|
||||
MAKECONSTMulScale(26)
|
||||
MAKECONSTMulScale(27)
|
||||
MAKECONSTMulScale(28)
|
||||
MAKECONSTMulScale(29)
|
||||
MAKECONSTMulScale(30)
|
||||
MAKECONSTMulScale(31)
|
||||
MAKECONSTMulScale(32)
|
||||
#undef MAKECONSTMulScale
|
||||
|
||||
static inline DWORD UMulScale16(DWORD a, DWORD b) { return ((QWORD)a * b) >> 16; }
|
||||
|
||||
#define MAKECONSTDMulScale(s) \
|
||||
static inline SDWORD DMulScale##s (SDWORD a, SDWORD b, SDWORD c, SDWORD d) \
|
||||
{ \
|
||||
return (((SQWORD)a * b) + ((SQWORD)c * d)) >> s; \
|
||||
}
|
||||
|
||||
MAKECONSTDMulScale(1)
|
||||
MAKECONSTDMulScale(2)
|
||||
MAKECONSTDMulScale(3)
|
||||
MAKECONSTDMulScale(4)
|
||||
MAKECONSTDMulScale(5)
|
||||
MAKECONSTDMulScale(6)
|
||||
MAKECONSTDMulScale(7)
|
||||
MAKECONSTDMulScale(8)
|
||||
MAKECONSTDMulScale(9)
|
||||
MAKECONSTDMulScale(10)
|
||||
MAKECONSTDMulScale(11)
|
||||
MAKECONSTDMulScale(12)
|
||||
MAKECONSTDMulScale(13)
|
||||
MAKECONSTDMulScale(14)
|
||||
MAKECONSTDMulScale(15)
|
||||
MAKECONSTDMulScale(16)
|
||||
MAKECONSTDMulScale(17)
|
||||
MAKECONSTDMulScale(18)
|
||||
MAKECONSTDMulScale(19)
|
||||
MAKECONSTDMulScale(20)
|
||||
MAKECONSTDMulScale(21)
|
||||
MAKECONSTDMulScale(22)
|
||||
MAKECONSTDMulScale(23)
|
||||
MAKECONSTDMulScale(24)
|
||||
MAKECONSTDMulScale(25)
|
||||
MAKECONSTDMulScale(26)
|
||||
MAKECONSTDMulScale(27)
|
||||
MAKECONSTDMulScale(28)
|
||||
MAKECONSTDMulScale(29)
|
||||
MAKECONSTDMulScale(30)
|
||||
MAKECONSTDMulScale(31)
|
||||
MAKECONSTDMulScale(32)
|
||||
#undef MAKECONSTDMulScale
|
||||
|
||||
|
||||
#define MAKECONSTDivScale(s) \
|
||||
static inline SDWORD DivScale##s (SDWORD a, SDWORD b) \
|
||||
{ \
|
||||
SDWORD result, dummy; \
|
||||
asm volatile \
|
||||
("idivl %4" \
|
||||
:"=a,a" (result), \
|
||||
"=d,d" (dummy) \
|
||||
: "a,a" (a<<s), \
|
||||
"d,d" (a>>(32-s)), \
|
||||
"r,m" (b) \
|
||||
: "cc"); \
|
||||
return result; \
|
||||
}
|
||||
|
||||
MAKECONSTDivScale(2)
|
||||
MAKECONSTDivScale(3)
|
||||
MAKECONSTDivScale(4)
|
||||
MAKECONSTDivScale(5)
|
||||
MAKECONSTDivScale(6)
|
||||
MAKECONSTDivScale(7)
|
||||
MAKECONSTDivScale(8)
|
||||
MAKECONSTDivScale(9)
|
||||
MAKECONSTDivScale(10)
|
||||
MAKECONSTDivScale(11)
|
||||
MAKECONSTDivScale(12)
|
||||
MAKECONSTDivScale(13)
|
||||
MAKECONSTDivScale(14)
|
||||
MAKECONSTDivScale(15)
|
||||
MAKECONSTDivScale(16)
|
||||
MAKECONSTDivScale(17)
|
||||
MAKECONSTDivScale(18)
|
||||
MAKECONSTDivScale(19)
|
||||
MAKECONSTDivScale(20)
|
||||
MAKECONSTDivScale(21)
|
||||
MAKECONSTDivScale(22)
|
||||
MAKECONSTDivScale(23)
|
||||
MAKECONSTDivScale(24)
|
||||
MAKECONSTDivScale(25)
|
||||
MAKECONSTDivScale(26)
|
||||
MAKECONSTDivScale(27)
|
||||
MAKECONSTDivScale(28)
|
||||
MAKECONSTDivScale(29)
|
||||
MAKECONSTDivScale(30)
|
||||
MAKECONSTDivScale(31)
|
||||
#undef MAKECONSTDivScale
|
||||
|
|
@ -4,14 +4,72 @@
|
|||
#include <stdlib.h>
|
||||
#include "doomtype.h"
|
||||
|
||||
// Unfortunately, the Scale function still gets badly handled on 32 bit x86 platforms so it's the last remaining piece of inline assembly
|
||||
|
||||
// GCC inlines
|
||||
#if defined(__GNUC__) && defined(__i386__) && !defined(__clang__)
|
||||
#include "gccinlines.h"
|
||||
#elif defined(_MSC_VER) && defined(_M_IX86)
|
||||
#include "mscinlines.h"
|
||||
#else
|
||||
#include "basicinlines.h"
|
||||
#ifndef alloca
|
||||
// MinGW does not seem to come with alloca defined.
|
||||
#define alloca __builtin_alloca
|
||||
#endif
|
||||
|
||||
static inline int32_t Scale(int32_t a, int32_t b, int32_t c)
|
||||
{
|
||||
int32_t result, dummy;
|
||||
|
||||
asm volatile
|
||||
("imull %3\n\t"
|
||||
"idivl %4"
|
||||
: "=a,a,a,a,a,a" (result),
|
||||
"=&d,&d,&d,&d,d,d" (dummy)
|
||||
: "a,a,a,a,a,a" (a),
|
||||
"m,r,m,r,d,d" (b),
|
||||
"r,r,m,m,r,m" (c)
|
||||
: "cc"
|
||||
);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
// MSVC inlines
|
||||
#elif defined(_MSC_VER) && defined(_M_IX86)
|
||||
#pragma warning (disable: 4035)
|
||||
|
||||
__forceinline int32_t Scale(int32_t a, int32_t b, int32_t c)
|
||||
{
|
||||
__asm mov eax, a
|
||||
__asm imul b
|
||||
__asm idiv c
|
||||
}
|
||||
|
||||
#pragma warning (default: 4035)
|
||||
#else
|
||||
|
||||
static __forceinline int32_t Scale(int32_t a, int32_t b, int32_t c)
|
||||
{
|
||||
return (int32_t)(((int64_t)a*b) / c);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
// Modern compilers are smart enough to do these multiplications intelligently.
|
||||
__forceinline int32_t MulScale14(int32_t a, int32_t b) { return (int32_t)(((int64_t)a * b) >> 14); } // only used by R_DrawVoxel
|
||||
__forceinline int32_t MulScale30(int32_t a, int32_t b) { return (int32_t)(((int64_t)a * b) >> 30); } // only used once in the node builder
|
||||
__forceinline int32_t MulScale32(int32_t a, int32_t b) { return (int32_t)(((int64_t)a * b) >> 32); } // only used by R_DrawVoxel
|
||||
|
||||
__forceinline uint32_t UMulScale16(uint32_t a, uint32_t b) { return (uint32_t)(((uint64_t)a * b) >> 16); } // used for sky drawing
|
||||
|
||||
__forceinline int32_t DMulScale3(int32_t a, int32_t b, int32_t c, int32_t d) { return (int32_t)(((int64_t)a*b + (int64_t)c*d) >> 3); } // used for setting up slopes for Build maps
|
||||
__forceinline int32_t DMulScale6(int32_t a, int32_t b, int32_t c, int32_t d) { return (int32_t)(((int64_t)a*b + (int64_t)c*d) >> 6); } // only used by R_DrawVoxel
|
||||
__forceinline int32_t DMulScale10(int32_t a, int32_t b, int32_t c, int32_t d) { return (int32_t)(((int64_t)a*b + (int64_t)c*d) >> 10); } // only used by R_DrawVoxel
|
||||
__forceinline int32_t DMulScale18(int32_t a, int32_t b, int32_t c, int32_t d) { return (int32_t)(((int64_t)a*b + (int64_t)c*d) >> 18); } // only used by R_DrawVoxel
|
||||
__forceinline int32_t DMulScale32(int32_t a, int32_t b, int32_t c, int32_t d) { return (int32_t)(((int64_t)a*b + (int64_t)c*d) >> 32); } // used by R_PointOnSide.
|
||||
|
||||
// Sadly, for divisions this is not true but these are so infrequently used that the C versions are just fine, despite not being fully optimal.
|
||||
__forceinline int32_t DivScale6(int32_t a, int32_t b) { return (int32_t)(((int64_t)a << 6) / b); } // only used by R_DrawVoxel
|
||||
__forceinline int32_t DivScale21(int32_t a, int32_t b) { return (int32_t)(((int64_t)a << 21) / b); } // only used by R_DrawVoxel
|
||||
__forceinline int32_t DivScale30(int32_t a, int32_t b) { return (int32_t)(((int64_t)a << 30) / b); } // only used once in the node builder
|
||||
|
||||
__forceinline void fillshort(void *buff, unsigned int count, WORD clear)
|
||||
{
|
||||
SWORD *b2 = (SWORD *)buff;
|
||||
|
@ -23,14 +81,18 @@ __forceinline void fillshort(void *buff, unsigned int count, WORD clear)
|
|||
|
||||
#include "xs_Float.h"
|
||||
|
||||
inline SDWORD FixedDiv (SDWORD a, SDWORD b)
|
||||
inline int32_t FixedDiv (int32_t a, int32_t b)
|
||||
{
|
||||
if ((DWORD)abs(a) >> (31-16) >= (DWORD)abs (b))
|
||||
if ((uint32_t)abs(a) >> (31-16) >= (uint32_t)abs (b))
|
||||
return (a^b)<0 ? FIXED_MIN : FIXED_MAX;
|
||||
return DivScale16 (a, b);
|
||||
|
||||
return (int32_t)(((int64_t)a << 16) / b);
|
||||
}
|
||||
|
||||
#define FixedMul MulScale16
|
||||
__forceinline int32_t FixedMul(int32_t a, int32_t b)
|
||||
{
|
||||
return (int32_t)(((int64_t)a * b) >> 16);
|
||||
}
|
||||
|
||||
inline fixed_t FloatToFixed(double f)
|
||||
{
|
||||
|
|
186
src/mscinlines.h
186
src/mscinlines.h
|
@ -1,186 +0,0 @@
|
|||
// "Build Engine & Tools" Copyright (c) 1993-1997 Ken Silverman
|
||||
// Ken Silverman's official web site: "http://www.advsys.net/ken"
|
||||
// See the included license file "BUILDLIC.TXT" for license info.
|
||||
//
|
||||
// This file is based on pragmas.h from Ken Silverman's original Build
|
||||
// source code release but is meant for use with Visual C++ instead of
|
||||
// Watcom C.
|
||||
//
|
||||
// Some of the inline assembly has been turned into C code, because VC++
|
||||
// is smart enough to produce code at least as good as Ken's inlines.
|
||||
// The more used functions are still inline assembly, because they do
|
||||
// things that can't really be done in C. (I consider this a bad thing,
|
||||
// because VC++ has considerably poorer support for inline assembly than
|
||||
// Watcom, so it's better to rely on its C optimizer to produce fast code.)
|
||||
//
|
||||
|
||||
|
||||
#include <string.h>
|
||||
#include <stddef.h>
|
||||
|
||||
#pragma warning (disable: 4035)
|
||||
|
||||
__forceinline SDWORD Scale (SDWORD a, SDWORD b, SDWORD c)
|
||||
{
|
||||
__asm mov eax,a
|
||||
__asm imul b
|
||||
__asm idiv c
|
||||
}
|
||||
|
||||
#define MAKECONSTMulScale(s) \
|
||||
__forceinline SDWORD MulScale##s (SDWORD a, SDWORD b) \
|
||||
{ \
|
||||
__asm mov eax,a \
|
||||
__asm imul b \
|
||||
__asm shrd eax,edx,s \
|
||||
}
|
||||
MAKECONSTMulScale(1)
|
||||
MAKECONSTMulScale(2)
|
||||
MAKECONSTMulScale(3)
|
||||
MAKECONSTMulScale(4)
|
||||
MAKECONSTMulScale(5)
|
||||
MAKECONSTMulScale(6)
|
||||
MAKECONSTMulScale(7)
|
||||
MAKECONSTMulScale(8)
|
||||
MAKECONSTMulScale(9)
|
||||
MAKECONSTMulScale(10)
|
||||
MAKECONSTMulScale(11)
|
||||
MAKECONSTMulScale(12)
|
||||
MAKECONSTMulScale(13)
|
||||
MAKECONSTMulScale(14)
|
||||
MAKECONSTMulScale(15)
|
||||
MAKECONSTMulScale(16)
|
||||
MAKECONSTMulScale(17)
|
||||
MAKECONSTMulScale(18)
|
||||
MAKECONSTMulScale(19)
|
||||
MAKECONSTMulScale(20)
|
||||
MAKECONSTMulScale(21)
|
||||
MAKECONSTMulScale(22)
|
||||
MAKECONSTMulScale(23)
|
||||
MAKECONSTMulScale(24)
|
||||
MAKECONSTMulScale(25)
|
||||
MAKECONSTMulScale(26)
|
||||
MAKECONSTMulScale(27)
|
||||
MAKECONSTMulScale(28)
|
||||
MAKECONSTMulScale(29)
|
||||
MAKECONSTMulScale(30)
|
||||
MAKECONSTMulScale(31)
|
||||
#undef MAKECONSTMulScale
|
||||
|
||||
__forceinline SDWORD MulScale32 (SDWORD a, SDWORD b)
|
||||
{
|
||||
__asm mov eax,a
|
||||
__asm imul b
|
||||
__asm mov eax,edx
|
||||
}
|
||||
|
||||
__forceinline DWORD UMulScale16(DWORD a, DWORD b)
|
||||
{
|
||||
__asm mov eax,a
|
||||
__asm mul b
|
||||
__asm shrd eax,edx,16
|
||||
}
|
||||
|
||||
#define MAKECONSTDMulScale(s) \
|
||||
__forceinline SDWORD DMulScale##s (SDWORD a, SDWORD b, SDWORD c, SDWORD d) \
|
||||
{ \
|
||||
__asm mov eax,a \
|
||||
__asm imul b \
|
||||
__asm mov ebx,eax \
|
||||
__asm mov eax,c \
|
||||
__asm mov esi,edx \
|
||||
__asm imul d \
|
||||
__asm add eax,ebx \
|
||||
__asm adc edx,esi \
|
||||
__asm shrd eax,edx,s \
|
||||
}
|
||||
|
||||
MAKECONSTDMulScale(1)
|
||||
MAKECONSTDMulScale(2)
|
||||
MAKECONSTDMulScale(3)
|
||||
MAKECONSTDMulScale(4)
|
||||
MAKECONSTDMulScale(5)
|
||||
MAKECONSTDMulScale(6)
|
||||
MAKECONSTDMulScale(7)
|
||||
MAKECONSTDMulScale(8)
|
||||
MAKECONSTDMulScale(9)
|
||||
MAKECONSTDMulScale(10)
|
||||
MAKECONSTDMulScale(11)
|
||||
MAKECONSTDMulScale(12)
|
||||
MAKECONSTDMulScale(13)
|
||||
MAKECONSTDMulScale(14)
|
||||
MAKECONSTDMulScale(15)
|
||||
MAKECONSTDMulScale(16)
|
||||
MAKECONSTDMulScale(17)
|
||||
MAKECONSTDMulScale(18)
|
||||
MAKECONSTDMulScale(19)
|
||||
MAKECONSTDMulScale(20)
|
||||
MAKECONSTDMulScale(21)
|
||||
MAKECONSTDMulScale(22)
|
||||
MAKECONSTDMulScale(23)
|
||||
MAKECONSTDMulScale(24)
|
||||
MAKECONSTDMulScale(25)
|
||||
MAKECONSTDMulScale(26)
|
||||
MAKECONSTDMulScale(27)
|
||||
MAKECONSTDMulScale(28)
|
||||
MAKECONSTDMulScale(29)
|
||||
MAKECONSTDMulScale(30)
|
||||
MAKECONSTDMulScale(31)
|
||||
#undef MAKCONSTDMulScale
|
||||
|
||||
__forceinline SDWORD DMulScale32 (SDWORD a, SDWORD b, SDWORD c, SDWORD d)
|
||||
{
|
||||
__asm mov eax,a
|
||||
__asm imul b
|
||||
__asm mov ebx,eax
|
||||
__asm mov eax,c
|
||||
__asm mov esi,edx
|
||||
__asm imul d
|
||||
__asm add eax,ebx
|
||||
__asm adc edx,esi
|
||||
__asm mov eax,edx
|
||||
}
|
||||
|
||||
#define MAKECONSTDivScale(s) \
|
||||
__forceinline SDWORD DivScale##s (SDWORD a, SDWORD b) \
|
||||
{ \
|
||||
__asm mov edx,a \
|
||||
__asm sar edx,32-s \
|
||||
__asm mov eax,a \
|
||||
__asm shl eax,s \
|
||||
__asm idiv b \
|
||||
}
|
||||
|
||||
MAKECONSTDivScale(2)
|
||||
MAKECONSTDivScale(3)
|
||||
MAKECONSTDivScale(4)
|
||||
MAKECONSTDivScale(5)
|
||||
MAKECONSTDivScale(6)
|
||||
MAKECONSTDivScale(7)
|
||||
MAKECONSTDivScale(8)
|
||||
MAKECONSTDivScale(9)
|
||||
MAKECONSTDivScale(10)
|
||||
MAKECONSTDivScale(11)
|
||||
MAKECONSTDivScale(12)
|
||||
MAKECONSTDivScale(13)
|
||||
MAKECONSTDivScale(14)
|
||||
MAKECONSTDivScale(15)
|
||||
MAKECONSTDivScale(16)
|
||||
MAKECONSTDivScale(17)
|
||||
MAKECONSTDivScale(18)
|
||||
MAKECONSTDivScale(19)
|
||||
MAKECONSTDivScale(20)
|
||||
MAKECONSTDivScale(21)
|
||||
MAKECONSTDivScale(22)
|
||||
MAKECONSTDivScale(23)
|
||||
MAKECONSTDivScale(24)
|
||||
MAKECONSTDivScale(25)
|
||||
MAKECONSTDivScale(26)
|
||||
MAKECONSTDivScale(27)
|
||||
MAKECONSTDivScale(28)
|
||||
MAKECONSTDivScale(29)
|
||||
MAKECONSTDivScale(30)
|
||||
MAKECONSTDivScale(31)
|
||||
#undef MAKECONSTDivScale
|
||||
|
||||
#pragma warning (default: 4035)
|
|
@ -2001,8 +2001,8 @@ int P_VanillaPointOnLineSide(double x, double y, const line_t* line)
|
|||
auto dx = FloatToFixed(x - line->v1->fX());
|
||||
auto dy = FloatToFixed(y - line->v1->fY());
|
||||
|
||||
auto left = MulScale16( int(delta.Y * 256) , dx );
|
||||
auto right = MulScale16( dy , int(delta.X * 256) );
|
||||
auto left = FixedMul( int(delta.Y * 256) , dx );
|
||||
auto right = FixedMul( dy , int(delta.X * 256) );
|
||||
|
||||
if (right < left)
|
||||
return 0; // front side
|
||||
|
|
|
@ -456,7 +456,7 @@ static bool VOX_ReadSpriteNames(FScanner &sc, TArray<DWORD> &vsprites)
|
|||
}
|
||||
else if (sc.StringLen == 5 && (sc.String[4] = toupper(sc.String[4]), sc.String[4] < 'A' || sc.String[4] >= 'A' + MAX_SPRITE_FRAMES))
|
||||
{
|
||||
sc.ScriptMessage("Sprite frame %s is invalid.\n", sc.String[4]);
|
||||
sc.ScriptMessage("Sprite frame %c is invalid.\n", sc.String[4]);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -61,8 +61,8 @@ public:
|
|||
int MustMatchString(const char * const *strings, size_t stride = sizeof(char*));
|
||||
int GetMessageLine();
|
||||
|
||||
void ScriptError(const char *message, ...);
|
||||
void ScriptMessage(const char *message, ...);
|
||||
void ScriptError(const char *message, ...) GCCPRINTF(2,3);
|
||||
void ScriptMessage(const char *message, ...) GCCPRINTF(2,3);
|
||||
|
||||
bool isText();
|
||||
|
||||
|
@ -155,7 +155,7 @@ struct FScriptPosition
|
|||
FScriptPosition(FString fname, int line);
|
||||
FScriptPosition(FScanner &sc);
|
||||
FScriptPosition &operator=(const FScriptPosition &other);
|
||||
void Message(int severity, const char *message,...) const;
|
||||
void Message(int severity, const char *message,...) const GCCPRINTF(3,4);
|
||||
static void ResetErrorCounter()
|
||||
{
|
||||
WarnCounter = 0;
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
/*
|
||||
** thingdef_expression.cpp
|
||||
** codegen.cpp
|
||||
**
|
||||
** Expression evaluation
|
||||
** Compiler backend / code generation for ZScript and DECORATE
|
||||
**
|
||||
**---------------------------------------------------------------------------
|
||||
** Copyright 2008 Christoph Oelckers
|
||||
** Copyright 2008-2016 Christoph Oelckers
|
||||
** All rights reserved.
|
||||
**
|
||||
** Redistribution and use in source and binary forms, with or without
|
||||
|
@ -6586,8 +6586,7 @@ ExpEmit FxStructMember::Emit(VMFunctionBuilder *build)
|
|||
|
||||
//==========================================================================
|
||||
//
|
||||
// not really needed at the moment but may become useful with meta properties
|
||||
// and some other class-specific extensions.
|
||||
//
|
||||
//
|
||||
//==========================================================================
|
||||
|
||||
|
|
|
@ -74,7 +74,7 @@ void ZCCCompiler::ProcessClass(ZCC_Class *cnode, PSymbolTreeNode *treenode)
|
|||
}
|
||||
if (cls == nullptr)
|
||||
{
|
||||
Error(cnode, "Class %s cannot be found in the current translation unit.");
|
||||
Error(cnode, "Class %s cannot be found in the current translation unit.", FName(cnode->NodeName).GetChars());
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -135,8 +135,8 @@ private:
|
|||
ZCC_ExprTypeRef *NodeFromSymbolType(PSymbolType *sym, ZCC_Expression *idnode);
|
||||
|
||||
|
||||
void Warn(ZCC_TreeNode *node, const char *msg, ...);
|
||||
void Error(ZCC_TreeNode *node, const char *msg, ...);
|
||||
void Warn(ZCC_TreeNode *node, const char *msg, ...) GCCPRINTF(3,4);
|
||||
void Error(ZCC_TreeNode *node, const char *msg, ...) GCCPRINTF(3,4);
|
||||
void MessageV(ZCC_TreeNode *node, const char *txtcolor, const char *msg, va_list argptr);
|
||||
|
||||
FxExpression *ConvertAST(PStruct *cclass, ZCC_TreeNode *ast);
|
||||
|
|
|
@ -190,7 +190,7 @@ enum
|
|||
VERB_DEBUG
|
||||
};
|
||||
|
||||
void cmsg(int type, int verbosity_level, const char *fmt, ...);
|
||||
void cmsg(int type, int verbosity_level, const char *fmt, ...) GCCPRINTF(3,4);
|
||||
|
||||
|
||||
/*
|
||||
|
|
|
@ -680,17 +680,23 @@ void I_SetWndProc()
|
|||
|
||||
void RestoreConView()
|
||||
{
|
||||
HDC screenDC = GetDC(0);
|
||||
int dpi = GetDeviceCaps(screenDC, LOGPIXELSX);
|
||||
ReleaseDC(0, screenDC);
|
||||
int width = (512 * dpi + 96 / 2) / 96;
|
||||
int height = (384 * dpi + 96 / 2) / 96;
|
||||
|
||||
// Make sure the window has a frame in case it was fullscreened.
|
||||
SetWindowLongPtr (Window, GWL_STYLE, WS_VISIBLE|WS_OVERLAPPEDWINDOW);
|
||||
if (GetWindowLong (Window, GWL_EXSTYLE) & WS_EX_TOPMOST)
|
||||
{
|
||||
SetWindowPos (Window, HWND_BOTTOM, 0, 0, 512, 384,
|
||||
SetWindowPos (Window, HWND_BOTTOM, 0, 0, width, height,
|
||||
SWP_DRAWFRAME | SWP_NOCOPYBITS | SWP_NOMOVE);
|
||||
SetWindowPos (Window, HWND_TOP, 0, 0, 0, 0, SWP_NOCOPYBITS | SWP_NOMOVE | SWP_NOSIZE);
|
||||
}
|
||||
else
|
||||
{
|
||||
SetWindowPos (Window, NULL, 0, 0, 512, 384,
|
||||
SetWindowPos (Window, NULL, 0, 0, width, height,
|
||||
SWP_DRAWFRAME | SWP_NOCOPYBITS | SWP_NOMOVE | SWP_NOZORDER);
|
||||
}
|
||||
|
||||
|
@ -935,8 +941,11 @@ void DoMain (HINSTANCE hInstance)
|
|||
progdir.Truncate((long)strlen(program));
|
||||
progdir.UnlockBuffer();
|
||||
|
||||
width = 512;
|
||||
height = 384;
|
||||
HDC screenDC = GetDC(0);
|
||||
int dpi = GetDeviceCaps(screenDC, LOGPIXELSX);
|
||||
ReleaseDC(0, screenDC);
|
||||
width = (512 * dpi + 96 / 2) / 96;
|
||||
height = (384 * dpi + 96 / 2) / 96;
|
||||
|
||||
// Many Windows structures that specify their size do so with the first
|
||||
// element. DEVMODE is not one of those structures.
|
||||
|
|
|
@ -1375,10 +1375,16 @@ static HCURSOR CreateAlphaCursor(FTexture *cursorpic)
|
|||
HBITMAP color, mono;
|
||||
void *bits;
|
||||
|
||||
// Find closest integer scale factor for the monitor DPI
|
||||
HDC screenDC = GetDC(0);
|
||||
int dpi = GetDeviceCaps(screenDC, LOGPIXELSX);
|
||||
int scale = MAX((dpi + 96 / 2 - 1) / 96, 1);
|
||||
ReleaseDC(0, screenDC);
|
||||
|
||||
memset(&bi, 0, sizeof(bi));
|
||||
bi.bV5Size = sizeof(bi);
|
||||
bi.bV5Width = 32;
|
||||
bi.bV5Height = 32;
|
||||
bi.bV5Width = 32 * scale;
|
||||
bi.bV5Height = 32 * scale;
|
||||
bi.bV5Planes = 1;
|
||||
bi.bV5BitCount = 32;
|
||||
bi.bV5Compression = BI_BITFIELDS;
|
||||
|
@ -1403,7 +1409,7 @@ static HCURSOR CreateAlphaCursor(FTexture *cursorpic)
|
|||
}
|
||||
|
||||
// Create an empty mask bitmap, since CreateIconIndirect requires this.
|
||||
mono = CreateBitmap(32, 32, 1, 1, NULL);
|
||||
mono = CreateBitmap(32 * scale, 32 * scale, 1, 1, NULL);
|
||||
if (mono == NULL)
|
||||
{
|
||||
DeleteObject(color);
|
||||
|
@ -1413,10 +1419,28 @@ static HCURSOR CreateAlphaCursor(FTexture *cursorpic)
|
|||
// Copy cursor to the color bitmap. Note that GDI bitmaps are upside down compared
|
||||
// to normal conventions, so we create the FBitmap pointing at the last row and use
|
||||
// a negative pitch so that CopyTrueColorPixels will use GDI's orientation.
|
||||
FBitmap bmp((BYTE *)bits + 31*32*4, -32*4, 32, 32);
|
||||
cursorpic->CopyTrueColorPixels(&bmp, 0, 0);
|
||||
if (scale == 1)
|
||||
{
|
||||
FBitmap bmp((BYTE *)bits + 31 * 32 * 4, -32 * 4, 32, 32);
|
||||
cursorpic->CopyTrueColorPixels(&bmp, 0, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
TArray<uint32_t> unscaled;
|
||||
unscaled.Resize(32 * 32);
|
||||
FBitmap bmp((BYTE *)&unscaled[0] + 31 * 32 * 4, -32 * 4, 32, 32);
|
||||
cursorpic->CopyTrueColorPixels(&bmp, 0, 0);
|
||||
uint32_t *scaled = (uint32_t*)bits;
|
||||
for (int y = 0; y < 32 * scale; y++)
|
||||
{
|
||||
for (int x = 0; x < 32 * scale; x++)
|
||||
{
|
||||
scaled[x + y * 32 * scale] = unscaled[x / scale + y / scale * 32];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return CreateBitmapCursor(cursorpic->LeftOffset, cursorpic->TopOffset, mono, color);
|
||||
return CreateBitmapCursor(cursorpic->LeftOffset * scale, cursorpic->TopOffset * scale, mono, color);
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
</trustInfo>
|
||||
<asmv3:application xmlns:asmv3="urn:schemas-microsoft-com:asm.v3">
|
||||
<asmv3:windowsSettings xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings">
|
||||
<dpiAware>true</dpiAware>
|
||||
<dpiAware>true/pm</dpiAware>
|
||||
</asmv3:windowsSettings>
|
||||
</asmv3:application>
|
||||
<compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1">
|
||||
|
@ -31,4 +31,4 @@
|
|||
<supportedOS Id="{8e0f7a12-bfb3-4fe8-b9a5-48fd50a15a9a}"/>
|
||||
</application>
|
||||
</compatibility>
|
||||
</assembly>
|
||||
</assembly>
|
||||
|
|
Loading…
Reference in a new issue