Ripped out SDL2, and begun made WinMain ASM-accurate

Almost there... see #74.
This commit is contained in:
Clownacy 2019-09-01 14:39:16 +01:00
parent f956eb9264
commit 451945e80c
12 changed files with 265 additions and 323 deletions

View file

@ -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=""

View file

@ -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

View file

@ -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);

View file

@ -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();

View file

@ -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

View file

@ -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,66 +79,62 @@ 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
// Set the window icons. See res/ICON/ICON.rc.
// SDL_SetHint(SDL_HINT_WINDOWS_INTRESOURCE_ICON, "101");
// SDL_SetHint(SDL_HINT_WINDOWS_INTRESOURCE_ICON_SMALL, "102");
#endif
// Initialize SDL
if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_EVENTS | SDL_INIT_TIMER) >= 0)
{
// Load configuration
CONFIG conf; CONFIG conf;
if (!LoadConfigData(&conf)) if (!LoadConfigData(&conf))
DefaultConfigData(&conf); DefaultConfigData(&conf);
// Apply keybinds // Apply keybinds
// Swap X and Z buttons // Swap X and Z buttons
if (conf.attack_button_mode) switch (conf.attack_button_mode)
{
if (conf.attack_button_mode == 1)
{
gKeyJump = KEY_X;
gKeyShot = KEY_Z;
}
}
else
{ {
case 0:
gKeyJump = KEY_Z; gKeyJump = KEY_Z;
gKeyShot = KEY_X; gKeyShot = KEY_X;
break;
case 1:
gKeyJump = KEY_X;
gKeyShot = KEY_Z;
break;
} }
// Swap Okay and Cancel buttons // Swap Okay and Cancel buttons
if (conf.ok_button_mode) switch (conf.ok_button_mode)
{
if (conf.ok_button_mode == 1)
{
gKeyOk = gKeyShot;
gKeyCancel = gKeyJump;
}
}
else
{ {
case 0:
gKeyOk = gKeyJump; gKeyOk = gKeyJump;
gKeyCancel = gKeyShot; gKeyCancel = gKeyShot;
break;
case 1:
gKeyOk = gKeyShot;
gKeyCancel = gKeyJump;
break;
} }
// Swap left and right weapon switch keys // Swap left and right weapon switch keys
@ -158,22 +145,21 @@ int main(int argc, char *argv[])
} }
// Alternate movement keys // Alternate movement keys
if (conf.move_button_mode) switch (conf.move_button_mode)
{
if (conf.move_button_mode == 1)
{
gKeyLeft = KEY_ALT_LEFT;
gKeyUp = KEY_ALT_UP;
gKeyRight = KEY_ALT_RIGHT;
gKeyDown = KEY_ALT_DOWN;
}
}
else
{ {
case 0:
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;
case 1:
gKeyLeft = KEY_ALT_LEFT;
gKeyUp = KEY_ALT_UP;
gKeyRight = KEY_ALT_RIGHT;
gKeyDown = KEY_ALT_DOWN;
break;
} }
// Set gamepad inputs // Set gamepad inputs
@ -204,50 +190,36 @@ int main(int argc, char *argv[])
case 5: case 5:
gJoystickButtonTable[i] = gKeyMap; gJoystickButtonTable[i] = gKeyMap;
break; break;
default:
continue;
} }
} }
RECT unused_rect = {0, 0, WINDOW_WIDTH, WINDOW_HEIGHT}; RECT unused_rect = {0, 0, WINDOW_WIDTH, WINDOW_HEIGHT};
/* // Load cursor WNDCLASSEXA wndclassex;
size_t size; memset(&wndclassex, 0, sizeof(WNDCLASSEXA));
const unsigned char *data = FindResource("CURSOR_NORMAL", "CURSOR", &size); 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 (data) HWND hWnd;
{
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) switch (conf.display_mode)
{ {
case 1: case 1:
case 2: case 2:
{
wndclassex.lpszMenuName = "MENU_MAIN";
if (RegisterClassExA(&wndclassex) == 0)
{
ReleaseMutex(hMutex);
return 0;
}
// Set window dimensions // Set window dimensions
if (conf.display_mode == 1) if (conf.display_mode == 1)
{ {
@ -260,38 +232,58 @@ int main(int argc, char *argv[])
windowHeight = WINDOW_HEIGHT * 2; windowHeight = WINDOW_HEIGHT * 2;
} }
// Create window int nWidth = windowWidth + 2 * GetSystemMetrics(7) + 2;
gWindow = SDL_CreateWindow(lpWindowName, SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, windowWidth, windowHeight, 0);
if (gWindow) 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)
{ {
SDL_SysWMinfo wmInfo; ReleaseMutex(hMutex);
SDL_VERSION(&wmInfo.version); return 0;
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);
} }
HMENU v18 = GetMenu(hWnd);
if (conf.display_mode == 1)
StartDirectDraw(hWnd, 0, 0);
else
StartDirectDraw(hWnd, 1, 0);
break; break;
}
case 0: case 0:
case 3: case 3:
case 4: case 4:
{
if (RegisterClassExA(&wndclassex) == 0)
{
ReleaseMutex(hMutex);
return 0;
}
// Set window dimensions // Set window dimensions
windowWidth = WINDOW_WIDTH * 2; windowWidth = WINDOW_WIDTH * 2;
windowHeight = WINDOW_HEIGHT * 2; windowHeight = WINDOW_HEIGHT * 2;
// Create window SetWindowPadding(0, 0);
gWindow = SDL_CreateWindow(lpWindowName, SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, windowWidth, windowHeight, 0); hWnd = CreateWindowExA(0, lpWindowName, lpWindowName, 0x90080000, 0, 0, GetSystemMetrics(0), GetSystemMetrics(1), 0, 0, hInstance, 0);
ghWnd = hWnd;
if (gWindow) if (hWnd == NULL)
{ {
ReleaseMutex(hMutex);
return 0;
}
// Set colour depth // Set colour depth
int depth;
switch (conf.display_mode) switch (conf.display_mode)
{ {
case 0: case 0:
@ -305,72 +297,40 @@ int main(int argc, char *argv[])
break; 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); StartDirectDraw(ghWnd, 2, depth);
bFullscreen = TRUE; bFullscreen = TRUE;
SDL_ShowCursor(0); ShowCursor(0);
}
break; break;
} }
// Create window
if (gWindow)
{
// Check debug things
if (CheckFileExists("fps"))
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);
SDL_Surface *iconSurf = SDL_LoadBMP_RW(fp, 1);
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);
SDL_LowerBlitScaled(iconConverted, NULL, iconSurfUpscaled, NULL);
SDL_FreeSurface(iconConverted);
SDL_SetWindowIcon(gWindow, iconSurfUpscaled);
SDL_FreeSurface(iconSurfUpscaled);
} }
else
{
printf("Failed to load icon\n");
}*/
#endif
// Set rects // Set rects
RECT rcLoading = {0, 0, 64, 8}; RECT rcLoading = {0, 0, 64, 8};
RECT rcFull = {0, 0, WINDOW_WIDTH, WINDOW_HEIGHT}; RECT rcFull = {0, 0, 0, 0};
rcFull.right = WINDOW_WIDTH;
rcFull.bottom = WINDOW_HEIGHT;
// Load the "LOADING" text // Load the "LOADING" text
MakeSurface_File("Loading", SURFACE_ID_LOADING); BOOL b = MakeSurface_File("Loading", SURFACE_ID_LOADING);
// Draw loading screen // Draw loading screen
CortBox(&rcFull, 0x000000); CortBox(&rcFull, 0x000000);
PutBitmap3(&rcFull, (WINDOW_WIDTH - 64) / 2, (WINDOW_HEIGHT - 8) / 2, &rcLoading, SURFACE_ID_LOADING); PutBitmap3(&rcFull, (WINDOW_WIDTH - 64) / 2, (WINDOW_HEIGHT - 8) / 2, &rcLoading, SURFACE_ID_LOADING);
// Draw to screen // Draw to screen
if (Flip_SystemTask(ghWnd)) if (!Flip_SystemTask(ghWnd))
{
ReleaseMutex(hMutex);
return 1;
}
else
{ {
// Initialize sound // Initialize sound
InitDirectSound(ghWnd); InitDirectSound(hWnd);
// Initialize joystick // Initialize joystick
if (conf.bJoystick && InitDirectInput(hinstance, ghWnd)) if (conf.bJoystick && InitDirectInput(hInstance, hWnd))
{ {
ResetJoystickStatus(); ResetJoystickStatus();
gbUseJoystick = TRUE; gbUseJoystick = TRUE;
@ -381,25 +341,17 @@ int main(int argc, char *argv[])
InitTriangleTable(); InitTriangleTable();
// Run game code // Run game code
Game(ghWnd); Game(hWnd);
// End stuff // End stuff
EndDirectSound(); EndDirectSound();
EndTextObject(); EndTextObject();
EndDirectDraw(ghWnd); EndDirectDraw(hWnd);
ReleaseMutex(hMutex);
} }
SDL_DestroyWindow(gWindow); return 1;
}
}
else
{
SDL_Quit();
return -1;
}
SDL_Quit();
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();

View file

@ -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"

View file

@ -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"

View file

@ -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)

View file

@ -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"

View file

@ -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"

View file

@ -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();