Slaughtered SDL 1.2 code

This commit is contained in:
Monster Iestyn 2017-10-07 18:32:50 +01:00
parent 52620ac9b1
commit b2bd073677
53 changed files with 0 additions and 33890 deletions

View file

@ -165,13 +165,7 @@ UNIXCOMMON=1
endif endif
ifdef SDL ifdef SDL
#SDL 2.0
ifndef SDL12
include sdl/Makefile.cfg include sdl/Makefile.cfg
#SDL 1.2
else
include sdl12/Makefile.cfg
endif #ifndef SDL12
endif #ifdef SDL endif #ifdef SDL
ifdef DISTCC ifdef DISTCC

View file

@ -357,13 +357,7 @@ OBJDUMP_OPTS?=--wide --source --line-numbers
LD=$(CC) LD=$(CC)
ifdef SDL ifdef SDL
# SDL 2.0
ifndef SDL12
INTERFACE=sdl INTERFACE=sdl
# SDL 1.2
else
INTERFACE=sdl12
endif
OBJDIR:=$(OBJDIR)/SDL OBJDIR:=$(OBJDIR)/SDL
endif endif

View file

@ -1,506 +0,0 @@
/*
SDL_image: An example image loading library for use with SDL
Copyright (C) 1999-2004 Sam Lantinga
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library 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
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with this library; if not, write to the Free
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Sam Lantinga
slouken@libsdl.org
*/
/* $Id: IMG_xpm.c,v 1.10 2004/01/04 22:04:38 slouken Exp $ */
/*
* XPM (X PixMap) image loader:
*
* Supports the XPMv3 format, EXCEPT:
* - hotspot coordinates are ignored
* - only colour ('c') colour symbols are used
* - rgb.txt is not used (for portability), so only RGB colours
* are recognized (#rrggbb etc) - only a few basic colour names are
* handled
*
* The result is an 8bpp indexed surface if possible, otherwise 32bpp.
* The colourkey is correctly set if transparency is used.
*
* Besides the standard API, also provides
*
* SDL_Surface *IMG_ReadXPMFromArray(char **xpm)
*
* that reads the image data from an XPM file included in the C source.
*
* TODO: include rgb.txt here. The full table (from solaris 2.6) only
* requires about 13K in binary form.
*/
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <ctype.h>
//#include "SDL_image.h"
#ifdef LOAD_XPM
/* See if an image is contained in a data source */
#if 0
int IMG_isXPM(SDL_RWops *src)
{
char magic[9];
return (SDL_RWread(src, magic, sizeof (magic), 1)
&& memcmp(magic, "/* XPM */", 9) == 0);
}
#endif
/* Hash table to look up colors from pixel strings */
#define STARTING_HASH_SIZE 256
struct hash_entry {
char *key;
Uint32 color;
struct hash_entry *next;
};
struct color_hash {
struct hash_entry **table;
struct hash_entry *entries; /* array of all entries */
struct hash_entry *next_free;
size_t size;
int maxnum;
};
static int hash_key(const char *key, int cpp, size_t size)
{
int hash;
hash = 0;
while ( cpp-- > 0 ) {
hash = hash * 33 + *key++;
}
return (int)(hash & (size - 1));
}
static struct color_hash *create_colorhash(int maxnum)
{
size_t bytes;
int s;
struct color_hash *hash;
/* we know how many entries we need, so we can allocate
everything here */
hash = malloc(sizeof *hash);
if (!hash)
return NULL;
/* use power-of-2 sized hash table for decoding speed */
for (s = STARTING_HASH_SIZE; s < maxnum; s <<= 1)
;
hash->size = s;
hash->maxnum = maxnum;
bytes = hash->size * sizeof (struct hash_entry **);
hash->entries = NULL; /* in case malloc fails */
hash->table = malloc(bytes);
if (!hash->table)
return NULL;
memset(hash->table, 0, bytes);
hash->entries = malloc(maxnum * sizeof (struct hash_entry));
if (!hash->entries)
{
free(hash->table);
return NULL;
}
hash->next_free = hash->entries;
return hash;
}
static int add_colorhash(struct color_hash *hash,
char *key, int cpp, Uint32 color)
{
const int indexkey = hash_key(key, cpp, hash->size);
struct hash_entry *e = hash->next_free++;
e->color = color;
e->key = key;
e->next = hash->table[indexkey];
hash->table[indexkey] = e;
return 1;
}
/* fast lookup that works if cpp == 1 */
#define QUICK_COLORHASH(hash, key) ((hash)->table[*(const Uint8 *)(key)]->color)
static Uint32 get_colorhash(struct color_hash *hash, const char *key, int cpp)
{
struct hash_entry *entry = hash->table[hash_key(key, cpp, hash->size)];
while (entry) {
if (memcmp(key, entry->key, cpp) == 0)
return entry->color;
entry = entry->next;
}
return 0; /* garbage in - garbage out */
}
static void free_colorhash(struct color_hash *hash)
{
if (hash && hash->table) {
free(hash->table);
free(hash->entries);
free(hash);
}
}
/* portable case-insensitive string comparison */
static int string_equal(const char *a, const char *b, size_t n)
{
while (*a && *b && n) {
if (toupper((unsigned char)*a) != toupper((unsigned char)*b))
return 0;
a++;
b++;
n--;
}
return *a == *b;
}
#undef ARRAYSIZE
#define ARRAYSIZE(a) (int)(sizeof (a) / sizeof ((a)[0]))
/*
* convert colour spec to RGB (in 0xrrggbb format).
* return 1 if successful.
*/
static int color_to_rgb(const char *spec, size_t speclen, Uint32 *rgb)
{
/* poor man's rgb.txt */
static struct { const char *name; Uint32 rgb; } known[] = {
{"none", 0xffffffff},
{"black", 0x00000000},
{"white", 0x00ffffff},
{"red", 0x00ff0000},
{"green", 0x0000ff00},
{"blue", 0x000000ff}
};
if (spec[0] == '#') {
char buf[7];
switch (speclen) {
case 4:
buf[0] = buf[1] = spec[1];
buf[2] = buf[3] = spec[2];
buf[4] = buf[5] = spec[3];
break;
case 7:
memcpy(buf, spec + 1, 6);
break;
case 13:
buf[0] = spec[1];
buf[1] = spec[2];
buf[2] = spec[5];
buf[3] = spec[6];
buf[4] = spec[9];
buf[5] = spec[10];
break;
}
buf[6] = '\0';
*rgb = (Uint32)strtol(buf, NULL, 16);
return 1;
} else {
int i;
for (i = 0; i < ARRAYSIZE(known); i++)
if (string_equal(known[i].name, spec, speclen)) {
*rgb = known[i].rgb;
return 1;
}
return 0;
}
}
#ifndef MAX
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#endif
static char *linebuf;
static int buflen;
static const char *error;
/*
* Read next line from the source.
* If len > 0, it's assumed to be at least len chars (for efficiency).
* Return NULL and set error upon EOF or parse error.
*/
static const char *get_next_line(const char ***lines, SDL_RWops *src, int len)
{
char *linebufnew;
if (lines) {
return *(*lines)++;
} else {
char c;
int n;
do {
if (SDL_RWread(src, &c, 1, 1) <= 0) {
error = "Premature end of data";
return NULL;
}
} while (c != '"');
if (len) {
len += 4; /* "\",\n\0" */
if (len > buflen){
buflen = len;
linebufnew = realloc(linebuf, buflen);
if(!linebufnew) {
free(linebuf);
error = "Out of memory";
return NULL;
}
linebuf = linebufnew;
}
if (SDL_RWread(src, linebuf, len - 1, 1) <= 0) {
error = "Premature end of data";
return NULL;
}
n = len - 2;
} else {
n = 0;
do {
if (n >= buflen - 1) {
if (buflen == 0)
buflen = 16;
buflen *= 2;
linebufnew = realloc(linebuf, buflen);
if(!linebufnew) {
free(linebuf);
error = "Out of memory";
return NULL;
}
linebuf = linebufnew;
}
if (SDL_RWread(src, linebuf + n, 1, 1) <= 0) {
error = "Premature end of data";
return NULL;
}
} while (linebuf[n++] != '"');
n--;
}
linebuf[n] = '\0';
return linebuf;
}
}
#define SKIPSPACE(p) \
do { \
while (isspace((unsigned char)*(p))) \
++(p); \
} while (0)
#define SKIPNONSPACE(p) \
do { \
while (!isspace((unsigned char)*(p)) && *p) \
++(p); \
} while (0)
/* read XPM from either array or RWops */
static SDL_Surface *load_xpm(const char **xpm, SDL_RWops *src)
{
SDL_Surface *image = NULL;
int indexc;
int x, y;
int w, h, ncolors, cpp;
int indexed;
Uint8 *dst;
struct color_hash *colors = NULL;
SDL_Color *im_colors = NULL;
char *keystrings = NULL, *nextkey;
const char *line;
const char ***xpmlines = NULL;
int pixels_len;
error = NULL;
linebuf = NULL;
buflen = 0;
if (xpm)
xpmlines = &xpm;
line = get_next_line(xpmlines, src, 0);
if (!line)
goto done;
/*
* The header string of an XPMv3 image has the format
*
* <width> <height> <ncolors> <cpp> [ <hotspot_x> <hotspot_y> ]
*
* where the hotspot coords are intended for mouse cursors.
* Right now we don't use the hotspots but it should be handled
* one day.
*/
if (sscanf(line, "%d %d %d %d", &w, &h, &ncolors, &cpp) != 4
|| w <= 0 || h <= 0 || ncolors <= 0 || cpp <= 0) {
error = "Invalid format description";
goto done;
}
keystrings = malloc(ncolors * cpp);
if (!keystrings) {
error = "Out of memory";
goto done;
}
nextkey = keystrings;
/* Create the new surface */
if (ncolors <= 256) {
indexed = 1;
image = SDL_CreateRGBSurface(SDL_SWSURFACE, w, h, 8,
0, 0, 0, 0);
im_colors = image->format->palette->colors;
image->format->palette->ncolors = ncolors;
} else {
indexed = 0;
image = SDL_CreateRGBSurface(SDL_SWSURFACE, w, h, 32,
0xff0000, 0x00ff00, 0x0000ff, 0);
}
if (!image) {
/* Hmm, some SDL error (out of memory?) */
goto done;
}
/* Read the colors */
colors = create_colorhash(ncolors);
if (!colors) {
error = "Out of memory";
goto done;
}
for (indexc = 0; indexc < ncolors; ++indexc ) {
const char *p;
line = get_next_line(xpmlines, src, 0);
if (!line)
goto done;
p = line + cpp + 1;
/* parse a colour definition */
for (;;) {
char nametype;
const char *colname;
Uint32 rgb, pixel;
SKIPSPACE(p);
if (!*p) {
error = "colour parse error";
goto done;
}
nametype = *p;
SKIPNONSPACE(p);
SKIPSPACE(p);
colname = p;
SKIPNONSPACE(p);
if (nametype == 's')
continue; /* skip symbolic colour names */
if (!color_to_rgb(colname, p - colname, &rgb))
continue;
memcpy(nextkey, line, cpp);
if (indexed) {
SDL_Color *c = im_colors + indexc;
c->r = (Uint8)(rgb >> 16);
c->g = (Uint8)(rgb >> 8);
c->b = (Uint8)(rgb);
pixel = indexc;
} else
pixel = rgb;
add_colorhash(colors, nextkey, cpp, pixel);
nextkey += cpp;
if (rgb == 0xffffffff)
SDL_SetColorKey(image, SDL_SRCCOLORKEY, pixel);
break;
}
}
/* Read the pixels */
pixels_len = w * cpp;
dst = image->pixels;
for (y = 0; y < h; y++) {
line = get_next_line(xpmlines, src, pixels_len);
if (indexed) {
/* optimization for some common cases */
if (cpp == 1)
for (x = 0; x < w; x++)
dst[x] = (Uint8)QUICK_COLORHASH(colors,
line + x);
else
for (x = 0; x < w; x++)
dst[x] = (Uint8)get_colorhash(colors,
line + x * cpp,
cpp);
} else {
for (x = 0; x < w; x++)
((Uint32*)dst)[x] = get_colorhash(colors,
line + x * cpp,
cpp);
}
dst += image->pitch;
}
done:
if (error) {
SDL_FreeSurface(image);
image = NULL;
SDL_SetError(error);
}
free(keystrings);
free_colorhash(colors);
free(linebuf);
return(image);
}
/* Load a XPM type image from an RWops datasource */
#if 0
SDL_Surface *IMG_LoadXPM_RW(SDL_RWops *src)
{
if ( !src ) {
/* The error message has been set in SDL_RWFromFile */
return NULL;
}
return load_xpm(NULL, src);
}
#endif
static inline SDL_Surface *IMG_ReadXPMFromArray(const char **xpm)
{
return load_xpm(xpm, NULL);
}
#else /* not LOAD_XPM */
/* See if an image is contained in a data source */
#if 0
int IMG_isXPM(SDL_RWops *src)
{
return(0);
}
/* Load a XPM type image from an SDL datasource */
SDL_Surface *IMG_LoadXPM_RW(SDL_RWops *src)
{
return(NULL);
}
#endif
static inline SDL_Surface *IMG_ReadXPMFromArray(const char **xpm)
{
return NULL;
}
#endif /* not LOAD_XPM */

View file

@ -1,17 +0,0 @@
#
# sdl12/makeCYG.cfg for SRB2/Cygwin
#
#
#Cygwin, for debugging
NOHW=1
NOHS=1
NOASM=1
OPTS+=-DLINUX
i_system_o+=$(OBJDIR)/SRB2.res
# name of the exefile
EXENAME?=lsdlsrb2.exe

View file

@ -1,61 +0,0 @@
#
# sdl12/makeNIX.cfg for SRB2/?nix
#
#Valgrind support
ifdef VALGRIND
VALGRIND_PKGCONFIG?=valgrind
VALGRIND_CFLAGS?=$(shell $(PKG_CONFIG) $(VALGRIND_PKGCONFIG) --cflags)
VALGRIND_LDFLAGS?=$(shell $(PKG_CONFIG) $(VALGRIND_PKGCONFIG) --libs)
ZDEBUG=1
LIBS+=$(VALGRIND_LDFLAGS)
ifdef GCC46
WFLAGS+=-Wno-error=unused-but-set-variable
WFLAGS+=-Wno-unused-but-set-variable
endif
endif
#
#here is GNU/Linux and other
#
OPTS=-DUNIXCOMMON
#LDFLAGS = -L/usr/local/lib
LIBS=-lm
ifdef LINUX
LIBS+=-lrt
ifdef NOTERMIOS
OPTS+=-DNOTERMIOS
endif
endif
#
#here is Solaris
#
ifdef SOLARIS
NOIPX=1
NOASM=1
OPTS+=-DSOLARIS -DINADDR_NONE=INADDR_ANY -DBSD_COMP
OPTS+=-I/usr/local/include -I/opt/sfw/include
LDFLAGS+=-L/opt/sfw/lib
LIBS+=-lsocket -lnsl
endif
#
#here is FreeBSD
#
ifdef FREEBSD
OPTS+=-DLINUX -DFREEBSD -I/usr/X11R6/include
SDL_CONFIG?=sdl11-config
LDFLAGS+=-L/usr/X11R6/lib
LIBS+=-lipx -lkvm
endif
ifndef NOHW
OPTS+=-I/usr/X11R6/include
LDFLAGS+=-L/usr/X11R6/lib
endif
# name of the exefile
EXENAME?=lsdlsrb2

View file

