Ripped out SDL2, and begun made WinMain ASM-accurate
Almost there... see #74.
This commit is contained in:
parent
f956eb9264
commit
451945e80c
12 changed files with 265 additions and 323 deletions
|
@ -21,7 +21,7 @@
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCCLCompilerTool"
|
Name="VCCLCompilerTool"
|
||||||
Optimization="0"
|
Optimization="0"
|
||||||
AdditionalIncludeDirectories="SDL2/include;freetype/include"
|
AdditionalIncludeDirectories=""
|
||||||
PreprocessorDefinitions="WIN32;_DEBUG;WINDOWS;NONPORTABLE"
|
PreprocessorDefinitions="WIN32;_DEBUG;WINDOWS;NONPORTABLE"
|
||||||
MinimalRebuild="TRUE"
|
MinimalRebuild="TRUE"
|
||||||
BasicRuntimeChecks="0"
|
BasicRuntimeChecks="0"
|
||||||
|
@ -34,7 +34,7 @@
|
||||||
Name="VCCustomBuildTool"/>
|
Name="VCCustomBuildTool"/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCLinkerTool"
|
Name="VCLinkerTool"
|
||||||
AdditionalDependencies="SDL2/lib/SDL2.lib SDL2/lib/SDL2main.lib freetype/lib/freetype.lib Version.lib dsound.lib WinMM.lib dxguid.lib dinput.lib ddraw.lib"
|
AdditionalDependencies="Version.lib dsound.lib WinMM.lib dxguid.lib dinput.lib ddraw.lib ShLwApi.Lib"
|
||||||
OutputFile="$(OutDir)\$(ProjectName).exe"
|
OutputFile="$(OutDir)\$(ProjectName).exe"
|
||||||
LinkIncremental="2"
|
LinkIncremental="2"
|
||||||
AdditionalLibraryDirectories=""
|
AdditionalLibraryDirectories=""
|
||||||
|
@ -73,7 +73,7 @@
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCCLCompilerTool"
|
Name="VCCLCompilerTool"
|
||||||
Optimization="0"
|
Optimization="0"
|
||||||
AdditionalIncludeDirectories="SDL2/include;freetype/include"
|
AdditionalIncludeDirectories=""
|
||||||
PreprocessorDefinitions="WIN32;NDEBUG;WINDOWS;NONPORTABLE"
|
PreprocessorDefinitions="WIN32;NDEBUG;WINDOWS;NONPORTABLE"
|
||||||
MinimalRebuild="TRUE"
|
MinimalRebuild="TRUE"
|
||||||
RuntimeLibrary="0"
|
RuntimeLibrary="0"
|
||||||
|
@ -85,7 +85,7 @@
|
||||||
Name="VCCustomBuildTool"/>
|
Name="VCCustomBuildTool"/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCLinkerTool"
|
Name="VCLinkerTool"
|
||||||
AdditionalDependencies="SDL2/lib/SDL2.lib SDL2/lib/SDL2main.lib freetype/lib/freetype.lib Version.lib dsound.lib WinMM.lib dxguid.lib dinput.lib ddraw.lib"
|
AdditionalDependencies="Version.lib dsound.lib WinMM.lib dxguid.lib dinput.lib ddraw.lib ShLwApi.Lib"
|
||||||
OutputFile="$(OutDir)\$(ProjectName).exe"
|
OutputFile="$(OutDir)\$(ProjectName).exe"
|
||||||
LinkIncremental="1"
|
LinkIncremental="1"
|
||||||
IgnoreAllDefaultLibraries="FALSE"
|
IgnoreAllDefaultLibraries="FALSE"
|
||||||
|
@ -123,7 +123,7 @@
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCCLCompilerTool"
|
Name="VCCLCompilerTool"
|
||||||
Optimization="0"
|
Optimization="0"
|
||||||
AdditionalIncludeDirectories="SDL2/include;freetype/include"
|
AdditionalIncludeDirectories=""
|
||||||
PreprocessorDefinitions="WIN32;NDEBUG;WINDOWS;NONPORTABLE;JAPANESE"
|
PreprocessorDefinitions="WIN32;NDEBUG;WINDOWS;NONPORTABLE;JAPANESE"
|
||||||
MinimalRebuild="TRUE"
|
MinimalRebuild="TRUE"
|
||||||
RuntimeLibrary="0"
|
RuntimeLibrary="0"
|
||||||
|
@ -135,7 +135,7 @@
|
||||||
Name="VCCustomBuildTool"/>
|
Name="VCCustomBuildTool"/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCLinkerTool"
|
Name="VCLinkerTool"
|
||||||
AdditionalDependencies="SDL2/lib/SDL2.lib SDL2/lib/SDL2main.lib freetype/lib/freetype.lib Version.lib dsound.lib WinMM.lib dxguid.lib dinput.lib ddraw.lib"
|
AdditionalDependencies="Version.lib dsound.lib WinMM.lib dxguid.lib dinput.lib ddraw.lib ShLwApi.Lib"
|
||||||
OutputFile="$(OutDir)\$(ProjectName).exe"
|
OutputFile="$(OutDir)\$(ProjectName).exe"
|
||||||
LinkIncremental="1"
|
LinkIncremental="1"
|
||||||
IgnoreAllDefaultLibraries="FALSE"
|
IgnoreAllDefaultLibraries="FALSE"
|
||||||
|
@ -173,7 +173,7 @@
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCCLCompilerTool"
|
Name="VCCLCompilerTool"
|
||||||
Optimization="0"
|
Optimization="0"
|
||||||
AdditionalIncludeDirectories="SDL2/include;freetype/include"
|
AdditionalIncludeDirectories=""
|
||||||
PreprocessorDefinitions="WIN32;_DEBUG;WINDOWS;NONPORTABLE;JAPANESE"
|
PreprocessorDefinitions="WIN32;_DEBUG;WINDOWS;NONPORTABLE;JAPANESE"
|
||||||
MinimalRebuild="TRUE"
|
MinimalRebuild="TRUE"
|
||||||
BasicRuntimeChecks="0"
|
BasicRuntimeChecks="0"
|
||||||
|
@ -186,7 +186,7 @@
|
||||||
Name="VCCustomBuildTool"/>
|
Name="VCCustomBuildTool"/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCLinkerTool"
|
Name="VCLinkerTool"
|
||||||
AdditionalDependencies="SDL2/lib/SDL2.lib SDL2/lib/SDL2main.lib freetype/lib/freetype.lib Version.lib dsound.lib WinMM.lib dxguid.lib dinput.lib ddraw.lib"
|
AdditionalDependencies="Version.lib dsound.lib WinMM.lib dxguid.lib dinput.lib ddraw.lib ShLwApi.Lib"
|
||||||
OutputFile="$(OutDir)\$(ProjectName).exe"
|
OutputFile="$(OutDir)\$(ProjectName).exe"
|
||||||
LinkIncremental="2"
|
LinkIncremental="2"
|
||||||
AdditionalLibraryDirectories=""
|
AdditionalLibraryDirectories=""
|
||||||
|
|
|
@ -782,6 +782,10 @@ addr = 0x412250
|
||||||
name = "GetTrg"
|
name = "GetTrg"
|
||||||
addr = 0x4122E0
|
addr = 0x4122E0
|
||||||
|
|
||||||
|
[[func]]
|
||||||
|
name = "WinMain"
|
||||||
|
addr = 0x412420
|
||||||
|
|
||||||
[[func]]
|
[[func]]
|
||||||
name = "InitMapData2"
|
name = "InitMapData2"
|
||||||
addr = 0x413750
|
addr = 0x413750
|
||||||
|
|
|
@ -1,7 +1,5 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "SDL.h"
|
|
||||||
|
|
||||||
#include "WindowsWrapper.h"
|
#include "WindowsWrapper.h"
|
||||||
|
|
||||||
#ifndef RGB
|
#ifndef RGB
|
||||||
|
@ -50,6 +48,7 @@ typedef enum SurfaceID
|
||||||
SURFACE_ID_MAX = 40
|
SURFACE_ID_MAX = 40
|
||||||
} SurfaceID;
|
} SurfaceID;
|
||||||
|
|
||||||
|
void SetWindowPadding(int width, int height);
|
||||||
BOOL Flip_SystemTask(HWND hWnd);
|
BOOL Flip_SystemTask(HWND hWnd);
|
||||||
BOOL StartDirectDraw(HWND hWnd, int lMagnification, int lColourDepth);
|
BOOL StartDirectDraw(HWND hWnd, int lMagnification, int lColourDepth);
|
||||||
void EndDirectDraw(HWND hWnd);
|
void EndDirectDraw(HWND hWnd);
|
||||||
|
|
13
src/Game.cpp
13
src/Game.cpp
|
@ -2,8 +2,7 @@
|
||||||
|
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
#include "SDL.h"
|
|
||||||
|
|
||||||
#include "WindowsWrapper.h"
|
#include "WindowsWrapper.h"
|
||||||
|
|
||||||
|
@ -53,7 +52,7 @@ BOOL bContinue;
|
||||||
int Random(int min, int max)
|
int Random(int min, int max)
|
||||||
{
|
{
|
||||||
const int range = max - min + 1;
|
const int range = max - min + 1;
|
||||||
return min + rep_rand() % range;
|
return min + rand() % range;
|
||||||
}
|
}
|
||||||
|
|
||||||
void PutNumber4(int x, int y, int value, BOOL bZero)
|
void PutNumber4(int x, int y, int value, BOOL bZero)
|
||||||
|
@ -212,8 +211,8 @@ int ModeOpening(HWND hWnd)
|
||||||
++gCounter;
|
++gCounter;
|
||||||
}
|
}
|
||||||
|
|
||||||
wait = SDL_GetTicks(); // The original version used GetTickCount instead
|
wait = GetTickCount();
|
||||||
while (SDL_GetTicks() < wait + 500)
|
while (GetTickCount() < wait + 500)
|
||||||
{
|
{
|
||||||
CortBox(&grcGame, 0x000000);
|
CortBox(&grcGame, 0x000000);
|
||||||
PutFramePerSecound();
|
PutFramePerSecound();
|
||||||
|
@ -457,8 +456,8 @@ int ModeTitle(HWND hWnd)
|
||||||
ChangeMusic(MUS_SILENCE);
|
ChangeMusic(MUS_SILENCE);
|
||||||
|
|
||||||
// Black screen when option is selected
|
// Black screen when option is selected
|
||||||
wait = SDL_GetTicks(); // The original version used GetTickCount instead
|
wait = GetTickCount();
|
||||||
while (SDL_GetTicks() < wait + 1000)
|
while (GetTickCount() < wait + 1000)
|
||||||
{
|
{
|
||||||
CortBox(&grcGame, 0);
|
CortBox(&grcGame, 0);
|
||||||
PutFramePerSecound();
|
PutFramePerSecound();
|
||||||
|
|
|
@ -7,8 +7,6 @@
|
||||||
#define DIRECTINPUT_VERSION 0x500
|
#define DIRECTINPUT_VERSION 0x500
|
||||||
#include <dinput.h>
|
#include <dinput.h>
|
||||||
|
|
||||||
#include "SDL.h"
|
|
||||||
|
|
||||||
#include "WindowsWrapper.h"
|
#include "WindowsWrapper.h"
|
||||||
|
|
||||||
typedef struct DirectInputPair
|
typedef struct DirectInputPair
|
||||||
|
|
534
src/Main.cpp
534
src/Main.cpp
|
@ -4,8 +4,7 @@
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#include "SDL.h"
|
#include <shlwapi.h>
|
||||||
#include "SDL_syswm.h"
|
|
||||||
|
|
||||||
#include "WindowsWrapper.h"
|
#include "WindowsWrapper.h"
|
||||||
|
|
||||||
|
@ -22,41 +21,33 @@
|
||||||
#include "Sound.h"
|
#include "Sound.h"
|
||||||
#include "Triangle.h"
|
#include "Triangle.h"
|
||||||
|
|
||||||
// These two are defined in Draw.cpp. This is a bit of a hack.
|
|
||||||
SDL_Window *gWindow;
|
|
||||||
|
|
||||||
char gModulePath[MAX_PATH];
|
char gModulePath[MAX_PATH];
|
||||||
char gDataPath[MAX_PATH];
|
char gDataPath[MAX_PATH];
|
||||||
|
|
||||||
int gJoystickButtonTable[8];
|
int gJoystickButtonTable[8];
|
||||||
|
|
||||||
HWND ghWnd;
|
HWND ghWnd;
|
||||||
BOOL gbUseJoystick = FALSE;
|
|
||||||
BOOL bFps = FALSE;
|
|
||||||
BOOL bFullscreen;
|
BOOL bFullscreen;
|
||||||
|
|
||||||
BOOL bActive = TRUE;
|
static BOOL gbUseJoystick = FALSE;
|
||||||
|
static BOOL bFps = FALSE;
|
||||||
|
static BOOL bActive = TRUE;
|
||||||
|
|
||||||
|
static HANDLE hObject;
|
||||||
|
static HANDLE hMutex;
|
||||||
|
static HINSTANCE ghInstance;
|
||||||
|
|
||||||
|
static int windowWidth;
|
||||||
|
static int windowHeight;
|
||||||
|
|
||||||
|
static const char *mutex_name = "Doukutsu";
|
||||||
|
|
||||||
#ifdef JAPANESE
|
#ifdef JAPANESE
|
||||||
const char *lpWindowName = "洞窟物語エンジン2";
|
static const char *lpWindowName = "\x93\xB4\x8C\x41\x95\xA8\x8C\xEA";
|
||||||
#else
|
#else
|
||||||
const char *lpWindowName = "Cave Story Engine 2 ~ Doukutsu Monogatari Enjin 2";
|
static const char *lpWindowName = "Cave Story ~ Doukutsu Monogatari";
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// A replication of MSVC's rand algorithm
|
|
||||||
static unsigned long next = 1;
|
|
||||||
|
|
||||||
int rep_rand()
|
|
||||||
{
|
|
||||||
next = ((next) * 214013 + 2531011);
|
|
||||||
return ((next) >> 16) & 0x7FFF;
|
|
||||||
}
|
|
||||||
|
|
||||||
void rep_srand(unsigned int seed)
|
|
||||||
{
|
|
||||||
next = seed;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Framerate stuff
|
// Framerate stuff
|
||||||
void PutFramePerSecound()
|
void PutFramePerSecound()
|
||||||
{
|
{
|
||||||
|
@ -66,7 +57,7 @@ void PutFramePerSecound()
|
||||||
|
|
||||||
int GetFramePerSecound()
|
int GetFramePerSecound()
|
||||||
{
|
{
|
||||||
unsigned int current_tick;
|
/* unsigned int current_tick;
|
||||||
static BOOL need_new_base_tick = TRUE;
|
static BOOL need_new_base_tick = TRUE;
|
||||||
static int frames_this_second;
|
static int frames_this_second;
|
||||||
static int current_frame;
|
static int current_frame;
|
||||||
|
@ -88,318 +79,279 @@ int GetFramePerSecound()
|
||||||
current_frame = 0;
|
current_frame = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
return frames_this_second;
|
return frames_this_second;*/
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(int argc, char *argv[])
|
int __stdcall WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nShowCmd)
|
||||||
{
|
{
|
||||||
|
hObject = OpenMutexA(MUTEX_ALL_ACCESS, 0, mutex_name);
|
||||||
|
if (hObject != NULL)
|
||||||
|
{
|
||||||
|
CloseHandle(hObject);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
hMutex = CreateMutexA(NULL, FALSE, mutex_name);
|
||||||
|
|
||||||
|
ghInstance = hInstance;
|
||||||
|
|
||||||
// Get executable's path
|
// Get executable's path
|
||||||
char *base_path = SDL_GetBasePath();
|
GetModuleFileNameA(NULL, gModulePath, MAX_PATH);
|
||||||
strcpy(gModulePath, base_path);
|
PathRemoveFileSpecA(gModulePath);
|
||||||
SDL_free(base_path);
|
|
||||||
if (gModulePath[strlen(gModulePath) - 1] == '/' || gModulePath[strlen(gModulePath) - 1] == '\\')
|
|
||||||
gModulePath[strlen(gModulePath) - 1] = '\0'; // String cannot end in slash or stuff will probably break (original does this through a windows.h provided function)
|
|
||||||
|
|
||||||
// Get path of the data folder
|
// Get path of the data folder
|
||||||
strcpy(gDataPath, gModulePath);
|
strcpy(gDataPath, gModulePath);
|
||||||
strcat(gDataPath, "/data");
|
strcat(gDataPath, "\\data");
|
||||||
|
|
||||||
#ifdef WINDOWS
|
CONFIG conf;
|
||||||
// Set the window icons. See res/ICON/ICON.rc.
|
if (!LoadConfigData(&conf))
|
||||||
// SDL_SetHint(SDL_HINT_WINDOWS_INTRESOURCE_ICON, "101");
|
DefaultConfigData(&conf);
|
||||||
// SDL_SetHint(SDL_HINT_WINDOWS_INTRESOURCE_ICON_SMALL, "102");
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// Initialize SDL
|
// Apply keybinds
|
||||||
if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_EVENTS | SDL_INIT_TIMER) >= 0)
|
// Swap X and Z buttons
|
||||||
|
switch (conf.attack_button_mode)
|
||||||
{
|
{
|
||||||
// Load configuration
|
case 0:
|
||||||
CONFIG conf;
|
|
||||||
|
|
||||||
if (!LoadConfigData(&conf))
|
|
||||||
DefaultConfigData(&conf);
|
|
||||||
|
|
||||||
// Apply keybinds
|
|
||||||
// Swap X and Z buttons
|
|
||||||
if (conf.attack_button_mode)
|
|
||||||
{
|
|
||||||
if (conf.attack_button_mode == 1)
|
|
||||||
{
|
|
||||||
gKeyJump = KEY_X;
|
|
||||||
gKeyShot = KEY_Z;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
gKeyJump = KEY_Z;
|
gKeyJump = KEY_Z;
|
||||||
gKeyShot = KEY_X;
|
gKeyShot = KEY_X;
|
||||||
}
|
break;
|
||||||
|
|
||||||
// Swap Okay and Cancel buttons
|
case 1:
|
||||||
if (conf.ok_button_mode)
|
gKeyJump = KEY_X;
|
||||||
{
|
gKeyShot = KEY_Z;
|
||||||
if (conf.ok_button_mode == 1)
|
break;
|
||||||
{
|
}
|
||||||
gKeyOk = gKeyShot;
|
|
||||||
gKeyCancel = gKeyJump;
|
// Swap Okay and Cancel buttons
|
||||||
}
|
switch (conf.ok_button_mode)
|
||||||
}
|
{
|
||||||
else
|
case 0:
|
||||||
{
|
|
||||||
gKeyOk = gKeyJump;
|
gKeyOk = gKeyJump;
|
||||||
gKeyCancel = gKeyShot;
|
gKeyCancel = gKeyShot;
|
||||||
}
|
break;
|
||||||
|
|
||||||
// Swap left and right weapon switch keys
|
case 1:
|
||||||
if (CheckFileExists("s_reverse"))
|
gKeyOk = gKeyShot;
|
||||||
{
|
gKeyCancel = gKeyJump;
|
||||||
gKeyArms = KEY_ARMSREV;
|
break;
|
||||||
gKeyArmsRev = KEY_ARMS;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// Alternate movement keys
|
// Swap left and right weapon switch keys
|
||||||
if (conf.move_button_mode)
|
if (CheckFileExists("s_reverse"))
|
||||||
{
|
{
|
||||||
if (conf.move_button_mode == 1)
|
gKeyArms = KEY_ARMSREV;
|
||||||
{
|
gKeyArmsRev = KEY_ARMS;
|
||||||
gKeyLeft = KEY_ALT_LEFT;
|
}
|
||||||
gKeyUp = KEY_ALT_UP;
|
|
||||||
gKeyRight = KEY_ALT_RIGHT;
|
// Alternate movement keys
|
||||||
gKeyDown = KEY_ALT_DOWN;
|
switch (conf.move_button_mode)
|
||||||
}
|
{
|
||||||
}
|
case 0:
|
||||||
else
|
|
||||||
{
|
|
||||||
gKeyLeft = KEY_LEFT;
|
gKeyLeft = KEY_LEFT;
|
||||||
gKeyUp = KEY_UP;
|
gKeyUp = KEY_UP;
|
||||||
gKeyRight = KEY_RIGHT;
|
gKeyRight = KEY_RIGHT;
|
||||||
gKeyDown = KEY_DOWN;
|
gKeyDown = KEY_DOWN;
|
||||||
}
|
break;
|
||||||
|
|
||||||
// Set gamepad inputs
|
case 1:
|
||||||
for (int i = 0; i < 8; i++)
|
gKeyLeft = KEY_ALT_LEFT;
|
||||||
{
|
gKeyUp = KEY_ALT_UP;
|
||||||
switch (conf.joystick_button[i])
|
gKeyRight = KEY_ALT_RIGHT;
|
||||||
{
|
gKeyDown = KEY_ALT_DOWN;
|
||||||
case 1:
|
break;
|
||||||
gJoystickButtonTable[i] = gKeyJump;
|
}
|
||||||
break;
|
|
||||||
|
|
||||||
case 2:
|
// Set gamepad inputs
|
||||||
gJoystickButtonTable[i] = gKeyShot;
|
for (int i = 0; i < 8; i++)
|
||||||
break;
|
{
|
||||||
|
switch (conf.joystick_button[i])
|
||||||
case 3:
|
|
||||||
gJoystickButtonTable[i] = gKeyArms;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 6:
|
|
||||||
gJoystickButtonTable[i] = gKeyArmsRev;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 4:
|
|
||||||
gJoystickButtonTable[i] = gKeyItem;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 5:
|
|
||||||
gJoystickButtonTable[i] = gKeyMap;
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
RECT unused_rect = {0, 0, WINDOW_WIDTH, WINDOW_HEIGHT};
|
|
||||||
|
|
||||||
/* // Load cursor
|
|
||||||
size_t size;
|
|
||||||
const unsigned char *data = FindResource("CURSOR_NORMAL", "CURSOR", &size);
|
|
||||||
|
|
||||||
if (data)
|
|
||||||
{
|
|
||||||
SDL_RWops *fp = SDL_RWFromConstMem(data, size);
|
|
||||||
|
|
||||||
SDL_Surface *cursor_surface = SDL_LoadBMP_RW(fp, 1);
|
|
||||||
SDL_SetColorKey(cursor_surface, SDL_TRUE, SDL_MapRGB(cursor_surface->format, 0xFF, 0, 0xFF)); // Pink regions are transparent
|
|
||||||
|
|
||||||
SDL_Cursor *cursor = SDL_CreateColorCursor(cursor_surface, 0, 0); // Don't worry, the hotspots are accurate to the original files
|
|
||||||
|
|
||||||
if (cursor)
|
|
||||||
SDL_SetCursor(cursor);
|
|
||||||
else
|
|
||||||
printf("Failed to load cursor\n");
|
|
||||||
|
|
||||||
SDL_FreeSurface(cursor_surface);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
printf("Failed to load cursor\n");
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
// Get window dimensions and colour depth
|
|
||||||
int windowWidth;
|
|
||||||
int windowHeight;
|
|
||||||
int depth;
|
|
||||||
|
|
||||||
HINSTANCE hinstance;
|
|
||||||
|
|
||||||
switch (conf.display_mode)
|
|
||||||
{
|
{
|
||||||
case 1:
|
case 1:
|
||||||
case 2:
|
gJoystickButtonTable[i] = gKeyJump;
|
||||||
// Set window dimensions
|
break;
|
||||||
if (conf.display_mode == 1)
|
|
||||||
{
|
case 2:
|
||||||
windowWidth = WINDOW_WIDTH;
|
gJoystickButtonTable[i] = gKeyShot;
|
||||||
windowHeight = WINDOW_HEIGHT;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
windowWidth = WINDOW_WIDTH * 2;
|
|
||||||
windowHeight = WINDOW_HEIGHT * 2;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Create window
|
|
||||||
gWindow = SDL_CreateWindow(lpWindowName, SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, windowWidth, windowHeight, 0);
|
|
||||||
|
|
||||||
if (gWindow)
|
|
||||||
{
|
|
||||||
SDL_SysWMinfo wmInfo;
|
|
||||||
SDL_VERSION(&wmInfo.version);
|
|
||||||
SDL_GetWindowWMInfo(gWindow, &wmInfo);
|
|
||||||
ghWnd = wmInfo.info.win.window;
|
|
||||||
hinstance = wmInfo.info.win.hinstance;
|
|
||||||
|
|
||||||
if (conf.display_mode == 1)
|
|
||||||
StartDirectDraw(ghWnd, 0, 0);
|
|
||||||
else
|
|
||||||
StartDirectDraw(ghWnd, 1, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 0:
|
|
||||||
case 3:
|
case 3:
|
||||||
|
gJoystickButtonTable[i] = gKeyArms;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 6:
|
||||||
|
gJoystickButtonTable[i] = gKeyArmsRev;
|
||||||
|
break;
|
||||||
|
|
||||||
case 4:
|
case 4:
|
||||||
// Set window dimensions
|
gJoystickButtonTable[i] = gKeyItem;
|
||||||
windowWidth = WINDOW_WIDTH * 2;
|
break;
|
||||||
windowHeight = WINDOW_HEIGHT * 2;
|
|
||||||
|
|
||||||
// Create window
|
|
||||||
gWindow = SDL_CreateWindow(lpWindowName, SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, windowWidth, windowHeight, 0);
|
|
||||||
|
|
||||||
if (gWindow)
|
|
||||||
{
|
|
||||||
// Set colour depth
|
|
||||||
switch (conf.display_mode)
|
|
||||||
{
|
|
||||||
case 0:
|
|
||||||
depth = 16;
|
|
||||||
break;
|
|
||||||
case 3:
|
|
||||||
depth = 24;
|
|
||||||
break;
|
|
||||||
case 4:
|
|
||||||
depth = 32;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
SDL_SysWMinfo wmInfo;
|
|
||||||
SDL_VERSION(&wmInfo.version);
|
|
||||||
SDL_GetWindowWMInfo(gWindow, &wmInfo);
|
|
||||||
ghWnd = wmInfo.info.win.window;
|
|
||||||
hinstance = wmInfo.info.win.hinstance;
|
|
||||||
|
|
||||||
StartDirectDraw(ghWnd, 2, depth);
|
|
||||||
bFullscreen = TRUE;
|
|
||||||
|
|
||||||
SDL_ShowCursor(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
case 5:
|
||||||
|
gJoystickButtonTable[i] = gKeyMap;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Create window
|
RECT unused_rect = {0, 0, WINDOW_WIDTH, WINDOW_HEIGHT};
|
||||||
|
|
||||||
|
WNDCLASSEXA wndclassex;
|
||||||
|
memset(&wndclassex, 0, sizeof(WNDCLASSEXA));
|
||||||
|
wndclassex.cbSize = sizeof(WNDCLASSEXA);
|
||||||
|
// wndclassex.lpfnWndProc = WindowProcedure;
|
||||||
|
wndclassex.hInstance = hInstance;
|
||||||
|
wndclassex.hbrBackground = (HBRUSH)GetStockObject(3);
|
||||||
|
wndclassex.lpszClassName = lpWindowName;
|
||||||
|
wndclassex.hCursor = LoadCursorA(hInstance, "CURSOR_NORMAL");
|
||||||
|
wndclassex.hIcon = LoadIconA(hInstance, "0");
|
||||||
|
wndclassex.hIconSm = LoadIconA(hInstance, "ICON_MINI");
|
||||||
|
|
||||||
if (gWindow)
|
HWND hWnd;
|
||||||
|
|
||||||
|
switch (conf.display_mode)
|
||||||
|
{
|
||||||
|
case 1:
|
||||||
|
case 2:
|
||||||
{
|
{
|
||||||
// Check debug things
|
wndclassex.lpszMenuName = "MENU_MAIN";
|
||||||
if (CheckFileExists("fps"))
|
if (RegisterClassExA(&wndclassex) == 0)
|
||||||
bFps = TRUE;
|
|
||||||
|
|
||||||
#ifndef WINDOWS
|
|
||||||
/* // Load icon
|
|
||||||
size_t size;
|
|
||||||
const unsigned char *data = FindResource("ICON_MINI", "ICON", &size);
|
|
||||||
|
|
||||||
if (data)
|
|
||||||
{
|
{
|
||||||
SDL_RWops *fp = SDL_RWFromConstMem(data, size);
|
ReleaseMutex(hMutex);
|
||||||
SDL_Surface *iconSurf = SDL_LoadBMP_RW(fp, 1);
|
return 0;
|
||||||
SDL_Surface *iconConverted = SDL_ConvertSurfaceFormat(iconSurf, SDL_PIXELFORMAT_RGB888, 0);
|
}
|
||||||
SDL_FreeSurface(iconSurf);
|
|
||||||
SDL_Surface *iconSurfUpscaled = SDL_CreateRGBSurfaceWithFormat(0, 256, 256, 0, SDL_PIXELFORMAT_RGB888);
|
// Set window dimensions
|
||||||
SDL_LowerBlitScaled(iconConverted, NULL, iconSurfUpscaled, NULL);
|
if (conf.display_mode == 1)
|
||||||
SDL_FreeSurface(iconConverted);
|
{
|
||||||
SDL_SetWindowIcon(gWindow, iconSurfUpscaled);
|
windowWidth = WINDOW_WIDTH;
|
||||||
SDL_FreeSurface(iconSurfUpscaled);
|
windowHeight = WINDOW_HEIGHT;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
printf("Failed to load icon\n");
|
windowWidth = WINDOW_WIDTH * 2;
|
||||||
}*/
|
windowHeight = WINDOW_HEIGHT * 2;
|
||||||
#endif
|
|
||||||
|
|
||||||
// Set rects
|
|
||||||
RECT rcLoading = {0, 0, 64, 8};
|
|
||||||
RECT rcFull = {0, 0, WINDOW_WIDTH, WINDOW_HEIGHT};
|
|
||||||
|
|
||||||
// Load the "LOADING" text
|
|
||||||
MakeSurface_File("Loading", SURFACE_ID_LOADING);
|
|
||||||
|
|
||||||
// Draw loading screen
|
|
||||||
CortBox(&rcFull, 0x000000);
|
|
||||||
PutBitmap3(&rcFull, (WINDOW_WIDTH - 64) / 2, (WINDOW_HEIGHT - 8) / 2, &rcLoading, SURFACE_ID_LOADING);
|
|
||||||
|
|
||||||
// Draw to screen
|
|
||||||
if (Flip_SystemTask(ghWnd))
|
|
||||||
{
|
|
||||||
// Initialize sound
|
|
||||||
InitDirectSound(ghWnd);
|
|
||||||
|
|
||||||
// Initialize joystick
|
|
||||||
if (conf.bJoystick && InitDirectInput(hinstance, ghWnd))
|
|
||||||
{
|
|
||||||
ResetJoystickStatus();
|
|
||||||
gbUseJoystick = TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Initialize stuff
|
|
||||||
InitTextObject(conf.font_name);
|
|
||||||
InitTriangleTable();
|
|
||||||
|
|
||||||
// Run game code
|
|
||||||
Game(ghWnd);
|
|
||||||
|
|
||||||
// End stuff
|
|
||||||
EndDirectSound();
|
|
||||||
EndTextObject();
|
|
||||||
EndDirectDraw(ghWnd);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
SDL_DestroyWindow(gWindow);
|
int nWidth = windowWidth + 2 * GetSystemMetrics(7) + 2;
|
||||||
|
|
||||||
|
int nHeight = (2 * GetSystemMetrics(8) + GetSystemMetrics(4)) + GetSystemMetrics(15) + windowHeight + 2;
|
||||||
|
int x = (GetSystemMetrics(0) - nWidth) / 2;
|
||||||
|
int y = (GetSystemMetrics(1) - nHeight) / 2;
|
||||||
|
SetWindowPadding(GetSystemMetrics(7) + 1, GetSystemMetrics(8) + GetSystemMetrics(4) + GetSystemMetrics(15) + 1);
|
||||||
|
|
||||||
|
hWnd = CreateWindowExA(0, lpWindowName, lpWindowName, 0x10CA0000u, x, y, nWidth, nHeight, 0, 0, hInstance, 0);
|
||||||
|
ghWnd = hWnd;
|
||||||
|
|
||||||
|
if (hWnd == NULL)
|
||||||
|
{
|
||||||
|
ReleaseMutex(hMutex);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
HMENU v18 = GetMenu(hWnd);
|
||||||
|
|
||||||
|
if (conf.display_mode == 1)
|
||||||
|
StartDirectDraw(hWnd, 0, 0);
|
||||||
|
else
|
||||||
|
StartDirectDraw(hWnd, 1, 0);
|
||||||
|
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
case 0:
|
||||||
|
case 3:
|
||||||
|
case 4:
|
||||||
|
{
|
||||||
|
if (RegisterClassExA(&wndclassex) == 0)
|
||||||
|
{
|
||||||
|
ReleaseMutex(hMutex);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Set window dimensions
|
||||||
|
windowWidth = WINDOW_WIDTH * 2;
|
||||||
|
windowHeight = WINDOW_HEIGHT * 2;
|
||||||
|
|
||||||
|
SetWindowPadding(0, 0);
|
||||||
|
hWnd = CreateWindowExA(0, lpWindowName, lpWindowName, 0x90080000, 0, 0, GetSystemMetrics(0), GetSystemMetrics(1), 0, 0, hInstance, 0);
|
||||||
|
ghWnd = hWnd;
|
||||||
|
if (hWnd == NULL)
|
||||||
|
{
|
||||||
|
ReleaseMutex(hMutex);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Set colour depth
|
||||||
|
int depth;
|
||||||
|
|
||||||
|
switch (conf.display_mode)
|
||||||
|
{
|
||||||
|
case 0:
|
||||||
|
depth = 16;
|
||||||
|
break;
|
||||||
|
case 3:
|
||||||
|
depth = 24;
|
||||||
|
break;
|
||||||
|
case 4:
|
||||||
|
depth = 32;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
StartDirectDraw(ghWnd, 2, depth);
|
||||||
|
bFullscreen = TRUE;
|
||||||
|
|
||||||
|
ShowCursor(0);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Set rects
|
||||||
|
RECT rcLoading = {0, 0, 64, 8};
|
||||||
|
RECT rcFull = {0, 0, 0, 0};
|
||||||
|
rcFull.right = WINDOW_WIDTH;
|
||||||
|
rcFull.bottom = WINDOW_HEIGHT;
|
||||||
|
|
||||||
|
// Load the "LOADING" text
|
||||||
|
BOOL b = MakeSurface_File("Loading", SURFACE_ID_LOADING);
|
||||||
|
|
||||||
|
// Draw loading screen
|
||||||
|
CortBox(&rcFull, 0x000000);
|
||||||
|
PutBitmap3(&rcFull, (WINDOW_WIDTH - 64) / 2, (WINDOW_HEIGHT - 8) / 2, &rcLoading, SURFACE_ID_LOADING);
|
||||||
|
|
||||||
|
// Draw to screen
|
||||||
|
if (!Flip_SystemTask(ghWnd))
|
||||||
|
{
|
||||||
|
ReleaseMutex(hMutex);
|
||||||
|
return 1;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
SDL_Quit();
|
// Initialize sound
|
||||||
return -1;
|
InitDirectSound(hWnd);
|
||||||
|
|
||||||
|
// Initialize joystick
|
||||||
|
if (conf.bJoystick && InitDirectInput(hInstance, hWnd))
|
||||||
|
{
|
||||||
|
ResetJoystickStatus();
|
||||||
|
gbUseJoystick = TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Initialize stuff
|
||||||
|
InitTextObject(conf.font_name);
|
||||||
|
InitTriangleTable();
|
||||||
|
|
||||||
|
// Run game code
|
||||||
|
Game(hWnd);
|
||||||
|
|
||||||
|
// End stuff
|
||||||
|
EndDirectSound();
|
||||||
|
EndTextObject();
|
||||||
|
EndDirectDraw(hWnd);
|
||||||
|
|
||||||
|
ReleaseMutex(hMutex);
|
||||||
}
|
}
|
||||||
|
|
||||||
SDL_Quit();
|
return 1;
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void InactiveWindow()
|
void InactiveWindow()
|
||||||
|
@ -466,7 +418,7 @@ BOOL SystemTask()
|
||||||
{
|
{
|
||||||
// Handle window events
|
// Handle window events
|
||||||
BOOL focusGained = TRUE;
|
BOOL focusGained = TRUE;
|
||||||
|
/*
|
||||||
while (SDL_PollEvent(NULL) || !focusGained)
|
while (SDL_PollEvent(NULL) || !focusGained)
|
||||||
{
|
{
|
||||||
SDL_Event event;
|
SDL_Event event;
|
||||||
|
@ -643,7 +595,7 @@ BOOL SystemTask()
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
// Run joystick code
|
// Run joystick code
|
||||||
if (gbUseJoystick)
|
if (gbUseJoystick)
|
||||||
JoystickProc();
|
JoystickProc();
|
||||||
|
|
|
@ -2,8 +2,6 @@
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
#include "SDL.h"
|
|
||||||
|
|
||||||
#include "WindowsWrapper.h"
|
#include "WindowsWrapper.h"
|
||||||
|
|
||||||
#include "ArmsItem.h"
|
#include "ArmsItem.h"
|
||||||
|
|
|
@ -12,8 +12,6 @@
|
||||||
|
|
||||||
#include <dsound.h>
|
#include <dsound.h>
|
||||||
|
|
||||||
#include "SDL.h"
|
|
||||||
|
|
||||||
#include "WindowsWrapper.h"
|
#include "WindowsWrapper.h"
|
||||||
|
|
||||||
#include "Sound.h"
|
#include "Sound.h"
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
#include "PixTone.h"
|
#include "PixTone.h"
|
||||||
|
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#include "WindowsWrapper.h"
|
#include "WindowsWrapper.h"
|
||||||
|
@ -53,9 +54,9 @@ void MakeWaveTables(void)
|
||||||
gWaveModelTable[4][i] = -0x40;
|
gWaveModelTable[4][i] = -0x40;
|
||||||
|
|
||||||
// White noise wave
|
// White noise wave
|
||||||
rep_srand(0);
|
srand(0);
|
||||||
for (i = 0; i < 256; ++i)
|
for (i = 0; i < 256; ++i)
|
||||||
gWaveModelTable[5][i] = (signed char)(rep_rand() & 0xFF) / 2;
|
gWaveModelTable[5][i] = (signed char)(rand() & 0xFF) / 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOL MakePixelWaveData(const PIXTONEPARAMETER *ptp, unsigned char *pData)
|
BOOL MakePixelWaveData(const PIXTONEPARAMETER *ptp, unsigned char *pData)
|
||||||
|
|
|
@ -4,8 +4,6 @@
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#include "SDL.h"
|
|
||||||
|
|
||||||
#include "WindowsWrapper.h"
|
#include "WindowsWrapper.h"
|
||||||
|
|
||||||
#include "ArmsItem.h"
|
#include "ArmsItem.h"
|
||||||
|
|
|
@ -4,8 +4,6 @@
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#include "SDL.h"
|
|
||||||
|
|
||||||
#include "WindowsWrapper.h"
|
#include "WindowsWrapper.h"
|
||||||
|
|
||||||
#include "ArmsItem.h"
|
#include "ArmsItem.h"
|
||||||
|
|
|
@ -41,7 +41,4 @@ struct RECT
|
||||||
#define MAX_PATH FILENAME_MAX
|
#define MAX_PATH FILENAME_MAX
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
int rep_rand();
|
|
||||||
void rep_srand(unsigned int seed);
|
|
||||||
|
|
||||||
BOOL SystemTask();
|
BOOL SystemTask();
|
||||||
|
|
Loading…
Add table
Reference in a new issue