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
|
||||
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=""
|
||||
|
|
|
@ -782,6 +782,10 @@ addr = 0x412250
|
|||
name = "GetTrg"
|
||||
addr = 0x4122E0
|
||||
|
||||
[[func]]
|
||||
name = "WinMain"
|
||||
addr = 0x412420
|
||||
|
||||
[[func]]
|
||||
name = "InitMapData2"
|
||||
addr = 0x413750
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
#pragma once
|
||||
|
||||
#include "SDL.h"
|
||||
|
||||
#include "WindowsWrapper.h"
|
||||
|
||||
#ifndef RGB
|
||||
|
@ -50,6 +48,7 @@ typedef enum SurfaceID
|
|||
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);
|
||||
|
|
13
src/Game.cpp
13
src/Game.cpp
|
@ -2,8 +2,7 @@
|
|||
|
||||
#include <stddef.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include "SDL.h"
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "WindowsWrapper.h"
|
||||
|
||||
|
@ -53,7 +52,7 @@ BOOL bContinue;
|
|||
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 @@ int ModeOpening(HWND hWnd)
|
|||
++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 @@ int ModeTitle(HWND hWnd)
|
|||
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();
|
||||
|
|
|
@ -7,8 +7,6 @@
|
|||
#define DIRECTINPUT_VERSION 0x500
|
||||
#include <dinput.h>
|
||||
|
||||
#include "SDL.h"
|
||||
|
||||
#include "WindowsWrapper.h"
|
||||
|
||||
typedef struct DirectInputPair
|
||||
|
|
318
src/Main.cpp
318
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,41 +21,33 @@
|
|||
#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];
|
||||
|
||||
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 @@ void PutFramePerSecound()
|
|||
|
||||
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,66 +79,62 @@ int GetFramePerSecound()
|
|||
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
|
||||
|
||||
// Initialize SDL
|
||||
if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_EVENTS | SDL_INIT_TIMER) >= 0)
|
||||
{
|
||||
// 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
|
||||
switch (conf.attack_button_mode)
|
||||
{
|
||||
case 0:
|
||||
gKeyJump = KEY_Z;
|
||||
gKeyShot = KEY_X;
|
||||
break;
|
||||
|
||||
case 1:
|
||||
gKeyJump = KEY_X;
|
||||
gKeyShot = KEY_Z;
|
||||
break;
|
||||
}
|
||||
|
||||
// Swap Okay and Cancel buttons
|
||||
if (conf.ok_button_mode)
|
||||
{
|
||||
if (conf.ok_button_mode == 1)
|
||||
{
|
||||
gKeyOk = gKeyShot;
|
||||
gKeyCancel = gKeyJump;
|
||||
}
|
||||
}
|
||||
else
|
||||
switch (conf.ok_button_mode)
|
||||
{
|
||||
case 0:
|
||||
gKeyOk = gKeyJump;
|
||||
gKeyCancel = gKeyShot;
|
||||
break;
|
||||
|
||||
case 1:
|
||||
gKeyOk = gKeyShot;
|
||||
gKeyCancel = gKeyJump;
|
||||
break;
|
||||
}
|
||||
|
||||
// Swap left and right weapon switch keys
|
||||
|
@ -158,22 +145,21 @@ int main(int argc, char *argv[])
|
|||
}
|
||||
|
||||
// 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
|
||||
switch (conf.move_button_mode)
|
||||
{
|
||||
case 0:
|
||||
gKeyLeft = KEY_LEFT;
|
||||
gKeyUp = KEY_UP;
|
||||
gKeyRight = KEY_RIGHT;
|
||||
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
|
||||
|
@ -204,50 +190,36 @@ int main(int argc, char *argv[])
|
|||
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);
|
||||
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);
|
||||
|
||||
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;
|
||||
HWND hWnd;
|
||||
|
||||
switch (conf.display_mode)
|
||||
{
|
||||
case 1:
|
||||
case 2:
|
||||
{
|
||||
wndclassex.lpszMenuName = "MENU_MAIN";
|
||||
if (RegisterClassExA(&wndclassex) == 0)
|
||||
{
|
||||
ReleaseMutex(hMutex);
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Set window dimensions
|
||||
if (conf.display_mode == 1)
|
||||
{
|
||||
|
@ -260,38 +232,58 @@ int main(int argc, char *argv[])
|
|||
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)
|
||||
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;
|
||||
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);
|
||||
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;
|
||||
|
||||
// Create window
|
||||
gWindow = SDL_CreateWindow(lpWindowName, SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, windowWidth, windowHeight, 0);
|
||||
|
||||
if (gWindow)
|
||||
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:
|
||||
|
@ -305,72 +297,40 @@ int main(int argc, char *argv[])
|
|||
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);
|
||||
}
|
||||
|
||||
ShowCursor(0);
|
||||
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
|
||||
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
|
||||
MakeSurface_File("Loading", SURFACE_ID_LOADING);
|
||||
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))
|
||||
if (!Flip_SystemTask(ghWnd))
|
||||
{
|
||||
ReleaseMutex(hMutex);
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Initialize sound
|
||||
InitDirectSound(ghWnd);
|
||||
InitDirectSound(hWnd);
|
||||
|
||||
// Initialize joystick
|
||||
if (conf.bJoystick && InitDirectInput(hinstance, ghWnd))
|
||||
if (conf.bJoystick && InitDirectInput(hInstance, hWnd))
|
||||
{
|
||||
ResetJoystickStatus();
|
||||
gbUseJoystick = TRUE;
|
||||
|
@ -381,25 +341,17 @@ int main(int argc, char *argv[])
|
|||
InitTriangleTable();
|
||||
|
||||
// Run game code
|
||||
Game(ghWnd);
|
||||
Game(hWnd);
|
||||
|
||||
// End stuff
|
||||
EndDirectSound();
|
||||
EndTextObject();
|
||||
EndDirectDraw(ghWnd);
|
||||
EndDirectDraw(hWnd);
|
||||
|
||||
ReleaseMutex(hMutex);
|
||||
}
|
||||
|
||||
SDL_DestroyWindow(gWindow);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
SDL_Quit();
|
||||
return -1;
|
||||
}
|
||||
|
||||
SDL_Quit();
|
||||
return 0;
|
||||
return 1;
|
||||
}
|
||||
|
||||
void InactiveWindow()
|
||||
|
@ -466,7 +418,7 @@ BOOL SystemTask()
|
|||
{
|
||||
// Handle window events
|
||||
BOOL focusGained = TRUE;
|
||||
|
||||
/*
|
||||
while (SDL_PollEvent(NULL) || !focusGained)
|
||||
{
|
||||
SDL_Event event;
|
||||
|
@ -643,7 +595,7 @@ BOOL SystemTask()
|
|||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
*/
|
||||
// Run joystick code
|
||||
if (gbUseJoystick)
|
||||
JoystickProc();
|
||||
|
|
|
@ -2,8 +2,6 @@
|
|||
|
||||
#include <stdio.h>
|
||||
|
||||
#include "SDL.h"
|
||||
|
||||
#include "WindowsWrapper.h"
|
||||
|
||||
#include "ArmsItem.h"
|
||||
|
|
|
@ -12,8 +12,6 @@
|
|||
|
||||
#include <dsound.h>
|
||||
|
||||
#include "SDL.h"
|
||||
|
||||
#include "WindowsWrapper.h"
|
||||
|
||||
#include "Sound.h"
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
#include "PixTone.h"
|
||||
|
||||
#include <math.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "WindowsWrapper.h"
|
||||
|
@ -53,9 +54,9 @@ void MakeWaveTables(void)
|
|||
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)
|
||||
|
|
|
@ -4,8 +4,6 @@
|
|||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "SDL.h"
|
||||
|
||||
#include "WindowsWrapper.h"
|
||||
|
||||
#include "ArmsItem.h"
|
||||
|
|
|
@ -4,8 +4,6 @@
|
|||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "SDL.h"
|
||||
|
||||
#include "WindowsWrapper.h"
|
||||
|
||||
#include "ArmsItem.h"
|
||||
|
|
|
@ -41,7 +41,4 @@ struct RECT
|
|||
#define MAX_PATH FILENAME_MAX
|
||||
#endif
|
||||
|
||||
int rep_rand();
|
||||
void rep_srand(unsigned int seed);
|
||||
|
||||
BOOL SystemTask();
|
||||
|
|
Loading…
Add table
Reference in a new issue