@ -1,137 +0,0 @@
#
# sdl12/makefile.cfg for SRB2/SDL
#
#
#SDL...., *looks at Alam*, THIS IS A MESS!
#
ifdef UNIXCOMMON
include sdl12/MakeNIX.cfg
endif
ifdef PANDORA
include sdl12/SRB2Pandora/Makefile.cfg
endif #ifdef PANDORA
ifdef CYGWIN32
include sdl12/MakeCYG.cfg
endif #ifdef CYGWIN32
ifdef SDL_PKGCONFIG
SDL_CFLAGS?=$(shell $(PKG_CONFIG) $(SDL_PKGCONFIG) --cflags)
SDL_LDFLAGS?=$(shell $(PKG_CONFIG) $(SDL_PKGCONFIG) --libs)
else
ifdef PREFIX
SDL_CONFIG?=$(PREFIX)-sdl-config
else
SDL_CONFIG?=sdl-config
endif
ifdef STATIC
SDL_CFLAGS?=$(shell $(SDL_CONFIG) --cflags)
SDL_LDFLAGS?=$(shell $(SDL_CONFIG) --static-libs)
else
SDL_CFLAGS?=$(shell $(SDL_CONFIG) --cflags)
SDL_LDFLAGS?=$(shell $(SDL_CONFIG) --libs)
endif
endif
#use the x86 asm code
ifndef CYGWIN32
ifndef NOASM
USEASM=1
endif
endif
OBJS+=$(OBJDIR)/i_video.o $(OBJDIR)/dosstr.o $(OBJDIR)/endtxt.o $(OBJDIR)/hwsym_sdl.o
OPTS+=-DDIRECTFULLSCREEN -DHAVE_SDL
ifndef NOHW
OBJS+=$(OBJDIR)/r_opengl.o $(OBJDIR)/ogl_sdl.o
endif
ifndef NOHS
ifdef OPENAL
OBJS+=$(OBJDIR)/s_openal.o
OPTS+=-DSTATIC3DS
STATICHS=1
else
ifdef FMOD
OBJS+=$(OBJDIR)/s_fmod.o
OPTS+=-DSTATIC3DS
STATICHS=1
else
ifdef MINGW
ifdef DS3D
OBJS+=$(OBJDIR)/s_ds3d.o
OPTS+=-DSTATIC3DS
STATICHS=1
endif
endif
endif
endif
endif
ifdef FILTERS
OBJS+=$(OBJDIR)/filters.o $(OBJDIR)/hq2x.o $(OBJDIR)/lq2x.o
OPTS+=-DHAVE_FILTER
endif
ifdef NOMIXER
i_sound_o=$(OBJDIR)/sdl_sound.o
else
i_sound_o=$(OBJDIR)/mixer_sound.o
OPTS+=-DHAVE_MIXER
SDL_LDFLAGS+=-lSDL_mixer
endif
ifdef SDL_TTF
OPTS+=-DHAVE_TTF
SDL_LDFLAGS+=-lSDL_ttf -lfreetype -lz
OBJS+=$(OBJDIR)/i_ttf.o
endif
#ifdef SDL_IMAGE
# OPTS+=-DHAVE_IMAGE
# SDL_LDFLAGS+=-lSDL_image
#endif
ifdef SDL_NET
OPTS+=-DHAVE_SDLNET
SDL_LDFLAGS+=-lSDL_net
endif
ifdef SDLMAIN
OPTS+=-DSDLMAIN
else
ifdef MINGW
SDL_CFLAGS+=-Umain
SDL_LDFLAGS+=-mconsole
endif
endif
ifndef NOHW
ifdef OPENAL
ifdef MINGW
LIBS:=-lopenal32 $(LIBS)
else
LIBS:=-lopenal $(LIBS)
endif
else
ifdef MINGW
ifdef DS3D
LIBS:=-ldsound -luuid $(LIBS)
endif
endif
endif
endif
CFLAGS+=$(SDL_CFLAGS)
LIBS:=$(SDL_LDFLAGS) $(LIBS)
ifdef STATIC
LIBS+=$(shell $(SDL_CONFIG) --static-libs)
endif

View file

@ -1,425 +0,0 @@
/* XPM */
static char * C:\Repo\srb2\src\sdl\SDL_icon_xpm[] = {
"32 32 390 2",
" c None",
". c #4F4F70",
"+ c #4D4D87",
"@ c #4D4D84",
"# c #4E4E6C",
"$ c #6C6C95",
"% c #5E5EB2",
"& c #6B6BE7",
"* c #7373F9",
"= c #7C7CFF",
"- c #6F70E7",
"; c #494BB2",
"> c #4F4FA3",
", c #6464D4",
"' c #7979F5",
") c #5F5FCA",
"! c #5D5D93",
"~ c #3A3A9F",
"{ c #6060AC",
"] c #777793",
"^ c #5C5CB3",
"/ c #7373EA",
"( c #7A7AFF",
"_ c #7575FF",
": c #7979FF",
"< c #6264DD",
"[ c #47478C",
"} c #564567",
"| c #4647D0",
"1 c #5C5CAE",
"2 c #5E5EFF",
"3 c #2929FF",
"4 c #1D1DFF",
"5 c #1919D1",
"6 c #4F4F90",
"7 c #1E1ECE",
"8 c #5858FF",
"9 c #6767A8",
"0 c #4949A0",
"a c #7070FB",
"b c #7D7DFF",
"c c #7777FF",
"d c #7373FF",
"e c #7272FF",
"f c #7878FF",
"g c #6465D8",
"h c #363886",
"i c #9F7655",
"j c #C89B5C",
"k c #1D1CB7",
"l c #3031B1",
"m c #1919F4",
"n c #1111FF",
"o c #1818FF",
"p c #1B1BFF",
"q c #1C1CFF",
"r c #2626B3",
"s c #1E1EC8",
"t c #1A1AE8",
"u c #24249F",
"v c #2F2FD2",
"w c #7676FF",
"x c #6869E2",
"y c #414290",
"z c #8C6751",
"A c #FCBA68",
"B c #E9BD7D",
"C c #201EB8",
"D c #090AB8",
"E c #1616EB",
"F c #1818FD",
"G c #1414EE",
"H c #1010E1",
"I c #0E0EE2",
"J c #0E0EF4",
"K c #0606B2",
"L c #7A7A89",
"M c #0C0C9A",
"N c #0A0AA7",
"O c #2424E4",
"P c #6669E6",
"Q c #4F4A8F",
"R c #BF853B",
"S c #FFD98D",
"T c #CDAB76",
"U c #1717C4",
"V c #0F10BA",
"W c #0909B6",
"X c #0505C3",
"Y c #0000B6",
"Z c #0000BE",
"` c #0000AD",
" . c #1D1D83",
".. c #63638E",
"+. c #090975",
"@. c #1414F3",
"#. c #5B5BFF",
"$. c #7B7BFF",
"%. c #7070FF",
"&. c #6E6EFF",
"*. c #7172F6",
"=. c #625DAF",
"-. c #BA9E6C",
";. c #887167",
">. c #090DF2",
",. c #1313BE",
"'. c #000085",
"). c #0000AC",
"!. c #0202AA",
"~. c #242488",
"{. c #1414C7",
"]. c #1717FF",
"^. c #5959FF",
"/. c #7F7FFF",
"(. c #7474FF",
"_. c #7171FF",
":. c #8686FF",
"<. c #7574FF",
"[. c #797CFF",
"}. c #5756B8",
"|. c #1C19A4",
"1. c #1617FF",
"2. c #1212BD",
"3. c #040485",
"4. c #0707A4",
"5. c #1B1B71",
"6. c #373797",
"7. c #1616FF",
"8. c #5050FF",
"9. c #8080FF",
"0. c #AAAAFF",
"a. c #AEAEF6",
"b. c #8A8AEF",
"c. c #6969FB",
"d. c #2728FF",
"e. c #1314FF",
"f. c #1919FF",
"g. c #1313E8",
"h. c #1F1FF4",
"i. c #5454FF",
"j. c #6D6DF0",
"k. c #6868B5",
"l. c #0B0BB8",
"m. c #1212C5",
"n. c #1616FC",
"o. c #1515FF",
"p. c #1212FF",
"q. c #2323FF",
"r. c #3636FF",
"s. c #4040FF",
"t. c #4343F9",
"u. c #5D5DB8",
"v. c #7F7F92",
"w. c #878793",
"x. c #4B4B94",
"y. c #0B0CE2",
"z. c #1313FF",
"A. c #4C4CFF",
"B. c #8282FF",
"C. c #7171ED",
"D. c #636394",
"E. c #575785",
"F. c #A9A99C",
"G. c #1414BC",
"H. c #1414FF",
"I. c #0707FD",
"J. c #2525AA",
"K. c #A8A8A4",
"L. c #EBEBE2",
"M. c #F9F9F2",
"N. c #E1E1CC",
"O. c #4D4D9F",
"P. c #0B0BF7",
"Q. c #2121FF",
"R. c #3232FF",
"S. c #5555FF",
"T. c #6161B4",
"U. c #B5B5B2",
"V. c #FFFFF8",
"W. c #4F4F9A",
"X. c #0B0BF5",
"Y. c #1616C5",
"Z. c #A8A8A1",
"`. c #FFFFFC",
" + c #FFFFFF",
".+ c #C0C0C4",
"++ c #1212D4",
"@+ c #4444FF",
"#+ c #6464FF",
"$+ c #8383FF",
"%+ c #6767C3",
"&+ c #E4E4E4",
"*+ c #9494AE",
"=+ c #0808DF",
"-+ c #0D0DF2",
";+ c #61619A",
">+ c #F1F1E0",
",+ c #E8E8DD",
"'+ c #2424BB",
")+ c #1010FF",
"!+ c #3434FF",
"~+ c #6161FF",
"{+ c #6969D2",
"]+ c #EFEFF0",
"^+ c #C2C2BA",
"/+ c #1010B6",
"(+ c #0909AC",
"_+ c #A4A49A",
":+ c #EAEADE",
"<+ c #2525B8",
"[+ c #2F2FFF",
"}+ c #3C3CB5",
"|+ c #EEEEEE",
"1+ c #BBBBAD",
"2+ c #0B0B56",
"3+ c #0B0BFC",
"4+ c #1212EF",
"5+ c #0C0C3E",
"6+ c #919187",
"7+ c #DEDED6",
"8+ c #1F1FC0",
"9+ c #1A1AFF",
"0+ c #1717FA",
"a+ c #1515F8",
"b+ c #1111FC",
"c+ c #494992",
"d+ c #999998",
"e+ c #3E3E3B",
"f+ c #3C3C99",
"g+ c #535397",
"h+ c #5A5A4D",
"i+ c #6F6F70",
"j+ c #BFBFC9",
"k+ c #1111D6",
"l+ c #1515F1",
"m+ c #0F0FE2",
"n+ c #0D0DD9",
"o+ c #0909CD",
"p+ c #0808C7",
"q+ c #0505C7",
"r+ c #0303CB",
"s+ c #0101C0",
"t+ c #0202AF",
"u+ c #0606AC",
"v+ c #121283",
"w+ c #BBBBBB",
"x+ c #BEBEBE",
"y+ c #2F2F2E",
"z+ c #C7C8BB",
"A+ c #D8DAD1",
"B+ c #272828",
"C+ c #929292",
"D+ c #8688C7",
"E+ c #0506F6",
"F+ c #1616F5",
"G+ c #0B0BD3",
"H+ c #0202B6",
"I+ c #0000AF",
"J+ c #0000B4",
"K+ c #0000BD",
"L+ c #0000BB",
"M+ c #00009E",
"N+ c #2C2C7E",
"O+ c #6A6A8B",
"P+ c #959595",
"Q+ c #F0F0F1",
"R+ c #E1E1E1",
"S+ c #8C8E90",
"T+ c #BEBEBF",
"U+ c #C9C7C5",
"V+ c #939699",
"W+ c #E7EAED",
"X+ c #CBCBC7",
"Y+ c #413B9B",
"Z+ c #0607DD",
"`+ c #0C0CE2",
" @ c #0303B9",
".@ c #0000A8",
"+@ c #181888",
"@@ c #6A6A6A",
"#@ c #626263",
"$@ c #4B4B4C",
"%@ c #3E3B36",
"&@ c #9B805C",
"*@ c #D9B07D",
"=@ c #C9AE89",
"-@ c #B9AF9E",
";@ c #C7C5C4",
">@ c #CBCCCF",
",@ c #C7C6C6",
"'@ c #AEA59A",
")@ c #B69974",
"!@ c #D8B87F",
"~@ c #9B8272",
"{@ c #0E0B9B",
"]@ c #0000B7",
"^@ c #0000B8",
"/@ c #000082",
"(@ c #00007A",
"_@ c #636379",
":@ c #62533E",
"<@ c #B59B6C",
"[@ c #DEB07B",
"}@ c #FECC90",
"|@ c #FFCE92",
"1@ c #FEC98C",
"2@ c #F1BD82",
"3@ c #D1A979",
"4@ c #BC9E73",
"5@ c #CCA777",
"6@ c #EAB980",
"7@ c #FFCD90",
"8@ c #FFD595",
"9@ c #FDD782",
"0@ c #413678",
"a@ c #0000AE",
"b@ c #000077",
"c@ c #010193",
"d@ c #0C0CE4",
"e@ c #38389E",
"f@ c #EEC585",
"g@ c #FFDA9D",
"h@ c #FFC992",
"i@ c #FFC88F",
"j@ c #FFC990",
"k@ c #FFCE93",
"l@ c #FFD094",
"m@ c #FFCC92",
"n@ c #C9A174",
"o@ c #EDBD88",
"p@ c #FAD287",
"q@ c #3A2F7F",
"r@ c #0000BA",
"s@ c #0000B0",
"t@ c #0101B2",
"u@ c #1111ED",
"v@ c #1919C1",
"w@ c #95887C",
"x@ c #DCAC6E",
"y@ c #FFD393",
"z@ c #FFCD94",
"A@ c #FFCA93",
"B@ c #FFC991",
"C@ c #FFC78E",
"D@ c #FFCB91",
"E@ c #E0B581",
"F@ c #BB9A6F",
"G@ c #FFDC97",
"H@ c #C1A173",
"I@ c #0E0B9A",
"J@ c #0000B5",
"K@ c #0101B6",
"L@ c #1010E0",
"M@ c #1616EC",
"N@ c #A68156",
"O@ c #E7AC6B",
"P@ c #FFC582",
"Q@ c #FFCF8F",
"R@ c #FFD195",
"S@ c #FFD296",
"T@ c #FFD396",
"U@ c #FFD193",
"V@ c #FFD28F",
"W@ c #D2A96B",
"X@ c #2F2482",
"Y@ c #0000C1",
"Z@ c #0000C0",
"`@ c #0000BF",
" # c #0101BF",
".# c #1212F0",
"+# c #767698",
"@# c #9C866E",
"## c #A9865D",
"$# c #C0915D",
"%# c #C89760",
"&# c #C29360",
"*# c #AD8A61",
"=# c #9D8971",
"-# c #7F7A7A",
";# c #70708F",
"># c #6F6F91",
",# c #575788",
"'# c #464687",
")# c #2F2F87",
"!# c #15158F",
"~# c #0101A8",
"{# c #1313FB",
"]# c #57579F",
"^# c #343487",
"/# c #434388",
" ",
" ",
" ",
" . + @ # ",
" $ % & * = - ; > , ' ) ! ",
" ~ { ] ^ / = ( _ : < [ } | 1 2 3 4 5 6 ",
" 7 8 9 0 a b c d e f g h i j k l m n o p q r ",
" s t u v _ f d d d w x y z A B C D E F G H I J K L ",
" M N O _ c e d d d _ P Q R S T U V W X Y Z ` ... ",
" +.@.#.$.d d d d %.&._ *.=.-.;.>.,.'.).!.~. ",
" {.].^./.(.d d _.$.:._ <.[.}.|.1.2.3.4.5. ",
" 6.7.7.4 8.e : w 9.0.a.b.c.2 d.e.f.g.h.i.j.k. ",
" l.m.n.o.p.q.r.s.t.u.v.w.x.y.z.o o z.A.B./.b C.D. ",
" E.F.G.].o H.z.I.J.K.L.M.N.O.P.o o o Q.R.S._.b B.T. ",
" U.V.W.X.f.f.7.Y.Z.`. + + +.+++].o o o.n z.q.@+#+$+%+ ",
" &+ +*+=+].o -+;+>+ + + + +,+'+H.o o o o o H.)+o !+~+{+ ",
" ]+ +^+/+H.o.(+_+ + + + + +:+<+z.o o o o o o o 7.n H.[+}+ ",
" |+ +1+2+3+4+5+6+ + + + + +7+8+H.o o f.9+f.9+f.F 0+a+b+o.c+ ",
" &+ +d+e+f+g+h+i+ + + + + +j+k+].f.9+l+m+n+o+p+q+r+s+t+u+v+ ",
" w+ +x+y+z+A+B+C+ + + + + +D+E+9+F+G+H+I+J+K+L+M+N+O+ ",
" P+Q+R+S+T+U+V+W+ + + + +X+Y+Z+`+ @I+J+Z .@+@E. ",
" @@#@$@%@&@*@=@-@;@>@,@'@)@!@~@{@]@^@I+/@(@_@ ",
" :@<@[@}@|@1@2@3@4@5@6@7@8@9@0@L+a@b@c@d@e@ ",
" f@g@h@i@i@j@k@l@|@m@n@o@p@q@r@s@t@u@p v@ ",
" w@x@y@z@A@B@i@C@D@E@F@G@H@I@L+J@K@L@p M@ ",
" N@O@P@Q@R@S@T@U@V@W@X@Y@Z@Y@`@ #.#p +# ",
" @###$#%#&#*#=#-#;#>#,#'#)#!#~#{#]# ",
" ^#/# ",
" ",
" ",
" ",
" "};

