Rearranged files to avoid usage of symbolic links

This commit is contained in:
alexey.lysiuk 2014-12-15 17:40:30 +02:00
parent ce70a7c66e
commit 8bc890c995
18 changed files with 958 additions and 968 deletions

View file

@ -545,19 +545,20 @@ set( PLAT_WIN32_SOURCES
win32/i_system.cpp win32/i_system.cpp
win32/st_start.cpp win32/st_start.cpp
win32/win32video.cpp ) win32/win32video.cpp )
set( PLAT_POSIX_SOURCES
posix/i_cd.cpp
posix/i_movie.cpp
posix/i_system.cpp
posix/st_start.cpp )
set( PLAT_SDL_SOURCES set( PLAT_SDL_SOURCES
sdl/crashcatcher.c sdl/crashcatcher.c
sdl/hardware.cpp sdl/hardware.cpp
sdl/i_cd.cpp
sdl/i_gui.cpp sdl/i_gui.cpp
sdl/i_input.cpp sdl/i_input.cpp
sdl/i_joystick.cpp sdl/i_joystick.cpp
sdl/i_main.cpp sdl/i_main.cpp
sdl/i_movie.cpp
sdl/i_system.cpp
sdl/i_timer.cpp sdl/i_timer.cpp
sdl/sdlvideo.cpp sdl/sdlvideo.cpp )
sdl/st_start.cpp )
set( PLAT_MAC_SOURCES set( PLAT_MAC_SOURCES
cocoa/iwadpicker_cocoa.mm ) cocoa/iwadpicker_cocoa.mm )
set( PLAT_COCOA_SOURCES set( PLAT_COCOA_SOURCES
@ -571,18 +572,14 @@ set( PLAT_COCOA_SOURCES
cocoa/hid/ImmrHIDUtilAddOn.c cocoa/hid/ImmrHIDUtilAddOn.c
cocoa/critsec.cpp cocoa/critsec.cpp
cocoa/i_backend_cocoa.mm cocoa/i_backend_cocoa.mm
cocoa/i_cd.cpp
cocoa/i_joystick.cpp cocoa/i_joystick.cpp
cocoa/i_movie.cpp
cocoa/i_system.cpp
cocoa/i_timer.cpp cocoa/i_timer.cpp
cocoa/st_start.cpp
cocoa/zdoom.icns ) cocoa/zdoom.icns )
if( WIN32 ) if( WIN32 )
set( SYSTEM_SOURCES_DIR win32 ) set( SYSTEM_SOURCES_DIR win32 )
set( SYSTEM_SOURCES ${PLAT_WIN32_SOURCES} ) set( SYSTEM_SOURCES ${PLAT_WIN32_SOURCES} )
set( OTHER_SYSTEM_SOURCES ${PLAT_SDL_SOURCES} ${PLAT_MAC_SOURCES} ${PLAT_COCOA_SOURCES} ) set( OTHER_SYSTEM_SOURCES ${PLAT_POSIX_SOURCES} ${PLAT_SDL_SOURCES} ${PLAT_MAC_SOURCES} ${PLAT_COCOA_SOURCES} )
if( ZD_CMAKE_COMPILER_IS_GNUCXX_COMPATIBLE ) if( ZD_CMAKE_COMPILER_IS_GNUCXX_COMPATIBLE )
# CMake is not set up to compile and link rc files with GCC. :( # CMake is not set up to compile and link rc files with GCC. :(
@ -595,23 +592,23 @@ if( WIN32 )
endif( ZD_CMAKE_COMPILER_IS_GNUCXX_COMPATIBLE ) endif( ZD_CMAKE_COMPILER_IS_GNUCXX_COMPATIBLE )
elseif( APPLE ) elseif( APPLE )
if( OSX_COCOA_BACKEND ) if( OSX_COCOA_BACKEND )
set( SYSTEM_SOURCES_DIR cocoa ) set( SYSTEM_SOURCES_DIR posix cocoa )
set( SYSTEM_SOURCES ${PLAT_COCOA_SOURCES} ) set( SYSTEM_SOURCES ${PLAT_COCOA_SOURCES} )
set( OTHER_SYSTEM_SOURCES ${PLAT_WIN32_SOURCES} ${PLAT_SDL_SOURCES} ) set( OTHER_SYSTEM_SOURCES ${PLAT_WIN32_SOURCES} ${PLAT_SDL_SOURCES} )
else( OSX_COCOA_BACKEND ) else( OSX_COCOA_BACKEND )
set( SYSTEM_SOURCES_DIR sdl ) set( SYSTEM_SOURCES_DIR posix sdl )
set( SYSTEM_SOURCES ${PLAT_SDL_SOURCES} ) set( SYSTEM_SOURCES ${PLAT_SDL_SOURCES} )
set( PLAT_MAC_SOURCES ${PLAT_MAC_SOURCES} cocoa/i_system_cocoa.mm ) set( PLAT_MAC_SOURCES ${PLAT_MAC_SOURCES} cocoa/i_system_cocoa.mm )
set( OTHER_SYSTEM_SOURCES ${PLAT_WIN32_SOURCES} ${PLAT_COCOA_SOURCES} ) set( OTHER_SYSTEM_SOURCES ${PLAT_WIN32_SOURCES} ${PLAT_COCOA_SOURCES} )
endif( OSX_COCOA_BACKEND ) endif( OSX_COCOA_BACKEND )
set( SYSTEM_SOURCES ${SYSTEM_SOURCES} ${PLAT_MAC_SOURCES} "${FMOD_LIBRARY}" ) set( SYSTEM_SOURCES ${SYSTEM_SOURCES} ${PLAT_POSIX_SOURCES} ${PLAT_MAC_SOURCES} "${FMOD_LIBRARY}" )
set_source_files_properties( cocoa/zdoom.icns PROPERTIES MACOSX_PACKAGE_LOCATION Resources ) set_source_files_properties( cocoa/zdoom.icns PROPERTIES MACOSX_PACKAGE_LOCATION Resources )
set_source_files_properties( "${FMOD_LIBRARY}" PROPERTIES MACOSX_PACKAGE_LOCATION Frameworks ) set_source_files_properties( "${FMOD_LIBRARY}" PROPERTIES MACOSX_PACKAGE_LOCATION Frameworks )
else( WIN32 ) else( WIN32 )
set( SYSTEM_SOURCES_DIR sdl ) set( SYSTEM_SOURCES_DIR posix sdl )
set( SYSTEM_SOURCES ${PLAT_SDL_SOURCES} ) set( SYSTEM_SOURCES ${PLAT_POSIX_SOURCES} ${PLAT_SDL_SOURCES} )
set( OTHER_SYSTEM_SOURCES ${PLAT_WIN32_SOURCES} ${PLAT_MAC_SOURCES} ${PLAT_COCOA_SOURCES} ) set( OTHER_SYSTEM_SOURCES ${PLAT_WIN32_SOURCES} ${PLAT_MAC_SOURCES} ${PLAT_COCOA_SOURCES} )
endif( WIN32 ) endif( WIN32 )
@ -672,12 +669,12 @@ if( WIN32 )
set( EXTRA_HEADER_DIRS win32/*.h ) set( EXTRA_HEADER_DIRS win32/*.h )
elseif( APPLE ) elseif( APPLE )
if( OSX_COCOA_BACKEND ) if( OSX_COCOA_BACKEND )
set( EXTRA_HEADER_DIRS cocoa/*.h ) set( EXTRA_HEADER_DIRS posix/*.h cocoa/*.h )
else( OSX_COCOA_BACKEND ) else( OSX_COCOA_BACKEND )
set( EXTRA_HEADER_DIRS sdl/*.h ) set( EXTRA_HEADER_DIRS posix/*.h sdl/*.h )
endif( OSX_COCOA_BACKEND ) endif( OSX_COCOA_BACKEND )
else( WIN32 ) else( WIN32 )
set( EXTRA_HEADER_DIRS sdl/*.h ) set( EXTRA_HEADER_DIRS posix/*.h sdl/*.h )
endif( WIN32 ) endif( WIN32 )
file( GLOB HEADER_FILES file( GLOB HEADER_FILES
${EXTRA_HEADER_DIRS} ${EXTRA_HEADER_DIRS}
@ -693,6 +690,7 @@ file( GLOB HEADER_FILES
menu/*.h menu/*.h
oplsynth/*.h oplsynth/*.h
oplsynth/dosbox/*.h oplsynth/dosbox/*.h
posix/*.h
r_data/*.h r_data/*.h
resourcefiles/*.h resourcefiles/*.h
sdl/*.h sdl/*.h

View file

@ -1 +0,0 @@
../sdl/dikeys.h

View file

@ -1 +0,0 @@
../sdl/hardware.h

View file

@ -1 +0,0 @@
../sdl/i_cd.cpp

View file

@ -1 +0,0 @@
../sdl/i_input.h

View file

@ -1 +0,0 @@
../sdl/i_movie.cpp

View file

@ -1 +0,0 @@
../sdl/i_system.cpp

View file

@ -1 +0,0 @@
../sdl/i_system.h

View file

@ -1 +0,0 @@
../sdl/st_start.cpp

View file

@ -1,155 +1,155 @@
// ZDoom bases its keycodes on DirectInput's scan codes // ZDoom bases its keycodes on DirectInput's scan codes
// Why? Because it was Win32-only before porting to anything else, // Why? Because it was Win32-only before porting to anything else,
// so this made sense. AFAIK, it's primarily used under Win32 now, // so this made sense. AFAIK, it's primarily used under Win32 now,
// so it still makes sense. // so it still makes sense.
// //
// Actually, these key codes may only be used for key bindings now, // Actually, these key codes may only be used for key bindings now,
// in which case they're not really necessary--if we tweaked c_bind.cpp. // in which case they're not really necessary--if we tweaked c_bind.cpp.
enum enum
{ {
DIK_ESCAPE = 1, DIK_ESCAPE = 1,
DIK_1, DIK_1,
DIK_2, DIK_2,
DIK_3, DIK_3,
DIK_4, DIK_4,
DIK_5, DIK_5,
DIK_6, DIK_6,
DIK_7, DIK_7,
DIK_8, DIK_8,
DIK_9, DIK_9,
DIK_0, DIK_0,
DIK_MINUS, /* - on main keyboard */ DIK_MINUS, /* - on main keyboard */
DIK_EQUALS, DIK_EQUALS,
DIK_BACK, /* backspace */ DIK_BACK, /* backspace */
DIK_TAB, DIK_TAB,
DIK_Q, DIK_Q,
DIK_W, DIK_W,
DIK_E, DIK_E,
DIK_R, DIK_R,
DIK_T, DIK_T,
DIK_Y, DIK_Y,
DIK_U, DIK_U,
DIK_I, DIK_I,
DIK_O, DIK_O,
DIK_P, DIK_P,
DIK_LBRACKET, DIK_LBRACKET,
DIK_RBRACKET, DIK_RBRACKET,
DIK_RETURN, /* Enter on main keyboard */ DIK_RETURN, /* Enter on main keyboard */
DIK_LCONTROL, DIK_LCONTROL,
DIK_A, DIK_A,
DIK_S, DIK_S,
DIK_D, DIK_D,
DIK_F, DIK_F,
DIK_G, DIK_G,
DIK_H, DIK_H,
DIK_J, DIK_J,
DIK_K, DIK_K,
DIK_L, DIK_L,
DIK_SEMICOLON, DIK_SEMICOLON,
DIK_APOSTROPHE, DIK_APOSTROPHE,
DIK_GRAVE, /* accent grave */ DIK_GRAVE, /* accent grave */
DIK_LSHIFT, DIK_LSHIFT,
DIK_BACKSLASH, DIK_BACKSLASH,
DIK_Z, DIK_Z,
DIK_X, DIK_X,
DIK_C, DIK_C,
DIK_V, DIK_V,
DIK_B, DIK_B,
DIK_N, DIK_N,
DIK_M, DIK_M,
DIK_COMMA, DIK_COMMA,
DIK_PERIOD, /* . on main keyboard */ DIK_PERIOD, /* . on main keyboard */
DIK_SLASH, /* / on main keyboard */ DIK_SLASH, /* / on main keyboard */
DIK_RSHIFT, DIK_RSHIFT,
DIK_MULTIPLY, /* * on numeric keypad */ DIK_MULTIPLY, /* * on numeric keypad */
DIK_LMENU, /* left Alt */ DIK_LMENU, /* left Alt */
DIK_SPACE, DIK_SPACE,
DIK_CAPITAL, DIK_CAPITAL,
DIK_F1, DIK_F1,
DIK_F2, DIK_F2,
DIK_F3, DIK_F3,
DIK_F4, DIK_F4,
DIK_F5, DIK_F5,
DIK_F6, DIK_F6,
DIK_F7, DIK_F7,
DIK_F8, DIK_F8,
DIK_F9, DIK_F9,
DIK_F10, DIK_F10,
DIK_NUMLOCK, DIK_NUMLOCK,
DIK_SCROLL, /* Scroll Lock */ DIK_SCROLL, /* Scroll Lock */
DIK_NUMPAD7, DIK_NUMPAD7,
DIK_NUMPAD8, DIK_NUMPAD8,
DIK_NUMPAD9, DIK_NUMPAD9,
DIK_SUBTRACT, /* - on numeric keypad */ DIK_SUBTRACT, /* - on numeric keypad */
DIK_NUMPAD4, DIK_NUMPAD4,
DIK_NUMPAD5, DIK_NUMPAD5,
DIK_NUMPAD6, DIK_NUMPAD6,
DIK_ADD, /* + on numeric keypad */ DIK_ADD, /* + on numeric keypad */
DIK_NUMPAD1, DIK_NUMPAD1,
DIK_NUMPAD2, DIK_NUMPAD2,
DIK_NUMPAD3, DIK_NUMPAD3,
DIK_NUMPAD0, DIK_NUMPAD0,
DIK_DECIMAL, /* . on numeric keypad */ DIK_DECIMAL, /* . on numeric keypad */
DIK_OEM_102 = 0x56, /* < > | on UK/Germany keyboards */ DIK_OEM_102 = 0x56, /* < > | on UK/Germany keyboards */
DIK_F11, DIK_F11,
DIK_F12, DIK_F12,
DIK_F13 = 0x64, /* (NEC PC98) */ DIK_F13 = 0x64, /* (NEC PC98) */
DIK_F14, /* (NEC PC98) */ DIK_F14, /* (NEC PC98) */
DIK_F15, /* (NEC PC98) */ DIK_F15, /* (NEC PC98) */
DIK_KANA = 0x70, /* (Japanese keyboard) */ DIK_KANA = 0x70, /* (Japanese keyboard) */
DIK_ABNT_C1 = 0x73, /* / ? on Portugese (Brazilian) keyboards */ DIK_ABNT_C1 = 0x73, /* / ? on Portugese (Brazilian) keyboards */
DIK_CONVERT = 0x79, /* (Japanese keyboard) */ DIK_CONVERT = 0x79, /* (Japanese keyboard) */
DIK_NOCONVERT = 0x7B, /* (Japanese keyboard) */ DIK_NOCONVERT = 0x7B, /* (Japanese keyboard) */
DIK_YEN = 0x7D, /* (Japanese keyboard) */ DIK_YEN = 0x7D, /* (Japanese keyboard) */
DIK_ABNT_C2 = 0x7E, /* Numpad . on Portugese (Brazilian) keyboards */ DIK_ABNT_C2 = 0x7E, /* Numpad . on Portugese (Brazilian) keyboards */
DIK_NUMPAD_EQUALS = 0x8D, /* = on numeric keypad (NEC PC98) */ DIK_NUMPAD_EQUALS = 0x8D, /* = on numeric keypad (NEC PC98) */
DIK_PREVTRACK = 0x90, /* Previous Track (DIK_CIRCUMFLEX on Japanese keyboard) */ DIK_PREVTRACK = 0x90, /* Previous Track (DIK_CIRCUMFLEX on Japanese keyboard) */
DIK_AT, /* (NEC PC98) */ DIK_AT, /* (NEC PC98) */
DIK_COLON, /* (NEC PC98) */ DIK_COLON, /* (NEC PC98) */
DIK_UNDERLINE, /* (NEC PC98) */ DIK_UNDERLINE, /* (NEC PC98) */
DIK_KANJI, /* (Japanese keyboard) */ DIK_KANJI, /* (Japanese keyboard) */
DIK_STOP, /* (NEC PC98) */ DIK_STOP, /* (NEC PC98) */
DIK_AX, /* (Japan AX) */ DIK_AX, /* (Japan AX) */
DIK_UNLABELED, /* (J3100) */ DIK_UNLABELED, /* (J3100) */
DIK_NEXTTRACK = 0x99, /* Next Track */ DIK_NEXTTRACK = 0x99, /* Next Track */
DIK_NUMPADENTER = 0x9C, /* Enter on numeric keypad */ DIK_NUMPADENTER = 0x9C, /* Enter on numeric keypad */
DIK_RCONTROL = 0x9D, DIK_RCONTROL = 0x9D,
DIK_MUTE = 0xA0, /* Mute */ DIK_MUTE = 0xA0, /* Mute */
DIK_CALCULATOR = 0xA1, /* Calculator */ DIK_CALCULATOR = 0xA1, /* Calculator */
DIK_PLAYPAUSE = 0xA2, /* Play / Pause */ DIK_PLAYPAUSE = 0xA2, /* Play / Pause */
DIK_MEDIASTOP = 0xA4, /* Media Stop */ DIK_MEDIASTOP = 0xA4, /* Media Stop */
DIK_VOLUMEDOWN = 0xAE, /* Volume - */ DIK_VOLUMEDOWN = 0xAE, /* Volume - */
DIK_VOLUMEUP = 0xB0, /* Volume + */ DIK_VOLUMEUP = 0xB0, /* Volume + */
DIK_WEBHOME = 0xB2, /* Web home */ DIK_WEBHOME = 0xB2, /* Web home */
DIK_NUMPADCOMMA = 0xB3, /* , on numeric keypad (NEC PC98) */ DIK_NUMPADCOMMA = 0xB3, /* , on numeric keypad (NEC PC98) */
DIK_DIVIDE = 0xB5, /* / on numeric keypad */ DIK_DIVIDE = 0xB5, /* / on numeric keypad */
DIK_SYSRQ = 0xB7, DIK_SYSRQ = 0xB7,
DIK_RMENU = 0xB8, /* right Alt */ DIK_RMENU = 0xB8, /* right Alt */
DIK_PAUSE = 0xC5, /* Pause */ DIK_PAUSE = 0xC5, /* Pause */
DIK_HOME = 0xC7, /* Home on arrow keypad */ DIK_HOME = 0xC7, /* Home on arrow keypad */
DIK_UP = 0xC8, /* UpArrow on arrow keypad */ DIK_UP = 0xC8, /* UpArrow on arrow keypad */
DIK_PRIOR = 0xC9, /* PgUp on arrow keypad */ DIK_PRIOR = 0xC9, /* PgUp on arrow keypad */
DIK_LEFT = 0xCB, /* LeftArrow on arrow keypad */ DIK_LEFT = 0xCB, /* LeftArrow on arrow keypad */
DIK_RIGHT = 0xCD, /* RightArrow on arrow keypad */ DIK_RIGHT = 0xCD, /* RightArrow on arrow keypad */
DIK_END = 0xCF, /* End on arrow keypad */ DIK_END = 0xCF, /* End on arrow keypad */
DIK_DOWN = 0xD0, /* DownArrow on arrow keypad */ DIK_DOWN = 0xD0, /* DownArrow on arrow keypad */
DIK_NEXT = 0xD1, /* PgDn on arrow keypad */ DIK_NEXT = 0xD1, /* PgDn on arrow keypad */
DIK_INSERT = 0xD2, /* Insert on arrow keypad */ DIK_INSERT = 0xD2, /* Insert on arrow keypad */
DIK_DELETE = 0xD3, /* Delete on arrow keypad */ DIK_DELETE = 0xD3, /* Delete on arrow keypad */
DIK_LWIN = 0xDB, /* Left Windows key */ DIK_LWIN = 0xDB, /* Left Windows key */
DIK_RWIN = 0xDC, /* Right Windows key */ DIK_RWIN = 0xDC, /* Right Windows key */
DIK_APPS = 0xDD, /* AppMenu key */ DIK_APPS = 0xDD, /* AppMenu key */
DIK_POWER = 0xDE, /* System Power */ DIK_POWER = 0xDE, /* System Power */
DIK_SLEEP = 0xDF, /* System Sleep */ DIK_SLEEP = 0xDF, /* System Sleep */
DIK_WAKE = 0xE3, /* System Wake */ DIK_WAKE = 0xE3, /* System Wake */
DIK_WEBSEARCH = 0xE5, /* Web Search */ DIK_WEBSEARCH = 0xE5, /* Web Search */
DIK_WEBFAVORITES = 0xE6, /* Web Favorites */ DIK_WEBFAVORITES = 0xE6, /* Web Favorites */
DIK_WEBREFRESH = 0xE7, /* Web Refresh */ DIK_WEBREFRESH = 0xE7, /* Web Refresh */
DIK_WEBSTOP = 0xE8, /* Web Stop */ DIK_WEBSTOP = 0xE8, /* Web Stop */
DIK_WEBFORWARD = 0xE9, /* Web Forward */ DIK_WEBFORWARD = 0xE9, /* Web Forward */
DIK_WEBBACK = 0xEA, /* Web Back */ DIK_WEBBACK = 0xEA, /* Web Back */
DIK_MYCOMPUTER = 0xEB, /* My Computer */ DIK_MYCOMPUTER = 0xEB, /* My Computer */
DIK_MAIL = 0xEC, /* Mail */ DIK_MAIL = 0xEC, /* Mail */
DIK_MEDIASELECT = 0xED /* Media Select */ DIK_MEDIASELECT = 0xED /* Media Select */
}; };

