Initial SDL implementation very very rough.

This commit is contained in:
Justin Marshall
2020-06-01 18:49:33 -07:00
parent 96416e9ca9
commit c294a35427
8 changed files with 94 additions and 52 deletions
+40 -23
View File
@@ -55,6 +55,7 @@
* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
#include "function.h" #include "function.h"
#include <SDL.h>
/* /*
@@ -471,7 +472,6 @@ KeyNumType GadgetClass::Input(void)
{ {
int mousex, mousey; int mousex, mousey;
KeyNumType key; KeyNumType key;
unsigned flags;
int forced = false; int forced = false;
/* /*
@@ -530,33 +530,50 @@ KeyNumType GadgetClass::Input(void)
** know the position of the mouse at the exact instant when the click occurred ** know the position of the mouse at the exact instant when the click occurred
** rather the the mouse position at the time we get around to this function. ** rather the the mouse position at the time we get around to this function.
*/ */
if (((key&0xFF) == KN_LMOUSE) || ((key&0xFF) == KN_RMOUSE)) { // jmarshall
mousex = Keyboard->MouseQX; static int flags = 0;
mousey = Keyboard->MouseQY; SDL_GetMouseState(&mousex, &mousey);
} else {
mousex = Get_Mouse_X(); if (flags == LEFTRELEASE || flags == RIGHTRELEASE)
mousey = Get_Mouse_Y(); flags = 0;
SDL_Event event;
while (SDL_PollEvent(&event)) {
switch (event.type)
{
case SDL_MOUSEBUTTONDOWN:
if (event.button.button == SDL_BUTTON_LEFT) {
flags = LEFTPRESS;
}
break;
case SDL_MOUSEBUTTONUP:
if (event.button.button == SDL_BUTTON_LEFT) {
flags = LEFTRELEASE;
}
break;
}
} }
// jmarshall end
/* /*
** Set the mouse button state flags. These will be passed to the individual ** Set the mouse button state flags. These will be passed to the individual
** buttons so that they can determine what action to perform (if any). ** buttons so that they can determine what action to perform (if any).
*/ */
flags = 0; //if (key) {
if (key) { // if (key == KN_LMOUSE) {
if (key == KN_LMOUSE) { // flags |= LEFTPRESS;
flags |= LEFTPRESS; // }
} // if (key == KN_RMOUSE) {
if (key == KN_RMOUSE) { // flags |= RIGHTPRESS;
flags |= RIGHTPRESS; // }
} // if (key == (KN_LMOUSE | KN_RLSE_BIT)) {
if (key == (KN_LMOUSE | KN_RLSE_BIT)) { // flags |= LEFTRELEASE;
flags |= LEFTRELEASE; // }
} // if (key == (KN_RMOUSE | KN_RLSE_BIT)) {
if (key == (KN_RMOUSE | KN_RLSE_BIT)) { // flags |= RIGHTRELEASE;
flags |= RIGHTRELEASE; // }
} //}
}
/* /*
** If the mouse wasn't responsible for this key code, then it must be from ** If the mouse wasn't responsible for this key code, then it must be from
+1 -1
View File
@@ -3381,7 +3381,7 @@ static void Init_Mouse(void)
** to set one of our own. ** to set one of our own.
*/ */
#ifdef WIN32 #ifdef WIN32
ShowCursor(false); // ShowCursor(false);
#endif #endif
if (MouseInstalled) { if (MouseInstalled) {
void const * temp_mouse_shapes = MFCD::Retrieve("MOUSE.SHP"); void const * temp_mouse_shapes = MFCD::Retrieve("MOUSE.SHP");
+4 -1
View File
@@ -40,6 +40,8 @@
#include <sys\timeb.h> #include <sys\timeb.h>
#endif #endif
#include <sdl.h>
/***************************** /*****************************
** Function prototypes ** Function prototypes
******************************/ ******************************/
@@ -806,7 +808,8 @@ int Main_Menu(unsigned long )
/* /*
** Get and process player input. ** Get and process player input.
*/ */
input = (KeyNumType)0;
input = commands->Input(); input = commands->Input();
#ifndef FIXIT_VERSION_3 #ifndef FIXIT_VERSION_3
+1 -1
View File
@@ -82,7 +82,7 @@ int WWMessageBox::Process(const char * msg, const char * b1txt, const char * b2t
int curbutton; int curbutton;
TextButtonClass * buttons[3]; TextButtonClass * buttons[3];
void * back; void * back;
BOOL display; // display level BOOL display = TRUE; // display level
int realval[5]; int realval[5];
#ifndef WIN32 #ifndef WIN32
+5 -2
View File
@@ -92,7 +92,7 @@
<FunctionLevelLinking>true</FunctionLevelLinking> <FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions> <IntrinsicFunctions>true</IntrinsicFunctions>
<ConformanceMode>false</ConformanceMode> <ConformanceMode>false</ConformanceMode>
<AdditionalIncludeDirectories>./win32lib</AdditionalIncludeDirectories> <AdditionalIncludeDirectories>../external/sdl2/include;./win32lib</AdditionalIncludeDirectories>
<MultiProcessorCompilation>true</MultiProcessorCompilation> <MultiProcessorCompilation>true</MultiProcessorCompilation>
<WholeProgramOptimization>false</WholeProgramOptimization> <WholeProgramOptimization>false</WholeProgramOptimization>
<PreprocessorDefinitions>WINDOWS_IGNORE_PACKING_MISMATCH;TRUE_FALSE_DEFINED;ENGLISH;WIN32;NDEBUG;_WINDOWS;_USRDLL;REDALERT_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions> <PreprocessorDefinitions>WINDOWS_IGNORE_PACKING_MISMATCH;TRUE_FALSE_DEFINED;ENGLISH;WIN32;NDEBUG;_WINDOWS;_USRDLL;REDALERT_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
@@ -120,7 +120,7 @@
<WarningLevel>Level3</WarningLevel> <WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization> <Optimization>Disabled</Optimization>
<ConformanceMode>false</ConformanceMode> <ConformanceMode>false</ConformanceMode>
<AdditionalIncludeDirectories>./win32lib</AdditionalIncludeDirectories> <AdditionalIncludeDirectories>../external/sdl2/include;./win32lib</AdditionalIncludeDirectories>
<SDLCheck>false</SDLCheck> <SDLCheck>false</SDLCheck>
<MultiProcessorCompilation>true</MultiProcessorCompilation> <MultiProcessorCompilation>true</MultiProcessorCompilation>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat> <DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
@@ -782,6 +782,9 @@
<ItemGroup> <ItemGroup>
<ResourceCompile Include="Resource\RedAlert.rc" /> <ResourceCompile Include="Resource\RedAlert.rc" />
</ItemGroup> </ItemGroup>
<ItemGroup>
<Library Include="..\external\sdl2\lib\x86\SDL2.lib" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" /> <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets"> <ImportGroup Label="ExtensionTargets">
<Import Project="$(VCTargetsPath)\BuildCustomizations\masm.targets" /> <Import Project="$(VCTargetsPath)\BuildCustomizations\masm.targets" />
+8
View File
@@ -19,6 +19,9 @@
<Filter Include="Source Files\Resource"> <Filter Include="Source Files\Resource">
<UniqueIdentifier>{f4599de7-e877-410c-943f-afc4bef70eb6}</UniqueIdentifier> <UniqueIdentifier>{f4599de7-e877-410c-943f-afc4bef70eb6}</UniqueIdentifier>
</Filter> </Filter>
<Filter Include="Source Files\sdl">
<UniqueIdentifier>{3254aa87-c780-4496-a35f-35ab3a6d4cc1}</UniqueIdentifier>
</Filter>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ClCompile Include="AADATA.CPP"> <ClCompile Include="AADATA.CPP">
@@ -1839,4 +1842,9 @@
<Filter>Source Files\Resource</Filter> <Filter>Source Files\Resource</Filter>
</ResourceCompile> </ResourceCompile>
</ItemGroup> </ItemGroup>
<ItemGroup>
<Library Include="..\external\sdl2\lib\x86\SDL2.lib">
<Filter>Source Files\sdl</Filter>
</Library>
</ItemGroup>
</Project> </Project>
+6 -6
View File
@@ -702,18 +702,18 @@ extern int DLLForceMouseY;
int Get_Mouse_X(void) int Get_Mouse_X(void)
{ {
if (DLLForceMouseX >= 0) { //if (DLLForceMouseX >= 0) {
return DLLForceMouseX; // return DLLForceMouseX;
} //}
if (!_Mouse) return(0); if (!_Mouse) return(0);
return(_Mouse->Get_Mouse_X()); return(_Mouse->Get_Mouse_X());
} }
int Get_Mouse_Y(void) int Get_Mouse_Y(void)
{ {
if (DLLForceMouseY >= 0) { //if (DLLForceMouseY >= 0) {
return DLLForceMouseY; // return DLLForceMouseY;
} //}
if (!_Mouse) return(0); if (!_Mouse) return(0);
return(_Mouse->Get_Mouse_Y()); return(_Mouse->Get_Mouse_Y());
+29 -18
View File
@@ -51,9 +51,13 @@
#include "ipx95.h" #include "ipx95.h"
#endif //WINSOCK_IPX #endif //WINSOCK_IPX
#include <SDL.h>
#include <SDL_syswm.h>
void output(short,short) void output(short,short)
{} {}
SDL_Window* game_window;
unsigned long CCFocusMessage = WM_USER+50; //Private message for receiving application focus unsigned long CCFocusMessage = WM_USER+50; //Private message for receiving application focus
extern void VQA_PauseAudio(void); extern void VQA_PauseAudio(void);
@@ -455,24 +459,31 @@ void Create_Main_Window ( HANDLE instance , int command_show , int width , int h
// //
// Create our main window // Create our main window
// //
hwnd = CreateWindowEx ( // hwnd = CreateWindowEx (
WS_EX_TOPMOST, // WS_EX_TOPMOST,
WINDOW_NAME, // WINDOW_NAME,
WINDOW_NAME, // WINDOW_NAME,
WS_POPUP, // Denzil | WS_MAXIMIZE, // WS_POPUP, // Denzil | WS_MAXIMIZE,
0, // 0,
0, // 0,
// Denzil 5/18/98 - Making window fullscreen prevents other apps // // Denzil 5/18/98 - Making window fullscreen prevents other apps
// from getting WM_PAINT messages // // from getting WM_PAINT messages
// jmarshall //// jmarshall
width, //width, // width, //width,
height, //height, // height, //height,
// jmarshall end //// jmarshall end
// End Denzil // // End Denzil
NULL, // NULL,
NULL, // NULL,
(HINSTANCE)instance, // (HINSTANCE)instance,
NULL ); // NULL );
SDL_Init(SDL_INIT_VIDEO);
game_window = SDL_CreateWindow(WINDOW_NAME, SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, width, height, SDL_WINDOW_SHOWN);
SDL_SysWMinfo wmInfo;
SDL_VERSION(&wmInfo.version);
SDL_GetWindowWMInfo(game_window, &wmInfo);
hwnd = wmInfo.info.win.window;
GameInFocus = TRUE;
ShowWindow (hwnd, command_show ); ShowWindow (hwnd, command_show );
ShowCommand = command_show; ShowCommand = command_show;