View file

@ -1,12 +0,0 @@
/* Include the SDL main definition header */
#include "SDL_main.h"
#ifdef main
#undef main
int main(int argc, char *argv[])
{
return(SDL_main(argc, argv));
}
#else
/* Nothing to do on this platform */;
#endif

View file

@ -1,11 +0,0 @@
/* SDLMain.m - main entry point for our Cocoa-ized SDL app
Initial Version: Darrell Walisser <dwaliss1@purdue.edu>
Non-NIB-Code & other changes: Max Horn <max@quendi.de>
Feel free to customize this file to suit your needs
*/
#import <Cocoa/Cocoa.h>
@interface SDLMain : NSObject
@end

View file

@ -1,374 +0,0 @@
/* SDLMain.m - main entry point for our Cocoa-ized SDL app
Initial Version: Darrell Walisser <dwaliss1@purdue.edu>
Non-NIB-Code & other changes: Max Horn <max@quendi.de>
Feel free to customize this file to suit your needs
*/
#import "SDL.h"
#import "SDL_macosx_main.h"
#import <sys/param.h> /* for MAXPATHLEN */
#import <unistd.h>
/* For some reaon, Apple removed setAppleMenu from the headers in 10.4,
but the method still is there and works. To avoid warnings, we declare
it ourselves here. */
@interface NSApplication(SDL_Missing_Methods)
- (void)setAppleMenu:(NSMenu *)menu;
@end
/* Use this flag to determine whether we use SDLMain.nib or not */
#define SDL_USE_NIB_FILE 0
/* Use this flag to determine whether we use CPS (docking) or not */
#define SDL_USE_CPS 1
#if SDL_USE_CPS
/* Portions of CPS.h */
typedef struct CPSProcessSerNum
{
UInt32 lo;
UInt32 hi;
} CPSProcessSerNum;
extern OSErr CPSGetCurrentProcess( CPSProcessSerNum *psn);
extern OSErr CPSEnableForegroundOperation( CPSProcessSerNum *psn, UInt32 _arg2, UInt32 _arg3, UInt32 _arg4, UInt32 _arg5);
extern OSErr CPSSetFrontProcess( CPSProcessSerNum *psn);
#endif /* SDL_USE_CPS */
static int gArgc;
static char **gArgv;
static BOOL gFinderLaunch;
static void addArgument(const char *value)
{
if(!gArgc)
gArgv = (char **)malloc(sizeof(*gArgv));
else
{
char **newgArgv = (char **)realloc(gArgv, sizeof(*gArgv) * (gArgc + 1));
if (!newgArgv)
{
newgArgv = malloc(sizeof(*gArgv) * (gArgc + 1));
memcpy(newgArgv, gArgv, sizeof(*gArgv) * gArgc);
free(gArgv);
}
gArgv = newgArgv;
}
gArgc++;
gArgv[gArgc - 1] = (char *)malloc(sizeof(char) * (strlen(value) + 1));
strcpy(gArgv[gArgc - 1], value);
}
static NSString *getApplicationName(void)
{
NSDictionary *dict;
NSString *appName = NULL;
/* Determine the application name */
dict = ( NSDictionary *)CFBundleGetInfoDictionary(CFBundleGetMainBundle());
if (dict)
appName = [dict objectForKey: @"CFBundleName"];
if (![appName length])
appName = [[NSProcessInfo processInfo] processName];
return appName;
}
#if SDL_USE_NIB_FILE
/* A helper category for NSString */
@interface NSString (ReplaceSubString)
- (NSString *)stringByReplacingRange:(NSRange)aRange with:(NSString *)aString;
@end
#endif
@interface SDLApplication : NSApplication
@end
@implementation SDLApplication
/* Invoked from the Quit menu item */
- (void)terminate:(id)sender
{
#if (__GNUC__ > 3) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1)
(void)sender;
#endif
/* Post a SDL_QUIT event */
SDL_Event event;
event.type = SDL_QUIT;
SDL_PushEvent(&event);
}
@end
/* The main class of the application, the application's delegate */
@implementation SDLMain
/* Set the working directory to the .app's parent directory */
- (void) setupWorkingDirectory:(BOOL)shouldChdir
{
if (shouldChdir)
{
char parentdir[MAXPATHLEN];
CFURLRef url = CFBundleCopyBundleURL(CFBundleGetMainBundle());
CFURLRef url2 = CFURLCreateCopyDeletingLastPathComponent(0, url);
if (CFURLGetFileSystemRepresentation(url2, true, (UInt8 *)parentdir, MAXPATHLEN))
{
assert ( chdir (parentdir) == 0 ); /* chdir to the binary app's parent */
}
CFRelease(url);
CFRelease(url2);
}
}
#if SDL_USE_NIB_FILE
/* Fix menu to contain the real app name instead of "SDL App" */
- (void)fixMenu:(NSMenu *)aMenu withAppName:(NSString *)appName
{
NSRange aRange;
NSEnumerator *enumerator;
NSMenuItem *menuItem;
aRange = [[aMenu title] rangeOfString:@"SDL App"];
if (aRange.length != 0)
[aMenu setTitle: [[aMenu title] stringByReplacingRange:aRange with:appName]];
enumerator = [[aMenu itemArray] objectEnumerator];
while ((menuItem = [enumerator nextObject]))
{
aRange = [[menuItem title] rangeOfString:@"SDL App"];
if (aRange.length != 0)
[menuItem setTitle: [[menuItem title] stringByReplacingRange:aRange with:appName]];
if ([menuItem hasSubmenu])
[self fixMenu:[menuItem submenu] withAppName:appName];
}
[ aMenu sizeToFit ];
}
#else
static void setApplicationMenu(void)
{
/* warning: this code is very odd */
NSMenu *appleMenu;
NSMenuItem *menuItem;
NSString *title;
NSString *appName;
appName = getApplicationName();
appleMenu = [[NSMenu alloc] initWithTitle:@""];
/* Add menu items */
title = [@"About " stringByAppendingString:appName];
[appleMenu addItemWithTitle:title action:@selector(orderFrontStandardAboutPanel:) keyEquivalent:@""];
[appleMenu addItem:[NSMenuItem separatorItem]];
title = [@"Hide " stringByAppendingString:appName];
[appleMenu addItemWithTitle:title action:@selector(hide:) keyEquivalent:@"h"];
menuItem = (NSMenuItem *)[appleMenu addItemWithTitle:@"Hide Others" action:@selector(hideOtherApplications:) keyEquivalent:@"h"];
[menuItem setKeyEquivalentModifierMask:(NSAlternateKeyMask|NSCommandKeyMask)];
[appleMenu addItemWithTitle:@"Show All" action:@selector(unhideAllApplications:) keyEquivalent:@""];
[appleMenu addItem:[NSMenuItem separatorItem]];
title = [@"Quit " stringByAppendingString:appName];
[appleMenu addItemWithTitle:title action:@selector(terminate:) keyEquivalent:@"q"];
/* Put menu into the menubar */
menuItem = [[NSMenuItem alloc] initWithTitle:@"" action:nil keyEquivalent:@""];
[menuItem setSubmenu:appleMenu];
[[NSApp mainMenu] addItem:menuItem];
/* Tell the application object that this is now the application menu */
[NSApp setAppleMenu:appleMenu];
/* Finally give up our references to the objects */
[appleMenu release];
[menuItem release];
}
/* Create a window menu */
static void setupWindowMenu(void)
{
NSMenu *windowMenu;
NSMenuItem *windowMenuItem;
NSMenuItem *menuItem;
windowMenu = [[NSMenu alloc] initWithTitle:@"Window"];
/* "Minimize" item */
menuItem = [[NSMenuItem alloc] initWithTitle:@"Minimize" action:@selector(performMiniaturize:) keyEquivalent:@"m"];
[windowMenu addItem:menuItem];
[menuItem release];
/* Put menu into the menubar */
windowMenuItem = [[NSMenuItem alloc] initWithTitle:@"Window" action:nil keyEquivalent:@""];
[windowMenuItem setSubmenu:windowMenu];
[[NSApp mainMenu] addItem:windowMenuItem];
/* Tell the application object that this is now the window menu */
[NSApp setWindowsMenu:windowMenu];
/* Finally give up our references to the objects */
[windowMenu release];
[windowMenuItem release];
}
/* Replacement for NSApplicationMain */
static void CustomApplicationMain (int argc, char **argv)
{
#if (__GNUC__ > 3) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1)
(void)argc;
(void)argv;
#endif
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
SDLMain *sdlMain;
/* Ensure the application object is initialised */
[SDLApplication sharedApplication];
#if SDL_USE_CPS
{
CPSProcessSerNum PSN;
/* Tell the dock about us */
if (!CPSGetCurrentProcess(&PSN))
if (!CPSEnableForegroundOperation(&PSN,0x03,0x3C,0x2C,0x1103))
if (!CPSSetFrontProcess(&PSN))
[SDLApplication sharedApplication];
}
#endif /* SDL_USE_CPS */
/* Set up the menubar */
[NSApp setMainMenu:[[NSMenu alloc] init]];
setApplicationMenu();
setupWindowMenu();
/* Create SDLMain and make it the app delegate */
sdlMain = [[SDLMain alloc] init];
[NSApp setDelegate:sdlMain];
/* Start the main event loop */
[NSApp run];
[sdlMain release];
[pool release];
}
#endif
- (BOOL)application:(NSApplication *)theApplication openFile:(NSString *)filename
{
#if (__GNUC__ > 3) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1)
(void)theApplication;
#endif
addArgument("-iwad");
addArgument([filename UTF8String]);
return YES;
}
/* Called when the internal event loop has just started running */
- (void) applicationDidFinishLaunching: (NSNotification *) note
{
#if (__GNUC__ > 3) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1)
(void)note;
#endif
int status;
/* Set the working directory to the .app's parent directory */
[self setupWorkingDirectory:gFinderLaunch];
#if SDL_USE_NIB_FILE
/* Set the main menu to contain the real app name instead of "SDL App" */
[self fixMenu:[NSApp mainMenu] withAppName:getApplicationName()];
#endif
if (!getenv("SRB2WADDIR"))
setenv("SRB2WADDIR", [[[NSBundle mainBundle] resourcePath] UTF8String], 1);
/* Hand off to main application code */
status = SDL_main (gArgc, gArgv);
/* We're done, thank you for playing */
exit(status);
}
@end
@implementation NSString (ReplaceSubString)
- (NSString *)stringByReplacingRange:(NSRange)aRange with:(NSString *)aString
{
size_t bufferSize;
size_t selfLen = [self length];
size_t aStringLen = [aString length];
unichar *buffer;
NSRange localRange;
NSString *result;
bufferSize = selfLen + aStringLen - aRange.length;
buffer = NSAllocateMemoryPages(bufferSize*sizeof(unichar));
/* Get first part into buffer */
localRange.location = 0;
localRange.length = aRange.location;
[self getCharacters:buffer range:localRange];
/* Get middle part into buffer */
localRange.location = 0;
localRange.length = aStringLen;
[aString getCharacters:(buffer+aRange.location) range:localRange];
/* Get last part into buffer */
localRange.location = aRange.location + aRange.length;
localRange.length = selfLen - localRange.location;
[self getCharacters:(buffer+aRange.location+aStringLen) range:localRange];
/* Build output string */
result = [NSString stringWithCharacters:buffer length:bufferSize];
NSDeallocateMemoryPages(buffer, bufferSize);
return result;
}
@end
#ifdef main
# undef main
#endif
/* Main entry point to executable - should *not* be SDL_main! */
int main (int argc, char **argv)
{
/* Copy the arguments into a global variable */
/* This is passed if we are launched by double-clicking */
if ( argc >= 2 && strncmp (argv[1], "-psn", 4) == 0 ) {
gArgc = 1;
gFinderLaunch = YES;
} else {
gArgc = argc;
gFinderLaunch = NO;
}
gArgv = argv;
/* Some additional arguments we always want to run with. */
//addArgument("-opengl");
#if SDL_USE_NIB_FILE
[SDLApplication poseAsClass:[NSApplication class]];
NSApplicationMain (argc, argv);
#else
CustomApplicationMain (argc, argv);
#endif
return 0;
}

View file

@ -1,7 +0,0 @@
/* Include the SDL main definition header */
#include "SDL_main.h"
void XBoxStartup()
{
SDL_main(0, NULL); /// \todo ?
}

View file

