summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBardur Arantsson <bardur@scientician.net>2016-02-05 19:22:46 +0100
committerBardur Arantsson <bardur@scientician.net>2016-02-05 19:22:46 +0100
commite5bb0921ef06a98b77b3e91d9b2f77caaa1f89a9 (patch)
tree01e17bf81572f1f66244c61a8658b750f5384936
parentc8bd25efe980a6455fef1f6622fe5c69d1ed7a4d (diff)
Build: Produce multiple independent executables
-rw-r--r--CMakeLists.txt28
-rw-r--r--README.md7
-rw-r--r--src/.gitignore6
-rw-r--r--src/CMakeLists.txt64
-rw-r--r--src/birth.cc1
-rw-r--r--src/birth.h14
-rw-r--r--src/birth.hpp1
-rw-r--r--src/dungeon.cc1
-rw-r--r--src/files.h1
-rw-r--r--src/files.hpp1
-rw-r--r--src/init2.cc35
-rw-r--r--src/init2.h1
-rw-r--r--src/main-gcu.c18
-rw-r--r--src/main-gtk2.c24
-rw-r--r--src/main-sdl.c21
-rw-r--r--src/main-win.c8
-rw-r--r--src/main-x11.c15
-rw-r--r--src/main.cc (renamed from src/main.c)184
-rw-r--r--src/main.h11
-rw-r--r--src/modules.cc1
-rw-r--r--src/modules.h15
-rw-r--r--src/modules.hpp2
-rw-r--r--src/util.h3
-rw-r--r--src/util.hpp3
-rw-r--r--src/variable.h8
-rw-r--r--src/variable.hpp8
26 files changed, 193 insertions, 288 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 9519785a..42d24e38 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -69,23 +69,11 @@ ENDIF()
# X11 support (OPTIONAL)
#
FIND_PACKAGE(X11)
-IF(X11_FOUND)
- # Add X11 flags/options
- ADD_DEFINITIONS(-DUSE_X11)
- INCLUDE_DIRECTORIES(${X11_INCLUDE_DIR})
- SET(LIBS ${LIBS} ${X11_LIBRARIES})
-ENDIF()
#
# GTK2 support (OPTIONAL)
#
FIND_PACKAGE(GTK2)
-IF(GTK2_FOUND)
- # Add GTK flags/options
- ADD_DEFINITIONS(-DUSE_GTK2)
- INCLUDE_DIRECTORIES(${GTK2_INCLUDE_DIRS})
- SET(LIBS ${LIBS} ${GTK2_LIBRARIES})
-ENDIF()
#
# SDL support (OPTIONAL)
@@ -100,10 +88,7 @@ IF(SDL_FOUND)
FIND_PACKAGE(SDL_image)
FIND_PACKAGE(SDL_ttf)
IF(SDLIMAGE_FOUND AND SDLTTF_FOUND)
- # Add SDL flags/options
- ADD_DEFINITIONS(-DUSE_SDL)
- INCLUDE_DIRECTORIES(${SDL_INCLUDE_DIR} ${SDLIMAGE_INCLUDE_DIR} ${SDLTTF_INCLUDE_DIR})
- SET(LIBS ${LIBS} ${SDLIMAGE_LIBRARY} ${SDLTTF_LIBRARY} ${SDL_LIBRARY} m)
+ # Handled in src/CMakeLists.txt
ELSE()
# Let user know that (and why) we haven't enabled SDL.
IF(SDLIMAGE_FOUND)
@@ -122,21 +107,14 @@ ENDIF()
# Curses support (OPTIONAL)
#
FIND_PACKAGE(Curses)
-IF(CURSES_FOUND)
- # Add Curses flags/options
- ADD_DEFINITIONS(-DUSE_GCU)
- INCLUDE_DIRECTORIES(${CURSES_INCLUDE_DIR})
- SET(LIBS ${LIBS} ${CURSES_LIBRARIES})
-ENDIF()
#
# Windows support
#
if(WIN32)
- # Add Windows flags/options
+ # This definition is required for more than just the main-win file,
+ # so we need to have it here.
ADD_DEFINITIONS(-DWINDOWS)
- SET(EXECUTABLE_OPTIONS WIN32)
- SET(LIBS ${LIBS} winmm wsock32)
endif(WIN32)
#
diff --git a/README.md b/README.md
index cdf11c24..b61fd0b1 100644
--- a/README.md
+++ b/README.md
@@ -28,11 +28,12 @@ To configure for your system, run
$ cmake .
$ make
-You should now be able to run
+You should now be able to run one of the executables in ./src
+to run ToME. For example, you'd run
- $ ./src/tome
+ $ ./src/tome-x11
-to start ToME.
+to start ToME with the X11 frontend.
**Important:** The current working directory must be at the root of
the source tree for the above command to run -- if it isn't, then
diff --git a/src/.gitignore b/src/.gitignore
index 098f3b10..485f14c6 100644
--- a/src/.gitignore
+++ b/src/.gitignore
@@ -1,3 +1,7 @@
/harness
-/tome
+/tome-gcu
+/tome-gtk2
+/tome-sdl
+/tome-x11
+/tome-win
*.plist
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 9919485d..c984db61 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -108,15 +108,6 @@ SET(SRCS_COMMON
z-util.c
)
-# Sources (PROGRAM)
-SET(SRCS_PROGRAM
- main-gcu.c
- main-gtk2.c
- main-sdl.c
- main-x11.c
- main.c
-)
-
# Sources (TEST)
SET(SRCS_TESTS
../tests/get_level_device.cc
@@ -128,11 +119,14 @@ ADD_LIBRARY(game
${SRCS_COMMON}
)
+ADD_LIBRARY(game_main
+ main.cc)
+
# Need a few additional source files for Windows.
-if(WIN32)
+IF(WIN32)
SET(SRCS ${SRCS} main-win.c)
# Resource files require a little workaround.
- if(MINGW)
+ IF(MINGW)
# Workaround for resource compilation for mingw on CMake.
# See http://www.cmake.org/Bug/view.php?id=4068
ADD_CUSTOM_COMMAND(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/angband_rc.o
@@ -140,20 +134,44 @@ if(WIN32)
-i${CMAKE_CURRENT_SOURCE_DIR}/angband.rc
-o ${CMAKE_CURRENT_BINARY_DIR}/angband_rc.o)
SET(SRCS ${SRCS} ${CMAKE_CURRENT_BINARY_DIR}/angband_rc.o)
- else(MINGW)
+ ELSE(MINGW)
SET(SRCS ${SRCS} angband.rc)
- endif(MINGW)
-endif(WIN32)
+ ENDIF(MINGW)
+ # Executable for Win32
+ ADD_EXECUTABLE(tome-win WIN32 main-win.c)
+ TARGET_LINK_LIBRARIES(tome-win game squelch ${LIBS} winmm wsock32)
+ INSTALL(TARGETS tome-win RUNTIME DESTINATION bin)
+ENDIF(WIN32)
+
+# tome executables
+IF(X11_FOUND)
+ INCLUDE_DIRECTORIES(${X11_INCLUDE_DIR})
+ ADD_EXECUTABLE(tome-x11 main-x11.c)
+ TARGET_LINK_LIBRARIES(tome-x11 game game_main squelch ${LIBS} ${X11_LIBRARIES})
+ INSTALL(TARGETS tome-x11 RUNTIME DESTINATION bin)
+ENDIF()
-# tome executable
-ADD_EXECUTABLE(tome ${EXECUTABLE_OPTIONS} ${SRCS_PROGRAM})
-TARGET_LINK_LIBRARIES(tome game squelch ${LIBS})
+IF(SDL_FOUND AND SDLIMAGE_FOUND AND SDLTTF_FOUND)
+ INCLUDE_DIRECTORIES(${SDL_INCLUDE_DIR} ${SDLIMAGE_INCLUDE_DIR} ${SDLTTF_INCLUDE_DIR})
+ ADD_EXECUTABLE(tome-sdl main-sdl.c)
+ TARGET_LINK_LIBRARIES(tome-sdl game game_main squelch ${LIBS} ${SDLIMAGE_LIBRARY} ${SDLTTF_LIBRARY} ${SDL_LIBRARY} m)
+ INSTALL(TARGETS tome-sdl RUNTIME DESTINATION bin)
+ENDIF()
+
+IF(CURSES_FOUND)
+ INCLUDE_DIRECTORIES(${CURSES_INCLUDE_DIR})
+ ADD_EXECUTABLE(tome-gcu main-gcu.c)
+ TARGET_LINK_LIBRARIES(tome-gcu game game_main squelch ${LIBS} ${CURSES_LIBRARIES})
+ INSTALL(TARGETS tome-gcu RUNTIME DESTINATION bin)
+ENDIF()
+
+IF(GTK2_FOUND)
+ INCLUDE_DIRECTORIES(${GTK2_INCLUDE_DIRS})
+ ADD_EXECUTABLE(tome-gtk2 main-gtk2.c)
+ TARGET_LINK_LIBRARIES(tome-gtk2 game game_main squelch ${LIBS} ${GTK2_LIBRARIES})
+ INSTALL(TARGETS tome-gtk2 RUNTIME DESTINATION bin)
+ENDIF()
# test harness executable
-ADD_EXECUTABLE(harness ${EXECUTABLE_OPTIONS} ${SRCS_TESTS})
+ADD_EXECUTABLE(harness ${SRCS_TESTS})
TARGET_LINK_LIBRARIES(harness game squelch ${LIBS})
-
-# Installation
-INSTALL(TARGETS tome
- RUNTIME DESTINATION bin
-)
diff --git a/src/birth.cc b/src/birth.cc
index db481866..f8b81e35 100644
--- a/src/birth.cc
+++ b/src/birth.cc
@@ -6,7 +6,6 @@
* included in all such copies.
*/
#include "birth.hpp"
-#include "birth.h"
#include "ability_type.hpp"
#include "artifact_type.hpp"
diff --git a/src/birth.h b/src/birth.h
deleted file mode 100644
index 41620bfa..00000000
--- a/src/birth.h
+++ /dev/null
@@ -1,14 +0,0 @@
-#pragma once
-
-#include "h-basic.h"
-
-// C linkage required for these functions since main-* code uses them.
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-extern bool_ no_begin_screen;
-
-#ifdef __cplusplus
-} // extern "C"
-#endif
diff --git a/src/birth.hpp b/src/birth.hpp
index fb036ecc..dd5ff850 100644
--- a/src/birth.hpp
+++ b/src/birth.hpp
@@ -7,3 +7,4 @@ extern void save_savefile_names(void);
extern bool_ begin_screen(void);
extern void get_height_weight(void);
extern void player_birth(void);
+extern bool_ no_begin_screen;
diff --git a/src/dungeon.cc b/src/dungeon.cc
index bff82d12..41aa6bf6 100644
--- a/src/dungeon.cc
+++ b/src/dungeon.cc
@@ -10,7 +10,6 @@
#include "dungeon.h"
#include "birth.hpp"
-#include "birth.h"
#include "cave.hpp"
#include "cave_type.hpp"
#include "cmd1.hpp"
diff --git a/src/files.h b/src/files.h
index 0eb99f15..951c3c00 100644
--- a/src/files.h
+++ b/src/files.h
@@ -7,7 +7,6 @@
extern "C" {
#endif
-extern void process_player_name(bool_ sf);
extern void do_cmd_save_game(void);
extern void predict_score_gui(bool_ *initialized, bool_ *game_in_progress);
diff --git a/src/files.hpp b/src/files.hpp
index 52206d12..5979be89 100644
--- a/src/files.hpp
+++ b/src/files.hpp
@@ -25,3 +25,4 @@ extern char *get_line(const char* fname, cptr fdir, char *linbuf, int line);
extern void race_legends(void);
extern void show_highclass(int building);
extern errr get_xtra_line(const char * file_name, monster_type *m_ptr, char * output);
+extern void process_player_name(bool_ sf);
diff --git a/src/init2.cc b/src/init2.cc
index f56045b9..da518a57 100644
--- a/src/init2.cc
+++ b/src/init2.cc
@@ -231,41 +231,6 @@ void init_file_paths(char *path)
/*
- * Initialize and verify the file paths, and the score file.
- *
- * Use the ANGBAND_PATH environment var if possible, else use
- * DEFAULT_PATH, and in either case, branch off appropriately.
- *
- * First, we'll look for the ANGBAND_PATH environment variable,
- * and then look for the files in there. If that doesn't work,
- * we'll try the DEFAULT_PATH constant. So be sure that one of
- * these two things works...
- *
- * We must ensure that the path ends with "PATH_SEP" if needed,
- * since the "init_file_paths()" function will simply append the
- * relevant "sub-directory names" to the given path.
- */
-void init_file_paths_with_env()
-{
- char path[1024];
-
- cptr tail;
-
- /* Get the environment variable */
- tail = getenv("TOME_PATH");
-
- /* Use the angband_path, or a default */
- strcpy(path, tail ? tail : DEFAULT_PATH);
-
- /* Hack -- Add a path separator (only if needed) */
- if (!suffix(path, PATH_SEP)) strcat(path, PATH_SEP);
-
- /* Initialize */
- init_file_paths(path);
-}
-
-
-/*
* Hack -- help give useful error messages
*/
s16b error_idx;
diff --git a/src/init2.h b/src/init2.h
index 5697e4ef..ba18f2d7 100644
--- a/src/init2.h
+++ b/src/init2.h
@@ -6,7 +6,6 @@ extern "C" {
#endif
extern void init_file_paths(char *path);
-extern void init_file_paths_with_env();
extern void init_angband(void);
#ifdef __cplusplus
diff --git a/src/main-gcu.c b/src/main-gcu.c
index c253daf2..ac41272c 100644
--- a/src/main-gcu.c
+++ b/src/main-gcu.c
@@ -38,12 +38,11 @@
* Consider the use of "savetty()" and "resetty()". XXX XXX XXX
*/
+#include "main.h"
#include "util.h"
#include "variable.h"
-#ifdef USE_GCU
-
#include <limits.h>
/*
@@ -794,7 +793,7 @@ static void hook_quit(cptr str)
*
* Someone should really check the semantics of "initscr()"
*/
-errr init_gcu(int argc, char **argv)
+int init_gcu(int argc, char **argv)
{
int i;
@@ -1015,7 +1014,12 @@ errr init_gcu(int argc, char **argv)
return (0);
}
-
-#endif /* USE_GCU */
-
-
+int main(int argc, char *argv[])
+{
+ return main_real(
+ argc,
+ argv,
+ "gcu",
+ init_gcu,
+ " -- -b Requests big screen\n");
+}
diff --git a/src/main-gtk2.c b/src/main-gtk2.c
index ca3eff60..124802c3 100644
--- a/src/main-gtk2.c
+++ b/src/main-gtk2.c
@@ -31,16 +31,11 @@
*/
#include "files.h"
+#include "main.h"
#include "util.h"
#include "variable.h"
-/*
- * Activate variant-specific features
- */
-
-#ifdef USE_GTK2
-
/* Force ANSI standard */
/* #define __STRICT_ANSI__ */
@@ -1897,7 +1892,7 @@ static void hook_quit(cptr str)
/*
* Initialization function
*/
-errr init_gtk2(int argc, char **argv)
+int init_gtk2(int argc, char **argv)
{
int i;
@@ -1974,4 +1969,17 @@ errr init_gtk2(int argc, char **argv)
return (0);
}
-#endif /* USE_GTK2 */
+/**
+ * Main
+ */
+int main(int argc, char *argv[])
+{
+ return main_real(
+ argc,
+ argv,
+ "gtk2",
+ init_gtk2,
+ // Usage:
+ " -- -n# Number of terms to use\n"
+ " -- -b Turn off software backing store\n");
+}
diff --git a/src/main-sdl.c b/src/main-sdl.c
index 9a177cbb..e9aec927 100644
--- a/src/main-sdl.c
+++ b/src/main-sdl.c
@@ -23,9 +23,8 @@
// in this Software without prior written authorization from the author(s).
*/
-#ifdef USE_SDL
-
#include "loadsave.h"
+#include "main.h"
#include "util.h"
#include "variable.h"
@@ -1824,7 +1823,7 @@ void dumpWindowSettings(void)
/* The main-sdl initialization routine!
This routine processes arguments, opens the SDL
window, loads fonts, etc. */
-errr init_sdl(int argc, char **argv)
+int init_sdl(int argc, char **argv)
{
int i;
char filename[PATH_MAX + 1];
@@ -2097,4 +2096,18 @@ errr init_sdl(int argc, char **argv)
return 0;
}
-#endif
+int main(int argc, char *argv[])
+{
+ return main_real(
+ argc,
+ argv,
+ "sdl",
+ init_sdl,
+ " -- -n # Number of virtual consoles to use\n"
+ " -- -w # Request screen width in pixels\n"
+ " -- -h # Request screen height in pixels\n"
+ " -- -bpp # Request screen color depth in bits\n"
+ " -- -fs Start with full-screen display\n"
+ " -- -s # Request font size\n"
+ " -- -f <font> Request true-type font by name\n");
+}
diff --git a/src/main-win.c b/src/main-win.c
index a2daffbe..0403dc46 100644
--- a/src/main-win.c
+++ b/src/main-win.c
@@ -74,9 +74,6 @@
#include "util.h"
#include "variable.h"
-#ifdef WINDOWS
-
-
/*
* Extract the "WIN32" flag from the compiler
*/
@@ -3349,8 +3346,3 @@ int FAR PASCAL WinMain(HINSTANCE hInst, HINSTANCE hPrevInst,
/* Paranoia */
return (0);
}
-
-
-#endif /* WINDOWS */
-
-
diff --git a/src/main-x11.c b/src/main-x11.c
index b4b242e5..99778c77 100644
--- a/src/main-x11.c
+++ b/src/main-x11.c
@@ -93,11 +93,10 @@
*/
#include "loadsave.h"
+#include "main.h"
#include "util.h"
#include "variable.h"
-#ifdef USE_X11
-
#ifndef __MAKEDEPEND__
#include <X11/Xlib.h>
#include <X11/Xutil.h>
@@ -2584,5 +2583,13 @@ errr init_x11(int argc, char *argv[])
return (0);
}
-#endif /* USE_X11 */
-
+int main(int argc, char *argv[])
+{
+ return main_real(
+ argc,
+ argv,
+ "x11",
+ init_x11,
+ " -- -n# Number of terms to use\n"
+ " -- -d<name> Display to use\n");
+}
diff --git a/src/main.c b/src/main.cc
index 9845c21f..7badc9bb 100644
--- a/src/main.c
+++ b/src/main.cc
@@ -1,5 +1,3 @@
-/* File: main.c */
-
/*
* Copyright (c) 1997 Ben Harrison, and others
*
@@ -8,23 +6,17 @@
* are included in all such copies.
*/
-#include "birth.h"
+#include "main.h"
+
+#include "birth.hpp"
#include "dungeon.h"
-#include "files.h"
+#include "files.hpp"
#include "init2.h"
-#include "modules.h"
+#include "modules.hpp"
#include "util.h"
+#include "util.hpp"
#include "variable.h"
-
-
-
-/*
- * Some machines have a "main()" function in their "main-xxx.c" file,
- * all the others use this file for their "main()" function.
- */
-
-
-#if !defined(WINDOWS)
+#include "variable.hpp"
/*
@@ -83,7 +75,6 @@ static void init_save_dir(void)
}
}
-
static void init_player_name()
{
/* Get the user id (?) */
@@ -94,22 +85,50 @@ static void init_player_name()
}
+/*
+ * Initialize and verify the file paths, and the score file.
+ *
+ * Use the ANGBAND_PATH environment var if possible, else use
+ * DEFAULT_PATH, and in either case, branch off appropriately.
+ *
+ * First, we'll look for the ANGBAND_PATH environment variable,
+ * and then look for the files in there. If that doesn't work,
+ * we'll try the DEFAULT_PATH constant. So be sure that one of
+ * these two things works...
+ *
+ * We must ensure that the path ends with "PATH_SEP" if needed,
+ * since the "init_file_paths()" function will simply append the
+ * relevant "sub-directory names" to the given path.
+ */
+static void init_file_paths_with_env()
+{
+ char path[1024];
+
+ /* Get the environment variable */
+ cptr tail = getenv("TOME_PATH");
+
+ /* Use the angband_path, or a default */
+ strcpy(path, tail ? tail : DEFAULT_PATH);
+
+ /* Hack -- Add a path separator (only if needed) */
+ if (!suffix(path, PATH_SEP)) strcat(path, PATH_SEP);
+
+ /* Initialize */
+ init_file_paths(path);
+}
+
/*
* Simple "main" function for multiple platforms.
*
* Note the special "--" option which terminates the processing of
* standard options. All non-standard options (if any) are passed
- * directly to the "init_xxx()" function.
+ * directly to the platform initialization function.
*/
-int main(int argc, char *argv[])
+int main_real(int argc, char *argv[], char const *platform_sys, int (*init_platform)(int, char *[]), char const *platform_usage)
{
int i;
- bool_ done = FALSE;
-
- cptr mstr = NULL;
-
bool_ args = TRUE;
/* Get the file paths */
@@ -162,13 +181,6 @@ int main(int argc, char *argv[])
break;
}
- case 'm':
- {
- if (!argv[i][2]) goto usage;
- mstr = &argv[i][2];
- break;
- }
-
case 'M':
{
if (!argv[i][2]) goto usage;
@@ -179,13 +191,14 @@ int main(int argc, char *argv[])
case 'h':
{
goto usage;
- break;
}
case '-':
{
if (argv[i][2] == 'h' && !strcmp((argv[i] + 2), "help"))
+ {
goto usage;
+ }
else
{
argv[i] = argv[0];
@@ -210,40 +223,10 @@ usage:
puts(" -o Request original keyset");
puts(" -r Request rogue-like keyset");
puts(" -u<who> Use your <who> savefile");
- puts(" -M<which> Use the <which> module");
- puts(" -m<sys> Force 'main-<sys>.c' usage");
-
-#ifdef USE_GTK2
- puts(" -mgtk2 To use GTK2");
- puts(" -- Sub options");
- puts(" -- -n# Number of terms to use");
- puts(" -- -b Turn off software backing store");
-#endif /* USE_GTK2 */
-
-#ifdef USE_X11
- puts(" -mx11 To use X11");
- puts(" -- Sub options");
- puts(" -- -n# Number of terms to use");
- puts(" -- -d<name> Display to use");
-#endif /* USE_X11 */
-
-#ifdef USE_GCU
- puts(" -mgcu To use curses");
- puts(" -- Sub options");
- puts(" -- -b Requests big screen");
-#endif /* USE_GCU */
+ puts(" -M<which> Use the <which> module");
-#ifdef USE_SDL
- puts(" -msdl To use SDL");
puts(" -- Sub options");
- puts(" -- -n # Number of virtual consoles to use");
- puts(" -- -w # Request screen width in pixels");
- puts(" -- -h # Request screen height in pixels");
- puts(" -- -bpp # Request screen color depth in bits");
- puts(" -- -fs Start with full-screen display");
- puts(" -- -s # Request font size");
- puts(" -- -f <font> Request true-type font by name");
-#endif /* USE_SDL */
+ puts(platform_usage);
/* Actually abort the process */
quit(NULL);
@@ -266,77 +249,28 @@ usage:
/* Install "quit" hook */
quit_aux = quit_hook;
-
-#ifdef USE_GTK2
- /* Attempt to use the "main-gtk2.c" support */
- if (!done && (!mstr || (streq(mstr, "gtk2"))))
- {
- extern errr init_gtk2(int, char**);
- if (0 == init_gtk2(argc, argv))
- {
- ANGBAND_SYS = "gtk2";
- done = TRUE;
- }
- }
-#endif
-
-#ifdef USE_X11
- /* Attempt to use the "main-x11.c" support */
- if (!done && (!mstr || (streq(mstr, "x11"))))
- {
- extern errr init_x11(int, char**);
- if (0 == init_x11(argc, argv))
- {
- ANGBAND_SYS = "x11";
- done = TRUE;
- }
- }
-#endif
-
-#ifdef USE_GCU
- /* Attempt to use the "main-gcu.c" support */
- if (!done && (!mstr || (streq(mstr, "gcu"))))
+ /* Run the platform main initialization */
+ if (init_platform(argc, argv))
{
- extern errr init_gcu(int, char**);
- if (0 == init_gcu(argc, argv))
- {
- ANGBAND_SYS = "gcu";
- done = TRUE;
- }
+ quit("Unable to prepare any 'display module'!");
}
-#endif
-
-#ifdef USE_SDL
- /* Attempt to use the "main-sdl.c" support */
- if (!done && (!mstr || (streq(mstr, "sdl"))))
+ else
{
- extern errr init_sdl(int, char**);
- if (0 == init_sdl(argc, argv))
- {
- ANGBAND_SYS = "sdl";
- done = TRUE;
- }
- }
-#endif
+ ANGBAND_SYS = platform_sys;
- /* Make sure we have a display! */
- if (!done) quit("Unable to prepare any 'display module'!");
+ /* Initialize */
+ init_angband();
+ /* Wait for response */
+ pause_line(23);
- /* Initialize */
- init_angband();
-
- /* Wait for response */
- pause_line(23);
+ /* Play the game */
+ play_game();
- /* Play the game */
- play_game();
-
- /* Quit */
- quit(NULL);
+ /* Quit */
+ quit(NULL);
+ }
/* Exit */
return (0);
}
-
-#endif
diff --git a/src/main.h b/src/main.h
new file mode 100644
index 00000000..edc590b3
--- /dev/null
+++ b/src/main.h
@@ -0,0 +1,11 @@
+#pragma once
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+int main_real(int argc, char *argv[], char const *platform_sys, int (*init_platform)(int, char *[]), char const *platform_usage);
+
+#ifdef __cplusplus
+} // extern "C"
+#endif
diff --git a/src/modules.cc b/src/modules.cc
index c5d065f4..a0014502 100644
--- a/src/modules.cc
+++ b/src/modules.cc
@@ -7,7 +7,6 @@
*/
#include "modules.hpp"
-#include "modules.h"
#include "birth.hpp"
#include "cave.hpp"
diff --git a/src/modules.h b/src/modules.h
deleted file mode 100644
index 8a3b88b0..00000000
--- a/src/modules.h
+++ /dev/null
@@ -1,15 +0,0 @@
-#pragma once
-
-#include "h-basic.h"
-
-// C linkage required for these functions since main-* code uses them.
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-extern bool_ private_check_user_directory(cptr dirpath);
-extern cptr force_module;
-
-#ifdef __cplusplus
-} // extern "C"
-#endif
diff --git a/src/modules.hpp b/src/modules.hpp
index d83e3e2e..7a8a055f 100644
--- a/src/modules.hpp
+++ b/src/modules.hpp
@@ -9,3 +9,5 @@ extern void theme_intro();
extern s16b *theme_race_status(int r_idx);
extern void init_hooks_module();
extern int find_module(cptr name);
+extern bool_ private_check_user_directory(cptr dirpath);
+extern cptr force_module;
diff --git a/src/util.h b/src/util.h
index 4ae797b9..6d9d4655 100644
--- a/src/util.h
+++ b/src/util.h
@@ -7,15 +7,12 @@
extern "C" {
#endif
-extern errr path_parse(char *buf, int max, cptr file);
extern errr path_build(char *buf, int max, cptr path, cptr file);
extern void bell(void);
extern errr macro_add(cptr pat, cptr act);
extern sint macro_find_exact(cptr pat);
extern char inkey(void);
extern void prt(cptr str, int row, int col);
-extern void pause_line(int row);
-extern void user_name(char *buf, int id);
#ifdef __cplusplus
} // extern "C"
diff --git a/src/util.hpp b/src/util.hpp
index deddff42..ebeee8c5 100644
--- a/src/util.hpp
+++ b/src/util.hpp
@@ -72,3 +72,6 @@ extern void get_count(int number, int max);
extern bool in_bounds(int y, int x);
extern bool in_bounds2(int y, int x);
extern bool panel_contains(int y, int x);
+extern errr path_parse(char *buf, int max, cptr file);
+extern void pause_line(int row);
+extern void user_name(char *buf, int id);
diff --git a/src/variable.h b/src/variable.h
index 7621149a..6d6e5775 100644
--- a/src/variable.h
+++ b/src/variable.h
@@ -7,10 +7,7 @@ extern "C" {
#endif
extern cptr ANGBAND_SYS;
-extern char *ANGBAND_DIR_MODULES;
extern char *ANGBAND_DIR_SAVE;
-extern char *ANGBAND_DIR_CORE;
-extern char *ANGBAND_DIR_DNGN;
extern char *ANGBAND_DIR_DATA;
extern char *ANGBAND_DIR_EDIT;
extern char *ANGBAND_DIR_FILE;
@@ -23,15 +20,10 @@ extern char *ANGBAND_DIR_XTRA;
extern term *angband_term[ANGBAND_TERM_MAX];
extern char angband_term_name[ANGBAND_TERM_MAX][80];
extern byte angband_color_table[256][4];
-extern bool_ arg_wizard;
-extern bool_ arg_force_original;
-extern bool_ arg_force_roguelike;
extern bool_ character_generated;
extern bool_ character_icky;
extern bool_ inkey_flag;
extern bool_ msg_flag;
-extern char player_name[32];
-extern char player_base[32];
extern char savefile[1024];
#ifdef __cplusplus
diff --git a/src/variable.hpp b/src/variable.hpp
index ab52f5b6..877a5597 100644
--- a/src/variable.hpp
+++ b/src/variable.hpp
@@ -190,6 +190,8 @@ extern player_race_mod *rmp_ptr;
extern player_class *cp_ptr;
extern player_spec *spp_ptr;
extern s16b player_hp[PY_MAX_LEVEL];
+extern char player_name[32];
+extern char player_base[32];
extern ability_type *ab_info;
extern skill_type *s_info;
extern vault_type *v_info;
@@ -217,6 +219,9 @@ extern cptr DEFAULT_FEAT_TEXT;
extern cptr DEFAULT_FEAT_TUNNEL;
extern cptr DEFAULT_FEAT_BLOCK;
extern char *ANGBAND_DIR;
+extern char *ANGBAND_DIR_MODULES;
+extern char *ANGBAND_DIR_CORE;
+extern char *ANGBAND_DIR_DNGN;
extern bool_ (*get_mon_num_hook)(int r_idx);
extern bool_ (*get_mon_num2_hook)(int r_idx);
extern bool_ (*get_obj_num_hook)(int k_idx);
@@ -306,3 +311,6 @@ extern timer_type *gl_timers;
extern const char *get_version_string();
extern tval_desc tvals[];
extern hist_type *bg;
+extern bool_ arg_wizard;
+extern bool_ arg_force_original;
+extern bool_ arg_force_roguelike;