//------------------------------------------------------------------------- /* Copyright (C) 1997, 2005 - 3D Realms Entertainment This file is part of Shadow Warrior version 1.2 Shadow Warrior 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 2 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, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. Original Source: 1997 - Frank Maddin and Jim Norwood Prepared for public release: 03/28/2005 - Charlie Wiederhold, 3D Realms */ //------------------------------------------------------------------------- #include "ns.h" #include "build.h" #include "baselayer.h" #include "osd.h" #include "settings.h" #include "mytypes.h" #include "scriplib.h" #include "gamedefs.h" #include "keyboard.h" #include "function.h" #include "control.h" #include "fx_man.h" #include "sounds.h" #include "config.h" #include "common_game.h" // we load this in to get default button and key assignments // as well as setting up function mappings #include "_functio.h" #include "_config.h" #if defined RENDERTYPESDL && defined SDL_TARGET && SDL_TARGET > 1 # include "sdl_inc.h" #endif BEGIN_SW_NS extern void ReadGameSetup(int32_t scripthandle); extern void WriteGameSetup(int32_t scripthandle); // // Comm variables // char CommPlayerName[32]; int32_t NumberPlayers,CommPort,PortSpeed,IrqNumber,UartAddress; // // Sound variables // int32_t UseMouse = 1, UseJoystick = 0; uint8_t KeyboardKeys[NUMGAMEFUNCTIONS][2]; int32_t MouseButtons[MAXMOUSEBUTTONS]; int32_t MouseButtonsClicked[MAXMOUSEBUTTONS]; int32_t MouseDigitalAxes[MAXMOUSEAXES][2]; int32_t MouseAnalogAxes[MAXMOUSEAXES]; int32_t MouseAnalogScale[MAXMOUSEAXES]; int32_t JoystickButtons[MAXJOYBUTTONS]; int32_t JoystickButtonsClicked[MAXJOYBUTTONS]; int32_t JoystickDigitalAxes[MAXJOYAXES][2]; int32_t JoystickAnalogAxes[MAXJOYAXES]; int32_t JoystickAnalogScale[MAXJOYAXES]; int32_t JoystickAnalogDead[MAXJOYAXES]; int32_t JoystickAnalogSaturate[MAXJOYAXES]; // // Screen variables // int32_t ScreenMode = 1; int32_t ScreenWidth = 640; int32_t ScreenHeight = 480; int32_t ScreenBPP = 8; int32_t ForceSetup = 1; extern char WangBangMacro[10][64]; char RTSName[MAXRTSNAMELENGTH]; static int32_t scripthandle = -1; /* =================== = = CONFIG_FunctionNameToNum = =================== */ int32_t CONFIG_FunctionNameToNum(const char *func) { int32_t i; if (!func) return -1; for (i=0; i= (unsigned)NUMGAMEFUNCTIONS) { return NULL; } else { return gamefunctions[func]; } } /* =================== = = CONFIG_AnalogNameToNum = =================== */ int32_t CONFIG_AnalogNameToNum(const char *func) { if (!Bstrcasecmp(func,"analog_turning")) { return analog_turning; } if (!Bstrcasecmp(func,"analog_strafing")) { return analog_strafing; } if (!Bstrcasecmp(func,"analog_moving")) { return analog_moving; } if (!Bstrcasecmp(func,"analog_lookingupanddown")) { return analog_lookingupanddown; } return -1; } const char *CONFIG_AnalogNumToName(int32_t func) { switch (func) { case analog_turning: return "analog_turning"; case analog_strafing: return "analog_strafing"; case analog_moving: return "analog_moving"; case analog_lookingupanddown: return "analog_lookingupanddown"; default: break; } return NULL; } /* =================== = = CONFIG_SetDefaults = =================== */ void CONFIG_SetDefaults(void) { // JBF 20031211 int32_t i;// , f; //uint8_t k1,k2; ScreenMode = 1; #if defined RENDERTYPESDL && SDL_MAJOR_VERSION > 1 uint32_t inited = SDL_WasInit(SDL_INIT_VIDEO); if (inited == 0) SDL_Init(SDL_INIT_VIDEO); else if (!(inited & SDL_INIT_VIDEO)) SDL_InitSubSystem(SDL_INIT_VIDEO); SDL_DisplayMode dm; if (SDL_GetDesktopDisplayMode(0, &dm) == 0) { ScreenWidth = dm.w; ScreenHeight = dm.h; } else #endif { ScreenWidth = 1024; ScreenHeight = 768; } ScreenBPP = 32; memcpy(&gs, &gs_defaults, sizeof(gs)); Bstrcpy(RTSName, DEFAULTRTSFILE); Bstrcpy(CommPlayerName, DEFAULTPLAYERNAME); Bstrcpy(WangBangMacro[0], MACRO1); Bstrcpy(WangBangMacro[1], MACRO2); Bstrcpy(WangBangMacro[2], MACRO3); Bstrcpy(WangBangMacro[3], MACRO4); Bstrcpy(WangBangMacro[4], MACRO5); Bstrcpy(WangBangMacro[5], MACRO6); Bstrcpy(WangBangMacro[6], MACRO7); Bstrcpy(WangBangMacro[7], MACRO8); Bstrcpy(WangBangMacro[8], MACRO9); Bstrcpy(WangBangMacro[9], MACRO10); SetDefaultKeyDefinitions(0); SetMouseDefaults(0); memset(MouseDigitalAxes, -1, sizeof(MouseDigitalAxes)); for (i=0; i= (MAXMOUSEBUTTONS-2)) continue; // scroll wheel Bsprintf(buf,"MouseButtonClicked%d",dummy); SCRIPT_PutString(scripthandle,"Controls", buf, CONFIG_FunctionNumToName(MouseButtonsClicked[dummy])); } for (dummy=0; dummy