@ -1,334 +0,0 @@
/*
SDL_main.c, placed in the public domain by Sam Lantinga 4/13/98
The WinMain function -- calls your program's main() function
*/
#include <stdio.h>
#include <string.h>
#include <ctype.h>
#include <stdlib.h>
#define RPC_NO_WINDOWS_H
#include <windows.h>
#include <malloc.h> /* For _alloca() */
#include <tchar.h>
# define DIR_SEPERATOR TEXT("/")
# include <direct.h>
/* Include the SDL main definition header */
#ifdef _MSC_VER
#pragma warning(disable : 4214 4244)
#endif
#include "SDL.h"
#include "SDL_main.h"
#ifdef _MSC_VER
#pragma warning(default : 4214 4244)
#endif
#include "../../win32/win_dbg.h"
#define USE_MESSAGEBOX
#ifdef main
# ifndef _WIN32_WCE_EMULATION
# undef main
# endif /* _WIN32_WCE_EMULATION */
#endif /* main */
/* The standard output files */
#define STDOUT_FILE TEXT("stdout.txt")
#define STDERR_FILE TEXT("stderr.txt")
#ifndef NO_STDIO_REDIRECT
static TCHAR stdoutPath[MAX_PATH];
static TCHAR stderrPath[MAX_PATH];
#endif
/* Parse a command line buffer into arguments */
static int ParseCommandLine(char *cmdline, char **argv)
{
char *bufp;
int argc;
argc = 0;
for ( bufp = cmdline; *bufp; ) {
/* Skip leading whitespace */
while ( isspace(*bufp) ) {
++bufp;
}
/* Skip over argument */
if ( *bufp == '"' ) {
++bufp;
if ( *bufp ) {
if ( argv ) {
argv[argc] = bufp;
}
++argc;
}
/* Skip over word */
while ( *bufp && (*bufp != '"') ) {
++bufp;
}
} else {
if ( *bufp ) {
if ( argv ) {
argv[argc] = bufp;
}
++argc;
}
/* Skip over word */
while ( *bufp && ! isspace(*bufp) ) {
++bufp;
}
}
if ( *bufp ) {
if ( argv ) {
*bufp = '\0';
}
++bufp;
}
}
if ( argv ) {
argv[argc] = NULL;
}
return(argc);
}
/* Show an error message */
static void ShowError(const char *title, const char *message)
{
/* If USE_MESSAGEBOX is defined, you need to link with user32.lib */
#ifdef USE_MESSAGEBOX
MessageBoxA(NULL,
message,
title,
MB_ICONEXCLAMATION|MB_OK);
#else
fprintf(stderr, "%s: %s\n", title, message);
#endif
}
/* Pop up an out of memory message, returns to Windows */
static BOOL OutOfMemory(void)
{
ShowError("Fatal Error", "Out of memory - aborting");
return FALSE;
}
/* Remove the output files if there was no output written */
static void __cdecl cleanup_output(void)
{
#ifndef NO_STDIO_REDIRECT
FILE *file;
int empty;
#endif
/* Flush the output in case anything is queued */
fclose(stdout);
fclose(stderr);
#ifndef NO_STDIO_REDIRECT
/* See if the files have any output in them */
if ( stdoutPath[0] ) {
file = _tfopen(stdoutPath, TEXT("rb"));
if ( file ) {
empty = (fgetc(file) == EOF) ? 1 : 0;
fclose(file);
if ( empty ) {
_tremove(stdoutPath);
}
}
}
if ( stderrPath[0] ) {
file = _tfopen(stderrPath, TEXT("rb"));
if ( file ) {
empty = (fgetc(file) == EOF) ? 1 : 0;
fclose(file);
if ( empty ) {
_tremove(stderrPath);
}
}
}
#endif
}
#if defined(_MSC_VER)
/* The VC++ compiler needs main defined */
#define console_main main
#endif
/* This is where execution begins [console apps] */
int console_main(int argc, char *argv[])
{
size_t n;
int st;
char *bufp, *appname;
/* Get the class name from argv[0] */
appname = argv[0];
if ( (bufp=strrchr(argv[0], '\\')) != NULL ) {
appname = bufp+1;
} else
if ( (bufp=strrchr(argv[0], '/')) != NULL ) {
appname = bufp+1;
}
if ( (bufp=strrchr(appname, '.')) == NULL )
n = strlen(appname);
else
n = (bufp-appname);
bufp = (char *)alloca(n+1);
if ( bufp == NULL ) {
return OutOfMemory();
}
strncpy(bufp, appname, n);
bufp[n] = '\0';
appname = bufp;
/* Load SDL dynamic link library */
if ( SDL_Init(SDL_INIT_NOPARACHUTE) < 0 ) {
ShowError("WinMain() error", SDL_GetError());
return(FALSE);
}
atexit(cleanup_output);
atexit(SDL_Quit);
#ifndef DISABLE_VIDEO
#if 0
/* Create and register our class *
DJM: If we do this here, the user nevers gets a chance to
putenv(SDL_WINDOWID). This is already called later by
the (DIB|DX5)_CreateWindow function, so it should be
safe to comment it out here.
if ( SDL_RegisterApp(appname, CS_BYTEALIGNCLIENT,
GetModuleHandle(NULL)) < 0 ) {
ShowError("WinMain() error", SDL_GetError());
exit(1);
}*/
#else
/* Sam:
We still need to pass in the application handle so that
DirectInput will initialize properly when SDL_RegisterApp()
is called later in the video initialization.
*/
SDL_SetModuleHandle(GetModuleHandle(NULL));
#endif /* 0 */
#endif /* !DISABLE_VIDEO */
/* Run the application main() code */
st = SDL_main(argc, argv);
/* Exit cleanly, calling atexit() functions */
//exit(0);
cleanup_output();
SDL_Quit();
/* Hush little compiler, don't you cry... */
return st;
}
/* This is where execution begins [windowed apps] */
int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrev, LPSTR szCmdLine, int sw)
{
HINSTANCE handle;
int Result = -1;
char **argv;
int argc;
LPSTR cmdline;
LPSTR bufp;
#ifndef NO_STDIO_REDIRECT
FILE *newfp;
#endif
/* Start up DDHELP.EXE before opening any files, so DDHELP doesn't
keep them open. This is a hack.. hopefully it will be fixed
someday. DDHELP.EXE starts up the first time DDRAW.DLL is loaded.
*/
hPrev = hInst = NULL;
sw = 0;
handle = LoadLibrary(TEXT("DDRAW.DLL"));
if ( handle != NULL ) {
FreeLibrary(handle);
}
#ifndef NO_STDIO_REDIRECT
_tgetcwd( stdoutPath, sizeof( stdoutPath ) );
_tcscat( stdoutPath, DIR_SEPERATOR STDOUT_FILE );
/* Redirect standard input and standard output */
newfp = _tfreopen(stdoutPath, TEXT("w"), stdout);
if ( newfp == NULL ) { /* This happens on NT */
#if !defined(stdout)
stdout = _tfopen(stdoutPath, TEXT("w"));
#else
newfp = _tfopen(stdoutPath, TEXT("w"));
if ( newfp ) {
*stdout = *newfp;
}
#endif
}
_tgetcwd( stderrPath, sizeof( stderrPath ) );
_tcscat( stderrPath, DIR_SEPERATOR STDERR_FILE );
newfp = _tfreopen(stderrPath, TEXT("w"), stderr);
if ( newfp == NULL ) { /* This happens on NT */
#if !defined(stderr)
stderr = _tfopen(stderrPath, TEXT("w"));
#else
newfp = _tfopen(stderrPath, TEXT("w"));
if ( newfp ) {
*stderr = *newfp;
}
#endif
}
setvbuf(stdout, NULL, _IOLBF, BUFSIZ); /* Line buffered */
setbuf(stderr, NULL); /* No buffering */
#endif /* !NO_STDIO_REDIRECT */
szCmdLine = NULL;
/* Grab the command line (use alloca() on Windows) */
bufp = GetCommandLineA();
cmdline = (LPSTR)alloca(strlen(bufp)+1);
if ( cmdline == NULL ) {
return OutOfMemory();
}
strcpy(cmdline, bufp);
/* Parse it into argv and argc */
argc = ParseCommandLine(cmdline, NULL);
argv = (char **)alloca((argc+1)*(sizeof *argv));
if ( argv == NULL ) {
return OutOfMemory();
}
ParseCommandLine(cmdline, argv);
#ifdef BUGTRAP
/* Try BugTrap. */
if(InitBugTrap())
Result = console_main(argc, argv);
else
{
#endif
/* Run the main program (after a little SDL initialization) */
__try
{
Result = console_main(argc, argv);
}
__except ( RecordExceptionInfo(GetExceptionInformation()))
{
SetUnhandledExceptionFilter(EXCEPTION_CONTINUE_SEARCH); //Do nothing here.
}
#ifdef BUGTRAP
} /* BT failure clause. */
/* This is safe even if BT didn't start. */
ShutdownBugTrap();
#endif
return Result;
}

View file

@ -1,39 +0,0 @@
# Quick Pandora target to make a compliant SRB2 PND file.
PNDNAME=SRB2.pnd
PNDDIR=$(BIN)/pnd
ICON=sdl12/SRB2Pandora/icon.png
PXML=sdl12/SRB2Pandora/PXML.xml
SED=sed
CAT=cat
CP=cp
XARGS=xargs
FOR=for
WGET=wget -P $(PNDDIR) -c -nc
SHXARGS:=$(XARGS)
SHSED:=$(SED)
ifndef ECHO
CP:=@$(CP)
CAT:=@$(CAT)
SED:=@$(SED)
XARGS:=@$(XARGS)
FOR:=@(FOR)
endif
$(BIN)/$(PNDNAME): $(BIN)/$(EXENAME)
@echo Linking $(PNDNAME)...
$(MKDIR) $(PNDDIR)
$(CP) $(BIN)/$(EXENAME) $(PNDDIR)
$(CP) $(ICON) $(PNDDIR)
$(CP) $(PXML) $(PNDDIR)
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
$(MKISOFS) -l -r -o $@ $(PNDDIR)
$(CAT) $(PXML) >> $@
$(REMOVE) -r $(PNDDIR)

View file

@ -1,17 +0,0 @@
<?xml version="1.0" encoding="UTF-8" ?>
<PXML xmlns="http://openpandora.org/namespaces/PXML">
<application id="srb2.pandora.v20" appdata="srb2">
<title lang="en_US">Sonic Robo Blast 2</title>
<title lang="ja_JA">ソニック・ロボ・ブラスト・2</title>
<description lang="en_US">A 3D Sonic fangame with a huge fanbase developing custom content, including characters, levels, and even large-scale modifications</description>
<version major="2" minor="0" release="6" build="1" />
<exec command="lsdlsrb2" background="true" standalone="true" x11="ignore"/>
<author name="Sonic Team Junior" website="http://www.srb2.org/" email="stjr@srb2.org"/>
<icon src="icon.png"/>
<categories>
<category name="Game">
<subcategory name="ActionGame" />
</category>
</categories>
</application>
</PXML>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.7 KiB

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -1,74 +0,0 @@
Microsoft Developer Studio Workspace File, Format Version 6.00
# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!
###############################################################################
Project: "Srb2SDL"=.\Srb2SDL.dsp - Package Owner=<4>
Package=<5>
{{{
}}}
Package=<4>
{{{
Begin Project Dependency
Project_Dep_Name libpng
End Project Dependency
Begin Project Dependency
Project_Dep_Name zlib
End Project Dependency
}}}
###############################################################################
Project: "libpng"="..\..\libs\libpng-src\projects\visualc6\libpng.dsp" - Package Owner=<4>
Package=<5>
{{{
}}}
Package=<4>
{{{
Begin Project Dependency
Project_Dep_Name zlib
End Project Dependency
}}}
###############################################################################
Project: "s_openal"=..\hardware\s_openal\s_openal.dsp - Package Owner=<4>
Package=<5>
{{{
}}}
Package=<4>
{{{
}}}
###############################################################################
Project: "zlib"=..\..\libs\zlib\projects\visualc6\zlib.dsp - Package Owner=<4>
Package=<5>
{{{
}}}
Package=<4>
{{{
}}}
###############################################################################
Global:
Package=<5>
{{{
}}}
Package=<3>
{{{
}}}
###############################################################################

Binary file not shown.

Before

Width:  |  Height:  |  Size: 364 KiB

View file

@ -1,38 +0,0 @@
// Emacs style mode select -*- C++ -*-
//-----------------------------------------------------------------------------
//
// This file is in the public domain.
// (Re)written by Graue in 2006.
//
//-----------------------------------------------------------------------------
/// \file
/// \brief String uppercasing/lowercasing functions for non-DOS non-Win32
/// systems
#include "../doomtype.h"
#ifndef HAVE_DOSSTR_FUNCS
#include <ctype.h>
int strupr(char *n)
{
while (*n != '\0')
{
*n = toupper(*n);
n++;
}
return 1;
}
int strlwr(char *n)
{
while (*n != '\0')
{
*n = tolower(*n);
n++;
}
return 1;
}
#endif

View file

@ -1,234 +0,0 @@
/*
* Function to write the SRB2 end message text
*
* Copyright (C) 1998 by Udo Munk <udo@umserver.umnet.de>
*
* This code is provided AS IS and there are no guarantees, none.
* Feel free to share and modify.
*/
//-----------------------------------------------------------------------------
/// \file
/// \brief Support to show ENDOOM text
///
/// Loads the lump ENDOOM, set up the console to print
/// out the colors and text
#include <stdio.h>
#include <stdlib.h>
// need this 19990118 by Kin
#include "../doomdef.h"
#include "../w_wad.h"
#include "../z_zone.h"
#include "endtxt.h"
/** \brief The ShowEndTxt function
Prints out the ENDOOM the way DOOM.EXE/DOOM2.EXE did for Win32 or Linux/GNU
\return void
*/
void ShowEndTxt(void)
{
INT32 i;
UINT16 j, att = 0;
INT32 nlflag = 1;
#ifdef _WIN32
HANDLE co = GetStdHandle(STD_OUTPUT_HANDLE);
DWORD mode, bytesWritten;
CONSOLE_SCREEN_BUFFER_INFO backupcon;
COORD resizewin = {80,-1};
CHAR let = 0;
#endif
UINT16 *ptext;
void *data;
lumpnum_t endoomnum = W_GetNumForName("ENDOOM");
//char *col;
/* if the xterm has more then 80 columns we need to add nl's */
/* doesn't work, COLUMNS is not in the environment at this time ???
col = I_getenv("COLUMNS");
if (col) {
if (atoi(col) > 80)
nlflag++;
}
*/
/* get the lump with the text */
data = ptext = W_CacheLumpNum(endoomnum, PU_CACHE);
#ifdef _WIN32
if (co == INVALID_HANDLE_VALUE || GetFileType(co) != FILE_TYPE_CHAR || !GetConsoleMode(co, &mode)) // test if it a good handle
{
Z_Free(data);
return;
}
backupcon.wAttributes = FOREGROUND_RED|FOREGROUND_GREEN|FOREGROUND_BLUE; // Just in case
GetConsoleScreenBufferInfo(co, &backupcon); //Store old state
resizewin.Y = backupcon.dwSize.Y;
if (backupcon.dwSize.X < resizewin.X)
SetConsoleScreenBufferSize(co, resizewin);
for (i=1; i<=80*25; i++) // print 80x25 text and deal with the attributes too
{
j = (UINT16)(*ptext >> 8); // attribute first
let = (char)(*ptext & 0xff); // text second
if (j != att) // attribute changed?
{
att = j; // save current attribute
SetConsoleTextAttribute(co, j); //set fg and bg color for buffer
}
WriteConsoleA(co, &let, 1, &bytesWritten, NULL); // now the text
if (nlflag && !(i % 80) && backupcon.dwSize.X > resizewin.X) // do we need a nl?
{
att = backupcon.wAttributes;
SetConsoleTextAttribute(co, att); // all attributes off
WriteConsoleA(co, "\n", 1, &bytesWritten, NULL); // newline to console
}
ptext++;
}
SetConsoleTextAttribute(co, backupcon.wAttributes); // all attributes off
#else
/* print 80x25 text and deal with the attributes too */
for (i=1; i<=80*25; i++) {
/* attribute first */
/* attribute changed? */
if ((j = *ptext >> 8) != att) {
/* save current attribute */
att = j;
/* set new attribute, forground color first */
printf("\033[");
switch (j & 0x0f) {
case 0: /* black */
printf("30");
break;
case 1: /* blue */
printf("34");
break;
case 2: /* green */
printf("32");
break;
case 3: /* cyan */
printf("36");
break;
case 4: /* red */
printf("31");
break;
case 5: /* magenta */
printf("35");
break;
case 6: /* brown */
printf("33");
break;
case 7: /* bright grey */
printf("37");
break;
case 8: /* dark grey */
printf("1;30");
break;
case 9: /* bright blue */
printf("1;34");
break;
case 10: /* bright green */
printf("1;32");
break;
case 11: /* bright cyan */
printf("1;36");
break;
case 12: /* bright red */
printf("1;31");
break;
case 13: /* bright magenta */
printf("1;35");
break;
case 14: /* yellow */
printf("1;33");
break;
case 15: /* white */
printf("1;37");
break;
}
printf("m");
/* now background color */
printf("\033[");
switch ((j >> 4) & 0x0f) {
case 0: /* black */
printf("40");
break;
case 1: /* blue */
printf("44");
break;
case 2: /* green */
printf("42");
break;
case 3: /* cyan */
printf("46");
break;
case 4: /* red */
printf("41");
break;
case 5: /* magenta */
printf("45");
break;
case 6: /* brown */
printf("43");
break;
case 7: /* bright grey */
printf("47");
break;
case 8: /* dark grey */
printf("1;40");
break;
case 9: /* bright blue */
printf("1;44");
break;
case 10: /* bright green */
printf("1;42");
break;
case 11: /* bright cyan */
printf("1;46");
break;
case 12: /* bright red */
printf("1;41");
break;
case 13: /* bright magenta */
printf("1;45");
break;
case 14: /* yellow */
printf("1;43");
break;
case 15: /* white */
printf("1;47");
break;
}
printf("m");
}
/* now the text */
printf("%c",*ptext++ & 0xff);
/* do we need a nl? */
if (nlflag)
{
if (!(i % 80))
{
printf("\033[0m");
att = 0;
printf("\n");
}
}
}
/* all attributes off */
printf("\033[0m");
#endif
if (nlflag)
printf("\n");
Z_Free(data);
}

View file

@ -1,24 +0,0 @@
// 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 Support to show ENDOOM text
#ifndef __ENDTXT__
#define __ENDTXT__
void ShowEndTxt (void);
#endif

File diff suppressed because it is too large Load diff

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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
}

View file