View file

@ -1,96 +1,96 @@
/* /*
** hardware.h ** hardware.h
** **
**--------------------------------------------------------------------------- **---------------------------------------------------------------------------
** Copyright 1998-2006 Randy Heit ** Copyright 1998-2006 Randy Heit
** All rights reserved. ** All rights reserved.
** **
** Redistribution and use in source and binary forms, with or without ** Redistribution and use in source and binary forms, with or without
** modification, are permitted provided that the following conditions ** modification, are permitted provided that the following conditions
** are met: ** are met:
** **
** 1. Redistributions of source code must retain the above copyright ** 1. Redistributions of source code must retain the above copyright
** notice, this list of conditions and the following disclaimer. ** notice, this list of conditions and the following disclaimer.
** 2. Redistributions in binary form must reproduce the above copyright ** 2. Redistributions in binary form must reproduce the above copyright
** notice, this list of conditions and the following disclaimer in the ** notice, this list of conditions and the following disclaimer in the
** documentation and/or other materials provided with the distribution. ** documentation and/or other materials provided with the distribution.
** 3. The name of the author may not be used to endorse or promote products ** 3. The name of the author may not be used to endorse or promote products
** derived from this software without specific prior written permission. ** derived from this software without specific prior written permission.
** **
** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR ** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES ** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. ** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, ** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT ** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, ** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY ** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT ** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF ** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
**--------------------------------------------------------------------------- **---------------------------------------------------------------------------
** **
*/ */
#ifndef __HARDWARE_H__ #ifndef __HARDWARE_H__
#define __HARDWARE_H__ #define __HARDWARE_H__
#include "i_video.h" #include "i_video.h"
#include "v_video.h" #include "v_video.h"
// Semaphores // Semaphores
#ifdef __APPLE__ #ifdef __APPLE__
#include <mach/mach_init.h> #include <mach/mach_init.h>
#include <mach/semaphore.h> #include <mach/semaphore.h>
#include <mach/task.h> #include <mach/task.h>
typedef semaphore_t Semaphore; typedef semaphore_t Semaphore;
#define SEMAPHORE_WAIT(sem) \ #define SEMAPHORE_WAIT(sem) \
while(semaphore_wait(sem) != KERN_SUCCESS){} while(semaphore_wait(sem) != KERN_SUCCESS){}
#define SEMAPHORE_SIGNAL(sem) \ #define SEMAPHORE_SIGNAL(sem) \
semaphore_signal(sem); semaphore_signal(sem);
#define SEMAPHORE_INIT(sem, shared, value) \ #define SEMAPHORE_INIT(sem, shared, value) \
semaphore_create(mach_task_self(), &sem, shared, value); semaphore_create(mach_task_self(), &sem, shared, value);
#else #else
#include <semaphore.h> #include <semaphore.h>
typedef sem_t Semaphore; typedef sem_t Semaphore;
#define SEMAPHORE_WAIT(sem) \ #define SEMAPHORE_WAIT(sem) \
do { \ do { \
while(sem_wait(&sem) != 0); \ while(sem_wait(&sem) != 0); \
int semValue; \ int semValue; \
sem_getvalue(&sem, &semValue); \ sem_getvalue(&sem, &semValue); \
if(semValue < 1) \ if(semValue < 1) \
break; \ break; \
} while(true); } while(true);
#define SEMAPHORE_SIGNAL(sem) \ #define SEMAPHORE_SIGNAL(sem) \
sem_post(&sem); sem_post(&sem);
#define SEMAPHORE_INIT(sem, shared, value) \ #define SEMAPHORE_INIT(sem, shared, value) \
sem_init(&sem, shared, value); sem_init(&sem, shared, value);
#endif #endif
class IVideo class IVideo
{ {
public: public:
virtual ~IVideo () {} virtual ~IVideo () {}
virtual EDisplayType GetDisplayType () = 0; virtual EDisplayType GetDisplayType () = 0;
virtual void SetWindowedScale (float scale) = 0; virtual void SetWindowedScale (float scale) = 0;
virtual DFrameBuffer *CreateFrameBuffer (int width, int height, bool fs, DFrameBuffer *old) = 0; virtual DFrameBuffer *CreateFrameBuffer (int width, int height, bool fs, DFrameBuffer *old) = 0;
virtual void StartModeIterator (int bits, bool fs) = 0; virtual void StartModeIterator (int bits, bool fs) = 0;
virtual bool NextMode (int *width, int *height, bool *letterbox) = 0; virtual bool NextMode (int *width, int *height, bool *letterbox) = 0;
virtual bool SetResolution (int width, int height, int bits); virtual bool SetResolution (int width, int height, int bits);
virtual void DumpAdapters(); virtual void DumpAdapters();
}; };
void I_InitGraphics (); void I_InitGraphics ();
void I_ShutdownGraphics (); void I_ShutdownGraphics ();
void I_CreateRenderer(); void I_CreateRenderer();
extern Semaphore FPSLimitSemaphore; extern Semaphore FPSLimitSemaphore;
void I_SetFPSLimit(int limit); void I_SetFPSLimit(int limit);
extern IVideo *Video; extern IVideo *Video;
#endif // __HARDWARE_H__ #endif // __HARDWARE_H__

