Skip to content

Commit

Permalink
- Backend update from GZDoom.
Browse files Browse the repository at this point in the history
  • Loading branch information
coelckers committed Jul 20, 2022
1 parent 6b4561f commit a4d2347
Show file tree
Hide file tree
Showing 17 changed files with 77 additions and 188 deletions.
8 changes: 4 additions & 4 deletions source/common/2d/v_draw.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -682,13 +682,13 @@ static inline FSpecialColormap * ListGetSpecialColormap(VMVa_List &tags)
//==========================================================================

template<class T>
bool ParseDrawTextureTags(F2DDrawer *drawer, FGameTexture *img, double x, double y, uint32_t tag, T& tags, DrawParms *parms, bool fortext)
bool ParseDrawTextureTags(F2DDrawer *drawer, FGameTexture *img, double x, double y, uint32_t tag, T& tags, DrawParms *parms, bool fortext, bool checkimage)
{
INTBOOL boolval;
int intval;
bool fillcolorset = false;

if (!fortext)
if (!fortext && checkimage)
{
if (img == NULL || !img->isValid())
{
Expand Down Expand Up @@ -1285,8 +1285,8 @@ bool ParseDrawTextureTags(F2DDrawer *drawer, FGameTexture *img, double x, double
}
// explicitly instantiate both versions for v_text.cpp.

template bool ParseDrawTextureTags<Va_List>(F2DDrawer* drawer, FGameTexture *img, double x, double y, uint32_t tag, Va_List& tags, DrawParms *parms, bool fortext);
template bool ParseDrawTextureTags<VMVa_List>(F2DDrawer* drawer, FGameTexture *img, double x, double y, uint32_t tag, VMVa_List& tags, DrawParms *parms, bool fortext);
template bool ParseDrawTextureTags<Va_List>(F2DDrawer* drawer, FGameTexture *img, double x, double y, uint32_t tag, Va_List& tags, DrawParms *parms, bool fortext, bool checkimage);
template bool ParseDrawTextureTags<VMVa_List>(F2DDrawer* drawer, FGameTexture *img, double x, double y, uint32_t tag, VMVa_List& tags, DrawParms *parms, bool fortext, bool checkimage);

//==========================================================================
//
Expand Down
2 changes: 1 addition & 1 deletion source/common/2d/v_draw.h
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ inline int active_con_scale(F2DDrawer *drawer)
#endif

template<class T>
bool ParseDrawTextureTags(F2DDrawer *drawer, FGameTexture* img, double x, double y, uint32_t tag, T& tags, DrawParms* parms, bool fortext);
bool ParseDrawTextureTags(F2DDrawer *drawer, FGameTexture* img, double x, double y, uint32_t tag, T& tags, DrawParms* parms, bool fortext, bool checkimage = true);

template<class T>
void DrawTextCommon(F2DDrawer *drawer, FFont* font, int normalcolor, double x, double y, const T* string, DrawParms& parms);
Expand Down
4 changes: 3 additions & 1 deletion source/common/console/c_console.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,9 @@ bool vidactive = false;
bool cursoron = false;
int ConBottom, ConScroll, RowAdjust;
uint64_t CursorTicker;
constate_e ConsoleState = c_up;
uint8_t ConsoleState = c_up;

DEFINE_GLOBAL(ConsoleState)

static int TopLine, InsertLine;

Expand Down
7 changes: 3 additions & 4 deletions source/common/console/c_console.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,19 +41,18 @@

struct event_t;

typedef enum cstate_t
enum cstate_t : uint8_t
{
c_up=0, c_down=1, c_falling=2, c_rising=3
}
constate_e;
};

enum
{
PRINTLEVELS = 5
};
extern int PrintColors[PRINTLEVELS + 2];

extern constate_e ConsoleState;
extern uint8_t ConsoleState;

// Initialize the console
void C_InitConsole (int width, int height, bool ingame);
Expand Down
5 changes: 1 addition & 4 deletions source/common/engine/renderstyle.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,7 @@
#undef OPAQUE
#endif

enum
{
OPAQUE = 65536,
};
constexpr int OPAQUE = 65536;

enum ETexMode
{
Expand Down
1 change: 0 additions & 1 deletion source/common/platform/posix/cocoa/i_input.mm
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@
CVAR(Bool, k_allowfullscreentoggle, true, CVAR_ARCHIVE | CVAR_GLOBALCONFIG)

extern int paused, chatmodeon;
extern constate_e ConsoleState;
extern bool ToggleFullscreen;
bool GUICapture;

Expand Down
1 change: 0 additions & 1 deletion source/common/platform/posix/sdl/i_input.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ CVAR (Bool, use_mouse, true, CVAR_ARCHIVE|CVAR_GLOBALCONFIG)


extern int WaitingForKey, chatmodeon;
extern constate_e ConsoleState;

static const SDL_Keycode DIKToKeySym[256] =
{
Expand Down
66 changes: 4 additions & 62 deletions source/common/platform/win32/i_input.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,6 @@ FJoystickCollection *JoyDevices[NUM_JOYDEVICES];


extern HINSTANCE g_hInst;
static HMODULE DInputDLL;

bool GUICapture;
extern FMouse *Mouse;
Expand All @@ -116,7 +115,6 @@ extern BOOL paused;
static bool noidle = false;

LPDIRECTINPUT8 g_pdi;
LPDIRECTINPUT g_pdi3;

extern bool AppActive;

Expand Down Expand Up @@ -523,58 +521,12 @@ bool I_InitInput (void *hwnd)

noidle = !!Args->CheckParm ("-noidle");
g_pdi = NULL;
g_pdi3 = NULL;

// Try for DirectInput 8 first, then DirectInput 3 for NT 4's benefit.
DInputDLL = LoadLibraryA("dinput8.dll");
if (DInputDLL != NULL)
hr = DirectInput8Create(g_hInst, DIRECTINPUT_VERSION, IID_IDirectInput8, (void **)&g_pdi, NULL);
if (FAILED(hr))
{
typedef HRESULT (WINAPI *blah)(HINSTANCE, DWORD, REFIID, LPVOID *, LPUNKNOWN);
blah di8c = (blah)GetProcAddress(DInputDLL, "DirectInput8Create");
if (di8c != NULL)
{
hr = di8c(g_hInst, DIRECTINPUT_VERSION, IID_IDirectInput8, (void **)&g_pdi, NULL);
if (FAILED(hr))
{
Printf(TEXTCOLOR_ORANGE "DirectInput8Create failed: %08lx\n", hr);
g_pdi = NULL; // Just to be sure DirectInput8Create didn't change it
}
}
else
{
Printf(TEXTCOLOR_ORANGE "Could not find DirectInput8Create in dinput8.dll\n");
}
}

if (g_pdi == NULL)
{
if (DInputDLL != NULL)
{
FreeLibrary(DInputDLL);
}
DInputDLL = LoadLibraryA ("dinput.dll");
if (DInputDLL == NULL)
{
I_FatalError ("Could not load dinput.dll: %08lx", GetLastError());
}

typedef HRESULT (WINAPI *blah)(HINSTANCE, DWORD, LPDIRECTINPUT*, LPUNKNOWN);
#ifdef UNICODE
blah dic = (blah)GetProcAddress (DInputDLL, "DirectInputCreateW");
#else
blah dic = (blah)GetProcAddress(DInputDLL, "DirectInputCreateA");
#endif

if (dic == NULL)
{
I_FatalError ("dinput.dll is corrupt");
}

hr = dic (g_hInst, 0x0300, &g_pdi3, NULL);
if (FAILED(hr))
{
I_FatalError ("DirectInputCreate failed: %08lx", hr);
}
Printf(TEXTCOLOR_ORANGE "DirectInput8Create failed: %08lx\n", hr);
g_pdi = NULL; // Just to be sure DirectInput8Create didn't change it
}

Printf ("I_StartupMouse\n");
Expand Down Expand Up @@ -622,16 +574,6 @@ void I_ShutdownInput ()
g_pdi->Release ();
g_pdi = NULL;
}
if (g_pdi3)
{
g_pdi3->Release ();
g_pdi3 = NULL;
}
if (DInputDLL != NULL)
{
FreeLibrary (DInputDLL);
DInputDLL = NULL;
}
}

void I_GetEvent ()
Expand Down
11 changes: 3 additions & 8 deletions source/common/platform/win32/i_keyboard.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,6 @@ class FRawKeyboard : public FKeyboard
// EXTERNAL DATA DECLARATIONS ----------------------------------------------

extern LPDIRECTINPUT8 g_pdi;
extern LPDIRECTINPUT g_pdi3;
extern bool GUICapture;

// PRIVATE DATA DEFINITIONS ------------------------------------------------
Expand Down Expand Up @@ -320,17 +319,13 @@ bool FDInputKeyboard::GetDevice()
{
HRESULT hr;

if (g_pdi3 != NULL)
{ // DirectInput3 interface
hr = g_pdi3->CreateDevice(GUID_SysKeyboard, (LPDIRECTINPUTDEVICE*)&Device, NULL);
}
else if (g_pdi != NULL)
if (g_pdi != NULL)
{ // DirectInput8 interface
hr = g_pdi->CreateDevice(GUID_SysKeyboard, &Device, NULL);
}
else
{
hr = -1;
hr = E_FAIL;
}
if (FAILED(hr))
{
Expand Down Expand Up @@ -383,7 +378,7 @@ void FDInputKeyboard::ProcessInput()

for (;;)
{
DWORD cbObjectData = g_pdi3 ? sizeof(DIDEVICEOBJECTDATA_DX3) : sizeof(DIDEVICEOBJECTDATA);
DWORD cbObjectData = sizeof(DIDEVICEOBJECTDATA);
dwElements = 1;
hr = Device->GetDeviceData(cbObjectData, &od, &dwElements, 0);
if (hr == DIERR_INPUTLOST || hr == DIERR_NOTACQUIRED)
Expand Down
23 changes: 10 additions & 13 deletions source/common/platform/win32/i_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@

#include <processenv.h>
#include <shellapi.h>
#include <VersionHelpers.h>

#ifdef _MSC_VER
#pragma warning(disable:4244)
Expand Down Expand Up @@ -179,33 +180,29 @@ int DoMain (HINSTANCE hInstance)
StdOut = NULL;
}
}
if (StdOut == NULL)
if (StdOut == nullptr)
{
if (AttachConsole(ATTACH_PARENT_PROCESS))
{
StdOut = GetStdHandle(STD_OUTPUT_HANDLE);
DWORD foo; WriteFile(StdOut, "\n", 1, &foo, NULL);
AttachedStdOut = true;
}
if (StdOut == NULL && AllocConsole())
if (StdOut == nullptr && AllocConsole())
{
StdOut = GetStdHandle(STD_OUTPUT_HANDLE);
}

// Deprecated stuff for legacy consoles. As of now this is still relevant, but this code can be removed once Windows 7 is no longer relevant.
CONSOLE_FONT_INFOEX cfi;
cfi.cbSize = sizeof(cfi);
if (GetCurrentConsoleFontEx(StdOut, false, &cfi))
if (StdOut != nullptr)
{
if (*cfi.FaceName == 0) // If the face name is empty, the default (useless) raster font is actoive.
SetConsoleCP(CP_UTF8);
SetConsoleOutputCP(CP_UTF8);
DWORD mode;
if (GetConsoleMode(StdOut, &mode))
{
//cfi.dwFontSize = { 8, 14 };
wcscpy(cfi.FaceName, L"Lucida Console");
cfi.FontFamily = FF_DONTCARE;
SetCurrentConsoleFontEx(StdOut, false, &cfi);
if (SetConsoleMode(StdOut, mode | ENABLE_VIRTUAL_TERMINAL_PROCESSING))
FancyStdOut = IsWindows10OrGreater(); // Windows 8.1 and lower do not understand ANSI formatting.
}
}
FancyStdOut = true;
}
}

Expand Down
11 changes: 3 additions & 8 deletions source/common/platform/win32/i_mouse.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,6 @@ static void CenterMouse(int x, int y, LONG *centx, LONG *centy);
// EXTERNAL DATA DECLARATIONS ----------------------------------------------

extern LPDIRECTINPUT8 g_pdi;
extern LPDIRECTINPUT g_pdi3;
extern bool GUICapture;
extern int BlockMouseMove;

Expand Down Expand Up @@ -680,17 +679,13 @@ bool FDInputMouse::GetDevice()
{
HRESULT hr;

if (g_pdi3 != NULL)
{ // DirectInput3 interface
hr = g_pdi3->CreateDevice(GUID_SysMouse, (LPDIRECTINPUTDEVICE*)&Device, NULL);
}
else if (g_pdi != NULL)
if (g_pdi != NULL)
{ // DirectInput8 interface
hr = g_pdi->CreateDevice(GUID_SysMouse, &Device, NULL);
}
else
{
hr = -1;
hr = E_FAIL;
}
if (FAILED(hr))
{
Expand Down Expand Up @@ -783,7 +778,7 @@ void FDInputMouse::ProcessInput()
event_t ev = { 0 };
for (;;)
{
DWORD cbObjectData = g_pdi3 ? sizeof(DIDEVICEOBJECTDATA_DX3) : sizeof(DIDEVICEOBJECTDATA);
DWORD cbObjectData = sizeof(DIDEVICEOBJECTDATA);
dwElements = 1;
hr = Device->GetDeviceData(cbObjectData, &od, &dwElements, 0);
if (hr == DIERR_INPUTLOST || hr == DIERR_NOTACQUIRED)
Expand Down
Loading

0 comments on commit a4d2347

Please sign in to comment.