@ -1,181 +0,0 @@
// 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 Tool for dynamic referencing of hardware rendering functions
///
/// Declaration and definition of the HW rendering
/// functions do have the same name. Originally, the
/// implementation was stored in a separate library.
/// For SDL, we need some function to return the addresses,
/// otherwise we have a conflict with the compiler.
#include "hwsym_sdl.h"
#include "../doomdef.h"
#ifdef _MSC_VER
#pragma warning(disable : 4214 4244)
#endif
#ifdef HAVE_SDL
#include "SDL.h"
#ifdef _MSC_VER
#pragma warning(default : 4214 4244)
#endif
#if SDL_VERSION_ATLEAST(1,2,6) && !defined (NOLOADSO)
#include "SDL_loadso.h" // 1.2.6+
#elif !defined (NOLOADSO)
#define NOLOADSO
#endif
#define _CREATE_DLL_ // necessary for Unix AND Windows
#ifdef HWRENDER
#include "../hardware/hw_drv.h"
#include "ogl_sdl.h"
#ifdef STATIC_OPENGL
#include "../hardware/r_opengl/r_opengl.h"
#endif
#endif
#ifdef HW3SOUND
#include "../hardware/hw3dsdrv.h"
#endif
#define GETFUNC(func) \
else if (0 == strcmp(#func, funcName)) \
funcPointer = &func \
//
//
/** \brief The *hwSym function
Stupid function to return function addresses
\param funcName the name of the function
\param handle an object to look in(NULL for self)
\return void
*/
//
void *hwSym(const char *funcName,void *handle)
{
void *funcPointer = NULL;
#ifdef HWRENDER
if (0 == strcmp("SetPalette", funcName))
funcPointer = &OglSdlSetPalette;
GETFUNC(Init);
GETFUNC(Draw2DLine);
GETFUNC(DrawPolygon);
GETFUNC(SetBlend);
GETFUNC(ClearBuffer);
GETFUNC(SetTexture);
GETFUNC(ReadRect);
GETFUNC(GClipRect);
GETFUNC(ClearMipMapCache);
GETFUNC(SetSpecialState);
GETFUNC(GetTextureUsed);
GETFUNC(DrawMD2);
GETFUNC(DrawMD2i);
GETFUNC(SetTransform);
GETFUNC(GetRenderVersion);
#ifdef SHUFFLE
GETFUNC(PostImgRedraw);
#endif //SHUFFLE
GETFUNC(StartScreenWipe);
GETFUNC(EndScreenWipe);
GETFUNC(DoScreenWipe);
GETFUNC(DrawIntermissionBG);
GETFUNC(MakeScreenTexture);
GETFUNC(MakeScreenFinalTexture);
GETFUNC(DrawScreenFinalTexture);
#else //HWRENDER
if (0 == strcmp("FinishUpdate", funcName))
return funcPointer; //&FinishUpdate;
#endif //!HWRENDER
#ifdef STATIC3DS
GETFUNC(Startup);
GETFUNC(AddSfx);
GETFUNC(AddSource);
GETFUNC(StartSource);
GETFUNC(StopSource);
GETFUNC(GetHW3DSVersion);
GETFUNC(BeginFrameUpdate);
GETFUNC(EndFrameUpdate);
GETFUNC(IsPlaying);
GETFUNC(UpdateListener);
GETFUNC(UpdateSourceParms);
GETFUNC(SetGlobalSfxVolume);
GETFUNC(SetCone);
GETFUNC(Update3DSource);
GETFUNC(ReloadSource);
GETFUNC(KillSource);
GETFUNC(Shutdown);
GETFUNC(GetHW3DSTitle);
#endif
#ifdef NOLOADSO
else
funcPointer = handle;
#else
else if (handle)
funcPointer = SDL_LoadFunction(handle,funcName);
#endif
if (!funcPointer)
I_OutputMsg("hwSym for %s: %s\n", funcName, SDL_GetError());
return funcPointer;
}
/** \brief The *hwOpen function
\param hwfile Open a handle to the SO
\return Handle to SO
*/
void *hwOpen(const char *hwfile)
{
#ifdef NOLOADSO
(void)hwfile;
return NULL;
#else
void *tempso = NULL;
tempso = SDL_LoadObject(hwfile);
if (!tempso) I_OutputMsg("hwOpen of %s: %s\n", hwfile, SDL_GetError());
return tempso;
#endif
}
/** \brief The hwClose function
\param handle Close the handle of the SO
\return void
*/
void hwClose(void *handle)
{
#ifdef NOLOADSO
(void)handle;
#else
SDL_UnloadObject(handle);
#endif
}
#endif

View file

@ -1,23 +0,0 @@
// 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 Tool for dynamic referencing of hardware rendering/3D sound functions
void *hwSym(const char *funcName,void *handle);
void *hwOpen(const char *hwfile);
void hwClose(void *handle);

View file

@ -1,572 +0,0 @@
// 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 HAVE_SDL
#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 "../m_argv.h"
#include "../s_sound.h"
#define MAX_CD_TRACKS 256
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 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;
/**************************************************************************
*
* function: CDAudio_GetAudioDiskInfo
*
* description:
* set number of tracks if CD is available
*
**************************************************************************/
static INT32 CDAudio_GetAudioDiskInfo(void)
{
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)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
}
/**************************************************************************
*
* 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;
#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;
}
#endif

View file

@ -1,166 +0,0 @@
// Emacs style mode select -*- C++ -*-
//-----------------------------------------------------------------------------
//
// Copyright (C) 1993-1996 by id Software, Inc.
// 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 Main program, simply calls D_SRB2Main and D_SRB2Loop, the high level loop.
#include "../doomdef.h"
#include "../m_argv.h"
#include "../d_main.h"
#include "../i_system.h"
#ifdef __GNUC__
#include <unistd.h>
#endif
#ifdef HAVE_SDL
#ifdef HAVE_TTF
#include "SDL.h"
#include "i_ttf.h"
#endif
#ifdef SDLMAIN
#include "SDL_main.h"
#elif defined(FORCESDLMAIN)
extern int SDL_main(int argc, char *argv[]);
#endif
#ifdef LOGMESSAGES
FILE *logstream = NULL;
#endif
#ifndef DOXYGEN
#ifndef O_TEXT
#define O_TEXT 0
#endif
#ifndef O_SEQUENTIAL
#define O_SEQUENTIAL 0
#endif
#endif
#ifdef _WIN32
#include "../win32/win_dbg.h"
typedef BOOL (WINAPI *p_IsDebuggerPresent)(VOID);
#endif
#ifdef _WIN32
static inline VOID MakeCodeWritable(VOID)
{
#ifdef USEASM // Disable write-protection of code segment
DWORD OldRights;
const DWORD NewRights = PAGE_EXECUTE_READWRITE;
PBYTE pBaseOfImage = (PBYTE)GetModuleHandle(NULL);
PIMAGE_DOS_HEADER dosH =(PIMAGE_DOS_HEADER)pBaseOfImage;
PIMAGE_NT_HEADERS ntH = (PIMAGE_NT_HEADERS)(pBaseOfImage + dosH->e_lfanew);
PIMAGE_OPTIONAL_HEADER oH = (PIMAGE_OPTIONAL_HEADER)
((PBYTE)ntH + sizeof (IMAGE_NT_SIGNATURE) + sizeof (IMAGE_FILE_HEADER));
LPVOID pA = pBaseOfImage+oH->BaseOfCode;
SIZE_T pS = oH->SizeOfCode;
#if 1 // try to find the text section
PIMAGE_SECTION_HEADER ntS = IMAGE_FIRST_SECTION (ntH);
WORD s;
for (s = 0; s < ntH->FileHeader.NumberOfSections; s++)
{
if (memcmp (ntS[s].Name, ".text\0\0", 8) == 0)
{
pA = pBaseOfImage+ntS[s].VirtualAddress;
pS = ntS[s].Misc.VirtualSize;
break;
}
}
#endif
if (!VirtualProtect(pA,pS,NewRights,&OldRights))
I_Error("Could not make code writable\n");
#endif
}
#endif
/** \brief The main function
\param argc number of arg
\param *argv string table
\return int
*/
FUNCNORETURN
#ifdef FORCESDLMAIN
int SDL_main(int argc, char **argv)
#else
int main(int argc, char **argv)
#endif
{
const char *logdir = NULL;
myargc = argc;
myargv = argv; /// \todo pull out path to exe from this string
#ifdef HAVE_TTF
#ifdef _WIN32
I_StartupTTF(FONTPOINTSIZE, SDL_INIT_VIDEO|SDL_INIT_AUDIO, SDL_SWSURFACE);
#else
I_StartupTTF(FONTPOINTSIZE, SDL_INIT_VIDEO, SDL_SWSURFACE);
#endif
#endif
logdir = D_Home();
#ifdef LOGMESSAGES
#ifdef DEFAULTDIR
if (logdir)
logstream = fopen(va("%s/"DEFAULTDIR"/srb2log.txt",logdir), "a");
else
#endif
logstream = fopen("./srb2log.txt", "a");
#endif
//I_OutputMsg("I_StartupSystem() ...\n");
I_StartupSystem();
#ifdef _WIN32
{
p_IsDebuggerPresent pfnIsDebuggerPresent = (p_IsDebuggerPresent)GetProcAddress(GetModuleHandleA("kernel32.dll"), "IsDebuggerPresent");
if ((!pfnIsDebuggerPresent || !pfnIsDebuggerPresent())
#ifdef BUGTRAP
&& !InitBugTrap()
#endif
)
{
LoadLibraryA("exchndl.dll");
}
}
prevExceptionFilter = SetUnhandledExceptionFilter(RecordExceptionInfo);
MakeCodeWritable();
#endif
// startup SRB2
CONS_Printf("%s", M_GetText("Setting up SRB2...\n"));
D_SRB2Main();
CONS_Printf("%s", M_GetText("Entering main game loop...\n"));
// never return
D_SRB2Loop();
#ifdef BUGTRAP
// This is safe even if BT didn't start.
ShutdownBugTrap();
#endif
// return to OS
#ifndef __GNUC__
return 0;
#endif
}
#endif

View file

@ -1,442 +0,0 @@
// Emacs style mode select -*- C++ -*-
//-----------------------------------------------------------------------------
//
// Copyright (C) 1993-1996 by id Software, Inc.
// Portions 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 SDL 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"
#ifdef HAVE_SDL
#ifdef HAVE_SDLNET
#include "SDL_net.h"
#define MAXBANS 20
static IPaddress clientaddress[MAXNETNODES+1];
static IPaddress banned[MAXBANS];
static UDPpacket mypacket;
static UDPsocket mysocket = NULL;
static SDLNet_SocketSet myset = NULL;
static size_t numbans = 0;
static boolean NET_bannednode[MAXNETNODES+1]; /// \note do we really need the +1?
static boolean init_SDLNet_driver = false;
static const char *NET_AddrToStr(IPaddress* sk)
{
static char s[22]; // 255.255.255.255:65535
strcpy(s, SDLNet_ResolveIP(sk));
if (sk->port != 0) strcat(s, va(":%d", sk->port));
return s;
}
static const char *NET_GetNodeAddress(INT32 node)
{
if (!nodeconnected[node])
return NULL;
return NET_AddrToStr(&clientaddress[node]);
}
static const char *NET_GetBanAddress(size_t ban)
{
if (ban > numbans)
return NULL;
return NET_AddrToStr(&banned[ban]);
}
static boolean NET_cmpaddr(IPaddress* a, IPaddress* b)
{
return (a->host == b->host && (b->port == 0 || a->port == b->port));
}
static boolean NET_CanGet(void)
{
return myset?(SDLNet_CheckSockets(myset,0) == 1):false;
}
static void NET_Get(void)
{
INT32 mystatus;
INT32 newnode;
mypacket.len = MAXPACKETLENGTH;
if (!NET_CanGet())
{
doomcom->remotenode = -1; // no packet
return;
}
mystatus = SDLNet_UDP_Recv(mysocket,&mypacket);
if (mystatus != -1)
{
if (mypacket.channel != -1)
{
doomcom->remotenode = mypacket.channel+1; // good packet from a game player
doomcom->datalength = mypacket.len;
return;
}
newnode = SDLNet_UDP_Bind(mysocket,-1,&mypacket.address);
if (newnode != -1)
{
size_t i;
newnode++;
M_Memcpy(&clientaddress[newnode], &mypacket.address, sizeof (IPaddress));
DEBFILE(va("New node detected: node:%d address:%s\n", newnode,
NET_GetNodeAddress(newnode)));
doomcom->remotenode = newnode; // good packet from a game player
doomcom->datalength = mypacket.len;
for (i = 0; i < numbans; i++)
{
if (NET_cmpaddr(&mypacket.address, &banned[i]))
{
DEBFILE("This dude has been banned\n");
NET_bannednode[newnode] = true;
break;
}
}
if (i == numbans)
NET_bannednode[newnode] = false;
return;
}
else
I_OutputMsg("SDL_Net: %s",SDLNet_GetError());
}
else if (mystatus == -1)
{
I_OutputMsg("SDL_Net: %s",SDLNet_GetError());
}
DEBFILE("New node detected: No more free slots\n");
doomcom->remotenode = -1; // no packet
}
#if 0
static boolean NET_CanSend(void)
{
return true;
}
#endif
static void NET_Send(void)
{
if (!doomcom->remotenode)
return;
mypacket.len = doomcom->datalength;
if (SDLNet_UDP_Send(mysocket,doomcom->remotenode-1,&mypacket) == 0)
{
I_OutputMsg("SDL_Net: %s",SDLNet_GetError());
}
}
static void NET_FreeNodenum(INT32 numnode)
{
// can't disconnect from self :)
if (!numnode)
return;
DEBFILE(va("Free node %d (%s)\n", numnode, NET_GetNodeAddress(numnode)));
SDLNet_UDP_Unbind(mysocket,numnode-1);
memset(&clientaddress[numnode], 0, sizeof (IPaddress));
}
static UDPsocket NET_Socket(void)
{
UDPsocket temp = NULL;
Uint16 portnum = 0;
IPaddress tempip = {INADDR_BROADCAST,0};
//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 = atoi(M_GetNextParm());
}
else
portnum = sock_port;
temp = SDLNet_UDP_Open(portnum);
if (!temp)
{
I_OutputMsg("SDL_Net: %s",SDLNet_GetError());
return NULL;
}
if (SDLNet_UDP_Bind(temp,BROADCASTADDR-1,&tempip) == -1)
{
I_OutputMsg("SDL_Net: %s",SDLNet_GetError());
SDLNet_UDP_Close(temp);
return NULL;
}
clientaddress[BROADCASTADDR].port = sock_port;
clientaddress[BROADCASTADDR].host = INADDR_BROADCAST;
doomcom->extratics = 1; // internet is very high ping
return temp;
}
static void I_ShutdownSDLNetDriver(void)
{
if (myset) SDLNet_FreeSocketSet(myset);
myset = NULL;
SDLNet_Quit();
init_SDLNet_driver = false;
}
static void I_InitSDLNetDriver(void)
{
if (init_SDLNet_driver)
I_ShutdownSDLNetDriver();
if (SDLNet_Init() == -1)
{
I_OutputMsg("SDL_Net: %s",SDLNet_GetError());
return; // No good!
}
D_SetDoomcom();
mypacket.data = doomcom->data;
init_SDLNet_driver = true;
}
static void NET_CloseSocket(void)
{
if (mysocket)
SDLNet_UDP_Close(mysocket);
mysocket = NULL;
}
static SINT8 NET_NetMakeNodewPort(const char *hostname, const char *port)
{
INT32 newnode;
UINT16 portnum = sock_port;
IPaddress hostnameIP;
// retrieve portnum from address!
if (port && !port[0])
portnum = atoi(port);
if (SDLNet_ResolveHost(&hostnameIP,hostname,portnum) == -1)
{
I_OutputMsg("SDL_Net: %s",SDLNet_GetError());
return -1;
}
newnode = SDLNet_UDP_Bind(mysocket,-1,&hostnameIP);
if (newnode == -1)
{
I_OutputMsg("SDL_Net: %s",SDLNet_GetError());
return newnode;
}
newnode++;
M_Memcpy(&clientaddress[newnode],&hostnameIP,sizeof (IPaddress));
return (SINT8)newnode;
}
static boolean NET_OpenSocket(void)
{
memset(clientaddress, 0, sizeof (clientaddress));
//I_OutputMsg("SDL_Net Code starting up\n");
I_NetSend = NET_Send;
I_NetGet = NET_Get;
I_NetCloseSocket = NET_CloseSocket;
I_NetFreeNodenum = NET_FreeNodenum;
I_NetMakeNodewPort = NET_NetMakeNodewPort;
//I_NetCanSend = NET_CanSend;
// build the socket but close it first
NET_CloseSocket();
mysocket = NET_Socket();
if (!mysocket)
return false;
// for select
myset = SDLNet_AllocSocketSet(1);
if (!myset)
{
I_OutputMsg("SDL_Net: %s",SDLNet_GetError());
return false;
}
if (SDLNet_UDP_AddSocket(myset,mysocket) == -1)
{
I_OutputMsg("SDL_Net: %s",SDLNet_GetError());
return false;
}
return true;
}
static boolean NET_Ban(INT32 node)
{
if (numbans == MAXBANS)
return false;
M_Memcpy(&banned[numbans], &clientaddress[node], sizeof (IPaddress));
banned[numbans].port = 0;
numbans++;
return true;
}
static boolean NET_SetBanAddress(const char *address, const char *mask)
{
(void)mask;
if (bans == MAXBANS)
return false;
if (SDLNet_ResolveHost(&banned[numbans], address, 0) == -1)
return false;
numbans++;
return true;
}
static void NET_ClearBans(void)
{
numbans = 0;
}
#endif
//
// I_InitNetwork
// Only required for DOS, so this is more a dummy
//
boolean I_InitNetwork(void)
{
#ifdef HAVE_SDLNET
char serverhostname[255];
boolean ret = false;
SDL_version SDLcompiled;
const SDL_version *SDLlinked = SDLNet_Linked_Version();
SDL_NET_VERSION(&SDLcompiled)
I_OutputMsg("Compiled for SDL_Net version: %d.%d.%d\n",
SDLcompiled.major, SDLcompiled.minor, SDLcompiled.patch);
I_OutputMsg("Linked with SDL_Net version: %d.%d.%d\n",
SDLlinked->major, SDLlinked->minor, SDLlinked->patch);
//if (!M_CheckParm ("-sdlnet"))
// return false;
// initilize the driver
I_InitSDLNetDriver();
I_AddExitFunc(I_ShutdownSDLNetDriver);
if (!init_SDLNet_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;
}
}
mypacket.maxlen = hardware_MAXPACKETLENGTH;
I_NetOpenSocket = NET_OpenSocket;
I_Ban = NET_Ban;
I_ClearBans = NET_ClearBans;
I_GetNodeAddress = NET_GetNodeAddress;
I_GetBenAddress = NET_GetBenAddress;
I_SetBanAddress = NET_SetBanAddress;
bannednode = NET_bannednode;
return ret;
#else
if ( M_CheckParm ("-net") )
{
I_Error("-net not supported, use -server and -connect\n"
"see docs for more\n");
}
return false;
#endif
}
#endif

