Merge remote-tracking branch 'upstream/master'

This commit is contained in:
Sryder13 2014-05-27 20:44:13 +01:00
commit aa948b5950
8 changed files with 230 additions and 14 deletions

173
CMakeLists.txt Normal file
View file

@ -0,0 +1,173 @@
#
# Simple CMakeLists for Sonic Robo Blast 2
#
PROJECT(SRB2)
CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
#
# Dependencies
#
FIND_PACKAGE(SDL)
FIND_PACKAGE(SDL_mixer)
FIND_PACKAGE(PNG)
#
# Common stuff
#
# not added defines:
# -DHAVE_PNG - does not build (incorrect use of PNG_EXPORT etc.)
ADD_DEFINITIONS(-DDIRECTFULLSCREEN -DSDL -DHAVE_MIXER -DNOHW -DHW3SOUND -DHAVE_BLUA -DNOASM)
SET(SDL_DIR sdl) # may be set to SDL2 optionally
SET(COMMON_SRCS
src/${SDL_DIR}/dosstr.c
src/${SDL_DIR}/endtxt.c
src/${SDL_DIR}/hwsym_sdl.c
src/${SDL_DIR}/i_cdmus.c
src/${SDL_DIR}/i_main.c
src/${SDL_DIR}/i_net.c
src/${SDL_DIR}/i_system.c
src/${SDL_DIR}/i_video.c
src/${SDL_DIR}/mixer_sound.c
src/am_map.c
src/b_bot.c
src/blua/lapi.c
src/blua/lauxlib.c
src/blua/lbaselib.c
src/blua/lcode.c
src/blua/ldebug.c
src/blua/ldo.c
src/blua/ldump.c
src/blua/lfunc.c
src/blua/lgc.c
src/blua/linit.c
src/blua/llex.c
src/blua/lmem.c
src/blua/lobject.c
src/blua/lopcodes.c
src/blua/lparser.c
src/blua/lstate.c
src/blua/lstring.c
src/blua/lstrlib.c
src/blua/ltable.c
src/blua/ltablib.c
src/blua/ltm.c
src/blua/lundump.c
src/blua/lvm.c
src/blua/lzio.c
src/command.c
src/comptime.c
src/console.c
src/d_clisrv.c
src/d_main.c
src/d_net.c
src/d_netcmd.c
src/d_netfil.c
src/dehacked.c
src/f_finale.c
src/f_wipe.c
src/filesrch.c
src/g_game.c
src/g_input.c
src/hardware/hw3sound.c
src/hu_stuff.c
src/i_tcp.c
src/info.c
src/lua_baselib.c
src/lua_consolelib.c
src/lua_hooklib.c
src/lua_hudlib.c
src/lua_infolib.c
src/lua_maplib.c
src/lua_mathlib.c
src/lua_mobjlib.c
src/lua_playerlib.c
src/lua_script.c
src/lua_skinlib.c
src/lua_thinkerlib.c
src/lzf.c
src/m_anigif.c
src/m_argv.c
src/m_bbox.c
src/m_cheat.c
src/m_cond.c
src/m_fixed.c
src/m_menu.c
src/m_misc.c
src/m_queue.c
src/m_random.c
src/md5.c
src/mserv.c
src/p_ceilng.c
src/p_enemy.c
src/p_fab.c
src/p_floor.c
src/p_inter.c
src/p_lights.c
src/p_map.c
src/p_maputl.c
src/p_mobj.c
src/p_polyobj.c
src/p_saveg.c
src/p_setup.c
src/p_sight.c
src/p_spec.c
src/p_telept.c
src/p_tick.c
src/p_user.c
src/r_bsp.c
src/r_data.c
src/r_draw.c
src/r_main.c
src/r_plane.c
src/r_segs.c
src/r_sky.c
src/r_splats.c
src/r_things.c
src/s_sound.c
src/screen.c
src/sounds.c
src/st_stuff.c
src/string.c
src/tables.c
src/v_video.c
src/w_wad.c
src/y_inter.c
src/z_zone.c
)
#
# Platform-specific stuff
#
MACRO(EXTRALIB NAME)
FIND_LIBRARY(${NAME}_LIBRARY NAMES ${NAME})
IF(${NAME}_LIBRARY)
MESSAGE(STATUS "Found lib${NAME}: ${${NAME}_LIBRARY}")
SET(EXTRA_LIBRARIES ${EXTRA_LIBRARIES} ${${NAME}_LIBRARY})
ELSE(${NAME}_LIBRARY)
MESSAGE(FATAL_ERROR "Could not find lib${NAME}!")
ENDIF(${NAME}_LIBRARY)
ENDMACRO(EXTRALIB)
IF(${CMAKE_SYSTEM} MATCHES "FreeBSD")
ADD_DEFINITIONS(-DUNIXCOMMON -DLINUX -DFREEBSD)
EXTRALIB(kvm)
ELSEIF(${CMAKE_SYSTEM} MATCHES "Linux")
ADD_DEFINITIONS(-DUNIXCOMMON -DLINUX)
EXTRALIB(m)
EXTRALIB(rt)
ELSE(${CMAKE_SYSTEM} MATCHES "FreeBSD")
ADD_DEFINITIONS(-DUNIXCOMMON -DLINUX)
MESSAGE(WARNING "No specific settings for you system, it may be not supported!")
ENDIF(${CMAKE_SYSTEM} MATCHES "FreeBSD")
#
# Targets
#
INCLUDE_DIRECTORIES(${PNG_INCLUDE_DIRS} ${SDL_INCLUDE_DIR} ${SDL_MIXER_INCLUDE_DIRS})
ADD_EXECUTABLE(SRB2 ${COMMON_SRCS})
TARGET_LINK_LIBRARIES(SRB2 ${SDL_LIBRARY} ${SDL_MIXER_LIBRARIES} ${EXTRA_LIBRARIES})