View file

@ -1,154 +1,154 @@
#include "i_cd.h" #include "i_cd.h"
//========================================================================== //==========================================================================
// //
// CD_Init // CD_Init
// //
//========================================================================== //==========================================================================
bool CD_Init () bool CD_Init ()
{ {
return false; return false;
} }
bool CD_Init (int device) bool CD_Init (int device)
{ {
return false; return false;
} }
//========================================================================== //==========================================================================
// //
// CD_InitID // CD_InitID
// //
//========================================================================== //==========================================================================
bool CD_InitID (unsigned int id, int guess) bool CD_InitID (unsigned int id, int guess)
{ {
return false; return false;
} }
//========================================================================== //==========================================================================
// //
// CD_Close // CD_Close
// //
//========================================================================== //==========================================================================
void CD_Close () void CD_Close ()
{ {
} }
//========================================================================== //==========================================================================
// //
// CD_Eject // CD_Eject
// //
//========================================================================== //==========================================================================
void CD_Eject () void CD_Eject ()
{ {
} }
//========================================================================== //==========================================================================
// //
// CD_UnEject // CD_UnEject
// //
//========================================================================== //==========================================================================
bool CD_UnEject () bool CD_UnEject ()
{ {
return false; return false;
} }
//========================================================================== //==========================================================================
// //
// CD_Stop // CD_Stop
// //
//========================================================================== //==========================================================================
void CD_Stop () void CD_Stop ()
{ {
} }
//========================================================================== //==========================================================================
// //
// CD_Play // CD_Play
// //
//========================================================================== //==========================================================================
bool CD_Play (int track, bool looping) bool CD_Play (int track, bool looping)
{ {
return false; return false;
} }
//========================================================================== //==========================================================================
// //
// CD_PlayNoWait // CD_PlayNoWait
// //
//========================================================================== //==========================================================================
void CD_PlayNoWait (int track, bool looping) void CD_PlayNoWait (int track, bool looping)
{ {
} }
//========================================================================== //==========================================================================
// //
// CD_PlayCD // CD_PlayCD
// //
//========================================================================== //==========================================================================
bool CD_PlayCD (bool looping) bool CD_PlayCD (bool looping)
{ {
return false; return false;
} }
//========================================================================== //==========================================================================
// //
// CD_PlayCDNoWait // CD_PlayCDNoWait
// //
//========================================================================== //==========================================================================
void CD_PlayCDNoWait (bool looping) void CD_PlayCDNoWait (bool looping)
{ {
} }
//========================================================================== //==========================================================================
// //
// CD_Pause // CD_Pause
// //
//========================================================================== //==========================================================================
void CD_Pause () void CD_Pause ()
{ {
} }
//========================================================================== //==========================================================================
// //
// CD_Resume // CD_Resume
// //
//========================================================================== //==========================================================================
bool CD_Resume () bool CD_Resume ()
{ {
return false; return false;
} }
//========================================================================== //==========================================================================
// //
// CD_GetMode // CD_GetMode
// //
//========================================================================== //==========================================================================
ECDModes CD_GetMode () ECDModes CD_GetMode ()
{ {
return CDMode_Unknown; return CDMode_Unknown;
} }
//========================================================================== //==========================================================================
// //
// CD_CheckTrack // CD_CheckTrack
// //
//========================================================================== //==========================================================================
bool CD_CheckTrack (int track) bool CD_CheckTrack (int track)
{ {
return false; return false;
} }

