mirror of
https://git.do.srb2.org/KartKrew/Kart-Public.git
synced 2025-02-03 15:01:06 +00:00
Merge remote-tracking branch 'Furyhunter/sdl2'
This commit is contained in:
commit
0386516946
84 changed files with 909 additions and 12488 deletions
16
SRB2.cbp
16
SRB2.cbp
|
@ -33,7 +33,7 @@ HW3SOUND for 3D hardware sound support
|
||||||
<Add option="-g" />
|
<Add option="-g" />
|
||||||
<Add option="`sdl-config --cflags`" />
|
<Add option="`sdl-config --cflags`" />
|
||||||
<Add option="-DDIRECTFULLSCREEN" />
|
<Add option="-DDIRECTFULLSCREEN" />
|
||||||
<Add option="-DSDL" />
|
<Add option="-DHAVE_SDL" />
|
||||||
<Add option="-DPARANOIA" />
|
<Add option="-DPARANOIA" />
|
||||||
<Add option="-DRANGECHECK" />
|
<Add option="-DRANGECHECK" />
|
||||||
<Add option="-D_DEBUG" />
|
<Add option="-D_DEBUG" />
|
||||||
|
@ -56,7 +56,7 @@ HW3SOUND for 3D hardware sound support
|
||||||
<Add option="-g" />
|
<Add option="-g" />
|
||||||
<Add option="`sdl-config --cflags`" />
|
<Add option="`sdl-config --cflags`" />
|
||||||
<Add option="-DDIRECTFULLSCREEN" />
|
<Add option="-DDIRECTFULLSCREEN" />
|
||||||
<Add option="-DSDL" />
|
<Add option="-DHAVE_SDL" />
|
||||||
<Add option="-DNDEBUG" />
|
<Add option="-DNDEBUG" />
|
||||||
<Add option="-DCOMPVERSION" />
|
<Add option="-DCOMPVERSION" />
|
||||||
<Add option="-DHAVE_BLUA" />
|
<Add option="-DHAVE_BLUA" />
|
||||||
|
@ -77,7 +77,7 @@ HW3SOUND for 3D hardware sound support
|
||||||
<Add option="`sdl-config --cflags`" />
|
<Add option="`sdl-config --cflags`" />
|
||||||
<Add option="`libpng-config --cflags`" />
|
<Add option="`libpng-config --cflags`" />
|
||||||
<Add option="-DDIRECTFULLSCREEN" />
|
<Add option="-DDIRECTFULLSCREEN" />
|
||||||
<Add option="-DSDL" />
|
<Add option="-DHAVE_SDL" />
|
||||||
<Add option="-DHAVE_MIXER" />
|
<Add option="-DHAVE_MIXER" />
|
||||||
<Add option="-DHWRENDER" />
|
<Add option="-DHWRENDER" />
|
||||||
<Add option="-DHW3SOUND" />
|
<Add option="-DHW3SOUND" />
|
||||||
|
@ -107,7 +107,7 @@ HW3SOUND for 3D hardware sound support
|
||||||
<Add option="`sdl-config --cflags`" />
|
<Add option="`sdl-config --cflags`" />
|
||||||
<Add option="`libpng-config --cflags`" />
|
<Add option="`libpng-config --cflags`" />
|
||||||
<Add option="-DDIRECTFULLSCREEN" />
|
<Add option="-DDIRECTFULLSCREEN" />
|
||||||
<Add option="-DSDL" />
|
<Add option="-DHAVE_SDL" />
|
||||||
<Add option="-DHAVE_MIXER" />
|
<Add option="-DHAVE_MIXER" />
|
||||||
<Add option="-DHWRENDER" />
|
<Add option="-DHWRENDER" />
|
||||||
<Add option="-DHW3SOUND" />
|
<Add option="-DHW3SOUND" />
|
||||||
|
@ -138,7 +138,7 @@ HW3SOUND for 3D hardware sound support
|
||||||
<Add option="-D__USE_MINGW_ANSI_STDIO=0" />
|
<Add option="-D__USE_MINGW_ANSI_STDIO=0" />
|
||||||
<Add option="-DUSE_WGL_SWAP" />
|
<Add option="-DUSE_WGL_SWAP" />
|
||||||
<Add option="-DDIRECTFULLSCREEN" />
|
<Add option="-DDIRECTFULLSCREEN" />
|
||||||
<Add option="-DSDL" />
|
<Add option="-DHAVE_SDL" />
|
||||||
<Add option="-DHAVE_MIXER" />
|
<Add option="-DHAVE_MIXER" />
|
||||||
<Add option="-DHWRENDER" />
|
<Add option="-DHWRENDER" />
|
||||||
<Add option="-DHW3SOUND" />
|
<Add option="-DHW3SOUND" />
|
||||||
|
@ -185,7 +185,7 @@ HW3SOUND for 3D hardware sound support
|
||||||
<Add option="-D__USE_MINGW_ANSI_STDIO=0" />
|
<Add option="-D__USE_MINGW_ANSI_STDIO=0" />
|
||||||
<Add option="-DUSE_WGL_SWAP" />
|
<Add option="-DUSE_WGL_SWAP" />
|
||||||
<Add option="-DDIRECTFULLSCREEN" />
|
<Add option="-DDIRECTFULLSCREEN" />
|
||||||
<Add option="-DSDL" />
|
<Add option="-DHAVE_SDL" />
|
||||||
<Add option="-DHAVE_MIXER" />
|
<Add option="-DHAVE_MIXER" />
|
||||||
<Add option="-DHAVE_FMOD" />
|
<Add option="-DHAVE_FMOD" />
|
||||||
<Add option="-DHWRENDER" />
|
<Add option="-DHWRENDER" />
|
||||||
|
@ -551,7 +551,7 @@ HW3SOUND for 3D hardware sound support
|
||||||
<Add option="-DSTDC_HEADERS" />
|
<Add option="-DSTDC_HEADERS" />
|
||||||
<Add option="-DUSE_WGL_SWAP" />
|
<Add option="-DUSE_WGL_SWAP" />
|
||||||
<Add option="-DDIRECTFULLSCREEN" />
|
<Add option="-DDIRECTFULLSCREEN" />
|
||||||
<Add option="-DSDL" />
|
<Add option="-DHAVE_SDL" />
|
||||||
<Add option="-DHAVE_MIXER" />
|
<Add option="-DHAVE_MIXER" />
|
||||||
<Add option="-DHWRENDER" />
|
<Add option="-DHWRENDER" />
|
||||||
<Add option="-DHW3SOUND" />
|
<Add option="-DHW3SOUND" />
|
||||||
|
@ -592,7 +592,7 @@ HW3SOUND for 3D hardware sound support
|
||||||
<Add option="-DSTDC_HEADERS" />
|
<Add option="-DSTDC_HEADERS" />
|
||||||
<Add option="-DUSE_WGL_SWAP" />
|
<Add option="-DUSE_WGL_SWAP" />
|
||||||
<Add option="-DDIRECTFULLSCREEN" />
|
<Add option="-DDIRECTFULLSCREEN" />
|
||||||
<Add option="-DSDL" />
|
<Add option="-DHAVE_SDL" />
|
||||||
<Add option="-DHAVE_MIXER" />
|
<Add option="-DHAVE_MIXER" />
|
||||||
<Add option="-DHWRENDER" />
|
<Add option="-DHWRENDER" />
|
||||||
<Add option="-DHW3SOUND" />
|
<Add option="-DHW3SOUND" />
|
||||||
|
|
8
Srb2.dev
8
Srb2.dev
|
@ -2228,7 +2228,7 @@ Includes=libs/libpng-src;libs/zlib;libs
|
||||||
Libs=libs/libpng-src/projects;libs/zlib/win32;libs/miniupnpc/mingw32
|
Libs=libs/libpng-src/projects;libs/zlib/win32;libs/miniupnpc/mingw32
|
||||||
ResourceIncludes=src/win32
|
ResourceIncludes=src/win32
|
||||||
MakeIncludes=comptime.mk;cpdebug.mk
|
MakeIncludes=comptime.mk;cpdebug.mk
|
||||||
Compiler=-DNDEBUG_@@_-fno-exceptions_@@_-DSTDC_HEADERS_@@_-Wall_@@_-Os_@@_-g_@@_-gdwarf-2_@@_-DUSE_WGL_SWAP_@@_-DDIRECTFULLSCREEN_@@_-DSDL_@@_-DHWRENDER_@@_-DHW3SOUND_@@_-DHAVE_MIXER_@@_-DHAVE_PNG_@@_-D__USE_MINGW_ANSI_STDIO=0_@@_-DHAVE_MINIUPNPC_@@_-DSTATIC_MINIUPNPC_@@_-DHAVE_BLUA_@@_
|
Compiler=-DNDEBUG_@@_-fno-exceptions_@@_-DSTDC_HEADERS_@@_-Wall_@@_-Os_@@_-g_@@_-gdwarf-2_@@_-DUSE_WGL_SWAP_@@_-DDIRECTFULLSCREEN_@@_-DHAVE_SDL_@@_-DHWRENDER_@@_-DHW3SOUND_@@_-DHAVE_MIXER_@@_-DHAVE_PNG_@@_-D__USE_MINGW_ANSI_STDIO=0_@@_-DHAVE_MINIUPNPC_@@_-DSTATIC_MINIUPNPC_@@_-DHAVE_BLUA_@@_
|
||||||
CppCompiler=-Os_@@_-g_@@_-gdwarf-2_@@_
|
CppCompiler=-Os_@@_-g_@@_-gdwarf-2_@@_
|
||||||
Linker=-lSDL_@@_-lSDL_Mixer_@@_-lpng32_@@_-lz32_@@_-lminiupnpc_@@_-lws2_32_@@_-liphlpapi_@@_-mconsole_@@_
|
Linker=-lSDL_@@_-lSDL_Mixer_@@_-lpng32_@@_-lz32_@@_-lminiupnpc_@@_-lws2_32_@@_-liphlpapi_@@_-mconsole_@@_
|
||||||
PreprocDefines=NORMALSRB2_@@_
|
PreprocDefines=NORMALSRB2_@@_
|
||||||
|
@ -2305,7 +2305,7 @@ Includes=libs/libpng-src;libs/zlib;libs
|
||||||
Libs=libs/libpng-src/projects;libs/zlib/win32;libs/miniupnpc/mingw32
|
Libs=libs/libpng-src/projects;libs/zlib/win32;libs/miniupnpc/mingw32
|
||||||
ResourceIncludes=src/win32
|
ResourceIncludes=src/win32
|
||||||
MakeIncludes=comptime.mk;cpdebug.mk
|
MakeIncludes=comptime.mk;cpdebug.mk
|
||||||
Compiler=-D_DEBUG_@@_-fno-exceptions_@@_-DSTDC_HEADERS_@@_-Wall_@@_-O0_@@_-g_@@_-gdwarf-2_@@_-DUSE_WGL_SWAP_@@_-DDIRECTFULLSCREEN_@@_-DSDL_@@_-DHWRENDER_@@_-DHW3SOUND_@@_-DHAVE_MIXER_@@_-DHAVE_PNG_@@_-D__USE_MINGW_ANSI_STDIO=0_@@_-DHAVE_MINIUPNPC_@@_-DSTATIC_MINIUPNPC_@@_-DHAVE_BLUA_@@_
|
Compiler=-D_DEBUG_@@_-fno-exceptions_@@_-DSTDC_HEADERS_@@_-Wall_@@_-O0_@@_-g_@@_-gdwarf-2_@@_-DUSE_WGL_SWAP_@@_-DDIRECTFULLSCREEN_@@_-DHAVE_SDL_@@_-DHWRENDER_@@_-DHW3SOUND_@@_-DHAVE_MIXER_@@_-DHAVE_PNG_@@_-D__USE_MINGW_ANSI_STDIO=0_@@_-DHAVE_MINIUPNPC_@@_-DSTATIC_MINIUPNPC_@@_-DHAVE_BLUA_@@_
|
||||||
CppCompiler=-O0_@@_-g_@@_-gdwarf-2_@@_
|
CppCompiler=-O0_@@_-g_@@_-gdwarf-2_@@_
|
||||||
Linker=-lSDL_@@_-lSDL_Mixer_@@_-lpng32_@@_-lz32_@@_-lminiupnpc_@@_-lws2_32_@@_-liphlpapi_@@_-mconsole_@@_
|
Linker=-lSDL_@@_-lSDL_Mixer_@@_-lpng32_@@_-lz32_@@_-lminiupnpc_@@_-lws2_32_@@_-liphlpapi_@@_-mconsole_@@_
|
||||||
PreprocDefines=NORMALSRB2_@@_
|
PreprocDefines=NORMALSRB2_@@_
|
||||||
|
@ -2386,7 +2386,7 @@ Includes=libs/libpng-src;libs/zlib;libs
|
||||||
Libs=libs/libpng-src/projects;libs/zlib/win32;libs/miniupnpc/mingw64
|
Libs=libs/libpng-src/projects;libs/zlib/win32;libs/miniupnpc/mingw64
|
||||||
ResourceIncludes=src/win32
|
ResourceIncludes=src/win32
|
||||||
MakeIncludes=comptime.mk;cpdebug.mk
|
MakeIncludes=comptime.mk;cpdebug.mk
|
||||||
Compiler=-DNDEBUG_@@_-fno-exceptions_@@_-DSTDC_HEADERS_@@_-Wall_@@_-Os_@@_-g_@@_-DUSE_WGL_SWAP_@@_-DDIRECTFULLSCREEN_@@_-DSDL_@@_-DHWRENDER_@@_-DHW3SOUND_@@_-DHAVE_MIXER_@@_-DHAVE_PNG_@@_-D__USE_MINGW_ANSI_STDIO=0_@@_-DHAVE_MINIUPNPC_@@_-DSTATIC_MINIUPNPC_@@_-DHAVE_BLUA_@@_
|
Compiler=-DNDEBUG_@@_-fno-exceptions_@@_-DSTDC_HEADERS_@@_-Wall_@@_-Os_@@_-g_@@_-DUSE_WGL_SWAP_@@_-DDIRECTFULLSCREEN_@@_-DHAVE_SDL_@@_-DHWRENDER_@@_-DHW3SOUND_@@_-DHAVE_MIXER_@@_-DHAVE_PNG_@@_-D__USE_MINGW_ANSI_STDIO=0_@@_-DHAVE_MINIUPNPC_@@_-DSTATIC_MINIUPNPC_@@_-DHAVE_BLUA_@@_
|
||||||
CppCompiler=-Os_@@_-g_@@_
|
CppCompiler=-Os_@@_-g_@@_
|
||||||
Linker=-lSDL_@@_-lSDL_Mixer_@@_-lpng64_@@_-lz64_@@_-lminiupnpc_@@_-lws2_32_@@_-liphlpapi_@@_-mconsole_@@_
|
Linker=-lSDL_@@_-lSDL_Mixer_@@_-lpng64_@@_-lz64_@@_-lminiupnpc_@@_-lws2_32_@@_-liphlpapi_@@_-mconsole_@@_
|
||||||
PreprocDefines=NORMALSRB2_@@_
|
PreprocDefines=NORMALSRB2_@@_
|
||||||
|
@ -2413,7 +2413,7 @@ Includes=libs/libpng-src;libs/zlib;libs
|
||||||
Libs=libs/libpng-src/projects;libs/zlib/win32;libs/miniupnpc/mingw64
|
Libs=libs/libpng-src/projects;libs/zlib/win32;libs/miniupnpc/mingw64
|
||||||
ResourceIncludes=src/win32
|
ResourceIncludes=src/win32
|
||||||
MakeIncludes=comptime.mk;cpdebug.mk
|
MakeIncludes=comptime.mk;cpdebug.mk
|
||||||
Compiler=-D_DEBUG_@@_-fno-exceptions_@@_-DSTDC_HEADERS_@@_-Wall_@@_-O0_@@_-g_@@_-DUSE_WGL_SWAP_@@_-DDIRECTFULLSCREEN_@@_-DSDL_@@_-DHWRENDER_@@_-DHW3SOUND_@@_-DHAVE_MIXER_@@_-DHAVE_PNG_@@_-D__USE_MINGW_ANSI_STDIO=0_@@_-DHAVE_MINIUPNPC_@@_-DSTATIC_MINIUPNPC_@@_-DHAVE_BLUA_@@_
|
Compiler=-D_DEBUG_@@_-fno-exceptions_@@_-DSTDC_HEADERS_@@_-Wall_@@_-O0_@@_-g_@@_-DUSE_WGL_SWAP_@@_-DDIRECTFULLSCREEN_@@_-DHAVE_SDL_@@_-DHWRENDER_@@_-DHW3SOUND_@@_-DHAVE_MIXER_@@_-DHAVE_PNG_@@_-D__USE_MINGW_ANSI_STDIO=0_@@_-DHAVE_MINIUPNPC_@@_-DSTATIC_MINIUPNPC_@@_-DHAVE_BLUA_@@_
|
||||||
CppCompiler=-O0_@@_-g_@@_
|
CppCompiler=-O0_@@_-g_@@_
|
||||||
Linker=-lSDL_@@_-lSDL_Mixer_@@_-lpng64_@@_-lz64_@@_-lminiupnpc_@@_-lws2_32_@@_-liphlpapi_@@_-mconsole_@@_
|
Linker=-lSDL_@@_-lSDL_Mixer_@@_-lpng64_@@_-lz64_@@_-lminiupnpc_@@_-lws2_32_@@_-liphlpapi_@@_-mconsole_@@_
|
||||||
PreprocDefines=NORMALSRB2_@@_
|
PreprocDefines=NORMALSRB2_@@_
|
||||||
|
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -10,7 +10,7 @@
|
||||||
# -DPC_DOS -> use DOS specific code (eg:textmode stuff)...
|
# -DPC_DOS -> use DOS specific code (eg:textmode stuff)...
|
||||||
# -DLINUX -> use for the GNU/Linux specific
|
# -DLINUX -> use for the GNU/Linux specific
|
||||||
# -D_WINDOWS -> use for the Win32/DirectX specific
|
# -D_WINDOWS -> use for the Win32/DirectX specific
|
||||||
# -DSDL -> use for the SDL interface
|
# -DHAVE_SDL -> use for the SDL interface
|
||||||
#
|
#
|
||||||
# Sets:
|
# Sets:
|
||||||
# Compile the DGJPP/DOS version with 'make WATTCP=1'
|
# Compile the DGJPP/DOS version with 'make WATTCP=1'
|
||||||
|
|
|
@ -230,7 +230,6 @@ ifdef DUMMY
|
||||||
BIN:=$(BIN)/dummy
|
BIN:=$(BIN)/dummy
|
||||||
else
|
else
|
||||||
ifdef LINUX
|
ifdef LINUX
|
||||||
INTERFACE=sdl
|
|
||||||
NASMFORMAT=elf -DLINUX
|
NASMFORMAT=elf -DLINUX
|
||||||
SDL=1
|
SDL=1
|
||||||
ifndef NOGETTEXT
|
ifndef NOGETTEXT
|
||||||
|
|
|
@ -1139,7 +1139,7 @@ void CONS_Printf(const char *fmt, ...)
|
||||||
// if not in display loop, force screen update
|
// if not in display loop, force screen update
|
||||||
if (con_startup)
|
if (con_startup)
|
||||||
{
|
{
|
||||||
#if (defined (_WINDOWS)) || (defined (__OS2__) && !defined (SDL))
|
#if (defined (_WINDOWS)) || (defined (__OS2__) && !defined (HAVE_SDL))
|
||||||
static lumpnum_t con_backpic_lumpnum = UINT32_MAX;
|
static lumpnum_t con_backpic_lumpnum = UINT32_MAX;
|
||||||
patch_t *con_backpic;
|
patch_t *con_backpic;
|
||||||
|
|
||||||
|
|
10
src/d_main.c
10
src/d_main.c
|
@ -731,7 +731,7 @@ static void IdentifyVersion(void)
|
||||||
char *srb2wad1, *srb2wad2;
|
char *srb2wad1, *srb2wad2;
|
||||||
const char *srb2waddir = NULL;
|
const char *srb2waddir = NULL;
|
||||||
|
|
||||||
#if (defined (__unix__) && !defined (MSDOS)) || defined (UNIXCOMMON) || defined (SDL)
|
#if (defined (__unix__) && !defined (MSDOS)) || defined (UNIXCOMMON) || defined (HAVE_SDL)
|
||||||
// change to the directory where 'srb2.srb' is found
|
// change to the directory where 'srb2.srb' is found
|
||||||
srb2waddir = I_LocateWad();
|
srb2waddir = I_LocateWad();
|
||||||
#endif
|
#endif
|
||||||
|
@ -757,7 +757,7 @@ static void IdentifyVersion(void)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined (macintosh) && !defined (SDL)
|
#if defined (macintosh) && !defined (HAVE_SDL)
|
||||||
// cwd is always "/" when app is dbl-clicked
|
// cwd is always "/" when app is dbl-clicked
|
||||||
if (!stricmp(srb2waddir, "/"))
|
if (!stricmp(srb2waddir, "/"))
|
||||||
srb2waddir = I_GetWadDir();
|
srb2waddir = I_GetWadDir();
|
||||||
|
@ -804,7 +804,7 @@ static void IdentifyVersion(void)
|
||||||
// Add our crappy patches to fix our bugs
|
// Add our crappy patches to fix our bugs
|
||||||
D_AddFile(va(pandf,srb2waddir,"patch.dta"));
|
D_AddFile(va(pandf,srb2waddir,"patch.dta"));
|
||||||
|
|
||||||
#if !defined (SDL) || defined (HAVE_MIXER)
|
#if !defined (HAVE_SDL) || defined (HAVE_MIXER)
|
||||||
{
|
{
|
||||||
#if defined (DC) && 0
|
#if defined (DC) && 0
|
||||||
const char *musicfile = "music_dc.dta";
|
const char *musicfile = "music_dc.dta";
|
||||||
|
@ -929,7 +929,7 @@ void D_SRB2Main(void)
|
||||||
D_Titlebar(srb2, title);
|
D_Titlebar(srb2, title);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined (__OS2__) && !defined (SDL)
|
#if defined (__OS2__) && !defined (HAVE_SDL)
|
||||||
// set PM window title
|
// set PM window title
|
||||||
snprintf(pmData->title, sizeof (pmData->title),
|
snprintf(pmData->title, sizeof (pmData->title),
|
||||||
"Sonic Robo Blast 2" VERSIONSTRING ": %s",
|
"Sonic Robo Blast 2" VERSIONSTRING ": %s",
|
||||||
|
@ -1136,7 +1136,7 @@ void D_SRB2Main(void)
|
||||||
|
|
||||||
G_LoadGameData();
|
G_LoadGameData();
|
||||||
|
|
||||||
#if (defined (__unix__) && !defined (MSDOS)) || defined (UNIXCOMMON) || defined (SDL)
|
#if (defined (__unix__) && !defined (MSDOS)) || defined (UNIXCOMMON) || defined (HAVE_SDL)
|
||||||
VID_PrepareModeList(); // Regenerate Modelist according to cv_fullscreen
|
VID_PrepareModeList(); // Regenerate Modelist according to cv_fullscreen
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -258,7 +258,7 @@ consvar_t cv_usejoystick = {"use_joystick", "0", CV_SAVE|CV_CALL, usejoystick_co
|
||||||
consvar_t cv_usejoystick2 = {"use_joystick2", "0", CV_SAVE|CV_CALL, usejoystick_cons_t,
|
consvar_t cv_usejoystick2 = {"use_joystick2", "0", CV_SAVE|CV_CALL, usejoystick_cons_t,
|
||||||
I_InitJoystick2, 0, NULL, NULL, 0, 0, NULL};
|
I_InitJoystick2, 0, NULL, NULL, 0, 0, NULL};
|
||||||
#endif
|
#endif
|
||||||
#if (defined (LJOYSTICK) || defined (SDL))
|
#if (defined (LJOYSTICK) || defined (HAVE_SDL))
|
||||||
#ifdef LJOYSTICK
|
#ifdef LJOYSTICK
|
||||||
consvar_t cv_joyport = {"joyport", "/dev/js0", CV_SAVE, joyport_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL};
|
consvar_t cv_joyport = {"joyport", "/dev/js0", CV_SAVE, joyport_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL};
|
||||||
consvar_t cv_joyport2 = {"joyport2", "/dev/js0", CV_SAVE, joyport_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; //Alam: for later
|
consvar_t cv_joyport2 = {"joyport2", "/dev/js0", CV_SAVE, joyport_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; //Alam: for later
|
||||||
|
|
|
@ -24,7 +24,7 @@
|
||||||
#define SOUND_FMOD 3
|
#define SOUND_FMOD 3
|
||||||
|
|
||||||
#ifndef SOUND
|
#ifndef SOUND
|
||||||
#ifdef SDL
|
#ifdef HAVE_SDL
|
||||||
|
|
||||||
// Use Mixer interface?
|
// Use Mixer interface?
|
||||||
#ifdef HAVE_MIXER
|
#ifdef HAVE_MIXER
|
||||||
|
|
|
@ -24,7 +24,7 @@
|
||||||
#include "hw_dll.h"
|
#include "hw_dll.h"
|
||||||
#include "hws_data.h"
|
#include "hws_data.h"
|
||||||
|
|
||||||
#if defined (SDL) || !defined (HWD)
|
#if defined (HAVE_SDL) || !defined (HWD)
|
||||||
EXPORT void HWRAPI(Shutdown) (void);
|
EXPORT void HWRAPI(Shutdown) (void);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -26,7 +26,7 @@
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined (VID_X11) && !defined (SDL)
|
#if defined (VID_X11) && !defined (HAVE_SDL)
|
||||||
#include <GL/glx.h>
|
#include <GL/glx.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -32,12 +32,12 @@
|
||||||
// STANDARD DLL EXPORTS
|
// STANDARD DLL EXPORTS
|
||||||
// ==========================================================================
|
// ==========================================================================
|
||||||
|
|
||||||
#ifdef SDL
|
#ifdef HAVE_SDL
|
||||||
#undef VID_X11
|
#undef VID_X11
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
EXPORT boolean HWRAPI(Init) (I_Error_t ErrorFunction);
|
EXPORT boolean HWRAPI(Init) (I_Error_t ErrorFunction);
|
||||||
#ifndef SDL
|
#ifndef HAVE_SDL
|
||||||
EXPORT void HWRAPI(Shutdown) (void);
|
EXPORT void HWRAPI(Shutdown) (void);
|
||||||
#endif
|
#endif
|
||||||
#ifdef _WINDOWS
|
#ifdef _WINDOWS
|
||||||
|
@ -116,7 +116,7 @@ struct hwdriver_s
|
||||||
HookXwin pfnHookXwin;
|
HookXwin pfnHookXwin;
|
||||||
GetRenderer pfnGetRenderer;
|
GetRenderer pfnGetRenderer;
|
||||||
#endif
|
#endif
|
||||||
#ifndef SDL
|
#ifndef HAVE_SDL
|
||||||
Shutdown pfnShutdown;
|
Shutdown pfnShutdown;
|
||||||
#endif
|
#endif
|
||||||
#ifdef SHUFFLE
|
#ifdef SHUFFLE
|
||||||
|
|
|
@ -163,7 +163,7 @@ static I_Error_t I_Error_GL = NULL;
|
||||||
// : else do nothing
|
// : else do nothing
|
||||||
// Returns :
|
// Returns :
|
||||||
// -----------------+
|
// -----------------+
|
||||||
#if !(defined (SDL) && defined (STATIC3DS))
|
#if !(defined (HAVE_SDL) && defined (STATIC3DS))
|
||||||
FUNCPRINTF void DBG_Printf(const char *lpFmt, ...)
|
FUNCPRINTF void DBG_Printf(const char *lpFmt, ...)
|
||||||
{
|
{
|
||||||
#ifdef DEBUG_TO_FILE
|
#ifdef DEBUG_TO_FILE
|
||||||
|
|
|
@ -20,7 +20,7 @@
|
||||||
#ifndef _R_OPENGL_H_
|
#ifndef _R_OPENGL_H_
|
||||||
#define _R_OPENGL_H_
|
#define _R_OPENGL_H_
|
||||||
|
|
||||||
#ifdef SDL
|
#ifdef HAVE_SDL
|
||||||
|
|
||||||
#ifdef _MSC_VER
|
#ifdef _MSC_VER
|
||||||
#pragma warning(disable : 4214 4244)
|
#pragma warning(disable : 4214 4244)
|
||||||
|
@ -50,7 +50,7 @@
|
||||||
|
|
||||||
#undef DEBUG_TO_FILE // maybe defined in previous *.h
|
#undef DEBUG_TO_FILE // maybe defined in previous *.h
|
||||||
#define DEBUG_TO_FILE // output debugging msgs to ogllog.txt
|
#define DEBUG_TO_FILE // output debugging msgs to ogllog.txt
|
||||||
#if defined ( SDL ) && !defined ( LOGMESSAGES )
|
#if defined ( HAVE_SDL ) && !defined ( LOGMESSAGES )
|
||||||
#undef DEBUG_TO_FILE
|
#undef DEBUG_TO_FILE
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -109,7 +109,7 @@ extern PFNglGetString pglGetString;
|
||||||
|
|
||||||
extern const GLubyte *gl_extensions;
|
extern const GLubyte *gl_extensions;
|
||||||
extern RGBA_t myPaletteData[];
|
extern RGBA_t myPaletteData[];
|
||||||
#ifndef SDL
|
#ifndef HAVE_SDL
|
||||||
extern FILE *logstream;
|
extern FILE *logstream;
|
||||||
#endif
|
#endif
|
||||||
extern GLint screen_width;
|
extern GLint screen_width;
|
||||||
|
|
|
@ -48,7 +48,7 @@
|
||||||
#undef DEBUG_TO_FILE
|
#undef DEBUG_TO_FILE
|
||||||
#define DEBUG_TO_FILE
|
#define DEBUG_TO_FILE
|
||||||
|
|
||||||
#if defined ( SDL ) && !defined ( LOGMESSAGES )
|
#if defined ( HAVE_SDL ) && !defined ( LOGMESSAGES )
|
||||||
#undef DEBUG_TO_FILE
|
#undef DEBUG_TO_FILE
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -55,7 +55,7 @@ FILE *logstream = NULL;
|
||||||
#define MAXCHANNEL 1024
|
#define MAXCHANNEL 1024
|
||||||
|
|
||||||
#undef DEBUG_TO_FILE
|
#undef DEBUG_TO_FILE
|
||||||
#if defined ( SDL ) && !defined ( LOGMESSAGES )
|
#if defined ( HAVE_SDL ) && !defined ( LOGMESSAGES )
|
||||||
#define DEBUG_TO_FILE
|
#define DEBUG_TO_FILE
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -1187,7 +1187,7 @@ BOOL WINAPI DllMain(HINSTANCE hinstDLL, // handle to DLL module
|
||||||
}
|
}
|
||||||
return TRUE; // Successful DLL_PROCESS_ATTACH.
|
return TRUE; // Successful DLL_PROCESS_ATTACH.
|
||||||
}
|
}
|
||||||
#elif !defined (SDL)
|
#elif !defined (HAVE_SDL)
|
||||||
|
|
||||||
// **************************************************************************
|
// **************************************************************************
|
||||||
// FUNCTIONS
|
// FUNCTIONS
|
||||||
|
|
|
@ -31,7 +31,7 @@ FILE* logstream = NULL;
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#ifndef SDL // let not make a logstream here is we are inline the HW3D in the SDL binary
|
#ifndef HAVE_SDL // let not make a logstream here is we are inline the HW3D in the SDL binary
|
||||||
FILE* logstream = NULL;
|
FILE* logstream = NULL;
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
@ -49,7 +49,7 @@ FILE* logstream = NULL;
|
||||||
#include "../hw3dsdrv.h"
|
#include "../hw3dsdrv.h"
|
||||||
|
|
||||||
//#undef DEBUG_TO_FILE
|
//#undef DEBUG_TO_FILE
|
||||||
//#if defined ( SDL ) && !defined ( LOGMESSAGES )
|
//#if defined ( HAVE_SDL ) && !defined ( LOGMESSAGES )
|
||||||
#define DEBUG_TO_FILE
|
#define DEBUG_TO_FILE
|
||||||
//#endif
|
//#endif
|
||||||
|
|
||||||
|
|
|
@ -1110,7 +1110,7 @@ static menuitem_t OP_VideoOptionsMenu[] =
|
||||||
{IT_SUBMENU|IT_STRING, NULL, "3D Card Options...", &OP_OpenGLOptionsDef, 20},
|
{IT_SUBMENU|IT_STRING, NULL, "3D Card Options...", &OP_OpenGLOptionsDef, 20},
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if (defined (__unix__) && !defined (MSDOS)) || defined (UNIXCOMMON) || defined (SDL)
|
#if (defined (__unix__) && !defined (MSDOS)) || defined (UNIXCOMMON) || defined (HAVE_SDL)
|
||||||
{IT_STRING|IT_CVAR, NULL, "Fullscreen", &cv_fullscreen, 30},
|
{IT_STRING|IT_CVAR, NULL, "Fullscreen", &cv_fullscreen, 30},
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -6827,7 +6827,7 @@ static void M_VideoModeMenu(INT32 choice)
|
||||||
|
|
||||||
memset(modedescs, 0, sizeof(modedescs));
|
memset(modedescs, 0, sizeof(modedescs));
|
||||||
|
|
||||||
#if (defined (__unix__) && !defined (MSDOS)) || defined (UNIXCOMMON) || defined (SDL)
|
#if (defined (__unix__) && !defined (MSDOS)) || defined (UNIXCOMMON) || defined (HAVE_SDL)
|
||||||
VID_PrepareModeList(); // FIXME: hack
|
VID_PrepareModeList(); // FIXME: hack
|
||||||
#endif
|
#endif
|
||||||
vidm_nummodes = 0;
|
vidm_nummodes = 0;
|
||||||
|
|
11
src/m_misc.c
11
src/m_misc.c
|
@ -47,8 +47,11 @@
|
||||||
#include "hardware/hw_main.h"
|
#include "hardware/hw_main.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef SDL
|
#ifdef HAVE_SDL
|
||||||
#include "sdl/hwsym_sdl.h"
|
#include "sdl/hwsym_sdl.h"
|
||||||
|
#ifdef __linux__
|
||||||
|
typedef off_t off64_t;
|
||||||
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined (_WIN32)
|
#if defined (_WIN32)
|
||||||
|
@ -651,7 +654,7 @@ static void M_PNGText(png_structp png_ptr, png_infop png_info_ptr, PNG_CONST png
|
||||||
char Movietxt[] = "SRB2 Movie";
|
char Movietxt[] = "SRB2 Movie";
|
||||||
size_t i;
|
size_t i;
|
||||||
char interfacetxt[] =
|
char interfacetxt[] =
|
||||||
#ifdef SDL
|
#ifdef HAVE_SDL
|
||||||
"SDL";
|
"SDL";
|
||||||
#elif defined (_WINDOWS)
|
#elif defined (_WINDOWS)
|
||||||
"DirectX";
|
"DirectX";
|
||||||
|
@ -806,7 +809,7 @@ static inline boolean M_PNGLib(void)
|
||||||
pnglib = GetModuleHandleA("libpng12.dll");
|
pnglib = GetModuleHandleA("libpng12.dll");
|
||||||
if (!pnglib)
|
if (!pnglib)
|
||||||
pnglib = GetModuleHandleA("libpng13.dll");
|
pnglib = GetModuleHandleA("libpng13.dll");
|
||||||
#elif defined (SDL)
|
#elif defined (HAVE_SDL)
|
||||||
#ifdef __APPLE__
|
#ifdef __APPLE__
|
||||||
pnglib = hwOpen("libpng.dylib");
|
pnglib = hwOpen("libpng.dylib");
|
||||||
#else
|
#else
|
||||||
|
@ -815,7 +818,7 @@ static inline boolean M_PNGLib(void)
|
||||||
#endif
|
#endif
|
||||||
if (!pnglib)
|
if (!pnglib)
|
||||||
return false;
|
return false;
|
||||||
#ifdef SDL
|
#ifdef HAVE_SDL
|
||||||
apng_set_acTL = hwSym("png_set_acTL", pnglib);
|
apng_set_acTL = hwSym("png_set_acTL", pnglib);
|
||||||
apng_write_frame_head = hwSym("png_write_frame_head", pnglib);
|
apng_write_frame_head = hwSym("png_write_frame_head", pnglib);
|
||||||
apng_write_frame_tail = hwSym("png_write_frame_tail", pnglib);
|
apng_write_frame_tail = hwSym("png_write_frame_tail", pnglib);
|
||||||
|
|
|
@ -253,7 +253,7 @@ void S_RegisterSoundStuff(void)
|
||||||
CV_RegisterVar(&surround);
|
CV_RegisterVar(&surround);
|
||||||
CV_RegisterVar(&cv_samplerate);
|
CV_RegisterVar(&cv_samplerate);
|
||||||
|
|
||||||
#if defined (macintosh) && !defined (SDL) // mp3 playlist stuff
|
#if defined (macintosh) && !defined (HAVE_SDL) // mp3 playlist stuff
|
||||||
{
|
{
|
||||||
INT32 i;
|
INT32 i;
|
||||||
for (i = 0; i < PLAYLIST_LENGTH; i++)
|
for (i = 0; i < PLAYLIST_LENGTH; i++)
|
||||||
|
@ -761,7 +761,7 @@ void S_PauseSound(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
// pause cd music
|
// pause cd music
|
||||||
#if (defined (__unix__) && !defined (MSDOS)) || defined (UNIXCOMMON) || defined (SDL)
|
#if (defined (__unix__) && !defined (MSDOS)) || defined (UNIXCOMMON) || defined (HAVE_SDL)
|
||||||
I_PauseCD();
|
I_PauseCD();
|
||||||
#else
|
#else
|
||||||
I_StopCD();
|
I_StopCD();
|
||||||
|
@ -1050,7 +1050,7 @@ static boolean S_MIDIMusic(musicinfo_t *music, boolean looping)
|
||||||
|
|
||||||
// load & register it
|
// load & register it
|
||||||
music->data = W_CacheLumpNum(music->lumpnum, PU_MUSIC);
|
music->data = W_CacheLumpNum(music->lumpnum, PU_MUSIC);
|
||||||
#if defined (macintosh) && !defined (SDL)
|
#if defined (macintosh) && !defined (HAVE_SDL)
|
||||||
music->handle = I_RegisterSong(music_num);
|
music->handle = I_RegisterSong(music_num);
|
||||||
#else
|
#else
|
||||||
music->handle = I_RegisterSong(music->data, W_LumpLength(music->lumpnum));
|
music->handle = I_RegisterSong(music->data, W_LumpLength(music->lumpnum));
|
||||||
|
@ -1154,7 +1154,7 @@ void S_StopMusic(void)
|
||||||
I_StopSong(mus_playing->handle);
|
I_StopSong(mus_playing->handle);
|
||||||
I_UnRegisterSong(mus_playing->handle);
|
I_UnRegisterSong(mus_playing->handle);
|
||||||
|
|
||||||
#ifndef SDL //SDL uses RWOPS
|
#ifndef HAVE_SDL //SDL uses RWOPS
|
||||||
Z_ChangeTag(mus_playing->data, PU_CACHE);
|
Z_ChangeTag(mus_playing->data, PU_CACHE);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -37,7 +37,7 @@ extern CV_PossibleValue_t soundvolume_cons_t[];
|
||||||
//part of i_cdmus.c
|
//part of i_cdmus.c
|
||||||
extern consvar_t cd_volume, cdUpdate;
|
extern consvar_t cd_volume, cdUpdate;
|
||||||
|
|
||||||
#if defined (macintosh) && !defined (SDL)
|
#if defined (macintosh) && !defined (HAVE_SDL)
|
||||||
typedef enum
|
typedef enum
|
||||||
{
|
{
|
||||||
music_normal,
|
music_normal,
|
||||||
|
|
|
@ -30,6 +30,10 @@ ifdef NOTERMIOS
|
||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
ifdef LINUX64
|
||||||
|
OPTS+=-DLINUX64
|
||||||
|
endif
|
||||||
|
|
||||||
#
|
#
|
||||||
#here is Solaris
|
#here is Solaris
|
||||||
#
|
#
|
||||||
|
@ -89,4 +93,4 @@ ifndef NOHW
|
||||||
endif
|
endif
|
||||||
|
|
||||||
# name of the exefile
|
# name of the exefile
|
||||||
EXENAME?=lsdlsrb2
|
EXENAME?=lsdl2srb2
|
||||||
|
|
|
@ -43,9 +43,9 @@ SDL_CFLAGS?=$(shell $(PKG_CONFIG) $(SDL_PKGCONFIG) --cflags)
|
||||||
SDL_LDFLAGS?=$(shell $(PKG_CONFIG) $(SDL_PKGCONFIG) --libs)
|
SDL_LDFLAGS?=$(shell $(PKG_CONFIG) $(SDL_PKGCONFIG) --libs)
|
||||||
else
|
else
|
||||||
ifdef PREFIX
|
ifdef PREFIX
|
||||||
SDL_CONFIG?=$(PREFIX)-sdl-config
|
SDL_CONFIG?=$(PREFIX)-sdl2-config
|
||||||
else
|
else
|
||||||
SDL_CONFIG?=sdl-config
|
SDL_CONFIG?=sdl2-config
|
||||||
endif
|
endif
|
||||||
|
|
||||||
ifdef STATIC
|
ifdef STATIC
|
||||||
|
@ -67,7 +67,7 @@ endif
|
||||||
|
|
||||||
OBJS+=$(OBJDIR)/i_video.o $(OBJDIR)/dosstr.o $(OBJDIR)/endtxt.o $(OBJDIR)/hwsym_sdl.o
|
OBJS+=$(OBJDIR)/i_video.o $(OBJDIR)/dosstr.o $(OBJDIR)/endtxt.o $(OBJDIR)/hwsym_sdl.o
|
||||||
|
|
||||||
OPTS+=-DDIRECTFULLSCREEN -DSDL
|
OPTS+=-DDIRECTFULLSCREEN -DHAVE_SDL
|
||||||
|
|
||||||
ifndef NOHW
|
ifndef NOHW
|
||||||
OBJS+=$(OBJDIR)/r_opengl.o $(OBJDIR)/ogl_sdl.o
|
OBJS+=$(OBJDIR)/r_opengl.o $(OBJDIR)/ogl_sdl.o
|
||||||
|
@ -95,33 +95,28 @@ endif
|
||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
|
|
||||||
ifdef FILTERS
|
|
||||||
OBJS+=$(OBJDIR)/filters.o $(OBJDIR)/hq2x.o $(OBJDIR)/lq2x.o
|
|
||||||
OPTS+=-DHAVE_FILTER
|
|
||||||
endif
|
|
||||||
|
|
||||||
ifdef NOMIXER
|
ifdef NOMIXER
|
||||||
i_sound_o=$(OBJDIR)/sdl_sound.o
|
i_sound_o=$(OBJDIR)/sdl_sound.o
|
||||||
else
|
else
|
||||||
i_sound_o=$(OBJDIR)/mixer_sound.o
|
i_sound_o=$(OBJDIR)/mixer_sound.o
|
||||||
OPTS+=-DHAVE_MIXER
|
OPTS+=-DHAVE_MIXER
|
||||||
SDL_LDFLAGS+=-lSDL_mixer
|
SDL_LDFLAGS+=-lSDL2_mixer
|
||||||
endif
|
endif
|
||||||
|
|
||||||
ifdef SDL_TTF
|
ifdef SDL_TTF
|
||||||
OPTS+=-DHAVE_TTF
|
OPTS+=-DHAVE_TTF
|
||||||
SDL_LDFLAGS+=-lSDL_ttf -lfreetype -lz
|
SDL_LDFLAGS+=-lSDL2_ttf -lfreetype -lz
|
||||||
OBJS+=$(OBJDIR)/i_ttf.o
|
OBJS+=$(OBJDIR)/i_ttf.o
|
||||||
endif
|
endif
|
||||||
|
|
||||||
#ifdef SDL_IMAGE
|
ifdef SDL_IMAGE
|
||||||
# OPTS+=-DHAVE_IMAGE
|
OPTS+=-DHAVE_IMAGE
|
||||||
# SDL_LDFLAGS+=-lSDL_image
|
SDL_LDFLAGS+=-lSDL2_image
|
||||||
#endif
|
endif
|
||||||
|
|
||||||
ifdef SDL_NET
|
ifdef SDL_NET
|
||||||
OPTS+=-DHAVE_SDLNET
|
OPTS+=-DHAVE_SDLNET
|
||||||
SDL_LDFLAGS+=-lSDL_net
|
SDL_LDFLAGS+=-lSDL2_net
|
||||||
endif
|
endif
|
||||||
|
|
||||||
ifdef SDLMAIN
|
ifdef SDLMAIN
|
||||||
|
|
|
@ -1,12 +0,0 @@
|
||||||
#
|
|
||||||
# Makefile.cfg for WinCE with GCC
|
|
||||||
#
|
|
||||||
|
|
||||||
OPTS+=-D_WIN32_WCE -D_UNICODE
|
|
||||||
SDL_CFLAGS?=
|
|
||||||
SDL_LDFLAGS?=
|
|
||||||
NOHS=1
|
|
||||||
NOHW=1
|
|
||||||
NONET=1
|
|
||||||
NOMIXER=1
|
|
||||||
NOPNG=1
|
|
Binary file not shown.
|
@ -1,447 +0,0 @@
|
||||||
// Emacs style mode select -*- C++ -*-
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
//
|
|
||||||
// Copyright (C) 2004 by Sonic Team Jr.
|
|
||||||
//
|
|
||||||
// This program 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.
|
|
||||||
//
|
|
||||||
// DESCRIPTION:
|
|
||||||
// stub and replacement "ANSI" C functions for use under Windows CE
|
|
||||||
//
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
|
|
||||||
#include "../../doomdef.h"
|
|
||||||
#include "cehelp.h"
|
|
||||||
|
|
||||||
#define _SEC_IN_MINUTE 60
|
|
||||||
#define _SEC_IN_HOUR 3600
|
|
||||||
#define _SEC_IN_DAY 86400
|
|
||||||
|
|
||||||
static const int DAYS_IN_MONTH[12] =
|
|
||||||
{31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
|
|
||||||
|
|
||||||
#define _DAYS_IN_MONTH(x) ((x == 1) ? days_in_feb : DAYS_IN_MONTH[x])
|
|
||||||
|
|
||||||
static const int _DAYS_BEFORE_MONTH[12] =
|
|
||||||
{0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334};
|
|
||||||
|
|
||||||
#define _ISLEAP(y) (((y) % 4) == 0 && (((y) % 100) != 0 || (((y)+1900) % 400) == 0))
|
|
||||||
#define _DAYS_IN_YEAR(year) (_ISLEAP(year) ? 366 : 365)
|
|
||||||
|
|
||||||
char *strerror(int ecode)
|
|
||||||
{
|
|
||||||
static char buff[1024 + 1];
|
|
||||||
DWORD dwMsgLen = FormatMessageA(FORMAT_MESSAGE_FROM_SYSTEM|FORMAT_MESSAGE_IGNORE_INSERTS, NULL,
|
|
||||||
ecode, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), &buff[0], 1024, NULL);
|
|
||||||
return buff;
|
|
||||||
}
|
|
||||||
|
|
||||||
int unlink( const char *filename )
|
|
||||||
{
|
|
||||||
return remove(filename);
|
|
||||||
}
|
|
||||||
|
|
||||||
int remove( const char *path )
|
|
||||||
{
|
|
||||||
return DeleteFileA(path)-1;
|
|
||||||
}
|
|
||||||
|
|
||||||
int rename( const char *oldname, const char *newname )
|
|
||||||
{
|
|
||||||
return MoveFileA(oldname, newname)!=0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline void STToTM(const SYSTEMTIME *st, struct tm *tm)
|
|
||||||
{
|
|
||||||
if (!st || !tm) return;
|
|
||||||
tm->tm_sec = st->wSecond;
|
|
||||||
tm->tm_min = st->wMinute;
|
|
||||||
tm->tm_hour = st->wHour;
|
|
||||||
tm->tm_mday = st->wDay;
|
|
||||||
tm->tm_mon = st->wMonth - 1;
|
|
||||||
tm->tm_year = st->wYear - 1900;
|
|
||||||
tm->tm_wday = st->wDayOfWeek;
|
|
||||||
tm->tm_yday = 0;
|
|
||||||
tm->tm_isdst = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
time_t time(time_t *T)
|
|
||||||
{
|
|
||||||
time_t returntime;
|
|
||||||
SYSTEMTIME st;
|
|
||||||
struct tm stft;
|
|
||||||
GetSystemTime(&st);
|
|
||||||
STToTM(&st,&stft);
|
|
||||||
returntime = mktime(&stft);
|
|
||||||
if (T) *T = returntime;
|
|
||||||
return returntime;
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline UINT64 TTtoFT(const time_t wt, FILETIME *ft)
|
|
||||||
{
|
|
||||||
UINT64 temptime = wt; // FILETIME: 1/(10^7) secs since January 1, 1601
|
|
||||||
temptime *= 10000000; // time_t : 1 secs since January 1, 1970
|
|
||||||
// 369 years * 365 days * 24 hours * 60 mins * 60 secs * 10
|
|
||||||
// 123 leaps days * 24 hours * 60 mins * 60 secs * 10
|
|
||||||
temptime += 116444736000000000;
|
|
||||||
if (ft) CopyMemory(ft,&temptime,sizeof (ULARGE_INTEGER));
|
|
||||||
return temptime;
|
|
||||||
}
|
|
||||||
|
|
||||||
static struct tm cehelptm;
|
|
||||||
|
|
||||||
struct tm * localtime(const time_t *CLOCK)
|
|
||||||
{
|
|
||||||
SYSTEMTIME st;
|
|
||||||
FILETIME stft;
|
|
||||||
UINT64 ftli = 0;
|
|
||||||
if (CLOCK) ftli = TTtoFT(*CLOCK, &stft);
|
|
||||||
if (ftli)
|
|
||||||
FileTimeToSystemTime(&stft,&st);
|
|
||||||
else
|
|
||||||
GetSystemTime(&st);
|
|
||||||
STToTM(&st,&cehelptm);
|
|
||||||
if (st.wYear >= 1970)
|
|
||||||
return &cehelptm;
|
|
||||||
else
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void validate_structure (struct tm *tim_p) // from newlib
|
|
||||||
{
|
|
||||||
div_t res;
|
|
||||||
int days_in_feb = 28;
|
|
||||||
|
|
||||||
/* calculate time & date to account for out of range values */
|
|
||||||
if (tim_p->tm_sec < 0 || tim_p->tm_sec > 59)
|
|
||||||
{
|
|
||||||
res = div (tim_p->tm_sec, 60);
|
|
||||||
tim_p->tm_min += res.quot;
|
|
||||||
if ((tim_p->tm_sec = res.rem) < 0)
|
|
||||||
{
|
|
||||||
tim_p->tm_sec += 60;
|
|
||||||
--tim_p->tm_min;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (tim_p->tm_min < 0 || tim_p->tm_min > 59)
|
|
||||||
{
|
|
||||||
res = div (tim_p->tm_min, 60);
|
|
||||||
tim_p->tm_hour += res.quot;
|
|
||||||
if ((tim_p->tm_min = res.rem) < 0)
|
|
||||||
{
|
|
||||||
tim_p->tm_min += 60;
|
|
||||||
--tim_p->tm_hour;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (tim_p->tm_hour < 0 || tim_p->tm_hour > 23)
|
|
||||||
{
|
|
||||||
res = div (tim_p->tm_hour, 24);
|
|
||||||
tim_p->tm_mday += res.quot;
|
|
||||||
if ((tim_p->tm_hour = res.rem) < 0)
|
|
||||||
{
|
|
||||||
tim_p->tm_hour += 24;
|
|
||||||
--tim_p->tm_mday;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (tim_p->tm_mon > 11)
|
|
||||||
{
|
|
||||||
res = div (tim_p->tm_mon, 12);
|
|
||||||
tim_p->tm_year += res.quot;
|
|
||||||
if ((tim_p->tm_mon = res.rem) < 0)
|
|
||||||
{
|
|
||||||
tim_p->tm_mon += 12;
|
|
||||||
--tim_p->tm_year;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (_DAYS_IN_YEAR (tim_p->tm_year) == 366)
|
|
||||||
days_in_feb = 29;
|
|
||||||
|
|
||||||
if (tim_p->tm_mday <= 0)
|
|
||||||
{
|
|
||||||
while (tim_p->tm_mday <= 0)
|
|
||||||
{
|
|
||||||
if (--tim_p->tm_mon == -1)
|
|
||||||
{
|
|
||||||
tim_p->tm_year--;
|
|
||||||
tim_p->tm_mon = 11;
|
|
||||||
days_in_feb =
|
|
||||||
((_DAYS_IN_YEAR (tim_p->tm_year) == 366) ?
|
|
||||||
29 : 28);
|
|
||||||
}
|
|
||||||
tim_p->tm_mday += _DAYS_IN_MONTH (tim_p->tm_mon);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
while (tim_p->tm_mday > _DAYS_IN_MONTH (tim_p->tm_mon))
|
|
||||||
{
|
|
||||||
tim_p->tm_mday -= _DAYS_IN_MONTH (tim_p->tm_mon);
|
|
||||||
if (++tim_p->tm_mon == 12)
|
|
||||||
{
|
|
||||||
tim_p->tm_year++;
|
|
||||||
tim_p->tm_mon = 0;
|
|
||||||
days_in_feb =
|
|
||||||
((_DAYS_IN_YEAR (tim_p->tm_year) == 366) ?
|
|
||||||
29 : 28);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
time_t mktime (struct tm *tim_p) // from newlib
|
|
||||||
{
|
|
||||||
time_t tim = 0;
|
|
||||||
long days = 0;
|
|
||||||
int year;
|
|
||||||
|
|
||||||
/* validate structure */
|
|
||||||
validate_structure (tim_p);
|
|
||||||
|
|
||||||
/* compute hours, minutes, seconds */
|
|
||||||
tim += tim_p->tm_sec + (tim_p->tm_min * _SEC_IN_MINUTE) +
|
|
||||||
(tim_p->tm_hour * _SEC_IN_HOUR);
|
|
||||||
|
|
||||||
/* compute days in year */
|
|
||||||
days += tim_p->tm_mday - 1;
|
|
||||||
days += _DAYS_BEFORE_MONTH[tim_p->tm_mon];
|
|
||||||
if (tim_p->tm_mon > 1 && _DAYS_IN_YEAR (tim_p->tm_year) == 366)
|
|
||||||
days++;
|
|
||||||
|
|
||||||
/* compute day of the year */
|
|
||||||
tim_p->tm_yday = days;
|
|
||||||
|
|
||||||
if (tim_p->tm_year > 10000
|
|
||||||
|| tim_p->tm_year < -10000)
|
|
||||||
{
|
|
||||||
return (time_t) -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* compute days in other years */
|
|
||||||
if (tim_p->tm_year > 70)
|
|
||||||
{
|
|
||||||
for (year = 70; year < tim_p->tm_year; year++)
|
|
||||||
days += _DAYS_IN_YEAR (year);
|
|
||||||
}
|
|
||||||
else if (tim_p->tm_year < 70)
|
|
||||||
{
|
|
||||||
for (year = 69; year > tim_p->tm_year; year--)
|
|
||||||
days -= _DAYS_IN_YEAR (year);
|
|
||||||
days -= _DAYS_IN_YEAR (year);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* compute day of the week */
|
|
||||||
if ((tim_p->tm_wday = (days + 4) % 7) < 0)
|
|
||||||
tim_p->tm_wday += 7;
|
|
||||||
|
|
||||||
/* compute total seconds */
|
|
||||||
tim += (days * _SEC_IN_DAY);
|
|
||||||
|
|
||||||
return tim;
|
|
||||||
}
|
|
||||||
|
|
||||||
#undef WINAPI
|
|
||||||
#define WINAPI __stdcall //__delcspec(dllexport)
|
|
||||||
|
|
||||||
#ifdef _MSC_VER
|
|
||||||
//#pragma warning(disable : 4273)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
static __forceinline int STRtoWSTR(LPCSTR lpMultiByteStr, int cchMultiByte,
|
|
||||||
LPWSTR lpWideCharStr, int cchWideChar)
|
|
||||||
{
|
|
||||||
return MultiByteToWideChar(CP_ACP,MB_PRECOMPOSED,lpMultiByteStr,
|
|
||||||
cchMultiByte,lpWideCharStr,cchWideChar);
|
|
||||||
}
|
|
||||||
|
|
||||||
static __forceinline int WSTRtoSTR(LPCWSTR lpWideCharStr, int cchWideChar,
|
|
||||||
LPSTR lpMultiByteStr, int cbMultiByte)
|
|
||||||
{
|
|
||||||
return WideCharToMultiByte(CP_ACP,WC_COMPOSITECHECK|WC_SEPCHARS,
|
|
||||||
lpWideCharStr,cchWideChar,lpMultiByteStr,cbMultiByte,NULL,NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
DWORD WINAPI FormatMessageA(
|
|
||||||
DWORD dwFlags,
|
|
||||||
LPCVOID lpSource,
|
|
||||||
DWORD dwMessageId,
|
|
||||||
DWORD dwLanguageId,
|
|
||||||
LPSTR lpBuffer,
|
|
||||||
DWORD nSize,
|
|
||||||
va_list *Arguments)
|
|
||||||
{
|
|
||||||
const int nSizeW = STRtoWSTR(lpBuffer,nSize,NULL,0);
|
|
||||||
int nSizeF = 0;
|
|
||||||
LPWSTR lpBufferW = alloca(sizeof (wchar_t)*nSizeW);
|
|
||||||
LPWSTR lpSourceW = NULL;
|
|
||||||
|
|
||||||
if (!lpBufferW)
|
|
||||||
{
|
|
||||||
SetLastError(ERROR_NOT_ENOUGH_MEMORY);
|
|
||||||
ZeroMemory(lpBuffer,nSize);
|
|
||||||
return nSizeF;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (dwFlags & FORMAT_MESSAGE_FROM_STRING)
|
|
||||||
{
|
|
||||||
const int sLen = STRtoWSTR(lpSource, -1, NULL, 0);
|
|
||||||
lpSourceW = alloca(sizeof (wchar_t)*sLen);
|
|
||||||
|
|
||||||
if (lpSourceW)
|
|
||||||
STRtoWSTR(lpSource, -1, lpSourceW, sLen);
|
|
||||||
else
|
|
||||||
{
|
|
||||||
SetLastError(ERROR_NOT_ENOUGH_MEMORY);
|
|
||||||
return nSizeF;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (lpSourceW)
|
|
||||||
nSizeF = FormatMessageW(dwFlags, lpSourceW, dwMessageId, dwLanguageId,
|
|
||||||
lpBufferW, nSizeW, Arguments);
|
|
||||||
else
|
|
||||||
nSizeF = FormatMessageW(dwFlags, lpSource, dwMessageId, dwLanguageId,
|
|
||||||
lpBufferW, nSizeW, Arguments);
|
|
||||||
|
|
||||||
return WSTRtoSTR(lpBufferW, nSizeF, lpBuffer, nSize);
|
|
||||||
}
|
|
||||||
|
|
||||||
BOOL WINAPI DeleteFileA(
|
|
||||||
LPCSTR lpFileName)
|
|
||||||
{
|
|
||||||
const int sLen = STRtoWSTR(lpFileName, -1, NULL, 0);
|
|
||||||
LPWSTR lpFileNameW = alloca(sizeof (wchar_t)*sLen);
|
|
||||||
|
|
||||||
if (lpFileNameW)
|
|
||||||
STRtoWSTR(lpFileName, -1, lpFileNameW, sLen);
|
|
||||||
else
|
|
||||||
{
|
|
||||||
SetLastError(ERROR_NOT_ENOUGH_MEMORY);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
return DeleteFileW(lpFileNameW);
|
|
||||||
}
|
|
||||||
|
|
||||||
BOOL WINAPI MoveFileA(
|
|
||||||
LPCSTR lpExistingFileName,
|
|
||||||
LPCSTR lpNewFileName
|
|
||||||
)
|
|
||||||
{
|
|
||||||
const int sLen1 = STRtoWSTR(lpExistingFileName, -1, NULL, 0);
|
|
||||||
LPWSTR lpExistingFileNameW = alloca(sizeof (wchar_t)*sLen1);
|
|
||||||
|
|
||||||
const int sLen2 = STRtoWSTR(lpNewFileName, -1, NULL, 0);
|
|
||||||
LPWSTR lpNewFileNameW = alloca(sizeof (wchar_t)*sLen2);
|
|
||||||
|
|
||||||
|
|
||||||
if (!lpExistingFileNameW || !lpNewFileNameW)
|
|
||||||
{
|
|
||||||
SetLastError(ERROR_NOT_ENOUGH_MEMORY);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
STRtoWSTR(lpExistingFileName, -1, lpExistingFileNameW, sLen1);
|
|
||||||
STRtoWSTR(lpNewFileName, -1, lpNewFileNameW, sLen2);
|
|
||||||
|
|
||||||
return MoveFileW(lpExistingFileNameW, lpNewFileNameW);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
HANDLE WINAPI CreateFileA(
|
|
||||||
LPCSTR lpFileName,
|
|
||||||
DWORD dwDesiredAccess,
|
|
||||||
DWORD dwShareMode,
|
|
||||||
LPSECURITY_ATTRIBUTES lpSecurityAttributes,
|
|
||||||
DWORD dwCreationDisposition,
|
|
||||||
DWORD dwFlagsAndAttributes,
|
|
||||||
HANDLE hTemplateFile)
|
|
||||||
{
|
|
||||||
const int sLen = STRtoWSTR(lpFileName, -1, NULL, 0);
|
|
||||||
LPWSTR lpFileNameW = alloca(sizeof (wchar_t)*sLen);
|
|
||||||
|
|
||||||
if (lpFileNameW)
|
|
||||||
STRtoWSTR(lpFileName, -1, lpFileNameW, sLen);
|
|
||||||
else
|
|
||||||
{
|
|
||||||
SetLastError(ERROR_NOT_ENOUGH_MEMORY);
|
|
||||||
return INVALID_HANDLE_VALUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
return CreateFileW(lpFileNameW, dwDesiredAccess, dwShareMode,
|
|
||||||
lpSecurityAttributes, dwCreationDisposition, dwFlagsAndAttributes,
|
|
||||||
hTemplateFile);
|
|
||||||
}
|
|
||||||
|
|
||||||
BOOL WINAPI CreateDirectoryA(
|
|
||||||
LPCSTR lpPathName,
|
|
||||||
LPSECURITY_ATTRIBUTES lpSecurityAttributes)
|
|
||||||
{
|
|
||||||
const int sLen = STRtoWSTR(lpPathName, -1, NULL, 0);
|
|
||||||
LPWSTR lpPathNameW = alloca(sizeof (wchar_t)*sLen);
|
|
||||||
|
|
||||||
if (lpPathNameW)
|
|
||||||
STRtoWSTR(lpPathName, -1, lpPathNameW, sLen);
|
|
||||||
else
|
|
||||||
{
|
|
||||||
SetLastError(ERROR_NOT_ENOUGH_MEMORY);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
return CreateDirectoryW(lpPathNameW, lpSecurityAttributes);
|
|
||||||
}
|
|
||||||
|
|
||||||
int WINAPI MessageBoxA(
|
|
||||||
HWND hWnd ,
|
|
||||||
LPCSTR lpText,
|
|
||||||
LPCSTR lpCaption,
|
|
||||||
UINT uType)
|
|
||||||
{
|
|
||||||
const int sLen1 = STRtoWSTR(lpText, -1, NULL, 0);
|
|
||||||
LPWSTR lpTextW = alloca(sizeof (wchar_t)*sLen1);
|
|
||||||
|
|
||||||
const int sLen2 = STRtoWSTR(lpCaption, -1, NULL, 0);
|
|
||||||
LPWSTR lpCaptionW = alloca(sizeof (wchar_t)*sLen2);
|
|
||||||
|
|
||||||
|
|
||||||
if (!lpTextW || !lpCaptionW)
|
|
||||||
{
|
|
||||||
SetLastError(ERROR_NOT_ENOUGH_MEMORY);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
STRtoWSTR(lpText, -1, lpTextW, sLen1);
|
|
||||||
STRtoWSTR(lpCaption, -1, lpCaptionW, sLen2);
|
|
||||||
|
|
||||||
return MessageBoxW(hWnd, lpTextW, lpCaptionW, uType);
|
|
||||||
}
|
|
||||||
|
|
||||||
VOID WINAPI OutputDebugStringA(
|
|
||||||
LPCSTR lpOutputString)
|
|
||||||
{
|
|
||||||
const int sLen = STRtoWSTR(lpOutputString, -1, NULL, 0);
|
|
||||||
LPWSTR lpOutputStringW = alloca(sizeof (wchar_t)*sLen);
|
|
||||||
|
|
||||||
if (lpOutputStringW)
|
|
||||||
STRtoWSTR(lpOutputString, -1, lpOutputStringW, sLen);
|
|
||||||
else
|
|
||||||
{
|
|
||||||
SetLastError(ERROR_NOT_ENOUGH_MEMORY);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
OutputDebugStringW(lpOutputStringW);
|
|
||||||
}
|
|
||||||
|
|
|
@ -1,63 +0,0 @@
|
||||||
// Emacs style mode select -*- C++ -*-
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
//
|
|
||||||
// Copyright (C) 2004 by Sonic Team Jr.
|
|
||||||
//
|
|
||||||
// This program 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.
|
|
||||||
//
|
|
||||||
// DESCRIPTION:
|
|
||||||
// stub and replacement "ANSI" C functions for use under Windows CE
|
|
||||||
//
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
|
|
||||||
#ifndef __I_WINCE__
|
|
||||||
#define __I_WINCE__
|
|
||||||
|
|
||||||
#ifdef USEASMCE
|
|
||||||
#define USEASM // Remline if NASM doesn't work on x86 targets
|
|
||||||
#endif
|
|
||||||
|
|
||||||
char *strerror(int ecode);
|
|
||||||
int access(const char *path, int amode);
|
|
||||||
int unlink( const char *filename );
|
|
||||||
int remove( const char *path );
|
|
||||||
int rename( const char *oldname, const char *newname );
|
|
||||||
//CreateDirectoryEx( const char *currectpath, const char *path,SECURITY_ATTRIBUTES)
|
|
||||||
|
|
||||||
#ifndef _TIME_T_DEFINED
|
|
||||||
typedef long time_t; /* time value */
|
|
||||||
#define _TIME_T_DEFINED /* avoid multiple def's of time_t */
|
|
||||||
#endif
|
|
||||||
|
|
||||||
time_t time(time_t *T);
|
|
||||||
|
|
||||||
#ifndef __GNUC__
|
|
||||||
#ifndef _TM_DEFINED
|
|
||||||
struct tm {
|
|
||||||
int tm_sec; /* seconds after the minute - [0,59] */
|
|
||||||
int tm_min; /* minutes after the hour - [0,59] */
|
|
||||||
int tm_hour; /* hours since midnight - [0,23] */
|
|
||||||
int tm_mday; /* day of the month - [1,31] */
|
|
||||||
int tm_mon; /* months since January - [0,11] */
|
|
||||||
int tm_year; /* years since 1900 */
|
|
||||||
int tm_wday; /* days since Sunday - [0,6] */
|
|
||||||
int tm_yday; /* days since January 1 - [0,365] */
|
|
||||||
int tm_isdst; /* daylight savings time flag */
|
|
||||||
};
|
|
||||||
#define _TM_DEFINED
|
|
||||||
#endif
|
|
||||||
|
|
||||||
struct tm * localtime(const time_t *CLOCK);
|
|
||||||
|
|
||||||
time_t mktime (struct tm *tim_p);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif
|
|
1
src/sdl/SRB2DC/.gitignore
vendored
1
src/sdl/SRB2DC/.gitignore
vendored
|
@ -1 +0,0 @@
|
||||||
/scramble
|
|
Binary file not shown.
|
@ -1,53 +0,0 @@
|
||||||
#
|
|
||||||
# Makefile.cfg for SRB2/Dreamcast
|
|
||||||
#
|
|
||||||
|
|
||||||
#include $(KOS_BASE)/Makefile.rules
|
|
||||||
|
|
||||||
#
|
|
||||||
#hmmm, the Dreamcast
|
|
||||||
#
|
|
||||||
|
|
||||||
HOSTCC:=$(CC)
|
|
||||||
CC=$(KOS_CC)
|
|
||||||
PREFIX=$(KOS_CC_BASE)/bin/$(KOS_CC_PREFIX)
|
|
||||||
OBJDUMP=$(PREFIX)-objdump
|
|
||||||
OBJCOPY=$(PREFIX)-objcopy
|
|
||||||
|
|
||||||
#NOHW=1 #No working MiniGL right now
|
|
||||||
NOHS=1 #No HWSound right now
|
|
||||||
ifndef LWIP
|
|
||||||
NONET=1 #No LWIP
|
|
||||||
endif
|
|
||||||
#i_net_o=$(OBJDIR)/i_udp.o #use KOS's UDP
|
|
||||||
#NOMIXER=1 #Basic sound only
|
|
||||||
NOIPX=1 #No IPX network code
|
|
||||||
NOPNG=1 #No Screenshot
|
|
||||||
|
|
||||||
OPTS=$(KOS_CFLAGS) -DUNIXCOMMON -DDC
|
|
||||||
ifndef NOHW
|
|
||||||
OPTS+=-DSTATIC_OPENGL -DMINI_GL_COMPATIBILITY -DKOS_GL_COMPATIBILITY
|
|
||||||
endif
|
|
||||||
SDL_CFLAGS?=-I$(KOS_BASE)/addons/include/SDL
|
|
||||||
SDL_LDFLAGS?=-lSDL
|
|
||||||
LDFLAGS=$(KOS_LDFLAGS)
|
|
||||||
LIBS:=$(KOS_LIBS) -lconio -lm
|
|
||||||
ifndef NOMIXER
|
|
||||||
LIBS:=-loggvorbisplay -lSDL $(LIBS)
|
|
||||||
endif
|
|
||||||
|
|
||||||
ifdef LWIP
|
|
||||||
OPTS+=-I$(KOS_BASE)/../kos-ports/lwip/kos/include -I$(KOS_BASE)/../kos-ports/lwip/lwip/src/include/ipv4 -I$(KOS_BASE)/../kos-ports/lwip/lwip/src/include -DIPv4
|
|
||||||
LIBS:=-llwip4 -lkosutils $(LIBS)
|
|
||||||
OPTS+=-DHAVE_LWIP
|
|
||||||
endif
|
|
||||||
ifndef NOHW
|
|
||||||
LIBS+=-lgl
|
|
||||||
endif
|
|
||||||
|
|
||||||
i_system_o+=$(OBJDIR)/dchelp.o
|
|
||||||
i_main_o=$(KOS_START) $(OBJDIR)/i_main.o $(OBJEXTRA)
|
|
||||||
|
|
||||||
# name of the exefile
|
|
||||||
EXENAME?=SRB2.elf
|
|
||||||
BINNAME?=SRB2.BIN
|
|
Binary file not shown.
|
@ -1,19 +0,0 @@
|
||||||
#define VMU_width 48
|
|
||||||
#define VMU_height 32
|
|
||||||
static unsigned char VMU_bits[] = {
|
|
||||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
||||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe0, 0x0f, 0x00, 0x00,
|
|
||||||
0x00, 0x00, 0x58, 0x75, 0x00, 0x00, 0x00, 0x00, 0xee, 0xaa, 0x00, 0x00,
|
|
||||||
0x00, 0x86, 0x55, 0x55, 0x01, 0x00, 0x00, 0xda, 0xc8, 0xaf, 0x00, 0x00,
|
|
||||||
0x00, 0x62, 0x55, 0x54, 0x00, 0x00, 0x00, 0x32, 0xa2, 0x6c, 0x00, 0x00,
|
|
||||||
0x00, 0x5c, 0x55, 0xfd, 0x01, 0x00, 0x00, 0xac, 0x88, 0xaa, 0x02, 0x00,
|
|
||||||
0x00, 0x54, 0x75, 0x55, 0x05, 0x00, 0x00, 0xac, 0xbf, 0xaa, 0x0a, 0x00,
|
|
||||||
0x00, 0xd6, 0x61, 0x55, 0x15, 0x00, 0x00, 0xe9, 0xc0, 0xaa, 0x2a, 0x00,
|
|
||||||
0x00, 0x39, 0x40, 0x55, 0x55, 0x00, 0x00, 0x6d, 0xc0, 0xaa, 0xbe, 0x00,
|
|
||||||
0x00, 0x6d, 0x40, 0xd5, 0xc3, 0x00, 0x00, 0x6d, 0xc0, 0xea, 0x00, 0x00,
|
|
||||||
0x00, 0x29, 0x60, 0xf5, 0x00, 0x00, 0x00, 0x26, 0xe0, 0xfa, 0x00, 0x00,
|
|
||||||
0x00, 0x58, 0xb8, 0xbd, 0x00, 0x00, 0x00, 0x84, 0x07, 0xdf, 0x00, 0x00,
|
|
||||||
0x00, 0x08, 0x20, 0xae, 0x00, 0x00, 0x00, 0x30, 0xc0, 0x5f, 0x01, 0x00,
|
|
||||||
0x00, 0xc0, 0x3f, 0xb8, 0x01, 0x00, 0x00, 0x00, 0x00, 0xc0, 0x01, 0x00,
|
|
||||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
||||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
|
|
|
@ -1,134 +0,0 @@
|
||||||
// Emacs style mode select -*- C++ -*-
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
//
|
|
||||||
// Copyright (C) 2006 by Sonic Team Jr.
|
|
||||||
//
|
|
||||||
// This program 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.
|
|
||||||
//
|
|
||||||
// DESCRIPTION:
|
|
||||||
// stub and replacement "ANSI" C functions for use on Dreamcast/KOS
|
|
||||||
//
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
#include <kos/fs.h>
|
|
||||||
#include <errno.h>
|
|
||||||
#ifndef HAVE_LWIP
|
|
||||||
#include <sys/socket.h>
|
|
||||||
#endif
|
|
||||||
#include "../../doomdef.h"
|
|
||||||
#include "dchelp.h"
|
|
||||||
|
|
||||||
int access(const char *path, int amode)
|
|
||||||
{
|
|
||||||
file_t handle = FILEHND_INVALID;
|
|
||||||
|
|
||||||
if (amode == F_OK || amode == R_OK)
|
|
||||||
handle=fs_open(path,O_RDONLY);
|
|
||||||
else if (amode == (R_OK|W_OK))
|
|
||||||
handle=fs_open(path,O_RDWR);
|
|
||||||
else if (amode == W_OK)
|
|
||||||
handle=fs_open(path,O_WRONLY);
|
|
||||||
|
|
||||||
if (handle != FILEHND_INVALID)
|
|
||||||
{
|
|
||||||
fs_close(handle);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
double hypot(double x, double y)
|
|
||||||
{
|
|
||||||
double ax, yx, yx2, yx1;
|
|
||||||
if (abs(y) > abs(x)) // |y|>|x|
|
|
||||||
{
|
|
||||||
ax = abs(y); // |y| => ax
|
|
||||||
yx = (x/y);
|
|
||||||
}
|
|
||||||
else // |x|>|y|
|
|
||||||
{
|
|
||||||
ax = abs(x); // |x| => ax
|
|
||||||
yx = (x/y);
|
|
||||||
}
|
|
||||||
yx2 = yx*yx; // (x/y)^2
|
|
||||||
yx1 = sqrt(1+yx2); // (1 + (x/y)^2)^1/2
|
|
||||||
return ax*yx1; // |x|*((1 + (x/y)^2)^1/2)
|
|
||||||
}
|
|
||||||
|
|
||||||
#if !(defined (NONET) || defined (NOMD5))
|
|
||||||
#ifdef HAVE_LWIP
|
|
||||||
|
|
||||||
#include <lwip/lwip.h>
|
|
||||||
|
|
||||||
static uint8 ip[4];
|
|
||||||
static char *h_addr_listtmp[2] = {ip, NULL};
|
|
||||||
static struct hostent hostenttmp = {NULL, NULL, 0, 1, h_addr_listtmp};
|
|
||||||
|
|
||||||
struct hostent *gethostbyname(const char *name)
|
|
||||||
{
|
|
||||||
struct sockaddr_in dnssrv;
|
|
||||||
dnssrv.sin_family = AF_INET;
|
|
||||||
dnssrv.sin_port = htons(53);
|
|
||||||
dnssrv.sin_addr.s_addr = htonl(0x0a030202); ///< what?
|
|
||||||
if (lwip_gethostbyname(&dnssrv, name, ip) < 0)
|
|
||||||
return NULL;
|
|
||||||
else
|
|
||||||
return &hostenttmp;
|
|
||||||
}
|
|
||||||
#else
|
|
||||||
|
|
||||||
struct hostent *gethostbyname(const char *name)
|
|
||||||
{
|
|
||||||
(void)name;
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
int ioctl(int s, long cmd, void *argp)
|
|
||||||
{
|
|
||||||
return fs_ioctl(s, argp, cmd); //FIONBIO?
|
|
||||||
}
|
|
||||||
|
|
||||||
int select(int maxfdp1, void *readset, void *writeset, void *exceptset,
|
|
||||||
void *timeout)
|
|
||||||
{
|
|
||||||
(void)maxfdp1;
|
|
||||||
(void)readset;
|
|
||||||
(void)writeset;
|
|
||||||
(void)exceptset;
|
|
||||||
(void)timeout;
|
|
||||||
errno = EAFNOSUPPORT;
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
int getsockopt (int s, int level, int optname, void *optval, socklen_t *optlen)
|
|
||||||
{
|
|
||||||
(void)s;
|
|
||||||
(void)level; //SOL_SOCKET
|
|
||||||
(void)optname; //SO_RCVBUF, SO_ERROR
|
|
||||||
(void)optval;
|
|
||||||
(void)optlen;
|
|
||||||
errno = EAFNOSUPPORT;
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
int setsockopt (int s, int level, int optname, void *optval, socklen_t optlen)
|
|
||||||
{
|
|
||||||
(void)s;
|
|
||||||
(void)level; //SOL_SOCKET
|
|
||||||
(void)optname; //SO_REUSEADDR, SO_BROADCAST, SO_RCVBUF
|
|
||||||
(void)optval;
|
|
||||||
(void)optlen;
|
|
||||||
errno = EAFNOSUPPORT;
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
||||||
#endif
|
|
|
@ -1,51 +0,0 @@
|
||||||
// Emacs style mode select -*- C++ -*-
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
//
|
|
||||||
// Copyright (C) 2006 by Sonic Team Jr.
|
|
||||||
//
|
|
||||||
// This program 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.
|
|
||||||
//
|
|
||||||
// DESCRIPTION:
|
|
||||||
// stub and replacement "ANSI" C functions for use on Dreamcast/KOS
|
|
||||||
//
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
|
|
||||||
#ifndef __I_DREAMCAST__
|
|
||||||
#define __I_DREAMCAST__
|
|
||||||
|
|
||||||
struct hostent
|
|
||||||
{
|
|
||||||
char *h_name; /* Official name of host. */
|
|
||||||
char **h_aliases; /* Alias list. */
|
|
||||||
int h_addrtype; /* Host address type. */
|
|
||||||
int h_length; /* Length of address. */
|
|
||||||
char **h_addr_list; /* List of addresses from name server. */
|
|
||||||
#define h_addr h_addr_list[0] /* Address, for backward compatibility. */
|
|
||||||
};
|
|
||||||
|
|
||||||
struct hostent *gethostbyname(const char *name);
|
|
||||||
|
|
||||||
#ifndef HAVE_LWIP
|
|
||||||
#define INADDR_NONE ((uint32) 0xffffffff)
|
|
||||||
#define INADDR_LOOPBACK ((uint32) 0x7f000001)
|
|
||||||
#define SOCK_STREAM 1
|
|
||||||
#define FIONBIO 0
|
|
||||||
#define SOL_SOCKET 0
|
|
||||||
#define SO_ERROR 0
|
|
||||||
#define SO_REUSEADDR 0
|
|
||||||
#define SO_BROADCAST 0
|
|
||||||
#define SO_RCVBUF 0
|
|
||||||
int ioctl(int s, long cmd, void *argp);
|
|
||||||
int select(int maxfdp1, void *readset, void *writeset, void *exceptset, void *timeout);
|
|
||||||
int getsockopt(int s, int level, int optname, void *optval, socklen_t *optlen);
|
|
||||||
int setsockopt(int s, int level, int optname, void *optval, socklen_t optlen);
|
|
||||||
#endif
|
|
||||||
#endif
|
|
|
@ -1,455 +0,0 @@
|
||||||
// Emacs style mode select -*- C++ -*-
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
// Copyright (C) 1993-1996 by id Software, Inc.
|
|
||||||
// Portions Copyright (C) 2005 by Sonic Team Jr.
|
|
||||||
//
|
|
||||||
// This program 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.
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
/// \file
|
|
||||||
/// \brief KOS UDP network interface
|
|
||||||
|
|
||||||
#include "../../doomdef.h"
|
|
||||||
|
|
||||||
#include "../../i_system.h"
|
|
||||||
#include "../../d_event.h"
|
|
||||||
#include "../../d_net.h"
|
|
||||||
#include "../../m_argv.h"
|
|
||||||
|
|
||||||
#include "../../doomstat.h"
|
|
||||||
|
|
||||||
#include "../../i_net.h"
|
|
||||||
|
|
||||||
#include "../../z_zone.h"
|
|
||||||
|
|
||||||
#include "../../i_tcp.h"
|
|
||||||
|
|
||||||
#include <kos/net.h>
|
|
||||||
//#include <net/net_ipv4.h>
|
|
||||||
#define NET_NONE 0x00000000
|
|
||||||
#define NET_LOCAL 0x0100007F
|
|
||||||
#define NET_ANY 0xFFFFFFFF
|
|
||||||
|
|
||||||
#define MAXBANS 20
|
|
||||||
|
|
||||||
typedef struct
|
|
||||||
{
|
|
||||||
uint32 host;
|
|
||||||
uint16 port;
|
|
||||||
} IPaddress;
|
|
||||||
|
|
||||||
static IPaddress clientaddress[MAXNETNODES+1];
|
|
||||||
static boolean nodeconnected[MAXNETNODES+1];
|
|
||||||
|
|
||||||
static int mysocket = 0;
|
|
||||||
static boolean init_KOSUDP_driver = false;
|
|
||||||
|
|
||||||
static size_t numbans = 0;
|
|
||||||
static IPaddress banned[MAXBANS];
|
|
||||||
static boolean KOSUDP_bannednode[MAXNETNODES+1]; /// \note do we really need the +1?
|
|
||||||
|
|
||||||
static inline int net_udp_sendto(int sock, const uint8 *data, int size, uint16 rem_port, uint32 rem_addr)
|
|
||||||
{
|
|
||||||
uint8 dst_ip[4] = {((uint8*)(&(rem_addr)))[0],
|
|
||||||
((uint8*)(&(rem_addr)))[1],
|
|
||||||
((uint8*)(&(rem_addr)))[2],
|
|
||||||
((uint8*)(&(rem_addr)))[3]};
|
|
||||||
return net_udp_send_raw(net_default_dev, clientaddress[0].port, rem_port, dst_ip, data, size);
|
|
||||||
(void)sock;
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline int net_udp_recvfrom(int sock, uint8 *buf, int size, uint16 *rem_port, uint32 *rem_addr)
|
|
||||||
{
|
|
||||||
return net_udp_recv(sock, buf, size);
|
|
||||||
(void)rem_port;
|
|
||||||
(void)rem_addr;
|
|
||||||
}
|
|
||||||
|
|
||||||
static const char *KOSUDP_AddrToStr(IPaddress* sk)
|
|
||||||
{
|
|
||||||
static char s[22]; // 255.255.255.255:65535
|
|
||||||
sprintf(s,"%d.%d.%d.%d:%d",
|
|
||||||
((uint8*)(&(sk->host)))[3],
|
|
||||||
((uint8*)(&(sk->host)))[2],
|
|
||||||
((uint8*)(&(sk->host)))[1],
|
|
||||||
((uint8*)(&(sk->host)))[0],
|
|
||||||
net_ntohs(sk->port));
|
|
||||||
return s;
|
|
||||||
}
|
|
||||||
|
|
||||||
static const char *KOSUDP_GetNodeAddress(int node)
|
|
||||||
{
|
|
||||||
if (!nodeconnected[node])
|
|
||||||
return NULL;
|
|
||||||
return KOSUDP_AddrToStr(&clientaddress[node]);
|
|
||||||
}
|
|
||||||
|
|
||||||
static const char *KOSUDP_GetBanAddress(size_t ban)
|
|
||||||
{
|
|
||||||
if (ban > numbans)
|
|
||||||
return NULL;
|
|
||||||
return KOSUDP_AddrToStr(&banned[ban]);
|
|
||||||
}
|
|
||||||
|
|
||||||
static boolean KOSUDP_cmpaddr(IPaddress* a, IPaddress* b)
|
|
||||||
{
|
|
||||||
return (a->host == b->host && (b->port == 0 || a->port == b->port));
|
|
||||||
}
|
|
||||||
|
|
||||||
static SINT8 getfreenode(void)
|
|
||||||
{
|
|
||||||
SINT8 j;
|
|
||||||
|
|
||||||
for (j = 0; j < MAXNETNODES; j++)
|
|
||||||
if (!nodeconnected[j])
|
|
||||||
{
|
|
||||||
nodeconnected[j] = true;
|
|
||||||
return j;
|
|
||||||
}
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void KOSUDP_Get(void)
|
|
||||||
{
|
|
||||||
int size;
|
|
||||||
size_t i;
|
|
||||||
SINT8 j;
|
|
||||||
IPaddress temp = {clientaddress[BROADCASTADDR].host,clientaddress[BROADCASTADDR].port};
|
|
||||||
|
|
||||||
size = net_udp_recvfrom(mysocket,(char *)&doomcom->data, MAXPACKETLENGTH, &temp.port, &temp.host);
|
|
||||||
if (size == 0)
|
|
||||||
{
|
|
||||||
doomcom->remotenode = -1; // no packet
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// find remote node number
|
|
||||||
for (i = 0; i < MAXNETNODES; i++)
|
|
||||||
if (KOSUDP_cmpaddr(&temp, &(clientaddress[i])))
|
|
||||||
{
|
|
||||||
doomcom->remotenode = (INT16)i; // good packet from a game player
|
|
||||||
doomcom->datalength = (INT16)size;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// not found
|
|
||||||
|
|
||||||
// find a free slot
|
|
||||||
j = getfreenode();
|
|
||||||
if (j > 0)
|
|
||||||
{
|
|
||||||
M_Memcpy(&clientaddress[j], &temp, sizeof (temp));
|
|
||||||
DEBFILE(va("New node detected: node:%d address:%s\n", j,
|
|
||||||
KOSUDP_GetNodeAddress(j)));
|
|
||||||
doomcom->remotenode = (INT16)j; // good packet from a game player
|
|
||||||
doomcom->datalength = (INT16)size;
|
|
||||||
// check if it's a banned dude so we can send a refusal later
|
|
||||||
for (i = 0; i < numbans; i++)
|
|
||||||
if (KOSUDP_cmpaddr(&temp, &banned[i]))
|
|
||||||
{
|
|
||||||
KOSUDP_bannednode[j] = true;
|
|
||||||
DEBFILE("This dude has been banned\n");
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
if (i == numbans)
|
|
||||||
KOSUDP_bannednode[j] = false;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
DEBFILE("New node detected: No more free slots\n");
|
|
||||||
doomcom->remotenode = -1; // no packet
|
|
||||||
}
|
|
||||||
|
|
||||||
#if 0
|
|
||||||
static boolean KOSUDP_CanSend(void)
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
static void KOSUDP_Send(void)
|
|
||||||
{
|
|
||||||
const IPaddress *nodeinfo;
|
|
||||||
|
|
||||||
if (!doomcom->remotenode || !nodeconnected[doomcom->remotenode])
|
|
||||||
return;
|
|
||||||
|
|
||||||
nodeinfo = clientaddress + doomcom->remotenode;
|
|
||||||
|
|
||||||
if (net_udp_sendto(mysocket, (char *)&doomcom->data, doomcom->datalength, nodeinfo->port, nodeinfo->host) == -1)
|
|
||||||
{
|
|
||||||
CONS_Printf("KOSUDP: error sending data\n");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static void KOSUDP_FreeNodenum(int numnode)
|
|
||||||
{
|
|
||||||
// can't disconnect from self :)
|
|
||||||
if (!numnode)
|
|
||||||
return;
|
|
||||||
|
|
||||||
DEBFILE(va("Free node %d (%s)\n", numnode, KOSUDP_GetNodeAddress(numnode)));
|
|
||||||
|
|
||||||
nodeconnected[numnode] = false;
|
|
||||||
|
|
||||||
memset(&clientaddress[numnode], 0, sizeof (IPaddress));
|
|
||||||
}
|
|
||||||
|
|
||||||
static int KOSUDP_Socket(void)
|
|
||||||
{
|
|
||||||
int temp = 0;
|
|
||||||
uint16 portnum = 0;
|
|
||||||
const uint32 hostip = net_default_dev?net_ntohl(net_ipv4_address(net_default_dev->ip_addr)):NET_LOCAL;
|
|
||||||
//Hurdler: I'd like to put a server and a client on the same computer
|
|
||||||
//Logan: Me too
|
|
||||||
//BP: in fact for client we can use any free port we want i have read
|
|
||||||
// in some doc that connect in udp can do it for us...
|
|
||||||
//Alam: where?
|
|
||||||
if (M_CheckParm("-clientport"))
|
|
||||||
{
|
|
||||||
if (!M_IsNextParm())
|
|
||||||
I_Error("syntax: -clientport <portnum>");
|
|
||||||
portnum = net_ntohs(atoi(M_GetNextParm()));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
portnum = net_ntohs(sock_port);
|
|
||||||
|
|
||||||
temp = net_udp_sock_open(portnum, hostip, portnum, NET_NONE);
|
|
||||||
if (temp)
|
|
||||||
{
|
|
||||||
int btemp = net_udp_sock_open(portnum, hostip, portnum, NET_ANY);
|
|
||||||
clientaddress[0].port = portnum;
|
|
||||||
clientaddress[0].host = NET_NONE;
|
|
||||||
if (btemp)
|
|
||||||
{
|
|
||||||
clientaddress[BROADCASTADDR].port = net_ntohs(sock_port);
|
|
||||||
clientaddress[BROADCASTADDR].host = NET_ANY;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
CONS_Printf("KOSUDP: can't setup broadcast sock\n");
|
|
||||||
net_udp_sock_close(temp);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
CONS_Printf("KOSUDP: can't setup main sock\n");
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
doomcom->extratics = 1; // internet is very high ping
|
|
||||||
|
|
||||||
return temp;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void I_ShutdownKOSUDPDriver(void)
|
|
||||||
{
|
|
||||||
//net_shutdown();
|
|
||||||
init_KOSUDP_driver = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void I_InitKOSUDPDriver(void)
|
|
||||||
{
|
|
||||||
if (init_KOSUDP_driver)
|
|
||||||
I_ShutdownKOSUDPDriver();
|
|
||||||
else
|
|
||||||
net_init();
|
|
||||||
D_SetDoomcom();
|
|
||||||
memset(&clientaddress,0,sizeof (clientaddress));
|
|
||||||
init_KOSUDP_driver = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void KOSUDP_CloseSocket(void)
|
|
||||||
{
|
|
||||||
if (mysocket)
|
|
||||||
net_udp_sock_close(mysocket);
|
|
||||||
mysocket = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static SINT8 KOSUDP_NetMakeNodewPort(const char *hostname, const char* port)
|
|
||||||
{
|
|
||||||
SINT8 newnode;
|
|
||||||
uint16 portnum = net_ntohs(sock_port);
|
|
||||||
|
|
||||||
if (port && !port[0])
|
|
||||||
portnum = net_ntohs((UINT16)atoi(port));
|
|
||||||
|
|
||||||
newnode = getfreenode();
|
|
||||||
if (newnode == -1)
|
|
||||||
return -1;
|
|
||||||
// find ip of the server
|
|
||||||
clientaddress[newnode].port = portnum;
|
|
||||||
clientaddress[newnode].host = inet_addr(hostname);
|
|
||||||
|
|
||||||
if (clientaddress[newnode].host == NET_NONE)
|
|
||||||
{
|
|
||||||
free(hostname);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
return newnode;
|
|
||||||
}
|
|
||||||
|
|
||||||
static boolean KOSUDP_OpenSocket(void)
|
|
||||||
{
|
|
||||||
size_t i;
|
|
||||||
|
|
||||||
memset(clientaddress, 0, sizeof (clientaddress));
|
|
||||||
|
|
||||||
for (i = 0; i < MAXNETNODES; i++)
|
|
||||||
nodeconnected[i] = false;
|
|
||||||
|
|
||||||
//CONS_Printf("KOSUDP Code starting up\n");
|
|
||||||
|
|
||||||
nodeconnected[0] = true; // always connected to self
|
|
||||||
nodeconnected[BROADCASTADDR] = true;
|
|
||||||
I_NetSend = KOSUDP_Send;
|
|
||||||
I_NetGet = KOSUDP_Get;
|
|
||||||
I_NetCloseSocket = KOSUDP_CloseSocket;
|
|
||||||
I_NetFreeNodenum = KOSUDP_FreeNodenum;
|
|
||||||
I_NetMakeNodewPort = KOSUDP_NetMakeNodewPort;
|
|
||||||
|
|
||||||
//I_NetCanSend = KOSUDP_CanSend;
|
|
||||||
|
|
||||||
// build the socket but close it first
|
|
||||||
KOSUDP_CloseSocket();
|
|
||||||
mysocket = KOSUDP_Socket();
|
|
||||||
|
|
||||||
if (mysocket)
|
|
||||||
{
|
|
||||||
#if 0
|
|
||||||
// for select
|
|
||||||
myset = SDLNet_AllocSocketSet(1);
|
|
||||||
if (!myset)
|
|
||||||
{
|
|
||||||
CONS_Printf("SDL_Net: %s",SDLNet_GetError());
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (SDLNet_UDP_AddSocket(myset,mysocket) == -1)
|
|
||||||
{
|
|
||||||
CONS_Printf("SDL_Net: %s",SDLNet_GetError());
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
static boolean KOSUDP_Ban(int node)
|
|
||||||
{
|
|
||||||
if (numbans == MAXBANS)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
M_Memcpy(&banned[numbans], &clientaddress[node], sizeof (IPaddress));
|
|
||||||
banned[numbans].port = 0'
|
|
||||||
numbans++;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void KOSUDP_ClearBans(void)
|
|
||||||
{
|
|
||||||
numbans = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// I_InitNetwork
|
|
||||||
// Only required for DOS, so this is more a dummy
|
|
||||||
//
|
|
||||||
boolean I_InitNetwork(void)
|
|
||||||
{
|
|
||||||
char serverhostname[255];
|
|
||||||
boolean ret = false;
|
|
||||||
//if (!M_CheckParm ("-kosnet"))
|
|
||||||
// return false;
|
|
||||||
// initilize the driver
|
|
||||||
I_InitKOSUDPDriver();
|
|
||||||
I_AddExitFunc(I_ShutdownKOSUDPDriver);
|
|
||||||
if (!init_KOSUDP_driver)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
if (M_CheckParm("-udpport"))
|
|
||||||
{
|
|
||||||
if (M_IsNextParm())
|
|
||||||
sock_port = (UINT16)atoi(M_GetNextParm());
|
|
||||||
else
|
|
||||||
sock_port = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
// parse network game options,
|
|
||||||
if (M_CheckParm("-server") || dedicated)
|
|
||||||
{
|
|
||||||
server = true;
|
|
||||||
|
|
||||||
// If a number of clients (i.e. nodes) is specified, the server will wait for the clients
|
|
||||||
// to connect before starting.
|
|
||||||
// If no number is specified here, the server starts with 1 client, and others can join
|
|
||||||
// in-game.
|
|
||||||
// Since Boris has implemented join in-game, there is no actual need for specifying a
|
|
||||||
// particular number here.
|
|
||||||
// FIXME: for dedicated server, numnodes needs to be set to 0 upon start
|
|
||||||
/* if (M_IsNextParm())
|
|
||||||
doomcom->numnodes = (INT16)atoi(M_GetNextParm());
|
|
||||||
else */if (dedicated)
|
|
||||||
doomcom->numnodes = 0;
|
|
||||||
else
|
|
||||||
doomcom->numnodes = 1;
|
|
||||||
|
|
||||||
if (doomcom->numnodes < 0)
|
|
||||||
doomcom->numnodes = 0;
|
|
||||||
if (doomcom->numnodes > MAXNETNODES)
|
|
||||||
doomcom->numnodes = MAXNETNODES;
|
|
||||||
|
|
||||||
// server
|
|
||||||
servernode = 0;
|
|
||||||
// FIXME:
|
|
||||||
// ??? and now ?
|
|
||||||
// server on a big modem ??? 4*isdn
|
|
||||||
net_bandwidth = 16000;
|
|
||||||
hardware_MAXPACKETLENGTH = INETPACKETLENGTH;
|
|
||||||
|
|
||||||
ret = true;
|
|
||||||
}
|
|
||||||
else if (M_CheckParm("-connect"))
|
|
||||||
{
|
|
||||||
if (M_IsNextParm())
|
|
||||||
strcpy(serverhostname, M_GetNextParm());
|
|
||||||
else
|
|
||||||
serverhostname[0] = 0; // assuming server in the LAN, use broadcast to detect it
|
|
||||||
|
|
||||||
// server address only in ip
|
|
||||||
if (serverhostname[0])
|
|
||||||
{
|
|
||||||
COM_BufAddText("connect \"");
|
|
||||||
COM_BufAddText(serverhostname);
|
|
||||||
COM_BufAddText("\"\n");
|
|
||||||
|
|
||||||
// probably modem
|
|
||||||
hardware_MAXPACKETLENGTH = INETPACKETLENGTH;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// so we're on a LAN
|
|
||||||
COM_BufAddText("connect any\n");
|
|
||||||
|
|
||||||
net_bandwidth = 800000;
|
|
||||||
hardware_MAXPACKETLENGTH = MAXPACKETLENGTH;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
I_NetOpenSocket = KOSUDP_OpenSocket;
|
|
||||||
I_Ban = KOSUDP_Ban;
|
|
||||||
I_ClearBans = KOSUDP_ClearBans;
|
|
||||||
I_GetNodeAddress = KOSUDP_GetNodeAddress;
|
|
||||||
I_GetBanAddress = KOSUDP_GetBanAddress;
|
|
||||||
bannednode = KOSUDP_bannednode;
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
|
|
@ -1,259 +0,0 @@
|
||||||
#include <stdio.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
|
|
||||||
#define MAXCHUNK (2048*1024)
|
|
||||||
|
|
||||||
static unsigned int seed;
|
|
||||||
|
|
||||||
void my_srand(unsigned int n)
|
|
||||||
{
|
|
||||||
seed = n & 0xffff;
|
|
||||||
}
|
|
||||||
|
|
||||||
unsigned int my_rand()
|
|
||||||
{
|
|
||||||
seed = (seed * 2109 + 9273) & 0x7fff;
|
|
||||||
return (seed + 0xc000) & 0xffff;
|
|
||||||
}
|
|
||||||
|
|
||||||
void load(FILE *fh, unsigned char *ptr, unsigned long sz)
|
|
||||||
{
|
|
||||||
if (fread(ptr, 1, sz, fh) != sz)
|
|
||||||
{
|
|
||||||
fprintf(stderr, "Read error!\n");
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void load_chunk(FILE *fh, unsigned char *ptr, unsigned long sz)
|
|
||||||
{
|
|
||||||
static int idx[MAXCHUNK/32];
|
|
||||||
int i;
|
|
||||||
|
|
||||||
/* Convert chunk size to number of slices */
|
|
||||||
sz /= 32;
|
|
||||||
|
|
||||||
/* Initialize index table with unity,
|
|
||||||
so that each slice gets loaded exactly once */
|
|
||||||
for (i = 0; i < sz; i++)
|
|
||||||
idx[i] = i;
|
|
||||||
|
|
||||||
for (i = sz-1; i >= 0; --i)
|
|
||||||
{
|
|
||||||
/* Select a replacement index */
|
|
||||||
int x = (my_rand() * i) >> 16;
|
|
||||||
|
|
||||||
/* Swap */
|
|
||||||
int tmp = idx[i];
|
|
||||||
idx[i] = idx[x];
|
|
||||||
idx[x] = tmp;
|
|
||||||
|
|
||||||
/* Load resulting slice */
|
|
||||||
load(fh, ptr+32*idx[i], 32);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void load_file(FILE *fh, unsigned char *ptr, unsigned long filesz)
|
|
||||||
{
|
|
||||||
unsigned long chunksz;
|
|
||||||
|
|
||||||
my_srand(filesz);
|
|
||||||
|
|
||||||
/* Descramble 2 meg blocks for as long as possible, then
|
|
||||||
gradually reduce the window down to 32 bytes (1 slice) */
|
|
||||||
for (chunksz = MAXCHUNK; chunksz >= 32; chunksz >>= 1)
|
|
||||||
while (filesz >= chunksz)
|
|
||||||
{
|
|
||||||
load_chunk(fh, ptr, chunksz);
|
|
||||||
filesz -= chunksz;
|
|
||||||
ptr += chunksz;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Load final incomplete slice */
|
|
||||||
if (filesz)
|
|
||||||
load(fh, ptr, filesz);
|
|
||||||
}
|
|
||||||
|
|
||||||
void read_file(char *filename, unsigned char **ptr, unsigned long *sz)
|
|
||||||
{
|
|
||||||
FILE *fh = fopen(filename, "rb");
|
|
||||||
if (fh == NULL)
|
|
||||||
{
|
|
||||||
fprintf(stderr, "Can't open \"%s\".\n", filename);
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
if (fseek(fh, 0, SEEK_END)<0)
|
|
||||||
{
|
|
||||||
fprintf(stderr, "Seek error.\n");
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
*sz = ftell(fh);
|
|
||||||
*ptr = malloc(*sz);
|
|
||||||
if ( *ptr == NULL )
|
|
||||||
{
|
|
||||||
fprintf(stderr, "Out of memory.\n");
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
if (fseek(fh, 0, SEEK_SET)<0)
|
|
||||||
{
|
|
||||||
fprintf(stderr, "Seek error.\n");
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
load_file(fh, *ptr, *sz);
|
|
||||||
fclose(fh);
|
|
||||||
}
|
|
||||||
|
|
||||||
void save(FILE *fh, unsigned char *ptr, unsigned long sz)
|
|
||||||
{
|
|
||||||
if (fwrite(ptr, 1, sz, fh) != sz)
|
|
||||||
{
|
|
||||||
fprintf(stderr, "Write error!\n");
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void save_chunk(FILE *fh, unsigned char *ptr, unsigned long sz)
|
|
||||||
{
|
|
||||||
static int idx[MAXCHUNK/32];
|
|
||||||
int i;
|
|
||||||
|
|
||||||
/* Convert chunk size to number of slices */
|
|
||||||
sz /= 32;
|
|
||||||
|
|
||||||
/* Initialize index table with unity,
|
|
||||||
so that each slice gets saved exactly once */
|
|
||||||
for (i = 0; i < sz; i++)
|
|
||||||
idx[i] = i;
|
|
||||||
|
|
||||||
for (i = sz-1; i >= 0; --i)
|
|
||||||
{
|
|
||||||
/* Select a replacement index */
|
|
||||||
int x = (my_rand() * i) >> 16;
|
|
||||||
|
|
||||||
/* Swap */
|
|
||||||
int tmp = idx[i];
|
|
||||||
idx[i] = idx[x];
|
|
||||||
idx[x] = tmp;
|
|
||||||
|
|
||||||
/* Save resulting slice */
|
|
||||||
save(fh, ptr+32*idx[i], 32);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void save_file(FILE *fh, unsigned char *ptr, unsigned long filesz)
|
|
||||||
{
|
|
||||||
unsigned long chunksz;
|
|
||||||
|
|
||||||
my_srand(filesz);
|
|
||||||
|
|
||||||
/* Descramble 2 meg blocks for as long as possible, then
|
|
||||||
gradually reduce the window down to 32 bytes (1 slice) */
|
|
||||||
for (chunksz = MAXCHUNK; chunksz >= 32; chunksz >>= 1)
|
|
||||||
while (filesz >= chunksz)
|
|
||||||
{
|
|
||||||
save_chunk(fh, ptr, chunksz);
|
|
||||||
filesz -= chunksz;
|
|
||||||
ptr += chunksz;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Save final incomplete slice */
|
|
||||||
if (filesz)
|
|
||||||
save(fh, ptr, filesz);
|
|
||||||
}
|
|
||||||
|
|
||||||
void write_file(char *filename, unsigned char *ptr, unsigned long sz)
|
|
||||||
{
|
|
||||||
FILE *fh = fopen(filename, "wb");
|
|
||||||
if (fh == NULL)
|
|
||||||
{
|
|
||||||
fprintf(stderr, "Can't open \"%s\".\n", filename);
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
save_file(fh, ptr, sz);
|
|
||||||
fclose(fh);
|
|
||||||
}
|
|
||||||
|
|
||||||
void descramble(char *src, char *dst)
|
|
||||||
{
|
|
||||||
unsigned char *ptr = NULL;
|
|
||||||
unsigned long sz = 0;
|
|
||||||
FILE *fh;
|
|
||||||
|
|
||||||
read_file(src, &ptr, &sz);
|
|
||||||
|
|
||||||
fh = fopen(dst, "wb");
|
|
||||||
if (fh == NULL)
|
|
||||||
{
|
|
||||||
fprintf(stderr, "Can't open \"%s\".\n", dst);
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
if ( fwrite(ptr, 1, sz, fh) != sz )
|
|
||||||
{
|
|
||||||
fprintf(stderr, "Write error.\n");
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
fclose(fh);
|
|
||||||
free(ptr);
|
|
||||||
}
|
|
||||||
|
|
||||||
void scramble(char *src, char *dst)
|
|
||||||
{
|
|
||||||
unsigned char *ptr = NULL;
|
|
||||||
unsigned long sz = 0;
|
|
||||||
FILE *fh;
|
|
||||||
|
|
||||||
fh = fopen(src, "rb");
|
|
||||||
if (fh == NULL)
|
|
||||||
{
|
|
||||||
fprintf(stderr, "Can't open \"%s\".\n", src);
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
if (fseek(fh, 0, SEEK_END)<0)
|
|
||||||
{
|
|
||||||
fprintf(stderr, "Seek error.\n");
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
sz = ftell(fh);
|
|
||||||
ptr = malloc(sz);
|
|
||||||
if ( ptr == NULL )
|
|
||||||
{
|
|
||||||
fprintf(stderr, "Out of memory.\n");
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
if (fseek(fh, 0, SEEK_SET)<0)
|
|
||||||
{
|
|
||||||
fprintf(stderr, "Seek error.\n");
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
if ( fread(ptr, 1, sz, fh) != sz )
|
|
||||||
{
|
|
||||||
fprintf(stderr, "Read error.\n");
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
fclose(fh);
|
|
||||||
|
|
||||||
write_file(dst, ptr, sz);
|
|
||||||
|
|
||||||
free(ptr);
|
|
||||||
}
|
|
||||||
|
|
||||||
int main(int argc, char *argv[])
|
|
||||||
{
|
|
||||||
int opt = 0;
|
|
||||||
|
|
||||||
if (argc > 1 && !strcmp(argv[1], "-d"))
|
|
||||||
opt ++;
|
|
||||||
|
|
||||||
if (argc != 3+opt)
|
|
||||||
{
|
|
||||||
fprintf(stderr, "Usage: %s [-d] from to\n", argv[0]);
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (opt)
|
|
||||||
descramble(argv[2], argv[3]);
|
|
||||||
else
|
|
||||||
scramble(argv[1], argv[2]);
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
Binary file not shown.
Before Width: | Height: | Size: 3.6 KiB |
|
@ -1,139 +0,0 @@
|
||||||
#
|
|
||||||
# Makefile.cfg for SRB2 for the PlayStation 3 using PSL1GHT
|
|
||||||
#
|
|
||||||
|
|
||||||
# Check if PS3DEV and PSL1GHT is set in the environment. If so, continue with compilation.
|
|
||||||
.SUFFIXES:
|
|
||||||
|
|
||||||
ifeq ($(strip $(PS3DEV)),)
|
|
||||||
$(error "Please set PS3DEV in your environment. export PS3DEV=<path to>ps3dev-toolchain")
|
|
||||||
endif
|
|
||||||
|
|
||||||
ifeq ($(strip $(PSL1GHT)),)
|
|
||||||
$(error "Please set PSL1GHT in your environment. export PSL1GHT=<path to>PSL1GHT")
|
|
||||||
endif
|
|
||||||
|
|
||||||
# Set compiler flags
|
|
||||||
|
|
||||||
# Disable same warning flags
|
|
||||||
WFLAGS+=-Wno-shadow -Wno-char-subscripts -Wno-format
|
|
||||||
|
|
||||||
ifdef JAILBREAK
|
|
||||||
EXENAME?=SRB2PS3-jb.elf
|
|
||||||
PKGNAME?=SRB2PS3-jb.pkg
|
|
||||||
else
|
|
||||||
EXENAME?=SRB2PS3.elf
|
|
||||||
PKGNAME?=SRB2PS3.pkg
|
|
||||||
endif
|
|
||||||
DGBNAME?=$(EXENAME).debug
|
|
||||||
|
|
||||||
SRB2PS3DIR=sdl/SRB2PS3
|
|
||||||
ICON0?=$(SRB2PS3DIR)/ICON0.png
|
|
||||||
SFOXML?=sfo.xml
|
|
||||||
SRB2TTF?=sdl/srb2.ttf
|
|
||||||
|
|
||||||
TITLE=Sonic Robo Blast 2 v2.0.6
|
|
||||||
APPID=SRB2-PS3
|
|
||||||
CONTENTID=UP0001-$(APPID)_00-0000000000000000
|
|
||||||
|
|
||||||
FSELF=$(PS3DEV)/bin/fself.py
|
|
||||||
MAKE_SELF_NPDRM=$(PS3DEV)/ps3publictools/make_self_npdrm
|
|
||||||
FINALIZE=$(PS3DEV)/ps3publictools/package_finalize
|
|
||||||
SFO=$(PS3DEV)/bin/sfo.py
|
|
||||||
PKG=$(PS3DEV)/bin/pkg.py
|
|
||||||
PS3LOADEXE=$(PS3DEV)/ps3tools/ps3load
|
|
||||||
SED=sed
|
|
||||||
MV=mv
|
|
||||||
XARGS=xargs
|
|
||||||
FOR=for
|
|
||||||
SHXARGS:=$(XARGS)
|
|
||||||
SHSED:=$(SED)
|
|
||||||
SPRXLINKER=$(PS3DEV)/bin/sprxlinker
|
|
||||||
|
|
||||||
ifdef JAILBREAK
|
|
||||||
PKGDIR=$(BIN)/pkg-jb
|
|
||||||
else
|
|
||||||
PKGDIR=$(BIN)/pkg
|
|
||||||
endif
|
|
||||||
USRDIR=$(PKGDIR)/USRDIR
|
|
||||||
ETCDIR=$(USRDIR)/etc
|
|
||||||
WGET=wget -P $(ETCDIR) -c -nc
|
|
||||||
|
|
||||||
ifndef ECHO
|
|
||||||
FSELF:=@$(FSELF)
|
|
||||||
MAKE_SELF_NPDRM:=@$(MAKE_SELF_NPDRM)
|
|
||||||
FINALIZE:=@$(FINALIZE)
|
|
||||||
SFO:=@$(SFO)
|
|
||||||
PKG:=@$(PKG)
|
|
||||||
PS3LOADEXE:=@$(PS3LOADEXE)
|
|
||||||
SED:=@$(SED)
|
|
||||||
MV:=@$(MV)
|
|
||||||
SPRXLINKER:=@$(SPRXLINKER)
|
|
||||||
XARGS:=@$(XARGS)
|
|
||||||
FOR:=@(FOR)
|
|
||||||
endif
|
|
||||||
|
|
||||||
# SRB2PS3 needs SDL_ttf to display any console text
|
|
||||||
SDL_TTF=1
|
|
||||||
|
|
||||||
# newlib has no support for networking
|
|
||||||
#NONET=1
|
|
||||||
|
|
||||||
# use absolute paths because changing PATH variable breaks distcc
|
|
||||||
PREFIX := $(PS3DEV)/ppu/bin/$(PREFIX)
|
|
||||||
|
|
||||||
# PS3DEV toolchain libdir and includedir
|
|
||||||
PS3DEV_INC := $(PS3DEV)/ppu/include
|
|
||||||
PS3DEV_LIB := $(PS3DEV)/ppu/lib
|
|
||||||
|
|
||||||
# PSL1GHT libdir and includedir
|
|
||||||
PSL1GHT_INC := $(PSL1GHT)/ppu/include
|
|
||||||
PSL1GHT_LIB := $(PSL1GHT)/ppu/lib
|
|
||||||
|
|
||||||
PS3PORTS := $(PS3DEV)/portlibs
|
|
||||||
PS3PORTS_BIN := $(PS3PORTS)/ppu/bin
|
|
||||||
PS3PORTS_INC := $(PS3PORTS)/ppu/include
|
|
||||||
|
|
||||||
PNG_CONFIG := $(PS3PORTS_BIN)/libpng-config
|
|
||||||
# static compilation
|
|
||||||
PNG_STATIC=1
|
|
||||||
|
|
||||||
SDL_CONFIG := $(PS3PORTS_BIN)/sdl-config
|
|
||||||
|
|
||||||
INCLUDE := -I$(PSL1GHT_INC) -I$(PS3DEV_INC) -I$(PS3PORTS_INC)
|
|
||||||
|
|
||||||
OPTS+=-D_PS3 -DUNIXCOMMON
|
|
||||||
CFLAGS+= -g $(INCLUDE) -L$(PSL1GHT_LIB) -L$(PS3DEV_LIB) -L$(PS3DEV)/lib
|
|
||||||
CXXFLAGS+=$(CFLAGS)
|
|
||||||
LDFLAGS+= -B$(PSL1GHT_LIB) -B$(PS3DEV_LIB) -B$(PS3DEV)/lib
|
|
||||||
LIBS+=-lrsx
|
|
||||||
ifndef NONET
|
|
||||||
LIBS+=-lnet -lsysmodule
|
|
||||||
endif
|
|
||||||
|
|
||||||
$(BIN)/$(PKGNAME): $(OBJS) $(BIN)/$(EXENAME)
|
|
||||||
@echo Linking $(PKGNAME)...
|
|
||||||
-$(MKDIR) $(ETCDIR)
|
|
||||||
$(CP) $(ICON0) $(PKGDIR)
|
|
||||||
$(CP) $(SRB2TTF) $(ETCDIR)
|
|
||||||
ifdef WITHDATA
|
|
||||||
$(FOR) datafile in $(shell echo $(D_FILES) | $(SHSED) 's/\.srb/\.wad/' | $(SHXARGS) -n 1 basename); do \
|
|
||||||
$(WGET) http://alam.srb2.org/SRB2/2.0.6-Final/Resources/$$datafile; \
|
|
||||||
done
|
|
||||||
endif
|
|
||||||
$(SPRXLINKER) $(BIN)/$(EXENAME)
|
|
||||||
ifdef JAILBREAK
|
|
||||||
$(SED) 's/@@PS3_SYSTEM_VER@@/3.41/' $(SRB2PS3DIR)/$(SFOXML) > $(BIN)/$(SFOXML)
|
|
||||||
$(FSELF) -n $(BIN)/$(EXENAME) $(USRDIR)/EBOOT.BIN
|
|
||||||
else
|
|
||||||
$(SED) 's/@@PS3_SYSTEM_VER@@/3.55/' $(SRB2PS3DIR)/$(SFOXML) > $(BIN)/$(SFOXML)
|
|
||||||
$(MAKE_SELF_NPDRM) $(BIN)/$(EXENAME) $(USRDIR)/EBOOT.BIN $(CONTENTID)
|
|
||||||
endif
|
|
||||||
$(SFO) --title "$(TITLE)" --appid "$(APPID)" -f $(BIN)/$(SFOXML) $(PKGDIR)/PARAM.SFO
|
|
||||||
$(PKG) --contentid $(CONTENTID) $(PKGDIR)/ $(BIN)/$(PKGNAME)
|
|
||||||
ifndef JAILBREAK
|
|
||||||
$(FINALIZE) $(BIN)/$(PKGNAME)
|
|
||||||
endif
|
|
||||||
|
|
||||||
run: $(BIN)/$(EXENAME)
|
|
||||||
$(PS3LOADEXE) $(USRDIR)/EBOOT.BIN
|
|
|
@ -1,39 +0,0 @@
|
||||||
<?xml version="1.0" ?>
|
|
||||||
<sfo>
|
|
||||||
<value name="APP_VER" type="string">
|
|
||||||
02.06
|
|
||||||
</value>
|
|
||||||
<value name="ATTRIBUTE" type="integer">
|
|
||||||
0
|
|
||||||
</value>
|
|
||||||
<value name="BOOTABLE" type="integer">
|
|
||||||
1
|
|
||||||
</value>
|
|
||||||
<value name="CATEGORY" type="string">
|
|
||||||
HG
|
|
||||||
</value>
|
|
||||||
<value name="LICENSE" type="string">
|
|
||||||
This application was created with the official non-official SDK called PSL1GHT, for more information visit http://www.psl1ght.com/ . This is in no way associated with Sony Computer Entertainment Inc., please do not contact them for help, they will not be able to provide it.
|
|
||||||
</value>
|
|
||||||
<value name="PARENTAL_LEVEL" type="integer">
|
|
||||||
0
|
|
||||||
</value>
|
|
||||||
<value name="PS3_SYSTEM_VER" type="string">
|
|
||||||
0@@PS3_SYSTEM_VER@@00
|
|
||||||
</value>
|
|
||||||
<value name="RESOLUTION" type="integer">
|
|
||||||
63
|
|
||||||
</value>
|
|
||||||
<value name="SOUND_FORMAT" type="integer">
|
|
||||||
279
|
|
||||||
</value>
|
|
||||||
<value name="TITLE" type="string">
|
|
||||||
Sonic Robo Blast 2
|
|
||||||
</value>
|
|
||||||
<value name="TITLE_ID" type="string">
|
|
||||||
SRB200000
|
|
||||||
</value>
|
|
||||||
<value name="VERSION" type="string">
|
|
||||||
02.06
|
|
||||||
</value>
|
|
||||||
</sfo>
|
|
Binary file not shown.
Before Width: | Height: | Size: 3.6 KiB |
|
@ -1,126 +0,0 @@
|
||||||
#
|
|
||||||
# Makefile.cfg for SRB2/PSP
|
|
||||||
#
|
|
||||||
|
|
||||||
#
|
|
||||||
#hmmm, the PSP
|
|
||||||
#
|
|
||||||
|
|
||||||
PSPSDK=$(shell psp-config -p)
|
|
||||||
PSPDEV=$(shell psp-config -d)
|
|
||||||
PSPPREFIX=$(shell psp-config -P)
|
|
||||||
STRIP=psp-strip
|
|
||||||
MKSFO?=mksfoex -d MEMSIZE=1
|
|
||||||
#MKSFO=mksfo
|
|
||||||
PACK_PBP=pack-pbp
|
|
||||||
FIXUP=psp-fixup-imports
|
|
||||||
HOSTCC:=$(CC)
|
|
||||||
CC=$(PSPDEV)/bin/psp-gcc
|
|
||||||
OBJCOPY=psp-objcopy
|
|
||||||
OBJDUMP=psp-objdump
|
|
||||||
ifdef FIXEDPRX
|
|
||||||
PRXGEN=psp-prxgen
|
|
||||||
else
|
|
||||||
PRXGEN=$(OBJCOPY)
|
|
||||||
endif
|
|
||||||
ifndef PRXSIGN
|
|
||||||
SIGNER:=$(PSPDEV)/bin/$(OBJCOPY)
|
|
||||||
endif
|
|
||||||
|
|
||||||
ifndef ECHO
|
|
||||||
MKSFO:=@$(MKSFO)
|
|
||||||
PACK_PBP:=@$(PACK_PBP)
|
|
||||||
FIXUP:=@$(FIXUP)
|
|
||||||
PRXGEN:=@$(PRXGEN)
|
|
||||||
endif
|
|
||||||
|
|
||||||
PSP_EBOOT_TITLE=SRB2-PSP vME
|
|
||||||
PSP_EBOOT_SFO=$(BIN)/PARAM.SFO
|
|
||||||
PSP_EBOOT_ICON=sdl/SRB2PSP/ICON0.png
|
|
||||||
PSP_EBOOT_ICON1=NULL
|
|
||||||
PSP_EBOOT_UNKPNG=NULL
|
|
||||||
PSP_EBOOT_PIC1=sdl/SRB2PSP/PIC1.png
|
|
||||||
PSP_EBOOT_SND0=NULL
|
|
||||||
PSP_EBOOT_PSAR=NULL
|
|
||||||
|
|
||||||
SIGNER?=sdl/SRB2PSP/psp-prxsign/psp-prxsign
|
|
||||||
|
|
||||||
SDL=1
|
|
||||||
PREFIX=psp
|
|
||||||
NONX86=1
|
|
||||||
#NOHW=1
|
|
||||||
NOHS=1
|
|
||||||
NOMD5=1
|
|
||||||
NONET=1 #No TCPIP code
|
|
||||||
NOPNG=1 #No Screenshot
|
|
||||||
|
|
||||||
OPTS=-I$(PSPPREFIX)/include -I$(PSPSDK)/include
|
|
||||||
OPTS+=-DUNIXCOMMON -DFORCESDLMAIN -G0
|
|
||||||
WFLAGS+=-Wno-undef
|
|
||||||
WFLAGS+=-O1
|
|
||||||
LIBS=-lm
|
|
||||||
SDL_CONFIG?=$(PSPPREFIX)/bin/sdl-config
|
|
||||||
#SDL_CFLAGS?=-I$(PSPDEV)/psp/include/SDL
|
|
||||||
#SDL_LDFLAGS?=-lSDLmain -lSDL -lglut -lGLU -lGL -lpspgu -lpspaudiolib -lpspaudio -lpsphprm -lpspvfpu -lpsprtc
|
|
||||||
ifndef NOMIXER
|
|
||||||
LIBS:=-liberty -lvorbisfile -lvorbis -logg -lSDL $(LIBS)
|
|
||||||
endif
|
|
||||||
ifndef NOHW
|
|
||||||
OPTS+=-DSTATIC_OPENGL -DMINI_GL_COMPATIBILITY
|
|
||||||
LIBS+=-lGLU -lGL -lm
|
|
||||||
endif
|
|
||||||
#PSPSDK_LIBS=-L$(PSPSDK)/lib -lpspdebug -lpspdisplay -lpspge -lpspctrl -lpspsdk
|
|
||||||
#LIBS+=$(PSPSDK_LIBS) -lc -lpspnet -lpspnet_inet -lpspnet_apctl -lpspnet_resolver -lpsputility -lpspuser -lpspkernel
|
|
||||||
ifdef FIXEDPRX
|
|
||||||
LDFLAGS := -specs=$(PSPSDK)/lib/prxspecs -Wl,-q,-T$(PSPSDK)/lib/linkfile.prx $(LDFLAGS)
|
|
||||||
LIBS+=$(PSPSDK)/lib/prxexports.o
|
|
||||||
endif
|
|
||||||
|
|
||||||
ifeq ($(PSP_FW_VERSION),)
|
|
||||||
PSP_FW_VERSION=150
|
|
||||||
endif
|
|
||||||
|
|
||||||
CPPFLAGS:=-D_PSP_FW_VERSION=$(PSP_FW_VERSION) $(CPPFLAGS)
|
|
||||||
|
|
||||||
|
|
||||||
# name of the exefile
|
|
||||||
EXENAME?=SRB2PSP.elf
|
|
||||||
PRXNAME?=SRB2PSP.prx
|
|
||||||
DBGNAME?=SRB2PSP.debug
|
|
||||||
|
|
||||||
post-build: $(BIN)/EBOOT.PBP
|
|
||||||
|
|
||||||
kxploit: $(BIN)/$(EXENAME) $(PSP_EBOOT_SFO)
|
|
||||||
-$(MKDIR) "$(BIN)/kxploit/srb2"
|
|
||||||
@echo emitting kxploit/srb2/
|
|
||||||
$(STRIP) $(BIN)/$(EXENAME) -o $(BIN)/kxploit/srb2/EBOOT.PBP
|
|
||||||
@echo emitting kxploit/srb2%
|
|
||||||
-$(MKDIR) "$(BIN)/kxploit/srb2%/"
|
|
||||||
$(PACK_PBP) "$(BIN)/kxploit/srb2%/EBOOT.PBP" $(PSP_EBOOT_SFO) $(PSP_EBOOT_ICON) \
|
|
||||||
$(PSP_EBOOT_ICON1) $(PSP_EBOOT_UNKPNG) $(PSP_EBOOT_PIC1) \
|
|
||||||
$(PSP_EBOOT_SND0) NULL $(PSP_EBOOT_PSAR)
|
|
||||||
|
|
||||||
sdl/SRB2PSP/psp-prxsign/psp-prxsign:
|
|
||||||
-$(MAKE) -C sdl/SRB2PSP/psp-prxsign CFLAGS=-pipe CC="$(HOSTCC)"
|
|
||||||
|
|
||||||
fix-up: $(BIN)/$(EXENAME)
|
|
||||||
@echo Running psp-fixup-imports on $(EXENAME)
|
|
||||||
$(FIXUP) $(BIN)/$(EXENAME)
|
|
||||||
|
|
||||||
$(BIN)/$(PRXNAME): $(BIN)/$(EXENAME) fix-up
|
|
||||||
@echo Building $(PRXNAME) out of $(EXENAME)
|
|
||||||
$(PRXGEN) $(BIN)/$(EXENAME) $@
|
|
||||||
|
|
||||||
$(BIN)/EBOOT.PBP: $(BIN)/$(PRXNAME) $(SIGNER) $(PSP_EBOOT_SFO)
|
|
||||||
@echo Signing and running pack-pbp to make PBP
|
|
||||||
$(SIGNER) $(BIN)/$(PRXNAME) $(BIN)/$(PRXNAME).sign
|
|
||||||
$(PACK_PBP) $@ $(PSP_EBOOT_SFO) $(PSP_EBOOT_ICON) \
|
|
||||||
$(PSP_EBOOT_ICON1) $(PSP_EBOOT_UNKPNG) $(PSP_EBOOT_PIC1) \
|
|
||||||
$(PSP_EBOOT_SND0) $(BIN)/$(PRXNAME).sign $(PSP_EBOOT_PSAR)
|
|
||||||
$(REMOVE) $(BIN)/$(PRXNAME).sign
|
|
||||||
|
|
||||||
$(PSP_EBOOT_SFO):
|
|
||||||
-$(MKDIR) $(BIN)
|
|
||||||
$(MKSFO) '$(PSP_EBOOT_TITLE)' $@
|
|
||||||
|
|
||||||
#include $(PSPSDK)/lib/build.mak
|
|
Binary file not shown.
Before Width: | Height: | Size: 20 KiB |
2
src/sdl/SRB2PSP/psp-prxsign/.gitignore
vendored
2
src/sdl/SRB2PSP/psp-prxsign/.gitignore
vendored
|
@ -1,2 +0,0 @@
|
||||||
/psp-prxsign
|
|
||||||
/psp-prxsign.exe
|
|
|
@ -1,22 +0,0 @@
|
||||||
EXE=psp-prxsign
|
|
||||||
SRC=main.c cmac.c
|
|
||||||
OBJ=$(SRC:.c=.o)# replaces the .c from SRC with .o
|
|
||||||
|
|
||||||
OPENSSL_PKGCONFIG?=openssl
|
|
||||||
OPENSSL_CFLAGS?=$(shell pkg-config $(OPENSSL_PKGCONFIG) --cflags)
|
|
||||||
OPENSSL_LDFLAGS?=$(shell pkg-config $(OPENSSL_PKGCONFIG) --libs)
|
|
||||||
|
|
||||||
CFLAGS+=$(OPENSSL_CFLAGS)
|
|
||||||
LDFLAGS+=$(OPENSSL_LDFLAGS)
|
|
||||||
|
|
||||||
.PHONY : all # .PHONY ignores files named all
|
|
||||||
|
|
||||||
all: $(EXE) # all is dependent on $(BIN) to be complete
|
|
||||||
|
|
||||||
|
|
||||||
$(EXE): $(OBJ) # $(EXE) is dependent on all of the files in $(OBJ) to exist
|
|
||||||
$(CC) $^ $(LDFLAGS) -o $@
|
|
||||||
|
|
||||||
.PHONY : clean # .PHONY ignores files named clean
|
|
||||||
clean:
|
|
||||||
-$(RM) $(OBJ) $(EXE)
|
|
|
@ -1,130 +0,0 @@
|
||||||
#include "cmac.h"
|
|
||||||
|
|
||||||
#define AES_128 0
|
|
||||||
unsigned char const_Rb[16] = {
|
|
||||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
||||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x87
|
|
||||||
};
|
|
||||||
unsigned char const_Zero[16] = {
|
|
||||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
||||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
|
|
||||||
};
|
|
||||||
|
|
||||||
void xor_128(unsigned char *a, unsigned char *b, unsigned char *out)
|
|
||||||
{
|
|
||||||
int i;
|
|
||||||
for (i=0;i<16; i++)
|
|
||||||
{
|
|
||||||
out[i] = a[i] ^ b[i];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* AES-CMAC Generation Function */
|
|
||||||
|
|
||||||
static inline void leftshift_onebit(unsigned char *input,unsigned char *output)
|
|
||||||
{
|
|
||||||
int i;
|
|
||||||
unsigned char overflow = 0;
|
|
||||||
|
|
||||||
for ( i=15; i>=0; i-- )
|
|
||||||
{
|
|
||||||
output[i] = input[i] << 1;
|
|
||||||
output[i] |= overflow;
|
|
||||||
overflow = (input[i] & 0x80)?1:0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void generate_subkey(unsigned char *key, unsigned char *K1, unsigned char *K2)
|
|
||||||
{
|
|
||||||
unsigned char L[16];
|
|
||||||
unsigned char Z[16];
|
|
||||||
unsigned char tmp[16];
|
|
||||||
int i;
|
|
||||||
|
|
||||||
for ( i=0; i<16; i++ ) Z[i] = 0;
|
|
||||||
|
|
||||||
AES_KEY aes;
|
|
||||||
AES_set_encrypt_key(key, 128, &aes);
|
|
||||||
|
|
||||||
AES_encrypt(Z, L, &aes);
|
|
||||||
|
|
||||||
if ( (L[0] & 0x80) == 0 ) /* If MSB(L) = 0, then K1 = L << 1 */
|
|
||||||
{
|
|
||||||
leftshift_onebit(L,K1);
|
|
||||||
} else { /* Else K1 = ( L << 1 ) (+) Rb */
|
|
||||||
leftshift_onebit(L,tmp);
|
|
||||||
xor_128(tmp,const_Rb,K1);
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( (K1[0] & 0x80) == 0 )
|
|
||||||
{
|
|
||||||
leftshift_onebit(K1,K2);
|
|
||||||
} else {
|
|
||||||
leftshift_onebit(K1,tmp);
|
|
||||||
xor_128(tmp,const_Rb,K2);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline void padding ( unsigned char *lastb, unsigned char *pad, int length )
|
|
||||||
{
|
|
||||||
int j;
|
|
||||||
|
|
||||||
/* original last block */
|
|
||||||
for ( j=0; j<16; j++ )
|
|
||||||
{
|
|
||||||
if ( j < length )
|
|
||||||
{
|
|
||||||
pad[j] = lastb[j];
|
|
||||||
} else if ( j == length ) {
|
|
||||||
pad[j] = 0x80;
|
|
||||||
} else {
|
|
||||||
pad[j] = 0x00;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void AES_CMAC ( unsigned char *key, unsigned char *input, int length, unsigned char *mac )
|
|
||||||
{
|
|
||||||
unsigned char X[16],Y[16], M_last[16], padded[16];
|
|
||||||
unsigned char K1[16], K2[16];
|
|
||||||
int n, i, flag;
|
|
||||||
generate_subkey(key,K1,K2);
|
|
||||||
|
|
||||||
n = (length+15) / 16; /* n is number of rounds */
|
|
||||||
|
|
||||||
if ( n == 0 )
|
|
||||||
{
|
|
||||||
n = 1;
|
|
||||||
flag = 0;
|
|
||||||
} else {
|
|
||||||
if ( (length%16) == 0 ) { /* last block is a complete block */
|
|
||||||
flag = 1;
|
|
||||||
} else { /* last block is not complete block */
|
|
||||||
flag = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( flag ) { /* last block is complete block */
|
|
||||||
xor_128(&input[16*(n-1)],K1,M_last);
|
|
||||||
} else {
|
|
||||||
padding(&input[16*(n-1)],padded,length%16);
|
|
||||||
xor_128(padded,K2,M_last);
|
|
||||||
}
|
|
||||||
AES_KEY aes;
|
|
||||||
AES_set_encrypt_key(key, 128, &aes);
|
|
||||||
|
|
||||||
for ( i=0; i<16; i++ ) X[i] = 0;
|
|
||||||
for ( i=0; i<n-1; i++ )
|
|
||||||
{
|
|
||||||
xor_128(X,&input[16*i],Y); /* Y := Mi (+) X */
|
|
||||||
AES_encrypt(Y, X, &aes); /* X := AES-128(KEY, Y); */
|
|
||||||
}
|
|
||||||
|
|
||||||
xor_128(X,M_last,Y);
|
|
||||||
AES_encrypt(Y, X, &aes);
|
|
||||||
|
|
||||||
for ( i=0; i<16; i++ ) {
|
|
||||||
mac[i] = X[i];
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,38 +0,0 @@
|
||||||
/*
|
|
||||||
---------------------------------------------------------------------------
|
|
||||||
Copyright (c) 1998-2008, Brian Gladman, Worcester, UK. All rights reserved.
|
|
||||||
|
|
||||||
LICENSE TERMS
|
|
||||||
|
|
||||||
The redistribution and use of this software (with or without changes)
|
|
||||||
is allowed without the payment of fees or royalties provided that:
|
|
||||||
|
|
||||||
1. source code distributions include the above copyright notice, this
|
|
||||||
list of conditions and the following disclaimer;
|
|
||||||
|
|
||||||
2. binary distributions include the above copyright notice, this list
|
|
||||||
of conditions and the following disclaimer in their documentation;
|
|
||||||
|
|
||||||
3. the name of the copyright holder is not used to endorse products
|
|
||||||
built using this software without specific written permission.
|
|
||||||
|
|
||||||
DISCLAIMER
|
|
||||||
|
|
||||||
This software is provided 'as is' with no explicit or implied warranties
|
|
||||||
in respect of its properties, including, but not limited to, correctness
|
|
||||||
and/or fitness for purpose.
|
|
||||||
---------------------------------------------------------------------------
|
|
||||||
Issue Date: 6/10/2008
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef CMAC_AES_H
|
|
||||||
#define CMAC_AES_H
|
|
||||||
|
|
||||||
#include <string.h>
|
|
||||||
#include <openssl/aes.h>
|
|
||||||
|
|
||||||
void xor_128(unsigned char *a, unsigned char *b, unsigned char *out);
|
|
||||||
void generate_subkey(unsigned char *key, unsigned char *K1, unsigned char *K2);
|
|
||||||
void AES_CMAC(unsigned char *key, unsigned char *input, int length, unsigned char *mac);
|
|
||||||
|
|
||||||
#endif
|
|
|
@ -1,25 +0,0 @@
|
||||||
#ifndef __kirk_header__
|
|
||||||
#define __kirk_header__
|
|
||||||
|
|
||||||
static unsigned int size_kirk_header = 272;
|
|
||||||
static unsigned char kirk_header[] __attribute__((aligned(16))) = {
|
|
||||||
0x2a, 0x4f, 0x3c, 0x49, 0x8a, 0x73, 0x4e, 0xd1, 0xf4, 0x55, 0x93, 0x0b, 0x9b, 0x69, 0xdc, 0x65,
|
|
||||||
0x73, 0x22, 0x69, 0xd3, 0x73, 0x96, 0x7a, 0x60, 0x66, 0x8c, 0x88, 0xcf, 0x2f, 0x83, 0x58, 0xbc,
|
|
||||||
0xb2, 0x00, 0x0a, 0x11, 0x72, 0x43, 0xc5, 0xde, 0xef, 0xbb, 0x2c, 0xbf, 0x97, 0x79, 0x6b, 0x9c,
|
|
||||||
0x10, 0x1e, 0x7c, 0x57, 0x0e, 0xdb, 0x1d, 0x61, 0x6e, 0xb5, 0xf9, 0x3d, 0x35, 0xe9, 0x5c, 0xd8,
|
|
||||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
||||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
||||||
0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
||||||
0x00, 0x33, 0x55, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
||||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
||||||
0x7e, 0x50, 0x53, 0x50, 0x00, 0x02, 0x00, 0x00, 0x01, 0x01, 0x22, 0x74, 0x69, 0x66, 0x70, 0x73,
|
|
||||||
0x70, 0x22, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
||||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x00, 0x33, 0x55, 0x00, 0x50, 0x34, 0x55, 0x00,
|
|
||||||
0x00, 0x00, 0x00, 0x00, 0x40, 0x67, 0x3d, 0x00, 0x50, 0x55, 0x0a, 0x01, 0x10, 0x00, 0x40, 0x00,
|
|
||||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x6b, 0x3d, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
||||||
0x00, 0x00, 0x00, 0x00, 0x4c, 0x6b, 0x3d, 0x00, 0xcc, 0xbb, 0x11, 0x01, 0x00, 0x00, 0x00, 0x00,
|
|
||||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
||||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0d, 0x00, 0x00, 0x00,
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif
|
|
|
@ -1,190 +0,0 @@
|
||||||
#include <stdio.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <openssl/aes.h>
|
|
||||||
#include <openssl/sha.h>
|
|
||||||
#include <elf.h>
|
|
||||||
#include "cmac.h"
|
|
||||||
#include "kirk_header.h"
|
|
||||||
#include "psp_header.h"
|
|
||||||
|
|
||||||
typedef unsigned char byte;
|
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
byte key[16];
|
|
||||||
byte ckey[16];
|
|
||||||
byte head_hash[16];
|
|
||||||
byte data_hash[16];
|
|
||||||
byte unused[32];
|
|
||||||
int unk1; // 1
|
|
||||||
int unk2; // 0
|
|
||||||
int unk3[2];
|
|
||||||
int datasize;
|
|
||||||
int dataoffset;
|
|
||||||
int unk4[6];
|
|
||||||
} kirk1head_t;
|
|
||||||
|
|
||||||
// secret kirk command 1 key
|
|
||||||
byte kirk_key[] = {
|
|
||||||
0x98, 0xc9, 0x40, 0x97, 0x5c, 0x1d, 0x10, 0xe8, 0x7f, 0xe6, 0x0e, 0xa3, 0xfd, 0x03, 0xa8, 0xba
|
|
||||||
};
|
|
||||||
|
|
||||||
int main(int argc, char **argv)
|
|
||||||
{
|
|
||||||
int i, relrem, size, fullsize, blocks, datasize;
|
|
||||||
size_t j;
|
|
||||||
kirk1head_t kirk;
|
|
||||||
byte iv[16];
|
|
||||||
byte cmac[32];
|
|
||||||
byte subk[32];
|
|
||||||
byte psph[0x150];
|
|
||||||
byte *datablob;
|
|
||||||
byte *filebuff;
|
|
||||||
FILE *f;
|
|
||||||
AES_KEY aesKey;
|
|
||||||
Elf32_Ehdr *ehdr;
|
|
||||||
Elf32_Shdr *shdr;
|
|
||||||
Elf32_Rel *relo;
|
|
||||||
|
|
||||||
if(argc < 3) {
|
|
||||||
printf("Usage: %s unsigned.prx signed.prx\n", argv[0]);
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
// clean kirk header, use modified PRXdecrypter to get it
|
|
||||||
/*f = fopen(argv[1], "rb");
|
|
||||||
if(!f) {
|
|
||||||
printf("failed to open %s\n", argv[1]);
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
fread(&kirk, 1, sizeof(kirk1head_t), f);
|
|
||||||
fclose(f);*/
|
|
||||||
//memcpy(&kirk, kirk_header, size_kirk_header);
|
|
||||||
memcpy(&kirk, kirk_header, sizeof(kirk1head_t));
|
|
||||||
|
|
||||||
datasize = kirk.datasize;
|
|
||||||
if(datasize % 16) datasize += 16 - (datasize % 16);
|
|
||||||
|
|
||||||
// original ~PSP header
|
|
||||||
/*f = fopen(argv[2], "rb");
|
|
||||||
if(!f) {
|
|
||||||
free(datablob);
|
|
||||||
printf("failed to open %s\n", argv[2]);
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
fread(psph, 1, 0x150, f);
|
|
||||||
fclose(f);*/
|
|
||||||
memcpy(&psph, psp_header, size_psp_header);
|
|
||||||
|
|
||||||
// file to encrypt
|
|
||||||
f = fopen(argv[1], "rb");
|
|
||||||
if(!f) {
|
|
||||||
printf("psp-prxsign: Unable to open PRX\n");
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
fseek(f, 0, SEEK_END);
|
|
||||||
size = ftell(f);
|
|
||||||
if(size > datasize - 16) {
|
|
||||||
fclose(f);
|
|
||||||
printf("psp-prxsign: PRX is too large\n");
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
printf("%s : %i\n", argv[1], size);
|
|
||||||
fseek(f, 0, SEEK_SET);
|
|
||||||
|
|
||||||
fullsize = datasize + 0x30 + kirk.dataoffset;
|
|
||||||
|
|
||||||
// datablob holds everything needed to calculate data HASH
|
|
||||||
datablob = malloc(fullsize);
|
|
||||||
if(!datablob) {
|
|
||||||
fclose(f);
|
|
||||||
printf("psp-prxsign: Failed to allocate memory for blob\n");
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
memset(datablob, 0, fullsize);
|
|
||||||
memcpy(datablob, &kirk.unk1, 0x30);
|
|
||||||
memcpy(datablob + 0x30, psph, kirk.dataoffset);
|
|
||||||
filebuff = datablob + 0x30 + kirk.dataoffset;
|
|
||||||
|
|
||||||
int whocares = fread(filebuff, 1, size, f);
|
|
||||||
(void)whocares;
|
|
||||||
fclose(f);
|
|
||||||
|
|
||||||
// remove relocations type 7
|
|
||||||
relrem = 0;
|
|
||||||
ehdr = (void *)filebuff;
|
|
||||||
if(!memcmp(ehdr->e_ident, ELFMAG, 4) && ehdr->e_shnum) {
|
|
||||||
shdr = (void *)(filebuff + ehdr->e_shoff);
|
|
||||||
for(i = 0; i < ehdr->e_shnum; i++) {
|
|
||||||
if(shdr[i].sh_type == 0x700000A0) {
|
|
||||||
relo = (void *)(filebuff + shdr[i].sh_offset);
|
|
||||||
for(j = 0; j < shdr[i].sh_size / sizeof(Elf32_Rel); j++) {
|
|
||||||
if((relo[j].r_info & 0xFF) == 7) {
|
|
||||||
relo[j].r_info = 0;
|
|
||||||
relrem++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
//printf("%i relocations type 7 removed\ncalculating ...\n", relrem);
|
|
||||||
|
|
||||||
// get AES/CMAC key
|
|
||||||
AES_set_decrypt_key(kirk_key, 128, &aesKey);
|
|
||||||
memset(iv, 0, 16);
|
|
||||||
AES_cbc_encrypt(kirk.key, kirk.key, 32, &aesKey, iv, AES_DECRYPT);
|
|
||||||
|
|
||||||
// check header hash, optional
|
|
||||||
// if you take correct kirk header, hash is always correct
|
|
||||||
/* AES_CMAC(kirk.ckey, datablob, 0x30, cmac);
|
|
||||||
if(memcmp(cmac, kirk.head_hash, 16)) {
|
|
||||||
free(datablob);
|
|
||||||
printf("header hash invalid\n");
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
// encrypt input file
|
|
||||||
AES_set_encrypt_key(kirk.key, 128, &aesKey);
|
|
||||||
memset(iv, 0, 16);
|
|
||||||
AES_cbc_encrypt(filebuff, filebuff, datasize, &aesKey, iv, AES_ENCRYPT);
|
|
||||||
|
|
||||||
// make CMAC correct
|
|
||||||
generate_subkey(kirk.ckey, subk, subk + 16);
|
|
||||||
AES_set_encrypt_key(kirk.ckey, 128, &aesKey);
|
|
||||||
blocks = fullsize / 16;
|
|
||||||
memset(cmac, 0, 16);
|
|
||||||
for(i = 0; i < blocks - 1; i++) {
|
|
||||||
xor_128(cmac, &datablob[16 * i], cmac + 16);
|
|
||||||
AES_encrypt(cmac + 16, cmac, &aesKey);
|
|
||||||
}
|
|
||||||
|
|
||||||
AES_set_decrypt_key(kirk.ckey, 128, &aesKey);
|
|
||||||
AES_decrypt(kirk.data_hash, iv, &aesKey);
|
|
||||||
xor_128(cmac, iv, iv);
|
|
||||||
xor_128(iv, subk, &datablob[16 * (blocks-1)]);
|
|
||||||
// check it, optional
|
|
||||||
// it works, this is only if you want to change something
|
|
||||||
/* AES_CMAC(kirk.ckey, datablob, fullsize, cmac);
|
|
||||||
if(memcmp(cmac, kirk.data_hash, 16)) {
|
|
||||||
fclose(f);
|
|
||||||
free(datablob);
|
|
||||||
printf("data hash calculation error\n");
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
f = fopen(argv[2], "wb");
|
|
||||||
if(!f) {
|
|
||||||
free(datablob);
|
|
||||||
printf("psp-prxsign: Failed to write signed PRX\n");
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
//printf("saving ...\n");
|
|
||||||
// save ~PSP header
|
|
||||||
fwrite(psph, 1, 0x150, f);
|
|
||||||
// save encrypted file
|
|
||||||
fwrite(filebuff, 1, fullsize - 0x30 - kirk.dataoffset, f);
|
|
||||||
fclose(f);
|
|
||||||
free(datablob);
|
|
||||||
//printf("everything done\n");
|
|
||||||
return 0;
|
|
||||||
}
|
|
|
@ -1,29 +0,0 @@
|
||||||
#ifndef __psp_header__
|
|
||||||
#define __psp_header__
|
|
||||||
|
|
||||||
static unsigned int size_psp_header = 336;
|
|
||||||
static unsigned char psp_header[] __attribute__((aligned(16))) = {
|
|
||||||
0x7e, 0x50, 0x53, 0x50, 0x00, 0x02, 0x00, 0x00, 0x01, 0x01, 0x22, 0x74, 0x69, 0x66, 0x70, 0x73,
|
|
||||||
0x70, 0x22, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
||||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x00, 0x33, 0x55, 0x00, 0x50, 0x34, 0x55, 0x00,
|
|
||||||
0x00, 0x00, 0x00, 0x00, 0x40, 0x67, 0x3d, 0x00, 0x50, 0x55, 0x0a, 0x01, 0x10, 0x00, 0x40, 0x00,
|
|
||||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x6b, 0x3d, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
||||||
0x00, 0x00, 0x00, 0x00, 0x4c, 0x6b, 0x3d, 0x00, 0xcc, 0xbb, 0x11, 0x01, 0x00, 0x00, 0x00, 0x00,
|
|
||||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
||||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0d, 0x00, 0x00, 0x00,
|
|
||||||
0x90, 0x82, 0x4c, 0x48, 0xa3, 0x53, 0xb2, 0x1b, 0x13, 0x95, 0x2f, 0xf1, 0x0b, 0x90, 0x9c, 0x11,
|
|
||||||
0x61, 0x40, 0x20, 0x67, 0xf8, 0xdb, 0xfc, 0x95, 0x5c, 0xbe, 0x8c, 0x80, 0xf3, 0x92, 0x03, 0x01,
|
|
||||||
0xb0, 0xbe, 0xf5, 0xf8, 0xa1, 0xaf, 0xaf, 0xa8, 0x38, 0x26, 0x63, 0x09, 0x26, 0x0e, 0xb7, 0xd5,
|
|
||||||
0x00, 0x33, 0x55, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
||||||
0x5c, 0x3e, 0x03, 0x22, 0xe5, 0x7d, 0xb9, 0xd1, 0x13, 0x67, 0x97, 0xa3, 0x5b, 0xd8, 0x77, 0x1f,
|
|
||||||
0xf0, 0x05, 0xf3, 0xad, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
||||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
||||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
||||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
||||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
||||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x87, 0x4a, 0xd7, 0x37,
|
|
||||||
0xc2, 0x8f, 0x15, 0x43, 0x33, 0x93, 0x4d, 0x5b, 0xc0, 0x6e, 0xe4, 0x00, 0xc6, 0x0a, 0x71, 0x11,
|
|
||||||
0x98, 0xb6, 0xc3, 0xb7, 0x59, 0x66, 0x21, 0xa8, 0x65, 0xf6, 0x53, 0xa9, 0x7a, 0x48, 0x17, 0xb6,
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif
|
|
|
@ -1,124 +0,0 @@
|
||||||
#
|
|
||||||
# Makefile.cfg for SRB2Wii native using libogc
|
|
||||||
#
|
|
||||||
|
|
||||||
# Check if DEVKITPPC is set in the environment. If so, continue with compilation.
|
|
||||||
.SUFFIXES:
|
|
||||||
|
|
||||||
ifeq ($(strip $(DEVKITPPC)),)
|
|
||||||
$(error "Please set DEVKITPPC in your environment. export DEVKITPPC=<path to>devkitPPC")
|
|
||||||
endif
|
|
||||||
|
|
||||||
# Set compiler flags
|
|
||||||
|
|
||||||
SRB2NAME?=srb2wii
|
|
||||||
EXENAME?=$(SRB2NAME).elf
|
|
||||||
DBGNAME?=$(SRB2NAME).elf.debug
|
|
||||||
DOLNAME?=$(SRB2NAME).dol
|
|
||||||
|
|
||||||
ICONPNG?=sdl/SRB2WII/icon.png
|
|
||||||
METAXML?=sdl/SRB2WII/meta.xml
|
|
||||||
|
|
||||||
APPDIR=apps/$(SRB2NAME)
|
|
||||||
ZIPNAME=$(SRB2NAME).zip
|
|
||||||
|
|
||||||
ELF2DOL=$(DEVKITPPC)/bin/elf2dol
|
|
||||||
WIILOADEXE=$(DEVKITPPC)/bin/wiiload
|
|
||||||
ZIP=zip -r -9
|
|
||||||
WGET=wget -P srb2wii -c -nc
|
|
||||||
SED=sed
|
|
||||||
XARGS=xargs
|
|
||||||
SHXARGS:=$(XARGS)
|
|
||||||
SHSED:=$(SED)
|
|
||||||
FOR=for
|
|
||||||
|
|
||||||
ifndef ECHO
|
|
||||||
ELF2DOL:=@$(ELF2DOL)
|
|
||||||
WIILOADEXE:=@$(WIILOADEXE)
|
|
||||||
ZIP:=@$(ZIP)
|
|
||||||
SED:=@$(SED)
|
|
||||||
XARGS:=@$(XARGS)
|
|
||||||
FOR:=@$(FOR)
|
|
||||||
endif
|
|
||||||
|
|
||||||
# Disable same warning flags
|
|
||||||
WFLAGS+=-Wno-shadow -Wno-char-subscripts -Wno-old-style-definition -Wno-unsuffixed-float-constants
|
|
||||||
|
|
||||||
# newlib has no support for networking
|
|
||||||
NONET=1
|
|
||||||
|
|
||||||
# use pkgconfig for PKG
|
|
||||||
PNG_PKGCONFIG=libpng
|
|
||||||
|
|
||||||
# use absolute paths because changing PATH variable breaks distcc
|
|
||||||
PREFIX := $(DEVKITPPC)/bin/$(PREFIX)
|
|
||||||
|
|
||||||
# FIXME: DevkitPPC and ready-compiled SDL Wii require these things to be in a silly order
|
|
||||||
# libogc/DevkitPro required stuff
|
|
||||||
LIBOGC := $(DEVKITPRO)/libogc
|
|
||||||
LIBOGC_INC := $(LIBOGC)/include
|
|
||||||
LIBOGC_LIB := $(LIBOGC)/lib
|
|
||||||
|
|
||||||
PORTLIBS := $(DEVKITPRO)/portlibs/ppc
|
|
||||||
PORTLIBS_INC := $(PORTLIBS)/include
|
|
||||||
PORTLIBS_LIB := $(PORTLIBS)/lib
|
|
||||||
|
|
||||||
SDL_CPPFLAGS := -I$(LIBOGC_INC)/SDL
|
|
||||||
SDL_LIB := $(DEVKITPRO)/libogc/lib/wii
|
|
||||||
INCLUDE := -I$(LIBOGC_INC) $(SDL_CPPFLAGS) -I$(PORTLIBS_INC)
|
|
||||||
|
|
||||||
PKG_CONFIG_PATH := $(PORTLIBS)/lib/pkgconfig
|
|
||||||
PKG_BROKEN_SWTICH := --static --define-variable=DEVKITPRO=$(DEVKITPRO)
|
|
||||||
PNG_PKGCONFIG := $(PKG_CONFIG_PATH)/libpng.pc $(PKG_BROKEN_SWTICH)
|
|
||||||
ZLIB_PKGCONFIG := $(PKG_CONFIG_PATH)/zlib.pc $(PKG_BROKEN_SWTICH)
|
|
||||||
|
|
||||||
ZLIB_CFLAGS?=$(shell $(PKG_CONFIG) $(ZLIB_PKGCONFIG) --cflags)
|
|
||||||
ZLIB_LDFLAGS?=$(shell $(PKG_CONFIG) $(ZLIB_PKGCONFIG) --libs)
|
|
||||||
|
|
||||||
ifdef RDB
|
|
||||||
LIBS+=-ldb
|
|
||||||
OPTS+=-DREMOTE_DEBUGGING=$(RDB)
|
|
||||||
endif
|
|
||||||
|
|
||||||
LIBS+= -L$(SDL_LIB)
|
|
||||||
ifndef NOMIXER
|
|
||||||
LD=$(CXX)
|
|
||||||
LIBS+=-lSDL_mixer -lvorbisidec -lsmpeg
|
|
||||||
endif
|
|
||||||
LIBS+=-lSDL
|
|
||||||
|
|
||||||
LIBS+=$(ZLIB_LDFLAGS) -lfat -lwiiuse -lbte -logc -lm -lwiikeyboard -L$(LIBOGC_LIB)
|
|
||||||
|
|
||||||
MACHDEP = -DGEKKO -mrvl -mcpu=750 -meabi -mhard-float
|
|
||||||
OPTS+=-DWII -D_WII -DUNIXCOMMON
|
|
||||||
CFLAGS+=-D__BIG_ENDIAN__ -g -O3 -fsigned-char $(MACHDEP) $(INCLUDE)
|
|
||||||
CXXFLAGS+=$(CFLAGS)
|
|
||||||
LDFLAGS+=-g $(MACHDEP) -Wl,-Map,$(notdir $@).map
|
|
||||||
|
|
||||||
SDL_CONFIG=/bin/true
|
|
||||||
SDL_CFLAGS=
|
|
||||||
SDL_LDFLAGS=
|
|
||||||
|
|
||||||
$(BIN)/$(DOLNAME): $(BIN)/$(EXENAME)
|
|
||||||
@echo Linking $(DOLNAME)...
|
|
||||||
$(ELF2DOL) $(BIN)/$(EXENAME) $(BIN)/$(DOLNAME)
|
|
||||||
@echo Creating /apps/$(SRB2NAME)...
|
|
||||||
$(MKDIR) $(APPDIR)
|
|
||||||
$(CP) $(BIN)/$(DOLNAME) $(APPDIR)/boot.dol
|
|
||||||
$(CP) $(ICONPNG) $(APPDIR)
|
|
||||||
$(CP) $(METAXML) $(APPDIR)
|
|
||||||
ifdef WITHDATA
|
|
||||||
$(MKDIR) srb2wii
|
|
||||||
$(FOR) datafile in $(shell echo $(D_FILES) | $(SHSED) -e 's/\.srb/\.wad/' -e 's/music.dta//' | $(SHXARGS) -n 1 basename); do \
|
|
||||||
$(WGET) http://alam.srb2.org/SRB2/2.0.6-Final/Resources/$$datafile; \
|
|
||||||
done
|
|
||||||
# downsampled music.dta specially for SRB2Wii
|
|
||||||
$(WGET) http://repos.srb2.org/srb2ports/music.dta
|
|
||||||
$(ZIP) $(BIN)/$(ZIPNAME) $(APPDIR) srb2wii
|
|
||||||
else
|
|
||||||
$(ZIP) $(BIN)/$(ZIPNAME) $(APPDIR)
|
|
||||||
endif
|
|
||||||
$(REMOVE) -r $(APPDIR)
|
|
||||||
|
|
||||||
run: $(BIN)/$(EXENAME)
|
|
||||||
$(WIILOADEXE) $(BIN)/$(DBGNAME)
|
|
Binary file not shown.
Before Width: | Height: | Size: 11 KiB |
|
@ -1,18 +0,0 @@
|
||||||
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
|
||||||
<app version="1">
|
|
||||||
<name>SRB2Wii</name>
|
|
||||||
<coder>Callum</coder>
|
|
||||||
<version>2.0.6</version>
|
|
||||||
<release_date>20101207</release_date>
|
|
||||||
<short_description>A 3D Sonic fangame</short_description>
|
|
||||||
<long_description>Sonic Robo Blast 2 is a 3D fangame by a small group called
|
|
||||||
Sonic Team Junior, using the Doom engine as a base.
|
|
||||||
The game has been worked on for almost 11 years so far, and
|
|
||||||
it is still being very much developed today, with a huge
|
|
||||||
fanbase developing custom content, including characters,
|
|
||||||
levels, and even large-scale modifications that play out
|
|
||||||
a brand new adventure.
|
|
||||||
Based on the Doom II engine, SRB2's system requirements
|
|
||||||
are very low, even the oldest computers can play it at a
|
|
||||||
decent speed.</long_description>
|
|
||||||
</app>
|
|
|
@ -1,44 +0,0 @@
|
||||||
#
|
|
||||||
# Makefile.cfg for SRB2/XBOX
|
|
||||||
#
|
|
||||||
|
|
||||||
#
|
|
||||||
#hmmm, the XBOX
|
|
||||||
#
|
|
||||||
|
|
||||||
NOHW=1 #No working OpenGL right now
|
|
||||||
NOHS=1 #No HWSound right now
|
|
||||||
NOASM=1 #No Fast code
|
|
||||||
NONET=1 #No network code
|
|
||||||
NOMD5=1 #No Slow MD5
|
|
||||||
NOPNG=1 #No Screenshot
|
|
||||||
#SDLMAIN=1 #SDLMain!
|
|
||||||
|
|
||||||
ifndef OPENXDK
|
|
||||||
OPENXDK=/usr/local/openxdk
|
|
||||||
endif
|
|
||||||
|
|
||||||
CXBE=$(OPENXDK)/bin/cxbe
|
|
||||||
|
|
||||||
ifdef ECHO
|
|
||||||
CXBE:=@$(CXBE)
|
|
||||||
endif
|
|
||||||
|
|
||||||
ifndef NOHW
|
|
||||||
OPTS+=-DMINI_GL_COMPATIBILITY
|
|
||||||
endif
|
|
||||||
|
|
||||||
BUILTLM=-fno-builtin
|
|
||||||
CFLAGS+=-D_XBOX -std=gnu99 -ffreestanding $(BUILTLM) -fno-exceptions
|
|
||||||
CFLAGS+=-I$(OPENXDK)/i386-pc-xbox/include -I$(OPENXDK)/include
|
|
||||||
OPTS+=-nostdlib -mno-cygwin -march=i386
|
|
||||||
LDFLAGS+=-nostdlib -Wl,--file-alignment,0x20 -Wl,--section-alignment,0x20 -shared -Wl,--entry,_WinMainCRTStartup -Wl,--strip-all -L$(OPENXDK)/i386-pc-xbox/lib -L$(OPENXDK)/lib
|
|
||||||
LIBS=-lg -lc -lm
|
|
||||||
SDL_CFLAGS?=-I$(OPENXDK)/include/SDL
|
|
||||||
SDL_LDFLAGS?=-lSDL -lopenxdk -lhal -lc -lhal -lusb -lhal -lc -lxboxkrnl
|
|
||||||
|
|
||||||
i_system_o+=$(OBJDIR)/xboxhelp.o
|
|
||||||
|
|
||||||
# name of the exefile
|
|
||||||
EXENAME?=SRB2XBOX.EXE
|
|
||||||
BINNAME?=default.xbe
|
|
|
@ -1,91 +0,0 @@
|
||||||
// Emacs style mode select -*- C++ -*-
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
//
|
|
||||||
// Copyright (C) 2004 by Sonic Team Jr.
|
|
||||||
//
|
|
||||||
// This program 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.
|
|
||||||
//
|
|
||||||
// DESCRIPTION:
|
|
||||||
// stub and replacement "ANSI" C functions for use under OpenXDK
|
|
||||||
//
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
|
|
||||||
#include "../../doomdef.h"
|
|
||||||
#include "xboxhelp.h"
|
|
||||||
#ifdef __GNUC__
|
|
||||||
#include <unistd.h>
|
|
||||||
#else
|
|
||||||
#include <stdlib.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
char *getcwd(char *_buf, size_t _size )
|
|
||||||
{
|
|
||||||
(void)_buf;
|
|
||||||
(void)_size;
|
|
||||||
return _buf;
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef _MSC_VER
|
|
||||||
int mkdir(const char *path)
|
|
||||||
{
|
|
||||||
(void)path;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
#elif 0 //__GNUC__?
|
|
||||||
int mkdir(const char *path, mode_t _mode)
|
|
||||||
{
|
|
||||||
(void)path;
|
|
||||||
(void)_mode;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
int chdir (const char *__path )
|
|
||||||
{
|
|
||||||
(void)__path;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
time_t time(time_t *T)
|
|
||||||
{
|
|
||||||
long returntime = 0;
|
|
||||||
(void)T;
|
|
||||||
/*
|
|
||||||
SYSTEMTIME st;
|
|
||||||
FILETIME stft;
|
|
||||||
INT64 ftli;
|
|
||||||
if (!T) return returntime;
|
|
||||||
GetSystemTime(&st);
|
|
||||||
SystemTimeToFileTime(&st,&stft);
|
|
||||||
CopyMemory(&ftli,&stft,sizeof (LARGE_INTEGER));
|
|
||||||
returntime = (long)ftli;
|
|
||||||
*T = returntime;
|
|
||||||
*/
|
|
||||||
return returntime;
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef _MSC_VER
|
|
||||||
#include <RtcApi.h>
|
|
||||||
void __cdecl _RTC_Initialize(void)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
char *getenv(const char *__env)
|
|
||||||
{
|
|
||||||
__env = NULL;
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
int putenv(const char *__env)
|
|
||||||
{
|
|
||||||
__env = NULL;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
#endif
|
|
|
@ -1,6 +0,0 @@
|
||||||
#if defined (_MSC_VER)
|
|
||||||
int access(const char *path, int amode);
|
|
||||||
char *getcwd(char *_buf, size_t _size );
|
|
||||||
int mkdir(const char *path);
|
|
||||||
int chdir (const char *__path );
|
|
||||||
#endif
|
|
|
@ -96,7 +96,7 @@
|
||||||
<ClCompile>
|
<ClCompile>
|
||||||
<Optimization>Disabled</Optimization>
|
<Optimization>Disabled</Optimization>
|
||||||
<AdditionalIncludeDirectories>$(ProjectDir)..\..\libs\libpng-src;$(ProjectDir)..\..\libs\zlib;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
<AdditionalIncludeDirectories>$(ProjectDir)..\..\libs\libpng-src;$(ProjectDir)..\..\libs\zlib;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||||
<PreprocessorDefinitions>_DEBUG;USE_WGL_SWAP;DIRECTFULLSCREEN;SDL;HWRENDER;HW3SOUND;HAVE_FILTER;HAVE_MIXER;USEASM;HAVE_PNG;COMPVERSION;HAVE_BLUA;_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_DEPRECATE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
<PreprocessorDefinitions>_DEBUG;USE_WGL_SWAP;DIRECTFULLSCREEN;HAVE_SDL;HWRENDER;HW3SOUND;HAVE_FILTER;HAVE_MIXER;USEASM;HAVE_PNG;COMPVERSION;HAVE_BLUA;_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_DEPRECATE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
<MinimalRebuild>true</MinimalRebuild>
|
<MinimalRebuild>true</MinimalRebuild>
|
||||||
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
|
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
|
||||||
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
|
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
|
||||||
|
@ -145,7 +145,7 @@
|
||||||
<ClCompile>
|
<ClCompile>
|
||||||
<Optimization>Disabled</Optimization>
|
<Optimization>Disabled</Optimization>
|
||||||
<AdditionalIncludeDirectories>$(ProjectDir)..\..\libs\libpng-src;$(ProjectDir)..\..\libs\zlib;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
<AdditionalIncludeDirectories>$(ProjectDir)..\..\libs\libpng-src;$(ProjectDir)..\..\libs\zlib;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||||
<PreprocessorDefinitions>_DEBUG;USE_WGL_SWAP;DIRECTFULLSCREEN;SDL;HWRENDER;HW3SOUND;HAVE_FILTER;HAVE_MIXER;HAVE_PNG;COMPVERSION;HAVE_BLUA;_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_DEPRECATE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
<PreprocessorDefinitions>_DEBUG;USE_WGL_SWAP;DIRECTFULLSCREEN;HAVE_SDL;HWRENDER;HW3SOUND;HAVE_FILTER;HAVE_MIXER;HAVE_PNG;COMPVERSION;HAVE_BLUA;_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_DEPRECATE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
<MinimalRebuild>true</MinimalRebuild>
|
<MinimalRebuild>true</MinimalRebuild>
|
||||||
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
|
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
|
||||||
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
|
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
|
||||||
|
@ -202,7 +202,7 @@
|
||||||
<FavorSizeOrSpeed>Speed</FavorSizeOrSpeed>
|
<FavorSizeOrSpeed>Speed</FavorSizeOrSpeed>
|
||||||
<OmitFramePointers>true</OmitFramePointers>
|
<OmitFramePointers>true</OmitFramePointers>
|
||||||
<AdditionalIncludeDirectories>$(ProjectDir)..\..\libs\libpng-src;$(ProjectDir)..\..\libs\zlib;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
<AdditionalIncludeDirectories>$(ProjectDir)..\..\libs\libpng-src;$(ProjectDir)..\..\libs\zlib;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||||
<PreprocessorDefinitions>NDEBUG;SDLMAIN;NO_STDIO_REDIRECT;USE_WGL_SWAP;DIRECTFULLSCREEN;SDL;HWRENDER;HW3SOUND;HAVE_FILTER;HAVE_MIXER;USEASM;HAVE_PNG;COMPVERSION;HAVE_BLUA;_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_DEPRECATE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
<PreprocessorDefinitions>NDEBUG;SDLMAIN;NO_STDIO_REDIRECT;USE_WGL_SWAP;DIRECTFULLSCREEN;HAVE_SDL;HWRENDER;HW3SOUND;HAVE_FILTER;HAVE_MIXER;USEASM;HAVE_PNG;COMPVERSION;HAVE_BLUA;_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_DEPRECATE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
<StringPooling>true</StringPooling>
|
<StringPooling>true</StringPooling>
|
||||||
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
||||||
<PrecompiledHeaderOutputFile>.\..\..\objs\VC10\$(Platform)\$(Configuration)\SDL\Srb2SDL-vc9.pch</PrecompiledHeaderOutputFile>
|
<PrecompiledHeaderOutputFile>.\..\..\objs\VC10\$(Platform)\$(Configuration)\SDL\Srb2SDL-vc9.pch</PrecompiledHeaderOutputFile>
|
||||||
|
@ -258,7 +258,7 @@
|
||||||
<FavorSizeOrSpeed>Speed</FavorSizeOrSpeed>
|
<FavorSizeOrSpeed>Speed</FavorSizeOrSpeed>
|
||||||
<OmitFramePointers>true</OmitFramePointers>
|
<OmitFramePointers>true</OmitFramePointers>
|
||||||
<AdditionalIncludeDirectories>$(ProjectDir)..\..\libs\libpng-src;$(ProjectDir)..\..\libs\zlib;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
<AdditionalIncludeDirectories>$(ProjectDir)..\..\libs\libpng-src;$(ProjectDir)..\..\libs\zlib;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||||
<PreprocessorDefinitions>NDEBUG;SDLMAIN;NO_STDIO_REDIRECT;USE_WGL_SWAP;DIRECTFULLSCREEN;SDL;HWRENDER;HW3SOUND;HAVE_FILTER;HAVE_MIXER;HAVE_PNG;COMPVERSION;HAVE_BLUA;_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_DEPRECATE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
<PreprocessorDefinitions>NDEBUG;SDLMAIN;NO_STDIO_REDIRECT;USE_WGL_SWAP;DIRECTFULLSCREEN;HAVE_SDL;HWRENDER;HW3SOUND;HAVE_FILTER;HAVE_MIXER;HAVE_PNG;COMPVERSION;HAVE_BLUA;_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_DEPRECATE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
<StringPooling>true</StringPooling>
|
<StringPooling>true</StringPooling>
|
||||||
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
||||||
<PrecompiledHeaderOutputFile>.\..\..\objs\VC10\$(Platform)\$(Configuration)\SDL\Srb2SDL-vc9.pch</PrecompiledHeaderOutputFile>
|
<PrecompiledHeaderOutputFile>.\..\..\objs\VC10\$(Platform)\$(Configuration)\SDL\Srb2SDL-vc9.pch</PrecompiledHeaderOutputFile>
|
||||||
|
@ -1461,4 +1461,4 @@
|
||||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||||
<ImportGroup Label="ExtensionTargets">
|
<ImportGroup Label="ExtensionTargets">
|
||||||
</ImportGroup>
|
</ImportGroup>
|
||||||
</Project>
|
</Project>
|
||||||
|
|
|
@ -50,7 +50,7 @@
|
||||||
Name="VCCLCompilerTool"
|
Name="VCCLCompilerTool"
|
||||||
Optimization="0"
|
Optimization="0"
|
||||||
AdditionalIncludeDirectories=""$(ProjectDir)..\..\libs\libpng-src";"$(ProjectDir)..\..\libs\zlib""
|
AdditionalIncludeDirectories=""$(ProjectDir)..\..\libs\libpng-src";"$(ProjectDir)..\..\libs\zlib""
|
||||||
PreprocessorDefinitions="_DEBUG;USE_WGL_SWAP;DIRECTFULLSCREEN;SDL;HWRENDER;HW3SOUND;HAVE_FILTER;HAVE_MIXER;USEASM;HAVE_PNG;HAVE_BLUA;_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_DEPRECATE"
|
PreprocessorDefinitions="_DEBUG;USE_WGL_SWAP;DIRECTFULLSCREEN;HAVE_SDL;HWRENDER;HW3SOUND;HAVE_FILTER;HAVE_MIXER;USEASM;HAVE_PNG;HAVE_BLUA;_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_DEPRECATE"
|
||||||
MinimalRebuild="true"
|
MinimalRebuild="true"
|
||||||
BasicRuntimeChecks="3"
|
BasicRuntimeChecks="3"
|
||||||
RuntimeLibrary="1"
|
RuntimeLibrary="1"
|
||||||
|
@ -145,7 +145,7 @@
|
||||||
Name="VCCLCompilerTool"
|
Name="VCCLCompilerTool"
|
||||||
Optimization="0"
|
Optimization="0"
|
||||||
AdditionalIncludeDirectories=""$(ProjectDir)..\..\libs\libpng-src";"$(ProjectDir)..\..\libs\zlib""
|
AdditionalIncludeDirectories=""$(ProjectDir)..\..\libs\libpng-src";"$(ProjectDir)..\..\libs\zlib""
|
||||||
PreprocessorDefinitions="_DEBUG;USE_WGL_SWAP;DIRECTFULLSCREEN;SDL;HWRENDER;HW3SOUND;HAVE_FILTER;HAVE_MIXER;HAVE_PNG;HAVE_BLUA;_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_DEPRECATE"
|
PreprocessorDefinitions="_DEBUG;USE_WGL_SWAP;DIRECTFULLSCREEN;HAVE_SDL;HWRENDER;HW3SOUND;HAVE_FILTER;HAVE_MIXER;HAVE_PNG;HAVE_BLUA;_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_DEPRECATE"
|
||||||
MinimalRebuild="true"
|
MinimalRebuild="true"
|
||||||
BasicRuntimeChecks="3"
|
BasicRuntimeChecks="3"
|
||||||
RuntimeLibrary="1"
|
RuntimeLibrary="1"
|
||||||
|
@ -248,7 +248,7 @@
|
||||||
FavorSizeOrSpeed="1"
|
FavorSizeOrSpeed="1"
|
||||||
OmitFramePointers="true"
|
OmitFramePointers="true"
|
||||||
AdditionalIncludeDirectories=""$(ProjectDir)..\..\libs\libpng-src";"$(ProjectDir)..\..\libs\zlib""
|
AdditionalIncludeDirectories=""$(ProjectDir)..\..\libs\libpng-src";"$(ProjectDir)..\..\libs\zlib""
|
||||||
PreprocessorDefinitions="NDEBUG;SDLMAIN;NO_STDIO_REDIRECT;USE_WGL_SWAP;DIRECTFULLSCREEN;SDL;HWRENDER;HW3SOUND;HAVE_FILTER;HAVE_MIXER;USEASM;HAVE_PNG;HAVE_BLUA;_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_DEPRECATE"
|
PreprocessorDefinitions="NDEBUG;SDLMAIN;NO_STDIO_REDIRECT;USE_WGL_SWAP;DIRECTFULLSCREEN;HAVE_SDL;HWRENDER;HW3SOUND;HAVE_FILTER;HAVE_MIXER;USEASM;HAVE_PNG;HAVE_BLUA;_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_DEPRECATE"
|
||||||
StringPooling="true"
|
StringPooling="true"
|
||||||
RuntimeLibrary="0"
|
RuntimeLibrary="0"
|
||||||
PrecompiledHeaderFile=".\..\..\objs\VC9\$(Platform)\$(Configuration)\SDL\Srb2SDL-vc9.pch"
|
PrecompiledHeaderFile=".\..\..\objs\VC9\$(Platform)\$(Configuration)\SDL\Srb2SDL-vc9.pch"
|
||||||
|
@ -350,7 +350,7 @@
|
||||||
FavorSizeOrSpeed="1"
|
FavorSizeOrSpeed="1"
|
||||||
OmitFramePointers="true"
|
OmitFramePointers="true"
|
||||||
AdditionalIncludeDirectories=""$(ProjectDir)..\..\libs\libpng-src";"$(ProjectDir)..\..\libs\zlib""
|
AdditionalIncludeDirectories=""$(ProjectDir)..\..\libs\libpng-src";"$(ProjectDir)..\..\libs\zlib""
|
||||||
PreprocessorDefinitions="NDEBUG;SDLMAIN;NO_STDIO_REDIRECT;USE_WGL_SWAP;DIRECTFULLSCREEN;SDL;HWRENDER;HW3SOUND;HAVE_FILTER;HAVE_MIXER;HAVE_PNG;HAVE_BLUA;_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_DEPRECATE"
|
PreprocessorDefinitions="NDEBUG;SDLMAIN;NO_STDIO_REDIRECT;USE_WGL_SWAP;DIRECTFULLSCREEN;HAVE_SDL;HWRENDER;HW3SOUND;HAVE_FILTER;HAVE_MIXER;HAVE_PNG;HAVE_BLUA;_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_DEPRECATE"
|
||||||
StringPooling="true"
|
StringPooling="true"
|
||||||
RuntimeLibrary="0"
|
RuntimeLibrary="0"
|
||||||
PrecompiledHeaderFile=".\..\..\objs\VC9\$(Platform)\$(Configuration)\SDL\Srb2SDL-vc9.pch"
|
PrecompiledHeaderFile=".\..\..\objs\VC9\$(Platform)\$(Configuration)\SDL\Srb2SDL-vc9.pch"
|
||||||
|
|
|
@ -45,7 +45,7 @@ MTL=midl.exe
|
||||||
# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
|
# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
|
||||||
# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
|
# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
|
||||||
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
|
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
|
||||||
# ADD CPP /nologo /G5 /W3 /GX /Zi /Ot /Og /Oi /Op /Oy /Ob1 /I "..\..\libs\libpng-src" /I "..\..\libs\zlib" /D "NDEBUG" /D "SDLMAIN" /D "NO_STDIO_REDIRECT" /D "USE_WGL_SWAP" /D "DIRECTFULLSCREEN" /D "SDL" /D "HWRENDER" /D "HW3SOUND" /D "HAVE_FILTER" /D "HAVE_MIXER" /D "USEASM" /D "HAVE_PNG" /FR /FD /GF /c
|
# ADD CPP /nologo /G5 /W3 /GX /Zi /Ot /Og /Oi /Op /Oy /Ob1 /I "..\..\libs\libpng-src" /I "..\..\libs\zlib" /D "NDEBUG" /D "SDLMAIN" /D "NO_STDIO_REDIRECT" /D "USE_WGL_SWAP" /D "DIRECTFULLSCREEN" /D "HAVE_SDL" /D "HWRENDER" /D "HW3SOUND" /D "HAVE_FILTER" /D "HAVE_MIXER" /D "USEASM" /D "HAVE_PNG" /FR /FD /GF /c
|
||||||
# ADD BASE RSC /l 0x409 /d "NDEBUG"
|
# ADD BASE RSC /l 0x409 /d "NDEBUG"
|
||||||
# ADD RSC /l 0x409 /d "NDEBUG"
|
# ADD RSC /l 0x409 /d "NDEBUG"
|
||||||
# SUBTRACT RSC /x
|
# SUBTRACT RSC /x
|
||||||
|
@ -72,7 +72,7 @@ LINK32=link.exe
|
||||||
# PROP Target_Dir ""
|
# PROP Target_Dir ""
|
||||||
MTL=midl.exe
|
MTL=midl.exe
|
||||||
# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c
|
# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c
|
||||||
# ADD CPP /nologo /G6 /W4 /WX /Gm /GX /ZI /Od /Op /I "..\..\libs\libpng-src" /I "..\..\libs\zlib" /D "_DEBUG" /D "USE_WGL_SWAP" /D "DIRECTFULLSCREEN" /D "SDL" /D "HWRENDER" /D "HW3SOUND" /D "HAVE_FILTER" /D "HAVE_MIXER" /D "USEASM" /D "HAVE_PNG" /FR /FD /GZ /c
|
# ADD CPP /nologo /G6 /W4 /WX /Gm /GX /ZI /Od /Op /I "..\..\libs\libpng-src" /I "..\..\libs\zlib" /D "_DEBUG" /D "USE_WGL_SWAP" /D "DIRECTFULLSCREEN" /D "HAVE_SDL" /D "HWRENDER" /D "HW3SOUND" /D "HAVE_FILTER" /D "HAVE_MIXER" /D "USEASM" /D "HAVE_PNG" /FR /FD /GZ /c
|
||||||
# SUBTRACT CPP /YX
|
# SUBTRACT CPP /YX
|
||||||
# ADD BASE RSC /l 0x409 /d "_DEBUG"
|
# ADD BASE RSC /l 0x409 /d "_DEBUG"
|
||||||
# ADD RSC /l 0x409 /d "_DEBUG"
|
# ADD RSC /l 0x409 /d "_DEBUG"
|
||||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -1,212 +0,0 @@
|
||||||
#ifndef __FILTERS_H__
|
|
||||||
#define __FILTERS_H__
|
|
||||||
|
|
||||||
#ifdef _MSC_VER
|
|
||||||
#pragma warning(disable : 4514 4214 4244)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "SDL.h"
|
|
||||||
|
|
||||||
#ifdef _MSC_VER
|
|
||||||
#pragma warning(default : 4214 4244)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
typedef enum {
|
|
||||||
FILTER_2XSAI = 0,
|
|
||||||
FILTER_SUPER2XSAI,
|
|
||||||
FILTER_SUPEREAGLE,
|
|
||||||
FILTER_ADVMAME2X ,
|
|
||||||
FILTER_TV2X ,
|
|
||||||
FILTER_NORMAL2X ,
|
|
||||||
FILTER_BILINEAR ,
|
|
||||||
FILTER_DOTMATRIX ,
|
|
||||||
FILTER_NUM ,
|
|
||||||
} t_filter;
|
|
||||||
|
|
||||||
typedef void (*filter_2)(Uint8 *srcPtr, Uint32 srcPitch, Uint8 *dstPtr, Uint32 dstPitch, int width, int height);
|
|
||||||
SDL_Surface *filter_2x(SDL_Surface *src, SDL_Rect *srcclp, filter_2 filter);
|
|
||||||
SDL_Surface *filter_2xe(SDL_Surface *src, SDL_Rect *srcclp, filter_2 filter,Uint8 R, Uint8 G, Uint8 B);
|
|
||||||
//Alam_GBC: Header file based on sms_sdl's filter.h
|
|
||||||
//Note: need 3 lines at the bottom and top?
|
|
||||||
|
|
||||||
//int filter_init_2xsai(SDL_PixelFormat *BitFormat);
|
|
||||||
#define FILTER(src,dst) (Uint8 *)(src->pixels)+src->pitch*3, (Uint32)src->pitch, (Uint8 *)dst->pixels, (Uint32)dst->pitch, src->w, src->h-6
|
|
||||||
#define SDLFILTER(src,dst) (Uint8 *)src->pixels, (Uint32)src->pitch, (Uint8 *)dst->pixels, (Uint32)dst->pitch, src->w, src->h
|
|
||||||
int filter_init_2xsai(SDL_PixelFormat *BitFormat); //unless?
|
|
||||||
void filter_scan50(Uint8 *srcPtr, Uint32 srcPitch, Uint8 *dstPtr, Uint32 dstPitch, int width, int height);
|
|
||||||
void filter_scan100(Uint8 *srcPtr, Uint32 srcPitch, Uint8 *dstPtr, Uint32 dstPitch, int width, int height);
|
|
||||||
|
|
||||||
void filter_2xsai(Uint8 *srcPtr, Uint32 srcPitch, Uint8 *dstPtr, Uint32 dstPitch, int width, int height);
|
|
||||||
void filter_super2xsai(Uint8 *srcPtr, Uint32 srcPitch, Uint8 *dstPtr, Uint32 dstPitch, int width, int height);
|
|
||||||
void filter_supereagle(Uint8 *srcPtr, Uint32 srcPitch, Uint8 *dstPtr, Uint32 dstPitch, int width, int height);
|
|
||||||
void filter_advmame2x(Uint8 *srcPtr, Uint32 srcPitch, Uint8 *dstPtr, Uint32 dstPitch, int width, int height);
|
|
||||||
void filter_tv2x(Uint8 *srcPtr, Uint32 srcPitch, Uint8 *dstPtr, Uint32 dstPitch, int width, int height);
|
|
||||||
void filter_normal2x(Uint8 *srcPtr, Uint32 srcPitch, Uint8 *dstPtr, Uint32 dstPitch, int width, int height);
|
|
||||||
void filter_bilinear(Uint8 *srcPtr, Uint32 srcPitch, Uint8 *dstPtr, Uint32 dstPitch, int width, int height);
|
|
||||||
void filter_dotmatrix(Uint8 *srcPtr, Uint32 srcPitch, Uint8 *dstPtr, Uint32 dstPitch, int width, int height);
|
|
||||||
void filter_bicubic(Uint8 *srcPtr, Uint32 srcPitch, Uint8 *dstPtr, Uint32 dstPitch, int width, int height);
|
|
||||||
void lq2x16(Uint8 *srcPtr, Uint32 srcPitch, Uint8 *dstPtr, Uint32 dstPitch, int width, int height);
|
|
||||||
void hq2x16(Uint8 *srcPtr, Uint32 srcPitch, Uint8 *dstPtr, Uint32 dstPitch, int width, int height);
|
|
||||||
|
|
||||||
void filter_hq2x(Uint8 *srcPtr, Uint32 srcPitch, Uint8 *dstPtr, Uint32 dstPitch, int width, int height);
|
|
||||||
void lq2x32(Uint8 *srcPtr, Uint32 srcPitch, Uint8 *dstPtr, Uint32 dstPitch, int width, int height);
|
|
||||||
void hq2x32(Uint8 *srcPtr, Uint32 srcPitch, Uint8 *dstPtr, Uint32 dstPitch, int width, int height);
|
|
||||||
|
|
||||||
#ifdef FILTERS
|
|
||||||
typedef struct filter_s { filter_2 filter; int bpp; } filter_t;
|
|
||||||
#define NUMFILTERS 13
|
|
||||||
static filter_t filtermode[NUMFILTERS+1] = {
|
|
||||||
{NULL , 0}, //None
|
|
||||||
{filter_normal2x , 16}, //2xNormal
|
|
||||||
{filter_advmame2x , 16}, //AdvMAME2x
|
|
||||||
{filter_tv2x , 16}, //TV2x
|
|
||||||
{filter_bilinear , 16}, //Bilinear
|
|
||||||
{filter_dotmatrix , 16}, //DotMatrix
|
|
||||||
{lq2x16 , 16}, //16LQ2x
|
|
||||||
{hq2x16 , 16}, //16HQ2x
|
|
||||||
{lq2x32 , 32}, //32LQ2x
|
|
||||||
{hq2x32 , 32}, //32HQ2x
|
|
||||||
// {filter_bicubic , 16}, //Slow Bicubic
|
|
||||||
// BAD
|
|
||||||
{filter_2xsai , 16}, //2xSAI
|
|
||||||
{filter_super2xsai, 16}, //Super2xSAI
|
|
||||||
{filter_supereagle, 16}, //SuperEagle
|
|
||||||
};
|
|
||||||
CV_PossibleValue_t CV_Filters[] = {{ 0, "None"}, { 1, "2xNormal"},
|
|
||||||
{ 2, "AdvMAME2x"}, { 3, "TV2x"}, { 4, "Bilinear"} , { 5, "DotMatrix"},
|
|
||||||
{ 6, "16LQ2x"}, { 7, "16HQ2x"}, { 8, "32LQ2x"} , { 9, "32HQ2x"},
|
|
||||||
{10, "2xSAI"}, {11, "Super2xSAI"}, {12, "SuperEagle"}, {0, NULL},};
|
|
||||||
static void Filterchange(void);
|
|
||||||
consvar_t cv_filter = {"filter", "None", CV_CALL|CV_NOINIT, CV_Filters,Filterchange,0,NULL,NULL,0,0,NULL};
|
|
||||||
static filter_2 blitfilter = NULL;
|
|
||||||
static SDL_Surface *preSurface = NULL;
|
|
||||||
static SDL_Surface *f2xSurface = NULL;
|
|
||||||
|
|
||||||
static void Filterchange(void)
|
|
||||||
{
|
|
||||||
if(blitfilter) // only filtering?
|
|
||||||
{
|
|
||||||
int i=0;
|
|
||||||
for(;i < NUMFILTERS; i++)//find old filter
|
|
||||||
{
|
|
||||||
if(filtermode[i].filter == blitfilter) //Found it
|
|
||||||
break; //Stop
|
|
||||||
}
|
|
||||||
if(i < NUMFILTERS && filtermode[i].bpp == filtermode[cv_filter.value].bpp) //Easy to swap?
|
|
||||||
blitfilter = filtermode[cv_filter.value].filter; // Swap with new filter
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
FUNCINLINE static ATTRINLINE void FilterBlit(SDL_Surface *froSurface)
|
|
||||||
{
|
|
||||||
if(froSurface && blitfilter && preSurface && f2xSurface)
|
|
||||||
{
|
|
||||||
SDL_Rect dstclp = {0,3,0,0};
|
|
||||||
int lockedpre = 0, lockedf2x = 0, blitpre = 0;
|
|
||||||
blitpre = SDL_BlitSurface(froSurface,NULL,preSurface,&dstclp);
|
|
||||||
if(SDL_MUSTLOCK(preSurface)) lockedpre = SDL_LockSurface(preSurface);
|
|
||||||
if(SDL_MUSTLOCK(f2xSurface)) lockedf2x = SDL_LockSurface(f2xSurface);
|
|
||||||
if(lockedpre == 0 && preSurface->pixels && lockedf2x == 0 && f2xSurface->pixels && blitpre == 0)
|
|
||||||
{
|
|
||||||
blitfilter(FILTER(preSurface,f2xSurface));
|
|
||||||
if(SDL_MUSTLOCK(preSurface)) SDL_UnlockSurface(preSurface);
|
|
||||||
if(SDL_MUSTLOCK(f2xSurface)) SDL_UnlockSurface(f2xSurface);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
blitfilter = NULL;
|
|
||||||
if(preSurface) SDL_FreeSurface(preSurface);
|
|
||||||
preSurface = NULL;
|
|
||||||
if(f2xSurface) SDL_FreeSurface(f2xSurface);
|
|
||||||
f2xSurface = NULL;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
FUNCINLINE static ATTRINLINE int Setupf2x(int width, int height, int bpp)
|
|
||||||
{
|
|
||||||
blitfilter = NULL;
|
|
||||||
if(preSurface) SDL_FreeSurface(preSurface);
|
|
||||||
preSurface = NULL;
|
|
||||||
if(f2xSurface) SDL_FreeSurface(f2xSurface);
|
|
||||||
f2xSurface = NULL;
|
|
||||||
if( !(width%2) && !(height%2) && width >= BASEVIDWIDTH*2 && height >= BASEVIDHEIGHT*2 && cv_filter.value
|
|
||||||
&& cv_filter.value <= NUMFILTERS && filtermode[cv_filter.value].filter && filtermode[cv_filter.value].bpp)
|
|
||||||
{
|
|
||||||
int hwidth = width/2 + 6;
|
|
||||||
int heighth = height/2 + 6;
|
|
||||||
int hbpp = filtermode[cv_filter.value].bpp;
|
|
||||||
switch(hbpp)
|
|
||||||
{
|
|
||||||
case 8:
|
|
||||||
preSurface = SDL_CreateRGBSurface(SDL_SWSURFACE,hwidth,heighth, 8,0x00000000,0x00000000,0x00000000,0x00);
|
|
||||||
f2xSurface = SDL_CreateRGBSurface(SDL_HWSURFACE, width,height , 8,0x00000000,0x00000000,0x00000000,0x00);
|
|
||||||
case 15:
|
|
||||||
preSurface = SDL_CreateRGBSurface(SDL_SWSURFACE,hwidth,heighth,15,0x00007C00,0x000003E0,0x0000001F,0x00);
|
|
||||||
f2xSurface = SDL_CreateRGBSurface(SDL_HWSURFACE, width,height ,15,0x00007C00,0x000003E0,0x0000001F,0x00);
|
|
||||||
break;
|
|
||||||
case 16:
|
|
||||||
preSurface = SDL_CreateRGBSurface(SDL_SWSURFACE,hwidth,heighth,16,0x0000F800,0x000007E0,0x0000001F,0x00);
|
|
||||||
f2xSurface = SDL_CreateRGBSurface(SDL_HWSURFACE, width,height ,16,0x0000F800,0x000007E0,0x0000001F,0x00);
|
|
||||||
break;
|
|
||||||
case 24:
|
|
||||||
preSurface = SDL_CreateRGBSurface(SDL_SWSURFACE,hwidth,heighth,24,0x00FF0000,0x0000FF00,0x000000FF,0x00);
|
|
||||||
f2xSurface = SDL_CreateRGBSurface(SDL_HWSURFACE, width,height ,24,0x00FF0000,0x0000FF00,0x000000FF,0x00);
|
|
||||||
break;
|
|
||||||
case 32:
|
|
||||||
preSurface = SDL_CreateRGBSurface(SDL_SWSURFACE,hwidth,heighth,32,0x00FF0000,0x0000FF00,0x000000FF,0x00);
|
|
||||||
f2xSurface = SDL_CreateRGBSurface(SDL_HWSURFACE, width,height ,32,0x00FF0000,0x0000FF00,0x000000FF,0x00);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
//I_Error("Filter help");
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
if(preSurface && f2xSurface)
|
|
||||||
{
|
|
||||||
blitfilter = filtermode[cv_filter.value].filter;
|
|
||||||
if(bpp < hbpp) bpp = hbpp;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if(preSurface) SDL_FreeSurface(preSurface);
|
|
||||||
preSurface = NULL;
|
|
||||||
if(f2xSurface) SDL_FreeSurface(f2xSurface);
|
|
||||||
f2xSurface = NULL;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return bpp;
|
|
||||||
}
|
|
||||||
#else
|
|
||||||
|
|
||||||
#ifdef __GNUC__ // __attribute__ ((X))
|
|
||||||
#if (__GNUC__ > 3) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1)
|
|
||||||
#define FUNCINLINE __attribute__((always_inline))
|
|
||||||
#endif
|
|
||||||
#define FUNCNOINLINE __attribute__((noinline))
|
|
||||||
#elif defined(_MSC_VER)
|
|
||||||
#define inline __inline
|
|
||||||
#define ATTRNORETURN __declspec(noreturn)
|
|
||||||
#define ATTRINLINE __forceinline
|
|
||||||
#if _MSC_VER > 1200
|
|
||||||
#define ATTRNOINLINE __declspec(noinline)
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#ifndef FUNCINLINE
|
|
||||||
#define FUNCINLINE
|
|
||||||
#endif
|
|
||||||
#ifndef FUNCNOINLINE
|
|
||||||
#define FUNCNOINLINE
|
|
||||||
#endif
|
|
||||||
#ifndef ATTRINLINE
|
|
||||||
#define ATTRINLINE inline
|
|
||||||
#endif
|
|
||||||
#ifndef ATTRNOINLINE
|
|
||||||
#define ATTRNOINLINE
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif
|
|
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
|
@ -1,306 +0,0 @@
|
||||||
/*
|
|
||||||
* This file is part of the Advance project.
|
|
||||||
*
|
|
||||||
* Copyright (C) 2003 Andrea Mazzoleni
|
|
||||||
*
|
|
||||||
* This program 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., 675 Mass Ave, Cambridge, MA 02139, USA.
|
|
||||||
*
|
|
||||||
* In addition, as a special exception, Andrea Mazzoleni
|
|
||||||
* gives permission to link the code of this program with
|
|
||||||
* the MAME library (or with modified versions of MAME that use the
|
|
||||||
* same license as MAME), and distribute linked combinations including
|
|
||||||
* the two. You must obey the GNU General Public License in all
|
|
||||||
* respects for all of the code used other than MAME. If you modify
|
|
||||||
* this file, you may extend this exception to your version of the
|
|
||||||
* file, but you are not obligated to do so. If you do not wish to
|
|
||||||
* do so, delete this exception statement from your version.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef __INTERP_H
|
|
||||||
#define __INTERP_H
|
|
||||||
|
|
||||||
/***************************************************************************/
|
|
||||||
/* Basic types */
|
|
||||||
|
|
||||||
/***************************************************************************/
|
|
||||||
/* interpolation */
|
|
||||||
|
|
||||||
static Uint32 interp_mask[2] = {0xF81F,0x07E0};
|
|
||||||
static Uint32 interp_bits_per_pixel = 16;
|
|
||||||
|
|
||||||
#define INTERP_16_MASK_1(v) (v & interp_mask[0])
|
|
||||||
#define INTERP_16_MASK_2(v) (v & interp_mask[1])
|
|
||||||
|
|
||||||
FUNCINLINE static ATTRINLINE Uint16 interp_16_521(Uint16 p1, Uint16 p2, Uint16 p3)
|
|
||||||
{
|
|
||||||
return (Uint16)(INTERP_16_MASK_1((INTERP_16_MASK_1(p1)*5 + INTERP_16_MASK_1(p2)*2 + INTERP_16_MASK_1(p3)*1) / 8)
|
|
||||||
| INTERP_16_MASK_2((INTERP_16_MASK_2(p1)*5 + INTERP_16_MASK_2(p2)*2 + INTERP_16_MASK_2(p3)*1) / 8));
|
|
||||||
}
|
|
||||||
|
|
||||||
FUNCINLINE static ATTRINLINE Uint16 interp_16_332(Uint16 p1, Uint16 p2, Uint16 p3)
|
|
||||||
{
|
|
||||||
return (Uint16)(INTERP_16_MASK_1((INTERP_16_MASK_1(p1)*3 + INTERP_16_MASK_1(p2)*3 + INTERP_16_MASK_1(p3)*2) / 8)
|
|
||||||
| INTERP_16_MASK_2((INTERP_16_MASK_2(p1)*3 + INTERP_16_MASK_2(p2)*3 + INTERP_16_MASK_2(p3)*2) / 8));
|
|
||||||
}
|
|
||||||
|
|
||||||
FUNCINLINE static ATTRINLINE Uint16 interp_16_611(Uint16 p1, Uint16 p2, Uint16 p3)
|
|
||||||
{
|
|
||||||
return (Uint16)(INTERP_16_MASK_1((INTERP_16_MASK_1(p1)*6 + INTERP_16_MASK_1(p2) + INTERP_16_MASK_1(p3)) / 8)
|
|
||||||
| INTERP_16_MASK_2((INTERP_16_MASK_2(p1)*6 + INTERP_16_MASK_2(p2) + INTERP_16_MASK_2(p3)) / 8));
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
FUNCINLINE static ATTRINLINE Uint16 interp_16_71(Uint16 p1, Uint16 p2)
|
|
||||||
{
|
|
||||||
return (Uint16)(INTERP_16_MASK_1((INTERP_16_MASK_1(p1)*7 + INTERP_16_MASK_1(p2)) / 8)
|
|
||||||
| INTERP_16_MASK_2((INTERP_16_MASK_2(p1)*7 + INTERP_16_MASK_2(p2)) / 8));
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
FUNCINLINE static ATTRINLINE Uint16 interp_16_211(Uint16 p1, Uint16 p2, Uint16 p3)
|
|
||||||
{
|
|
||||||
return (Uint16)(INTERP_16_MASK_1((INTERP_16_MASK_1(p1)*2 + INTERP_16_MASK_1(p2) + INTERP_16_MASK_1(p3)) / 4)
|
|
||||||
| INTERP_16_MASK_2((INTERP_16_MASK_2(p1)*2 + INTERP_16_MASK_2(p2) + INTERP_16_MASK_2(p3)) / 4));
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
FUNCINLINE static ATTRINLINE Uint16 interp_16_772(Uint16 p1, Uint16 p2, Uint16 p3)
|
|
||||||
{
|
|
||||||
return (Uint16)(INTERP_16_MASK_1(((INTERP_16_MASK_1(p1) + INTERP_16_MASK_1(p2))*7 + INTERP_16_MASK_1(p3)*2) / 16)
|
|
||||||
| INTERP_16_MASK_2(((INTERP_16_MASK_2(p1) + INTERP_16_MASK_2(p2))*7 + INTERP_16_MASK_2(p3)*2) / 16));
|
|
||||||
}
|
|
||||||
|
|
||||||
FUNCINLINE static ATTRINLINE Uint16 interp_16_11(Uint16 p1, Uint16 p2)
|
|
||||||
{
|
|
||||||
return (Uint16)(INTERP_16_MASK_1((INTERP_16_MASK_1(p1) + INTERP_16_MASK_1(p2)) / 2)
|
|
||||||
| INTERP_16_MASK_2((INTERP_16_MASK_2(p1) + INTERP_16_MASK_2(p2)) / 2));
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
FUNCINLINE static ATTRINLINE Uint16 interp_16_31(Uint16 p1, Uint16 p2)
|
|
||||||
{
|
|
||||||
return (Uint16)(INTERP_16_MASK_1((INTERP_16_MASK_1(p1)*3 + INTERP_16_MASK_1(p2)) / 4)
|
|
||||||
| INTERP_16_MASK_2((INTERP_16_MASK_2(p1)*3 + INTERP_16_MASK_2(p2)) / 4));
|
|
||||||
}
|
|
||||||
|
|
||||||
FUNCINLINE static ATTRINLINE Uint16 interp_16_1411(Uint16 p1, Uint16 p2, Uint16 p3)
|
|
||||||
{
|
|
||||||
return (Uint16)(INTERP_16_MASK_1((INTERP_16_MASK_1(p1)*14 + INTERP_16_MASK_1(p2) + INTERP_16_MASK_1(p3)) / 16)
|
|
||||||
| INTERP_16_MASK_2((INTERP_16_MASK_2(p1)*14 + INTERP_16_MASK_2(p2) + INTERP_16_MASK_2(p3)) / 16));
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
FUNCINLINE static ATTRINLINE Uint16 interp_16_431(Uint16 p1, Uint16 p2, Uint16 p3)
|
|
||||||
{
|
|
||||||
return (Uint16)(INTERP_16_MASK_1((INTERP_16_MASK_1(p1)*4 + INTERP_16_MASK_1(p2)*3 + INTERP_16_MASK_1(p3)) / 8)
|
|
||||||
| INTERP_16_MASK_2((INTERP_16_MASK_2(p1)*4 + INTERP_16_MASK_2(p2)*3 + INTERP_16_MASK_2(p3)) / 8));
|
|
||||||
}
|
|
||||||
|
|
||||||
FUNCINLINE static ATTRINLINE Uint16 interp_16_53(Uint16 p1, Uint16 p2)
|
|
||||||
{
|
|
||||||
return (Uint16)(INTERP_16_MASK_1((INTERP_16_MASK_1(p1)*5 + INTERP_16_MASK_1(p2)*3) / 8)
|
|
||||||
| INTERP_16_MASK_2((INTERP_16_MASK_2(p1)*5 + INTERP_16_MASK_2(p2)*3) / 8));
|
|
||||||
}
|
|
||||||
|
|
||||||
FUNCINLINE static ATTRINLINE Uint16 interp_16_151(Uint16 p1, Uint16 p2)
|
|
||||||
{
|
|
||||||
return (Uint16)(INTERP_16_MASK_1((INTERP_16_MASK_1(p1)*15 + INTERP_16_MASK_1(p2)) / 16)
|
|
||||||
| INTERP_16_MASK_2((INTERP_16_MASK_2(p1)*15 + INTERP_16_MASK_2(p2)) / 16));
|
|
||||||
}
|
|
||||||
|
|
||||||
FUNCINLINE static ATTRINLINE Uint16 interp_16_97(Uint16 p1, Uint16 p2)
|
|
||||||
{
|
|
||||||
return (Uint16)(INTERP_16_MASK_1((INTERP_16_MASK_1(p1)*9 + INTERP_16_MASK_1(p2)*7) / 16)
|
|
||||||
| INTERP_16_MASK_2((INTERP_16_MASK_2(p1)*9 + INTERP_16_MASK_2(p2)*7) / 16));
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
#define INTERP_32_MASK_1(v) (v & 0xFF00FF)
|
|
||||||
#define INTERP_32_MASK_2(v) (v & 0x00FF00)
|
|
||||||
|
|
||||||
FUNCINLINE static ATTRINLINE Uint32 interp_32_521(Uint32 p1, Uint32 p2, Uint32 p3)
|
|
||||||
{
|
|
||||||
return INTERP_32_MASK_1((INTERP_32_MASK_1(p1)*5 + INTERP_32_MASK_1(p2)*2 + INTERP_32_MASK_1(p3)*1) / 8)
|
|
||||||
| INTERP_32_MASK_2((INTERP_32_MASK_2(p1)*5 + INTERP_32_MASK_2(p2)*2 + INTERP_32_MASK_2(p3)*1) / 8);
|
|
||||||
}
|
|
||||||
|
|
||||||
FUNCINLINE static ATTRINLINE Uint32 interp_32_332(Uint32 p1, Uint32 p2, Uint32 p3)
|
|
||||||
{
|
|
||||||
return INTERP_32_MASK_1((INTERP_32_MASK_1(p1)*3 + INTERP_32_MASK_1(p2)*3 + INTERP_32_MASK_1(p3)*2) / 8)
|
|
||||||
| INTERP_32_MASK_2((INTERP_32_MASK_2(p1)*3 + INTERP_32_MASK_2(p2)*3 + INTERP_32_MASK_2(p3)*2) / 8);
|
|
||||||
}
|
|
||||||
|
|
||||||
FUNCINLINE static ATTRINLINE Uint32 interp_32_211(Uint32 p1, Uint32 p2, Uint32 p3)
|
|
||||||
{
|
|
||||||
return INTERP_32_MASK_1((INTERP_32_MASK_1(p1)*2 + INTERP_32_MASK_1(p2) + INTERP_32_MASK_1(p3)) / 4)
|
|
||||||
| INTERP_32_MASK_2((INTERP_32_MASK_2(p1)*2 + INTERP_32_MASK_2(p2) + INTERP_32_MASK_2(p3)) / 4);
|
|
||||||
}
|
|
||||||
|
|
||||||
FUNCINLINE static ATTRINLINE Uint32 interp_32_611(Uint32 p1, Uint32 p2, Uint32 p3)
|
|
||||||
{
|
|
||||||
return INTERP_32_MASK_1((INTERP_32_MASK_1(p1)*6 + INTERP_32_MASK_1(p2) + INTERP_32_MASK_1(p3)) / 8)
|
|
||||||
| INTERP_32_MASK_2((INTERP_32_MASK_2(p1)*6 + INTERP_32_MASK_2(p2) + INTERP_32_MASK_2(p3)) / 8);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
FUNCINLINE static ATTRINLINE Uint32 interp_32_71(Uint32 p1, Uint32 p2)
|
|
||||||
{
|
|
||||||
return INTERP_32_MASK_1((INTERP_32_MASK_1(p1)*7 + INTERP_32_MASK_1(p2)) / 8)
|
|
||||||
| INTERP_32_MASK_2((INTERP_32_MASK_2(p1)*7 + INTERP_32_MASK_2(p2)) / 8);
|
|
||||||
}
|
|
||||||
|
|
||||||
FUNCINLINE static ATTRINLINE Uint32 interp_32_772(Uint32 p1, Uint32 p2, Uint32 p3)
|
|
||||||
{
|
|
||||||
return INTERP_32_MASK_1(((INTERP_32_MASK_1(p1) + INTERP_32_MASK_1(p2))*7 + INTERP_32_MASK_1(p3)*2) / 16)
|
|
||||||
| INTERP_32_MASK_2(((INTERP_32_MASK_2(p1) + INTERP_32_MASK_2(p2))*7 + INTERP_32_MASK_2(p3)*2) / 16);
|
|
||||||
}
|
|
||||||
|
|
||||||
FUNCINLINE static ATTRINLINE Uint32 interp_32_11(Uint32 p1, Uint32 p2)
|
|
||||||
{
|
|
||||||
return INTERP_32_MASK_1((INTERP_32_MASK_1(p1) + INTERP_32_MASK_1(p2)) / 2)
|
|
||||||
| INTERP_32_MASK_2((INTERP_32_MASK_2(p1) + INTERP_32_MASK_2(p2)) / 2);
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
FUNCINLINE static ATTRINLINE Uint32 interp_32_31(Uint32 p1, Uint32 p2)
|
|
||||||
{
|
|
||||||
return INTERP_32_MASK_1((INTERP_32_MASK_1(p1)*3 + INTERP_32_MASK_1(p2)) / 4)
|
|
||||||
| INTERP_32_MASK_2((INTERP_32_MASK_2(p1)*3 + INTERP_32_MASK_2(p2)) / 4);
|
|
||||||
}
|
|
||||||
|
|
||||||
FUNCINLINE static ATTRINLINE Uint32 interp_32_1411(Uint32 p1, Uint32 p2, Uint32 p3)
|
|
||||||
{
|
|
||||||
return INTERP_32_MASK_1((INTERP_32_MASK_1(p1)*14 + INTERP_32_MASK_1(p2) + INTERP_32_MASK_1(p3)) / 16)
|
|
||||||
| INTERP_32_MASK_2((INTERP_32_MASK_2(p1)*14 + INTERP_32_MASK_2(p2) + INTERP_32_MASK_2(p3)) / 16);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
FUNCINLINE static ATTRINLINE Uint32 interp_32_431(Uint32 p1, Uint32 p2, Uint32 p3)
|
|
||||||
{
|
|
||||||
return INTERP_32_MASK_1((INTERP_32_MASK_1(p1)*4 + INTERP_32_MASK_1(p2)*3 + INTERP_32_MASK_1(p3)) / 8)
|
|
||||||
| INTERP_32_MASK_2((INTERP_32_MASK_2(p1)*4 + INTERP_32_MASK_2(p2)*3 + INTERP_32_MASK_2(p3)) / 8);
|
|
||||||
}
|
|
||||||
|
|
||||||
FUNCINLINE static ATTRINLINE Uint32 interp_32_53(Uint32 p1, Uint32 p2)
|
|
||||||
{
|
|
||||||
return INTERP_32_MASK_1((INTERP_32_MASK_1(p1)*5 + INTERP_32_MASK_1(p2)*3) / 8)
|
|
||||||
| INTERP_32_MASK_2((INTERP_32_MASK_2(p1)*5 + INTERP_32_MASK_2(p2)*3) / 8);
|
|
||||||
}
|
|
||||||
|
|
||||||
FUNCINLINE static ATTRINLINE Uint32 interp_32_151(Uint32 p1, Uint32 p2)
|
|
||||||
{
|
|
||||||
return INTERP_32_MASK_1((INTERP_32_MASK_1(p1)*15 + INTERP_32_MASK_1(p2)) / 16)
|
|
||||||
| INTERP_32_MASK_2((INTERP_32_MASK_2(p1)*15 + INTERP_32_MASK_2(p2)) / 16);
|
|
||||||
}
|
|
||||||
|
|
||||||
FUNCINLINE static ATTRINLINE Uint32 interp_32_97(Uint32 p1, Uint32 p2)
|
|
||||||
{
|
|
||||||
return INTERP_32_MASK_1((INTERP_32_MASK_1(p1)*9 + INTERP_32_MASK_1(p2)*7) / 16)
|
|
||||||
| INTERP_32_MASK_2((INTERP_32_MASK_2(p1)*9 + INTERP_32_MASK_2(p2)*7) / 16);
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/***************************************************************************/
|
|
||||||
/* diff */
|
|
||||||
|
|
||||||
#define INTERP_Y_LIMIT (0x30*4)
|
|
||||||
#define INTERP_U_LIMIT (0x07*4)
|
|
||||||
#define INTERP_V_LIMIT (0x06*8)
|
|
||||||
|
|
||||||
static int interp_16_diff(Uint16 p1, Uint16 p2)
|
|
||||||
{
|
|
||||||
int r, g, b;
|
|
||||||
int y, u, v;
|
|
||||||
|
|
||||||
if (p1 == p2)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
if (interp_bits_per_pixel == 16) {
|
|
||||||
b = (int)((p1 & 0x1F) - (p2 & 0x1F)) << 3;
|
|
||||||
g = (int)((p1 & 0x7E0) - (p2 & 0x7E0)) >> 3;
|
|
||||||
r = (int)((p1 & 0xF800) - (p2 & 0xF800)) >> 8;
|
|
||||||
} else {
|
|
||||||
b = (int)((p1 & 0x1F) - (p2 & 0x1F)) << 3;
|
|
||||||
g = (int)((p1 & 0x3E0) - (p2 & 0x3E0)) >> 2;
|
|
||||||
r = (int)((p1 & 0x7C00) - (p2 & 0x7C00)) >> 7;
|
|
||||||
}
|
|
||||||
|
|
||||||
y = r + g + b;
|
|
||||||
u = r - b;
|
|
||||||
v = -r + 2*g - b;
|
|
||||||
|
|
||||||
if (y < -INTERP_Y_LIMIT || y > INTERP_Y_LIMIT)
|
|
||||||
return 1;
|
|
||||||
|
|
||||||
if (u < -INTERP_U_LIMIT || u > INTERP_U_LIMIT)
|
|
||||||
return 1;
|
|
||||||
|
|
||||||
if (v < -INTERP_V_LIMIT || v > INTERP_V_LIMIT)
|
|
||||||
return 1;
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int interp_32_diff(Uint32 p1, Uint32 p2)
|
|
||||||
{
|
|
||||||
int r, g, b;
|
|
||||||
int y, u, v;
|
|
||||||
|
|
||||||
if ((p1 & 0xF8F8F8) == (p2 & 0xF8F8F8))
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
b = (int)((p1 & 0xFF) - (p2 & 0xFF));
|
|
||||||
g = (int)((p1 & 0xFF00) - (p2 & 0xFF00)) >> 8;
|
|
||||||
r = (int)((p1 & 0xFF0000) - (p2 & 0xFF0000)) >> 16;
|
|
||||||
|
|
||||||
y = r + g + b;
|
|
||||||
u = r - b;
|
|
||||||
v = -r + 2*g - b;
|
|
||||||
|
|
||||||
if (y < -INTERP_Y_LIMIT || y > INTERP_Y_LIMIT)
|
|
||||||
return 1;
|
|
||||||
|
|
||||||
if (u < -INTERP_U_LIMIT || u > INTERP_U_LIMIT)
|
|
||||||
return 1;
|
|
||||||
|
|
||||||
if (v < -INTERP_V_LIMIT || v > INTERP_V_LIMIT)
|
|
||||||
return 1;
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
static void interp_set(Uint32 bits_per_pixel)
|
|
||||||
{
|
|
||||||
interp_bits_per_pixel = bits_per_pixel;
|
|
||||||
|
|
||||||
switch (bits_per_pixel) {
|
|
||||||
case 15 :
|
|
||||||
interp_mask[0] = 0x7C1F;
|
|
||||||
interp_mask[1] = 0x03E0;
|
|
||||||
break;
|
|
||||||
case 16 :
|
|
||||||
interp_mask[0] = 0xF81F;
|
|
||||||
interp_mask[1] = 0x07E0;
|
|
||||||
break;
|
|
||||||
case 32 :
|
|
||||||
interp_mask[0] = 0xFF00FF;
|
|
||||||
interp_mask[1] = 0x00FF00;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
#endif
|
|
|
@ -1,564 +0,0 @@
|
||||||
#include "filters.h"
|
|
||||||
#include "interp.h"
|
|
||||||
|
|
||||||
static void hq2x_16_def(Uint16* dst0, Uint16* dst1, const Uint16* src0, const Uint16* src1, const Uint16* src2, Uint32 count)
|
|
||||||
{
|
|
||||||
Uint32 i;
|
|
||||||
|
|
||||||
for(i=0;i<count;++i) {
|
|
||||||
Uint8 mask;
|
|
||||||
|
|
||||||
Uint16 c[9];
|
|
||||||
|
|
||||||
c[1] = src0[0];
|
|
||||||
c[4] = src1[0];
|
|
||||||
c[7] = src2[0];
|
|
||||||
|
|
||||||
if (i>0) {
|
|
||||||
c[0] = src0[-1];
|
|
||||||
c[3] = src1[-1];
|
|
||||||
c[6] = src2[-1];
|
|
||||||
} else {
|
|
||||||
c[0] = c[1];
|
|
||||||
c[3] = c[4];
|
|
||||||
c[6] = c[7];
|
|
||||||
}
|
|
||||||
|
|
||||||
if (i<count-1) {
|
|
||||||
c[2] = src0[1];
|
|
||||||
c[5] = src1[1];
|
|
||||||
c[8] = src2[1];
|
|
||||||
} else {
|
|
||||||
c[2] = c[1];
|
|
||||||
c[5] = c[4];
|
|
||||||
c[8] = c[7];
|
|
||||||
}
|
|
||||||
|
|
||||||
mask = 0;
|
|
||||||
|
|
||||||
if (interp_16_diff(c[0], c[4]))
|
|
||||||
mask |= 1 << 0;
|
|
||||||
if (interp_16_diff(c[1], c[4]))
|
|
||||||
mask |= 1 << 1;
|
|
||||||
if (interp_16_diff(c[2], c[4]))
|
|
||||||
mask |= 1 << 2;
|
|
||||||
if (interp_16_diff(c[3], c[4]))
|
|
||||||
mask |= 1 << 3;
|
|
||||||
if (interp_16_diff(c[5], c[4]))
|
|
||||||
mask |= 1 << 4;
|
|
||||||
if (interp_16_diff(c[6], c[4]))
|
|
||||||
mask |= 1 << 5;
|
|
||||||
if (interp_16_diff(c[7], c[4]))
|
|
||||||
mask |= 1 << 6;
|
|
||||||
if (interp_16_diff(c[8], c[4]))
|
|
||||||
mask |= 1 << 7;
|
|
||||||
|
|
||||||
#define P0 dst0[0]
|
|
||||||
#define P1 dst0[1]
|
|
||||||
#define P2 dst1[0]
|
|
||||||
#define P3 dst1[1]
|
|
||||||
#define MUR interp_16_diff(c[1], c[5])
|
|
||||||
#define MDR interp_16_diff(c[5], c[7])
|
|
||||||
#define MDL interp_16_diff(c[7], c[3])
|
|
||||||
#define MUL interp_16_diff(c[3], c[1])
|
|
||||||
#define IC(p0) c[p0]
|
|
||||||
#define I11(p0,p1) interp_16_11(c[p0], c[p1])
|
|
||||||
#define I211(p0,p1,p2) interp_16_211(c[p0], c[p1], c[p2])
|
|
||||||
#define I31(p0,p1) interp_16_31(c[p0], c[p1])
|
|
||||||
#define I332(p0,p1,p2) interp_16_332(c[p0], c[p1], c[p2])
|
|
||||||
#define I431(p0,p1,p2) interp_16_431(c[p0], c[p1], c[p2])
|
|
||||||
#define I521(p0,p1,p2) interp_16_521(c[p0], c[p1], c[p2])
|
|
||||||
#define I53(p0,p1) interp_16_53(c[p0], c[p1])
|
|
||||||
#define I611(p0,p1,p2) interp_16_611(c[p0], c[p1], c[p2])
|
|
||||||
#define I71(p0,p1) interp_16_71(c[p0], c[p1])
|
|
||||||
#define I772(p0,p1,p2) interp_16_772(c[p0], c[p1], c[p2])
|
|
||||||
#define I97(p0,p1) interp_16_97(c[p0], c[p1])
|
|
||||||
#define I1411(p0,p1,p2) interp_16_1411(c[p0], c[p1], c[p2])
|
|
||||||
#define I151(p0,p1) interp_16_151(c[p0], c[p1])
|
|
||||||
|
|
||||||
switch (mask) {
|
|
||||||
#include "hq2x.h"
|
|
||||||
}
|
|
||||||
|
|
||||||
#undef P0
|
|
||||||
#undef P1
|
|
||||||
#undef P2
|
|
||||||
#undef P3
|
|
||||||
#undef MUR
|
|
||||||
#undef MDR
|
|
||||||
#undef MDL
|
|
||||||
#undef MUL
|
|
||||||
#undef IC
|
|
||||||
#undef I11
|
|
||||||
#undef I211
|
|
||||||
#undef I31
|
|
||||||
#undef I332
|
|
||||||
#undef I431
|
|
||||||
#undef I521
|
|
||||||
#undef I53
|
|
||||||
#undef I611
|
|
||||||
#undef I71
|
|
||||||
#undef I772
|
|
||||||
#undef I97
|
|
||||||
#undef I1411
|
|
||||||
#undef I151
|
|
||||||
|
|
||||||
src0 += 1;
|
|
||||||
src1 += 1;
|
|
||||||
src2 += 1;
|
|
||||||
dst0 += 2;
|
|
||||||
dst1 += 2;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static void hq2x_32_def(Uint32* dst0, Uint32* dst1, const Uint32* src0, const Uint32* src1, const Uint32* src2, Uint32 count)
|
|
||||||
{
|
|
||||||
Uint32 i;
|
|
||||||
|
|
||||||
for(i=0;i<count;++i) {
|
|
||||||
Uint8 mask;
|
|
||||||
|
|
||||||
Uint32 c[9];
|
|
||||||
|
|
||||||
c[1] = src0[0];
|
|
||||||
c[4] = src1[0];
|
|
||||||
c[7] = src2[0];
|
|
||||||
|
|
||||||
if (i>0) {
|
|
||||||
c[0] = src0[-1];
|
|
||||||
c[3] = src1[-1];
|
|
||||||
c[6] = src2[-1];
|
|
||||||
} else {
|
|
||||||
c[0] = c[1];
|
|
||||||
c[3] = c[4];
|
|
||||||
c[6] = c[7];
|
|
||||||
}
|
|
||||||
|
|
||||||
if (i<count-1) {
|
|
||||||
c[2] = src0[1];
|
|
||||||
c[5] = src1[1];
|
|
||||||
c[8] = src2[1];
|
|
||||||
} else {
|
|
||||||
c[2] = c[1];
|
|
||||||
c[5] = c[4];
|
|
||||||
c[8] = c[7];
|
|
||||||
}
|
|
||||||
|
|
||||||
mask = 0;
|
|
||||||
|
|
||||||
if (interp_32_diff(c[0], c[4]))
|
|
||||||
mask |= 1 << 0;
|
|
||||||
if (interp_32_diff(c[1], c[4]))
|
|
||||||
mask |= 1 << 1;
|
|
||||||
if (interp_32_diff(c[2], c[4]))
|
|
||||||
mask |= 1 << 2;
|
|
||||||
if (interp_32_diff(c[3], c[4]))
|
|
||||||
mask |= 1 << 3;
|
|
||||||
if (interp_32_diff(c[5], c[4]))
|
|
||||||
mask |= 1 << 4;
|
|
||||||
if (interp_32_diff(c[6], c[4]))
|
|
||||||
mask |= 1 << 5;
|
|
||||||
if (interp_32_diff(c[7], c[4]))
|
|
||||||
mask |= 1 << 6;
|
|
||||||
if (interp_32_diff(c[8], c[4]))
|
|
||||||
mask |= 1 << 7;
|
|
||||||
|
|
||||||
#define P0 dst0[0]
|
|
||||||
#define P1 dst0[1]
|
|
||||||
#define P2 dst1[0]
|
|
||||||
#define P3 dst1[1]
|
|
||||||
#define MUR interp_32_diff(c[1], c[5])
|
|
||||||
#define MDR interp_32_diff(c[5], c[7])
|
|
||||||
#define MDL interp_32_diff(c[7], c[3])
|
|
||||||
#define MUL interp_32_diff(c[3], c[1])
|
|
||||||
#define IC(p0) c[p0]
|
|
||||||
#define I11(p0,p1) interp_32_11(c[p0], c[p1])
|
|
||||||
#define I211(p0,p1,p2) interp_32_211(c[p0], c[p1], c[p2])
|
|
||||||
#define I31(p0,p1) interp_32_31(c[p0], c[p1])
|
|
||||||
#define I332(p0,p1,p2) interp_32_332(c[p0], c[p1], c[p2])
|
|
||||||
#define I431(p0,p1,p2) interp_32_431(c[p0], c[p1], c[p2])
|
|
||||||
#define I521(p0,p1,p2) interp_32_521(c[p0], c[p1], c[p2])
|
|
||||||
#define I53(p0,p1) interp_32_53(c[p0], c[p1])
|
|
||||||
#define I611(p0,p1,p2) interp_32_611(c[p0], c[p1], c[p2])
|
|
||||||
#define I71(p0,p1) interp_32_71(c[p0], c[p1])
|
|
||||||
#define I772(p0,p1,p2) interp_32_772(c[p0], c[p1], c[p2])
|
|
||||||
#define I97(p0,p1) interp_32_97(c[p0], c[p1])
|
|
||||||
#define I1411(p0,p1,p2) interp_32_1411(c[p0], c[p1], c[p2])
|
|
||||||
#define I151(p0,p1) interp_32_151(c[p0], c[p1])
|
|
||||||
|
|
||||||
switch (mask) {
|
|
||||||
#include "hq2x.h"
|
|
||||||
}
|
|
||||||
|
|
||||||
#undef P0
|
|
||||||
#undef P1
|
|
||||||
#undef P2
|
|
||||||
#undef P3
|
|
||||||
#undef MUR
|
|
||||||
#undef MDR
|
|
||||||
#undef MDL
|
|
||||||
#undef MUL
|
|
||||||
#undef IC
|
|
||||||
#undef I11
|
|
||||||
#undef I211
|
|
||||||
#undef I31
|
|
||||||
#undef I332
|
|
||||||
#undef I431
|
|
||||||
#undef I521
|
|
||||||
#undef I53
|
|
||||||
#undef I611
|
|
||||||
#undef I71
|
|
||||||
#undef I772
|
|
||||||
#undef I97
|
|
||||||
#undef I1411
|
|
||||||
#undef I151
|
|
||||||
|
|
||||||
src0 += 1;
|
|
||||||
src1 += 1;
|
|
||||||
src2 += 1;
|
|
||||||
dst0 += 2;
|
|
||||||
dst1 += 2;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/***************************************************************************/
|
|
||||||
/* LQ2x C implementation */
|
|
||||||
|
|
||||||
/*
|
|
||||||
* This effect is derived from the hq2x effect made by Maxim Stepin
|
|
||||||
*/
|
|
||||||
|
|
||||||
static void lq2x_16_def(Uint16* dst0, Uint16* dst1, const Uint16* src0, const Uint16* src1, const Uint16* src2, Uint32 count)
|
|
||||||
{
|
|
||||||
Uint32 i;
|
|
||||||
|
|
||||||
for(i=0;i<count;++i) {
|
|
||||||
Uint8 mask;
|
|
||||||
|
|
||||||
Uint16 c[9];
|
|
||||||
|
|
||||||
c[1] = src0[0];
|
|
||||||
c[4] = src1[0];
|
|
||||||
c[7] = src2[0];
|
|
||||||
|
|
||||||
if (i>0) {
|
|
||||||
c[0] = src0[-1];
|
|
||||||
c[3] = src1[-1];
|
|
||||||
c[6] = src2[-1];
|
|
||||||
} else {
|
|
||||||
c[0] = c[1];
|
|
||||||
c[3] = c[4];
|
|
||||||
c[6] = c[7];
|
|
||||||
}
|
|
||||||
|
|
||||||
if (i<count-1) {
|
|
||||||
c[2] = src0[1];
|
|
||||||
c[5] = src1[1];
|
|
||||||
c[8] = src2[1];
|
|
||||||
} else {
|
|
||||||
c[2] = c[1];
|
|
||||||
c[5] = c[4];
|
|
||||||
c[8] = c[7];
|
|
||||||
}
|
|
||||||
|
|
||||||
mask = 0;
|
|
||||||
|
|
||||||
if (c[0] != c[4])
|
|
||||||
mask |= 1 << 0;
|
|
||||||
if (c[1] != c[4])
|
|
||||||
mask |= 1 << 1;
|
|
||||||
if (c[2] != c[4])
|
|
||||||
mask |= 1 << 2;
|
|
||||||
if (c[3] != c[4])
|
|
||||||
mask |= 1 << 3;
|
|
||||||
if (c[5] != c[4])
|
|
||||||
mask |= 1 << 4;
|
|
||||||
if (c[6] != c[4])
|
|
||||||
mask |= 1 << 5;
|
|
||||||
if (c[7] != c[4])
|
|
||||||
mask |= 1 << 6;
|
|
||||||
if (c[8] != c[4])
|
|
||||||
mask |= 1 << 7;
|
|
||||||
|
|
||||||
#define P0 dst0[0]
|
|
||||||
#define P1 dst0[1]
|
|
||||||
#define P2 dst1[0]
|
|
||||||
#define P3 dst1[1]
|
|
||||||
#define MUR (c[1] != c[5])
|
|
||||||
#define MDR (c[5] != c[7])
|
|
||||||
#define MDL (c[7] != c[3])
|
|
||||||
#define MUL (c[3] != c[1])
|
|
||||||
#define IC(p0) c[p0]
|
|
||||||
#define I11(p0,p1) interp_16_11(c[p0], c[p1])
|
|
||||||
#define I211(p0,p1,p2) interp_16_211(c[p0], c[p1], c[p2])
|
|
||||||
#define I31(p0,p1) interp_16_31(c[p0], c[p1])
|
|
||||||
#define I332(p0,p1,p2) interp_16_332(c[p0], c[p1], c[p2])
|
|
||||||
#define I431(p0,p1,p2) interp_16_431(c[p0], c[p1], c[p2])
|
|
||||||
#define I521(p0,p1,p2) interp_16_521(c[p0], c[p1], c[p2])
|
|
||||||
#define I53(p0,p1) interp_16_53(c[p0], c[p1])
|
|
||||||
#define I611(p0,p1,p2) interp_16_611(c[p0], c[p1], c[p2])
|
|
||||||
#define I71(p0,p1) interp_16_71(c[p0], c[p1])
|
|
||||||
#define I772(p0,p1,p2) interp_16_772(c[p0], c[p1], c[p2])
|
|
||||||
#define I97(p0,p1) interp_16_97(c[p0], c[p1])
|
|
||||||
#define I1411(p0,p1,p2) interp_16_1411(c[p0], c[p1], c[p2])
|
|
||||||
#define I151(p0,p1) interp_16_151(c[p0], c[p1])
|
|
||||||
|
|
||||||
switch (mask) {
|
|
||||||
#include "lq2x.h"
|
|
||||||
}
|
|
||||||
|
|
||||||
#undef P0
|
|
||||||
#undef P1
|
|
||||||
#undef P2
|
|
||||||
#undef P3
|
|
||||||
#undef MUR
|
|
||||||
#undef MDR
|
|
||||||
#undef MDL
|
|
||||||
#undef MUL
|
|
||||||
#undef IC
|
|
||||||
#undef I11
|
|
||||||
#undef I211
|
|
||||||
#undef I31
|
|
||||||
#undef I332
|
|
||||||
#undef I431
|
|
||||||
#undef I521
|
|
||||||
#undef I53
|
|
||||||
#undef I611
|
|
||||||
#undef I71
|
|
||||||
#undef I772
|
|
||||||
#undef I97
|
|
||||||
#undef I1411
|
|
||||||
#undef I151
|
|
||||||
|
|
||||||
src0 += 1;
|
|
||||||
src1 += 1;
|
|
||||||
src2 += 1;
|
|
||||||
dst0 += 2;
|
|
||||||
dst1 += 2;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static void lq2x_32_def(Uint32* dst0, Uint32* dst1, const Uint32* src0, const Uint32* src1, const Uint32* src2, Uint32 count)
|
|
||||||
{
|
|
||||||
Uint32 i;
|
|
||||||
|
|
||||||
for(i=0;i<count;++i) {
|
|
||||||
Uint8 mask;
|
|
||||||
|
|
||||||
Uint32 c[9];
|
|
||||||
|
|
||||||
c[1] = src0[0];
|
|
||||||
c[4] = src1[0];
|
|
||||||
c[7] = src2[0];
|
|
||||||
|
|
||||||
if (i>0) {
|
|
||||||
c[0] = src0[-1];
|
|
||||||
c[3] = src1[-1];
|
|
||||||
c[6] = src2[-1];
|
|
||||||
} else {
|
|
||||||
c[0] = c[1];
|
|
||||||
c[3] = c[4];
|
|
||||||
c[6] = c[7];
|
|
||||||
}
|
|
||||||
|
|
||||||
if (i<count-1) {
|
|
||||||
c[2] = src0[1];
|
|
||||||
c[5] = src1[1];
|
|
||||||
c[8] = src2[1];
|
|
||||||
} else {
|
|
||||||
c[2] = c[1];
|
|
||||||
c[5] = c[4];
|
|
||||||
c[8] = c[7];
|
|
||||||
}
|
|
||||||
|
|
||||||
mask = 0;
|
|
||||||
|
|
||||||
if (c[0] != c[4])
|
|
||||||
mask |= 1 << 0;
|
|
||||||
if (c[1] != c[4])
|
|
||||||
mask |= 1 << 1;
|
|
||||||
if (c[2] != c[4])
|
|
||||||
mask |= 1 << 2;
|
|
||||||
if (c[3] != c[4])
|
|
||||||
mask |= 1 << 3;
|
|
||||||
if (c[5] != c[4])
|
|
||||||
mask |= 1 << 4;
|
|
||||||
if (c[6] != c[4])
|
|
||||||
mask |= 1 << 5;
|
|
||||||
if (c[7] != c[4])
|
|
||||||
mask |= 1 << 6;
|
|
||||||
if (c[8] != c[4])
|
|
||||||
mask |= 1 << 7;
|
|
||||||
|
|
||||||
#define P0 dst0[0]
|
|
||||||
#define P1 dst0[1]
|
|
||||||
#define P2 dst1[0]
|
|
||||||
#define P3 dst1[1]
|
|
||||||
#define MUR (c[1] != c[5])
|
|
||||||
#define MDR (c[5] != c[7])
|
|
||||||
#define MDL (c[7] != c[3])
|
|
||||||
#define MUL (c[3] != c[1])
|
|
||||||
#define IC(p0) c[p0]
|
|
||||||
#define I11(p0,p1) interp_32_11(c[p0], c[p1])
|
|
||||||
#define I211(p0,p1,p2) interp_32_211(c[p0], c[p1], c[p2])
|
|
||||||
#define I31(p0,p1) interp_32_31(c[p0], c[p1])
|
|
||||||
#define I332(p0,p1,p2) interp_32_332(c[p0], c[p1], c[p2])
|
|
||||||
#define I431(p0,p1,p2) interp_32_431(c[p0], c[p1], c[p2])
|
|
||||||
#define I521(p0,p1,p2) interp_32_521(c[p0], c[p1], c[p2])
|
|
||||||
#define I53(p0,p1) interp_32_53(c[p0], c[p1])
|
|
||||||
#define I611(p0,p1,p2) interp_32_611(c[p0], c[p1], c[p2])
|
|
||||||
#define I71(p0,p1) interp_32_71(c[p0], c[p1])
|
|
||||||
#define I772(p0,p1,p2) interp_32_772(c[p0], c[p1], c[p2])
|
|
||||||
#define I97(p0,p1) interp_32_97(c[p0], c[p1])
|
|
||||||
#define I1411(p0,p1,p2) interp_32_1411(c[p0], c[p1], c[p2])
|
|
||||||
#define I151(p0,p1) interp_32_151(c[p0], c[p1])
|
|
||||||
|
|
||||||
switch (mask) {
|
|
||||||
#include "lq2x.h"
|
|
||||||
}
|
|
||||||
|
|
||||||
#undef P0
|
|
||||||
#undef P1
|
|
||||||
#undef P2
|
|
||||||
#undef P3
|
|
||||||
#undef MUR
|
|
||||||
#undef MDR
|
|
||||||
#undef MDL
|
|
||||||
#undef MUL
|
|
||||||
#undef IC
|
|
||||||
#undef I11
|
|
||||||
#undef I211
|
|
||||||
#undef I31
|
|
||||||
#undef I332
|
|
||||||
#undef I431
|
|
||||||
#undef I521
|
|
||||||
#undef I53
|
|
||||||
#undef I611
|
|
||||||
#undef I71
|
|
||||||
#undef I772
|
|
||||||
#undef I97
|
|
||||||
#undef I1411
|
|
||||||
#undef I151
|
|
||||||
|
|
||||||
src0 += 1;
|
|
||||||
src1 += 1;
|
|
||||||
src2 += 1;
|
|
||||||
dst0 += 2;
|
|
||||||
dst1 += 2;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void hq2x16(Uint8 *srcPtr, Uint32 srcPitch, Uint8 *dstPtr,
|
|
||||||
Uint32 dstPitch, int width, int height)
|
|
||||||
{
|
|
||||||
Uint16 *dst0 = (Uint16 *)dstPtr;
|
|
||||||
Uint16 *dst1 = dst0 + (dstPitch >> 1);
|
|
||||||
|
|
||||||
Uint16 *src0 = (Uint16 *)srcPtr;
|
|
||||||
Uint16 *src1 = src0 + (srcPitch >> 1);
|
|
||||||
Uint16 *src2 = src1 + (srcPitch >> 1);
|
|
||||||
int count = height-2;
|
|
||||||
|
|
||||||
hq2x_16_def(dst0, dst1, src0, src0, src1, width);
|
|
||||||
|
|
||||||
while(count) {
|
|
||||||
dst0 += dstPitch;
|
|
||||||
dst1 += dstPitch;
|
|
||||||
hq2x_16_def(dst0, dst1, src0, src1, src2, width);
|
|
||||||
src0 = src1;
|
|
||||||
src1 = src2;
|
|
||||||
src2 += srcPitch >> 1;
|
|
||||||
--count;
|
|
||||||
}
|
|
||||||
dst0 += dstPitch;
|
|
||||||
dst1 += dstPitch;
|
|
||||||
hq2x_16_def(dst0, dst1, src0, src1, src1, width);
|
|
||||||
}
|
|
||||||
|
|
||||||
void hq2x32(Uint8 *srcPtr, Uint32 srcPitch, Uint8 *dstPtr,
|
|
||||||
Uint32 dstPitch, int width, int height)
|
|
||||||
{
|
|
||||||
Uint32 *dst0 = (Uint32 *)dstPtr;
|
|
||||||
Uint32 *dst1 = dst0 + (dstPitch >> 2);
|
|
||||||
|
|
||||||
Uint32 *src0 = (Uint32 *)srcPtr;
|
|
||||||
Uint32 *src1 = src0 + (srcPitch >> 2);
|
|
||||||
Uint32 *src2 = src1 + (srcPitch >> 2);
|
|
||||||
int count = height-2;
|
|
||||||
|
|
||||||
hq2x_32_def(dst0, dst1, src0, src0, src1, width);
|
|
||||||
|
|
||||||
while(count) {
|
|
||||||
dst0 += dstPitch >> 1;
|
|
||||||
dst1 += dstPitch >> 1;
|
|
||||||
hq2x_32_def(dst0, dst1, src0, src1, src2, width);
|
|
||||||
src0 = src1;
|
|
||||||
src1 = src2;
|
|
||||||
src2 += srcPitch >> 2;
|
|
||||||
--count;
|
|
||||||
}
|
|
||||||
dst0 += dstPitch >> 1;
|
|
||||||
dst1 += dstPitch >> 1;
|
|
||||||
hq2x_32_def(dst0, dst1, src0, src1, src1, width);
|
|
||||||
}
|
|
||||||
|
|
||||||
void lq2x16(Uint8 *srcPtr, Uint32 srcPitch, Uint8 *dstPtr,
|
|
||||||
Uint32 dstPitch, int width, int height)
|
|
||||||
{
|
|
||||||
Uint16 *dst0 = (Uint16 *)dstPtr;
|
|
||||||
Uint16 *dst1 = dst0 + (dstPitch >> 1);
|
|
||||||
|
|
||||||
Uint16 *src0 = (Uint16 *)srcPtr;
|
|
||||||
Uint16 *src1 = src0 + (srcPitch >> 1);
|
|
||||||
Uint16 *src2 = src1 + (srcPitch >> 1);
|
|
||||||
int count = height-2;
|
|
||||||
|
|
||||||
lq2x_16_def(dst0, dst1, src0, src0, src1, width);
|
|
||||||
|
|
||||||
while(count) {
|
|
||||||
dst0 += dstPitch;
|
|
||||||
dst1 += dstPitch;
|
|
||||||
lq2x_16_def(dst0, dst1, src0, src1, src2, width);
|
|
||||||
src0 = src1;
|
|
||||||
src1 = src2;
|
|
||||||
src2 += srcPitch >> 1;
|
|
||||||
--count;
|
|
||||||
}
|
|
||||||
dst0 += dstPitch;
|
|
||||||
dst1 += dstPitch;
|
|
||||||
lq2x_16_def(dst0, dst1, src0, src1, src1, width);
|
|
||||||
}
|
|
||||||
|
|
||||||
void lq2x32(Uint8 *srcPtr, Uint32 srcPitch, Uint8 *dstPtr,
|
|
||||||
Uint32 dstPitch, int width, int height)
|
|
||||||
{
|
|
||||||
Uint32 *dst0 = (Uint32 *)dstPtr;
|
|
||||||
Uint32 *dst1 = dst0 + (dstPitch >> 2);
|
|
||||||
|
|
||||||
Uint32 *src0 = (Uint32 *)srcPtr;
|
|
||||||
Uint32 *src1 = src0 + (srcPitch >> 2);
|
|
||||||
Uint32 *src2 = src1 + (srcPitch >> 2);
|
|
||||||
int count = height-2;
|
|
||||||
|
|
||||||
lq2x_32_def(dst0, dst1, src0, src0, src1, width);
|
|
||||||
|
|
||||||
while(count) {
|
|
||||||
dst0 += dstPitch >> 1;
|
|
||||||
dst1 += dstPitch >> 1;
|
|
||||||
lq2x_32_def(dst0, dst1, src0, src1, src2, width);
|
|
||||||
src0 = src1;
|
|
||||||
src1 = src2;
|
|
||||||
src2 += srcPitch >> 2;
|
|
||||||
--count;
|
|
||||||
}
|
|
||||||
dst0 += dstPitch >> 1;
|
|
||||||
dst1 += dstPitch >> 1;
|
|
||||||
lq2x_32_def(dst0, dst1, src0, src1, src1, width);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
static inline void hq2x_init(Uint32 bits_per_pixel)
|
|
||||||
{
|
|
||||||
interp_set(bits_per_pixel);
|
|
||||||
}
|
|
||||||
*/
|
|
File diff suppressed because it is too large
Load diff
|
@ -1,15 +0,0 @@
|
||||||
#include "filters.h"
|
|
||||||
|
|
||||||
int main(int argc, char *argv[])
|
|
||||||
{
|
|
||||||
SDL_Surface *src = NULL;
|
|
||||||
SDL_Surface *dst = NULL;
|
|
||||||
src = SDL_LoadBMP("src.bmp"); //load
|
|
||||||
if(!src) return -1; //check
|
|
||||||
dst = filter_2x(src, NULL, hq2x32); //prcoess
|
|
||||||
SDL_FreeSurface(src); //free
|
|
||||||
if(!dst) return 0; //error
|
|
||||||
SDL_SaveBMP(dst, "dst.bmp"); //save
|
|
||||||
SDL_FreeSurface(dst); //free
|
|
||||||
return 1; //good
|
|
||||||
}
|
|
|
@ -29,7 +29,7 @@
|
||||||
#pragma warning(disable : 4214 4244)
|
#pragma warning(disable : 4214 4244)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef SDL
|
#ifdef HAVE_SDL
|
||||||
|
|
||||||
#include "SDL.h"
|
#include "SDL.h"
|
||||||
|
|
||||||
|
|
|
@ -1,588 +1,38 @@
|
||||||
// Emacs style mode select -*- C++ -*-
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
//
|
|
||||||
// Copyright (C) 1998-2000 by DooM Legacy Team.
|
|
||||||
//
|
|
||||||
// This program 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.
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
/// \file
|
|
||||||
/// \brief cd music interface
|
|
||||||
///
|
|
||||||
|
|
||||||
#ifdef SDL
|
|
||||||
|
|
||||||
#if defined (DC) || defined (_WIN32_WCE) || defined(GP2X) || defined(_PS3)
|
|
||||||
#define NOSDLCD
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <stdlib.h>
|
|
||||||
#ifndef NOSDLCD
|
|
||||||
|
|
||||||
#ifdef _MSC_VER
|
|
||||||
#pragma warning(disable : 4214 4244)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "SDL.h"
|
|
||||||
|
|
||||||
#ifdef _MSC_VER
|
|
||||||
#pragma warning(default : 4214 4244)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "../doomtype.h"
|
|
||||||
#include "../i_sound.h"
|
|
||||||
#include "../command.h"
|
#include "../command.h"
|
||||||
#include "../m_argv.h"
|
|
||||||
#include "../s_sound.h"
|
#include "../s_sound.h"
|
||||||
|
#include "../i_sound.h"
|
||||||
|
|
||||||
#define MAX_CD_TRACKS 256
|
//
|
||||||
|
// CD MUSIC I/O
|
||||||
|
//
|
||||||
|
|
||||||
#ifdef _XBOX
|
UINT8 cdaudio_started = 0;
|
||||||
INT32 SDL_SYS_CDInit(void)
|
|
||||||
{
|
|
||||||
return(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
void SDL_SYS_CDQuit(void)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
UINT8 cdaudio_started = 0; // for system startup/shutdown
|
|
||||||
|
|
||||||
consvar_t cd_volume = {"cd_volume","31",CV_SAVE,soundvolume_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL};
|
consvar_t cd_volume = {"cd_volume","31",CV_SAVE,soundvolume_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL};
|
||||||
consvar_t cdUpdate = {"cd_update","1",CV_SAVE, NULL, NULL, 0, NULL, NULL, 0, 0, NULL};
|
consvar_t cdUpdate = {"cd_update","1",CV_SAVE, NULL, NULL, 0, NULL, NULL, 0, 0, NULL};
|
||||||
|
|
||||||
#ifndef NOSDLCD
|
|
||||||
static SDL_bool cdValid = SDL_FALSE;
|
|
||||||
static SDL_bool cdPlaying = SDL_FALSE;
|
|
||||||
static SDL_bool wasPlaying = SDL_FALSE;
|
|
||||||
static SDL_bool cdEnabled = SDL_FALSE;
|
|
||||||
static SDL_bool playLooping = SDL_FALSE;
|
|
||||||
static Uint8 playTrack = 0;
|
|
||||||
static Uint8 maxTrack = MAX_CD_TRACKS-1;
|
|
||||||
static Uint8 cdRemap[MAX_CD_TRACKS];
|
|
||||||
static INT32 cdvolume = -1;
|
|
||||||
static SDL_CD *cdrom = NULL;
|
|
||||||
static CDstatus cdStatus = CD_ERROR;
|
|
||||||
|
|
||||||
/**************************************************************************
|
void I_InitCD(void){}
|
||||||
*
|
|
||||||
* function: CDAudio_GetAudioDiskInfo
|
void I_StopCD(void){}
|
||||||
*
|
|
||||||
* description:
|
void I_PauseCD(void){}
|
||||||
* set number of tracks if CD is available
|
|
||||||
*
|
void I_ResumeCD(void){}
|
||||||
**************************************************************************/
|
|
||||||
static INT32 CDAudio_GetAudioDiskInfo(void)
|
void I_ShutdownCD(void){}
|
||||||
|
|
||||||
|
void I_UpdateCD(void){}
|
||||||
|
|
||||||
|
void I_PlayCD(UINT8 track, UINT8 looping)
|
||||||
{
|
{
|
||||||
cdValid = SDL_FALSE;
|
|
||||||
maxTrack = 0;
|
|
||||||
|
|
||||||
if (!cdrom)
|
|
||||||
return 0;//Alam: Lies!
|
|
||||||
|
|
||||||
cdStatus = SDL_CDStatus(cdrom);
|
|
||||||
|
|
||||||
if (!CD_INDRIVE(cdStatus))
|
|
||||||
{
|
|
||||||
CONS_Printf("%s", M_GetText("No CD in drive\n"));
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (cdStatus == CD_ERROR)
|
|
||||||
{
|
|
||||||
CONS_Printf(M_GetText("CD Error: %s\n"), SDL_GetError());
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
cdValid = SDL_TRUE;
|
|
||||||
maxTrack = (Uint8)cdrom->numtracks;
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**************************************************************************
|
|
||||||
*
|
|
||||||
* function: I_EjectCD
|
|
||||||
*
|
|
||||||
* description:
|
|
||||||
*
|
|
||||||
*
|
|
||||||
**************************************************************************/
|
|
||||||
static void I_EjectCD(void)
|
|
||||||
{
|
|
||||||
if (!cdrom || !cdEnabled)
|
|
||||||
return; // no cd init'd
|
|
||||||
|
|
||||||
I_StopCD();
|
|
||||||
|
|
||||||
if (SDL_CDEject(cdrom))
|
|
||||||
CONS_Printf("%s", M_GetText("CD eject failed\n"));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**************************************************************************
|
|
||||||
*
|
|
||||||
* function: Command_Cd_f
|
|
||||||
*
|
|
||||||
* description:
|
|
||||||
* handles all CD commands from the console
|
|
||||||
*
|
|
||||||
**************************************************************************/
|
|
||||||
static void Command_Cd_f (void)
|
|
||||||
{
|
|
||||||
const char *command;
|
|
||||||
size_t ret, n;
|
|
||||||
|
|
||||||
if (!cdaudio_started)
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (COM_Argc() < 2)
|
|
||||||
{
|
|
||||||
CONS_Printf ("%s", M_GetText("cd [on] [off] [remap] [reset] [select]\n"
|
|
||||||
" [open] [info] [play <track>] [resume]\n"
|
|
||||||
" [stop] [pause] [loop <track>]\n"));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
command = COM_Argv (1);
|
|
||||||
|
|
||||||
if (!strncmp(command, "on", 2))
|
|
||||||
{
|
|
||||||
cdEnabled = SDL_TRUE;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!strncmp(command, "off", 3))
|
|
||||||
{
|
|
||||||
I_StopCD();
|
|
||||||
cdEnabled = SDL_FALSE;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!strncmp(command, "select", 6))
|
|
||||||
{
|
|
||||||
INT32 newcddrive;
|
|
||||||
newcddrive = atoi(COM_Argv(2));
|
|
||||||
command = SDL_CDName(newcddrive);
|
|
||||||
I_StopCD();
|
|
||||||
cdEnabled = SDL_FALSE;
|
|
||||||
SDL_CDClose(cdrom);
|
|
||||||
cdrom = SDL_CDOpen(newcddrive);
|
|
||||||
if (cdrom)
|
|
||||||
{
|
|
||||||
cdEnabled = SDL_TRUE;
|
|
||||||
CONS_Printf(M_GetText("Opened CD-ROM drive %s\n"), command ? command : COM_Argv(2));
|
|
||||||
}
|
|
||||||
else CONS_Printf(M_GetText("Couldn't open CD-ROM drive %s: %s\n"), command ? command : COM_Argv(2), SDL_GetError());
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!strncmp(command, "remap", 5))
|
|
||||||
{
|
|
||||||
ret = COM_Argc() - 2;
|
|
||||||
if (ret <= 0)
|
|
||||||
{
|
|
||||||
for (n = 1; n < MAX_CD_TRACKS; n++)
|
|
||||||
{
|
|
||||||
if (cdRemap[n] != n)
|
|
||||||
CONS_Printf(" %s -> %u\n", sizeu1(n), cdRemap[n]);
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
for (n = 1; n <= ret; n++)
|
|
||||||
cdRemap[n] = (Uint8)atoi(COM_Argv (n+1));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!strncmp(command, "reset", 5))
|
|
||||||
{
|
|
||||||
if (!cdrom) return;
|
|
||||||
cdEnabled = SDL_TRUE;
|
|
||||||
I_StopCD();
|
|
||||||
for (n = 0; n < MAX_CD_TRACKS; n++)
|
|
||||||
cdRemap[n] = (Uint8)n;
|
|
||||||
CDAudio_GetAudioDiskInfo();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!cdValid)
|
|
||||||
{
|
|
||||||
if (CDAudio_GetAudioDiskInfo()==-1 && !cdValid)
|
|
||||||
{
|
|
||||||
CONS_Printf("%s", M_GetText("No CD in drive\n"));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!strncmp(command, "open", 4))
|
|
||||||
{
|
|
||||||
I_EjectCD();
|
|
||||||
cdValid = SDL_FALSE;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!strncmp(command, "info", 4))
|
|
||||||
{
|
|
||||||
CONS_Printf(M_GetText("%u tracks\n"), maxTrack);
|
|
||||||
if (cdPlaying)
|
|
||||||
CONS_Printf(M_GetText("Currently %s track %u\n"), playLooping ? M_GetText("looping") : M_GetText("playing"), playTrack);
|
|
||||||
else if (wasPlaying)
|
|
||||||
CONS_Printf(M_GetText("Paused %s track %u\n"), playLooping ? M_GetText("looping") : M_GetText("playing"), playTrack);
|
|
||||||
CONS_Printf(M_GetText("Volume is %d\n"), cdvolume);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!strncmp(command, "play", 4))
|
|
||||||
{
|
|
||||||
I_PlayCD((UINT8)atoi(COM_Argv (2)), SDL_FALSE);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!strncmp(command, "loop", 4))
|
|
||||||
{
|
|
||||||
I_PlayCD((UINT8)atoi(COM_Argv (2)), true);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!strncmp(command, "stop", 4))
|
|
||||||
{
|
|
||||||
I_StopCD();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (!strncmp(command, "pause", 5))
|
|
||||||
{
|
|
||||||
I_PauseCD();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!strncmp(command, "resume", 6))
|
|
||||||
{
|
|
||||||
I_ResumeCD();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
CONS_Printf(M_GetText("Invalid CD command \"CD %s\"\n"), COM_Argv(1));
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/**************************************************************************
|
|
||||||
*
|
|
||||||
* function: StopCD
|
|
||||||
*
|
|
||||||
* description:
|
|
||||||
*
|
|
||||||
*
|
|
||||||
**************************************************************************/
|
|
||||||
void I_StopCD(void)
|
|
||||||
{
|
|
||||||
#ifndef NOSDLCD
|
|
||||||
if (!cdrom || !cdEnabled)
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (!(cdPlaying || wasPlaying))
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (SDL_CDStop(cdrom))
|
|
||||||
I_OutputMsg("cdromstop failed\n");
|
|
||||||
|
|
||||||
wasPlaying = SDL_FALSE;
|
|
||||||
cdPlaying = SDL_FALSE;
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
/**************************************************************************
|
|
||||||
*
|
|
||||||
* function: PauseCD
|
|
||||||
*
|
|
||||||
* description:
|
|
||||||
*
|
|
||||||
*
|
|
||||||
**************************************************************************/
|
|
||||||
void I_PauseCD (void)
|
|
||||||
{
|
|
||||||
#ifndef NOSDLCD
|
|
||||||
if (!cdrom || !cdEnabled)
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (!cdPlaying)
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (SDL_CDPause(cdrom))
|
|
||||||
I_OutputMsg("cdrompause failed\n");
|
|
||||||
|
|
||||||
wasPlaying = cdPlaying;
|
|
||||||
cdPlaying = SDL_FALSE;
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
/**************************************************************************
|
|
||||||
*
|
|
||||||
* function: ResumeCD
|
|
||||||
*
|
|
||||||
* description:
|
|
||||||
*
|
|
||||||
*
|
|
||||||
**************************************************************************/
|
|
||||||
// continue after a pause
|
|
||||||
void I_ResumeCD (void)
|
|
||||||
{
|
|
||||||
#ifndef NOSDLCD
|
|
||||||
if (!cdrom || !cdEnabled)
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (!cdValid)
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (!wasPlaying)
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (cd_volume.value == 0)
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (SDL_CDResume(cdrom))
|
|
||||||
I_OutputMsg("cdromresume failed\n");
|
|
||||||
|
|
||||||
cdPlaying = SDL_TRUE;
|
|
||||||
wasPlaying = SDL_FALSE;
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**************************************************************************
|
|
||||||
*
|
|
||||||
* function: ShutdownCD
|
|
||||||
*
|
|
||||||
* description:
|
|
||||||
*
|
|
||||||
*
|
|
||||||
**************************************************************************/
|
|
||||||
void I_ShutdownCD (void)
|
|
||||||
{
|
|
||||||
#ifndef NOSDLCD
|
|
||||||
if (!cdaudio_started)
|
|
||||||
return;
|
|
||||||
|
|
||||||
I_StopCD();
|
|
||||||
|
|
||||||
CONS_Printf("I_ShutdownCD: ");
|
|
||||||
SDL_CDClose(cdrom);
|
|
||||||
cdrom = NULL;
|
|
||||||
cdaudio_started = false;
|
|
||||||
CONS_Printf("%s", M_GetText("shut down\n"));
|
|
||||||
SDL_QuitSubSystem(SDL_INIT_CDROM);
|
|
||||||
cdEnabled = SDL_FALSE;
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
/**************************************************************************
|
|
||||||
*
|
|
||||||
* function: InitCD
|
|
||||||
*
|
|
||||||
* description:
|
|
||||||
* Initialize the first CD drive SDL detects and add console command 'cd'
|
|
||||||
*
|
|
||||||
**************************************************************************/
|
|
||||||
void I_InitCD (void)
|
|
||||||
{
|
|
||||||
#ifndef NOSDLCD
|
|
||||||
INT32 i;
|
|
||||||
|
|
||||||
// Has been checked in d_main.c, but doesn't hurt here
|
|
||||||
if (M_CheckParm ("-nocd"))
|
|
||||||
return;
|
|
||||||
|
|
||||||
CONS_Printf("%s", M_GetText("I_InitCD: Init CD audio\n"));
|
|
||||||
|
|
||||||
// Initialize SDL first
|
|
||||||
if (SDL_InitSubSystem(SDL_INIT_CDROM) < 0)
|
|
||||||
{
|
|
||||||
CONS_Printf(M_GetText("Couldn't initialize SDL CDROM: %s\n"), SDL_GetError());
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Open drive
|
|
||||||
cdrom = SDL_CDOpen(0);
|
|
||||||
|
|
||||||
if (!cdrom)
|
|
||||||
{
|
|
||||||
const char *cdName = SDL_CDName(0);
|
|
||||||
if (!cdName)
|
|
||||||
CONS_Printf(M_GetText("Couldn't open CD-ROM drive %s: %s\n"), "\b", SDL_GetError());
|
|
||||||
else
|
|
||||||
CONS_Printf(M_GetText("Couldn't open CD-ROM drive %s: %s\n"), cdName, SDL_GetError());
|
|
||||||
//return;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (i = 0; i < MAX_CD_TRACKS; i++)
|
|
||||||
cdRemap[i] = (Uint8)i;
|
|
||||||
|
|
||||||
cdaudio_started = true;
|
|
||||||
if (cdrom) cdEnabled = SDL_TRUE;
|
|
||||||
|
|
||||||
if (CDAudio_GetAudioDiskInfo()==-1)
|
|
||||||
{
|
|
||||||
CONS_Printf("%s", M_GetText("No CD in drive\n"));
|
|
||||||
cdValid = SDL_FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
COM_AddCommand ("cd", Command_Cd_f);
|
|
||||||
|
|
||||||
CONS_Printf("%s", M_GetText("CD audio Initialized\n"));
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//
|
|
||||||
/**************************************************************************
|
|
||||||
*
|
|
||||||
* function: UpdateCD
|
|
||||||
*
|
|
||||||
* description:
|
|
||||||
* sets CD volume (may have changed) and initiates play evey 2 seconds
|
|
||||||
* in case the song has elapsed
|
|
||||||
*
|
|
||||||
**************************************************************************/
|
|
||||||
void I_UpdateCD (void)
|
|
||||||
{
|
|
||||||
#ifndef NOSDLCD
|
|
||||||
static Uint32 lastchk = 0;
|
|
||||||
|
|
||||||
if (!cdEnabled || !cdrom)
|
|
||||||
return;
|
|
||||||
|
|
||||||
I_SetVolumeCD(cd_volume.value);
|
|
||||||
|
|
||||||
if (cdPlaying && lastchk < SDL_GetTicks())
|
|
||||||
{
|
|
||||||
lastchk = SDL_GetTicks() + 2000; //two seconds between chks
|
|
||||||
|
|
||||||
if (CDAudio_GetAudioDiskInfo()==-1)
|
|
||||||
{
|
|
||||||
cdPlaying = SDL_FALSE;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (cdStatus != CD_PLAYING && cdStatus != CD_PAUSED)
|
|
||||||
{
|
|
||||||
cdPlaying = SDL_FALSE;
|
|
||||||
if (playLooping)
|
|
||||||
I_PlayCD(playTrack, true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**************************************************************************
|
|
||||||
*
|
|
||||||
* function: PlayCD
|
|
||||||
*
|
|
||||||
* description:
|
|
||||||
* play the requested track and set the looping flag
|
|
||||||
* pauses the CD if volume is 0
|
|
||||||
*
|
|
||||||
**************************************************************************/
|
|
||||||
|
|
||||||
void I_PlayCD (UINT8 track, UINT8 looping)
|
|
||||||
{
|
|
||||||
#ifdef NOSDLCD
|
|
||||||
(void)track;
|
(void)track;
|
||||||
(void)looping;
|
(void)looping;
|
||||||
#else
|
|
||||||
if (!cdrom || !cdEnabled)
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (!cdValid)
|
|
||||||
{
|
|
||||||
CDAudio_GetAudioDiskInfo();
|
|
||||||
if (!cdValid)
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
track = cdRemap[track];
|
|
||||||
|
|
||||||
if (track < 1 || track > maxTrack)
|
|
||||||
{
|
|
||||||
CONS_Printf(M_GetText("Bad track number %u.\n"), track);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// don't try to play a non-audio track
|
|
||||||
if (cdrom->track[track].type == SDL_DATA_TRACK)
|
|
||||||
{
|
|
||||||
CONS_Printf(M_GetText("Track %u is not audio\n"), track);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (cdPlaying)
|
|
||||||
{
|
|
||||||
if (playTrack == track)
|
|
||||||
return;
|
|
||||||
I_StopCD();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (SDL_CDPlayTracks(cdrom, track, 0, 1, 0))
|
|
||||||
{
|
|
||||||
CONS_Printf(M_GetText("Error playing track %d: %s\n"), track, SDL_GetError());
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
playLooping = looping;
|
|
||||||
playTrack = (Uint8)track;
|
|
||||||
cdPlaying = SDL_TRUE;
|
|
||||||
|
|
||||||
if (cd_volume.value == 0)
|
|
||||||
I_PauseCD();
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
boolean I_SetVolumeCD(int volume)
|
||||||
/**************************************************************************
|
|
||||||
*
|
|
||||||
* function: SetVolumeCD
|
|
||||||
*
|
|
||||||
* description:
|
|
||||||
* SDL does not support setting the CD volume
|
|
||||||
* use pause instead and toggle between full and no music
|
|
||||||
*
|
|
||||||
**************************************************************************/
|
|
||||||
|
|
||||||
boolean I_SetVolumeCD (INT32 volume)
|
|
||||||
{
|
{
|
||||||
#ifdef NOSDLCD
|
|
||||||
(void)volume;
|
(void)volume;
|
||||||
#else
|
|
||||||
if (volume != cdvolume)
|
|
||||||
{
|
|
||||||
if (volume > 0 && volume < 16)
|
|
||||||
{
|
|
||||||
CV_SetValue(&cd_volume, 31);
|
|
||||||
cdvolume = 31;
|
|
||||||
I_ResumeCD();
|
|
||||||
}
|
|
||||||
else if (volume > 15 && volume < 31)
|
|
||||||
{
|
|
||||||
CV_SetValue(&cd_volume, 0);
|
|
||||||
cdvolume = 0;
|
|
||||||
I_PauseCD();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
|
@ -48,7 +48,7 @@ PSP_MAIN_THREAD_NAME("SRB2");
|
||||||
PSP_MAIN_THREAD_STACK_SIZE_KB(256);
|
PSP_MAIN_THREAD_STACK_SIZE_KB(256);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef SDL
|
#ifdef HAVE_SDL
|
||||||
|
|
||||||
#ifdef HAVE_TTF
|
#ifdef HAVE_TTF
|
||||||
#include "SDL.h"
|
#include "SDL.h"
|
||||||
|
|
|
@ -32,7 +32,7 @@
|
||||||
|
|
||||||
#include "../i_tcp.h"
|
#include "../i_tcp.h"
|
||||||
|
|
||||||
#ifdef SDL
|
#ifdef HAVE_SDL
|
||||||
|
|
||||||
#ifdef HAVE_SDLNET
|
#ifdef HAVE_SDLNET
|
||||||
|
|
||||||
|
|
|
@ -73,7 +73,7 @@ void __set_fpscr(long); // in libgcc / kernel's startup.s?
|
||||||
#pragma warning(disable : 4214 4244)
|
#pragma warning(disable : 4214 4244)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef SDL
|
#ifdef HAVE_SDL
|
||||||
|
|
||||||
#include "SDL.h"
|
#include "SDL.h"
|
||||||
|
|
||||||
|
@ -996,8 +996,8 @@ void I_GetJoystickEvents(void)
|
||||||
UINT64 joyhats = 0;
|
UINT64 joyhats = 0;
|
||||||
#if 0
|
#if 0
|
||||||
UINT64 joybuttons = 0;
|
UINT64 joybuttons = 0;
|
||||||
Sint16 axisx, axisy;
|
|
||||||
#endif
|
#endif
|
||||||
|
Sint16 axisx, axisy;
|
||||||
|
|
||||||
if (!joystick_started) return;
|
if (!joystick_started) return;
|
||||||
|
|
||||||
|
@ -1070,7 +1070,6 @@ void I_GetJoystickEvents(void)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#if 0
|
|
||||||
// send joystick axis positions
|
// send joystick axis positions
|
||||||
event.type = ev_joystick;
|
event.type = ev_joystick;
|
||||||
|
|
||||||
|
@ -1123,7 +1122,6 @@ void I_GetJoystickEvents(void)
|
||||||
}
|
}
|
||||||
D_PostEvent(&event);
|
D_PostEvent(&event);
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** \brief Open joystick handle
|
/** \brief Open joystick handle
|
||||||
|
@ -1156,7 +1154,7 @@ static int joy_open(const char *fname)
|
||||||
{
|
{
|
||||||
CONS_Printf(M_GetText("Cannot use joystick #%d/(%s), it doesn't exist\n"),joyindex,fname);
|
CONS_Printf(M_GetText("Cannot use joystick #%d/(%s), it doesn't exist\n"),joyindex,fname);
|
||||||
for (i = 0; i < num_joy; i++)
|
for (i = 0; i < num_joy; i++)
|
||||||
CONS_Printf("#%d/(%s)\n", i+1, SDL_JoystickName(i));
|
CONS_Printf("#%d/(%s)\n", i+1, SDL_JoystickNameForIndex(i));
|
||||||
I_ShutdownJoystick();
|
I_ShutdownJoystick();
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
@ -1177,7 +1175,7 @@ static int joy_open(const char *fname)
|
||||||
{
|
{
|
||||||
CONS_Printf(M_GetText("Found %d joysticks on this system\n"), num_joy);
|
CONS_Printf(M_GetText("Found %d joysticks on this system\n"), num_joy);
|
||||||
for (i = 0; i < num_joy; i++)
|
for (i = 0; i < num_joy; i++)
|
||||||
CONS_Printf("#%d/(%s)\n", i+1, SDL_JoystickName(i));
|
CONS_Printf("#%d/(%s)\n", i+1, SDL_JoystickNameForIndex(i));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
CONS_Printf("%s", M_GetText("Found no joysticks on this system\n"));
|
CONS_Printf("%s", M_GetText("Found no joysticks on this system\n"));
|
||||||
|
@ -1185,7 +1183,6 @@ static int joy_open(const char *fname)
|
||||||
}
|
}
|
||||||
|
|
||||||
JoyInfo.dev = SDL_JoystickOpen(joyindex-1);
|
JoyInfo.dev = SDL_JoystickOpen(joyindex-1);
|
||||||
CONS_Printf(M_GetText("Joystick: %s\n"), SDL_JoystickName(joyindex-1));
|
|
||||||
|
|
||||||
if (JoyInfo.dev == NULL)
|
if (JoyInfo.dev == NULL)
|
||||||
{
|
{
|
||||||
|
@ -1195,6 +1192,7 @@ static int joy_open(const char *fname)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
CONS_Printf(M_GetText("Joystick: %s\n"), SDL_JoystickName(JoyInfo.dev));
|
||||||
JoyInfo.axises = SDL_JoystickNumAxes(JoyInfo.dev);
|
JoyInfo.axises = SDL_JoystickNumAxes(JoyInfo.dev);
|
||||||
if (JoyInfo.axises > JOYAXISSET*2)
|
if (JoyInfo.axises > JOYAXISSET*2)
|
||||||
JoyInfo.axises = JOYAXISSET*2;
|
JoyInfo.axises = JOYAXISSET*2;
|
||||||
|
@ -1219,7 +1217,7 @@ static int joy_open(const char *fname)
|
||||||
JoyInfo.balls = SDL_JoystickNumBalls(JoyInfo.dev);
|
JoyInfo.balls = SDL_JoystickNumBalls(JoyInfo.dev);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
//Joystick.bGamepadStyle = !stricmp(SDL_JoystickName(SDL_JoystickIndex(JoyInfo.dev)), "pad");
|
//Joystick.bGamepadStyle = !stricmp(SDL_JoystickName(JoyInfo.dev), "pad");
|
||||||
|
|
||||||
return JoyInfo.axises;
|
return JoyInfo.axises;
|
||||||
}
|
}
|
||||||
|
@ -1290,8 +1288,8 @@ void I_GetJoystick2Events(void)
|
||||||
UINT64 joyhats = 0;
|
UINT64 joyhats = 0;
|
||||||
#if 0
|
#if 0
|
||||||
INT64 joybuttons = 0;
|
INT64 joybuttons = 0;
|
||||||
INT32 axisx, axisy;
|
|
||||||
#endif
|
#endif
|
||||||
|
INT32 axisx, axisy;
|
||||||
|
|
||||||
if (!joystick2_started)
|
if (!joystick2_started)
|
||||||
return;
|
return;
|
||||||
|
@ -1361,7 +1359,6 @@ void I_GetJoystick2Events(void)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#if 0
|
|
||||||
// send joystick axis positions
|
// send joystick axis positions
|
||||||
event.type = ev_joystick2;
|
event.type = ev_joystick2;
|
||||||
|
|
||||||
|
@ -1416,7 +1413,6 @@ void I_GetJoystick2Events(void)
|
||||||
}
|
}
|
||||||
D_PostEvent(&event);
|
D_PostEvent(&event);
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1448,7 +1444,7 @@ static int joy_open2(const char *fname)
|
||||||
{
|
{
|
||||||
CONS_Printf(M_GetText("Cannot use joystick #%d/(%s), it doesn't exist\n"),joyindex,fname);
|
CONS_Printf(M_GetText("Cannot use joystick #%d/(%s), it doesn't exist\n"),joyindex,fname);
|
||||||
for (i = 0; i < num_joy; i++)
|
for (i = 0; i < num_joy; i++)
|
||||||
CONS_Printf("#%d/(%s)\n", i+1, SDL_JoystickName(i));
|
CONS_Printf("#%d/(%s)\n", i+1, SDL_JoystickNameForIndex(i));
|
||||||
I_ShutdownJoystick2();
|
I_ShutdownJoystick2();
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
@ -1469,7 +1465,7 @@ static int joy_open2(const char *fname)
|
||||||
{
|
{
|
||||||
CONS_Printf(M_GetText("Found %d joysticks on this system\n"), num_joy);
|
CONS_Printf(M_GetText("Found %d joysticks on this system\n"), num_joy);
|
||||||
for (i = 0; i < num_joy; i++)
|
for (i = 0; i < num_joy; i++)
|
||||||
CONS_Printf("#%d/(%s)\n", i+1, SDL_JoystickName(i));
|
CONS_Printf("#%d/(%s)\n", i+1, SDL_JoystickNameForIndex(i));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
CONS_Printf("%s", M_GetText("Found no joysticks on this system\n"));
|
CONS_Printf("%s", M_GetText("Found no joysticks on this system\n"));
|
||||||
|
@ -1477,7 +1473,6 @@ static int joy_open2(const char *fname)
|
||||||
}
|
}
|
||||||
|
|
||||||
JoyInfo2.dev = SDL_JoystickOpen(joyindex-1);
|
JoyInfo2.dev = SDL_JoystickOpen(joyindex-1);
|
||||||
CONS_Printf(M_GetText("Joystick2: %s\n"), SDL_JoystickName(joyindex-1));
|
|
||||||
|
|
||||||
if (!JoyInfo2.dev)
|
if (!JoyInfo2.dev)
|
||||||
{
|
{
|
||||||
|
@ -1487,6 +1482,7 @@ static int joy_open2(const char *fname)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
CONS_Printf(M_GetText("Joystick2: %s\n"), SDL_JoystickName(JoyInfo2.dev));
|
||||||
JoyInfo2.axises = SDL_JoystickNumAxes(JoyInfo2.dev);
|
JoyInfo2.axises = SDL_JoystickNumAxes(JoyInfo2.dev);
|
||||||
if (JoyInfo2.axises > JOYAXISSET*2)
|
if (JoyInfo2.axises > JOYAXISSET*2)
|
||||||
JoyInfo2.axises = JOYAXISSET*2;
|
JoyInfo2.axises = JOYAXISSET*2;
|
||||||
|
@ -1511,7 +1507,7 @@ static int joy_open2(const char *fname)
|
||||||
JoyInfo2.balls = SDL_JoystickNumBalls(JoyInfo2.dev);
|
JoyInfo2.balls = SDL_JoystickNumBalls(JoyInfo2.dev);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
//Joystick.bGamepadStyle = !stricmp(SDL_JoystickName(SDL_JoystickIndex(JoyInfo2.dev)), "pad");
|
//Joystick.bGamepadStyle = !stricmp(SDL_JoystickName(JoyInfo2.dev), "pad");
|
||||||
|
|
||||||
return JoyInfo2.axises;
|
return JoyInfo2.axises;
|
||||||
}
|
}
|
||||||
|
@ -1582,11 +1578,11 @@ const char *I_GetJoyName(INT32 joyindex)
|
||||||
if (SDL_WasInit(SDL_INIT_JOYSTICK) == 0)
|
if (SDL_WasInit(SDL_INIT_JOYSTICK) == 0)
|
||||||
{
|
{
|
||||||
if (SDL_InitSubSystem(SDL_INIT_JOYSTICK) != -1)
|
if (SDL_InitSubSystem(SDL_INIT_JOYSTICK) != -1)
|
||||||
joyname = SDL_JoystickName(joyindex);
|
joyname = SDL_JoystickNameForIndex(joyindex);
|
||||||
SDL_QuitSubSystem(SDL_INIT_JOYSTICK);
|
SDL_QuitSubSystem(SDL_INIT_JOYSTICK);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
joyname = SDL_JoystickName(joyindex);
|
joyname = SDL_JoystickNameForIndex(joyindex);
|
||||||
return joyname;
|
return joyname;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2219,7 +2215,7 @@ void I_Sleep(void)
|
||||||
INT32 I_StartupSystem(void)
|
INT32 I_StartupSystem(void)
|
||||||
{
|
{
|
||||||
SDL_version SDLcompiled;
|
SDL_version SDLcompiled;
|
||||||
const SDL_version *SDLlinked;
|
SDL_version SDLlinked;
|
||||||
#ifdef _XBOX
|
#ifdef _XBOX
|
||||||
#ifdef __GNUC__
|
#ifdef __GNUC__
|
||||||
char DP[] =" Sonic Robo Blast 2!\n";
|
char DP[] =" Sonic Robo Blast 2!\n";
|
||||||
|
@ -2240,12 +2236,12 @@ INT32 I_StartupSystem(void)
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
SDL_VERSION(&SDLcompiled)
|
SDL_VERSION(&SDLcompiled)
|
||||||
SDLlinked = SDL_Linked_Version();
|
SDL_GetVersion(&SDLlinked);
|
||||||
I_StartupConsole();
|
I_StartupConsole();
|
||||||
I_OutputMsg("Compiled for SDL version: %d.%d.%d\n",
|
I_OutputMsg("Compiled for SDL version: %d.%d.%d\n",
|
||||||
SDLcompiled.major, SDLcompiled.minor, SDLcompiled.patch);
|
SDLcompiled.major, SDLcompiled.minor, SDLcompiled.patch);
|
||||||
I_OutputMsg("Linked with SDL version: %d.%d.%d\n",
|
I_OutputMsg("Linked with SDL version: %d.%d.%d\n",
|
||||||
SDLlinked->major, SDLlinked->minor, SDLlinked->patch);
|
SDLlinked.major, SDLlinked.minor, SDLlinked.patch);
|
||||||
#if 0 //#ifdef GP2X //start up everything
|
#if 0 //#ifdef GP2X //start up everything
|
||||||
if (SDL_Init(SDL_INIT_NOPARACHUTE|SDL_INIT_EVERYTHING) < 0)
|
if (SDL_Init(SDL_INIT_NOPARACHUTE|SDL_INIT_EVERYTHING) < 0)
|
||||||
#else
|
#else
|
||||||
|
@ -2875,7 +2871,7 @@ const char *I_LocateWad(void)
|
||||||
return waddir;
|
return waddir;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef LINUX
|
#if defined(LINUX) || defined(LINUX64)
|
||||||
#define MEMINFO_FILE "/proc/meminfo"
|
#define MEMINFO_FILE "/proc/meminfo"
|
||||||
#define MEMTOTAL "MemTotal:"
|
#define MEMTOTAL "MemTotal:"
|
||||||
#define MEMFREE "MemFree:"
|
#define MEMFREE "MemFree:"
|
||||||
|
@ -2931,7 +2927,25 @@ UINT32 I_GetFreeMem(UINT32 *total)
|
||||||
if (total)
|
if (total)
|
||||||
*total = 32 << 20;
|
*total = 32 << 20;
|
||||||
return 32 << 20;
|
return 32 << 20;
|
||||||
#elif defined (LINUX)
|
#elif (defined (_WIN32) || (defined (_WIN32_WCE) && !defined (__GNUC__))) && !defined (_XBOX)
|
||||||
|
MEMORYSTATUS info;
|
||||||
|
|
||||||
|
info.dwLength = sizeof (MEMORYSTATUS);
|
||||||
|
GlobalMemoryStatus( &info );
|
||||||
|
if (total)
|
||||||
|
*total = (UINT32)info.dwTotalPhys;
|
||||||
|
return (UINT32)info.dwAvailPhys;
|
||||||
|
#elif defined (__OS2__)
|
||||||
|
UINT32 pr_arena;
|
||||||
|
|
||||||
|
if (total)
|
||||||
|
DosQuerySysInfo( QSV_TOTPHYSMEM, QSV_TOTPHYSMEM,
|
||||||
|
(PVOID) total, sizeof (UINT32));
|
||||||
|
DosQuerySysInfo( QSV_MAXPRMEM, QSV_MAXPRMEM,
|
||||||
|
(PVOID) &pr_arena, sizeof (UINT32));
|
||||||
|
|
||||||
|
return pr_arena;
|
||||||
|
#elif defined (LINUX) || defined (LINUX64)
|
||||||
/* Linux */
|
/* Linux */
|
||||||
char buf[1024];
|
char buf[1024];
|
||||||
char *memTag;
|
char *memTag;
|
||||||
|
@ -2975,24 +2989,6 @@ UINT32 I_GetFreeMem(UINT32 *total)
|
||||||
if (total)
|
if (total)
|
||||||
*total = totalKBytes << 10;
|
*total = totalKBytes << 10;
|
||||||
return freeKBytes << 10;
|
return freeKBytes << 10;
|
||||||
#elif (defined (_WIN32) || (defined (_WIN32_WCE) && !defined (__GNUC__))) && !defined (_XBOX)
|
|
||||||
MEMORYSTATUS info;
|
|
||||||
|
|
||||||
info.dwLength = sizeof (MEMORYSTATUS);
|
|
||||||
GlobalMemoryStatus( &info );
|
|
||||||
if (total)
|
|
||||||
*total = (UINT32)info.dwTotalPhys;
|
|
||||||
return (UINT32)info.dwAvailPhys;
|
|
||||||
#elif defined (__OS2__)
|
|
||||||
UINT32 pr_arena;
|
|
||||||
|
|
||||||
if (total)
|
|
||||||
DosQuerySysInfo( QSV_TOTPHYSMEM, QSV_TOTPHYSMEM,
|
|
||||||
(PVOID) total, sizeof (UINT32));
|
|
||||||
DosQuerySysInfo( QSV_MAXPRMEM, QSV_MAXPRMEM,
|
|
||||||
(PVOID) &pr_arena, sizeof (UINT32));
|
|
||||||
|
|
||||||
return pr_arena;
|
|
||||||
#else
|
#else
|
||||||
// Guess 48 MB.
|
// Guess 48 MB.
|
||||||
if (total)
|
if (total)
|
||||||
|
@ -3039,8 +3035,8 @@ const CPUInfoFlags *I_CPUInfo(void)
|
||||||
WIN_CPUInfo.SSE2 = SDL_HasSSE2();
|
WIN_CPUInfo.SSE2 = SDL_HasSSE2();
|
||||||
WIN_CPUInfo.AltiVec = SDL_HasAltiVec();
|
WIN_CPUInfo.AltiVec = SDL_HasAltiVec();
|
||||||
}
|
}
|
||||||
WIN_CPUInfo.MMXExt = SDL_HasMMXExt();
|
WIN_CPUInfo.MMXExt = SDL_FALSE; //SDL_HasMMXExt(); No longer in SDL2
|
||||||
WIN_CPUInfo.AMD3DNowExt = SDL_Has3DNowExt();
|
WIN_CPUInfo.AMD3DNowExt = SDL_FALSE; //SDL_Has3DNowExt(); No longer in SDL2
|
||||||
#endif
|
#endif
|
||||||
GetSystemInfo(&SI);
|
GetSystemInfo(&SI);
|
||||||
WIN_CPUInfo.CPUs = SI.dwNumberOfProcessors;
|
WIN_CPUInfo.CPUs = SI.dwNumberOfProcessors;
|
||||||
|
@ -3052,9 +3048,9 @@ const CPUInfoFlags *I_CPUInfo(void)
|
||||||
memset(&SDL_CPUInfo,0,sizeof (CPUInfoFlags));
|
memset(&SDL_CPUInfo,0,sizeof (CPUInfoFlags));
|
||||||
SDL_CPUInfo.RDTSC = SDL_HasRDTSC();
|
SDL_CPUInfo.RDTSC = SDL_HasRDTSC();
|
||||||
SDL_CPUInfo.MMX = SDL_HasMMX();
|
SDL_CPUInfo.MMX = SDL_HasMMX();
|
||||||
SDL_CPUInfo.MMXExt = SDL_HasMMXExt();
|
SDL_CPUInfo.MMXExt = SDL_FALSE; //SDL_HasMMXExt(); No longer in SDL2
|
||||||
SDL_CPUInfo.AMD3DNow = SDL_Has3DNow();
|
SDL_CPUInfo.AMD3DNow = SDL_Has3DNow();
|
||||||
SDL_CPUInfo.AMD3DNowExt = SDL_Has3DNowExt();
|
SDL_CPUInfo.AMD3DNowExt = SDL_FALSE; //SDL_Has3DNowExt(); No longer in SDL2
|
||||||
SDL_CPUInfo.SSE = SDL_HasSSE();
|
SDL_CPUInfo.SSE = SDL_HasSSE();
|
||||||
SDL_CPUInfo.SSE2 = SDL_HasSSE2();
|
SDL_CPUInfo.SSE2 = SDL_HasSSE2();
|
||||||
SDL_CPUInfo.AltiVec = SDL_HasAltiVec();
|
SDL_CPUInfo.AltiVec = SDL_HasAltiVec();
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
/// \file
|
/// \file
|
||||||
/// \brief SDL_ttf interface code. Necessary for platforms with no framebuffer console systems.
|
/// \brief SDL_ttf interface code. Necessary for platforms with no framebuffer console systems.
|
||||||
|
|
||||||
#if defined(SDL) && defined(HAVE_TTF)
|
#if defined(HAVE_SDL) && defined(HAVE_TTF)
|
||||||
#include "SDL.h"
|
#include "SDL.h"
|
||||||
#include "SDL_ttf.h"
|
#include "SDL_ttf.h"
|
||||||
#include "../doomdef.h"
|
#include "../doomdef.h"
|
||||||
|
|
1568
src/sdl/i_video.c
1568
src/sdl/i_video.c
File diff suppressed because it is too large
Load diff
|
@ -1264,7 +1264,7 @@
|
||||||
GCC_PREPROCESSOR_DEFINITIONS = (
|
GCC_PREPROCESSOR_DEFINITIONS = (
|
||||||
MAC_ALERT,
|
MAC_ALERT,
|
||||||
SDLMAIN,
|
SDLMAIN,
|
||||||
SDL,
|
HAVE_SDL,
|
||||||
HAVE_MIXER,
|
HAVE_MIXER,
|
||||||
HAVE_PNG,
|
HAVE_PNG,
|
||||||
HAVE_BLUA,
|
HAVE_BLUA,
|
||||||
|
@ -1386,7 +1386,7 @@
|
||||||
GCC_PREPROCESSOR_DEFINITIONS = (
|
GCC_PREPROCESSOR_DEFINITIONS = (
|
||||||
MAC_ALERT,
|
MAC_ALERT,
|
||||||
SDLMAIN,
|
SDLMAIN,
|
||||||
SDL,
|
HAVE_SDL,
|
||||||
HAVE_MIXER,
|
HAVE_MIXER,
|
||||||
HAVE_PNG,
|
HAVE_PNG,
|
||||||
HAVE_BLUA,
|
HAVE_BLUA,
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
|
|
||||||
#include "../doomdef.h"
|
#include "../doomdef.h"
|
||||||
|
|
||||||
#if defined(SDL) && defined(HAVE_MIXER) && SOUND==SOUND_MIXER
|
#if defined(HAVE_SDL) && defined(HAVE_MIXER) && SOUND==SOUND_MIXER
|
||||||
|
|
||||||
#include "../sounds.h"
|
#include "../sounds.h"
|
||||||
#include "../s_sound.h"
|
#include "../s_sound.h"
|
||||||
|
@ -617,7 +617,7 @@ boolean I_StartDigSong(const char *musicname, boolean looping)
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
music = Mix_LoadMUS_RW(SDL_RWFromMem(data, len));
|
music = Mix_LoadMUS_RW(SDL_RWFromMem(data, len), SDL_FALSE);
|
||||||
if (!music)
|
if (!music)
|
||||||
{
|
{
|
||||||
CONS_Alert(CONS_ERROR, "Mix_LoadMUS_RW: %s\n", Mix_GetError());
|
CONS_Alert(CONS_ERROR, "Mix_LoadMUS_RW: %s\n", Mix_GetError());
|
||||||
|
@ -778,7 +778,7 @@ void I_SetMIDIMusicVolume(UINT8 volume)
|
||||||
|
|
||||||
INT32 I_RegisterSong(void *data, size_t len)
|
INT32 I_RegisterSong(void *data, size_t len)
|
||||||
{
|
{
|
||||||
music = Mix_LoadMUS_RW(SDL_RWFromMem(data, len));
|
music = Mix_LoadMUS_RW(SDL_RWFromMem(data, len), SDL_FALSE);
|
||||||
if (!music)
|
if (!music)
|
||||||
{
|
{
|
||||||
CONS_Alert(CONS_ERROR, "Mix_LoadMUS_RW: %s\n", Mix_GetError());
|
CONS_Alert(CONS_ERROR, "Mix_LoadMUS_RW: %s\n", Mix_GetError());
|
||||||
|
|
|
@ -21,10 +21,12 @@
|
||||||
#pragma warning(disable : 4214 4244)
|
#pragma warning(disable : 4214 4244)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef SDL
|
#ifdef HAVE_SDL
|
||||||
|
|
||||||
#include "SDL.h"
|
#include "SDL.h"
|
||||||
|
|
||||||
|
#include "sdlmain.h"
|
||||||
|
|
||||||
#ifdef _MSC_VER
|
#ifdef _MSC_VER
|
||||||
#pragma warning(default : 4214 4244)
|
#pragma warning(default : 4214 4244)
|
||||||
#endif
|
#endif
|
||||||
|
@ -62,19 +64,11 @@ PFNglGetIntegerv pglGetIntegerv;
|
||||||
PFNglGetString pglGetString;
|
PFNglGetString pglGetString;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef _PSP
|
|
||||||
static const Uint32 WOGLFlags = SDL_HWSURFACE|SDL_OPENGL/*|SDL_RESIZABLE*/;
|
|
||||||
static const Uint32 FOGLFlags = SDL_HWSURFACE|SDL_OPENGL|SDL_FULLSCREEN;
|
|
||||||
#else
|
|
||||||
static const Uint32 WOGLFlags = SDL_OPENGL/*|SDL_RESIZABLE*/;
|
|
||||||
static const Uint32 FOGLFlags = SDL_OPENGL|SDL_FULLSCREEN;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/** \brief SDL video display surface
|
/** \brief SDL video display surface
|
||||||
*/
|
*/
|
||||||
SDL_Surface *vidSurface = NULL;
|
|
||||||
INT32 oglflags = 0;
|
INT32 oglflags = 0;
|
||||||
void *GLUhandle = NULL;
|
void *GLUhandle = NULL;
|
||||||
|
SDL_GLContext sdlglcontext = 0;
|
||||||
|
|
||||||
#ifndef STATIC_OPENGL
|
#ifndef STATIC_OPENGL
|
||||||
void *GetGLFunc(const char *proc)
|
void *GetGLFunc(const char *proc)
|
||||||
|
@ -156,36 +150,13 @@ boolean LoadGL(void)
|
||||||
|
|
||||||
\return if true, changed video mode
|
\return if true, changed video mode
|
||||||
*/
|
*/
|
||||||
boolean OglSdlSurface(INT32 w, INT32 h, boolean isFullscreen)
|
boolean OglSdlSurface(INT32 w, INT32 h)
|
||||||
{
|
{
|
||||||
INT32 cbpp;
|
INT32 cbpp;
|
||||||
Uint32 OGLFlags;
|
|
||||||
const GLvoid *glvendor = NULL, *glrenderer = NULL, *glversion = NULL;
|
const GLvoid *glvendor = NULL, *glrenderer = NULL, *glversion = NULL;
|
||||||
|
|
||||||
cbpp = cv_scr_depth.value < 16 ? 16 : cv_scr_depth.value;
|
cbpp = cv_scr_depth.value < 16 ? 16 : cv_scr_depth.value;
|
||||||
|
|
||||||
if (vidSurface)
|
|
||||||
{
|
|
||||||
//Alam: SDL_Video system free vidSurface for me
|
|
||||||
#ifdef VOODOOSAFESWITCHING
|
|
||||||
SDL_QuitSubSystem(SDL_INIT_VIDEO);
|
|
||||||
SDL_InitSubSystem(SDL_INIT_VIDEO);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
if (isFullscreen)
|
|
||||||
OGLFlags = FOGLFlags;
|
|
||||||
else
|
|
||||||
OGLFlags = WOGLFlags;
|
|
||||||
|
|
||||||
cbpp = SDL_VideoModeOK(w, h, cbpp, OGLFlags);
|
|
||||||
if (cbpp < 16)
|
|
||||||
return true; //Alam: Let just say we did, ok?
|
|
||||||
|
|
||||||
vidSurface = SDL_SetVideoMode(w, h, cbpp, OGLFlags);
|
|
||||||
if (!vidSurface)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
glvendor = pglGetString(GL_VENDOR);
|
glvendor = pglGetString(GL_VENDOR);
|
||||||
// Get info and extensions.
|
// Get info and extensions.
|
||||||
//BP: why don't we make it earlier ?
|
//BP: why don't we make it earlier ?
|
||||||
|
@ -200,55 +171,21 @@ boolean OglSdlSurface(INT32 w, INT32 h, boolean isFullscreen)
|
||||||
DBG_Printf("Extensions : %s\n", gl_extensions);
|
DBG_Printf("Extensions : %s\n", gl_extensions);
|
||||||
oglflags = 0;
|
oglflags = 0;
|
||||||
|
|
||||||
#ifdef _WIN32
|
|
||||||
// BP: disable advenced feature that don't work on somes hardware
|
|
||||||
// Hurdler: Now works on G400 with bios 1.6 and certified drivers 6.04
|
|
||||||
if (strstr(glrenderer, "810")) oglflags |= GLF_NOZBUFREAD;
|
|
||||||
#elif defined (unix) || defined (UNIXCOMMON)
|
|
||||||
// disable advanced features not working on somes hardware
|
|
||||||
if (strstr(glrenderer, "G200")) oglflags |= GLF_NOTEXENV;
|
|
||||||
if (strstr(glrenderer, "G400")) oglflags |= GLF_NOTEXENV;
|
|
||||||
#endif
|
|
||||||
DBG_Printf("oglflags : 0x%X\n", oglflags );
|
|
||||||
|
|
||||||
#ifdef USE_PALETTED_TEXTURE
|
|
||||||
if (isExtAvailable("GL_EXT_paletted_texture", gl_extensions))
|
|
||||||
glColorTableEXT = SDL_GL_GetProcAddress("glColorTableEXT");
|
|
||||||
else
|
|
||||||
glColorTableEXT = NULL;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef USE_WGL_SWAP
|
|
||||||
if (isExtAvailable("WGL_EXT_swap_control", gl_extensions))
|
|
||||||
wglSwapIntervalEXT = SDL_GL_GetProcAddress("wglSwapIntervalEXT");
|
|
||||||
else
|
|
||||||
wglSwapIntervalEXT = NULL;
|
|
||||||
#else
|
|
||||||
if (isExtAvailable("GLX_SGI_swap_control", gl_extensions))
|
|
||||||
glXSwapIntervalSGIEXT = SDL_GL_GetProcAddress("glXSwapIntervalSGI");
|
|
||||||
else
|
|
||||||
glXSwapIntervalSGIEXT = NULL;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef KOS_GL_COMPATIBILITY
|
|
||||||
if (isExtAvailable("GL_EXT_texture_filter_anisotropic", gl_extensions))
|
if (isExtAvailable("GL_EXT_texture_filter_anisotropic", gl_extensions))
|
||||||
pglGetIntegerv(GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT, &maximumAnisotropy);
|
pglGetIntegerv(GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT, &maximumAnisotropy);
|
||||||
else
|
else
|
||||||
#endif
|
maximumAnisotropy = 1;
|
||||||
maximumAnisotropy = 0;
|
|
||||||
|
|
||||||
granisotropicmode_cons_t[1].value = maximumAnisotropy;
|
granisotropicmode_cons_t[1].value = maximumAnisotropy;
|
||||||
|
|
||||||
|
SDL_GL_SetSwapInterval(cv_vidwait.value ? 1 : 0);
|
||||||
|
|
||||||
SetModelView(w, h);
|
SetModelView(w, h);
|
||||||
SetStates();
|
SetStates();
|
||||||
pglClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
|
pglClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
|
||||||
|
|
||||||
HWR_Startup();
|
HWR_Startup();
|
||||||
#ifdef KOS_GL_COMPATIBILITY
|
|
||||||
textureformatGL = GL_ARGB4444;
|
|
||||||
#else
|
|
||||||
textureformatGL = cbpp > 16 ? GL_RGBA : GL_RGB5_A1;
|
textureformatGL = cbpp > 16 ? GL_RGBA : GL_RGB5_A1;
|
||||||
#endif
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -264,17 +201,11 @@ void OglSdlFinishUpdate(boolean waitvbl)
|
||||||
static boolean oldwaitvbl = false;
|
static boolean oldwaitvbl = false;
|
||||||
if (oldwaitvbl != waitvbl)
|
if (oldwaitvbl != waitvbl)
|
||||||
{
|
{
|
||||||
#ifdef USE_WGL_SWAP
|
SDL_GL_SetSwapInterval(waitvbl ? 1 : 0);
|
||||||
if (wglSwapIntervalEXT)
|
|
||||||
wglSwapIntervalEXT(waitvbl);
|
|
||||||
#else
|
|
||||||
if (glXSwapIntervalSGIEXT)
|
|
||||||
glXSwapIntervalSGIEXT(waitvbl);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
oldwaitvbl = waitvbl;
|
oldwaitvbl = waitvbl;
|
||||||
|
|
||||||
SDL_GL_SwapBuffers();
|
SDL_GL_SwapWindow(window);
|
||||||
}
|
}
|
||||||
|
|
||||||
EXPORT void HWRAPI( OglSdlSetPalette) (RGBA_t *palette, RGBA_t *pgamma)
|
EXPORT void HWRAPI( OglSdlSetPalette) (RGBA_t *palette, RGBA_t *pgamma)
|
||||||
|
@ -283,10 +214,6 @@ EXPORT void HWRAPI( OglSdlSetPalette) (RGBA_t *palette, RGBA_t *pgamma)
|
||||||
UINT32 redgamma = pgamma->s.red, greengamma = pgamma->s.green,
|
UINT32 redgamma = pgamma->s.red, greengamma = pgamma->s.green,
|
||||||
bluegamma = pgamma->s.blue;
|
bluegamma = pgamma->s.blue;
|
||||||
|
|
||||||
#if 0 // changing the gamma to 127 is a bad idea
|
|
||||||
i = SDL_SetGamma(byteasfloat(redgamma), byteasfloat(greengamma), byteasfloat(bluegamma));
|
|
||||||
#endif
|
|
||||||
if (i == 0) redgamma = greengamma = bluegamma = 0x7F; //Alam: cool
|
|
||||||
for (i = 0; i < 256; i++)
|
for (i = 0; i < 256; i++)
|
||||||
{
|
{
|
||||||
myPaletteData[i].s.red = (UINT8)MIN((palette[i].s.red * redgamma) /127, 255);
|
myPaletteData[i].s.red = (UINT8)MIN((palette[i].s.red * redgamma) /127, 255);
|
||||||
|
@ -294,20 +221,6 @@ EXPORT void HWRAPI( OglSdlSetPalette) (RGBA_t *palette, RGBA_t *pgamma)
|
||||||
myPaletteData[i].s.blue = (UINT8)MIN((palette[i].s.blue * bluegamma) /127, 255);
|
myPaletteData[i].s.blue = (UINT8)MIN((palette[i].s.blue * bluegamma) /127, 255);
|
||||||
myPaletteData[i].s.alpha = palette[i].s.alpha;
|
myPaletteData[i].s.alpha = palette[i].s.alpha;
|
||||||
}
|
}
|
||||||
#ifdef USE_PALETTED_TEXTURE
|
|
||||||
if (glColorTableEXT)
|
|
||||||
{
|
|
||||||
for (i = 0; i < 256; i++)
|
|
||||||
{
|
|
||||||
palette_tex[(3*i)+0] = palette[i].s.red;
|
|
||||||
palette_tex[(3*i)+1] = palette[i].s.green;
|
|
||||||
palette_tex[(3*i)+2] = palette[i].s.blue;
|
|
||||||
}
|
|
||||||
glColorTableEXT(GL_TEXTURE_2D, GL_RGB8, 256, GL_RGB, GL_UNSIGNED_BYTE, palette_tex);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
// on a chang<6E>de palette, il faut recharger toutes les textures
|
|
||||||
// jaja, und noch viel mehr ;-)
|
|
||||||
Flush();
|
Flush();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -18,13 +18,16 @@
|
||||||
|
|
||||||
#include "../v_video.h"
|
#include "../v_video.h"
|
||||||
|
|
||||||
extern SDL_Surface *vidSurface;
|
|
||||||
extern void *GLUhandle;
|
extern void *GLUhandle;
|
||||||
|
|
||||||
boolean OglSdlSurface(INT32 w, INT32 h, boolean isFullscreen);
|
boolean OglSdlSurface(INT32 w, INT32 h);
|
||||||
|
|
||||||
void OglSdlFinishUpdate(boolean vidwait);
|
void OglSdlFinishUpdate(boolean vidwait);
|
||||||
|
|
||||||
|
extern SDL_Window *window;
|
||||||
|
extern SDL_Renderer *renderer;
|
||||||
|
extern SDL_GLContext sdlglcontext;
|
||||||
|
|
||||||
#ifdef _CREATE_DLL_
|
#ifdef _CREATE_DLL_
|
||||||
EXPORT void HWRAPI( OglSdlSetPalette ) (RGBA_t *palette, RGBA_t *pgamma);
|
EXPORT void HWRAPI( OglSdlSetPalette ) (RGBA_t *palette, RGBA_t *pgamma);
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -23,7 +23,7 @@
|
||||||
#pragma warning(disable : 4214 4244)
|
#pragma warning(disable : 4214 4244)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(SDL) && SOUND==SOUND_SDL
|
#if defined(HAVE_SDL) && SOUND==SOUND_SDL
|
||||||
|
|
||||||
#include "SDL.h"
|
#include "SDL.h"
|
||||||
|
|
||||||
|
@ -856,6 +856,7 @@ FUNCINLINE static ATTRINLINE void I_UpdateStream16S(Uint8 *stream, int len)
|
||||||
|
|
||||||
if (Snd_Mutex) SDL_LockMutex(Snd_Mutex);
|
if (Snd_Mutex) SDL_LockMutex(Snd_Mutex);
|
||||||
|
|
||||||
|
|
||||||
// Mix sounds into the mixing buffer.
|
// Mix sounds into the mixing buffer.
|
||||||
// Loop over len
|
// Loop over len
|
||||||
while (len--)
|
while (len--)
|
||||||
|
@ -945,6 +946,7 @@ FUNCINLINE static ATTRINLINE void I_UpdateStream16M(Uint8 *stream, int len)
|
||||||
|
|
||||||
if (Snd_Mutex) SDL_LockMutex(Snd_Mutex);
|
if (Snd_Mutex) SDL_LockMutex(Snd_Mutex);
|
||||||
|
|
||||||
|
|
||||||
// Mix sounds into the mixing buffer.
|
// Mix sounds into the mixing buffer.
|
||||||
// Loop over len
|
// Loop over len
|
||||||
while (len--)
|
while (len--)
|
||||||
|
@ -1050,10 +1052,7 @@ static void SDLCALL I_UpdateStream(void *userdata, Uint8 *stream, int len)
|
||||||
if (!sound_started || !userdata)
|
if (!sound_started || !userdata)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
#if SDL_VERSION_ATLEAST(1,3,0)
|
memset(stream, 0x00, len); // only work in !AUDIO_U8, that needs 0x80
|
||||||
if (musicStarted)
|
|
||||||
memset(stream, 0x00, len); // only work in !AUDIO_U8, that needs 0x80
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if ((audio.channels != 1 && audio.channels != 2) ||
|
if ((audio.channels != 1 && audio.channels != 2) ||
|
||||||
(audio.format != AUDIO_S8 && audio.format != AUDIO_S16SYS))
|
(audio.format != AUDIO_S8 && audio.format != AUDIO_S16SYS))
|
||||||
|
@ -1320,8 +1319,8 @@ void I_StartupSound(void)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
char ad[100];
|
//char ad[100];
|
||||||
CONS_Printf(M_GetText(" Starting up with audio driver : %s\n"), SDL_AudioDriverName(ad, (int)sizeof ad));
|
//CONS_Printf(M_GetText(" Starting up with audio driver : %s\n"), SDL_AudioDriverName(ad, (int)sizeof ad));
|
||||||
}
|
}
|
||||||
samplecount = audio.samples;
|
samplecount = audio.samples;
|
||||||
CV_SetValue(&cv_samplerate, audio.freq);
|
CV_SetValue(&cv_samplerate, audio.freq);
|
||||||
|
@ -1782,7 +1781,9 @@ static boolean I_StartGMESong(const char *musicname, boolean looping)
|
||||||
gme_set_user_data(emu, data);
|
gme_set_user_data(emu, data);
|
||||||
gme_set_user_cleanup(emu, I_CleanupGME);
|
gme_set_user_cleanup(emu, I_CleanupGME);
|
||||||
gme_start_track(emu, 0);
|
gme_start_track(emu, 0);
|
||||||
|
#ifdef HAVE_MIXER
|
||||||
gme_set_fade(emu, Digfade);
|
gme_set_fade(emu, Digfade);
|
||||||
|
#endif
|
||||||
|
|
||||||
Snd_LockAudio();
|
Snd_LockAudio();
|
||||||
localdata.gme_emu = emu;
|
localdata.gme_emu = emu;
|
||||||
|
@ -2027,4 +2028,4 @@ static void SDLCALL I_FinishMusic(void)
|
||||||
if (Msc_Mutex) SDL_UnlockMutex(Msc_Mutex);
|
if (Msc_Mutex) SDL_UnlockMutex(Msc_Mutex);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
#endif //SDL
|
#endif //HAVE_SDL
|
||||||
|
|
|
@ -22,6 +22,11 @@
|
||||||
extern SDL_bool consolevent;
|
extern SDL_bool consolevent;
|
||||||
extern SDL_bool framebuffer;
|
extern SDL_bool framebuffer;
|
||||||
|
|
||||||
|
#include "../m_fixed.h"
|
||||||
|
|
||||||
|
// SDL2 stub macro
|
||||||
|
#define SDL2STUB(name) CONS_Printf("SDL2: stubbed: %s:%d\n", __func__, __LINE__)
|
||||||
|
|
||||||
/** \brief The JoyInfo_s struct
|
/** \brief The JoyInfo_s struct
|
||||||
|
|
||||||
info about joystick
|
info about joystick
|
||||||
|
|
|
@ -222,7 +222,7 @@ void V_SetPalette(INT32 palettenum)
|
||||||
#ifdef HWRENDER
|
#ifdef HWRENDER
|
||||||
if (rendermode != render_soft && rendermode != render_none)
|
if (rendermode != render_soft && rendermode != render_none)
|
||||||
HWR_SetPalette(&pLocalPalette[palettenum*256]);
|
HWR_SetPalette(&pLocalPalette[palettenum*256]);
|
||||||
#if (defined (__unix__) && !defined (MSDOS)) || defined (UNIXCOMMON) || defined (SDL)
|
#if (defined (__unix__) && !defined (MSDOS)) || defined (UNIXCOMMON) || defined (HAVE_SDL)
|
||||||
else
|
else
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
@ -236,7 +236,7 @@ void V_SetPaletteLump(const char *pal)
|
||||||
#ifdef HWRENDER
|
#ifdef HWRENDER
|
||||||
if (rendermode != render_soft && rendermode != render_none)
|
if (rendermode != render_soft && rendermode != render_none)
|
||||||
HWR_SetPalette(pLocalPalette);
|
HWR_SetPalette(pLocalPalette);
|
||||||
#if (defined (__unix__) && !defined (MSDOS)) || defined (UNIXCOMMON) || defined (SDL)
|
#if (defined (__unix__) && !defined (MSDOS)) || defined (UNIXCOMMON) || defined (HAVE_SDL)
|
||||||
else
|
else
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -53,13 +53,12 @@ endif
|
||||||
|
|
||||||
# name of the exefile
|
# name of the exefile
|
||||||
ifdef SDL
|
ifdef SDL
|
||||||
EXENAME?=srb2sdl.exe
|
EXENAME?=srb2sdl2.exe
|
||||||
else
|
else
|
||||||
EXENAME?=srb2win.exe
|
EXENAME?=srb2win.exe
|
||||||
endif
|
endif
|
||||||
|
|
||||||
ifdef SDL
|
ifdef SDL
|
||||||
D_FILES+=$(D_DIR)/fmod.dll
|
|
||||||
i_system_o+=$(OBJDIR)/SRB2.res
|
i_system_o+=$(OBJDIR)/SRB2.res
|
||||||
i_main_o+=$(OBJDIR)/win_dbg.o
|
i_main_o+=$(OBJDIR)/win_dbg.o
|
||||||
ifndef NOHW
|
ifndef NOHW
|
||||||
|
|
Loading…
Reference in a new issue