File diff suppressed because it is too large Load diff

View file

@ -1,330 +0,0 @@
// Emacs style mode select -*- C++ -*-
//-----------------------------------------------------------------------------
//
// Copyright (C) 2011 by Callum Dickinson.
//
// 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 SDL_ttf interface code. Necessary for platforms with no framebuffer console systems.
#if defined(SDL) && defined(HAVE_TTF)
#include "SDL.h"
#include "SDL_ttf.h"
#include "../doomdef.h"
#include "../doomstat.h"
#include "../d_netfil.h"
#include "../filesrch.h"
#include "i_ttf.h"
// Search directories to find aforementioned TTF file.
#if defined (__unix__) || defined(__APPLE__) || defined (UNIXCOMMON)
#define FONTSEARCHPATH1 "/usr/share/fonts"
#define FONTSEARCHPATH2 "/usr/local/share/fonts"
#define FONTSEARCHPATH3 "/usr/games/SRB2"
#define FONTSEARCHPATH4 "/usr/local/games/SRB2"
#define FONTSEARCHPATH5 "/usr/local/share/games/SRB2"
#else
#define FONTSEARCHPATH1 "."
#endif
#define FONTHANDLE -1
// Renduring surfaces.
SDL_Surface *TTFSurface = NULL;
SDL_Surface *TTFRendSurface = NULL;
// Text box.
SDL_Rect TTFRect;
// Temporary storage for the new TTFRect, used to check for
// line wrapping.
SDL_Rect TTFRectCheck;
// Text rendering resolution.
videoResolution res;
// Text storage buffer, the contents get printed to the SDL surface.
char textbuffer[8192];
// look for default ttf file in given directory
static char *searchFont(const char *fontsearchDir)
{
static char tempsw[256] = "";
filestatus_t fstemp;
strcpy(tempsw, FONTFILE);
fstemp = filesearch(tempsw, fontsearchDir, NULL, true, 20);
if (fstemp == FS_FOUND)
{
return tempsw;
}
return NULL;
}
// Load TTF font from file.
INT32 I_TTFLoadFont(const char *file, UINT32 ptsize)
{
TTF_Font *tmpfont = NULL;
float fontsize;
// If a font is currently loaded, unload it.
if (currentfont)
{
TTF_CloseFont(currentfont);
}
// Scale the specified font point size for the current resolution.
fontsize = (ptsize * 0.005f) * (res.width - res.height);
tmpfont = TTF_OpenFont(file, fontsize);
if (!tmpfont)
return FONTHANDLE;
// set pointer for current font
currentfont = tmpfont;
// set current font point size
currentfontpoint = ptsize;
// get font properties, and set them
currentfontstyle = TTF_GetFontStyle(currentfont);
TTF_SetFontStyle(currentfont, currentfontstyle);
// these functions only exist in SDL_ttf 2.0.10 onwards
#if SDL_TTF_VERSION_ATLEAST(2,0,10)
currentfontkerning = TTF_GetFontKerning(currentfont);
TTF_SetFontKerning(currentfont, currentfontkerning);
currentfonthinting = TTF_GetFontHinting(currentfont);
TTF_SetFontHinting(currentfont, currentfonthinting);
currentfontoutline = TTF_GetFontOutline(currentfont);
TTF_SetFontOutline(currentfont, currentfontoutline);
#endif
return 0;
}
static void I_TTFRendSurface(const char *textmsg, TTF_Font *font, TextQuality quality, SDL_Color fontfgcolor, SDL_Color fontbgcolor)
{
// Print text in the buffer.
// SDL_ttf has three modes to draw text.
// Solid rendering is quick, but dirty. Use it if you need speed more than quality.
switch (quality)
{
case solid:
TTFRendSurface = TTF_RenderText_Solid(font, textmsg, fontfgcolor);
break;
// Shaded rendering adds a background to the rendered text. Because of this, I_TTFDrawText
// takes an extra color more than the other styles to be a background color.
// Shaded is supposedly as fast as solid rendering and about as good quality as blended.
case shaded:
TTFRendSurface = TTF_RenderText_Shaded(font, textmsg, fontfgcolor, fontbgcolor);
break;
// Blended rendering is the opposite of solid. Good quality, but slow.
case blended:
TTFRendSurface = TTF_RenderText_Blended(font, textmsg, fontfgcolor);
break;
}
// Get SDL to update the main surface.
SDL_BlitSurface(TTFRendSurface, NULL, TTFSurface, &TTFRect);
SDL_Flip(TTFSurface);
}
// Draw text to screen. It will accept four colour vales (red, green, blue and alpha)
// with foreground for draw modes Solid and Blended, and an extra four values for background
// colour with draw type Shaded.
void I_TTFDrawText(TTF_Font *font, TextQuality quality, INT32 fgR, INT32 fgG, INT32 fgB, INT32 fgA, INT32 bgR, INT32 bgG, INT32 bgB, INT32 bgA, const char *textmsg)
{
// Temporary small buffer to store character to process.
// NULL pointer to prevc to kill warning
char c, prevc = 0x0;
// hack to allow TTF_SizeText to work properly.
char linebuffer[2];
// Don't need h, but TTF_SizeText needs a height parameter
INT32 w, h;
// Globally declare foreground and background text colours,
// text drawing mode and the font to draw.
SDL_Color fontfgcolor = {fgR, fgG, fgB, fgA};
SDL_Color fontbgcolor = {bgR, bgG, bgB, bgA};
// Keep on processing until the null terminator in the text buffer is reached.
while (*textmsg != '\0')
{
// Copy pointer for current character into the temporary buffer.
c = *textmsg;
// If c is a newline, move to the next available line.
if (c == '\n')
{
TTFRectCheck.x = 0;
TTFRectCheck.y += (currentfontpoint + 1);
}
// Otherwise...
else
{
// If the previous character was a newline, actually move to the next line.
if (prevc == '\n')
{
if (textbuffer != NULL)
{
// Render cached text to the SDL surface.
I_TTFRendSurface(textbuffer, font, quality, fontfgcolor, fontbgcolor);
// Empty text buffer.
memset(textbuffer, '\0', 1);
}
TTFRect.x = TTFRectCheck.x;
TTFRect.y = TTFRectCheck.y;
}
// Copy the character to the text buffer.
sprintf(textbuffer, "%s%c", textbuffer, c);
// Hack to allow TTF_SizeText to work properly.
sprintf(linebuffer, "%c", c);
// If we have reached the end of the screen, move to the next available line.
TTF_SizeText(currentfont, linebuffer, &w, &h);
TTFRectCheck.x += w;
if (TTFRectCheck.x >= res.width)
{
// Render cached text to the SDL surface.
I_TTFRendSurface(textbuffer, font, quality, fontfgcolor, fontbgcolor);
// Empty text buffer.
memset(textbuffer, '\0', 1);
// Move to the next line.
TTFRectCheck.x = 0;
TTFRectCheck.y += (currentfontpoint + 1);
// Set stored co-ordinates for next line.
TTFRect.x = TTFRectCheck.x;
TTFRect.y = TTFRectCheck.y;
}
}
// Add 1 to the pointer reference for the character to process.
textmsg++;
// Copy contents of the now-old buffer to somewhere else, so it can be referenced in next loop.
prevc = c;
}
// If the buffer was previously emptied by a line wrapping operation and
// no text came after that, don't print anything. Otherwise, print everything
// still in the buffer.
if (textbuffer != NULL)
{
// Render cached text to the SDL surface.
I_TTFRendSurface(textbuffer, font, quality, fontfgcolor, fontbgcolor);
// Empty text buffer.
memset(textbuffer, '\0', 1);
// Set stored co-ordinates for next line.
TTFRect.x = TTFRectCheck.x;
TTFRect.y = TTFRectCheck.y;
}
}
// Initialise SDL_ttf.
void I_StartupTTF(UINT32 fontpointsize, Uint32 initflags, Uint32 vidmodeflags)
{
char *fontpath = NULL;
INT32 fontstatus = -1;
res.width = 320;
res.height = 200;
bitsperpixel = 8;
// what's the point of trying to display an error?
// SDL_ttf is not started, can't display anything to screen (presumably)...
if (SDL_InitSubSystem(initflags) < 0)
I_Error("Couldn't initialize SDL: %s\n", SDL_GetError());
TTFSurface = SDL_SetVideoMode(res.width, res.height, bitsperpixel, vidmodeflags);
if (!TTFSurface)
I_Error("Couldn't set SDL Video resolution: %s\n", SDL_GetError());
if (TTF_Init() < 0)
I_Error("Couldn't start SDL_ttf: %s\n", TTF_GetError());
// look for default font in many directories
#ifdef FONTSEARCHPATH1
fontpath = searchFont(FONTSEARCHPATH1);
if (fontpath) fontstatus = I_TTFLoadFont(fontpath, fontpointsize);
#endif
#ifdef FONTSEARCHPATH2
if (fontstatus < 0)
{
fontpath = searchFont(FONTSEARCHPATH2);
if (fontpath) fontstatus = I_TTFLoadFont(fontpath, fontpointsize);
}
#endif
#ifdef FONTSEARCHPATH3
if (fontstatus < 0)
{
fontpath = searchFont(FONTSEARCHPATH3);
if (fontpath) fontstatus = I_TTFLoadFont(fontpath, fontpointsize);
}
#endif
#ifdef FONTSEARCHPATH4
if (fontstatus < 0)
{
fontpath = searchFont(FONTSEARCHPATH4);
if (fontpath) fontstatus = I_TTFLoadFont(fontpath, fontpointsize);
}
#endif
#ifdef FONTSEARCHPATH5
if (fontstatus < 0)
{
fontpath = searchFont(FONTSEARCHPATH5);
if (fontpath) fontstatus = I_TTFLoadFont(fontpath, fontpointsize);
}
#endif
#ifdef FONTSEARCHPATH6
if (fontstatus < 0)
{
fontpath = searchFont(FONTSEARCHPATH6);
if (fontpath) fontstatus = I_TTFLoadFont(fontpath, fontpointsize);
}
#endif
#ifdef FONTSEARCHPATH7
if (fontstatus < 0)
{
fontpath = searchFont(FONTSEARCHPATH7);
if (fontpath) fontstatus = I_TTFLoadFont(fontpath, fontpointsize);
}
#endif
// argh! no font file found! disable SDL_ttf code
if (fontstatus < 0)
{
I_ShutdownTTF();
CONS_Printf("Unable to find default font files! Not loading SDL_ttf\n");
}
else
{
// Get SDL_ttf compiled and linked version
SDL_version TTFcompiled;
const SDL_version *TTFlinked;
SDL_TTF_VERSION(&TTFcompiled);
TTFlinked = TTF_Linked_Version();
// Display it on screen
CONS_Printf("Compiled for SDL_ttf version: %d.%d.%d\n",
TTFcompiled.major, TTFcompiled.minor, TTFcompiled.patch);
CONS_Printf("Linked with SDL_ttf version: %d.%d.%d\n",
TTFlinked->major, TTFlinked->minor, TTFlinked->patch);
}
}
void I_ShutdownTTF(void)
{
// close current font
TTF_CloseFont(currentfont);
// shutdown SDL_ttf
TTF_Quit();
// Free TTF rendering surfaces.
SDL_FreeSurface(TTFSurface);
SDL_FreeSurface(TTFRendSurface);
}
#endif

View file

@ -1,86 +0,0 @@
// Emacs style mode select -*- C++ -*-
//-----------------------------------------------------------------------------
//
// Copyright (C) 2011 by Callum Dickinson.
//
// 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 SDL_ttf interface code. Necessary for platforms with SDL inits that need to run immediately.
#ifndef __I_TTF__
#define __I_TTF__
#include "../doomdef.h"
#include "SDL_ttf.h"
// Default name for standard TTF file.
#define FONTFILE "srb2.ttf"
#define FONTPOINTSIZE 12
// Default font foreground colours
#define DEFAULTFONTFGR 255
#define DEFAULTFONTFGG 255
#define DEFAULTFONTFGB 255
#define DEFAULTFONTFGA 255
// Default font background colours
#define DEFAULTFONTBGR 0
#define DEFAULTFONTBGG 0
#define DEFAULTFONTBGB 0
#define DEFAULTFONTBGA 255
#ifndef SDL_TTF_COMPILEDVERSION
#define SDL_TTF_COMPILEDVERSION \
SDL_VERSIONNUM(TTF_MAJOR_VERSION, TTF_MINOR_VERSION, TTF_PATCHLEVEL)
#endif
#ifndef SDL_TTF_VERSION_ATLEAST
#define SDL_TTF_VERSION_ATLEAST(X, Y, Z) \
(SDL_TTF_COMPILEDVERSION >= SDL_VERSIONNUM(X, Y, Z))
#endif
TTF_Font* currentfont;
int currentfontpoint;
int currentfontstyle;
#if SDL_TTF_VERSION_ATLEAST(2,0,10)
int currentfontkerning;
int currentfonthinting;
int currentfontoutline;
#endif
typedef struct
{
UINT16 width;
UINT16 height;
} VideoResolution;
UINT8 bitsperpixel;
typedef enum
{
solid,
shaded,
blended
} TextQuality;
// Load TTF font from file.
INT32 I_TTFLoadFont(const char *file, UINT32 ptsize);
// Draw TTF text to screen. It will accept four colour vales (red, green, blue and alpha)
// with foreground for draw modes Solid and Blended, and an extra four values for background
// colour with draw type Shaded.
void I_TTFDrawText(TTF_Font *font, TextQuality quality, INT32 fgR, INT32 fgG, INT32 fgB, INT32 fgA, INT32 bgR, INT32 bgG, INT32 bgB, INT32 bgA, const char *textmsg);
// Initialise SDL_ttf.
void I_StartupTTF(UINT32 fontpointsize, Uint32 initflags, Uint32 vidmodeflags);
void I_ShutdownTTF(void);
#endif

File diff suppressed because it is too large Load diff

View file

@ -1,28 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>English</string>
<key>CFBundleExecutable</key>
<string>${EXECUTABLE_NAME}</string>
<key>CFBundleIconFile</key>
<string>Srb2mac.icns</string>
<key>CFBundleIdentifier</key>
<string>com.yourcompany.Srb2mac</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>${PRODUCT_NAME}</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>1.0</string>
<key>NSMainNibFile</key>
<string>SDLMain</string>
<key>NSPrincipalClass</key>
<string>NSApplication</string>
</dict>
</plist>