View file

@ -1,10 +1,10 @@
#ifndef __I_INPUT_H__ #ifndef __I_INPUT_H__
#define __I_INPUT_H__ #define __I_INPUT_H__
void I_PutInClipboard (const char *str); void I_PutInClipboard (const char *str);
FString I_GetFromClipboard (bool use_primary_selection); FString I_GetFromClipboard (bool use_primary_selection);
void I_SetMouseCapture(); void I_SetMouseCapture();
void I_ReleaseMouseCapture(); void I_ReleaseMouseCapture();
#endif #endif

View file

@ -1,7 +1,7 @@
#include "i_movie.h" #include "i_movie.h"
int I_PlayMovie (const char *movie) int I_PlayMovie (const char *movie)
{ {
return MOVIE_Failed; return MOVIE_Failed;
} }

View file

@ -1,166 +1,166 @@
// Emacs style mode select -*- C++ -*- // Emacs style mode select -*- C++ -*-
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// //
// $Id:$ // $Id:$
// //
// Copyright (C) 1993-1996 by id Software, Inc. // Copyright (C) 1993-1996 by id Software, Inc.
// //
// This source is available for distribution and/or modification // This source is available for distribution and/or modification
// only under the terms of the DOOM Source Code License as // only under the terms of the DOOM Source Code License as
// published by id Software. All rights reserved. // published by id Software. All rights reserved.
// //
// The source is distributed in the hope that it will be useful, // The source is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of // but WITHOUT ANY WARRANTY; without even the implied warranty of
// FITNESS FOR A PARTICULAR PURPOSE. See the DOOM Source Code License // FITNESS FOR A PARTICULAR PURPOSE. See the DOOM Source Code License
// for more details. // for more details.
// //
// DESCRIPTION: // DESCRIPTION:
// System specific interface stuff. // System specific interface stuff.
// //
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
#ifndef __I_SYSTEM__ #ifndef __I_SYSTEM__
#define __I_SYSTEM__ #define __I_SYSTEM__
#include <dirent.h> #include <dirent.h>
#include <ctype.h> #include <ctype.h>
#include "doomtype.h" #include "doomtype.h"
struct ticcmd_t; struct ticcmd_t;
struct WadStuff; struct WadStuff;
#ifndef SHARE_DIR #ifndef SHARE_DIR
#define SHARE_DIR "/usr/local/share/" #define SHARE_DIR "/usr/local/share/"
#endif #endif
// Index values into the LanguageIDs array // Index values into the LanguageIDs array
enum enum
{ {
LANGIDX_UserPreferred, LANGIDX_UserPreferred,
LANGIDX_UserDefault, LANGIDX_UserDefault,
LANGIDX_SysPreferred, LANGIDX_SysPreferred,
LANGIDX_SysDefault LANGIDX_SysDefault
}; };
extern DWORD LanguageIDs[4]; extern DWORD LanguageIDs[4];
extern void SetLanguageIDs (); extern void SetLanguageIDs ();
// Called by DoomMain. // Called by DoomMain.
void I_Init (void); void I_Init (void);
// Called by D_DoomLoop, // Called by D_DoomLoop,
// returns current time in tics. // returns current time in tics.
extern int (*I_GetTime) (bool saveMS); extern int (*I_GetTime) (bool saveMS);
// like I_GetTime, except it waits for a new tic before returning // like I_GetTime, except it waits for a new tic before returning
extern int (*I_WaitForTic) (int); extern int (*I_WaitForTic) (int);
// Freezes tic counting temporarily. While frozen, calls to I_GetTime() // Freezes tic counting temporarily. While frozen, calls to I_GetTime()
// will always return the same value. This does not affect I_MSTime(). // will always return the same value. This does not affect I_MSTime().
// You must also not call I_WaitForTic() while freezing time, since the // You must also not call I_WaitForTic() while freezing time, since the
// tic will never arrive (unless it's the current one). // tic will never arrive (unless it's the current one).
extern void (*I_FreezeTime) (bool frozen); extern void (*I_FreezeTime) (bool frozen);
fixed_t I_GetTimeFrac (uint32 *ms); fixed_t I_GetTimeFrac (uint32 *ms);
// Return a seed value for the RNG. // Return a seed value for the RNG.
unsigned int I_MakeRNGSeed(); unsigned int I_MakeRNGSeed();
// //
// Called by D_DoomLoop, // Called by D_DoomLoop,
// called before processing any tics in a frame // called before processing any tics in a frame
// (just after displaying a frame). // (just after displaying a frame).
// Time consuming syncronous operations // Time consuming syncronous operations
// are performed here (joystick reading). // are performed here (joystick reading).
// Can call D_PostEvent. // Can call D_PostEvent.
// //
void I_StartFrame (void); void I_StartFrame (void);
// //
// Called by D_DoomLoop, // Called by D_DoomLoop,
// called before processing each tic in a frame. // called before processing each tic in a frame.
// Quick syncronous operations are performed here. // Quick syncronous operations are performed here.
// Can call D_PostEvent. // Can call D_PostEvent.
void I_StartTic (void); void I_StartTic (void);
// Asynchronous interrupt functions should maintain private queues // Asynchronous interrupt functions should maintain private queues
// that are read by the synchronous functions // that are read by the synchronous functions
// to be converted into events. // to be converted into events.
// Either returns a null ticcmd, // Either returns a null ticcmd,
// or calls a loadable driver to build it. // or calls a loadable driver to build it.
// This ticcmd will then be modified by the gameloop // This ticcmd will then be modified by the gameloop
// for normal input. // for normal input.
ticcmd_t *I_BaseTiccmd (void); ticcmd_t *I_BaseTiccmd (void);
// Called by M_Responder when quit is selected. // Called by M_Responder when quit is selected.
// Clean exit, displays sell blurb. // Clean exit, displays sell blurb.
void I_Quit (void); void I_Quit (void);
void I_Tactile (int on, int off, int total); void I_Tactile (int on, int off, int total);
void STACK_ARGS I_Error (const char *error, ...) GCCPRINTF(1,2); void STACK_ARGS I_Error (const char *error, ...) GCCPRINTF(1,2);
void STACK_ARGS I_FatalError (const char *error, ...) GCCPRINTF(1,2); void STACK_ARGS I_FatalError (const char *error, ...) GCCPRINTF(1,2);
void addterm (void (*func)(void), const char *name); void addterm (void (*func)(void), const char *name);
#define atterm(t) addterm (t, #t) #define atterm(t) addterm (t, #t)
void popterm (); void popterm ();
// Print a console string // Print a console string
void I_PrintStr (const char *str); void I_PrintStr (const char *str);
// Set the title string of the startup window // Set the title string of the startup window
void I_SetIWADInfo (); void I_SetIWADInfo ();
// Pick from multiple IWADs to use // Pick from multiple IWADs to use
int I_PickIWad (WadStuff *wads, int numwads, bool queryiwad, int defaultiwad); int I_PickIWad (WadStuff *wads, int numwads, bool queryiwad, int defaultiwad);
// The ini could not be saved at exit // The ini could not be saved at exit
bool I_WriteIniFailed (); bool I_WriteIniFailed ();
// [RH] Returns millisecond-accurate time // [RH] Returns millisecond-accurate time
unsigned int I_MSTime (void); unsigned int I_MSTime (void);
unsigned int I_FPSTime(); unsigned int I_FPSTime();
class FTexture; class FTexture;
bool I_SetCursor(FTexture *); bool I_SetCursor(FTexture *);
// Directory searching routines // Directory searching routines
struct findstate_t struct findstate_t
{ {
int count; int count;
struct dirent **namelist; struct dirent **namelist;
int current; int current;
}; };
void *I_FindFirst (const char *filespec, findstate_t *fileinfo); void *I_FindFirst (const char *filespec, findstate_t *fileinfo);
int I_FindNext (void *handle, findstate_t *fileinfo); int I_FindNext (void *handle, findstate_t *fileinfo);
int I_FindClose (void *handle); int I_FindClose (void *handle);
int I_FindAttr (findstate_t *fileinfo); int I_FindAttr (findstate_t *fileinfo);
#define I_FindName(a) ((a)->namelist[(a)->current]->d_name) #define I_FindName(a) ((a)->namelist[(a)->current]->d_name)
#define FA_RDONLY 1 #define FA_RDONLY 1
#define FA_HIDDEN 2 #define FA_HIDDEN 2
#define FA_SYSTEM 4 #define FA_SYSTEM 4
#define FA_DIREC 8 #define FA_DIREC 8
#define FA_ARCH 16 #define FA_ARCH 16
static inline char *strlwr(char *str) static inline char *strlwr(char *str)
{ {
char *ptr = str; char *ptr = str;
while(*ptr) while(*ptr)
{ {
*ptr = tolower(*ptr); *ptr = tolower(*ptr);
++ptr; ++ptr;
} }
return str; return str;
} }
#endif #endif

