ref: 451945e80cc0a51384de0e292c294795733e7696
parent: f956eb9264672be2ac197c9672bbe88f2da3bee8
author: Clownacy <Clownacy@users.noreply.github.com>
date: Sun Sep 1 10:39:16 EDT 2019
Ripped out SDL2, and begun made WinMain ASM-accurate Almost there... see #74.
--- a/msvc2003/CSE2.vcproj
+++ b/msvc2003/CSE2.vcproj
@@ -21,7 +21,7 @@
<Tool
Name="VCCLCompilerTool"
Optimization="0"
- AdditionalIncludeDirectories="SDL2/include;freetype/include"
+ AdditionalIncludeDirectories=""
PreprocessorDefinitions="WIN32;_DEBUG;WINDOWS;NONPORTABLE"
MinimalRebuild="TRUE"
BasicRuntimeChecks="0"
@@ -34,7 +34,7 @@
Name="VCCustomBuildTool"/>
<Tool
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"
LinkIncremental="2"
AdditionalLibraryDirectories=""
@@ -73,7 +73,7 @@
<Tool
Name="VCCLCompilerTool"
Optimization="0"
- AdditionalIncludeDirectories="SDL2/include;freetype/include"
+ AdditionalIncludeDirectories=""
PreprocessorDefinitions="WIN32;NDEBUG;WINDOWS;NONPORTABLE"
MinimalRebuild="TRUE"
RuntimeLibrary="0"
@@ -85,7 +85,7 @@
Name="VCCustomBuildTool"/>
<Tool
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"
LinkIncremental="1"
IgnoreAllDefaultLibraries="FALSE"
@@ -123,7 +123,7 @@
<Tool
Name="VCCLCompilerTool"
Optimization="0"
- AdditionalIncludeDirectories="SDL2/include;freetype/include"
+ AdditionalIncludeDirectories=""
PreprocessorDefinitions="WIN32;NDEBUG;WINDOWS;NONPORTABLE;JAPANESE"
MinimalRebuild="TRUE"
RuntimeLibrary="0"
@@ -135,7 +135,7 @@
Name="VCCustomBuildTool"/>
<Tool
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"
LinkIncremental="1"
IgnoreAllDefaultLibraries="FALSE"
@@ -173,7 +173,7 @@
<Tool
Name="VCCLCompilerTool"
Optimization="0"
- AdditionalIncludeDirectories="SDL2/include;freetype/include"
+ AdditionalIncludeDirectories=""
PreprocessorDefinitions="WIN32;_DEBUG;WINDOWS;NONPORTABLE;JAPANESE"
MinimalRebuild="TRUE"
BasicRuntimeChecks="0"
@@ -186,7 +186,7 @@
Name="VCCustomBuildTool"/>
<Tool
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"
LinkIncremental="2"
AdditionalLibraryDirectories=""
--- a/msvc2003/devilution/comparer-config.toml
+++ b/msvc2003/devilution/comparer-config.toml
@@ -783,6 +783,10 @@
addr = 0x4122E0
[[func]]
+name = "WinMain"
+addr = 0x412420
+
+[[func]]
name = "InitMapData2"
addr = 0x413750
--- a/src/Draw.h
+++ b/src/Draw.h
@@ -1,7 +1,5 @@
#pragma once
-#include "SDL.h"
-
#include "WindowsWrapper.h"
#ifndef RGB
@@ -50,6 +48,7 @@
SURFACE_ID_MAX = 40
} SurfaceID;
+void SetWindowPadding(int width, int height);
BOOL Flip_SystemTask(HWND hWnd);
BOOL StartDirectDraw(HWND hWnd, int lMagnification, int lColourDepth);
void EndDirectDraw(HWND hWnd);
--- a/src/Game.cpp
+++ b/src/Game.cpp
@@ -2,9 +2,8 @@
#include <stddef.h>
#include <stdio.h>
+#include <stdlib.h>
-#include "SDL.h"
-
#include "WindowsWrapper.h"
#include "ArmsItem.h"
@@ -53,7 +52,7 @@
int Random(int min, int max)
{
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)
@@ -212,8 +211,8 @@
++gCounter;
}
- wait = SDL_GetTicks(); // The original version used GetTickCount instead
- while (SDL_GetTicks() < wait + 500)
+ wait = GetTickCount();
+ while (GetTickCount() < wait + 500)
{
CortBox(&grcGame, 0x000000);
PutFramePerSecound();
@@ -457,8 +456,8 @@
ChangeMusic(MUS_SILENCE);
// Black screen when option is selected
- wait = SDL_GetTicks(); // The original version used GetTickCount instead
- while (SDL_GetTicks() < wait + 1000)
+ wait = GetTickCount();
+ while (GetTickCount() < wait + 1000)
{
CortBox(&grcGame, 0);
PutFramePerSecound();
--- a/src/Input.cpp
+++ b/src/Input.cpp
@@ -7,8 +7,6 @@
#define DIRECTINPUT_VERSION 0x500
#include <dinput.h>
-#include "SDL.h"
-
#include "WindowsWrapper.h"
typedef struct DirectInputPair
--- a/src/Main.cpp
+++ b/src/Main.cpp
@@ -4,8 +4,7 @@
#include <stdio.h>
#include <string.h>
-#include "SDL.h"
-#include "SDL_syswm.h"
+#include <shlwapi.h>
#include "WindowsWrapper.h"
@@ -22,9 +21,6 @@
#include "Sound.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 gDataPath[MAX_PATH];
@@ -31,32 +27,27 @@
int gJoystickButtonTable[8];
HWND ghWnd;
-BOOL gbUseJoystick = FALSE;
-BOOL bFps = FALSE;
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
-const char *lpWindowName = "洞窟物語エンジン2";
+static const char *lpWindowName = "\x93\xB4\x8C\x41\x95\xA8\x8C\xEA";
#else
-const char *lpWindowName = "Cave Story Engine 2 ~ Doukutsu Monogatari Enjin 2";
+static const char *lpWindowName = "Cave Story ~ Doukutsu Monogatari";
#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
void PutFramePerSecound()
{
@@ -66,7 +57,7 @@
int GetFramePerSecound()
{
- unsigned int current_tick;
+/* unsigned int current_tick;
static BOOL need_new_base_tick = TRUE;
static int frames_this_second;
static int current_frame;
@@ -88,318 +79,279 @@
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
- char *base_path = SDL_GetBasePath();
- strcpy(gModulePath, base_path);
- 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)
+ GetModuleFileNameA(NULL, gModulePath, MAX_PATH);
+ PathRemoveFileSpecA(gModulePath);
// Get path of the data folder
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
+ CONFIG conf;
+ if (!LoadConfigData(&conf))
+ DefaultConfigData(&conf);
- // Initialize SDL
- if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_EVENTS | SDL_INIT_TIMER) >= 0)
+ // Apply keybinds
+ // Swap X and Z buttons
+ switch (conf.attack_button_mode)
{
- // Load configuration
- 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
- {
+ case 0:
gKeyJump = KEY_Z;
gKeyShot = KEY_X;
- }
+ break;
- // Swap Okay and Cancel buttons
- if (conf.ok_button_mode)
- {
- if (conf.ok_button_mode == 1)
- {
- gKeyOk = gKeyShot;
- gKeyCancel = gKeyJump;
- }
- }
- else
- {
+ case 1:
+ gKeyJump = KEY_X;
+ gKeyShot = KEY_Z;
+ break;
+ }
+
+ // Swap Okay and Cancel buttons
+ switch (conf.ok_button_mode)
+ {
+ case 0:
gKeyOk = gKeyJump;
gKeyCancel = gKeyShot;
- }
+ break;
- // Swap left and right weapon switch keys
- if (CheckFileExists("s_reverse"))
- {
- gKeyArms = KEY_ARMSREV;
- gKeyArmsRev = KEY_ARMS;
- }
+ case 1:
+ gKeyOk = gKeyShot;
+ gKeyCancel = gKeyJump;
+ break;
+ }
- // Alternate movement keys
- if (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
- {
+ // Swap left and right weapon switch keys
+ if (CheckFileExists("s_reverse"))
+ {
+ gKeyArms = KEY_ARMSREV;
+ gKeyArmsRev = KEY_ARMS;
+ }
+
+ // Alternate movement keys
+ switch (conf.move_button_mode)
+ {
+ case 0:
gKeyLeft = KEY_LEFT;
gKeyUp = KEY_UP;
gKeyRight = KEY_RIGHT;
gKeyDown = KEY_DOWN;
- }
+ break;
- // Set gamepad inputs
- for (int i = 0; i < 8; i++)
+ case 1:
+ gKeyLeft = KEY_ALT_LEFT;
+ gKeyUp = KEY_ALT_UP;
+ gKeyRight = KEY_ALT_RIGHT;
+ gKeyDown = KEY_ALT_DOWN;
+ break;
+ }
+
+ // Set gamepad inputs
+ for (int i = 0; i < 8; i++)
+ {
+ switch (conf.joystick_button[i])
{
- switch (conf.joystick_button[i])
- {
- case 1:
- gJoystickButtonTable[i] = gKeyJump;
- break;
+ case 1:
+ gJoystickButtonTable[i] = gKeyJump;
+ break;
- case 2:
- gJoystickButtonTable[i] = gKeyShot;
- break;
+ case 2:
+ gJoystickButtonTable[i] = gKeyShot;
+ break;
- case 3:
- gJoystickButtonTable[i] = gKeyArms;
- break;
+ case 3:
+ gJoystickButtonTable[i] = gKeyArms;
+ break;
- case 6:
- gJoystickButtonTable[i] = gKeyArmsRev;
- break;
+ case 6:
+ gJoystickButtonTable[i] = gKeyArmsRev;
+ break;
- case 4:
- gJoystickButtonTable[i] = gKeyItem;
- break;
+ case 4:
+ gJoystickButtonTable[i] = gKeyItem;
+ break;
- case 5:
- gJoystickButtonTable[i] = gKeyMap;
- break;
-
- default:
- continue;
- }
+ case 5:
+ gJoystickButtonTable[i] = gKeyMap;
+ break;
}
+ }
- RECT unused_rect = {0, 0, WINDOW_WIDTH, WINDOW_HEIGHT};
+ RECT unused_rect = {0, 0, WINDOW_WIDTH, WINDOW_HEIGHT};
-/* // Load cursor
- size_t size;
- const unsigned char *data = FindResource("CURSOR_NORMAL", "CURSOR", &size);
+ 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 (data)
- {
- SDL_RWops *fp = SDL_RWFromConstMem(data, size);
+ HWND hWnd;
- 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
+ switch (conf.display_mode)
+ {
+ case 1:
+ case 2:
{
- printf("Failed to load cursor\n");
- }
-*/
- // Get window dimensions and colour depth
- int windowWidth;
- int windowHeight;
- int depth;
+ wndclassex.lpszMenuName = "MENU_MAIN";
+ if (RegisterClassExA(&wndclassex) == 0)
+ {
+ ReleaseMutex(hMutex);
+ return 0;
+ }
- HINSTANCE hinstance;
-
- switch (conf.display_mode)
- {
- case 1:
- case 2:
- // Set window dimensions
- if (conf.display_mode == 1)
- {
- windowWidth = WINDOW_WIDTH;
- 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;
-
- case 0:
- case 3:
- case 4:
- // Set window dimensions
+ // Set window dimensions
+ if (conf.display_mode == 1)
+ {
+ windowWidth = WINDOW_WIDTH;
+ 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);
+ int nWidth = windowWidth + 2 * GetSystemMetrics(7) + 2;
- if (gWindow)
- {
- // Set colour depth
- switch (conf.display_mode)
- {
- case 0:
- depth = 16;
- break;
- case 3:
- depth = 24;
- break;
- case 4:
- depth = 32;
- break;
- }
+ 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);
- SDL_SysWMinfo wmInfo;
- SDL_VERSION(&wmInfo.version);
- SDL_GetWindowWMInfo(gWindow, &wmInfo);
- ghWnd = wmInfo.info.win.window;
- hinstance = wmInfo.info.win.hinstance;
+ hWnd = CreateWindowExA(0, lpWindowName, lpWindowName, 0x10CA0000u, x, y, nWidth, nHeight, 0, 0, hInstance, 0);
+ ghWnd = hWnd;
- StartDirectDraw(ghWnd, 2, depth);
- bFullscreen = TRUE;
+ if (hWnd == NULL)
+ {
+ ReleaseMutex(hMutex);
+ return 0;
+ }
- SDL_ShowCursor(0);
- }
+ HMENU v18 = GetMenu(hWnd);
- break;
+ if (conf.display_mode == 1)
+ StartDirectDraw(hWnd, 0, 0);
+ else
+ StartDirectDraw(hWnd, 1, 0);
+
+ break;
}
- // Create window
-
-
- if (gWindow)
+ case 0:
+ case 3:
+ case 4:
{
- // Check debug things
- if (CheckFileExists("fps"))
- bFps = TRUE;
+ if (RegisterClassExA(&wndclassex) == 0)
+ {
+ ReleaseMutex(hMutex);
+ return 0;
+ }
-#ifndef WINDOWS
-/* // Load icon
- size_t size;
- const unsigned char *data = FindResource("ICON_MINI", "ICON", &size);
+ // Set window dimensions
+ windowWidth = WINDOW_WIDTH * 2;
+ windowHeight = WINDOW_HEIGHT * 2;
- if (data)
+ SetWindowPadding(0, 0);
+ hWnd = CreateWindowExA(0, lpWindowName, lpWindowName, 0x90080000, 0, 0, GetSystemMetrics(0), GetSystemMetrics(1), 0, 0, hInstance, 0);
+ ghWnd = hWnd;
+ if (hWnd == NULL)
{
- 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);
+ ReleaseMutex(hMutex);
+ return 0;
}
- else
- {
- printf("Failed to load icon\n");
- }*/
-#endif
- // Set rects
- RECT rcLoading = {0, 0, 64, 8};
- RECT rcFull = {0, 0, WINDOW_WIDTH, WINDOW_HEIGHT};
+ // Set colour depth
+ int depth;
- // 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))
+ switch (conf.display_mode)
{
- // Initialize sound
- InitDirectSound(ghWnd);
+ case 0:
+ depth = 16;
+ break;
+ case 3:
+ depth = 24;
+ break;
+ case 4:
+ depth = 32;
+ break;
+ }
- // Initialize joystick
- if (conf.bJoystick && InitDirectInput(hinstance, ghWnd))
- {
- ResetJoystickStatus();
- gbUseJoystick = TRUE;
- }
+ StartDirectDraw(ghWnd, 2, depth);
+ bFullscreen = TRUE;
- // Initialize stuff
- InitTextObject(conf.font_name);
- InitTriangleTable();
+ ShowCursor(0);
+ break;
+ }
+ }
- // Run game code
- Game(ghWnd);
+ // Set rects
+ RECT rcLoading = {0, 0, 64, 8};
+ RECT rcFull = {0, 0, 0, 0};
+ rcFull.right = WINDOW_WIDTH;
+ rcFull.bottom = WINDOW_HEIGHT;
- // End stuff
- EndDirectSound();
- EndTextObject();
- EndDirectDraw(ghWnd);
- }
+ // Load the "LOADING" text
+ BOOL b = MakeSurface_File("Loading", SURFACE_ID_LOADING);
- SDL_DestroyWindow(gWindow);
- }
+ // 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
{
- SDL_Quit();
- return -1;
+ // Initialize sound
+ 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 0;
+ return 1;
}
void InactiveWindow()
@@ -466,7 +418,7 @@
{
// Handle window events
BOOL focusGained = TRUE;
-
+/*
while (SDL_PollEvent(NULL) || !focusGained)
{
SDL_Event event;
@@ -643,7 +595,7 @@
#endif
}
}
-
+*/
// Run joystick code
if (gbUseJoystick)
JoystickProc();
--- a/src/MycParam.cpp
+++ b/src/MycParam.cpp
@@ -2,8 +2,6 @@
#include <stdio.h>
-#include "SDL.h"
-
#include "WindowsWrapper.h"
#include "ArmsItem.h"
--- a/src/Organya.cpp
+++ b/src/Organya.cpp
@@ -12,8 +12,6 @@
#include <dsound.h>
-#include "SDL.h"
-
#include "WindowsWrapper.h"
#include "Sound.h"
--- a/src/PixTone.cpp
+++ b/src/PixTone.cpp
@@ -1,6 +1,7 @@
#include "PixTone.h"
#include <math.h>
+#include <stdlib.h>
#include <string.h>
#include "WindowsWrapper.h"
@@ -53,9 +54,9 @@
gWaveModelTable[4][i] = -0x40;
// White noise wave
- rep_srand(0);
+ srand(0);
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)
--- a/src/Profile.cpp
+++ b/src/Profile.cpp
@@ -4,8 +4,6 @@
#include <stdio.h>
#include <string.h>
-#include "SDL.h"
-
#include "WindowsWrapper.h"
#include "ArmsItem.h"
--- a/src/TextScr.cpp
+++ b/src/TextScr.cpp
@@ -4,8 +4,6 @@
#include <stdlib.h>
#include <string.h>
-#include "SDL.h"
-
#include "WindowsWrapper.h"
#include "ArmsItem.h"
--- a/src/WindowsWrapper.h
+++ b/src/WindowsWrapper.h
@@ -41,7 +41,4 @@
#define MAX_PATH FILENAME_MAX
#endif
-int rep_rand();
-void rep_srand(unsigned int seed);
-
BOOL SystemTask();