Binary file not shown.

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -1,45 +0,0 @@
// Emacs style mode select -*- C++ -*-
//-----------------------------------------------------------------------------
//
// Copyright (C) 1993-1996 by id Software, Inc.
// Portions 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 Graphical Alerts for MacOSX
///
/// Shows alerts, since we can't just print these to the screen when
/// launched graphically on a mac.
#ifdef __APPLE_CC__
#include "mac_alert.h"
#include <CoreFoundation/CoreFoundation.h>
int MacShowAlert(const char *title, const char *message, const char *button1, const char *button2, const char *button3)
{
CFOptionFlags results;
CFUserNotificationDisplayAlert(0,
kCFUserNotificationStopAlertLevel | kCFUserNotificationNoDefaultButtonFlag,
NULL, NULL, NULL,
CFStringCreateWithCString(NULL, title, kCFStringEncodingASCII),
CFStringCreateWithCString(NULL, message, kCFStringEncodingASCII),
button1 != NULL ? CFStringCreateWithCString(NULL, button1, kCFStringEncodingASCII) : NULL,
button2 != NULL ? CFStringCreateWithCString(NULL, button2, kCFStringEncodingASCII) : NULL,
button3 != NULL ? CFStringCreateWithCString(NULL, button3, kCFStringEncodingASCII) : NULL,
&results);
return (int)results;
}
#endif

View file

@ -1,27 +0,0 @@
// Emacs style mode select -*- C++ -*-
//-----------------------------------------------------------------------------
//
// Copyright (C) 1993-1996 by id Software, Inc.
// Portions 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 Graphical Alerts for MacOSX
///
/// Shows alerts, since we can't just print these to the screen when
/// launched graphically on a mac.
#ifdef __APPLE_CC__
extern int MacShowAlert(const char *title, const char *message, const char *button1, const char *button2, const char *button3);
#endif

View file

@ -1,822 +0,0 @@
/// \file
/// \brief SDL Mixer interface for sound
#include "../doomdef.h"
#if defined(HAVE_SDL) && defined(HAVE_MIXER) && SOUND==SOUND_MIXER
#include "../sounds.h"
#include "../s_sound.h"
#include "../i_sound.h"
#include "../w_wad.h"
#include "../z_zone.h"
#include "../byteptr.h"
#ifdef _MSC_VER
#pragma warning(disable : 4214 4244)
#endif
#include "SDL.h"
#ifdef _MSC_VER
#pragma warning(default : 4214 4244)
#endif
#include "SDL_mixer.h"
/* This is the version number macro for the current SDL_mixer version: */
#ifndef SDL_MIXER_COMPILEDVERSION
#define SDL_MIXER_COMPILEDVERSION \
SDL_VERSIONNUM(MIX_MAJOR_VERSION, MIX_MINOR_VERSION, MIX_PATCHLEVEL)
#endif
/* This macro will evaluate to true if compiled with SDL_mixer at least X.Y.Z */
#ifndef SDL_MIXER_VERSION_ATLEAST
#define SDL_MIXER_VERSION_ATLEAST(X, Y, Z) \
(SDL_MIXER_COMPILEDVERSION >= SDL_VERSIONNUM(X, Y, Z))
#endif
#ifdef HAVE_LIBGME
#include "gme/gme.h"
#define GME_TREBLE 5.0
#define GME_BASS 1.0
#ifdef HAVE_PNG /// TODO: compile with zlib support without libpng
#define HAVE_ZLIB
#ifndef _MSC_VER
#ifndef _LARGEFILE64_SOURCE
#define _LARGEFILE64_SOURCE
#endif
#endif
#ifndef _LFS64_LARGEFILE
#define _LFS64_LARGEFILE
#endif
#ifndef _FILE_OFFSET_BITS
#define _FILE_OFFSET_BITS 0
#endif
#include "zlib.h"
#endif
#endif
UINT8 sound_started = false;
static boolean midimode;
static Mix_Music *music;
static UINT8 music_volume, midi_volume, sfx_volume;
static float loop_point;
#ifdef HAVE_LIBGME
static Music_Emu *gme;
static INT32 current_track;
#endif
void I_StartupSound(void)
{
I_Assert(!sound_started);
sound_started = true;
midimode = false;
music = NULL;
music_volume = midi_volume = sfx_volume = 0;
#if SDL_MIXER_VERSION_ATLEAST(1,2,11)
Mix_Init(MIX_INIT_FLAC|MIX_INIT_MOD|MIX_INIT_MP3|MIX_INIT_OGG);
#endif
Mix_OpenAudio(44100, AUDIO_S16LSB, 2, 2048);
Mix_AllocateChannels(256);
}
void I_ShutdownSound(void)
{
I_Assert(sound_started);
sound_started = false;
Mix_CloseAudio();
#if SDL_MIXER_VERSION_ATLEAST(1,2,11)
Mix_Quit();
#endif
#ifdef HAVE_LIBGME
if (gme)
gme_delete(gme);
#endif
}
void I_UpdateSound(void)
{
}
// this is as fast as I can possibly make it.
// sorry. more asm needed.
static Mix_Chunk *ds2chunk(void *stream)
{
UINT16 ver,freq;
UINT32 samples, i, newsamples;
UINT8 *sound;
SINT8 *s;
INT16 *d;
INT16 o;
fixed_t step, frac;
// lump header
ver = READUINT16(stream); // sound version format?
if (ver != 3) // It should be 3 if it's a doomsound...
return NULL; // onos! it's not a doomsound!
freq = READUINT16(stream);
samples = READUINT32(stream);
// convert from signed 8bit ???hz to signed 16bit 44100hz.
switch(freq)
{
case 44100:
if (samples >= UINT32_MAX>>2)
return NULL; // would wrap, can't store.
newsamples = samples;
break;
case 22050:
if (samples >= UINT32_MAX>>3)
return NULL; // would wrap, can't store.
newsamples = samples<<1;
break;
case 11025:
if (samples >= UINT32_MAX>>4)
return NULL; // would wrap, can't store.
newsamples = samples<<2;
break;
default:
frac = (44100 << FRACBITS) / (UINT32)freq;
if (!(frac & 0xFFFF)) // other solid multiples (change if FRACBITS != 16)
newsamples = samples * (frac >> FRACBITS);
else // strange and unusual fractional frequency steps, plus anything higher than 44100hz.
newsamples = FixedMul(FixedDiv(samples, freq), 44100) + 1; // add 1 to counter truncation.
if (newsamples >= UINT32_MAX>>2)
return NULL; // would and/or did wrap, can't store.
break;
}
sound = Z_Malloc(newsamples<<2, PU_SOUND, NULL); // samples * frequency shift * bytes per sample * channels
s = (SINT8 *)stream;
d = (INT16 *)sound;
i = 0;
switch(freq)
{
case 44100: // already at the same rate? well that makes it simple.
while(i++ < samples)
{
o = ((INT16)(*s++)+0x80)<<8; // changed signedness and shift up to 16 bits
*d++ = o; // left channel
*d++ = o; // right channel
}
break;
case 22050: // unwrap 2x
while(i++ < samples)
{
o = ((INT16)(*s++)+0x80)<<8; // changed signedness and shift up to 16 bits
*d++ = o; // left channel
*d++ = o; // right channel
*d++ = o; // left channel
*d++ = o; // right channel
}
break;
case 11025: // unwrap 4x
while(i++ < samples)
{
o = ((INT16)(*s++)+0x80)<<8; // changed signedness and shift up to 16 bits
*d++ = o; // left channel
*d++ = o; // right channel
*d++ = o; // left channel
*d++ = o; // right channel
*d++ = o; // left channel
*d++ = o; // right channel
*d++ = o; // left channel
*d++ = o; // right channel
}
break;
default: // convert arbitrary hz to 44100.
step = 0;
frac = ((UINT32)freq << FRACBITS) / 44100;
while (i < samples)
{
o = (INT16)(*s+0x80)<<8; // changed signedness and shift up to 16 bits
while (step < FRACUNIT) // this is as fast as I can make it.
{
*d++ = o; // left channel
*d++ = o; // right channel
step += frac;
}
do {
i++; s++;
step -= FRACUNIT;
} while (step >= FRACUNIT);
}
break;
}
// return Mixer Chunk.
return Mix_QuickLoad_RAW(sound, (UINT8*)d-sound);
}
void *I_GetSfx(sfxinfo_t *sfx)
{
void *lump;
Mix_Chunk *chunk;
#ifdef HAVE_LIBGME
Music_Emu *emu;
gme_info_t *info;
#endif
if (sfx->lumpnum == LUMPERROR)
sfx->lumpnum = S_GetSfxLumpNum(sfx);
sfx->length = W_LumpLength(sfx->lumpnum);
lump = W_CacheLumpNum(sfx->lumpnum, PU_SOUND);
// convert from standard DoomSound format.
chunk = ds2chunk(lump);
if (chunk)
{
Z_Free(lump);
return chunk;
}
// Not a doom sound? Try something else.
#ifdef HAVE_LIBGME
// VGZ format
if (((UINT8 *)lump)[0] == 0x1F
&& ((UINT8 *)lump)[1] == 0x8B)
{
#ifdef HAVE_ZLIB
UINT8 *inflatedData;
size_t inflatedLen;
z_stream stream;
int zErr; // Somewhere to handle any error messages zlib tosses out
memset(&stream, 0x00, sizeof (z_stream)); // Init zlib stream
// Begin the inflation process
inflatedLen = *(UINT32 *)lump + (sfx->length-4); // Last 4 bytes are the decompressed size, typically
inflatedData = (UINT8 *)Z_Malloc(inflatedLen, PU_SOUND, NULL); // Make room for the decompressed data
stream.total_in = stream.avail_in = sfx->length;
stream.total_out = stream.avail_out = inflatedLen;
stream.next_in = (UINT8 *)lump;
stream.next_out = inflatedData;
zErr = inflateInit2(&stream, 32 + MAX_WBITS);
if (zErr == Z_OK) // We're good to go
{
zErr = inflate(&stream, Z_FINISH);
if (zErr == Z_STREAM_END) {
// Run GME on new data
if (!gme_open_data(inflatedData, inflatedLen, &emu, 44100))
{
short *mem;
UINT32 len;
gme_equalizer_t eq = {GME_TREBLE, GME_BASS, 0,0,0,0,0,0,0,0};
Z_Free(inflatedData); // GME supposedly makes a copy for itself, so we don't need this lying around
Z_Free(lump); // We're done with the uninflated lump now, too.
gme_start_track(emu, 0);
gme_set_equalizer(emu, &eq);
gme_track_info(emu, &info, 0);
len = (info->play_length * 441 / 10) << 2;
mem = Z_Malloc(len, PU_SOUND, NULL);
gme_play(emu, len >> 1, mem);
gme_delete(emu);
return Mix_QuickLoad_RAW((Uint8 *)mem, len);
}
}
else
{
const char *errorType;
switch (zErr)
{
case Z_ERRNO:
errorType = "Z_ERRNO"; break;
case Z_STREAM_ERROR:
errorType = "Z_STREAM_ERROR"; break;
case Z_DATA_ERROR:
errorType = "Z_DATA_ERROR"; break;
case Z_MEM_ERROR:
errorType = "Z_MEM_ERROR"; break;
case Z_BUF_ERROR:
errorType = "Z_BUF_ERROR"; break;
case Z_VERSION_ERROR:
errorType = "Z_VERSION_ERROR"; break;
default:
errorType = "unknown error";
}
CONS_Alert(CONS_ERROR,"Encountered %s when running inflate: %s\n", errorType, stream.msg);
}
(void)inflateEnd(&stream);
}
else // Hold up, zlib's got a problem
{
const char *errorType;
switch (zErr)
{
case Z_ERRNO:
errorType = "Z_ERRNO"; break;
case Z_STREAM_ERROR:
errorType = "Z_STREAM_ERROR"; break;
case Z_DATA_ERROR:
errorType = "Z_DATA_ERROR"; break;
case Z_MEM_ERROR:
errorType = "Z_MEM_ERROR"; break;
case Z_BUF_ERROR:
errorType = "Z_BUF_ERROR"; break;
case Z_VERSION_ERROR:
errorType = "Z_VERSION_ERROR"; break;
default:
errorType = "unknown error";
}
CONS_Alert(CONS_ERROR,"Encountered %s when running inflateInit: %s\n", errorType, stream.msg);
}
Z_Free(inflatedData); // GME didn't open jack, but don't let that stop us from freeing this up
#else
//CONS_Alert(CONS_ERROR,"Cannot decompress VGZ; no zlib support\n");
#endif
}
// Try to read it as a GME sound
else if (!gme_open_data(lump, sfx->length, &emu, 44100))
{
short *mem;
UINT32 len;
gme_equalizer_t eq = {GME_TREBLE, GME_BASS, 0,0,0,0,0,0,0,0};
Z_Free(lump);
gme_start_track(emu, 0);
gme_set_equalizer(emu, &eq);
gme_track_info(emu, &info, 0);
len = (info->play_length * 441 / 10) << 2;
mem = Z_Malloc(len, PU_SOUND, NULL);
gme_play(emu, len >> 1, mem);
gme_delete(emu);
return Mix_QuickLoad_RAW((Uint8 *)mem, len);
}
#endif
// Try to load it as a WAVE or OGG using Mixer.
return Mix_LoadWAV_RW(SDL_RWFromMem(lump, sfx->length), 1);
}
void I_FreeSfx(sfxinfo_t *sfx)
{
if (sfx->data)
Mix_FreeChunk(sfx->data);
sfx->data = NULL;
}
INT32 I_StartSound(sfxenum_t id, UINT8 vol, UINT8 sep, UINT8 pitch, UINT8 priority)
{
UINT8 volume = (((UINT16)vol + 1) * (UINT16)sfx_volume) / 62; // (256 * 31) / 62 == 127
INT32 handle = Mix_PlayChannel(-1, S_sfx[id].data, 0);
Mix_Volume(handle, volume);
Mix_SetPanning(handle, min((UINT16)(0xff-sep)<<1, 0xff), min((UINT16)(sep)<<1, 0xff));
(void)pitch; // Mixer can't handle pitch
(void)priority; // priority and channel management is handled by SRB2...
return handle;
}
void I_StopSound(INT32 handle)
{
Mix_HaltChannel(handle);
}
boolean I_SoundIsPlaying(INT32 handle)
{
return Mix_Playing(handle);
}
void I_UpdateSoundParams(INT32 handle, UINT8 vol, UINT8 sep, UINT8 pitch)
{
UINT8 volume = (((UINT16)vol + 1) * (UINT16)sfx_volume) / 62; // (256 * 31) / 62 == 127
Mix_Volume(handle, volume);
Mix_SetPanning(handle, min((UINT16)(0xff-sep)<<1, 0xff), min((UINT16)(sep)<<1, 0xff));
(void)pitch;
}
void I_SetSfxVolume(UINT8 volume)
{
sfx_volume = volume;
}
//
// Music
//
// Music hooks
static void music_loop(void)
{
Mix_PlayMusic(music, 0);
Mix_SetMusicPosition(loop_point);
}
#ifdef HAVE_LIBGME
static void mix_gme(void *udata, Uint8 *stream, int len)
{
int i;
short *p;
(void)udata;
// no gme? no music.
if (!gme || gme_track_ended(gme))
return;
// play gme into stream
gme_play(gme, len/2, (short *)stream);
// apply volume to stream
for (i = 0, p = (short *)stream; i < len/2; i++, p++)
*p = ((INT32)*p) * music_volume / 31;
}
#endif
void I_InitMusic(void)
{
}
void I_ShutdownMusic(void)
{
I_ShutdownDigMusic();
I_ShutdownMIDIMusic();
}
void I_PauseSong(INT32 handle)
{
(void)handle;
Mix_PauseMusic();
}
void I_ResumeSong(INT32 handle)
{
(void)handle;
Mix_ResumeMusic();
}
//
// Digital Music
//
void I_InitDigMusic(void)
{
#ifdef HAVE_LIBGME
gme = NULL;
current_track = -1;
#endif
}
void I_ShutdownDigMusic(void)
{
if (midimode)
return;
#ifdef HAVE_LIBGME
if (gme)
{
Mix_HookMusic(NULL, NULL);
gme_delete(gme);
gme = NULL;
}
#endif
if (!music)
return;
Mix_HookMusicFinished(NULL);
Mix_FreeMusic(music);
music = NULL;
}
boolean I_StartDigSong(const char *musicname, boolean looping)
{
char *data;
size_t len;
lumpnum_t lumpnum = W_CheckNumForName(va("O_%s",musicname));
I_Assert(!music);
#ifdef HAVE_LIBGME
I_Assert(!gme);
#endif
if (lumpnum == LUMPERROR)
{
lumpnum = W_CheckNumForName(va("D_%s",musicname));
if (lumpnum == LUMPERROR)
return false;
midimode = true;
}
else
midimode = false;
data = (char *)W_CacheLumpNum(lumpnum, PU_MUSIC);
len = W_LumpLength(lumpnum);
#ifdef HAVE_LIBGME
if ((UINT8)data[0] == 0x1F
&& (UINT8)data[1] == 0x8B)
{
#ifdef HAVE_ZLIB
UINT8 *inflatedData;
size_t inflatedLen;
z_stream stream;
int zErr; // Somewhere to handle any error messages zlib tosses out
memset(&stream, 0x00, sizeof (z_stream)); // Init zlib stream
// Begin the inflation process
inflatedLen = *(UINT32 *)(data + (len-4)); // Last 4 bytes are the decompressed size, typically
inflatedData = (UINT8 *)Z_Calloc(inflatedLen, PU_MUSIC, NULL); // Make room for the decompressed data
stream.total_in = stream.avail_in = len;
stream.total_out = stream.avail_out = inflatedLen;
stream.next_in = (UINT8 *)data;
stream.next_out = inflatedData;
zErr = inflateInit2(&stream, 32 + MAX_WBITS);
if (zErr == Z_OK) // We're good to go
{
zErr = inflate(&stream, Z_FINISH);
if (zErr == Z_STREAM_END) {
// Run GME on new data
if (!gme_open_data(inflatedData, inflatedLen, &gme, 44100))
{
gme_equalizer_t eq = {GME_TREBLE, GME_BASS, 0,0,0,0,0,0,0,0};
gme_start_track(gme, 0);
current_track = 0;
gme_set_equalizer(gme, &eq);
Mix_HookMusic(mix_gme, gme);
Z_Free(inflatedData); // GME supposedly makes a copy for itself, so we don't need this lying around
return true;
}
}
else
{
const char *errorType;
switch (zErr)
{
case Z_ERRNO:
errorType = "Z_ERRNO"; break;
case Z_STREAM_ERROR:
errorType = "Z_STREAM_ERROR"; break;
case Z_DATA_ERROR:
errorType = "Z_DATA_ERROR"; break;
case Z_MEM_ERROR:
errorType = "Z_MEM_ERROR"; break;
case Z_BUF_ERROR:
errorType = "Z_BUF_ERROR"; break;
case Z_VERSION_ERROR:
errorType = "Z_VERSION_ERROR"; break;
default:
errorType = "unknown error";
}
CONS_Alert(CONS_ERROR,"Encountered %s when running inflate: %s\n", errorType, stream.msg);
}
(void)inflateEnd(&stream);
}
else // Hold up, zlib's got a problem
{
const char *errorType;
switch (zErr)
{
case Z_ERRNO:
errorType = "Z_ERRNO"; break;
case Z_STREAM_ERROR:
errorType = "Z_STREAM_ERROR"; break;
case Z_DATA_ERROR:
errorType = "Z_DATA_ERROR"; break;
case Z_MEM_ERROR:
errorType = "Z_MEM_ERROR"; break;
case Z_BUF_ERROR:
errorType = "Z_BUF_ERROR"; break;
case Z_VERSION_ERROR:
errorType = "Z_VERSION_ERROR"; break;
default:
errorType = "unknown error";
}
CONS_Alert(CONS_ERROR,"Encountered %s when running inflateInit: %s\n", errorType, stream.msg);
}
Z_Free(inflatedData); // GME didn't open jack, but don't let that stop us from freeing this up
#else
//CONS_Alert(CONS_ERROR,"Cannot decompress VGZ; no zlib support\n");
#endif
}
else if (!gme_open_data(data, len, &gme, 44100))
{
gme_equalizer_t eq = {GME_TREBLE, GME_BASS, 0,0,0,0,0,0,0,0};
gme_start_track(gme, 0);
current_track = 0;
gme_set_equalizer(gme, &eq);
Mix_HookMusic(mix_gme, gme);
return true;
}
#endif
music = Mix_LoadMUS_RW(SDL_RWFromMem(data, len));
if (!music)
{
CONS_Alert(CONS_ERROR, "Mix_LoadMUS_RW: %s\n", Mix_GetError());
return true;
}
// Find the OGG loop point.
loop_point = 0.0f;
if (looping)
{
const char *key1 = "LOOP";
const char *key2 = "POINT=";
const char *key3 = "MS=";
const UINT8 key1len = strlen(key1);
const UINT8 key2len = strlen(key2);
const UINT8 key3len = strlen(key3);
char *p = data;
while ((UINT32)(p - data) < len)
{
if (strncmp(p++, key1, key1len))
continue;
p += key1len-1; // skip OOP (the L was skipped in strncmp)
if (!strncmp(p, key2, key2len)) // is it LOOPPOINT=?
{
p += key2len; // skip POINT=
loop_point = (float)((44.1L+atoi(p)) / 44100.0L); // LOOPPOINT works by sample count.
// because SDL_Mixer is USELESS and can't even tell us
// something simple like the frequency of the streaming music,
// we are unfortunately forced to assume that ALL MUSIC is 44100hz.
// This means a lot of tracks that are only 22050hz for a reasonable downloadable file size will loop VERY badly.
}
else if (!strncmp(p, key3, key3len)) // is it LOOPMS=?
{
p += key3len; // skip MS=
loop_point = atoi(p) / 1000.0L; // LOOPMS works by real time, as miliseconds.
// Everything that uses LOOPMS will work perfectly with SDL_Mixer.
}
// Neither?! Continue searching.
}
}
if (Mix_PlayMusic(music, looping && loop_point == 0.0f ? -1 : 0) == -1)
{
CONS_Alert(CONS_ERROR, "Mix_PlayMusic: %s\n", Mix_GetError());
return true;
}
if (midimode)
Mix_VolumeMusic((UINT32)midi_volume*128/31);
else
Mix_VolumeMusic((UINT32)music_volume*128/31);
if (loop_point != 0.0f)
Mix_HookMusicFinished(music_loop);
return true;
}
void I_StopDigSong(void)
{
if (midimode)
return;
#ifdef HAVE_LIBGME
if (gme)
{
Mix_HookMusic(NULL, NULL);
gme_delete(gme);
gme = NULL;
current_track = -1;
return;
}
#endif
if (!music)
return;
Mix_HookMusicFinished(NULL);
Mix_FreeMusic(music);
music = NULL;
}
void I_SetDigMusicVolume(UINT8 volume)
{
music_volume = volume;
if (midimode || !music)
return;
Mix_VolumeMusic((UINT32)volume*128/31);
}
boolean I_SetSongSpeed(float speed)
{
if (speed > 250.0f)
speed = 250.0f; //limit speed up to 250x
#ifdef HAVE_LIBGME
if (gme)
{
SDL_LockAudio();
gme_set_tempo(gme, speed);
SDL_UnlockAudio();
return true;
}
#else
(void)speed;
#endif
return false;
}
boolean I_SetSongTrack(int track)
{
#ifdef HAVE_LIBGME
if (current_track == track)
return false;
// If the specified track is within the number of tracks playing, then change it
if (gme)
{
SDL_LockAudio();
if (track >= 0
&& track < gme_track_count(gme))
{
gme_err_t gme_e = gme_start_track(gme, track);
if (gme_e != NULL)
{
CONS_Alert(CONS_ERROR, "GME error: %s\n", gme_e);
return false;
}
current_track = track;
SDL_UnlockAudio();
return true;
}
SDL_UnlockAudio();
return false;
}
#endif
(void)track;
return false;
}
//
// MIDI Music
//
void I_InitMIDIMusic(void)
{
}
void I_ShutdownMIDIMusic(void)
{
if (!midimode || !music)
return;
Mix_FreeMusic(music);
music = NULL;
}
void I_SetMIDIMusicVolume(UINT8 volume)
{
midi_volume = volume;
if (!midimode || !music)
return;
Mix_VolumeMusic((UINT32)volume*128/31);
}
INT32 I_RegisterSong(void *data, size_t len)
{
music = Mix_LoadMUS_RW(SDL_RWFromMem(data, len));
if (!music)
{
CONS_Alert(CONS_ERROR, "Mix_LoadMUS_RW: %s\n", Mix_GetError());
return -1;
}
return 1337;
}
boolean I_PlaySong(INT32 handle, boolean looping)
{
(void)handle;
midimode = true;
if (Mix_PlayMusic(music, looping ? -1 : 0) == -1)
{
CONS_Alert(CONS_ERROR, "Mix_PlayMusic: %s\n", Mix_GetError());
return false;
}
Mix_VolumeMusic((UINT32)music_volume*128/31);
return true;
}
void I_StopSong(INT32 handle)
{
if (!midimode || !music)
return;
(void)handle;
Mix_HaltMusic();
}
void I_UnRegisterSong(INT32 handle)
{
if (!midimode || !music)
return;
(void)handle;
Mix_FreeMusic(music);
music = NULL;
}
#endif