View file

@ -1,354 +1,354 @@
/* /*
** st_start.cpp ** st_start.cpp
** Handles the startup screen. ** Handles the startup screen.
** **
**--------------------------------------------------------------------------- **---------------------------------------------------------------------------
** Copyright 2006-2007 Randy Heit ** Copyright 2006-2007 Randy Heit
** All rights reserved. ** All rights reserved.
** **
** Redistribution and use in source and binary forms, with or without ** Redistribution and use in source and binary forms, with or without
** modification, are permitted provided that the following conditions ** modification, are permitted provided that the following conditions
** are met: ** are met:
** **
** 1. Redistributions of source code must retain the above copyright ** 1. Redistributions of source code must retain the above copyright
** notice, this list of conditions and the following disclaimer. ** notice, this list of conditions and the following disclaimer.
** 2. Redistributions in binary form must reproduce the above copyright ** 2. Redistributions in binary form must reproduce the above copyright
** notice, this list of conditions and the following disclaimer in the ** notice, this list of conditions and the following disclaimer in the
** documentation and/or other materials provided with the distribution. ** documentation and/or other materials provided with the distribution.
** 3. The name of the author may not be used to endorse or promote products ** 3. The name of the author may not be used to endorse or promote products
** derived from this software without specific prior written permission. ** derived from this software without specific prior written permission.
** **
** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR ** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES ** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. ** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, ** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT ** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, ** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY ** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT ** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF ** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
**--------------------------------------------------------------------------- **---------------------------------------------------------------------------
** **
*/ */
// HEADER FILES ------------------------------------------------------------ // HEADER FILES ------------------------------------------------------------
#include <unistd.h> #include <unistd.h>
#include <sys/time.h> #include <sys/time.h>
#include <sys/types.h> #include <sys/types.h>
#include <termios.h> #include <termios.h>
#include "st_start.h" #include "st_start.h"
#include "doomdef.h" #include "doomdef.h"
#include "i_system.h" #include "i_system.h"
#include "c_cvars.h" #include "c_cvars.h"
// MACROS ------------------------------------------------------------------ // MACROS ------------------------------------------------------------------
// TYPES ------------------------------------------------------------------- // TYPES -------------------------------------------------------------------
class FTTYStartupScreen : public FStartupScreen class FTTYStartupScreen : public FStartupScreen
{ {
public: public:
FTTYStartupScreen(int max_progress); FTTYStartupScreen(int max_progress);
~FTTYStartupScreen(); ~FTTYStartupScreen();
void Progress(); void Progress();
void NetInit(const char *message, int num_players); void NetInit(const char *message, int num_players);
void NetProgress(int count); void NetProgress(int count);
void NetMessage(const char *format, ...); // cover for printf void NetMessage(const char *format, ...); // cover for printf
void NetDone(); void NetDone();
bool NetLoop(bool (*timer_callback)(void *), void *userdata); bool NetLoop(bool (*timer_callback)(void *), void *userdata);
protected: protected:
bool DidNetInit; bool DidNetInit;
int NetMaxPos, NetCurPos; int NetMaxPos, NetCurPos;
const char *TheNetMessage; const char *TheNetMessage;
termios OldTermIOS; termios OldTermIOS;
}; };
// EXTERNAL FUNCTION PROTOTYPES -------------------------------------------- // EXTERNAL FUNCTION PROTOTYPES --------------------------------------------
// PUBLIC FUNCTION PROTOTYPES ---------------------------------------------- // PUBLIC FUNCTION PROTOTYPES ----------------------------------------------
void I_ShutdownJoysticks(); void I_ShutdownJoysticks();
// PRIVATE FUNCTION PROTOTYPES --------------------------------------------- // PRIVATE FUNCTION PROTOTYPES ---------------------------------------------
static void DeleteStartupScreen(); static void DeleteStartupScreen();
// EXTERNAL DATA DECLARATIONS ---------------------------------------------- // EXTERNAL DATA DECLARATIONS ----------------------------------------------
// PUBLIC DATA DEFINITIONS ------------------------------------------------- // PUBLIC DATA DEFINITIONS -------------------------------------------------
FStartupScreen *StartScreen; FStartupScreen *StartScreen;
CUSTOM_CVAR(Int, showendoom, 0, CVAR_ARCHIVE|CVAR_GLOBALCONFIG) CUSTOM_CVAR(Int, showendoom, 0, CVAR_ARCHIVE|CVAR_GLOBALCONFIG)
{ {
if (self < 0) self = 0; if (self < 0) self = 0;
else if (self > 2) self=2; else if (self > 2) self=2;
} }
// PRIVATE DATA DEFINITIONS ------------------------------------------------ // PRIVATE DATA DEFINITIONS ------------------------------------------------
static const char SpinnyProgressChars[4] = { '|', '/', '-', '\\' }; static const char SpinnyProgressChars[4] = { '|', '/', '-', '\\' };
// CODE -------------------------------------------------------------------- // CODE --------------------------------------------------------------------
//========================================================================== //==========================================================================
// //
// FStartupScreen :: CreateInstance // FStartupScreen :: CreateInstance
// //
// Initializes the startup screen for the detected game. // Initializes the startup screen for the detected game.
// Sets the size of the progress bar and displays the startup screen. // Sets the size of the progress bar and displays the startup screen.
// //
//========================================================================== //==========================================================================
FStartupScreen *FStartupScreen::CreateInstance(int max_progress) FStartupScreen *FStartupScreen::CreateInstance(int max_progress)
{ {
atterm(DeleteStartupScreen); atterm(DeleteStartupScreen);
return new FTTYStartupScreen(max_progress); return new FTTYStartupScreen(max_progress);
} }
//=========================================================================== //===========================================================================
// //
// DeleteStartupScreen // DeleteStartupScreen
// //
// Makes sure the startup screen has been deleted before quitting. // Makes sure the startup screen has been deleted before quitting.
// //
//=========================================================================== //===========================================================================
void DeleteStartupScreen() void DeleteStartupScreen()
{ {
if (StartScreen != NULL) if (StartScreen != NULL)
{ {
delete StartScreen; delete StartScreen;
StartScreen = NULL; StartScreen = NULL;
} }
} }
//=========================================================================== //===========================================================================
// //
// FTTYStartupScreen Constructor // FTTYStartupScreen Constructor
// //
// Sets the size of the progress bar and displays the startup screen. // Sets the size of the progress bar and displays the startup screen.
// //
//=========================================================================== //===========================================================================
FTTYStartupScreen::FTTYStartupScreen(int max_progress) FTTYStartupScreen::FTTYStartupScreen(int max_progress)
: FStartupScreen(max_progress) : FStartupScreen(max_progress)
{ {
DidNetInit = false; DidNetInit = false;
NetMaxPos = 0; NetMaxPos = 0;
NetCurPos = 0; NetCurPos = 0;
TheNetMessage = NULL; TheNetMessage = NULL;
} }
//=========================================================================== //===========================================================================
// //
// FTTYStartupScreen Destructor // FTTYStartupScreen Destructor
// //
// Called just before entering graphics mode to deconstruct the startup // Called just before entering graphics mode to deconstruct the startup
// screen. // screen.
// //
//=========================================================================== //===========================================================================
FTTYStartupScreen::~FTTYStartupScreen() FTTYStartupScreen::~FTTYStartupScreen()
{ {
NetDone(); // Just in case it wasn't called yet and needs to be. NetDone(); // Just in case it wasn't called yet and needs to be.
} }
//=========================================================================== //===========================================================================
// //
// FTTYStartupScreen :: Progress // FTTYStartupScreen :: Progress
// //
// If there was a progress bar, this would move it. But the basic TTY // If there was a progress bar, this would move it. But the basic TTY
// startup screen doesn't have one, so this function does nothing. // startup screen doesn't have one, so this function does nothing.
// //
//=========================================================================== //===========================================================================
void FTTYStartupScreen::Progress() void FTTYStartupScreen::Progress()
{ {
} }
//=========================================================================== //===========================================================================
// //
// FTTYStartupScreen :: NetInit // FTTYStartupScreen :: NetInit
// //
// Sets stdin for unbuffered I/O, displays the given message, and shows // Sets stdin for unbuffered I/O, displays the given message, and shows
// a progress meter. // a progress meter.
// //
//=========================================================================== //===========================================================================
void FTTYStartupScreen::NetInit(const char *message, int numplayers) void FTTYStartupScreen::NetInit(const char *message, int numplayers)
{ {
if (!DidNetInit) if (!DidNetInit)
{ {
termios rawtermios; termios rawtermios;
fprintf (stderr, "Press 'Q' to abort network game synchronization."); fprintf (stderr, "Press 'Q' to abort network game synchronization.");
// Set stdin to raw mode so we can get keypresses in ST_CheckNetAbort() // Set stdin to raw mode so we can get keypresses in ST_CheckNetAbort()
// immediately without waiting for an EOL. // immediately without waiting for an EOL.
tcgetattr (STDIN_FILENO, &OldTermIOS); tcgetattr (STDIN_FILENO, &OldTermIOS);
rawtermios = OldTermIOS; rawtermios = OldTermIOS;
rawtermios.c_lflag &= ~(ICANON | ECHO); rawtermios.c_lflag &= ~(ICANON | ECHO);
tcsetattr (STDIN_FILENO, TCSANOW, &rawtermios); tcsetattr (STDIN_FILENO, TCSANOW, &rawtermios);
DidNetInit = true; DidNetInit = true;
} }
if (numplayers == 1) if (numplayers == 1)
{ {
// Status message without any real progress info. // Status message without any real progress info.
fprintf (stderr, "\n%s.", message); fprintf (stderr, "\n%s.", message);
} }
else else
{ {
fprintf (stderr, "\n%s: ", message); fprintf (stderr, "\n%s: ", message);
} }
fflush (stderr); fflush (stderr);
TheNetMessage = message; TheNetMessage = message;
NetMaxPos = numplayers; NetMaxPos = numplayers;
NetCurPos = 0; NetCurPos = 0;
NetProgress(1); // You always know about yourself NetProgress(1); // You always know about yourself
} }
//=========================================================================== //===========================================================================
// //
// FTTYStartupScreen :: NetDone // FTTYStartupScreen :: NetDone
// //
// Restores the old stdin tty settings. // Restores the old stdin tty settings.
// //
//=========================================================================== //===========================================================================
void FTTYStartupScreen::NetDone() void FTTYStartupScreen::NetDone()
{ {
// Restore stdin settings // Restore stdin settings
if (DidNetInit) if (DidNetInit)
{ {
tcsetattr (STDIN_FILENO, TCSANOW, &OldTermIOS); tcsetattr (STDIN_FILENO, TCSANOW, &OldTermIOS);
printf ("\n"); printf ("\n");
DidNetInit = false; DidNetInit = false;
} }
} }
//=========================================================================== //===========================================================================
// //
// FTTYStartupScreen :: NetMessage // FTTYStartupScreen :: NetMessage
// //
// Call this between NetInit() and NetDone() instead of Printf() to // Call this between NetInit() and NetDone() instead of Printf() to
// display messages, because the progress meter is mixed in the same output // display messages, because the progress meter is mixed in the same output
// stream as normal messages. // stream as normal messages.
// //
//=========================================================================== //===========================================================================
void FTTYStartupScreen::NetMessage(const char *format, ...) void FTTYStartupScreen::NetMessage(const char *format, ...)
{ {
FString str; FString str;
va_list argptr; va_list argptr;
va_start (argptr, format); va_start (argptr, format);
str.VFormat (format, argptr); str.VFormat (format, argptr);
va_end (argptr); va_end (argptr);
fprintf (stderr, "\r%-40s\n", str.GetChars()); fprintf (stderr, "\r%-40s\n", str.GetChars());
} }
//=========================================================================== //===========================================================================
// //
// FTTYStartupScreen :: NetProgress // FTTYStartupScreen :: NetProgress
// //
// Sets the network progress meter. If count is 0, it gets bumped by 1. // Sets the network progress meter. If count is 0, it gets bumped by 1.
// Otherwise, it is set to count. // Otherwise, it is set to count.
// //
//=========================================================================== //===========================================================================
void FTTYStartupScreen::NetProgress(int count) void FTTYStartupScreen::NetProgress(int count)
{ {
int i; int i;
if (count == 0) if (count == 0)
{ {
NetCurPos++; NetCurPos++;
} }
else if (count > 0) else if (count > 0)
{ {
NetCurPos = count; NetCurPos = count;
} }
if (NetMaxPos == 0) if (NetMaxPos == 0)
{ {
// Spinny-type progress meter, because we're a guest waiting for the host. // Spinny-type progress meter, because we're a guest waiting for the host.
fprintf (stderr, "\r%s: %c", TheNetMessage, SpinnyProgressChars[NetCurPos & 3]); fprintf (stderr, "\r%s: %c", TheNetMessage, SpinnyProgressChars[NetCurPos & 3]);
fflush (stderr); fflush (stderr);
} }
else if (NetMaxPos > 1) else if (NetMaxPos > 1)
{ {
// Dotty-type progress meter. // Dotty-type progress meter.
fprintf (stderr, "\r%s: ", TheNetMessage); fprintf (stderr, "\r%s: ", TheNetMessage);
for (i = 0; i < NetCurPos; ++i) for (i = 0; i < NetCurPos; ++i)
{ {
fputc ('.', stderr); fputc ('.', stderr);
} }
fprintf (stderr, "%*c[%2d/%2d]", NetMaxPos + 1 - NetCurPos, ' ', NetCurPos, NetMaxPos); fprintf (stderr, "%*c[%2d/%2d]", NetMaxPos + 1 - NetCurPos, ' ', NetCurPos, NetMaxPos);
fflush (stderr); fflush (stderr);
} }
} }
//=========================================================================== //===========================================================================
// //
// FTTYStartupScreen :: NetLoop // FTTYStartupScreen :: NetLoop
// //
// The timer_callback function is called at least two times per second // The timer_callback function is called at least two times per second
// and passed the userdata value. It should return true to stop the loop and // and passed the userdata value. It should return true to stop the loop and
// return control to the caller or false to continue the loop. // return control to the caller or false to continue the loop.
// //
// ST_NetLoop will return true if the loop was halted by the callback and // ST_NetLoop will return true if the loop was halted by the callback and
// false if the loop was halted because the user wants to abort the // false if the loop was halted because the user wants to abort the
// network synchronization. // network synchronization.
// //
//=========================================================================== //===========================================================================
bool FTTYStartupScreen::NetLoop(bool (*timer_callback)(void *), void *userdata) bool FTTYStartupScreen::NetLoop(bool (*timer_callback)(void *), void *userdata)
{ {
fd_set rfds; fd_set rfds;
struct timeval tv; struct timeval tv;
int retval; int retval;
char k; char k;
for (;;) for (;;)
{ {
// Don't flood the network with packets on startup. // Don't flood the network with packets on startup.
tv.tv_sec = 0; tv.tv_sec = 0;
tv.tv_usec = 500000; tv.tv_usec = 500000;
FD_ZERO (&rfds); FD_ZERO (&rfds);
FD_SET (STDIN_FILENO, &rfds); FD_SET (STDIN_FILENO, &rfds);
retval = select (1, &rfds, NULL, NULL, &tv); retval = select (1, &rfds, NULL, NULL, &tv);
if (retval == -1) if (retval == -1)
{ {
// Error // Error
} }
else if (retval == 0) else if (retval == 0)
{ {
if (timer_callback (userdata)) if (timer_callback (userdata))
{ {
fputc ('\n', stderr); fputc ('\n', stderr);
return true; return true;
} }
} }
else if (read (STDIN_FILENO, &k, 1) == 1) else if (read (STDIN_FILENO, &k, 1) == 1)
{ {
// Check input on stdin // Check input on stdin
if (k == 'q' || k == 'Q') if (k == 'q' || k == 'Q')
{ {
fprintf (stderr, "\nNetwork game synchronization aborted."); fprintf (stderr, "\nNetwork game synchronization aborted.");
return false; return false;
} }
} }
} }
} }
void ST_Endoom() void ST_Endoom()
{ {
I_ShutdownJoysticks(); I_ShutdownJoysticks();
exit(0); exit(0);
} }