Browse Source

Remove more IDA_GARBAGE

SHIWORD compiles to the same as >> 16
pull/25/head
Anders Jenbo 7 years ago
parent
commit
2c8661f969
  1. 4
      DiabloUI/connect.cpp
  2. 4
      DiabloUI/okcancel.cpp
  3. 6
      Source/missiles.cpp
  4. 55
      defs.h

4
DiabloUI/connect.cpp

@ -756,16 +756,14 @@ void __fastcall Connect_SetDiffString(_gamedata *gamedata, const char *str1, cha
size_t v8; // eax
unsigned char v9; // zf
unsigned char v10; // sf
unsigned char v11; // of
int v12; // eax
v7 = strlen(str1);
v8 = v7 + strlen(str2) + 5;
v11 = __OFSUB__(size, v8);
v9 = size == v8;
v10 = (signed int)(size - v8) < 0;
v12 = gamedata->bDiff;
if ((unsigned char)(v10 ^ v11) | v9)
if (v10 | v9)
_itoa(v12, str3, 10);
else
sprintf(str3, "%d\r%s\r%s", v12, str1, str2);

4
DiabloUI/okcancel.cpp

@ -218,7 +218,6 @@ void __stdcall UiMessageBoxCallback(HWND hWnd, char *lpText, LPCSTR lpCaption, U
{
int v4; // eax
unsigned char v5; // sf
unsigned char v6; // of
size_t v7; // eax
char *v8; // eax
int v9; // ecx
@ -242,9 +241,8 @@ void __stdcall UiMessageBoxCallback(HWND hWnd, char *lpText, LPCSTR lpCaption, U
if (v14 != (char *)0xFF000000)
break;
v4 = a5[2] + 1;
v6 = __OFSUB__(a5[2] + 1, 2);
v5 = a5[2]++ - 1 < 0;
if (!(v5 ^ v6)) {
if (!v5) {
v7 = strlen(lpText);
v8 = (char *)SMemAlloc(v7 + 256, "C:\\Src\\Diablo\\DiabloUI\\OkCancel.cpp", 392, 0);
v11 = 0; /* check */

6
Source/missiles.cpp

@ -735,8 +735,8 @@ void __fastcall GetMissilePos(int i)
int v12; // [esp+Ch] [ebp-8h]
v1 = i;
v2 = SHIWORD(missile[v1]._mityoff);
v3 = SHIWORD(missile[v1]._mitxoff);
v2 = missile[v1]._mityoff >> 16;
v3 = missile[v1]._mitxoff >> 16;
v4 = 2 * v2 + v3;
v5 = 2 * v2 - v3;
if (v4 >= 0) {
@ -758,7 +758,7 @@ void __fastcall GetMissilePos(int i)
}
missile[v1]._mix = v8 + missile[v1]._misx;
missile[v1]._miy = v11 + missile[v1]._misy;
missile[v1]._mixoff = SHIWORD(missile[v1]._mitxoff) + 32 * v11 - 32 * v8;
missile[v1]._mixoff = (missile[v1]._mitxoff >> 16) + 32 * v11 - 32 * v8;
missile[v1]._miyoff = v2 - 16 * v11 - 16 * v8;
ChangeLightOff(missile[v1]._mlid, v12 - 8 * v8, v10 - 8 * v11);
}

55
defs.h

@ -94,8 +94,6 @@
#ifndef IDA_GARBAGE
#define IDA_GARBAGE
typedef __int64 int64;
// Partially defined types. They are used when the decompiler does not know
// anything about the type except its size.
#define _BYTE unsigned char
@ -113,31 +111,23 @@ typedef __int64 int64;
#endif
// first unsigned macros:
#define BYTEn(x, n) (*((_BYTE*)&(x)+n))
#define WORDn(x, n) (*((_WORD*)&(x)+n))
#define DWORDn(x, n) (*((_DWORD*)&(x)+n))
#define _LOBYTE(x) BYTEn(x,LOW_IND(x,_BYTE))
#define _LOWORD(x) WORDn(x,LOW_IND(x,_WORD))
#define _HIBYTE(x) BYTEn(x,HIGH_IND(x,_BYTE))
#define _HIWORD(x) WORDn(x,HIGH_IND(x,_WORD))
#define BYTEn(x, n) (*((BYTE*)&(x)+n))
#define WORDn(x, n) (*((WORD*)&(x)+n))
#define _LOBYTE(x) BYTEn(x,LOW_IND(x,BYTE))
#define _LOWORD(x) WORDn(x,LOW_IND(x,WORD))
#define _HIBYTE(x) BYTEn(x,HIGH_IND(x,BYTE))
#define _HIWORD(x) WORDn(x,HIGH_IND(x,WORD))
#define BYTE1(x) BYTEn(x, 1) // byte 1 (counting from 0)
#define BYTE2(x) BYTEn(x, 2)
// now signed macros (the same but with sign extension)
#define SBYTEn(x, n) (*((char*)&(x)+n))
#define SWORDn(x, n) (*((short*)&(x)+n))
#define SLOBYTE(x) SBYTEn(x,LOW_IND(x,char))
#define SHIWORD(x) SWORDn(x,HIGH_IND(x,short))
// Helper functions to represent some assembly instructions.
#ifdef FAST_MEMCPY
#define qmemcpy memcpy
#else
__inline void *qmemcpy(void *dst, const void *src, size_t cnt)
{
char *out = (char *)dst;
@ -148,7 +138,6 @@ __inline void *qmemcpy(void *dst, const void *src, size_t cnt)
}
return dst;
}
#endif
// rotate right
__inline WORD __ROR2__(WORD value, DWORD count)
@ -158,34 +147,4 @@ __inline WORD __ROR2__(WORD value, DWORD count)
return value >> count | value << (16 - count);
}
#ifdef __cplusplus
// sign flag
template <class T>
char __SETS__(T x)
{
if (sizeof(T) == 1)
return char(x) < 0;
if (sizeof(T) == 2)
return short(x) < 0;
if (sizeof(T) == 4)
return int(x) < 0;
return int64(x) < 0;
}
// overflow flag of subtraction (x-y)
template <class T, class U>
char __OFSUB__(T x, U y)
{
if (sizeof(T) < sizeof(U)) {
U x2 = x;
char sx = __SETS__(x2);
return (sx ^ __SETS__(y)) & (sx ^ __SETS__(x2 - y));
} else {
T y2 = y;
char sx = __SETS__(x);
return (sx ^ __SETS__(y2)) & (sx ^ __SETS__(x - y2));
}
}
#endif
#endif /* IDA_GARBAGE */

Loading…
Cancel
Save