45
src/endian.h Normal file
View file

@ -0,0 +1,45 @@
// SONIC ROBO BLAST 2
//-----------------------------------------------------------------------------
// Copyright (C) 2014 by Sonic Team Junior.
//
// This program is free software distributed under the
// terms of the GNU General Public License, version 2.
// See the 'LICENSE' file for more details.
//-----------------------------------------------------------------------------
/// \file endian.h
/// \brief Endian detection
#ifndef __ENDIAN__
#define __ENDIAN__
#if defined(SRB2_BIG_ENDIAN) || defined(SRB2_LITTLE_ENDIAN)
// defined externally
#else
#if defined(__FreeBSD__)
// on FreeBSD, _BIG_ENDIAN is a constant to compare
// _BYTE_ORDER to, not a big-endianess flag
#include <sys/endian.h>
#if _BYTE_ORDER == _BIG_ENDIAN
#define SRB2_BIG_ENDIAN
#else
#define SRB2_LITTLE_ENDIAN
#endif
#elif defined(__BYTE_ORDER__)
// defined by at least gcc and clang
#if __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
#define SRB2_BIG_ENDIAN
#else
#define SRB2_LITTLE_ENDIAN
#endif
#else
// check used in vanilla SRB2 (may work incorrectly if
// _BIG_ENDIAN is used as on FreeBSD)
#if defined(_BIG_ENDIAN)
#define SRB2_BIG_ENDIAN
#else
#define SRB2_LITTLE_ENDIAN
#endif
#endif
#endif
#endif //__ENDIAN__

View file

@ -2854,9 +2854,10 @@ static void HWR_Subsector(size_t num)
#ifdef DOPLANES
// -------------------- WATER IN DEV. TEST ------------------------
//dck hack : use abs(tag) for waterheight
if (gr_frontsector->tag < 0)
//ilag : Since we changed to UINT16 for sector tags, simulate INT16
if (gr_frontsector->tag > 32767)
{
wh = ((-gr_frontsector->tag) <<FRACBITS) + (FRACUNIT/2);
wh = ((65535-gr_frontsector->tag) <<FRACBITS) + (FRACUNIT/2);
if (wh > gr_frontsector->floorheight &&
wh < gr_frontsector->ceilingheight)
{

View file

@ -14,9 +14,11 @@
#ifndef __M_SWAP__
#define __M_SWAP__
#include "endian.h"
// Endianess handling.
// WAD files are stored little endian.
#ifdef _BIG_ENDIAN
#ifdef SRB2_BIG_ENDIAN
#define SHORT(x) ((INT16)(\
(((UINT16)(x) & (UINT16)0x00ffU) << 8) \

View file

@ -44,14 +44,9 @@
#include "md5.h"
#ifdef _LIBC
#include <endian.h>
#if __BYTE_ORDER == __BIG_ENDIAN
#define WORDS_BIGENDIAN 1
#endif
#endif
#include "endian.h"
#if defined (WORDS_BIGENDIAN) || defined (_BIG_ENDIAN)
#if defined (SRB2_BIG_ENDIAN)
#define SWAP(n) \
(((n) << 24) | (((n) & 0xff00) << 8) | (((n) >> 8) & 0xff00) | ((n) >> 24))
#else

View file

@ -3670,7 +3670,7 @@ static void P_Boss3Thinker(mobj_t *mobj)
// Move Boss4's sectors by delta.
static boolean P_Boss4MoveCage(fixed_t delta)
{
const INT16 tag = -2;
const UINT16 tag = 65534;
INT32 snum;
sector_t *sector;
for (snum = sectors[tag%numsectors].firsttag; snum != -1; snum = sector->nexttag)
@ -3719,7 +3719,7 @@ static void P_Boss4PinchSpikeballs(mobj_t *mobj, angle_t angle, fixed_t fz)
// Destroy cage FOFs.
static void P_Boss4DestroyCage(void)
{
const INT16 tag = -2;
const UINT16 tag = 65534;
INT32 snum, next;
size_t a;
sector_t *sector, *rsec;

View file

@ -242,7 +242,7 @@ typedef struct sector_s
INT32 ceilingpic;
INT16 lightlevel;
INT16 special;
INT16 tag;
UINT16 tag;
INT32 nexttag, firsttag; // for fast tag searches
// origin for any sounds played by the sector

View file

@ -152,7 +152,7 @@ static Mix_Chunk *ds2chunk(void *stream)
if (!(frac & 0xFFFF)) // other solid multiples (change if FRACBITS != 16)
newsamples = samples * (frac >> FRACBITS);
else // strange and unusual fractional frequency steps, plus anything higher than 44100hz.
newsamples = FixedMul(frac, samples) + 1; // add 1 sample for security! the code below rounds up.
newsamples = FixedMul(FixedDiv(samples, freq), 44100) + 1; // add 1 to counter truncation.
if (newsamples >= UINT32_MAX>>2)
return NULL; // would and/or did wrap, can't store.
break;