Example #1
0
//
// Test whether the loaded file is an IWAD
//
static wfiletype_e W_isIWAD(FILE *f, long *offset)
{
   char id[4];

   if(fread(id, 1, earrlen(id), f) != earrlen(id))
      return WFT_ERROR;

   if(!strncmp(id, "IWAD", earrlen(id)))
   {
      *offset = 0;
      return WFT_WAD;
   }

   return WFT_UNKNOWN;
}
Example #2
0
//
// I_InitHALTimer
//
// Initialize the timer subsystem.
//
void I_InitHALTimer()
{
   int clockRate = realtic_clock_rate;
   int p;
   
   if((p = M_CheckParm("-speed")) && p < myargc-1 &&
      (p = atoi(myargv[p+1])) >= 10 && p <= 1000)
      clockRate = p;
   
   if(clockRate != 100)
      I_GetTime_Scale = ((int64_t)clockRate << CLOCK_BITS) / 100;

   // choose the first available timer driver
   for(size_t i = 0; i < earrlen(halTimerDrivers); i++)
   {
      if(halTimerDrivers[i].Init)
      {
         timer = &halTimerDrivers[i];
         break;
      }
   }

   // initialize the timer
   timer->Init();
}
Example #3
0
//
// EV_SpecialForStaticInitName
//
// Some static init specials have symbolic names. This will
// return the bound special for such a name if one exists.
//
int EV_SpecialForStaticInitName(const char *name)
{
   struct staticname_t
   {
      int staticFn;
      const char *name;
   };
   static staticname_t namedStatics[] =
   {
      { EV_STATIC_POLYOBJ_START_LINE,      "Polyobj_StartLine"      },
      { EV_STATIC_POLYOBJ_EXPLICIT_LINE,   "Polyobj_ExplicitLine"   },
      { EV_STATIC_SCROLL_LEFT_PARAM,       "Scroll_Texture_Left"    },
      { EV_STATIC_SCROLL_RIGHT_PARAM,      "Scroll_Texture_Right"   },
      { EV_STATIC_SCROLL_UP_PARAM,         "Scroll_Texture_Up"      },
      { EV_STATIC_SCROLL_DOWN_PARAM,       "Scroll_Texture_Down"    },
      { EV_STATIC_PORTAL_HORIZON_LINE,     "Line_Horizon"           },
      { EV_STATIC_LINE_SET_IDENTIFICATION, "Line_SetIdentification" },
   };

   // There aren't enough of these to warrant a hash table. Yet.
   for(size_t i = 0; i < earrlen(namedStatics); i++)
   {
      if(!strcasecmp(namedStatics[i].name, name))
         return EV_SpecialForStaticInit(namedStatics[i].staticFn);
   }

   return 0;
}
Example #4
0
//
// I_TranslateKey
//
// For SDL, translates from SDL keysyms to DOOM key values.
//
static int I_TranslateKey(SDL_Keysym *sym)
{
   const int scancode = sym->scancode;

   // This approach is taken from Chocolate Doom's TranslateKey
   switch(scancode)
   {
   case SDL_SCANCODE_LCTRL:
   case SDL_SCANCODE_RCTRL:
      return KEYD_RCTRL;
   case SDL_SCANCODE_LSHIFT:
   case SDL_SCANCODE_RSHIFT:
      return KEYD_RSHIFT;
   case SDL_SCANCODE_LALT:
   case SDL_SCANCODE_LGUI:
      return KEYD_LALT;
   case SDL_SCANCODE_RALT:
   case SDL_SCANCODE_RGUI:
      return KEYD_RALT;
   default:
      if(scancode >= 0 && scancode < static_cast<int>(earrlen(scancode_translate_table)))
         return scancode_translate_table[scancode];
      else
         return 0;
   }
}
Example #5
0
//
// XInputGamePad::poll
//
void XInputGamePad::poll()
{
   XINPUT_STATE xstate;
   XINPUT_GAMEPAD &pad = xstate.Gamepad;
   
   memset(&xstate, 0, sizeof(xstate));

   if(!pXInputGetState(dwUserIndex, &xstate))
   {
      // save old button and axis states
      backupState();

      // read button states
      for(size_t i = 0; i < earrlen(buttonTable); i++)
      {
         state.buttons[buttonTable[i].halButton] = 
            ((pad.wButtons & buttonTable[i].xInputButton) == buttonTable[i].xInputButton);
      }

      // read axis states
      
      state.axes[0] = pad.sThumbLX;
      state.axes[1] = pad.sThumbLY;
      state.axes[2] = pad.sThumbRX;
      state.axes[3] = pad.sThumbRY;

      normAxisPair(state.axes[0], state.axes[1], XINPUT_GAMEPAD_LEFT_THUMB_DEADZONE,  -32768, 32767);
      normAxisPair(state.axes[2], state.axes[3], XINPUT_GAMEPAD_RIGHT_THUMB_DEADZONE, -32768, 32767);
      
      state.axes[4] = normAxis(pad.bLeftTrigger,  XINPUT_GAMEPAD_TRIGGER_THRESHOLD, 255);
      state.axes[5] = normAxis(pad.bRightTrigger, XINPUT_GAMEPAD_TRIGGER_THRESHOLD, 255);
   }
}
Example #6
0
//
// G_InitKeyBindings
//
// Set up key names and various details
//
void G_InitKeyBindings()
{
   // various names for different keys
   for(size_t kn = 0; kn < earrlen(keyNames); kn++)
      keybindings[keyNames[kn].keyCode].name = keyNames[kn].name;

   for(int i = 0; i < NUMKEYS; i++)
   {
      // fill in name if not set yet

      if(!keybindings[i].name)
      {
         char tempstr[32];

         // build generic name
         if(ectype::isPrint(i))
            sprintf(tempstr, "%c", i);
         else
            sprintf(tempstr, "key%x", i);

         keybindings[i].name = Z_Strdup(tempstr, PU_STATIC, 0);
      }

      memset(keybindings[i].bindings, 0, NUMKEYACTIONCLASSES * sizeof(keyaction_t *));
   }

   for(int i = 0; i < NUMKEYACTIONS; i++)
      keyactions[i].num = i;
}
Example #7
0
//
// EV_PSXBindingForSectorSpecial
//
// Look up a PSX sector type. Defers to DOOM's lookup if a PSX type is not
// found first.
//
static ev_sectorbinding_t *EV_PSXBindingForSectorSpecial(int special)
{
   ev_sectorbinding_t *binding;

   if(!(binding = EV_findBinding(PSXSectorBindings, earrlen(PSXSectorBindings), special)))
      binding = EV_DOOMBindingForSectorSpecial(special);

   return binding;
}
Example #8
0
//
// EV_PSXStaticInitForSpecial
//
// Always looks up a static init function in the PSX mission's static init list,
// regardless of the map format or gamemode in use. Returns 0 if no such special
// exists.
//
int EV_PSXStaticInitForSpecial(int special)
{
   for(size_t i = 0; i < earrlen(PSXStaticBindings); i++)
   {
      if(PSXStaticBindings[i].actionNumber == special)
         return PSXStaticBindings[i].staticFn;
   }

   // otherwise, check the DOOM lookup
   return EV_DOOMStaticInitForSpecial(special);
}
Example #9
0
//
// EV_PSXSpecialForStaticInit
//
// Always looks up a special in the PSX mission's static init list, regardless
// of the map format or gamemode in use. Returns 0 if no such special exists.
//
int EV_PSXSpecialForStaticInit(int staticFn)
{
   // small set, so, linear search
   for(size_t i = 0; i < earrlen(PSXStaticBindings); i++)
   {
      if(PSXStaticBindings[i].staticFn == staticFn)
         return PSXStaticBindings[i].actionNumber;
   }

   // otherwise, check the DOOM lookup
   return EV_DOOMSpecialForStaticInit(staticFn);
}
Example #10
0
//
// P_getSlopeProps
//
// haleyjd 02/05/13: Get slope properties for a static init function.
//
static void P_getSlopeProps(int staticFn, bool &frontfloor, bool &backfloor,
                            bool &frontceil, bool &backceil, const int *args)
{
   struct staticslopeprops_t 
   {
      int  staticFn;
      bool frontfloor;
      bool backfloor;
      bool frontceil;
      bool backceil;
   };
   static staticslopeprops_t props[] =
   {
      { EV_STATIC_SLOPE_FSEC_FLOOR,             true,  false, false, false },
      { EV_STATIC_SLOPE_FSEC_CEILING,           false, false, true,  false },
      { EV_STATIC_SLOPE_FSEC_FLOOR_CEILING,     true,  false, true,  false },
      { EV_STATIC_SLOPE_BSEC_FLOOR,             false, true,  false, false },
      { EV_STATIC_SLOPE_BSEC_CEILING,           false, false, false, true  },
      { EV_STATIC_SLOPE_BSEC_FLOOR_CEILING,     false, true,  false, true  },
      { EV_STATIC_SLOPE_BACKFLOOR_FRONTCEILING, false, true,  true,  false },
      { EV_STATIC_SLOPE_FRONTFLOOR_BACKCEILING, true,  false, false, true  },
   };

   // Handle parameterized slope
   if(staticFn == EV_STATIC_SLOPE_PARAM)
   {
      int floor = args[0];
      if(floor < 0 || floor > 3)
         floor = 0;
      int ceiling = args[1];
      if(ceiling < 0 || ceiling > 3)
         ceiling = 0;
      frontfloor = !!(floor & 1);
      backfloor = !!(floor & 2);
      frontceil = !!(ceiling & 1);
      backceil = !!(ceiling & 2);
      return;
   }

   for(size_t i = 0; i < earrlen(props); i++)
   {
      if(staticFn == props[i].staticFn)
      {
         frontfloor = props[i].frontfloor;
         backfloor  = props[i].backfloor;
         frontceil  = props[i].frontceil;
         backceil   = props[i].backceil;
         break;
      }
   }
}
Example #11
0
static void EV_initUDMFEternityStaticHash()
{
   static bool firsttime = true;

   if(firsttime)
   {
      firsttime = false;

      // add every item in the Hexen static bindings array
      EV_addStaticSpecialsToHash(UDMFEternityStaticHash, UDMFEternityStaticSpecHash,
         UDMFEternityStaticBindings,
         earrlen(UDMFEternityStaticBindings));
   }
}
Example #12
0
//
// EV_InitDOOMStaticHash
//
// First-time-use initialization for the DOOM static specials hash table.
//
static void EV_initDOOMStaticHash()
{
   static bool firsttime = true;

   if(firsttime)
   {
      firsttime = false;
      
      // add every item in the DOOM static bindings array
      EV_addStaticSpecialsToHash(DOOMStaticHash, DOOMStaticSpecHash, 
                                 DOOMStaticBindings,
                                 earrlen(DOOMStaticBindings));
   }
}
Example #13
0
//
// EV_SpecialForStaticInitName
//
// Some static init specials have symbolic names. This will
// return the bound special for such a name if one exists.
//
int EV_SpecialForStaticInitName(const char *name)
{
   struct staticname_t
   {
      int staticFn;
      const char *name;
   };
   static staticname_t namedStatics[] =
   {
      { EV_STATIC_3DMIDTEX_ATTACH_PARAM,   "Sector_Attach3dMidtex"  },
      { EV_STATIC_INIT_PARAM,              "Static_Init"            },
      { EV_STATIC_PORTAL_LINE_PARAM,       "Line_SetPortal"         },
      { EV_STATIC_SLOPE_PARAM,             "Plane_Align"            },
      { EV_STATIC_POLYOBJ_START_LINE,      "Polyobj_StartLine"      },
      { EV_STATIC_POLYOBJ_EXPLICIT_LINE,   "Polyobj_ExplicitLine"   },
      { EV_STATIC_PUSHPULL_CONTROL_PARAM,  "PointPush_SetForce"     },
      { EV_STATIC_SCROLL_BY_OFFSETS,       "Scroll_Texture_Offsets" },
      { EV_STATIC_SCROLL_CEILING_PARAM,    "Scroll_Ceiling"         },
      { EV_STATIC_SCROLL_FLOOR_PARAM,      "Scroll_Floor"           },
      { EV_STATIC_SCROLL_LEFT_PARAM,       "Scroll_Texture_Left"    },
      { EV_STATIC_SCROLL_WALL_PARAM,       "Scroll_Texture_Model"   },
      { EV_STATIC_SCROLL_RIGHT_PARAM,      "Scroll_Texture_Right"   },
      { EV_STATIC_SCROLL_UP_PARAM,         "Scroll_Texture_Up"      },
      { EV_STATIC_SCROLL_DOWN_PARAM,       "Scroll_Texture_Down"    },
      { EV_STATIC_CURRENT_CONTROL_PARAM,   "Sector_SetCurrent"      },
      { EV_STATIC_FRICTION_TRANSFER,       "Sector_SetFriction"     },
      { EV_STATIC_PORTAL_SECTOR_PARAM,     "Sector_SetPortal"       },
      { EV_STATIC_WIND_CONTROL_PARAM,      "Sector_SetWind"         },
      { EV_STATIC_PORTAL_HORIZON_LINE,     "Line_Horizon"           },
      { EV_STATIC_LINE_SET_IDENTIFICATION, "Line_SetIdentification" },
      { EV_STATIC_LIGHT_TRANSFER_FLOOR,    "Transfer_FloorLight"    },
      { EV_STATIC_LIGHT_TRANSFER_CEILING,  "Transfer_CeilingLight"  },
      { EV_STATIC_TRANSFER_HEIGHTS,        "Transfer_Heights"       },
   };

   // There aren't enough of these to warrant a hash table. Yet.
   for(size_t i = 0; i < earrlen(namedStatics); i++)
   {
      if(!strcasecmp(namedStatics[i].name, name))
         return EV_SpecialForStaticInit(namedStatics[i].staticFn);
   }

   return 0;
}
Example #14
0
//
// Test whether the loaded file is a Jaguar ROM that contains an IWAD
//
// unzip.h -- IO for uncompress .zip files using zlib
// Version 0.15 beta, Mar 19th, 1998,
//
// Copyright (C) 1998 Gilles Vollant
//
// I WAIT FEEDBACK at mail [email protected]
// Visit also http://www.winimage.com/zLibDll/unzip.htm for evolution
//
// This software is provided 'as-is', without any express or implied
// warranty. In no event will the authors be held liable for any damages
// arising from the use of this software.
// 
// Permission is granted to anyone to use this software for any purpose,
// including commercial applications, and to alter it and redistribute it
// freely, subject to the following restrictions:
// 
// 1. The origin of this software must not be misrepresented; you must not
//    claim that you wrote the original software. If you use this software
//    in a product, an acknowledgment in the product documentation would be
//    appreciated but is not required.
// 2. Altered source versions must be plainly marked as such, and must not be
//    misrepresented as being the original software.
// 3. This notice may not be removed or altered from any source distribution.
//
static wfiletype_e W_isROM(FILE *f, long *offset)
{
   uint8_t buffer[WBUFFERSIZE + 4];
   long fileSize = 0;
   long backRead = 4;

   if(fseek(f, 0, SEEK_END))
      return WFT_ERROR;

   fileSize = ftell(f);
   while(backRead < fileSize)
   {
      long i, readSize, readPos;
      size_t sReadSize;

      if(backRead + WBUFFERSIZE > fileSize)
         backRead = fileSize;
      else
         backRead += WBUFFERSIZE;

      readPos  = fileSize - backRead;
      readSize = emin(earrlen(buffer), fileSize - readPos);

      if(fseek(f, readPos, SEEK_SET))
         return WFT_ERROR;

      sReadSize = (size_t)readSize;
      if(fread(buffer, 1, sReadSize, f) != sReadSize)
         return WFT_ERROR;

      for(i = readSize - 3; (i--) > 0; )
      {
         if(buffer[i] == 'I' && buffer[i + 1] == 'W' && buffer[i + 2] == 'A' && buffer[i + 3] == 'D')
         {
            *offset = readPos + i;
            return WFT_ROM;
         }
      }
   }
   
   return WFT_UNKNOWN;
}
Example #15
0
//
// EV_UDMFEternityBindingForSectorSpecial
//
// Look up a UDMF "Eternity" namespace sector special binding.
//
static ev_sectorbinding_t *EV_UDMFEternityBindingForSectorSpecial(int special)
{
   return EV_findBinding(UDMFEternitySectorBindings, earrlen(UDMFEternitySectorBindings), special);
}
Example #16
0
//
// EV_DOOMBindingForSectorSpecial
//
// Look up a DOOM sector special binding.
//
static ev_sectorbinding_t *EV_DOOMBindingForSectorSpecial(int special)
{
   return EV_findBinding(DoomSectorBindings, earrlen(DoomSectorBindings), special);
}
Example #17
0
//
// EV_HexenBindingForSectorSpecial
//
// Look up a Hexen sector special binding.
//
static ev_sectorbinding_t *EV_HexenBindingForSectorSpecial(int special)
{
   return EV_findBinding(HexenSectorBindings, earrlen(HexenSectorBindings), special);
}
Example #18
0
//
// EV_GenBindingForSectorSpecial
//
// Find the "lighting" special for a generalized sector.
//
static ev_sectorbinding_t *EV_GenBindingForSectorSpecial(int special)
{
   return EV_findBinding(GenBindings, earrlen(GenBindings), special & LIGHT_MASK);
}