diff --git a/CMakeLists.txt b/CMakeLists.txt
index 625694de0..b955f60c4 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -143,9 +143,9 @@ feature_summary(WHAT DISABLED_FEATURES DESCRIPTION "Disabled features:")
add_subdirectory(src/Libraries/)
set(MAC_SRC
+ src/MacSrc/SDLFunctions.c
src/MacSrc/ShockBitmap.c
src/MacSrc/InitMac.c
- src/MacSrc/Shock.c
src/MacSrc/Prefs.c
src/MacSrc/MacTune.c
src/MacSrc/SDLSound.c
@@ -275,6 +275,10 @@ set(GAME_SRC
src/GameSrc/mouselook.c
)
+set(SHOCK_SRC
+ src/ShockSrc/Shock.cpp
+)
+
include_directories(
src/Libraries/2D/Source
src/Libraries/3D/Source
@@ -297,6 +301,7 @@ include_directories(
src/GameSrc/Headers
src/MacSrc
src/MusicSrc
+ src/ShockSrc
${CMAKE_BINARY_DIR}/src/GameSrc/Headers
)
@@ -381,6 +386,7 @@ add_definitions(
add_executable(systemshock
${MAC_SRC}
+ ${SHOCK_SRC}
)
add_library(GAME_LIB ${GAME_SRC})
diff --git a/src/GameSrc/Headers/init.h b/src/GameSrc/Headers/init.h
index 402d2481d..58e2ff33a 100644
--- a/src/GameSrc/Headers/init.h
+++ b/src/GameSrc/Headers/init.h
@@ -33,7 +33,7 @@ extern grs_bitmap material_maps[MAX_MATERIALS];
extern void init_all(void);
extern void free_all(void);
extern uchar ppall[]; // pointer to main shadow palette
-
+errtype load_da_palette(void);
void object_data_flush(void);
errtype object_data_load(void);
extern uchar objdata_loaded;
diff --git a/src/GameSrc/damage.c b/src/GameSrc/damage.c
index 5d7cee5bc..1fd340214 100644
--- a/src/GameSrc/damage.c
+++ b/src/GameSrc/damage.c
@@ -402,7 +402,6 @@ int shield_absorb_damage(int damage, ubyte ub, byte shield_absorb, ubyte shield_
uchar alternate_death = FALSE;
extern bool gPlayingGame;
-extern bool gDeadPlayerQuit;
// kill_player()
// kills the player, checks for traps and stuff, so on
diff --git a/src/GameSrc/trigger.c b/src/GameSrc/trigger.c
index 9b64290e6..19c7510cc 100644
--- a/src/GameSrc/trigger.c
+++ b/src/GameSrc/trigger.c
@@ -1192,7 +1192,6 @@ extern uchar alternate_death;
extern bool gPlayingGame;
extern bool gDeadPlayerQuit;
-extern bool gGameCompletedQuit;
errtype trap_cutscene_func(int p1, int p2, int p3, int p4) {
short cs = qdata_get(p1);
diff --git a/src/MacSrc/InitMac.h b/src/MacSrc/InitMac.h
index 06b42b2c0..a11b78689 100644
--- a/src/MacSrc/InitMac.h
+++ b/src/MacSrc/InitMac.h
@@ -30,18 +30,18 @@ along with this program. If not, see .
// Prototypes
//--------------------
void InitMac(void);
-void FailNIL(void *);
+//void FailNIL(void *);
// Handle GetResourceFail(long id, short num);
-void CheckConfig(void);
-void ErrorDie(short stringnum);
+//void CheckConfig(void);
+//void ErrorDie(short stringnum);
void CleanupAndExit(void);
-void SetupWindows(WindowPtr *mainWind);
-void SetUpMenus(MenuHandle *theMenus, short numMenus);
-void StringAlert(short stringnum);
-void GetFolders(void);
+//void SetupWindows(WindowPtr *mainWind);
+//void SetUpMenus(MenuHandle *theMenus, short numMenus);
+//void StringAlert(short stringnum);
+//void GetFolders(void);
void InstallShockTimers(void);
-void RemoveShockTimers(void);
-void StartShockTimer(void);
-void StopShockTimer(void);
-void HideMenuBar(void);
-void ShowMenuBar(void);
+//void RemoveShockTimers(void);
+//void StartShockTimer(void);
+//void StopShockTimer(void);
+//void HideMenuBar(void);
+//void ShowMenuBar(void);
diff --git a/src/MacSrc/Prefs.h b/src/MacSrc/Prefs.h
index 9a95c6b3f..66285b274 100644
--- a/src/MacSrc/Prefs.h
+++ b/src/MacSrc/Prefs.h
@@ -73,6 +73,10 @@ void SetDefaultPrefs(void);
int16_t LoadPrefs(void);
int16_t SavePrefs(void);
+void CreateDefaultKeybindsFile(void);
+void LoadHotkeyKeybinds(void);
+void LoadMoveKeybinds(void);
+
//-------------------
// Enums
//-------------------
diff --git a/src/MacSrc/SDLFunctions.c b/src/MacSrc/SDLFunctions.c
new file mode 100644
index 000000000..6a1a7cab8
--- /dev/null
+++ b/src/MacSrc/SDLFunctions.c
@@ -0,0 +1,201 @@
+/*
+
+Copyright (C) 2015-2018 Night Dive Studios, LLC.
+Copyright (C) 2018-2020 Shockolate project
+
+This program is free software: you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation, either version 3 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program. If not, see .
+
+*/
+
+#include
+#include "shockolate_version.h"
+#include "InitMac.h"
+#include "OpenGL.h"
+#include "Prefs.h"
+#include "ShockBitmap.h"
+#include "Shock.h"
+#include "ShockHelp.h"
+
+#include "amaploop.h"
+#include "map.h"
+#include "gr2ss.h"
+#include "frflags.h"
+#include "version.h"
+
+
+SDL_AudioDeviceID device;
+SDL_Color gamePalette[256];
+SDL_Palette *sdlPalette;
+SDL_Renderer *renderer;
+SDL_Window *window;
+
+bool UseCutscenePalette = FALSE; // see cutsloop.c
+bool MouseCaptured = FALSE;
+char window_title[128];
+
+extern grs_screen *svga_screen;
+extern int mlook_enabled;
+
+void InitSDL() {
+ SDL_SetHint(SDL_HINT_NO_SIGNAL_HANDLERS, "1");
+ SDL_SetHint(SDL_HINT_RENDER_DRIVER, "opengl");
+ if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_TIMER | SDL_INIT_AUDIO) < 0) {
+ DEBUG("%s: Init failed", __FUNCTION__);
+ }
+
+ // TODO: figure out some universal set of settings that work...
+ SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_CORE);
+ SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 2);
+ SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 0);
+ SDL_GL_SetAttribute(SDL_GL_RED_SIZE, 8);
+ SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, 8);
+ SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, 8);
+ SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 24);
+ SDL_GL_SetAttribute(SDL_GL_STENCIL_SIZE, 8);
+ SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
+ SDL_GL_SetAttribute(SDL_GL_ALPHA_SIZE, 8);
+ SDL_GL_SetAttribute(SDL_GL_BUFFER_SIZE, 32);
+
+ gr_init();
+
+ extern short svga_mode_data[];
+ gr_set_mode(svga_mode_data[gShockPrefs.doVideoMode], TRUE);
+
+ INFO("Setting up screen and render contexts");
+
+ // Create a canvas to draw to
+
+ SetupOffscreenBitmaps(grd_cap->w, grd_cap->h);
+
+ // Open our window!
+
+ sprintf(window_title, "System Shock - %s", SHOCKOLATE_VERSION);
+
+ window = SDL_CreateWindow(window_title, SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, grd_cap->w, grd_cap->h,
+ SDL_WINDOW_HIDDEN | SDL_WINDOW_RESIZABLE | SDL_WINDOW_ALLOW_HIGHDPI | SDL_WINDOW_OPENGL);
+
+ // Create the palette
+
+ sdlPalette = SDL_AllocPalette(256);
+
+ // Setup the screen
+
+ svga_screen = cit_screen = gr_alloc_screen(grd_cap->w, grd_cap->h);
+ gr_set_screen(svga_screen);
+
+ gr_alloc_ipal();
+
+ SDL_ShowCursor(SDL_DISABLE);
+
+ atexit(SDL_Quit);
+
+ SDL_RaiseWindow(window);
+
+ renderer = SDL_CreateRenderer(window, -1, SDL_RENDERER_PRESENTVSYNC);
+ SDL_RenderSetLogicalSize(renderer, grd_cap->w, grd_cap->h);
+
+ // Startup OpenGL
+
+ init_opengl();
+
+ SDLDraw();
+
+ SDL_ShowWindow(window);
+}
+
+void SetSDLPalette(int index, int count, uchar *pal) {
+ static bool gammalut_init = 0;
+ static uchar gammalut[100 - 10 + 1][256];
+ if (!gammalut_init) {
+ double factor = (can_use_opengl() ? 1.0 : 2.2); // OpenGL uses 2.2
+ int i, j;
+ for (i = 10; i <= 100; i++) {
+ double gamma = (double)i * 1.0 / 100;
+ gamma = 1 - gamma;
+ gamma *= gamma;
+ gamma = 1 - gamma;
+ gamma = 1 / (gamma * factor);
+ for (j = 0; j < 256; j++)
+ gammalut[i - 10][j] = (uchar)(pow((double)j / 255, gamma) * 255);
+ }
+ gammalut_init = 1;
+ INFO("Gamma LUT init\'ed");
+ }
+
+ int gam = gShockPrefs.doGamma;
+ if (gam < 10)
+ gam = 10;
+ if (gam > 100)
+ gam = 100;
+ gam -= 10;
+
+ for (int i = index; i < index + count; i++) {
+ gamePalette[i].r = gammalut[gam][*pal++];
+ gamePalette[i].g = gammalut[gam][*pal++];
+ gamePalette[i].b = gammalut[gam][*pal++];
+ gamePalette[i].a = 0xff;
+ }
+
+ if (!UseCutscenePalette) {
+ // Hack black!
+ gamePalette[255].r = 0x0;
+ gamePalette[255].g = 0x0;
+ gamePalette[255].b = 0x0;
+ gamePalette[255].a = 0xff;
+ }
+
+ SDL_SetPaletteColors(sdlPalette, gamePalette, 0, 256);
+ SDL_SetSurfacePalette(drawSurface, sdlPalette);
+ SDL_SetSurfacePalette(offscreenDrawSurface, sdlPalette);
+
+ if (should_opengl_swap())
+ opengl_change_palette();
+}
+
+void SDLDraw() {
+ if (should_opengl_swap()) {
+ sdlPalette->colors[255].a = 0x00;
+ }
+
+ SDL_Texture *texture = SDL_CreateTextureFromSurface(renderer, drawSurface);
+
+ if (should_opengl_swap()) {
+ sdlPalette->colors[255].a = 0xff;
+ SDL_SetTextureBlendMode(texture, SDL_BLENDMODE_BLEND);
+ }
+
+ SDL_Rect srcRect = {0, 0, gScreenWide, gScreenHigh};
+ SDL_RenderCopy(renderer, texture, &srcRect, NULL);
+ SDL_DestroyTexture(texture);
+
+ if (should_opengl_swap()) {
+ opengl_swap_and_restore();
+ } else {
+ SDL_RenderPresent(renderer);
+ SDL_RenderClear(renderer);
+ }
+}
+
+void CaptureMouse(bool capture) {
+ MouseCaptured = (capture && gShockPrefs.goCaptureMouse);
+
+ if (!MouseCaptured && mlook_enabled && SDL_GetRelativeMouseMode() == SDL_TRUE) {
+ SDL_SetRelativeMouseMode(SDL_FALSE);
+
+ int w, h;
+ SDL_GetWindowSize(window, &w, &h);
+ SDL_WarpMouseInWindow(window, w / 2, h / 2);
+ } else
+ SDL_SetRelativeMouseMode(MouseCaptured ? SDL_TRUE : SDL_FALSE);
+}
diff --git a/src/MacSrc/Shock.c b/src/MacSrc/Shock.c
deleted file mode 100644
index 953620291..000000000
--- a/src/MacSrc/Shock.c
+++ /dev/null
@@ -1,385 +0,0 @@
-/*
-
-Copyright (C) 2015-2018 Night Dive Studios, LLC.
-
-This program is free software: you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation, either version 3 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program. If not, see .
-
-*/
-//====================================================================================
-//
-// System Shock - ©1994-1995 Looking Glass Technologies, Inc.
-//
-// Shock.c - Mac-specific initialization and main event loop.
-//
-//====================================================================================
-
-
-//--------------------
-// Includes
-//--------------------
-//#include
-
-#include "Shock.h"
-#include "InitMac.h"
-#include "OpenGL.h"
-#include "Prefs.h"
-#include "ShockBitmap.h"
-#include "ShockHelp.h"
-#ifdef TESTING
-#include "Tests.h"
-#endif
-
-#include "amaploop.h"
-#include "hkeyfunc.h"
-#include "mainloop.h"
-#include "setup.h"
-#include "fullscrn.h"
-#include "status.h"
-#include "map.h"
-#include "gr2ss.h"
-#include "frflags.h"
-#include "version.h"
-#include "shockolate_version.h"
-
-#include "Modding.h"
-
-#include
-#include
-
-extern uchar game_paused; // I've learned such bad lessons from LG.
-extern uchar objdata_loaded;
-extern uchar music_on;
-extern uchar startup_music;
-
-//--------------------
-// Globals
-//--------------------
-WindowPtr gMainWindow;
-MenuHandle gMainMenus[kNumMenus];
-//RgnHandle gCursorRgn;
-short gCursorSet;
-bool gDone = false;
-bool gInForeground = true;
-bool gPlayingGame; //¥¥¥ Temp
-bool gIsNewGame;
-long gGameSavedTime;
-bool gDeadPlayerQuit;
-bool gGameCompletedQuit;
-
-grs_screen *cit_screen;
-SDL_Window* window;
-SDL_Palette* sdlPalette;
-SDL_Renderer* renderer;
-
-SDL_AudioDeviceID device;
-
-char window_title[128];
-int num_args;
-char** arg_values;
-
-extern grs_screen *svga_screen;
-extern frc *svga_render_context;
-
-//--------------------
-// Prototypes
-//--------------------
-extern void init_all(void);
-extern void inv_change_fullscreen(uchar on);
-extern void object_data_flush(void);
-//extern Boolean IsFullscreenWareOn(void);
-extern errtype load_da_palette(void);
-extern void ShockMain(void);
-
-//see Prefs.c
-extern void CreateDefaultKeybindsFile(void);
-extern void LoadHotkeyKeybinds(void);
-extern void LoadMoveKeybinds(void);
-
-void InitSDL();
-void SDLDraw(void);
-errtype CheckFreeSpace(short checkRefNum);
-
-
-//------------------------------------------------------------------------------------
-// Main function.
-//------------------------------------------------------------------------------------
-int main(int argc, char** argv)
-{
- // Save the arguments for later
-
- num_args = argc;
- arg_values = argv;
-
- // FIXME externalize this
- log_set_quiet(0);
- log_set_level(LOG_INFO);
-
- // init mac managers
-
- InitMac();
-
- // Initialize the preferences file.
-
- SetDefaultPrefs();
- LoadPrefs();
-
- //see Prefs.c
- CreateDefaultKeybindsFile(); //only if it doesn't already exist
- //even if keybinds file still doesn't exist, defaults will be set here
- LoadHotkeyKeybinds();
- LoadMoveKeybinds();
-
-#ifdef TESTING
- SetupTests();
-#endif
-
- // Process some startup arguments
-
- bool show_splash = !CheckArgument("-nosplash");
-
- // CC: Modding support! This is so exciting.
-
- ProcessModArgs(argc, argv);
-
- // Initialize
-
- init_all();
- setup_init();
-
- gPlayingGame = TRUE;
- gDeadPlayerQuit = FALSE;
- gGameCompletedQuit = FALSE;
-
- load_da_palette();
- gr_clear(0xFF);
-
- // Draw the splash screen
-
- INFO("Showing splash screen");
- splash_draw(show_splash);
-
- // Start in the Main Menu loop
-
- _new_mode = _current_loop = SETUP_LOOP;
- loopmode_enter(SETUP_LOOP);
-
- // Start the main loop
-
- INFO("Showing main menu, starting game loop");
- mainloop(argc, argv);
-
- status_bio_end();
- stop_music();
-
- return 0;
-}
-
-bool CheckArgument(char* arg) {
- if(arg == NULL)
- return false;
-
- for(int i = 1; i < num_args; i++) {
- if(strcmp(arg_values[i], arg) == 0) {
- return true;
- }
- }
-
- return false;
-}
-
-//------------------------------------------------------------------------------------
-// Handle Quit menu command/apple event.
-//------------------------------------------------------------------------------------
-void DoQuit(void)
-{
- gDone = true;
-}
-
-#define NEEDED_DISKSPACE 700000
-//------------------------------------------------------------------------------------
-// See if we have enough free space to save the file.
-//------------------------------------------------------------------------------------
-errtype CheckFreeSpace(short checkRefNum)
-{
- // FIXME: This should probably do something?
- return (OK);
-}
-
-void InitSDL()
-{
- SDL_SetHint(SDL_HINT_NO_SIGNAL_HANDLERS, "1");
- SDL_SetHint(SDL_HINT_RENDER_DRIVER, "opengl");
- if(SDL_Init(SDL_INIT_VIDEO | SDL_INIT_TIMER | SDL_INIT_AUDIO) < 0) {
- DEBUG("%s: Init failed", __FUNCTION__);
- }
-
- // TODO: figure out some universal set of settings that work...
- SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_CORE);
- SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 2);
- SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 0);
- SDL_GL_SetAttribute(SDL_GL_RED_SIZE, 8);
- SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, 8);
- SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, 8);
- SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 24);
- SDL_GL_SetAttribute(SDL_GL_STENCIL_SIZE, 8);
- SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
- SDL_GL_SetAttribute(SDL_GL_ALPHA_SIZE, 8);
- SDL_GL_SetAttribute(SDL_GL_BUFFER_SIZE, 32);
-
- gr_init();
-
- extern short svga_mode_data[];
- gr_set_mode(svga_mode_data[gShockPrefs.doVideoMode], TRUE);
-
- INFO("Setting up screen and render contexts");
-
- // Create a canvas to draw to
-
- SetupOffscreenBitmaps(grd_cap->w, grd_cap->h);
-
- // Open our window!
-
- sprintf(window_title, "System Shock - %s", SHOCKOLATE_VERSION);
-
- window = SDL_CreateWindow(
- window_title, SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED,
- grd_cap->w, grd_cap->h, SDL_WINDOW_HIDDEN | SDL_WINDOW_RESIZABLE | SDL_WINDOW_ALLOW_HIGHDPI | SDL_WINDOW_OPENGL);
-
-
- // Create the palette
-
- sdlPalette = SDL_AllocPalette(256);
-
- // Setup the screen
-
- svga_screen = cit_screen = gr_alloc_screen(grd_cap->w, grd_cap->h);
- gr_set_screen(svga_screen);
-
- gr_alloc_ipal();
-
- SDL_ShowCursor(SDL_DISABLE);
-
- atexit(SDL_Quit);
-
- SDL_RaiseWindow(window);
-
- renderer = SDL_CreateRenderer(window, -1, SDL_RENDERER_PRESENTVSYNC);
- SDL_RenderSetLogicalSize(renderer, grd_cap->w, grd_cap->h);
-
- // Startup OpenGL
-
- init_opengl();
-
- SDLDraw();
-
- SDL_ShowWindow(window);
-}
-
-SDL_Color gamePalette[256];
-bool UseCutscenePalette = FALSE; //see cutsloop.c
-void SetSDLPalette(int index, int count, uchar *pal)
-{
- static bool gammalut_init = 0;
- static uchar gammalut[100-10+1][256];
- if (!gammalut_init)
- {
- double factor = (can_use_opengl() ? 1.0 : 2.2); //OpenGL uses 2.2
- int i, j;
- for (i = 10; i <= 100; i++)
- {
- double gamma = (double)i * 1.0 / 100;
- gamma = 1 - gamma;
- gamma *= gamma;
- gamma = 1 - gamma;
- gamma = 1 / (gamma * factor);
- for (j = 0; j < 256; j++)
- gammalut[i-10][j] = (uchar)(pow((double)j / 255, gamma) * 255);
- }
- gammalut_init = 1;
- INFO("Gamma LUT init\'ed");
- }
-
- int gam = gShockPrefs.doGamma;
- if (gam < 10) gam = 10;
- if (gam > 100) gam = 100;
- gam -= 10;
-
- for (int i = index; i < index+count; i++)
- {
- gamePalette[i].r = gammalut[gam][*pal++];
- gamePalette[i].g = gammalut[gam][*pal++];
- gamePalette[i].b = gammalut[gam][*pal++];
- gamePalette[i].a = 0xff;
- }
-
- if (!UseCutscenePalette)
- {
- // Hack black!
- gamePalette[255].r = 0x0;
- gamePalette[255].g = 0x0;
- gamePalette[255].b = 0x0;
- gamePalette[255].a = 0xff;
- }
-
- SDL_SetPaletteColors(sdlPalette, gamePalette, 0, 256);
- SDL_SetSurfacePalette(drawSurface, sdlPalette);
- SDL_SetSurfacePalette(offscreenDrawSurface, sdlPalette);
-
- if (should_opengl_swap())
- opengl_change_palette();
-}
-
-void SDLDraw()
-{
- if (should_opengl_swap()) {
- sdlPalette->colors[255].a = 0x00;
- }
-
- SDL_Texture* texture = SDL_CreateTextureFromSurface(renderer, drawSurface);
-
- if (should_opengl_swap()) {
- sdlPalette->colors[255].a = 0xff;
- SDL_SetTextureBlendMode(texture, SDL_BLENDMODE_BLEND);
- }
-
- SDL_Rect srcRect = { 0, 0, gScreenWide, gScreenHigh };
- SDL_RenderCopy(renderer, texture, &srcRect, NULL);
- SDL_DestroyTexture(texture);
-
- if (should_opengl_swap()) {
- opengl_swap_and_restore();
- } else {
- SDL_RenderPresent(renderer);
- SDL_RenderClear(renderer);
- }
-}
-
-bool MouseCaptured = FALSE;
-
-extern int mlook_enabled;
-
-void CaptureMouse(bool capture)
-{
- MouseCaptured = (capture && gShockPrefs.goCaptureMouse);
-
- if (!MouseCaptured && mlook_enabled && SDL_GetRelativeMouseMode() == SDL_TRUE)
- {
- SDL_SetRelativeMouseMode(SDL_FALSE);
-
- int w, h;
- SDL_GetWindowSize(window, &w, &h);
- SDL_WarpMouseInWindow(window, w/2, h/2);
- }
- else SDL_SetRelativeMouseMode(MouseCaptured ? SDL_TRUE : SDL_FALSE);
-}
diff --git a/src/MacSrc/Shock.h b/src/MacSrc/Shock.h
deleted file mode 100644
index 389a1b3a4..000000000
--- a/src/MacSrc/Shock.h
+++ /dev/null
@@ -1,193 +0,0 @@
-/*
-
-Copyright (C) 2015-2018 Night Dive Studios, LLC.
-
-This program is free software: you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation, either version 3 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program. If not, see .
-
-*/
-//====================================================================================
-//
-// System Shock - ©1994-1995 Looking Glass Technologies, Inc.
-//
-// Shock.h - Mac-specific initialization and main event loop.
-//
-//====================================================================================
-
-#include
-
-//--------------------
-// Defines
-//--------------------
-//#define TESTING 1
-
-//#ifdef IS_REALLY_OSX
-
-//--------------------
-// Menus
-//--------------------
-#ifdef TESTING
-#define kNumMenus 6
-#else
-#define kNumMenus 4
-#endif
-
-#define mApple 128 // Menu IDs
-#define mFile 129
-#define mEdit 130
-#define mOptions 131
-#ifdef TESTING
-#define mTests 132
-#define mTests2 133
-#endif
-
-#define fileNewGame 1 // File menu item IDs
-#define fileOpenGame 2
-#define fileSaveGame 3
-#define fileSaveGameAs 4
-#define filePlayIntro 6
-#define fileResumeGame 8
-#define fileEndGame 9
-#define fileQuit 11
-
-#define editUndo 1 // Edit menu item IDs
-#define editCut 3
-#define editCopy 4
-#define editPaste 5
-#define editClear 6
-
-#define optGameOptions 1 // Options menu item IDs
-#define optGraphicsOptions 2
-#define optSoundOptions 3
-
-#ifdef TESTING
-#define testBrowseImages 1 // Tests menu item IDs
-#define testBrowseFonts 2
-#define testLoadPalette 3
-#define testMoveKeys 5
-#define testMouse 6
-#define testPlayMovie 8
-#define testPlayMovie2x 9
-#define testPlayMovieDblSpd 10
-#define testPlayMovieHalfSpd 11
-#define testPlayIntro 13
-#define testPlayDeath 14
-#define testPlayEndGame 15
-#define testPlayCitadelVM 17
-#define testPlayDetachVM 18
-#define testPlayJettisonVM 19
-#define testPlayLaserMalVM 20
-#define testPlayShieldsVM 21
-#define testPlayAutoDesVM 22
-#define testPlayBark1 24
-#define testPlayBark2 25
-#define testPlayAlog1 26
-#define testPlayAlog2 27
-
-#define testLoadLevelR 1
-#define testLoadLevel1 2
-#define testLoadLevel2 3
-#define testLoadLevel3 4
-#define testZoomIn 6
-#define testZoomOut 7
-#define testRender 9
-#endif
-
-//--------------------
-// Graphics Defines
-//--------------------
-#define screenMaxX 640L
-#define screenMaxY 480L
-
-//--------------------
-// File Types
-//--------------------
-#define kAppFileType 'Shok'
-#define kGameFileType 'Sgam'
-#define kRsrcFileType 'Sres'
-
-//--------------------
-// Function Prototypes
-//--------------------
-typedef void* WindowPtr; // FIXME: get rid of UpdateWindow()?
-typedef void* MenuHandle; // FIXME: what's gMainMenus about?
-int main(int argc, char** argv);
-void HandleEvents(void);
-void UpdateWindow(WindowPtr wind);
-void DoCommand(unsigned long mResult);
-bool DoSaveGame(void);
-bool DoSaveGameAs(void);
-void DoQuit(void);
-void ScrollCredits(void);
-
-void InitSDL();
-void SetSDLPalette(int index, int count, uchar *pal);
-void SDLDraw();
-void CaptureMouse(bool capture);
-bool CheckArgument(char* name);
-
-//--------------------
-// Public Globals
-//--------------------
-extern WindowPtr gMainWindow;
-extern MenuHandle gMainMenus[kNumMenus];
-//extern RgnHandle gCursorRgn;
-//extern short gCursorSet;
-extern bool gDone;
-extern bool gInForeground;
-extern bool gIsNewGame;
-//extern FSSpec gSavedGameFile;
-extern long gGameSavedTime;
-
-//extern Handle gExtraMemory;
-//extern ColorSpec* gOriginalColors;
-extern unsigned long gRandSeed;
-extern short gMainVRef;
-// extern Handle gWatchCurs;
-
-extern short gOriginalDepth;
-extern short gStartupDepth;
-extern short gLastAlertDepth;
-extern char *gScreenAddress;
-extern long gScreenRowbytes;
-extern short gScreenWide, gScreenHigh;
-extern short gActiveWide, gActiveHigh;
-extern short gActiveLeft, gActiveTop;
-//extern Rect gActiveArea, gOffActiveArea;
-
-//extern Boolean gIsPowerPC;
-
-extern long gDataDirID;
-extern short gDataVref;
-extern long gCDDataDirID;
-extern short gCDDataVref;
-extern long gAlogDirID;
-extern short gAlogVref;
-extern long gBarkDirID;
-extern short gBarkVref;
-
-
-extern grs_screen *cit_screen;
-extern SDL_Window* window;
-
-
-/*#else
-extern short gOriginalDepth;
-extern short gStartupDepth;
-extern short gLastAlertDepth;
-extern Ptr gScreenAddress;
-extern long gScreenRowbytes;
-extern short gScreenWide, gScreenHigh;
-extern short gActiveWide, gActiveHigh;
-extern short gActiveLeft, gActiveTop;
-#endif*/
diff --git a/src/ShockSrc/Shock.cpp b/src/ShockSrc/Shock.cpp
new file mode 100644
index 000000000..c5833ed9a
--- /dev/null
+++ b/src/ShockSrc/Shock.cpp
@@ -0,0 +1,146 @@
+/*
+
+Copyright (C) 1994-1995 Looking Glass Technologies, Inc.
+Copyright (C) 2015-2018 Night Dive Studios, LLC.
+Copyright (C) 2018-2020 Shockolate project
+
+This program is free software: you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation, either version 3 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program. If not, see .
+
+*/
+
+//--------------------
+// Includes
+//--------------------
+
+extern "C" {
+#include "Shock.h"
+#include "InitMac.h"
+#include "OpenGL.h"
+#include "Prefs.h"
+#include "ShockBitmap.h"
+#include "ShockHelp.h"
+
+#include "amaploop.h"
+#include "hkeyfunc.h"
+#include "init.h"
+#include "mainloop.h"
+#include "setup.h"
+#include "fullscrn.h"
+#include "status.h"
+#include "map.h"
+#include "gr2ss.h"
+#include "frflags.h"
+#include "version.h"
+
+#include "Modding.h"
+
+//--------------------
+// Prototypes
+//--------------------
+extern void inv_change_fullscreen(uchar on);
+}
+
+//--------------------
+// Globals
+//--------------------
+bool gPlayingGame; //¥¥¥ Temp
+bool gDeadPlayerQuit;
+
+grs_screen *cit_screen;
+int num_args;
+char **arg_values;
+
+extern grs_screen *svga_screen;
+extern frc *svga_render_context;
+
+//------------------------------------------------------------------------------------
+// Main function.
+//------------------------------------------------------------------------------------
+int main(int argc, char **argv) {
+ // Save the arguments for later
+
+ num_args = argc;
+ arg_values = argv;
+
+ // FIXME externalize this
+ log_set_quiet(0);
+ log_set_level(LOG_INFO);
+
+ // init mac managers
+
+ InitMac();
+
+ // Initialize the preferences file.
+
+ SetDefaultPrefs();
+ LoadPrefs();
+
+ // see Prefs.c
+ CreateDefaultKeybindsFile(); // only if it doesn't already exist
+ // even if keybinds file still doesn't exist, defaults will be set here
+ LoadHotkeyKeybinds();
+ LoadMoveKeybinds();
+
+ // Process some startup arguments
+
+ bool show_splash = !CheckArgument("-nosplash");
+
+ // CC: Modding support! This is so exciting.
+
+ ProcessModArgs(argc, argv);
+
+ // Initialize
+
+ init_all();
+ setup_init();
+
+ gPlayingGame = TRUE;
+ gDeadPlayerQuit = FALSE;
+
+ load_da_palette();
+ gr_clear(0xFF);
+
+ // Draw the splash screen
+
+ INFO("Showing splash screen");
+ splash_draw(show_splash);
+
+ // Start in the Main Menu loop
+
+ _new_mode = _current_loop = SETUP_LOOP;
+ loopmode_enter(SETUP_LOOP);
+
+ // Start the main loop
+
+ INFO("Showing main menu, starting game loop");
+ mainloop(argc, argv);
+
+ status_bio_end();
+ stop_music();
+
+ return 0;
+}
+
+bool CheckArgument(const char *arg) {
+ if (arg == nullptr)
+ return false;
+
+ for (int i = 1; i < num_args; i++) {
+ if (strcmp(arg_values[i], arg) == 0) {
+ return true;
+ }
+ }
+
+ return false;
+}
diff --git a/src/ShockSrc/Shock.h b/src/ShockSrc/Shock.h
new file mode 100644
index 000000000..7b9597ca3
--- /dev/null
+++ b/src/ShockSrc/Shock.h
@@ -0,0 +1,46 @@
+/*
+
+Copyright (C) 1994-1995 Looking Glass Technologies, Inc.
+Copyright (C) 2015-2018 Night Dive Studios, LLC.
+Copyright (C) 2018-2020 Shockolate project
+
+This program is free software: you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation, either version 3 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program. If not, see .
+
+*/
+
+#include
+
+//--------------------
+// Function Prototypes
+//--------------------
+int main(int argc, char **argv);
+
+void InitSDL();
+void SetSDLPalette(int index, int count, uchar *pal);
+void SDLDraw();
+void CaptureMouse(bool capture);
+bool CheckArgument(const char *name);
+
+//--------------------
+// Public Globals
+//--------------------
+
+extern unsigned long gRandSeed;
+
+extern char *gScreenAddress;
+extern long gScreenRowbytes;
+extern short gScreenWide, gScreenHigh;
+
+extern grs_screen *cit_screen;
+extern SDL_Window *window;