View file

@ -1,306 +0,0 @@
// 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 SDL specific part of the OpenGL API for SRB2
#ifdef _MSC_VER
#pragma warning(disable : 4214 4244)
#endif
#ifdef HAVE_SDL
#include "SDL.h"
#ifdef _MSC_VER
#pragma warning(default : 4214 4244)
#endif
#include "../doomdef.h"
#ifdef HWRENDER
#include "../hardware/r_opengl/r_opengl.h"
#include "ogl_sdl.h"
#include "../i_system.h"
#include "hwsym_sdl.h"
#include "../m_argv.h"
#ifdef DEBUG_TO_FILE
#include <stdarg.h>
#if defined (_WIN32) && !defined (__CYGWIN__)
#include <direct.h>
#else
#include <unistd.h>
#endif
#include <sys/types.h>
#include <sys/stat.h>
#endif
#ifdef USE_WGL_SWAP
PFNWGLEXTSWAPCONTROLPROC wglSwapIntervalEXT = NULL;
#else
typedef int (*PFNGLXSWAPINTERVALPROC) (int);
PFNGLXSWAPINTERVALPROC glXSwapIntervalSGIEXT = NULL;
#endif
#ifndef STATIC_OPENGL
PFNglClear pglClear;
PFNglGetIntegerv pglGetIntegerv;
PFNglGetString pglGetString;
#endif
static const Uint32 WOGLFlags = SDL_OPENGL/*|SDL_RESIZABLE*/;
static const Uint32 FOGLFlags = SDL_OPENGL|SDL_FULLSCREEN;
/** \brief SDL video display surface
*/
SDL_Surface *vidSurface = NULL;
INT32 oglflags = 0;
void *GLUhandle = NULL;
#ifndef STATIC_OPENGL
void *GetGLFunc(const char *proc)
{
if (strncmp(proc, "glu", 3) == 0)
{
if (GLUhandle)
return hwSym(proc, GLUhandle);
else
return NULL;
}
return SDL_GL_GetProcAddress(proc);
}
#endif
boolean LoadGL(void)
{
#ifndef STATIC_OPENGL
const char *OGLLibname = NULL;
const char *GLULibname = NULL;
if (M_CheckParm ("-OGLlib") && M_IsNextParm())
OGLLibname = M_GetNextParm();
if (SDL_GL_LoadLibrary(OGLLibname) != 0)
{
I_OutputMsg("Could not load OpenGL Library: %s\n"
"Falling back to Software mode.\n", SDL_GetError());
if (!M_CheckParm ("-OGLlib"))
I_OutputMsg("If you know what is the OpenGL library's name, use -OGLlib\n");
return 0;
}
#if 0
GLULibname = "/proc/self/exe";
#elif defined (_WIN32)
GLULibname = "GLU32.DLL";
#elif defined (__MACH__)
GLULibname = "/System/Library/Frameworks/OpenGL.framework/Libraries/libGLU.dylib";
#elif defined (macintos)
GLULibname = "OpenGLLibrary";
#elif defined (__unix__)
GLULibname = "libGLU.so.1";
#elif defined (__HAIKU__)
GLULibname = "libGLU.so";
#else
GLULibname = NULL;
#endif
if (M_CheckParm ("-GLUlib") && M_IsNextParm())
GLULibname = M_GetNextParm();
if (GLULibname)
{
GLUhandle = hwOpen(GLULibname);
if (GLUhandle)
return SetupGLfunc();
else
{
I_OutputMsg("Could not load GLU Library: %s\n", GLULibname);
if (!M_CheckParm ("-GLUlib"))
I_OutputMsg("If you know what is the GLU library's name, use -GLUlib\n");
}
}
else
{
I_OutputMsg("Could not load GLU Library\n");
I_OutputMsg("If you know what is the GLU library's name, use -GLUlib\n");
}
#endif
return SetupGLfunc();
}
/** \brief The OglSdlSurface function
\param w width
\param h height
\param isFullscreen if true, go fullscreen
\return if true, changed video mode
*/
boolean OglSdlSurface(INT32 w, INT32 h, boolean isFullscreen)
{
INT32 cbpp;
Uint32 OGLFlags;
const GLvoid *glvendor = NULL, *glrenderer = NULL, *glversion = NULL;
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);
// Get info and extensions.
//BP: why don't we make it earlier ?
//Hurdler: we cannot do that before intialising gl context
glrenderer = pglGetString(GL_RENDERER);
glversion = pglGetString(GL_VERSION);
gl_extensions = pglGetString(GL_EXTENSIONS);
DBG_Printf("Vendor : %s\n", glvendor);
DBG_Printf("Renderer : %s\n", glrenderer);
DBG_Printf("Version : %s\n", glversion);
DBG_Printf("Extensions : %s\n", gl_extensions);
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
if (isExtAvailable("GL_EXT_texture_filter_anisotropic", gl_extensions))
pglGetIntegerv(GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT, &maximumAnisotropy);
else
maximumAnisotropy = 0;
SetupGLFunc13();
granisotropicmode_cons_t[1].value = maximumAnisotropy;
SetModelView(w, h);
SetStates();
pglClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
HWR_Startup();
textureformatGL = cbpp > 16 ? GL_RGBA : GL_RGB5_A1;
return true;
}
/** \brief The OglSdlFinishUpdate function
\param vidwait wait for video sync
\return void
*/
void OglSdlFinishUpdate(boolean waitvbl)
{
static boolean oldwaitvbl = false;
if (oldwaitvbl != waitvbl)
{
#ifdef USE_WGL_SWAP
if (wglSwapIntervalEXT)
wglSwapIntervalEXT(waitvbl);
#else
if (glXSwapIntervalSGIEXT)
glXSwapIntervalSGIEXT(waitvbl);
#endif
}
oldwaitvbl = waitvbl;
SDL_GL_SwapBuffers();
}
EXPORT void HWRAPI( OglSdlSetPalette) (RGBA_t *palette, RGBA_t *pgamma)
{
INT32 i = -1;
UINT32 redgamma = pgamma->s.red, greengamma = pgamma->s.green,
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++)
{
myPaletteData[i].s.red = (UINT8)MIN((palette[i].s.red * redgamma) /127, 255);
myPaletteData[i].s.green = (UINT8)MIN((palette[i].s.green * greengamma)/127, 255);
myPaletteData[i].s.blue = (UINT8)MIN((palette[i].s.blue * bluegamma) /127, 255);
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();
}
#endif //HWRENDER
#endif //SDL

View file

@ -1,30 +0,0 @@
// 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 SDL specific part of the OpenGL API for SRB2
#include "../v_video.h"
extern SDL_Surface *vidSurface;
extern void *GLUhandle;
boolean OglSdlSurface(INT32 w, INT32 h, boolean isFullscreen);
void OglSdlFinishUpdate(boolean vidwait);
#ifdef _CREATE_DLL_
EXPORT void HWRAPI( OglSdlSetPalette ) (RGBA_t *palette, RGBA_t *pgamma);
#endif

File diff suppressed because it is too large Load diff

View file

@ -1,65 +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.
//-----------------------------------------------------------------------------
/// \file
/// \brief System specific interface stuff.
#ifndef __sdlmain__
#define __sdlmain__
extern SDL_bool consolevent;
extern SDL_bool framebuffer;
/** \brief The JoyInfo_s struct
info about joystick
*/
typedef struct SDLJoyInfo_s
{
/// Joystick handle
SDL_Joystick *dev;
/// number of old joystick
int oldjoy;
/// number of axies
int axises;
/// scale of axises
INT32 scale;
/// number of buttons
int buttons;
/// number of hats
int hats;
/// number of balls
int balls;
} SDLJoyInfo_t;
/** \brief SDL info about joystick 1
*/
extern SDLJoyInfo_t JoyInfo;
/** \brief joystick axis deadzone
*/
#define SDL_JDEADZONE 153
#undef SDL_JDEADZONE
/** \brief SDL inof about joystick 2
*/
extern SDLJoyInfo_t JoyInfo2;
void I_GetConsoleEvents(void);
void SDLforceUngrabMouse(void);
#endif

Binary file not shown.