total destruction

removed wince, wii, psp, ps3, msdos and gp2x things aswell as removing sdl 1.2 things since that cant be used with kart anyways
This commit is contained in:
alufolie91 committed 2023-10-03 02:10:33 +02:00
1 parent 8ecf4f26a7
commit 90623359c7
184 files changed
+55 -52892

No files matched your search

+1 -4
View File
@@ -109,13 +109,10 @@ FILE_PATTERNS = *.c \
*.mm \
*.dox
RECURSIVE = YES
EXCLUDE = ./src/djgppdos/internal.h \
./src/djgppdos/setup.c \
./src/sdl/IMG_xpm.c \
EXCLUDE = ./src/sdl/IMG_xpm.c \
./src/sdl/SRB2DC/scramble.c
EXCLUDE_SYMLINKS = NO
EXCLUDE_PATTERNS = */src/hardware/*/* \
*/src/djgppdos/bcd.? \
*/src/sdl/SDL_main/* \
*/src/*/*_private.h \
*/src/sdl/*/*help.? \
-2
View File
@@ -1,2 +0,0 @@
# DON'T REMOVE
# This keeps the folder from disappearing
-2
View File
@@ -1,2 +0,0 @@
# DON'T REMOVE
# This keeps the folder from disappearing
-2
View File
@@ -1,2 +0,0 @@
# DON'T REMOVE
# This keeps the folder from disappearing
-5
View File
@@ -1,5 +0,0 @@
/*.elf
/*.self
/*.pkg
/*.BIN
/pkg
-5
View File
@@ -1,5 +0,0 @@
/*.elf
/*.self
/*.pkg
/*.BIN
/pkg
-4
View File
@@ -1,4 +0,0 @@
/EBOOT.PBP
/PARAM.SFO
/SRB2PSP.PBP
/SRB2PSP.elf
-3
View File
@@ -1,3 +0,0 @@
/*.elf
/*.dol
/apps
-3
View File
@@ -1,3 +0,0 @@
/*.elf
/*.dol
/apps
-2
View File
@@ -1,2 +0,0 @@
# DON'T REMOVE
# This keeps the folder from disappearing
-2
View File
@@ -1,2 +0,0 @@
# DON'T REMOVE
# This keeps the folder from disappearing
-2
View File
@@ -1,2 +0,0 @@
# DON'T REMOVE
# This keeps the folder from disappearing
-2
View File
@@ -1,2 +0,0 @@
# DON'T REMOVE
# This keeps the folder from disappearing
-2
View File
@@ -1,2 +0,0 @@
# DON'T REMOVE
# This keeps the folder from disappearing
-2
View File
@@ -1,2 +0,0 @@
# DON'T REMOVE
# This keeps the folder from disappearing
-2
View File
@@ -1,2 +0,0 @@
# DON'T REMOVE
# This keeps the folder from disappearing
-2
View File
@@ -1,2 +0,0 @@
# DON'T REMOVE
# This keeps the folder from disappearing
-2
View File
@@ -1,2 +0,0 @@
# DON'T REMOVE
# This keeps the folder from disappearing
-2
View File
@@ -1,2 +0,0 @@
# DON'T REMOVE
# This keeps the folder from disappearing
-2
View File
@@ -1,2 +0,0 @@
# DON'T REMOVE
# This keeps the folder from disappearing
-2
View File
@@ -1,2 +0,0 @@
# DON'T REMOVE
# This keeps the folder from disappearing
-2
View File
@@ -1,2 +0,0 @@
# DON'T REMOVE
# This keeps the folder from disappearing
-2
View File
@@ -1,2 +0,0 @@
# DON'T REMOVE
# This keeps the folder from disappearing
-2
View File
@@ -1,2 +0,0 @@
# DON'T REMOVE
# This keeps the folder from disappearing
-2
View File
@@ -1,2 +0,0 @@
# DON'T REMOVE
# This keeps the folder from disappearing
-2
View File
@@ -1,2 +0,0 @@
# DON'T REMOVE
# This keeps the folder from disappearing
-2
View File
@@ -1,2 +0,0 @@
# DON'T REMOVE
# This keeps the folder from disappearing
-2
View File
@@ -1,2 +0,0 @@
# DON'T REMOVE
# This keeps the folder from disappearing
-2
View File
@@ -1,2 +0,0 @@
# DON'T REMOVE
# This keeps the folder from disappearing
-2
View File
@@ -1,2 +0,0 @@
# DON'T REMOVE
# This keeps the folder from disappearing
-2
View File
@@ -1,2 +0,0 @@
# DON'T REMOVE
# This keeps the folder from disappearing
-2
View File
@@ -1,2 +0,0 @@
# DON'T REMOVE
# This keeps the folder from disappearing
-2
View File
@@ -1,2 +0,0 @@
# DON'T REMOVE
# This keeps the folder from disappearing
-2
View File
@@ -1,2 +0,0 @@
# DON'T REMOVE
# This keeps the folder from disappearing
-3
View File
@@ -1,3 +0,0 @@
*.arm9
*.elf*
*.nds
-3
View File
@@ -1,3 +0,0 @@
*.arm9
*.elf*
*.nds
-2
View File
@@ -1,2 +0,0 @@
# DON'T REMOVE
# This keeps the folder from disappearing
-2
View File
@@ -1,2 +0,0 @@
# DON'T REMOVE
# This keeps the folder from disappearing
-2
View File
@@ -1,2 +0,0 @@
# DON'T REMOVE
# This keeps the folder from disappearing
-2
View File
@@ -1,2 +0,0 @@
# DON'T REMOVE
# This keeps the folder from disappearing
-2
View File
@@ -1,2 +0,0 @@
# DON'T REMOVE
# This keeps the folder from disappearing
-2
View File
@@ -1,2 +0,0 @@
# DON'T REMOVE
# This keeps the folder from disappearing
-2
View File
@@ -1,2 +0,0 @@
# DON'T REMOVE
# This keeps the folder from disappearing
-2
View File
@@ -1,2 +0,0 @@
# DON'T REMOVE
# This keeps the folder from disappearing
-2
View File
@@ -1,2 +0,0 @@
# DON'T REMOVE
# This keeps the folder from disappearing
-2
View File
@@ -1,2 +0,0 @@
# DON'T REMOVE
# This keeps the folder from disappearing
-2
View File
@@ -1,2 +0,0 @@
# DON'T REMOVE
# This keeps the folder from disappearing
-2
View File
@@ -1,2 +0,0 @@
# DON'T REMOVE
# This keeps the folder from disappearing
-2
View File
@@ -1,2 +0,0 @@
# DON'T REMOVE
# This keeps the folder from disappearing
-2
View File
@@ -1,2 +0,0 @@
# DON'T REMOVE
# This keeps the folder from disappearing
-47
View File
@@ -8,13 +8,11 @@
# terms of the GNU General Public License, version 2.
# See the 'LICENSE' file for more details.
#
# -DPC_DOS -> use DOS specific code (eg:textmode stuff)...
# -DLINUX -> use for the GNU/Linux specific
# -D_WINDOWS -> use for the Win32/DirectX specific
# -DHAVE_SDL -> use for the SDL interface
#
# Sets:
# Compile the DGJPP/DOS version with 'make WATTCP=1'
# Compile the DirectX/Mingw version with 'make MINGW=1'
# Compile the SDL/Mingw version with 'make MINGW=1 SDL=1'
# Compile the SDL/Linux version with 'make LINUX=1'
@@ -87,7 +85,6 @@ ALL_SYSTEMS=\
MINGW64\
HAIKU\
DUMMY\
DJGPPDOS\
MINGW\
UNIX\
LINUX\
@@ -170,12 +167,6 @@ ifdef HAIKU
SDL=1
endif
ifdef NDS
# Include this before the main Makefile.cfg
EXENAME?=srb2.elf
include nds/Makefile.cfg
endif
include Makefile.cfg
ifdef DUMMY
@@ -204,10 +195,6 @@ NONX86=1
NOHW=1
endif
ifdef DJGPPDOS
include djgppdos/Makefile.cfg
endif
ifndef NOOPENMPT
HAVE_OPENMPT=1
endif
@@ -239,25 +226,8 @@ ifdef MACOSX
UNIXCOMMON=1
endif
ifdef NDS
NOPNG=1
NOZLIB=1
NONET=1
#NOHW=1
NOIPX=1
NONX86=1
OBJS+=$(OBJDIR)/i_video.o
LIBS+=-lm
endif
ifdef SDL
#SDL 2.0
ifndef SDL12
include sdl/Makefile.cfg
#SDL 1.2
else
include sdl12/Makefile.cfg
endif #ifndef SDL12
endif #ifdef SDL
ifdef DISTCC
@@ -585,10 +555,6 @@ POS:=$(BIN)/en.mo
OPTS+=-DGETTEXT
endif
ifdef DJGPPDOS
all: pre-build $(BIN)/$(EXENAME)
endif
ifdef PANDORA
all: pre-build $(BIN)/$(PNDNAME)
endif
@@ -603,10 +569,6 @@ ifdef SDL
all: pre-build $(BIN)/$(EXENAME)
endif
ifdef NDS
all: $(BIN)/$(EXENAME:.elf=.nds)
endif
ifdef DUMMY
all: $(BIN)/$(EXENAME)
endif
@@ -636,7 +598,6 @@ endif
# executable
# NOTE: DJGPP's objcopy do not have --add-gnu-debuglink
$(BIN)/$(EXENAME): $(POS) $(OBJS)
-$(MKDIR) $(BIN)
@@ -813,14 +774,6 @@ $(OBJDIR)/%.o: %.s
$(OBJDIR)/SRB2.res: win32/Srb2win.rc win32/afxres.h win32/resource.h
$(WINDRES) -i $< -O rc $(WINDRESFLAGS) --include-dir=win32 -o $@ -O coff
ifdef NDS
$(BIN)/$(EXENAME:.elf=.nds): $(BIN)/$(EXENAME:.elf=.arm9)
$(NDSTOOL) -c $@ -9 $(BIN)/$(EXENAME:.elf=.arm9)
%.arm9: %.elf
$(OBJCOPY) -O binary $< $@
endif
ifdef MINGW
ifndef SDL
ifndef NOHW
+1 -44
View File
@@ -336,18 +336,14 @@ endif
#indicate platform and what interface use with
ifndef WINCE
ifndef LINUX
ifndef FREEBSD
ifndef CYGWIN32
ifndef MINGW
ifndef MINGW64
ifndef SDL
ifndef NDS
ifndef DUMMY
DJGPPDOS=1
endif
endif
$(error No interface or platform flag defined)
endif
endif
endif
@@ -379,15 +375,6 @@ UPX_OPTS+=-q
endif
#Interface Setup
ifdef DJGPPDOS
INTERFACE=djgppdos
OBJDIR:=$(OBJDIR)/djgppdos
ifdef WATTCP
OBJDIR:=$(OBJDIR)/wattcp
endif
WFLAGS+=-Wno-format
BIN:=$(BIN)/Dos
else
ifdef DUMMY
INTERFACE=dummy
OBJDIR:=$(OBJDIR)/dummy
@@ -433,21 +420,6 @@ ifdef MINGW
INTERFACE=win32
OBJDIR:=$(OBJDIR)/Mingw
BIN:=$(BIN)/Mingw
else
ifdef WINCE
INTERFACE=sdl12
NONX86=1
PREFIX?=arm-wince-pe
SDL=1
SDL12=1
OBJDIR:=$(OBJDIR)/WinCE
BIN:=$(BIN)/WinCE
else
ifdef NDS
INTERFACE=nds
OBJDIR:=$(OBJDIR)/nds
BIN:=$(BIN)/nds
NOUPX=1
endif
endif
endif
@@ -455,15 +427,6 @@ endif
endif
endif
endif
endif
endif
endif
ifdef GP2X
ifdef SDL
SDL12=1
endif
endif
ifdef ARCHNAME
OBJDIR:=$(OBJDIR)/$(ARCHNAME)
@@ -474,13 +437,7 @@ OBJDUMP_OPTS?=--wide --source --line-numbers
LD=$(CC)
ifdef SDL
# SDL 2.0
ifndef SDL12
INTERFACE=sdl
# SDL 1.2
else
INTERFACE=sdl12
endif
OBJDIR:=$(OBJDIR)/SDL
endif
-5
View File
@@ -42,11 +42,6 @@ static const UINT8 NOCLIMBGRAYS = 204;
static const UINT8 NOCLIMBBROWNS = (2*16);
static const UINT8 NOCLIMBYELLOWS = (11*16);
#ifdef _NDS
#undef BACKGROUND
#endif
// Automap colors
#define BACKGROUND DBLACK
#define WALLCOLORS (REDS + REDRANGE/2)
-3
View File
@@ -1474,9 +1474,6 @@ static void Got_NetVar(UINT8 **p, INT32 playernum)
CONS_Alert(CONS_WARNING, "Netvar not found with netid %hu\n", netid);
return;
}
#if 0 //defined (GP2X)
CONS_Printf("Netvar received: %s [netid=%d] value %s\n", cvar->name, netid, svalue);
#endif
DEBFILE(va("Netvar received: %s [netid=%d] value %s\n", cvar->name, netid, svalue));
Setvalue(cvar, svalue, stealth);
+2 -13
View File
@@ -1413,21 +1413,10 @@ void CONS_Printf(const char *fmt, ...)
// echo console prints to log file
DEBFILE(txt);
if (!con_started)
{
#ifdef PC_DOS
CON_LogMessage(txt);
free(txt);
return;
#endif
}
else
// write message in con text buffer
if (con_started)
CON_Print(txt);
#ifndef PC_DOS
CON_LogMessage(txt);
#endif
Lock_state();
-2
View File
@@ -10,9 +10,7 @@
/// \file d_clisrv.c
/// \brief SRB2 Network game communication and protocol, all OS independent parts.
#if !defined (UNDER_CE)
#include <time.h>
#endif
#ifdef __GNUC__
#include <unistd.h> //for unlink
#endif
+10 -59
View File
@@ -15,7 +15,7 @@
/// plus functions to parse command line parameters, configure game
/// parameters, and call the startup functions.
#if (defined (__unix__) && !defined (MSDOS)) || defined(__APPLE__) || defined (UNIXCOMMON)
#if defined (__unix__) || defined (__APPLE__) || defined (UNIXCOMMON)
#include <sys/stat.h>
#include <sys/types.h>
#endif
@@ -24,20 +24,12 @@
#include <unistd.h> // for getcwd
#endif
#ifdef PC_DOS
#include <stdio.h> // for snprintf
int snprintf(char *str, size_t n, const char *fmt, ...);
//int vsnprintf(char *str, size_t n, const char *fmt, va_list ap);
#endif
#if defined (_WIN32) && !defined (_WIN32_WCE)
#ifdef _WIN32
#include <direct.h>
#include <malloc.h>
#endif
#if !defined (UNDER_CE)
#include <time.h>
#endif
#include "doomdef.h"
#include "am_map.h"
@@ -166,10 +158,6 @@ void D_PostEvent(const event_t *ev)
events[eventhead] = *ev;
eventhead = (eventhead+1) & (MAXEVENTS-1);
}
// just for lock this function
#if defined (PC_DOS) && !defined (DOXYGEN)
void D_PostEvent_end(void) {};
#endif
// modifier keys
// Now handled in I_OsPolling
@@ -942,7 +930,7 @@ static void IdentifyVersion(void)
const char *srb2waddir = NULL;
found_extra_kart = false;
#if (defined (__unix__) && !defined (MSDOS)) || defined (UNIXCOMMON) || defined (HAVE_SDL)
#if defined (__unix__) || defined (UNIXCOMMON) || defined (HAVE_SDL)
// change to the directory where 'srb2.srb' is found
srb2waddir = I_LocateWad();
#endif
@@ -954,11 +942,9 @@ static void IdentifyVersion(void)
}
else
{
#ifndef _WIN32_WCE
if (getcwd(srb2path, 256) != NULL)
srb2waddir = srb2path;
else
#endif
{
srb2waddir = srb2path;
}
@@ -1011,28 +997,6 @@ static void IdentifyVersion(void)
#endif
}
/* ======================================================================== */
// Just print the nice red titlebar like the original SRB2 for DOS.
/* ======================================================================== */
#ifdef PC_DOS
static inline void D_Titlebar(char *title1, char *title2)
{
// SRB2 banner
clrscr();
textattr((BLUE<<4)+WHITE);
clreol();
cputs(title1);
// standard srb2 banner
textattr((RED<<4)+WHITE);
clreol();
gotoxy((80-strlen(title2))/2, 2);
cputs(title2);
normvideo();
gotoxy(1,3);
}
#endif
//
// Center the title string, then add the date and time of compilation.
//
@@ -1060,7 +1024,6 @@ static inline void D_MakeTitleString(char *s)
strcpy(s, temp);
}
//
// D_SRB2Main
//
@@ -1091,7 +1054,7 @@ void D_SRB2Main(void)
"in this program.\n\n");
// keep error messages until the final flush(stderr)
#if !defined (PC_DOS) && !defined (_WIN32_WCE) && !defined(NOTERMIOS)
#if !defined(NOTERMIOS)
if (setvbuf(stderr, NULL, _IOFBF, 1000))
I_OutputMsg("setvbuf didnt work\n");
#endif
@@ -1113,11 +1076,11 @@ void D_SRB2Main(void)
// identify the main IWAD file to use
IdentifyVersion();
#if !defined (_WIN32_WCE) && !defined(NOTERMIOS)
#if !defined(NOTERMIOS)
setbuf(stdout, NULL); // non-buffered output
#endif
#if defined (_WIN32_WCE) //|| defined (_DEBUG) || defined (GP2X)
#if 0 //defined (_DEBUG)
devparm = M_CheckParm("-nodebug") == 0;
#else
devparm = M_CheckParm("-debug") != 0;
@@ -1132,10 +1095,6 @@ void D_SRB2Main(void)
strcpy(srb2, "SRB2Kart");
D_MakeTitleString(srb2);
#ifdef PC_DOS
D_Titlebar(srb2, title);
#endif
#if defined (__OS2__) && !defined (HAVE_SDL)
// set PM window title
snprintf(pmData->title, sizeof (pmData->title),
@@ -1157,13 +1116,8 @@ void D_SRB2Main(void)
if (!userhome)
{
#if ((defined (__unix__) && !defined (MSDOS)) || defined(__APPLE__) || defined (UNIXCOMMON)) && !defined (__CYGWIN__) && !defined(GP2X)
#if (defined (__unix__) || defined (__APPLE__) || defined (UNIXCOMMON)) && !defined (__CYGWIN__)
I_Error("Please set $HOME to your home directory\n");
#elif defined (_WIN32_WCE) && 0
if (dedicated)
snprintf(configfile, sizeof configfile, "/Storage Card/SRB2DEMO/d"CONFIGFILENAME);
else
snprintf(configfile, sizeof configfile, "/Storage Card/SRB2DEMO/"CONFIGFILENAME);
#else
if (dedicated)
snprintf(configfile, sizeof configfile, "d"CONFIGFILENAME);
@@ -1417,7 +1371,7 @@ void D_SRB2Main(void)
G_LoadGameData();
#if (defined (__unix__) && !defined (MSDOS)) || defined (UNIXCOMMON) || defined (HAVE_SDL)
#if defined (__unix__) || defined (UNIXCOMMON) || defined (HAVE_SDL)
VID_PrepareModeList(); // Regenerate Modelist according to cv_fullscreen
#endif
@@ -1738,17 +1692,14 @@ const char *D_Home(void)
userhome = M_GetNextParm();
else
{
#if defined (GP2X)
usehome = false; //let use the CWD
return NULL;
#elif !((defined (__unix__) && !defined (MSDOS)) || defined(__APPLE__) || defined (UNIXCOMMON)) && !defined (__APPLE__) && !defined(_WIN32_WCE)
#if !(defined (__unix__) || defined (__APPLE__) || defined (UNIXCOMMON))
if (FIL_FileOK(CONFIGFILENAME))
usehome = false; // Let's NOT use home
else
#endif
userhome = I_GetEnv("HOME"); //Alam: my new HOME for srb2
}
#if defined (_WIN32) && !defined(_WIN32_WCE) //Alam: only Win32 have APPDATA and USERPROFILE
#ifdef _WIN32 //Alam: only Win32 have APPDATA and USERPROFILE
if (!userhome && usehome) //Alam: Still not?
{
char *testhome = NULL;
-3
View File
@@ -39,9 +39,6 @@ void D_SRB2Main(void);
// Called by IO functions when input is detected.
void D_PostEvent(const event_t *ev);
#if defined (PC_DOS) && !defined (DOXYGEN)
void D_PostEvent_end(void); // delimiter for locking memory
#endif
void D_ProcessEvents(void);
+3 -3
View File
@@ -213,7 +213,7 @@ void SendWeaponPref3(void);
void SendWeaponPref4(void);
static CV_PossibleValue_t usemouse_cons_t[] = {{0, "Off"}, {1, "On"}, {2, "Force"}, {0, NULL}};
#if (defined (__unix__) && !defined (MSDOS)) || defined(__APPLE__) || defined (UNIXCOMMON)
#if defined (__unix__) || defined (__APPLE__) || defined (UNIXCOMMON)
static CV_PossibleValue_t mouse2port_cons_t[] = {{0, "/dev/gpmdata"}, {1, "/dev/ttyS0"},
{2, "/dev/ttyS1"}, {3, "/dev/ttyS2"}, {4, "/dev/ttyS3"}, {0, NULL}};
#else
@@ -326,7 +326,7 @@ consvar_t cv_joyscale4 = {"joyscale4", "1", CV_SAVE|CV_CALL, NULL, I_JoyScale4,
consvar_t cv_joyscale = {"joyscale", "1", CV_SAVE|CV_HIDEN, NULL, NULL, 0, NULL, NULL, 0, 0, NULL}; //Alam: Dummy for save
consvar_t cv_joyscale2 = {"joyscale2", "1", CV_SAVE|CV_HIDEN, NULL, NULL, 0, NULL, NULL, 0, 0, NULL}; //Alam: Dummy for save
#endif
#if (defined (__unix__) && !defined (MSDOS)) || defined(__APPLE__) || defined (UNIXCOMMON)
#if defined (__unix__) || defined (__APPLE__) || defined (UNIXCOMMON)
consvar_t cv_mouse2port = {"mouse2port", "/dev/gpmdata", CV_SAVE, mouse2port_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_mouse2opt = {"mouse2opt", "0", CV_SAVE, NULL, NULL, 0, NULL, NULL, 0, 0, NULL};
#else
@@ -1057,7 +1057,7 @@ void D_RegisterClientCommands(void)
// WARNING: the order is important when initialising mouse2
// we need the mouse2port
CV_RegisterVar(&cv_mouse2port);
#if (defined (__unix__) && !defined (MSDOS)) || defined(__APPLE__) || defined (UNIXCOMMON)
#if defined (__unix__) || defined (__APPLE__) || defined (UNIXCOMMON)
CV_RegisterVar(&cv_mouse2opt);
#endif
CV_RegisterVar(&cv_controlperkey);
+1 -1
View File
@@ -57,7 +57,7 @@ extern consvar_t cv_joyscale4;
// splitscreen with second mouse
extern consvar_t cv_mouse2port;
extern consvar_t cv_usemouse2;
#if (defined (__unix__) && !defined (MSDOS)) || defined (UNIXCOMMON)
#if defined (__unix__) || defined (__APPLE__) || defined (UNIXCOMMON)
extern consvar_t cv_mouse2opt;
#endif
+3 -11
View File
@@ -11,21 +11,17 @@
/// \brief Transfer a file using HSendPacket.
#include <stdio.h>
#ifndef _WIN32_WCE
#ifdef __OS2__
#include <sys/types.h>
#endif // __OS2__
#include <sys/stat.h>
#endif
#if !defined (UNDER_CE)
#include <time.h>
#endif
#if ((defined (_WIN32) && !defined (_WIN32_WCE)) || defined (__DJGPP__))
#ifdef _WIN32
#include <io.h>
#include <direct.h>
#elif !defined (_WIN32_WCE)
#else
#include <sys/types.h>
#include <dirent.h>
#include <utime.h>
@@ -34,13 +30,9 @@
#ifdef __GNUC__
#include <unistd.h>
#include <limits.h>
#elif defined (_WIN32) && !defined (_WIN32_WCE)
#elif defined (_WIN32)
#include <sys/utime.h>
#endif
#ifdef __DJGPP__
#include <dir.h>
#include <utime.h>
#endif
#ifdef HAVE_CURL
#include "curl/curl.h"
-6
View File
@@ -43,12 +43,6 @@
#include "r_draw.h" // translation colormap consts (for lua)
#endif
#ifdef PC_DOS
#include <stdio.h> // for snprintf
//int snprintf(char *str, size_t n, const char *fmt, ...);
int vsnprintf(char *str, size_t n, const char *fmt, va_list ap);
#endif
// Free slot names
// The crazy word-reading stuff uses these.
static char *FREE_STATES[NUMSTATEFREESLOTS];
-48
View File
@@ -1,48 +0,0 @@
#
# djgppdos/makefile.cfg for SRB2/DOS
#
#
#now for the DOS stuff, go DOS!
#
# options
OPTS=-DPC_DOS
WFLAGS+=-Wno-cast-qual
NOHW=1
NOHS=1
PNG_CFLAGS=
PNG_LDFLAGS=-lpng -lz
ifdef WATTCP
OPTS+=-DWATTCP
NOOBJDUMP=1
endif
#ifdef DEBUGMODE
LIBS=-lalld
#else
# LIBS=-lalleg
#endif
ifndef NONET
ifdef WATTCP
LIBS+=-lwatt
else
LIBS+=-lsocket
endif
endif
ifdef RDB
LIBS+=-lgdbst -ldzcom
OPTS+=-DREMOTE_DEBUGGING
endif
OBJS=$(OBJDIR)/i_video.o $(OBJDIR)/vid_vesa.o
# name of the exefile
ifdef WATTCP
EXENAME?=srb2dos.exe
else
EXENAME?=srb2w16.exe
endif
-755
View File
@@ -1,755 +0,0 @@
/* bcd.c -- Brennan's CD-ROM Audio Playing Library
by Brennan Underwood, http://brennan.home.ml.org/ */
#include <dos.h>
#include <dpmi.h>
#include <go32.h>
#include <fcntl.h>
#include <stdio.h>
#include <malloc.h>
#include <unistd.h>
#include <strings.h>
#ifdef STANDALONE
#include <conio.h> /* for getch() */
#endif
#include "bcd.h"
typedef struct {
int is_audio;
int start, end, len;
} Track;
static int mscdex_version;
static int first_drive;
static int num_tracks;
static int lowest_track, highest_track;
static int audio_length;
#ifdef STATIC_TRACKS
static Track tracks[99];
#else
static Track *tracks;
#endif
static int dos_mem_segment, dos_mem_selector = -1;
int _status, _error, _error_code;
const char *_bcd_error = NULL;
#define RESET_ERROR (_error = _error_code = 0)
#define ERROR_BIT (1 << 15)
#define BUSY_BIT (1 << 9)
#ifndef TRUE
#define TRUE 1
#define FALSE 0
#endif
#pragma pack(1)
/* I know 'typedef struct {} bleh' is a bad habit, but... */
typedef struct {
unsigned char len;
unsigned char unit;
unsigned char command;
unsigned short status;
unsigned char reserved[8];
} ATTRPACK RequestHeader;
typedef struct {
RequestHeader request_header;
unsigned char descriptor;
unsigned long address;
unsigned short len;
unsigned short secnum;
unsigned long ptr;
} ATTRPACK IOCTLI;
typedef struct {
unsigned char control;
unsigned char lowest;
unsigned char highest;
char total[4];
} ATTRPACK DiskInfo;
typedef struct {
unsigned char control;
unsigned char track_number;
char start[4];
unsigned char info;
} ATTRPACK TrackInfo;
typedef struct {
RequestHeader request;
unsigned char mode;
unsigned long start;
unsigned long len;
} ATTRPACK PlayRequest;
typedef struct {
RequestHeader request;
} ATTRPACK StopRequest;
typedef struct {
RequestHeader request;
} ATTRPACK ResumeRequest;
typedef struct {
unsigned char control;
unsigned char input0;
unsigned char volume0;
unsigned char input1;
unsigned char volume1;
unsigned char input2;
unsigned char volume2;
unsigned char input3;
unsigned char volume3;
} ATTRPACK VolumeRequest;
typedef struct {
unsigned char control;
unsigned char fn;
} ATTRPACK LockRequest;
typedef struct {
unsigned char control;
unsigned char mbyte;
} ATTRPACK MediaChangedRequest;
typedef struct {
unsigned char control;
unsigned long status;
} ATTRPACK StatusRequest;
typedef struct {
unsigned char control;
unsigned char mode;
unsigned long loc;
} ATTRPACK PositionRequest;
#pragma pack()
#ifdef __cplusplus
extern "C" {
#endif
const char *bcd_error(void) {
static char retstr[132];
const char *errorcodes[] = {
"Write-protect violation",
"Unknown unit",
"Drive not ready",
"Unknown command",
"CRC error",
"Bad drive request structure length",
"Seek error",
"Unknown media",
"Sector not found",
"Printer out of paper: world coming to an end",/* I mean really, on a CD? */
"Write fault",
"Read fault",
"General failure",
"Reserved",
"Reserved",
"Invalid disk change"
};
*retstr = 0;
if (_error != 0) {
strcat(retstr, "Device error: ");
if (_error_code < 0 || _error_code > 0xf)
strcat(retstr, "Invalid error");
else
strcat(retstr, errorcodes[_error_code]);
strcat(retstr, " ");
}
if (_bcd_error != NULL) {
if (*retstr) strcat(retstr, ", ");
strcat(retstr, "BCD error: ");
strcat(retstr, _bcd_error);
}
return retstr;
}
/* DOS IOCTL w/ command block */
static void bcd_ioctl(IOCTLI *ioctli, void *command, int len) {
int ioctli_len = sizeof (IOCTLI);
unsigned long command_address = dos_mem_segment << 4;
__dpmi_regs regs;
memset(&regs, 0, sizeof regs);
regs.x.es = (__tb >> 4) & 0xffff;
regs.x.ax = 0x1510;
regs.x.bx = __tb & 0xf;
regs.x.cx = first_drive;
ioctli->address = dos_mem_segment << 16;
ioctli->len = len;
dosmemput(ioctli, ioctli_len, __tb); /* put ioctl into dos area */
dosmemput(command, len, command_address); /* and command too */
if (__dpmi_int(0x2f, &regs) == -1) {
_bcd_error = "__dpmi_int() failed";
return;
}
dosmemget(__tb, ioctli_len, ioctli); /* retrieve results */
dosmemget(command_address, len, command);
_status = ioctli->request_header.status;
if (_status & ERROR_BIT) {
_error = TRUE;
_error_code = _status & 0xff;
} else {
_error = FALSE;
_error_code = 0;
}
}
/* no command block */
FUNCINLINE static ATTRINLINE void bcd_ioctl2(void *cmd, int len) {
__dpmi_regs regs;
memset(&regs, 0, sizeof regs);
regs.x.es = (__tb >> 4) & 0xffff;
regs.x.ax = 0x1510;
regs.x.bx = __tb & 0xf;
regs.x.cx = first_drive;
dosmemput(cmd, len, __tb); /* put ioctl block in dos arena */
if (__dpmi_int(0x2f, &regs) == -1) {
_bcd_error = "__dpmi_int() failed";
return;
}
/* I hate to have no error capability for ioctl2 but the command block
doesn't necessarily have a status field */
RESET_ERROR;
}
FUNCINLINE static ATTRINLINE int red2hsg(char *r) {
return r[0] + r[1]*75 + r[2]*4500 - 150;
}
int bcd_now_playing(void) {
int i, loc = bcd_audio_position();
_bcd_error = NULL;
if (!bcd_audio_busy()) {
_bcd_error = "Audio not playing";
return 0;
}
if (
#ifndef STATIC_TRACKS
tracks == NULL &&
#endif
!bcd_get_audio_info())
return 0;
for (i = lowest_track; i <= highest_track; i++) {
if (loc >= tracks[i].start && loc <= tracks[i].end) return i;
}
/* some bizarre location? */
_bcd_error = "Head outside of bounds";
return 0;
}
/* handles the setup for CD-ROM audio interface */
int bcd_open(void) {
__dpmi_regs regs;
_bcd_error = NULL;
/* disk I/O wouldn't work anyway if you set sizeof tb this low, but... */
if (_go32_info_block.size_of_transfer_buffer < 4096) {
_bcd_error = "Transfer buffer too small";
return 0;
}
memset(&regs, 0, sizeof regs);
regs.x.ax = 0x1500;
regs.x.bx = 0x0;
__dpmi_int(0x2f, &regs);
if (regs.x.bx == 0) { /* abba no longer lives */
_bcd_error = "MSCDEX not found";
return 0;
}
first_drive = regs.x.cx; /* use the first drive */
/* check for mscdex at least 2.0 */
memset(&regs, 0, sizeof regs);
regs.x.ax = 0x150C;
__dpmi_int(0x2f, &regs);
if (regs.x.bx == 0) {
_bcd_error = "MSCDEX version < 2.0";
return 0;
}
mscdex_version = regs.x.bx;
/* allocate 256 bytes of dos memory for the command blocks */
if ((dos_mem_segment = __dpmi_allocate_dos_memory(16, &dos_mem_selector))<0) {
_bcd_error = "Could not allocate 256 bytes of DOS memory";
return 0;
}
return mscdex_version;
}
/* Shuts down CD-ROM audio interface */
int bcd_close(void) {
_bcd_error = NULL;
if (dos_mem_selector != -1) {
__dpmi_free_dos_memory(dos_mem_selector);
dos_mem_selector = -1;
}
#ifndef STATIC_TRACKS
if (tracks) free(tracks);
tracks = NULL;
#endif
RESET_ERROR;
return 1;
}
int bcd_open_door(void) {
IOCTLI ioctli;
char eject = 0;
_bcd_error = NULL;
memset(&ioctli, 0, sizeof ioctli);
ioctli.request_header.len = sizeof ioctli;
ioctli.request_header.command = 12;
ioctli.len = 1;
bcd_ioctl(&ioctli, &eject, sizeof eject);
if (_error) return 0;
return 1;
}
int bcd_close_door(void) {
IOCTLI ioctli;
char closeit = 5;
_bcd_error = NULL;
memset(&ioctli, 0, sizeof ioctli);
ioctli.request_header.len = sizeof ioctli;
ioctli.request_header.command = 12;
ioctli.len = 1;
bcd_ioctl(&ioctli, &closeit, sizeof closeit);
if (_error) return 0;
return 1;
}
int bcd_lock(int fn) {
IOCTLI ioctli;
LockRequest req;
_bcd_error = NULL;
memset(&ioctli, 0, sizeof ioctli);
memset(&req, 0, sizeof req);
ioctli.request_header.len = sizeof ioctli;
ioctli.request_header.command = 12;
ioctli.len = sizeof req;
req.control = 1;
req.fn = fn ? 1 : 0;
bcd_ioctl(&ioctli, &req, sizeof req);
if (_error) return 0;
return 1;
}
int bcd_disc_changed(void) {
IOCTLI ioctli;
MediaChangedRequest req;
_bcd_error = NULL;
memset(&ioctli, 0, sizeof ioctli);
memset(&req, 0, sizeof req);
ioctli.request_header.len = sizeof ioctli;
ioctli.request_header.command = 3;
ioctli.len = sizeof req;
req.control = 9;
bcd_ioctl(&ioctli, &req, sizeof req);
return req.mbyte;
}
int bcd_reset(void) {
IOCTLI ioctli;
char reset = 2;
_bcd_error = NULL;
memset(&ioctli, 0, sizeof ioctli);
ioctli.request_header.len = sizeof ioctli;
ioctli.request_header.command = 12;
ioctli.len = 1;
bcd_ioctl(&ioctli, &reset, sizeof reset);
if (_error) return 0;
return 1;
}
int bcd_device_status(void) {
IOCTLI ioctli;
StatusRequest req;
_bcd_error = NULL;
memset(&ioctli, 0, sizeof ioctli);
memset(&req, 0, sizeof req);
ioctli.request_header.len = sizeof ioctli; // ok
ioctli.request_header.command = 3;
ioctli.len = sizeof req;
req.control = 6;
bcd_ioctl(&ioctli, &req, sizeof req);
return req.status;
}
static inline int bcd_get_status_word(void) {
IOCTLI ioctli;
DiskInfo disk_info;
/* get cd info as an excuse to get a look at the status word */
memset(&disk_info, 0, sizeof disk_info);
memset(&ioctli, 0, sizeof ioctli);
ioctli.request_header.len = 26;
ioctli.request_header.command = 3;
ioctli.len = 7;
disk_info.control = 10;
bcd_ioctl(&ioctli, &disk_info, sizeof disk_info);
return _status;
}
int bcd_audio_busy(void) {
_bcd_error = NULL;
/* If the door is open, then the head is busy, and so the busy bit is
on. It is not, however, playing audio. */
if (bcd_device_status() & BCD_DOOR_OPEN)
return 0;
bcd_get_status_word();
if (_error) return -1;
return (_status & BUSY_BIT) ? 1 : 0;
}
int bcd_audio_position(void) {
IOCTLI ioctli;
PositionRequest req;
_bcd_error = NULL;
memset(&ioctli, 0, sizeof ioctli);
memset(&req, 0, sizeof req);
ioctli.request_header.len = sizeof ioctli;
ioctli.request_header.command = 3;
ioctli.len = sizeof req;
req.control = 1;
bcd_ioctl(&ioctli, &req, sizeof req);
return req.loc;
}
/* Internal function to get track info */
static inline void bcd_get_track_info(int n, Track *t) {
IOCTLI ioctli;
TrackInfo info;
memset(&ioctli, 0, sizeof ioctli);
memset(&info, 0, sizeof info);
ioctli.request_header.len = sizeof ioctli;
ioctli.request_header.command = 3;
info.control = 11;
info.track_number = n;
bcd_ioctl(&ioctli, &info, sizeof info);
t->start = red2hsg(info.start);
if (info.info & 64)
t->is_audio = 0;
else
t->is_audio = 1;
}
int bcd_get_audio_info(void) {
IOCTLI ioctli;
DiskInfo disk_info;
int i;
_bcd_error = NULL;
#ifndef STATIC_TRACKS
if (tracks) free(tracks);
tracks = NULL;
#endif
memset(&disk_info, 0, sizeof disk_info);
memset(&ioctli, 0, sizeof ioctli);
ioctli.request_header.len = 26;
ioctli.request_header.command = 3;
ioctli.len = 7;
disk_info.control = 10;
bcd_ioctl(&ioctli, &disk_info, sizeof disk_info);
if (_error) return 0;
lowest_track = disk_info.lowest;
highest_track = disk_info.highest;
num_tracks = disk_info.highest - disk_info.lowest + 1;
#ifndef STATIC_TRACKS
//tracks = calloc(num_tracks, sizeof (Track));
/* alloc max space in order to attempt to avoid possible overrun bug */
tracks = calloc(highest_track+1, sizeof (Track));
if (tracks == NULL) {
_bcd_error = "Out of memory allocating tracks\n";
return 0;
}
#endif
/* get track starts */
for (i = lowest_track; i <= highest_track; i++)
bcd_get_track_info(i, tracks+i);
/* figure out track ends */
for (i = lowest_track; i < highest_track; i++)
tracks[i].end = tracks[i+1].start-1;
audio_length = red2hsg(disk_info.total);
tracks[i].end = audio_length;
for (i = lowest_track; i <= highest_track; i++)
tracks[i].len = tracks[i].end - tracks[i].start;
return num_tracks;
}
int bcd_get_track_address(int trackno, int *start, int *len) {
_bcd_error = NULL;
//if (trackno >= num_tracks+1 || trackno <= 0) {
if (trackno < lowest_track || trackno > highest_track) {
_bcd_error = "Track out of range";
*start = *len = 0;
return 0;
}
*start = tracks[trackno].start;
*len = tracks[trackno].len;
return 1;
}
int bcd_track_is_audio(int trackno) {
//if (trackno >= num_tracks+1 || trackno <= 0) {
if (trackno < lowest_track || trackno > highest_track) {
_bcd_error = "Track out of range";
return 0;
}
return tracks[trackno].is_audio;
}
int bcd_set_volume(int volume) {
IOCTLI ioctli;
VolumeRequest v;
_bcd_error = NULL;
if (volume > 255) volume = 255;
else if (volume < 0) volume = 0;
memset(&ioctli, 0, sizeof ioctli);
ioctli.request_header.len = sizeof ioctli;
ioctli.request_header.command = 12;
ioctli.len = sizeof v;
v.control = 3;
v.volume0 = volume;
v.input0 = 0;
v.volume1 = volume;
v.input1 = 1;
v.volume2 = volume;
v.input2 = 2;
v.volume3 = volume;
v.input3 = 3;
bcd_ioctl(&ioctli, &v, sizeof v);
if (_error) return 0;
return 1;
}
int bcd_play(int location, int frames) {
PlayRequest cmd;
memset(&cmd, 0, sizeof cmd);
_bcd_error = NULL;
/* the following should be in user code, but it'll fail otherwise */
if (bcd_audio_busy())
bcd_stop();
cmd.request.len = sizeof cmd;
cmd.request.command = 132;
cmd.start = location;
cmd.len = frames;
bcd_ioctl2(&cmd, sizeof cmd);
if (_error) return 0;
return 1;
}
int bcd_play_track(int trackno) {
_bcd_error = NULL;
if (!bcd_get_audio_info()) return 0;
if (trackno < lowest_track || trackno > highest_track) {
_bcd_error = "Track out of range";
return 0;
}
if (! tracks[trackno].is_audio) {
_bcd_error = "Not an audio track";
return 0;
}
return bcd_play(tracks[trackno].start, tracks[trackno].len);
}
int bcd_stop(void) {
StopRequest cmd;
_bcd_error = NULL;
memset(&cmd, 0, sizeof cmd);
cmd.request.len = sizeof cmd;
cmd.request.command = 133;
bcd_ioctl2(&cmd, sizeof cmd);
if (_error) return 0;
return 1;
}
int bcd_resume(void) {
ResumeRequest cmd;
_bcd_error = NULL;
memset(&cmd, 0, sizeof cmd);
cmd.request.len = sizeof cmd;
cmd.request.command = 136;
bcd_ioctl2(&cmd, sizeof cmd);
if (_error) return 0;
return 1;
}
#ifdef __cplusplus
}
#endif
#ifdef STANDALONE
static char *card(int c) {
return c == 1 ? "" : "s";
}
static void print_hsg(int hsg) {
int hours, minutes, seconds;
seconds = hsg / 75;
minutes = seconds / 60;
seconds %= 60;
hours = minutes / 60;
minutes %= 60;
printf("%2d:%02d:%02d", hours, minutes, seconds);
}
static void print_binary(int v, int len) {
for (;len;len--)
printf("%d", (v & (1 << len)) ? 1 : 0);
}
int main(int argc, char *argv[]) {
int i, n1, n2, t;
if (!bcd_open()) {
fprintf(stderr, "Couldn't open CD-ROM drive. %s\n", bcd_error());
exit(0);
}
for (i = 1; i < argc; i++) {
if (*argv[i] == '-') strcpy(argv[i], argv[i]+1);
if (!strcmp(argv[i], "open") || !strcmp(argv[i], "eject")) {
bcd_open_door();
} else if (!strcmp(argv[i], "close")) {
bcd_close_door();
} else if (!strcmp(argv[i], "sleep")) {
if (++i >= argc) break;
sleep(atoi(argv[i]));
} else if (!strcmp(argv[i], "list")) {
int nd = 0, na = 0, audio_time = 0;
if (!bcd_get_audio_info()) {
printf("Error getting audio info\n");
} else if (lowest_track == 0) {
printf("No audio tracks\n");
} else {
for (t = lowest_track; t <= highest_track; t++) {
printf("Track %2d: ", t);
print_hsg(tracks[t].start);
printf(" -> ");
print_hsg(tracks[t].end);
printf(" (");
print_hsg(tracks[t].len);
if (tracks[t].is_audio) {
na++;
printf(") audio");
audio_time += tracks[t].len;
} else {
nd++;
printf(") data ");
}
printf(" (HSG: %06d->%06d)\n", tracks[t].start, tracks[t].end);
}
printf("%d audio track%s, %d data track%s\n", na, card(na), nd, card(nd));
if (audio_time) {
printf("Audio time: ");
print_hsg(audio_time);
printf("\n");
}
}
} else if (!strcmp(argv[i], "lock")) {
bcd_lock(1);
} else if (!strcmp(argv[i], "pladdr")) {
if (++i >= argc) break;
n1 = atoi(argv[i]);
if (++i >= argc) break;
n2 = atoi(argv[i]);
printf("Playing frame %d to frame %d\n", n1, n2);
bcd_play(n1, n2-n1);
} else if (!strcmp(argv[i], "play")) {
if (++i >= argc) break;
if (bcd_audio_busy()) {
bcd_stop();
delay(1000);
}
n1 = atoi(argv[i]);
printf("Playing track %d\n", n1);
bcd_play_track(n1);
} else if (!strcmp(argv[i], "reset")) {
bcd_reset();
} else if (!strcmp(argv[i], "resume")) {
bcd_resume();
} else if (!strcmp(argv[i], "status")) {
int s;
s = bcd_device_status();
printf("MSCDEX version %d.%d\n", mscdex_version >> 8,
mscdex_version & 0xff);
printf("Device status word '");
print_binary(s, 16);
printf("'\nDoor is %sopen\n", s & BCD_DOOR_OPEN ? "" : "not ");
printf("Door is %slocked\n", s & BCD_DOOR_UNLOCKED ? "not " : "");
printf("Audio is %sbusy\n", bcd_audio_busy() ? "" : "not ");
s = bcd_disc_changed();
if (s == BCD_DISC_UNKNOWN) printf("Media change status unknown\n");
else printf("Media has %schanged\n",
(s == BCD_DISC_CHANGED) ? "" : "not ");
} else if (!strcmp(argv[i], "stop")) {
bcd_stop();
} else if (!strcmp(argv[i], "unlock")) {
bcd_lock(0);
} else if (!strcmp(argv[i], "volume")) {
bcd_set_volume(atoi(argv[++i]));
} else if (!strcmp(argv[i], "wait")) {
while (bcd_audio_busy()) {
int n = bcd_now_playing();
if (n == 0) break;
printf("%2d: ", n);
print_hsg(bcd_audio_position() - tracks[n].start);
printf("\r");
fflush(stdout);
delay(100);
if (kbhit() && getch() == 27) break;
}
printf("\n");
} else if (!strcmp(argv[i], "help") || !strcmp(argv[i], "usage")) {
printf("BCD version %x.%x\n" \
"Usage: BCD {commands}\n" \
"Valid commands:\n" \
"\tclose - close door/tray\n" \
"\tdelay {n} - delay {n} seconds\n" \
"\tlist - list track info\n" \
"\tlock - lock door/tray\n" \
"\topen - open door/tray\n" \
"\tpladdr {n1} {n2}- play frame {n1} to {n2}\n" \
"\tplay {n} - play track {n}\n" \
"\treset - reset the drive\n" \
"\tresume - resume from last stop\n" \
"\tstatus - show drive status\n" \
"\tstop - stop audio playback\n" \
"\tunlock - unlock door/tray\n" \
"\tvolume {n} - set volume to {n} where 0 <= {n} <= 255\n",
BCD_VERSION >> 8, BCD_VERSION & 0xff);
} else
printf("Unknown command '%s'\n", argv[i]);
if (_error || _bcd_error) printf("%s\n", bcd_error());
}
bcd_close();
exit(0);
}
#endif
-90
View File
@@ -1,90 +0,0 @@
/* bcd.h -- header file for BCD, a CD-ROM audio playing library for DJGPP
by Brennan Underwood, http://brennan.home.ml.org/ */
#ifndef _BCD_H
#define _BCD_H
#define BCD_VERSION 0x0103
/* Installation and setup functions */
/* Call this first! */
int bcd_open(void);
/* Call before exit. */
int bcd_close(void);
/* open door, unlocking first if necessary */
int bcd_open_door(void);
/* close door */
int bcd_close_door(void);
/* pass 1 to lock door, 0 to unlock */
int bcd_lock(int);
/* returns one of the following 3 #defined symbols */
int bcd_disc_changed(void);
#define BCD_DISC_CHANGED 0xff
#define BCD_DISC_NOT_CHANGED 1
#define BCD_DISC_UNKNOWN 0
/* perform a device reset */
int bcd_reset(void);
/* compare the returned status int to the following bits */
int bcd_device_status(void);
#define BCD_DOOR_OPEN 1
#define BCD_DOOR_UNLOCKED 2
#define BCD_SUPPORT_COOKED 4
#define BCD_READ_ONLY 8
#define BCD_DATA_READ_ONLY 16
#define BCD_SUPPORT_INTERLEAVE 32
/* returns 1 if audio is currently playing, 0 otherwise. -1 on error */
int bcd_audio_busy(void);
/* current head position in frames */
int bcd_audio_position(void);
/* convenience function, if audio busy, returns track# playing now */
int bcd_now_playing(void);
/* query MSCDEX for track list when disc changed or just starting up */
int bcd_get_audio_info(void);
/* get a particular track's info */
int bcd_get_track_address(int trackno, int *start, int *len);
/* check for track's audio/data status */
int bcd_track_is_audio(int trackno);
/* play a particular track from beginning to end */
int bcd_play_track(int tracknum);
/* play an arbitrary section of audio for an arbitrary length of time */
int bcd_play(int start, int len);
/* set the output volume. pass a parameter from 0-255 */
int bcd_set_volume(int);
/* stop and pause are equivalent */
int bcd_stop(void);
#define bcd_pause bcd_stop
int bcd_resume(void);
/* Troubleshooting */
/* Returns a human readable description of the last error encountered */
const char *bcd_error(void);
extern int _error_code;
/* If you are mad enough play the Rach 3, I mean parse _error_code yourself */
#define BCD_DE_WRITE_PROTECT 0
#define BCD_DE_UNKNOWN_UNIT 1
#define BCD_DE_DRIVE_NOT_READY 2
#define BCD_DE_UNKNOWN_COMMAND 3
#define BCD_DE_CRC_ERROR 4
#define BCD_DE_STRUCT_LEN 5
#define BCD_DE_SEEK_ERROR 6
#define BCD_DE_UNKNOWN_MEDIA 7
#define BCD_DE_SECTOR_NOT_FOUND 8
#define BCD_DE_OUT_OF_PAPER 9
#define BCD_DE_WRITE_FAULT 10
#define BCD_DE_READ_FAULT 11
#define BCD_DE_GENERAL_FAILURE 12
#define BCD_DE_INVALID_DISK_CHANGE 15
/* set by BCD itself, for stuff like "Out of memory" */
extern const char *_bcd_error;
/* uncomment this line to force BCD to use a statically allocated
Track array instead of using malloc */
#define STATIC_TRACKS
#endif
-445
View File
@@ -1,445 +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 (uses bcd library)
// Alam_GBC: I hate you, Brennan Underwood :)
#include "../doomtype.h"
#include "bcd.c"
//#include "bcd.h" // CD-Audio library by Brennan Underwood
#include "../doomdef.h"
#include "../i_sound.h"
#include "../command.h"
#include "../i_system.h"
#include "../s_sound.h"
// ------
// protos
// ------
static void Command_Cd_f (void);
//======================================================================
// CD AUDIO MUSIC SUBSYSTEM
//======================================================================
UINT8 cdaudio_started=0; // for system startup/shutdown
#define MAX_CD_TRACKS 256
static boolean cdPlaying = false;
static int cdPlayTrack; // when cdPlaying is true
static boolean cdLooping = false;
static UINT8 cdRemap[MAX_CD_TRACKS];
static boolean cdEnabled=true; // cd info available
static boolean cdValid; // true when last cd audio info was ok
static boolean wasPlaying;
static int cdVolume=0; // current cd volume (0-31)
// 0-31 like Music & Sfx, though CD hardware volume is 0-255.
consvar_t cd_volume = {"cd_volume","18",CV_SAVE,soundvolume_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL};
// allow Update for next/loop track
// some crap cd drivers take up to
// a second for a simple 'busy' check..
// (on those Update can be disabled)
consvar_t cdUpdate = {"cd_update","1",CV_SAVE, NULL, NULL, 0, NULL, NULL, 0, 0, NULL};
// hour,minutes,seconds
FUNCINLINE static ATTRINLINE char *hms(int hsg)
{
int hours, minutes, seconds;
static char s[9];
seconds = hsg / 75;
minutes = seconds / 60;
seconds %= 60;
hours = minutes / 60;
minutes %= 60;
if (hours>0)
sprintf (s, "%d:%02d:%02d", hours, minutes, seconds);
else
sprintf (s, "%2d:%02d", minutes, seconds);
return s;
}
static void Command_Cd_f (void)
{
const char * s;
int i,j;
if (!cdaudio_started)
return;
if (COM_Argc()<2)
{
CONS_Printf ("cd [on] [off] [remap] [reset] [open]\n"
" [info] [play <track>] [loop <track>]\n"
" [stop] [resume]\n");
return;
}
s = COM_Argv(1);
// activate cd music
if (!strncmp(s,"on",2))
{
cdEnabled = true;
return;
}
// stop/deactivate cd music
if (!strncmp(s,"off",3))
{
if (cdPlaying)
I_StopCD ();
cdEnabled = false;
return;
}
// remap tracks
if (!strncmp(s,"remap",5))
{
i = COM_Argc() - 2;
if (i <= 0)
{
CONS_Printf ("CD tracks remapped in that order :\n");
for (j = 1; j < MAX_CD_TRACKS; j++)
if (cdRemap[j] != j)
CONS_Printf (" %2d -> %2d\n", j, cdRemap[j]);
return;
}
for (j = 1; j <= i; j++)
cdRemap[j] = atoi (COM_Argv (j+1));
return;
}
// reset the CD driver, useful on some odd cd's
if (!strncmp(s,"reset",5))
{
cdEnabled = true;
if (cdPlaying)
I_StopCD ();
for (i = 0; i < MAX_CD_TRACKS; i++)
cdRemap[i] = i;
bcd_reset ();
cdValid = bcd_get_audio_info ();
return;
}
// any other command is not allowed until we could retrieve cd information
if (!cdValid)
{
CONS_Printf ("CD is not ready.\n");
return;
}
if (!strncmp(s,"open",4))
{
if (cdPlaying)
I_StopCD ();
bcd_open_door();
cdValid = false;
return;
}
if (!strncmp(s,"info",4))
{
int totaltime = 0;
if (!bcd_get_audio_info())
{
CONS_Printf ("Error getting audio info: %s\n",bcd_error());
cdValid = false;
return;
}
cdValid = true;
if (lowest_track == 0)
CONS_Printf ("No audio tracks\n");
else
{
// display list of tracks
// highlight current playing track
for (i=lowest_track; i <= highest_track; i++)
{
CONS_Printf ("%s%2d. %s %s\n",
cdPlaying && (cdPlayTrack == i) ? "\2 " : " ",
i, tracks[i].is_audio ? "audio" : "data ",
hms(tracks[i].len));
if (tracks[i].is_audio)
totaltime += tracks[i].len;
}
if (totaltime)
CONS_Printf ("\2Total time : %s\n", hms(totaltime));
}
if (cdPlaying)
{
CONS_Printf ("%s track : %d\n", cdLooping ? "looping" : "playing",
cdPlayTrack);
}
return;
}
if (!strncmp(s,"play",4))
{
I_PlayCD ((UINT8)atoi (COM_Argv (2)), false);
return;
}
if (!strncmp(s,"stop",4))
{
I_StopCD ();
return;
}
if (!strncmp(s,"loop",4))
{
I_PlayCD ((UINT8)atoi (COM_Argv (2)), true);
return;
}
if (!strncmp(s,"resume",4))
{
I_ResumeCD ();
return;
}
CONS_Printf ("cd command '%s' unknown\n", s);
}
// pause cd music
void I_StopCD (void)
{
if (!cdaudio_started || !cdEnabled)
return;
bcd_stop();
wasPlaying = cdPlaying;
cdPlaying = false;
}
// continue after a pause
void I_ResumeCD (void)
{
if (!cdaudio_started || !cdEnabled)
return;
if (!cdValid)
return;
if (!wasPlaying)
return;
bcd_resume ();
cdPlaying = true;
}
void I_ShutdownCD (void)
{
int rc;
if (!cdaudio_started)
return;
I_StopCD ();
rc = bcd_close ();
if (!rc)
CONS_Printf ("Error shuting down cd\n");
}
void I_InitCD (void)
{
int rc;
int i;
rc = bcd_open ();
if (rc>=0x200)
{
CONS_Printf ("MSCDEX version %d.%d\n", rc>>8, rc&255);
I_AddExitFunc (I_ShutdownCD);
cdaudio_started = true;
}
else
{
if (!rc)
CONS_Printf ("%s\n", bcd_error() );
cdaudio_started = false;
return;
}
// last saved in config.cfg
i = cd_volume.value;
I_SetVolumeCD (0); // initialize to 0 for some odd cd drivers
I_SetVolumeCD (i); // now set the last saved volume
for (i = 0; i < MAX_CD_TRACKS; i++)
cdRemap[i] = i;
if (!bcd_get_audio_info())
{
CONS_Printf("\2CD Init: No CD in player.\n");
cdEnabled = false;
cdValid = false;
}
else
{
cdEnabled = true;
cdValid = true;
}
COM_AddCommand ("cd", Command_Cd_f);
}
// loop/go to next track when track is finished (if cd_update var is true)
// update the volume when it has changed (from console/menu)
/// \todo check for cd change and restart music ?
void I_UpdateCD (void)
{
int newVolume;
int now;
static int last; //game tics (35th of second)
if (!cdaudio_started)
return;
now = I_GetTime ();
if ((now - last) < 10) // about 1/4 second
return;
last = now;
// update cd volume changed at console/menu
newVolume = cd_volume.value & 31;
if (cdVolume != newVolume)
I_SetVolumeCD (newVolume);
// slow drivers exit here
if (!cdUpdate.value)
return;
if (cdPlaying)
{
if (!bcd_audio_busy())
{
cdPlaying = false;
if (cdLooping)
I_PlayCD (cdPlayTrack, true);
else
{
// play the next cd track, or restart the first
cdPlayTrack++;
if (cdPlayTrack > highest_track)
cdPlayTrack = lowest_track;
while (!tracks[cdPlayTrack].is_audio && cdPlayTrack<highest_track)
cdPlayTrack++;
I_PlayCD (cdPlayTrack, true);
}
}
}
}
//
void I_PlayCD (UINT8 track, UINT8 looping)
{
if (!cdaudio_started || !cdEnabled)
return;
if (!cdValid)
return;
track = cdRemap[track];
if (cdPlaying)
{
if (cdPlayTrack == track)
return;
I_StopCD ();
}
if (track < lowest_track || track > highest_track)
{
//CONS_Printf ("\2CD Audio: wrong track number %d\n", track);
// suppose there are not enough tracks for game levels..
// then do a modulo so we always get something to hear
track = (track % (highest_track-lowest_track+1)) + 1;
//return;
}
cdPlayTrack = track;
if (!tracks[track].is_audio)
{
CONS_Printf ("\2CD Play: not an audio track\n");
return;
}
cdLooping = looping;
if (!bcd_play_track (track))
{
CONS_Printf ("CD Play: could not play track %d\n", track);
cdValid = false;
cdPlaying = false;
return;
}
cdPlaying = true;
}
// volume : logical cd audio volume 0-31 (hardware is 0-255)
boolean I_SetVolumeCD (INT32 volume)
{
int hardvol;
if (!cdaudio_started || !cdEnabled)
return false;
// translate to hardware volume
volume &= 31;
hardvol = ((volume+1)<<3)-1; //highest volume is 255
if (hardvol<=8)
hardvol=0; //lowest volume is ZERO
cdVolume = volume;
if (bcd_set_volume (hardvol))
{
CV_SetValue (&cd_volume, volume);
return true;
}
else
return false;
}
-78
View File
@@ -1,78 +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 high level loop.
#include "../doomdef.h"
#include "../m_argv.h"
#include "../d_main.h"
#include "../i_system.h"
#ifdef REMOTE_DEBUGGING
#include <i386-stub.h>
#include "rdb.h"
#endif
//### let's try with Allegro ###
#define alleg_mouse_unused
#define alleg_timer_unused
#define ALLEGRO_NO_KEY_DEFINES
#define alleg_keyboard_unused
#define alleg_joystick_unused
#define alleg_gfx_driver_unused
#define alleg_palette_unused
#define alleg_graphics_unused
#define alleg_vidmem_unused
#define alleg_flic_unused
#define alleg_sound_unused
#define alleg_file_unused
#define alleg_datafile_unused
#define alleg_math_unused
#define alleg_gui_unused
#include <allegro.h>
//### end of Allegro include ###
int main (int argc, char **argv)
{
myargc = argc;
myargv = argv;
{
//added:03-01-98:
// Setup signal handlers and other stuff BEFORE ANYTHING ELSE!
I_StartupSystem();
#ifdef REMOTE_DEBUGGING
/* Only setup if remote debugging is to be done, Muhahahaha!*/
gdb_serial_init(DEBUG_COM_PORT,DEBUG_COM_PORT_SPEED);
gdb_target_init();
breakpoint();
#endif
D_SRB2Main();
D_SRB2Loop();
}
//added:03-01-98:
// hmmm... it will never go here.
return 0;
}
#if ALLEGRO_VERSION == 4
END_OF_MAIN()
#endif
-113
View File
@@ -1,113 +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 doomcom network interface
#include <netinet/in.h>
#include <errno.h>
#include <unistd.h>
#include <go32.h>
#include <pc.h>
#include <dpmi.h>
#include <dos.h>
#include <sys/nearptr.h>
#include "../doomdef.h"
#include "../i_system.h"
#include "../d_event.h"
#include "../d_net.h"
#include "../m_argv.h"
#include "../doomstat.h"
#include "../z_zone.h"
#include "../i_net.h"
#include "../i_tcp.h"
//
// NETWORKING
//
typedef enum
{
CMD_SEND = 1,
CMD_GET = 2,
} command_t;
static void External_Driver_Get(void);
static void External_Driver_Send(void);
static void External_Driver_FreeNode(INT32 nodenum);
static inline boolean External_Driver_OpenSocket(void)
{
I_NetGet = External_Driver_Get;
I_NetSend = External_Driver_Send;
I_NetCloseSocket = NULL;
I_NetFreeNodenum = External_Driver_FreeNode;
return true;
}
//
// I_InitNetwork
//
boolean I_InitNetwork (void)
{
int netgamepar;
netgamepar = M_CheckParm ("-net");
if (!netgamepar)
return false;
// externals drivers specific
__djgpp_nearptr_enable();
// set up for network
doomcom=(doomcom_t *)(__djgpp_conventional_base+atoi(myargv[netgamepar+1]));
CONS_Printf("I_DosNet : Using int 0x%x for communication\n",doomcom->intnum);
server = (doomcom->consoleplayer == 0);
if (!server)
COM_BufAddText("connect any\n");
// ipx + time + 4 (padding)
packetheaderlength=30+4+4;
hardware_MAXPACKETLENGTH = 512;
I_NetOpenSocket = External_Driver_OpenSocket;
return true;
}
FUNCNORETURN static ATTRNORETURN void External_Driver_Get(void)
{
I_Error("External_Driver_Get not supported at this time");
}
FUNCNORETURN static ATTRNORETURN void External_Driver_Send(void)
{
I_Error("External_Driver_Send not supported at this time");
}
FUNCNORETURN static ATTRNORETURN void External_Driver_FreeNode(INT32 nodenum)
{
nodenum = 0;
I_Error("External_Driver_FreeNode not supported at this time");
}
-619
View File
@@ -1,619 +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 interface level code for sound
#include <stdio.h>
#include <stdlib.h>
#include <stdarg.h>
#include <math.h>
#include "../doomdef.h"
#include "../doomstat.h"
#include "../i_system.h"
#include "../i_sound.h"
#include "../z_zone.h"
#include "../m_argv.h"
#include "../m_misc.h"
#include "../w_wad.h"
#include "../s_sound.h"
#include "../console.h"
//### let's try with Allegro ###
#define alleg_mouse_unused
#define alleg_timer_unused
#define ALLEGRO_NO_KEY_DEFINES
#define alleg_keyboard_unused
#define alleg_joystick_unused
#define alleg_gfx_driver_unused
#define alleg_palette_unused
#define alleg_graphics_unused
#define alleg_vidmem_unused
#define alleg_flic_unused
//#define alleg_sound_unused we use it
#define alleg_file_unused
#define alleg_datafile_unused
#define alleg_math_unused
#define alleg_gui_unused
#include <allegro.h>
//### end of Allegro include ###
//allegro has 256 virtual voices
// warning should by a power of 2
#define VIRTUAL_VOICES 256
#define VOICESSHIFT 8
// Needed for calling the actual sound output.
#define SAMPLECOUNT 512
//
// this function converts raw 11khz, 8-bit data to a SAMPLE* that allegro uses
// it is need cuz allegro only loads samples from wavs and vocs
//added:11-01-98: now reads the frequency from the rawdata header.
// dsdata points a 4 UINT16 header:
// +0 : value 3 what does it mean?
// +2 : sample rate, either 11025 or 22050.
// +4 : number of samples, each sample is a single byte since it's 8bit
// +6 : value 0
static inline SAMPLE *raw2SAMPLE(UINT8 *dsdata, size_t len)
{
SAMPLE *spl;
spl=Z_Malloc(sizeof (SAMPLE),PU_SOUND,NULL);
if (spl==NULL)
I_Error("Raw2Sample : no more free mem");
spl->bits = 8;
spl->stereo = 0;
spl->freq = *((UINT16 *)dsdata+1); //mostly 11025, but some at 22050.
spl->len = len-8;
spl->priority = 255; //priority;
spl->loop_start = 0;
spl->loop_end = len-8;
spl->param = -1;
spl->data=(void *)(dsdata+8); //skip the 8bytes header
return spl;
}
// This function loads the sound data from the WAD lump,
// for single sound.
//
void *I_GetSfx (sfxinfo_t * sfx)
{
UINT8 *dssfx;
if (sfx->lumpnum == LUMPERROR)
sfx->lumpnum = S_GetSfxLumpNum (sfx);
sfx->length = W_LumpLength (sfx->lumpnum);
dssfx = (UINT8 *) W_CacheLumpNum (sfx->lumpnum, PU_SOUND);
//_go32_dpmi_lock_data(dssfx,size);
// convert raw data and header from Doom sfx to a SAMPLE for Allegro
return (void *)raw2SAMPLE (dssfx, sfx->length);
}
void I_FreeSfx (sfxinfo_t *sfx)
{
if (sfx->lumpnum == LUMPERROR)
return;
// free sample data
if ( sfx->data )
Z_Free((UINT8 *) ((SAMPLE *)sfx->data)->data - 8);
Z_Free(sfx->data); // Allegro SAMPLE structure
sfx->data = NULL;
sfx->lumpnum = LUMPERROR;
}
FUNCINLINE static ATTRINLINE int Volset(int vol)
{
return (vol*255/31);
}
void I_SetSfxVolume(INT32 volume)
{
if (sound_disabled)
return;
set_volume (Volset(volume),-1);
}
//
// Starting a sound means adding it
// to the current list of active sounds
// in the internal channels.
// As the SFX info struct contains
// e.g. a pointer to the raw data,
// it is ignored.
// As our sound handling does not handle
// priority, it is ignored.
// Pitching (that is, increased speed of playback)
// is set, but currently not used by mixing.
//
INT32 I_StartSound ( sfxenum_t id,
INT32 vol,
INT32 sep,
INT32 pitch,
INT32 priority,
INT32 channel)
{
int voice;
(void)channel;
if (sound_disabled)
return 0;
// UNUSED
priority = 0;
pitch = (pitch-128)/2+128;
voice = play_sample(S_sfx[id].data,vol,sep,(pitch*1000)/128,0);
// Returns a handle
return (id<<VOICESSHIFT)+voice;
}
void I_StopSound (INT32 handle)
{
// You need the handle returned by StartSound.
// Would be looping all channels,
// tracking down the handle,
// an setting the channel to zero.
int voice=handle & (VIRTUAL_VOICES-1);
if (sound_disabled)
return;
if (voice_check(voice)==S_sfx[handle>>VOICESSHIFT].data)
deallocate_voice(voice);
}
INT32 I_SoundIsPlaying(INT32 handle)
{
if (sound_disabled)
return FALSE;
if (voice_check(handle & (VIRTUAL_VOICES-1))==S_sfx[handle>>VOICESSHIFT].data)
return TRUE;
return FALSE;
}
// cut and past from ALLEGRO he don't share it :(
static inline int absolute_freq(int freq, SAMPLE *spl)
{
if (freq == 1000)
return spl->freq;
else
return (spl->freq * freq) / 1000;
}
void I_UpdateSoundParams( INT32 handle,
INT32 vol,
INT32 sep,
INT32 pitch)
{
// I fail too see that this is used.
// Would be using the handle to identify
// on which channel the sound might be active,
// and resetting the channel parameters.
int voice=handle & (VIRTUAL_VOICES-1);
int numsfx=handle>>VOICESSHIFT;
if (sound_disabled)
return;
if (voice_check(voice)==S_sfx[numsfx].data)
{
voice_set_volume(voice, vol);
voice_set_pan(voice, sep);
voice_set_frequency(voice, absolute_freq(pitch*1000/128,
S_sfx[numsfx].data));
}
}
void I_ShutdownSound(void)
{
// Wait till all pending sounds are finished.
//added:03-01-98:
if ( !sound_started )
return;
//added:08-01-98: remove_sound() explicitly because we don't use
// Allegro's allegro_exit();
remove_sound();
sound_started = false;
}
static char soundheader[] = "sound";
#if ALLEGRO_VERSION == 3
static char soundvar[] = "sb_freq";
#else
static char soundvar[] = "sound_freq";
#endif
void I_StartupSound(void)
{
int sfxcard,midicard;
#if ALLEGRO_VERSION == 3
char err[255];
#endif
if (sound_disabled)
sfxcard=DIGI_NONE;
else
sfxcard=DIGI_AUTODETECT;
if (midi_disabled)
midicard=MIDI_NONE;
else
midicard=MIDI_AUTODETECT; //DetectMusicCard();
digital_disabled=true; //Alam: No OGG/MP3/IT/MOD support
// Secure and configure sound device first.
CONS_Printf("I_StartupSound: ");
//Fab:25-04-98:note:install_sound will check for sound settings
// in the sound.cfg or allegro.cfg, in the current directory,
// or the directory pointed by 'ALLEGRO' env var.
#if ALLEGRO_VERSION == 3
if (install_sound(sfxcard,midicard,NULL)!=0)
{
sprintf (err,"Sound init error : %s\n",allegro_error);
CONS_Error (err);
sound_disabled=true;
midi_disabled=true;
}
else
{
CONS_Printf(" configured audio device\n" );
}
//added:08-01-98:we use a similar startup/shutdown scheme as Allegro.
I_AddExitFunc(I_ShutdownSound);
#endif
sound_started = true;
CV_SetValue(&cv_samplerate,get_config_int(soundheader,soundvar,cv_samplerate.value));
}
//
// MUSIC API.
// Still no music done.
// Remains. Dummies.
//
static MIDI* currsong; //im assuming only 1 song will be played at once
static int islooping=0;
static int musicdies=-1;
UINT8 music_started=0;
boolean songpaused=false;
/// ------------------------
// MUSIC SYSTEM
/// ------------------------
/* load_midi_mem:
* Loads a standard MIDI file from memory, returning a pointer to
* a MIDI structure, * or NULL on error.
* It is the load_midi from Allegro modified to load it from memory
*/
static MIDI *load_midi_mem(char *mempointer,int *e)
{
int c = *e;
long data=0;
unsigned char *fp;
MIDI *midi;
int num_tracks=0;
fp = (void *)mempointer;
if (!fp)
return NULL;
midi = malloc(sizeof (MIDI)); /* get some memory */
if (!midi)
return NULL;
for (c=0; c<MIDI_TRACKS; c++)
{
midi->track[c].data = NULL;
midi->track[c].len = 0;
}
fp+=4+4; // header size + 'chunk' size
swab(fp,&data,2); // convert to intel-endian
fp+=2; /* MIDI file type */
if ((data != 0) && (data != 1)) // only type 0 and 1 are suported
return NULL;
swab(fp,&num_tracks,2); /* number of tracks */
fp+=2;
if ((num_tracks < 1) || (num_tracks > MIDI_TRACKS))
return NULL;
swab(fp,&data,2); /* beat divisions */
fp+=2;
midi->divisions = ABS(data);
for (c=0; c<num_tracks; c++)
{ /* read each track */
if (memcmp(fp, "MTrk", 4))
return NULL;
fp+=4;
//swab(fp,&data,4); don't work !!!!??
((char *)&data)[0]=fp[3];
((char *)&data)[1]=fp[2];
((char *)&data)[2]=fp[1];
((char *)&data)[3]=fp[0];
fp+=4;
midi->track[c].len = data;
midi->track[c].data = fp;
fp+=data;
}
lock_midi(midi);
return midi;
}
void I_InitMusic(void)
{
if (midi_disabled)
return;
I_AddExitFunc(I_ShutdownMusic);
music_started = true;
songpaused = false;
}
void I_ShutdownMusic(void)
{
if ( !music_started )
return;
I_StopSong();
music_started=false;
}
/// ------------------------
// MUSIC PROPERTIES
/// ------------------------
musictype_t I_SongType(void)
{
if (currsong)
return MU_MID;
else
return MU_NONE;
}
boolean I_SongPlaying()
{
return (boolean)currsong;
}
boolean I_SongPaused()
{
return songpaused;
}
/// ------------------------
// MUSIC EFFECTS
/// ------------------------
boolean I_SetSongSpeed(float speed)
{
(void)speed;
return false;
}
/// ------------------------
// MUSIC SEEKING
/// ------------------------
UINT32 I_GetSongLength(void)
{
return 0;
}
boolean I_SetSongLoopPoint(UINT32 looppoint)
{
(void)looppoint;
return false;
}
UINT32 I_GetSongLoopPoint(void)
{
return 0;
}
boolean I_SetSongPosition(UINT32 position)
{
(void)position;
return false;
}
UINT32 I_GetSongPosition(void)
{
return 0;
}
/// ------------------------
// MUSIC PLAYBACK
/// ------------------------
boolean I_LoadSong(char *data, size_t len)
{
int e = len; //Alam: For error
if (midi_disabled)
return 0;
if (memcmp(data,"MThd",4)==0) // support mid file in WAD !!!
{
currsong=load_midi_mem(data,&e);
}
else
{
CONS_Printf("Music Lump is not a MIDI lump\n");
return 0;
}
if (currsong==NULL)
{
CONS_Printf("Not a valid mid file : %d\n",e);
return 0;
}
return 1;
}
void I_UnloadSong(void)
{
handle = 0;
if (midi_disabled)
return;
//destroy_midi(currsong);
}
boolean I_PlaySong(boolean looping)
{
handle = 0;
if (midi_disabled)
return false;
islooping = looping;
musicdies = gametic + NEWTICRATE*30;
if (play_midi(currsong,looping)==0)
return true;
return false;
}
void I_StopSong(void)
{
handle = 0;
if (midi_disabled)
return;
islooping = 0;
musicdies = 0;
stop_midi();
songpaused = false;
}
void I_PauseSong (INT32 handle)
{
handle = 0;
if (midi_disabled)
return;
midi_pause();
songpaused = true;
}
void I_ResumeSong (INT32 handle)
{
handle = 0;
if (midi_disabled)
return;
midi_resume();
songpaused = false;
}
void I_SetMusicVolume(INT32 volume)
{
if (midi_disabled)
return;
// Now set volume on output device.
set_volume (-1, Volset(volume));
}
boolean I_SetSongTrack(INT32 track)
{
(void)track;
return false;
}
// Is the song playing?
#if 0
int I_QrySongPlaying(int handle)
{
if (midi_disabled)
return 0;
//return islooping || musicdies > gametic;
return (midi_pos==-1);
}
#endif
/// ------------------------
// MUSIC FADING
/// ------------------------
void I_SetInternalMusicVolume(UINT8 volume)
{
(void)volume;
}
void I_StopFadingSong(void)
{
}
boolean I_FadeSongFromVolume(UINT8 target_volume, UINT8 source_volume, UINT32 ms, void (*callback)(void));
{
(void)target_volume;
(void)source_volume;
(void)ms;
return false;
}
boolean I_FadeSong(UINT8 target_volume, UINT32 ms, void (*callback)(void));
{
(void)target_volume;
(void)ms;
return false;
}
boolean I_FadeOutStopSong(UINT32 ms)
{
(void)ms;
return false;
}
boolean I_FadeInPlaySong(UINT32 ms, boolean looping)
{
(void)ms;
(void)looping;
return false;
}
File diff suppressed because it is too large. Load diff
-336
View File
@@ -1,336 +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 hardware and software level, screen and video i/o, refresh,
/// setup ... a big mess. Got to clean that up!
#include <stdlib.h>
#include <unistd.h>
#include <stdarg.h>
#include <sys/time.h>
#include <sys/types.h>
//#include <sys/socket.h>
#include <netinet/in.h>
//#include <errnos.h>
#include <signal.h>
#include <go32.h>
#include <pc.h>
#include <dpmi.h>
#include <dos.h>
#include <sys/nearptr.h>
#include "../doomdef.h"
#include "../i_system.h"
#include "../v_video.h"
#include "../m_argv.h"
#include "vid_vesa.h"
#include "../i_video.h"
//dosstuff -newly added
static unsigned long dascreen;
static int gfx_use_vesa1;
boolean highcolor;
#define SCREENDEPTH 1 // bytes per pixel, do NOT change.
rendermode_t rendermode=render_soft;
//
// I_OsPolling
//
void I_OsPolling(void)
{
I_GetEvent();
//i dont think i have to do anything else here
}
//
// I_UpdateNoBlit
//
void I_UpdateNoBlit (void)
{
// what is this?
}
//profile stuff ---------------------------------------------------------
//added:16-01-98:wanted to profile the VID_BlitLinearScreen() asm code.
//#define TIMING //uncomment this to enable profiling
#ifdef TIMING
#include "../p5prof.h"
static INT64 mycount;
static INT64 mytotal = 0;
static unsigned long nombre = NEWTICRATE*10;
//static char runtest[10][80];
#endif
//profile stuff ---------------------------------------------------------
//
// I_FinishUpdate
//
static void I_BlitScreenVesa1(void); //see later
void I_FinishUpdate (void)
{
// draw FPS if enabled
if (cv_ticrate.value)
SCR_DisplayTicRate();
if (cv_showping.value && netgame && consoleplayer != serverplayer)
SCR_DisplayLocalPing();
//blast it to the screen
// this code sucks
//memcpy(dascreen,screens[0],screenwidth*screenheight);
//added:03-01-98: I tried to I_WaitVBL(1) here, but it slows down
// the game when the view becomes complicated, it looses ticks
if (cv_vidwait.value)
I_WaitVBL(1);
//added:16-01-98:profile screen blit.
#ifdef TIMING
ProfZeroTimer();
#endif
//added:08-01-98: support vesa1 bank change, without Allegro's BITMAP screen.
if ( gfx_use_vesa1 )
{
I_Error("Banked screen update not finished for dynamic res\n");
I_BlitScreenVesa1(); //blast virtual to physical screen.
}
else
{
//added:16-01-98:use quickie asm routine, last 2 args are
// src and dest rowbytes
// (memcpy is as fast as this one...)
VID_BlitLinearScreen(screens[0], vid.direct,
vid.width*vid.bpp, vid.height,
vid.width*vid.bpp, vid.rowbytes );
}
#ifdef TIMING
RDMSR(0x10,&mycount);
mytotal += mycount; //64bit add
if (nombre--==0)
I_Error("ScreenBlit CPU Spy reports: 0x%d %d\n", *((int *)&mytotal+1),
(int)mytotal );
#endif
}
//
// I_UpdateNoVsync
//
void I_UpdateNoVsync(void)
{
int real_vidwait = cv_vidwait.value;
cv_vidwait.value = 0;
I_FinishUpdate();
cv_vidwait.value = real_vidwait;
}
//
// I_ReadScreen
//
void I_ReadScreen (UINT8 *scr)
{
VID_BlitLinearScreen(screens[0], scr,
vid.width*vid.bpp, vid.height,
vid.width*vid.bpp, vid.rowbytes );
}
void I_SetPalette (RGBA_t *palette)
{
int i;
outportb(0x3c8,0);
for (i=0;i<256;i++,palette++)
{
outportb(0x3c9,palette->s.red>>2);
outportb(0x3c9,palette->s.green>>2);
outportb(0x3c9,palette->s.blue>>2);
}
}
//added 29-12-1997
/*==========================================================================*/
// I_BlastScreen : copy the virtual screen buffer to the physical screen mem
// using bank switching if needed.
/*==========================================================================*/
static void I_BlitScreenVesa1(void)
{
#define VIDBANKSIZE (1<<16)
#define VIDBANKSIZEMASK (VIDBANKSIZE-1) // defines ahoy!
__dpmi_regs r;
UINT8 *p_src;
long i;
long virtualsize;
// virtual screen buffer size
virtualsize = vid.rowbytes * vid.height * SCREENDEPTH;
p_src = screens[0];
for (i=0; virtualsize > 0; i++ )
{
r.x.ax = 0x4f05;
r.x.bx = 0x0;
r.x.cx = 0x0;
r.x.dx = i;
__dpmi_int(0x10,&r); //set bank
M_Memcpy((UINT8 *)dascreen,p_src,(virtualsize < VIDBANKSIZE) ? virtualsize : VIDBANKSIZE );
p_src += VIDBANKSIZE;
virtualsize -= VIDBANKSIZE;
}
}
//added:08-01-98: now we use Allegro's set_gfx_mode, but we want to
// restore the exact text mode that was before.
static INT16 myOldVideoMode;
static inline void I_SaveOldVideoMode(void)
{
__dpmi_regs r;
r.x.ax = 0x4f03; // Return current video mode
__dpmi_int(0x10,&r);
if ( r.x.ax != 0x4f )
myOldVideoMode = -1;
else
myOldVideoMode = r.x.bx;
}
//
// Close the screen, restore previous video mode.
//
void I_ShutdownGraphics (void)
{
__dpmi_regs r;
rendermode = render_none;
if ( !graphics_started )
return;
// free the last video mode screen buffers
if (vid.buffer)
free (vid.buffer);
/* Restore old video mode */
if (myOldVideoMode!=-1)
{
/* Restore old video mode */
r.x.ax = 0x4f02; // Set Super VGA video mode
r.x.bx = myOldVideoMode;
__dpmi_int(0x10,&r);
// Boris: my s3 don't do a cls because "win95" :<
clrscr();
}
else // no vesa put the normal video mode
{
r.x.ax = 0x03;
__dpmi_int(0x10,&r);
}
graphics_started = false;
}
//added:08-01-98:
// Set VESA1 video mode, coz Allegro set_gfx_mode a larger screenwidth...
//
#if 0
int set_vesa1_mode( int width, int height )
{
__dpmi_regs r;
// setup video mode.
r.x.ax = 0x4f02;
if ( ( width==320 )&&( height==200 ) && ( SCREENDEPTH==1 ) )
r.x.bx = 0x13; // 320x 200x1 (256 colors)
else
if ( ( width==320 )&&( height==240 ) && ( SCREENDEPTH==1 ) )
r.x.bx = 0x154; // 320x 240x1 (256 colors)
else
if ( ( width==320 )&&( height==400 ) && ( SCREENDEPTH==1 ) )
r.x.bx = 0x155; // 320x 400x1 (256 colors)
else
if ( ( width==640 )&&( height==400 ) && ( SCREENDEPTH==1 ) )
r.x.bx = 0x100; // 640x 400x1 (256 colors)
else
if ( ( width==640 )&&( height==480 ) && ( SCREENDEPTH==1 ) )
r.x.bx = 0x101; // 640x 480x1 (256 colors)
else
if ( ( width==800 )&&( height==600 ) && ( SCREENDEPTH==1 ) )
r.x.bx = 0x103; // 800x 600x1 (256 colors)
else
if ( ( width==1024)&&( height==768 ) && ( SCREENDEPTH==1 ) )
r.x.bx = 0x105; //1024x 768x1 (256 colors)
else
I_Error("I_SetVesa1Mode: video mode not supported.");
// enter graphics mode.
__dpmi_int(0x10,&r);
if ( r.x.ax != 0x4f )
I_Error("I_SetVesa1Mode: init video mode failed !");
return 0;
}
#endif
//added:08-01-98: now uses Allegro to setup Linear Frame Buffer video modes.
//
// Initialize video mode, setup dynamic screen size variables,
// and allocate screens.
//
void I_StartupGraphics(void)
{
//added:26-01-98: VID_Init() must be done only once,
// use VID_SetMode() to change vid mode while in the game.
if ( graphics_started )
return;
// remember the exact screen mode we were...
I_SaveOldVideoMode();
CONS_Printf("Vid_Init...");
// 0 for 256 color, else use highcolor modes
highcolor = M_CheckParm ("-highcolor");
VID_Init();
//gfx_use_vesa1 = false;
//added:03-01-98: register exit code for graphics
I_AddExitFunc(I_ShutdownGraphics);
graphics_started = true;
}
-773
View File
@@ -1,773 +0,0 @@
/* ______ ___ ___
* /\ _ \ /\_ \ /\_ \
* \ \ \L\ \\//\ \ \//\ \ __ __ _ __ ___
* \ \ __ \ \ \ \ \ \ \ /'__`\ /'_ `\/\`'__\/ __`\
* \ \ \/\ \ \_\ \_ \_\ \_/\ __//\ \L\ \ \ \//\ \L\ \
* \ \_\ \_\/\____\/\____\ \____\ \____ \ \_\\ \____/
* \/_/\/_/\/____/\/____/\/____/\/___L\ \/_/ \/___/
* /\____/
* \_/__/
*
* Some definitions for internal use by the library code.
* This should not be included by user programs.
*
* By Shawn Hargreaves.
*
* See readme.txt for copyright information.
*/
#ifndef INTERNAL_H
#define INTERNAL_H
#include "allegro.h"
/* ______ ___ ___
* /\ _ \ /\_ \ /\_ \
* \ \ \L\ \\//\ \ \//\ \ __ __ _ __ ___
* \ \ __ \ \ \ \ \ \ \ /'__`\ /'_ `\/\`'__\/ __`\
* \ \ \/\ \ \_\ \_ \_\ \_/\ __//\ \L\ \ \ \//\ \L\ \
* \ \_\ \_\/\____\/\____\ \____\ \____ \ \_\\ \____/
* \/_/\/_/\/____/\/____/\/____/\/___L\ \/_/ \/___/
* /\____/
* \_/__/
*
* Some definitions for internal use by the library code.
* This should not be included by user programs.
*
* By Shawn Hargreaves.
*
* See readme.txt for copyright information.
*/
#ifndef INTERNDJ_H
#define INTERNDJ_H
#ifndef DJGPP
#error This file should only be used by the djgpp version of Allegro
#endif
#include <dos.h>
/* file access macros */
#define FILE_OPEN(filename, handle) handle = open(filename, O_RDONLY | O_BINARY, S_IRUSR | S_IWUSR)
#define FILE_CREATE(filename, handle) handle = open(filename, O_WRONLY | O_BINARY | O_CREAT | O_TRUNC, S_IRUSR | S_IWUSR)
#define FILE_CLOSE(handle) close(handle)
#define FILE_READ(handle, buf, size, sz) sz = read(handle, buf, size)
#define FILE_WRITE(handle, buf, size, sz) sz = write(handle, buf, size)
#define FILE_SEARCH_STRUCT struct ffblk
#define FILE_FINDFIRST(filename, attrib, dta) findfirst(filename, dta, attrib)
#define FILE_FINDNEXT(dta) findnext(dta)
#define FILE_ATTRIB ff_attrib
#define FILE_SIZE ff_fsize
#define FILE_NAME ff_name
#define FILE_TIME ff_ftime
#define FILE_DATE ff_fdate
/* macros to enable and disable interrupts */
#define DISABLE() asm volatile ("cli")
#define ENABLE() asm volatile ("sti")
__INLINE__ void enter_critical(void)
{
if (windows_version >= 3) {
__dpmi_regs r;
r.x.ax = 0x1681;
__dpmi_int(0x2F, &r);
}
DISABLE();
}
__INLINE__ void exit_critical(void)
{
if (windows_version >= 3) {
__dpmi_regs r;
r.x.ax = 0x1682;
__dpmi_int(0x2F, &r);
}
ENABLE();
}
/* interrupt hander stuff */
#define _map_irq(irq) (((irq)>7) ? ((irq)+104) : ((irq)+8))
int _install_irq(int num, int (*handler)(void));
void _remove_irq(int num);
void _restore_irq(int irq);
void _enable_irq(int irq);
void _disable_irq(int irq);
#define _eoi(irq) { outportb(0x20, 0x20); if ((irq)>7) outportb(0xA0, 0x20); }
typedef struct _IRQ_HANDLER
{
int (*handler)(void); /* our C handler */
int number; /* irq number */
__dpmi_paddr old_vector; /* original protected mode vector */
} _IRQ_HANDLER;
/* DPMI memory mapping routines */
int _create_physical_mapping(unsigned long *linear, int *segment, unsigned long physaddr, int size);
void _remove_physical_mapping(unsigned long *linear, int *segment);
int _create_linear_mapping(unsigned long *linear, unsigned long physaddr, int size);
void _remove_linear_mapping(unsigned long *linear);
int _create_selector(int *segment, unsigned long linear, int size);
void _remove_selector(int *segment);
void _unlock_dpmi_data(void *addr, int size);
/* bank switching routines */
void _accel_bank_stub(void);
void _accel_bank_stub_end(void);
void _accel_bank_switch (void);
void _accel_bank_switch_end(void);
void _vesa_window_1(void);
void _vesa_window_1_end(void);
void _vesa_window_2(void);
void _vesa_window_2_end(void);
void _vesa_pm_window_1(void);
void _vesa_pm_window_1_end(void);
void _vesa_pm_window_2(void);
void _vesa_pm_window_2_end(void);
void _vesa_pm_es_window_1(void);
void _vesa_pm_es_window_1_end(void);
void _vesa_pm_es_window_2(void);
void _vesa_pm_es_window_2_end(void);
/* stuff for the VESA and VBE/AF drivers */
extern __dpmi_regs _dpmi_reg;
extern int _window_2_offset;
extern void (*_pm_vesa_switcher)(void);
extern void (*_pm_vesa_scroller)(void);
extern void (*_pm_vesa_pallete)(void);
extern int _mmio_segment;
extern void *_accel_driver;
extern int _accel_active;
extern void *_accel_set_bank;
extern void *_accel_idle;
void _fill_vbeaf_libc_exports(void *ptr);
void _fill_vbeaf_pmode_exports(void *ptr);
/* sound lib stuff */
extern int _fm_port;
extern int _mpu_port;
extern int _mpu_irq;
extern int _sb_freq;
extern int _sb_port;
extern int _sb_dma;
extern int _sb_irq;
int _sb_read_dsp_version(void);
int _sb_reset_dsp(int data);
void _sb_voice(int state);
int _sb_set_mixer(int digi_volume, int midi_volume);
void _mpu_poll(void);
int _dma_allocate_mem(int bytes, int *sel, unsigned long *phys);
void _dma_start(int channel, unsigned long addr, int size, int auto_init, int input);
void _dma_stop(int channel);
unsigned long _dma_todo(int channel);
void _dma_lock_mem(void);
#endif /* ifndef INTERNDJ_H */
/* flag for how many times we have been initialised */
extern int _allegro_count;
/* some Allegro functions need a block of scratch memory */
extern void *_scratch_mem;
extern int _scratch_mem_size;
__INLINE__ void _grow_scratch_mem(int size)
{
if (size > _scratch_mem_size) {
size = (size+1023) & 0xFFFFFC00;
_scratch_mem = realloc(_scratch_mem, size);
_scratch_mem_size = size;
}
}
/* list of functions to call at program cleanup */
void _add_exit_func(void (*func)(void));
void _remove_exit_func(void (*func)(void));
/* reads a translation file into memory */
void _load_config_text(void);
/* various bits of mouse stuff */
void _set_mouse_range(void);
extern BITMAP *_mouse_screen;
extern BITMAP *_mouse_sprite, *_mouse_pointer;
extern int _mouse_x_focus, _mouse_y_focus;
extern int _mouse_width, _mouse_height;
/* various bits of timer stuff */
extern int _timer_use_retrace;
extern volatile int _retrace_hpp_value;
/* caches and tables for svga bank switching */
extern int _last_bank_1, _last_bank_2;
extern int *_gfx_bank;
/* bank switching routines */
void _stub_bank_switch (void);
void _stub_bank_switch_end(void);
/* stuff for setting up bitmaps */
void _check_gfx_virginity(void);
BITMAP *_make_bitmap(int w, int h, unsigned long addr, GFX_DRIVER *driver, int color_depth, int bpl);
void _sort_out_virtual_width(int *width, GFX_DRIVER *driver);
GFX_VTABLE *_get_vtable(int color_depth);
extern GFX_VTABLE _screen_vtable;
extern int _sub_bitmap_id_count;
extern int _textmode;
#define BYTES_PER_PIXEL(bpp) (((int)(bpp) + 7) / 8)
int _color_load_depth(int depth);
extern int _color_conv;
BITMAP *_fixup_loaded_bitmap(BITMAP *bmp, PALETTE pal, int bpp);
/* VGA register access routines */
void _vga_vsync(void);
void _vga_set_pallete_range(PALLETE p, int from, int to, int vsync);
extern int _crtc;
/* _read_vga_register:
* Reads the contents of a VGA register.
*/
__INLINE__ int _read_vga_register(int port, int index)
{
if (port==0x3C0)
inportb(_crtc+6);
outportb(port, index);
return inportb(port+1);
}
/* _write_vga_register:
* Writes a byte to a VGA register.
*/
__INLINE__ void _write_vga_register(int port, int index, int v)
{
if (port==0x3C0) {
inportb(_crtc+6);
outportb(port, index);
outportb(port, v);
}
else {
outportb(port, index);
outportb(port+1, v);
}
}
/* _alter_vga_register:
* Alters specific bits of a VGA register.
*/
__INLINE__ void _alter_vga_register(int port, int index, int mask, int v)
{
int temp;
temp = _read_vga_register(port, index);
temp &= (~mask);
temp |= (v & mask);
_write_vga_register(port, index, temp);
}
/* _vsync_out_h:
* Waits until the VGA is not in either a vertical or horizontal retrace.
*/
__INLINE__ void _vsync_out_h(void)
{
do {
} while (inportb(0x3DA) & 1);
}
/* _vsync_out_v:
* Waits until the VGA is not in a vertical retrace.
*/
__INLINE__ void _vsync_out_v(void)
{
do {
} while (inportb(0x3DA) & 8);
}
/* _vsync_in:
* Waits until the VGA is in the vertical retrace period.
*/
__INLINE__ void _vsync_in(void)
{
if (_timer_use_retrace) {
int t = retrace_count;
do {
} while (t == retrace_count);
}
else {
do {
} while (!(inportb(0x3DA) & 8));
}
}
/* _write_hpp:
* Writes to the VGA pelpan register.
*/
__INLINE__ void _write_hpp(int value)
{
if (_timer_use_retrace) {
_retrace_hpp_value = value;
do {
} while (_retrace_hpp_value == value);
}
else {
do {
} while (!(inportb(0x3DA) & 8));
_write_vga_register(0x3C0, 0x33, value);
}
}
void _set_vga_virtual_width(int old_width, int new_width);
/* current drawing mode */
extern int _drawing_mode;
extern BITMAP *_drawing_pattern;
extern int _drawing_x_anchor;
extern int _drawing_y_anchor;
extern unsigned int _drawing_x_mask;
extern unsigned int _drawing_y_mask;
/* graphics drawing routines */
void _normal_line(BITMAP *bmp, int x1, int y1, int x2, int y2, int color);
void _normal_rectfill(BITMAP *bmp, int x1, int y1, int x2, int y2, int color);
int _linear_getpixel8(struct BITMAP *bmp, int x, int y);
void _linear_putpixel8(struct BITMAP *bmp, int x, int y, int color);
void _linear_vline8(struct BITMAP *bmp, int x, int y1, int y2, int color);
void _linear_hline8(struct BITMAP *bmp, int x1, int y, int x2, int color);
void _linear_draw_sprite8(struct BITMAP *bmp, struct BITMAP *sprite, int x, int y);
void _linear_draw_sprite_v_flip8(struct BITMAP *bmp, struct BITMAP *sprite, int x, int y);
void _linear_draw_sprite_h_flip8(struct BITMAP *bmp, struct BITMAP *sprite, int x, int y);
void _linear_draw_sprite_vh_flip8(struct BITMAP *bmp, struct BITMAP *sprite, int x, int y);
void _linear_draw_trans_sprite8(struct BITMAP *bmp, struct BITMAP *sprite, int x, int y);
void _linear_draw_lit_sprite8(struct BITMAP *bmp, struct BITMAP *sprite, int x, int y, int color);
void _linear_draw_rle_sprite8(struct BITMAP *bmp, struct RLE_SPRITE *sprite, int x, int y);
void _linear_draw_trans_rle_sprite8(struct BITMAP *bmp, struct RLE_SPRITE *sprite, int x, int y);
void _linear_draw_lit_rle_sprite8(struct BITMAP *bmp, struct RLE_SPRITE *sprite, int x, int y, int color);
void _linear_draw_character8(struct BITMAP *bmp, struct BITMAP *sprite, int x, int y, int color);
void _linear_textout_fixed8(struct BITMAP *bmp, void *f, int h, unsigned char *str, int x, int y, int color);
void _linear_blit8(struct BITMAP *source, struct BITMAP *dest, int source_x, int source_y, int dest_x, int dest_y, int width, int height);
void _linear_blit_backward8(struct BITMAP *source, struct BITMAP *dest, int source_x, int source_y, int dest_x, int dest_y, int width, int height);
void _linear_masked_blit8(struct BITMAP *source, struct BITMAP *dest, int source_x, int source_y, int dest_x, int dest_y, int width, int height);
void _linear_clear_to_color8(struct BITMAP *bitmap, int color);
#ifdef ALLEGRO_COLOR16
void _linear_putpixel15(struct BITMAP *bmp, int x, int y, int color);
void _linear_vline15(struct BITMAP *bmp, int x, int y1, int y2, int color);
void _linear_hline15(struct BITMAP *bmp, int x1, int y, int x2, int color);
void _linear_draw_trans_sprite15(struct BITMAP *bmp, struct BITMAP *sprite, int x, int y);
void _linear_draw_lit_sprite15(struct BITMAP *bmp, struct BITMAP *sprite, int x, int y, int color);
void _linear_draw_rle_sprite15(struct BITMAP *bmp, struct RLE_SPRITE *sprite, int x, int y);
void _linear_draw_trans_rle_sprite15(struct BITMAP *bmp, struct RLE_SPRITE *sprite, int x, int y);
void _linear_draw_lit_rle_sprite15(struct BITMAP *bmp, struct RLE_SPRITE *sprite, int x, int y, int color);
int _linear_getpixel16(struct BITMAP *bmp, int x, int y);
void _linear_putpixel16(struct BITMAP *bmp, int x, int y, int color);
void _linear_vline16(struct BITMAP *bmp, int x, int y1, int y2, int color);
void _linear_hline16(struct BITMAP *bmp, int x1, int y, int x2, int color);
void _linear_draw_sprite16(struct BITMAP *bmp, struct BITMAP *sprite, int x, int y);
void _linear_draw_256_sprite16(struct BITMAP *bmp, struct BITMAP *sprite, int x, int y);
void _linear_draw_sprite_v_flip16(struct BITMAP *bmp, struct BITMAP *sprite, int x, int y);
void _linear_draw_sprite_h_flip16(struct BITMAP *bmp, struct BITMAP *sprite, int x, int y);
void _linear_draw_sprite_vh_flip16(struct BITMAP *bmp, struct BITMAP *sprite, int x, int y);
void _linear_draw_trans_sprite16(struct BITMAP *bmp, struct BITMAP *sprite, int x, int y);
void _linear_draw_lit_sprite16(struct BITMAP *bmp, struct BITMAP *sprite, int x, int y, int color);
void _linear_draw_rle_sprite16(struct BITMAP *bmp, struct RLE_SPRITE *sprite, int x, int y);
void _linear_draw_trans_rle_sprite16(struct BITMAP *bmp, struct RLE_SPRITE *sprite, int x, int y);
void _linear_draw_lit_rle_sprite16(struct BITMAP *bmp, struct RLE_SPRITE *sprite, int x, int y, int color);
void _linear_draw_character16(struct BITMAP *bmp, struct BITMAP *sprite, int x, int y, int color);
void _linear_textout_fixed16(struct BITMAP *bmp, void *f, int h, unsigned char *str, int x, int y, int color);
void _linear_blit16(struct BITMAP *source, struct BITMAP *dest, int source_x, int source_y, int dest_x, int dest_y, int width, int height);
void _linear_blit_backward16(struct BITMAP *source, struct BITMAP *dest, int source_x, int source_y, int dest_x, int dest_y, int width, int height);
void _linear_masked_blit16(struct BITMAP *source, struct BITMAP *dest, int source_x, int source_y, int dest_x, int dest_y, int width, int height);
void _linear_clear_to_color16(struct BITMAP *bitmap, int color);
#endif
#ifdef ALLEGRO_COLOR24
int _linear_getpixel24(struct BITMAP *bmp, int x, int y);
void _linear_putpixel24(struct BITMAP *bmp, int x, int y, int color);
void _linear_vline24(struct BITMAP *bmp, int x, int y1, int y2, int color);
void _linear_hline24(struct BITMAP *bmp, int x1, int y, int x2, int color);
void _linear_draw_sprite24(struct BITMAP *bmp, struct BITMAP *sprite, int x, int y);
void _linear_draw_256_sprite24(struct BITMAP *bmp, struct BITMAP *sprite, int x, int y);
void _linear_draw_sprite_v_flip24(struct BITMAP *bmp, struct BITMAP *sprite, int x, int y);
void _linear_draw_sprite_h_flip24(struct BITMAP *bmp, struct BITMAP *sprite, int x, int y);
void _linear_draw_sprite_vh_flip24(struct BITMAP *bmp, struct BITMAP *sprite, int x, int y);
void _linear_draw_trans_sprite24(struct BITMAP *bmp, struct BITMAP *sprite, int x, int y);
void _linear_draw_lit_sprite24(struct BITMAP *bmp, struct BITMAP *sprite, int x, int y, int color);
void _linear_draw_rle_sprite24(struct BITMAP *bmp, struct RLE_SPRITE *sprite, int x, int y);
void _linear_draw_trans_rle_sprite24(struct BITMAP *bmp, struct RLE_SPRITE *sprite, int x, int y);
void _linear_draw_lit_rle_sprite24(struct BITMAP *bmp, struct RLE_SPRITE *sprite, int x, int y, int color);
void _linear_draw_character24(struct BITMAP *bmp, struct BITMAP *sprite, int x, int y, int color);
void _linear_textout_fixed24(struct BITMAP *bmp, void *f, int h, unsigned char *str, int x, int y, int color);
void _linear_blit24(struct BITMAP *source, struct BITMAP *dest, int source_x, int source_y, int dest_x, int dest_y, int width, int height);
void _linear_blit_backward24(struct BITMAP *source, struct BITMAP *dest, int source_x, int source_y, int dest_x, int dest_y, int width, int height);
void _linear_masked_blit24(struct BITMAP *source, struct BITMAP *dest, int source_x, int source_y, int dest_x, int dest_y, int width, int height);
void _linear_clear_to_color24(struct BITMAP *bitmap, int color);
#endif
#ifdef ALLEGRO_COLOR32
int _linear_getpixel32(struct BITMAP *bmp, int x, int y);
void _linear_putpixel32(struct BITMAP *bmp, int x, int y, int color);
void _linear_vline32(struct BITMAP *bmp, int x, int y1, int y2, int color);
void _linear_hline32(struct BITMAP *bmp, int x1, int y, int x2, int color);
void _linear_draw_sprite32(struct BITMAP *bmp, struct BITMAP *sprite, int x, int y);
void _linear_draw_256_sprite32(struct BITMAP *bmp, struct BITMAP *sprite, int x, int y);
void _linear_draw_sprite_v_flip32(struct BITMAP *bmp, struct BITMAP *sprite, int x, int y);
void _linear_draw_sprite_h_flip32(struct BITMAP *bmp, struct BITMAP *sprite, int x, int y);
void _linear_draw_sprite_vh_flip32(struct BITMAP *bmp, struct BITMAP *sprite, int x, int y);
void _linear_draw_trans_sprite32(struct BITMAP *bmp, struct BITMAP *sprite, int x, int y);
void _linear_draw_lit_sprite32(struct BITMAP *bmp, struct BITMAP *sprite, int x, int y, int color);
void _linear_draw_rle_sprite32(struct BITMAP *bmp, struct RLE_SPRITE *sprite, int x, int y);
void _linear_draw_trans_rle_sprite32(struct BITMAP *bmp, struct RLE_SPRITE *sprite, int x, int y);
void _linear_draw_lit_rle_sprite32(struct BITMAP *bmp, struct RLE_SPRITE *sprite, int x, int y, int color);
void _linear_draw_character32(struct BITMAP *bmp, struct BITMAP *sprite, int x, int y, int color);
void _linear_textout_fixed32(struct BITMAP *bmp, void *f, int h, unsigned char *str, int x, int y, int color);
void _linear_blit32(struct BITMAP *source, struct BITMAP *dest, int source_x, int source_y, int dest_x, int dest_y, int width, int height);
void _linear_blit_backward32(struct BITMAP *source, struct BITMAP *dest, int source_x, int source_y, int dest_x, int dest_y, int width, int height);
void _linear_masked_blit32(struct BITMAP *source, struct BITMAP *dest, int source_x, int source_y, int dest_x, int dest_y, int width, int height);
void _linear_clear_to_color32(struct BITMAP *bitmap, int color);
#endif
int _x_getpixel(struct BITMAP *bmp, int x, int y);
void _x_putpixel(struct BITMAP *bmp, int x, int y, int color);
void _x_vline(struct BITMAP *bmp, int x, int y1, int y2, int color);
void _x_hline(struct BITMAP *bmp, int x1, int y, int x2, int color);
void _x_draw_sprite(struct BITMAP *bmp, struct BITMAP *sprite, int x, int y);
void _x_draw_sprite_v_flip(struct BITMAP *bmp, struct BITMAP *sprite, int x, int y);
void _x_draw_sprite_h_flip(struct BITMAP *bmp, struct BITMAP *sprite, int x, int y);
void _x_draw_sprite_vh_flip(struct BITMAP *bmp, struct BITMAP *sprite, int x, int y);
void _x_draw_trans_sprite(struct BITMAP *bmp, struct BITMAP *sprite, int x, int y);
void _x_draw_lit_sprite(struct BITMAP *bmp, struct BITMAP *sprite, int x, int y, int color);
void _x_draw_rle_sprite(struct BITMAP *bmp, struct RLE_SPRITE *sprite, int x, int y);
void _x_draw_trans_rle_sprite(struct BITMAP *bmp, struct RLE_SPRITE *sprite, int x, int y);
void _x_draw_lit_rle_sprite(struct BITMAP *bmp, struct RLE_SPRITE *sprite, int x, int y, int color);
void _x_draw_character(struct BITMAP *bmp, struct BITMAP *sprite, int x, int y, int color);
void _x_textout_fixed(struct BITMAP *bmp, void *f, int h, unsigned char *str, int x, int y, int color);
void _x_blit_from_memory(struct BITMAP *source, struct BITMAP *dest, int source_x, int source_y, int dest_x, int dest_y, int width, int height);
void _x_blit_to_memory(struct BITMAP *source, struct BITMAP *dest, int source_x, int source_y, int dest_x, int dest_y, int width, int height);
void _x_blit(struct BITMAP *source, struct BITMAP *dest, int source_x, int source_y, int dest_x, int dest_y, int width, int height);
void _x_blit_forward(struct BITMAP *source, struct BITMAP *dest, int source_x, int source_y, int dest_x, int dest_y, int width, int height);
void _x_blit_backward(struct BITMAP *source, struct BITMAP *dest, int source_x, int source_y, int dest_x, int dest_y, int width, int height);
void _x_masked_blit(struct BITMAP *source, struct BITMAP *dest, int source_x, int source_y, int dest_x, int dest_y, int width, int height);
void _x_clear_to_color(struct BITMAP *bitmap, int color);
/* asm helper for stretch_blit() */
void _do_stretch(BITMAP *source, BITMAP *dest, void *drawer, int sx, fixed sy, fixed syd, int dx, int dy, int dh, int color_depth);
/* number of fractional bits used by the polygon rasteriser */
#define POLYGON_FIX_SHIFT 18
/* bitfield specifying which polygon attributes need interpolating */
#define INTERP_FLAT 1
#define INTERP_1COL 2
#define INTERP_3COL 4
#define INTERP_FIX_UV 8
#define INTERP_Z 16
#define INTERP_FLOAT_UV 32
#define OPT_FLOAT_UV_TO_FIX 64
#define COLOR_TO_RGB 128
/* information for polygon scanline fillers */
typedef struct POLYGON_SEGMENT
{
fixed u, v, du, dv; /* fixed point u/v coordinates */
fixed c, dc; /* single color gouraud shade values */
fixed r, g, b, dr, dg, db; /* RGB gouraud shade values */
float z, dz; /* polygon depth (1/z) */
float fu, fv, dfu, dfv; /* floating point u/v coordinates */
unsigned char *texture; /* the texture map */
int umask, vmask, vshift; /* texture map size information */
int seg; /* destination bitmap selector */
} POLYGON_SEGMENT;
/* an active polygon edge */
typedef struct POLYGON_EDGE
{
int top; /* top y position */
int bottom; /* bottom y position */
fixed x, dx; /* fixed point x position and gradient */
fixed w; /* width of line segment */
POLYGON_SEGMENT dat; /* texture/gouraud information */
struct POLYGON_EDGE *prev; /* doubly linked list */
struct POLYGON_EDGE *next;
} POLYGON_EDGE;
/* prototype for the scanline filler functions */
typedef void (*SCANLINE_FILLER)(unsigned long addr, int w, POLYGON_SEGMENT *info);
/* polygon helper functions */
extern SCANLINE_FILLER _optim_alternative_drawer;
POLYGON_EDGE *_add_edge(POLYGON_EDGE *list, POLYGON_EDGE *edge, int sort_by_x);
POLYGON_EDGE *_remove_edge(POLYGON_EDGE *list, POLYGON_EDGE *edge);
void _fill_3d_edge_structure(POLYGON_EDGE *edge, V3D *v1, V3D *v2, int flags, BITMAP *bmp);
void _fill_3d_edge_structure_f(POLYGON_EDGE *edge, V3D_f *v1, V3D_f *v2, int flags, BITMAP *bmp);
SCANLINE_FILLER _get_scanline_filler(int type, int *flags, POLYGON_SEGMENT *info, BITMAP *texture, BITMAP *bmp);
void _clip_polygon_segment(POLYGON_SEGMENT *info, int gap, int flags);
/* polygon scanline filler functions */
void _poly_scanline_gcol8(unsigned long addr, int w, POLYGON_SEGMENT *info);
void _poly_scanline_grgb8(unsigned long addr, int w, POLYGON_SEGMENT *info);
void _poly_scanline_atex8(unsigned long addr, int w, POLYGON_SEGMENT *info);
void _poly_scanline_ptex8(unsigned long addr, int w, POLYGON_SEGMENT *info);
void _poly_scanline_atex_mask8(unsigned long addr, int w, POLYGON_SEGMENT *info);
void _poly_scanline_ptex_mask8(unsigned long addr, int w, POLYGON_SEGMENT *info);
void _poly_scanline_atex_lit8(unsigned long addr, int w, POLYGON_SEGMENT *info);
void _poly_scanline_ptex_lit8(unsigned long addr, int w, POLYGON_SEGMENT *info);
void _poly_scanline_atex_mask_lit8(unsigned long addr, int w, POLYGON_SEGMENT *info);
void _poly_scanline_ptex_mask_lit8(unsigned long addr, int w, POLYGON_SEGMENT *info);
void _poly_scanline_grgb8x(unsigned long addr, int w, POLYGON_SEGMENT *info);
void _poly_scanline_grgb15(unsigned long addr, int w, POLYGON_SEGMENT *info);
void _poly_scanline_atex_mask15(unsigned long addr, int w, POLYGON_SEGMENT *info);
void _poly_scanline_ptex_mask15(unsigned long addr, int w, POLYGON_SEGMENT *info);
void _poly_scanline_atex_lit15(unsigned long addr, int w, POLYGON_SEGMENT *info);
void _poly_scanline_ptex_lit15(unsigned long addr, int w, POLYGON_SEGMENT *info);
void _poly_scanline_atex_mask_lit15(unsigned long addr, int w, POLYGON_SEGMENT *info);
void _poly_scanline_ptex_mask_lit15(unsigned long addr, int w, POLYGON_SEGMENT *info);
void _poly_scanline_grgb15x(unsigned long addr, int w, POLYGON_SEGMENT *info);
void _poly_scanline_atex_lit15x(unsigned long addr, int w, POLYGON_SEGMENT *info);
void _poly_scanline_ptex_lit15x(unsigned long addr, int w, POLYGON_SEGMENT *info);
void _poly_scanline_atex_mask_lit15x(unsigned long addr, int w, POLYGON_SEGMENT *info);
void _poly_scanline_ptex_mask_lit15x(unsigned long addr, int w, POLYGON_SEGMENT *info);
void _poly_scanline_ptex_lit15d(unsigned long addr, int w, POLYGON_SEGMENT *info);
void _poly_scanline_ptex_mask_lit15d(unsigned long addr, int w, POLYGON_SEGMENT *info);
void _poly_scanline_grgb16(unsigned long addr, int w, POLYGON_SEGMENT *info);
void _poly_scanline_atex16(unsigned long addr, int w, POLYGON_SEGMENT *info);
void _poly_scanline_ptex16(unsigned long addr, int w, POLYGON_SEGMENT *info);
void _poly_scanline_atex_mask16(unsigned long addr, int w, POLYGON_SEGMENT *info);
void _poly_scanline_ptex_mask16(unsigned long addr, int w, POLYGON_SEGMENT *info);
void _poly_scanline_atex_lit16(unsigned long addr, int w, POLYGON_SEGMENT *info);
void _poly_scanline_ptex_lit16(unsigned long addr, int w, POLYGON_SEGMENT *info);
void _poly_scanline_atex_mask_lit16(unsigned long addr, int w, POLYGON_SEGMENT *info);
void _poly_scanline_ptex_mask_lit16(unsigned long addr, int w, POLYGON_SEGMENT *info);
void _poly_scanline_grgb16x(unsigned long addr, int w, POLYGON_SEGMENT *info);
void _poly_scanline_atex_lit16x(unsigned long addr, int w, POLYGON_SEGMENT *info);
void _poly_scanline_ptex_lit16x(unsigned long addr, int w, POLYGON_SEGMENT *info);
void _poly_scanline_atex_mask_lit16x(unsigned long addr, int w, POLYGON_SEGMENT *info);
void _poly_scanline_ptex_mask_lit16x(unsigned long addr, int w, POLYGON_SEGMENT *info);
void _poly_scanline_ptex_lit16d(unsigned long addr, int w, POLYGON_SEGMENT *info);
void _poly_scanline_ptex_mask_lit16d(unsigned long addr, int w, POLYGON_SEGMENT *info);
void _poly_scanline_grgb24(unsigned long addr, int w, POLYGON_SEGMENT *info);
void _poly_scanline_atex24(unsigned long addr, int w, POLYGON_SEGMENT *info);
void _poly_scanline_ptex24(unsigned long addr, int w, POLYGON_SEGMENT *info);
void _poly_scanline_atex_mask24(unsigned long addr, int w, POLYGON_SEGMENT *info);
void _poly_scanline_ptex_mask24(unsigned long addr, int w, POLYGON_SEGMENT *info);
void _poly_scanline_atex_lit24(unsigned long addr, int w, POLYGON_SEGMENT *info);
void _poly_scanline_ptex_lit24(unsigned long addr, int w, POLYGON_SEGMENT *info);
void _poly_scanline_atex_mask_lit24(unsigned long addr, int w, POLYGON_SEGMENT *info);
void _poly_scanline_ptex_mask_lit24(unsigned long addr, int w, POLYGON_SEGMENT *info);
void _poly_scanline_grgb24x(unsigned long addr, int w, POLYGON_SEGMENT *info);
void _poly_scanline_atex_lit24x(unsigned long addr, int w, POLYGON_SEGMENT *info);
void _poly_scanline_ptex_lit24x(unsigned long addr, int w, POLYGON_SEGMENT *info);
void _poly_scanline_atex_mask_lit24x(unsigned long addr, int w, POLYGON_SEGMENT *info);
void _poly_scanline_ptex_mask_lit24x(unsigned long addr, int w, POLYGON_SEGMENT *info);
void _poly_scanline_ptex_lit24d(unsigned long addr, int w, POLYGON_SEGMENT *info);
void _poly_scanline_ptex_mask_lit24d(unsigned long addr, int w, POLYGON_SEGMENT *info);
void _poly_scanline_grgb32(unsigned long addr, int w, POLYGON_SEGMENT *info);
void _poly_scanline_atex32(unsigned long addr, int w, POLYGON_SEGMENT *info);
void _poly_scanline_ptex32(unsigned long addr, int w, POLYGON_SEGMENT *info);
void _poly_scanline_atex_mask32(unsigned long addr, int w, POLYGON_SEGMENT *info);
void _poly_scanline_ptex_mask32(unsigned long addr, int w, POLYGON_SEGMENT *info);
void _poly_scanline_atex_lit32(unsigned long addr, int w, POLYGON_SEGMENT *info);
void _poly_scanline_ptex_lit32(unsigned long addr, int w, POLYGON_SEGMENT *info);
void _poly_scanline_atex_mask_lit32(unsigned long addr, int w, POLYGON_SEGMENT *info);
void _poly_scanline_ptex_mask_lit32(unsigned long addr, int w, POLYGON_SEGMENT *info);
void _poly_scanline_grgb32x(unsigned long addr, int w, POLYGON_SEGMENT *info);
void _poly_scanline_atex_lit32x(unsigned long addr, int w, POLYGON_SEGMENT *info);
void _poly_scanline_ptex_lit32x(unsigned long addr, int w, POLYGON_SEGMENT *info);
void _poly_scanline_atex_mask_lit32x(unsigned long addr, int w, POLYGON_SEGMENT *info);
void _poly_scanline_ptex_mask_lit32x(unsigned long addr, int w, POLYGON_SEGMENT *info);
void _poly_scanline_ptex_lit32d(unsigned long addr, int w, POLYGON_SEGMENT *info);
void _poly_scanline_ptex_mask_lit32d(unsigned long addr, int w, POLYGON_SEGMENT *info);
/* sound lib stuff */
extern int _digi_volume;
extern int _midi_volume;
extern int _flip_pan;
extern int _sound_hq;
extern int (*_midi_init)(void);
extern void (*_midi_exit)(void);
int _midi_allocate_voice(int min, int max);
extern volatile long _midi_tick;
int _digmid_find_patches(char *dir, char *file);
#define VIRTUAL_VOICES 256
typedef struct /* a virtual (as seen by the user) soundcard voice */
{
SAMPLE *sample; /* which sample are we playing? (NULL = free) */
int num; /* physical voice number (-1 = been killed off) */
int autokill; /* set to free the voice when the sample finishes */
long time; /* when we were started (for voice allocation) */
int priority; /* how important are we? */
} VOICE;
extern VOICE _voice[VIRTUAL_VOICES];
typedef struct /* a physical (as used by hardware) soundcard voice */
{
int num; /* the virtual voice currently using me (-1 = free) */
int playmode; /* are we looping? */
int vol; /* current volume (fixed point .12) */
int dvol; /* volume delta, for ramping */
int target_vol; /* target volume, for ramping */
int pan; /* current pan (fixed point .12) */
int dpan; /* pan delta, for sweeps */
int target_pan; /* target pan, for sweeps */
int freq; /* current frequency (fixed point .12) */
int dfreq; /* frequency delta, for sweeps */
int target_freq; /* target frequency, for sweeps */
} PHYS_VOICE;
extern PHYS_VOICE _phys_voice[DIGI_VOICES];
#define MIXER_DEF_SFX 8
#define MIXER_MAX_SFX 64
int _mixer_init(int bufsize, int freq, int stereo, int is16bit, int *voices);
void _mixer_exit(void);
void _mix_some_samples(unsigned long buf, unsigned short seg, int issigned);
void _mixer_init_voice(int voice, SAMPLE *sample);
void _mixer_release_voice(int voice);
void _mixer_start_voice(int voice);
void _mixer_stop_voice(int voice);
void _mixer_loop_voice(int voice, int loopmode);
int _mixer_get_position(int voice);
void _mixer_set_position(int voice, int position);
int _mixer_get_volume(int voice);
void _mixer_set_volume(int voice, int volume);
void _mixer_ramp_volume(int voice, int time, int endvol);
void _mixer_stop_volume_ramp(int voice);
int _mixer_get_frequency(int voice);
void _mixer_set_frequency(int voice, int frequency);
void _mixer_sweep_frequency(int voice, int time, int endfreq);
void _mixer_stop_frequency_sweep(int voice);
int _mixer_get_pan(int voice);
void _mixer_set_pan(int voice, int pan);
void _mixer_sweep_pan(int voice, int time, int endpan);
void _mixer_stop_pan_sweep(int voice);
void _mixer_set_echo(int voice, int strength, int delay);
void _mixer_set_tremolo(int voice, int rate, int depth);
void _mixer_set_vibrato(int voice, int rate, int depth);
/* dummy functions for the NoSound drivers */
int _dummy_detect(int input);
int _dummy_init(int input, int voices);
void _dummy_exit(int input);
int _dummy_mixer_volume(int volume);
void _dummy_init_voice(int voice, SAMPLE *sample);
void _dummy_noop1(int p);
void _dummy_noop2(int p1, int p2);
void _dummy_noop3(int p1, int p2, int p3);
int _dummy_get_position(int voice);
int _dummy_get(int voice);
void _dummy_raw_midi(unsigned char data);
int _dummy_load_patches(char *patches, char *drums);
void _dummy_adjust_patches(char *patches, char *drums);
void _dummy_key_on(int inst, int note, int bend, int vol, int pan);
/* from djgpp's libc, needed to find which directory we were run from */
extern int __crt0_argc;
extern char **__crt0_argv;
#endif /* ifndef INTERNAL_H */
-22
View File
@@ -1,22 +0,0 @@
// Emacs style mode select -*- C++ -*-
//-----------------------------------------------------------------------------
//
// Copyright (C) 2005-2018 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 Set Com port and speed for GDBStubs for DJGGP
///
/// copy and rename as rdb.h and set the defines below as needed
#define DEBUG_COM_PORT 2
#define DEBUG_COM_PORT_SPEED 9600
-900
View File
@@ -1,900 +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 extended vesa VESA2.0 video modes i/o
#include <stdlib.h>
#include "../i_system.h" //I_Error()
#include "vid_vesa.h"
#include "../doomdef.h" //MAXVIDWIDTH, MAXVIDHEIGHT
#include "../screen.h"
#include <dpmi.h>
#include <go32.h>
#include <sys/farptr.h>
#include <sys/movedata.h>
#include <sys/segments.h>
#include <sys/nearptr.h>
#include "../console.h"
#include "../command.h" //added:21-03-98: vid_xxx commands
#include "../i_video.h"
// PROTOS
static vmode_t *VID_GetModePtr (int modenum);
static int VID_VesaGetModeInfo (int modenum);
static void VID_VesaGetExtraModes (void);
static INT32 VID_VesaInitMode (viddef_t *lvid, vmode_t *pcurrentmode);
static void VID_Command_NumModes_f (void);
static void VID_Command_ModeInfo_f (void);
static void VID_Command_ModeList_f (void);
static void VID_Command_Mode_f (void);
consvar_t cv_vidwait = {"vid_wait", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL};
static consvar_t cv_stretch = {"stretch", "On", CV_SAVE|CV_NOSHOWHELP, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL};
#define VBEVERSION 2 // we need vesa2 or higher
// -----------------------------------------------------
#define MASK_LINEAR(addr) (addr & 0x000FFFFF)
#define RM_TO_LINEAR(addr) (((addr & 0xFFFF0000) >> 12) + (addr & 0xFFFF))
#define RM_OFFSET(addr) (addr & 0xF)
#define RM_SEGMENT(addr) ((addr >> 4) & 0xFFFF)
// -----------------------------------------------------
static int totalvidmem;
static vmode_t vesa_modes[MAX_VESA_MODES] = {{NULL, NULL, 0, 0, 0, 0, 0, 0, NULL, NULL, 0}};
static vesa_extra_t vesa_extra[MAX_VESA_MODES];
//this is the only supported non-vesa mode : standard 320x200x256c.
#define NUMVGAVIDMODES 1
static INT32 VGA_InitMode (viddef_t *lvid, vmode_t *pcurrentmode);
static char vgamode1[] ="320x200";
static vmode_t vgavidmodes[NUMVGAVIDMODES] = {
{
NULL,
vgamode1,
320, 200, //(200.0/320.0)*(320.0/240.0),
320, 1, // rowbytes, bytes per pixel
0, 1,
NULL,
VGA_InitMode, 0
}
};
static char names[MAX_VESA_MODES][10];
//----------------------------i_video.c------------------------------------
// these ones should go to i_video.c, but I prefer keep them away from the
// doom sources until the vesa stuff is ok.
static int numvidmodes; //total number of video modes, vga, vesa1, vesa2.
static vmode_t *pvidmodes; //start of videomodes list.
static vmode_t *pcurrentmode; // the current active videomode.
//----------------------------i_video.c------------------------------------
// table des modes videos.
// seul le mode 320x200x256c standard VGA est support� sans le VESA.
// ce mode est le mode num�ro 0 dans la liste.
typedef struct
{
int modenum; // vesa vbe2.0 modenum
int mode_attributes;
int winasegment;
int winbsegment;
int bytes_per_scanline; // bytes per logical scanline (+16)
int win; // window number (A=0, B=1)
int win_size; // window size (+6)
int granularity; // how finely i can set the window in vid mem (+4)
int width, height; // displayed width and height (+18, +20)
int bits_per_pixel; // er, better be 8, 15, 16, 24, or 32 (+25)
int bytes_per_pixel; // er, better be 1, 2, or 4
int memory_model; // and better be 4 or 6, packed or direct color (+27)
int num_pages; // number of complete frame buffer pages (+29)
int red_width; // the # of bits in the red component (+31)
int red_pos; // the bit position of the red component (+32)
int green_width; // etc.. (+33)
int green_pos; // (+34)
int blue_width; // (+35)
int blue_pos; // (+36)
int pptr;
int pagesize;
int numpages;
} modeinfo_t;
static vbeinfoblock_t vesainfo;
static vesamodeinfo_t vesamodeinfo;
// ------------------------------------------------------------------------
// DOS stuff
// ------------------------------------------------------------------------
static unsigned long conventional_memory = (unsigned long)-1;
FUNCINLINE static ATTRINLINE void map_in_conventional_memory(void)
{
if (conventional_memory == (unsigned long)-1)
{
if (__djgpp_nearptr_enable())
{
conventional_memory = __djgpp_conventional_base;
}
}
}
// Converts a flat 32 bit ptr to a realmode 0x12345 type ptr (seg<<4 + offs)
#if 0
unsigned int ptr2real(void *ptr)
{
map_in_conventional_memory();
return (int)ptr - conventional_memory;
}
#endif
// Converts 0x12345 (seg<<4+offs) realmode ptr to a flat 32bit ptr
FUNCINLINE static ATTRINLINE void *real2ptr(unsigned int real)
{
map_in_conventional_memory();
return (void *) (real + conventional_memory);
}
// ------------------------------------------------------------------------
/* ======================================================================== */
// Add the standard VGA video modes (only one now) to the video modes list.
/* ======================================================================== */
static inline void VGA_Init(void)
{
vgavidmodes[NUMVGAVIDMODES-1].pnext = pvidmodes;
pvidmodes = &vgavidmodes[0];
numvidmodes += NUMVGAVIDMODES;
}
//added:30-01-98: return number of video modes in pvidmodes list
INT32 VID_NumModes(void)
{
return numvidmodes;
}
//added:21-03-98: return info on video mode
FUNCINLINE static ATTRINLINE const char *VID_ModeInfo (int modenum, char **ppheader)
{
static const char *badmodestr = "Bad video mode number\n";
vmode_t *pv;
pv = VID_GetModePtr (modenum);
if (!pv)
{
if (ppheader)
*ppheader = NULL;
return badmodestr;
}
else
{
//if (ppheader)
// *ppheader = pv->header;
return pv->name;
}
}
//added:03-02-98: return a video mode number from the dimensions
INT32 VID_GetModeForSize( INT32 w, INT32 h)
{
vmode_t *pv;
int modenum;
pv = pvidmodes;
for (modenum=0; pv!=NULL; pv=pv->pnext,modenum++ )
{
if ( pv->width==(unsigned)w && pv->height==(unsigned)h )
return modenum;
}
return 0;
}
/* ======================================================================== */
//
/* ======================================================================== */
void VID_Init (void)
{
COM_AddCommand ("vid_nummodes", VID_Command_NumModes_f);
COM_AddCommand ("vid_modeinfo", VID_Command_ModeInfo_f);
COM_AddCommand ("vid_modelist", VID_Command_ModeList_f);
COM_AddCommand ("vid_mode", VID_Command_Mode_f);
CV_RegisterVar (&cv_vidwait);
CV_RegisterVar (&cv_stretch);
//setup the videmodes list,
// note that mode 0 must always be VGA mode 0x13
pvidmodes = NULL;
pcurrentmode = NULL;
numvidmodes = 0;
// setup the vesa_modes list
VID_VesaGetExtraModes ();
// the game boots in 320x200 standard VGA, but
// we need a highcolor mode to run the game in highcolor
if (highcolor && numvidmodes==0)
I_Error ("No 15bit highcolor VESA2 video mode found, cannot run in highcolor.\n");
// add the vga modes at the start of the modes list
VGA_Init();
#ifdef DEBUG
CONS_Printf("VID_SetMode(%d)\n",vid.modenum);
#endif
VID_SetMode (0); //vid.modenum);
#ifdef DEBUG
CONS_Printf("after VID_SetMode\n");
CONS_Printf("vid.width %d\n",vid.width);
CONS_Printf("vid.height %d\n",vid.height);
CONS_Printf("vid.buffer %x\n",vid.buffer);
CONS_Printf("vid.rowbytes %d\n",vid.rowbytes);
CONS_Printf("vid.numpages %d\n",vid.numpages);
CONS_Printf("vid.recalc %d\n",vid.recalc);
CONS_Printf("vid.direct %x\n",vid.direct);
#endif
}
// ========================================================================
// Returns a vmode_t from the video modes list, given a video mode number.
// ========================================================================
vmode_t *VID_GetModePtr (int modenum)
{
vmode_t *pv;
pv = pvidmodes;
if (!pv)
I_Error ("VID_error 1\n");
while (modenum--)
{
pv = pv->pnext;
if (!pv)
I_Error ("VID_error 2\n");
}
return pv;
}
//added:30-01-98:return the name of a video mode
const char *VID_GetModeName (INT32 modenum)
{
return (VID_GetModePtr(modenum))->name;
}
// ========================================================================
// Sets a video mode
// ========================================================================
INT32 VID_SetMode (INT32 modenum) //, UINT8 *palette)
{
int vstat;
vmode_t *pnewmode, *poldmode;
if ((modenum >= numvidmodes) || (modenum < 0))
{
if (pcurrentmode == NULL)
{
modenum = 0; // mode hasn't been set yet, so initialize to base
// mode since they gave us an invalid initial mode
}
else
{
//nomodecheck = true;
I_Error ("Unknown video mode: %d\n", modenum);
//nomodecheck = false;
return 0;
}
}
pnewmode = VID_GetModePtr (modenum);
if (pnewmode == pcurrentmode)
return 1; // already in the desired mode
// initialize the new mode
poldmode = pcurrentmode;
pcurrentmode = pnewmode;
// initialize vidbuffer size for setmode
vid.width = pcurrentmode->width;
vid.height = pcurrentmode->height;
//vid.aspect = pcurrentmode->aspect;
vid.rowbytes = pcurrentmode->rowbytes;
vid.bpp = pcurrentmode->bytesperpixel;
//debug
//if (vid.rowbytes != vid.width)
// I_Error("vidrowbytes (%d) <> vidwidth(%d)\n",vid.rowbytes,vid.width);
vstat = (*pcurrentmode->setmode) (&vid, pcurrentmode);
if (vstat < 1)
{
if (vstat == 0)
{
// harware could not setup mode
//if (!VID_SetMode (vid.modenum))
// I_Error ("VID_SetMode: couldn't set video mode (hard failure)");
I_Error("Couldn't set video mode %d\n", modenum);
}
else
if (vstat == -1)
{
CONS_Printf ("Not enough mem for VID_SetMode...\n");
// not enough memory; just put things back the way they were
pcurrentmode = poldmode;
vid.width = pcurrentmode->width;
vid.height = pcurrentmode->height;
vid.rowbytes = pcurrentmode->rowbytes;
vid.bpp = pcurrentmode->bytesperpixel;
return 0;
}
}
vid.modenum = modenum;
//printf ("%s\n", VID_ModeInfo (vid.modenum, NULL));
//added:20-01-98: recalc all tables and realloc buffers based on
// vid values.
vid.recalc = 1;
if (!cv_stretch.value && (float)vid.width/vid.height != ((float)BASEVIDWIDTH/BASEVIDHEIGHT))
vid.height = (int)(vid.width * ((float)BASEVIDHEIGHT/BASEVIDWIDTH));// Adjust the height to match
return 1;
}
// converts a segm:offs 32bit pair to a 32bit flat ptr
#if 0
void *VID_ExtraFarToLinear (void *ptr)
{
int temp;
temp = (int)ptr;
return real2ptr (((temp & 0xFFFF0000) >> 12) + (temp & 0xFFFF));
}
#endif
// ========================================================================
// Helper function for VID_VesaGetExtraModes
// In: vesa mode number, from the vesa videomodenumbers list
// Out: false, if no info for given modenum
// ========================================================================
int VID_VesaGetModeInfo (int modenum)
{
int bytes_per_pixel;
unsigned int i;
__dpmi_regs regs;
for (i=0; i<sizeof (vesamodeinfo_t); i++)
_farpokeb(_dos_ds, MASK_LINEAR(__tb)+i, 0);
regs.x.ax = 0x4f01;
regs.x.di = RM_OFFSET(__tb);
regs.x.es = RM_SEGMENT(__tb);
regs.x.cx = modenum;
__dpmi_int(0x10, &regs);
if (regs.h.ah)
return false;
else
{
dosmemget (MASK_LINEAR(__tb), sizeof (vesamodeinfo_t), &vesamodeinfo);
bytes_per_pixel = (vesamodeinfo.BitsPerPixel+1)/8;
// we add either highcolor or lowcolor video modes, not the two
if (highcolor && (vesamodeinfo.BitsPerPixel != 15))
return false;
if (!highcolor && (vesamodeinfo.BitsPerPixel != 8))
return false;
if ((bytes_per_pixel > 2) ||
(vesamodeinfo.XResolution > MAXVIDWIDTH) ||
(vesamodeinfo.YResolution > MAXVIDHEIGHT))
{
return false;
}
// we only want color graphics modes that are supported by the hardware
if ((vesamodeinfo.ModeAttributes &
(MODE_SUPPORTED_IN_HW | COLOR_MODE | GRAPHICS_MODE) ) !=
(MODE_SUPPORTED_IN_HW | COLOR_MODE | GRAPHICS_MODE))
{
return false;
}
// we only work with linear frame buffers, except for 320x200,
// which is linear when banked at 0xA000
if (!(vesamodeinfo.ModeAttributes & LINEAR_FRAME_BUFFER))
{
if ((vesamodeinfo.XResolution != 320) ||
(vesamodeinfo.YResolution != 200))
{
return false;
}
}
// pagesize
if ((vesamodeinfo.BytesPerScanLine * vesamodeinfo.YResolution)
> totalvidmem)
{
return false;
}
vesamodeinfo.NumberOfImagePages = 1;
#ifdef DEBUG
CONS_Printf("VID: (VESA) info for mode 0x%x\n", modeinfo.modenum);
CONS_Printf(" mode attrib = 0x%0x\n", modeinfo.mode_attributes);
CONS_Printf(" win a attrib = 0x%0x\n", *(UINT8 *)(infobuf+2));
CONS_Printf(" win b attrib = 0x%0x\n", *(UINT8 *)(infobuf+3));
CONS_Printf(" win a seg 0x%0x\n", (int) modeinfo.winasegment);
CONS_Printf(" win b seg 0x%0x\n", (int) modeinfo.winbsegment);
CONS_Printf(" bytes per scanline = %d\n",
modeinfo.bytes_per_scanline);
CONS_Printf(" width = %d, height = %d\n", modeinfo.width,
modeinfo.height);
CONS_Printf(" win = %c\n", 'A' + modeinfo.win);
CONS_Printf(" win granularity = %d\n", modeinfo.granularity);
CONS_Printf(" win size = %d\n", modeinfo.win_size);
CONS_Printf(" bits per pixel = %d\n", modeinfo.bits_per_pixel);
CONS_Printf(" bytes per pixel = %d\n", modeinfo.bytes_per_pixel);
CONS_Printf(" memory model = 0x%x\n", modeinfo.memory_model);
CONS_Printf(" num pages = %d\n", modeinfo.num_pages);
CONS_Printf(" red width = %d\n", modeinfo.red_width);
CONS_Printf(" red pos = %d\n", modeinfo.red_pos);
CONS_Printf(" green width = %d\n", modeinfo.green_width);
CONS_Printf(" green pos = %d\n", modeinfo.green_pos);
CONS_Printf(" blue width = %d\n", modeinfo.blue_width);
CONS_Printf(" blue pos = %d\n", modeinfo.blue_pos);
CONS_Printf(" phys mem = %x\n", modeinfo.pptr);
#endif
}
return true;
}
// ========================================================================
// Get extended VESA modes information, keep the ones that we support,
// so they'll be available in the game Video menu.
// ========================================================================
#define MAXVESADESC 100
static char vesadesc[MAXVESADESC] = "";
void VID_VesaGetExtraModes (void)
{
unsigned int i;
unsigned long addr;
int nummodes;
__dpmi_meminfo phys_mem_info;
unsigned long mode_ptr;
__dpmi_regs regs;
// make a copy of the video modes list! else trash in __tb
UINT16 vmode[MAX_VESA_MODES+1];
int numvmodes;
UINT16 vesamode;
// new ugly stuff...
for (i=0; i<sizeof (vbeinfoblock_t); i++)
_farpokeb(_dos_ds, MASK_LINEAR(__tb)+i, 0);
dosmemput("VBE2", 4, MASK_LINEAR(__tb));
// see if VESA support is available
regs.x.ax = 0x4f00;
regs.x.di = RM_OFFSET(__tb);
regs.x.es = RM_SEGMENT(__tb);
__dpmi_int(0x10, &regs);
if (regs.h.ah)
goto no_vesa;
dosmemget(MASK_LINEAR(__tb), sizeof (vbeinfoblock_t), &vesainfo);
if (strncmp((void *)vesainfo.VESASignature, "VESA", 4) != 0)
{
no_vesa:
CONS_Printf ("No VESA driver\n");
return;
}
if (vesainfo.VESAVersion < (VBEVERSION<<8))
{
CONS_Printf ("VESA VBE %d.0 not available\n", VBEVERSION);
return;
}
//
// vesa version number
//
CONS_Printf ("%4.4s %d.%d (", vesainfo.VESASignature,
vesainfo.VESAVersion>>8,
vesainfo.VESAVersion&0xFF);
//
// vesa description string
//
i = 0;
addr = RM_TO_LINEAR(vesainfo.OemStringPtr);
_farsetsel(_dos_ds);
while (_farnspeekb(addr) != 0)
{
vesadesc[i++] = _farnspeekb(addr++);
if (i == MAXVESADESC-1)
break;
}
vesadesc[i]=0;
CONS_Printf ("%s)\n",vesadesc);
totalvidmem = vesainfo.TotalMemory << 16;
//
// find 8 bit modes
//
numvmodes = 0;
mode_ptr = RM_TO_LINEAR(vesainfo.VideoModePtr);
while ((vmode[numvmodes] = _farpeekw(_dos_ds, mode_ptr)) != 0xFFFF)
{
numvmodes++;
if ( numvmodes == MAX_VESA_MODES )
break;
mode_ptr += 2;
}
vmode[numvmodes] = 0xffff;
nummodes = 0; // number of video modes accepted for the game
numvmodes=0; // go again through vmodes table
while ( ((vesamode=vmode[numvmodes++]) != 0xFFFF) && (nummodes < MAX_VESA_MODES) )
{
//fill the modeinfo struct.
if (VID_VesaGetModeInfo (vesamode))
{
vesa_modes[nummodes].pnext = &vesa_modes[nummodes+1];
if (vesamodeinfo.XResolution > 999)
{
if (vesamodeinfo.YResolution > 999)
{
sprintf (&names[nummodes][0], "%4dx%4d", vesamodeinfo.XResolution,
vesamodeinfo.YResolution);
names[nummodes][9] = 0;
}
else
{
sprintf (&names[nummodes][0], "%4dx%3d", vesamodeinfo.XResolution,
vesamodeinfo.YResolution);
names[nummodes][8] = 0;
}
}
else
{
if (vesamodeinfo.YResolution > 999)
{
sprintf (&names[nummodes][0], "%3dx%4d", vesamodeinfo.XResolution,
vesamodeinfo.YResolution);
names[nummodes][8] = 0;
}
else
{
sprintf (&names[nummodes][0], "%3dx%3d", vesamodeinfo.XResolution,
vesamodeinfo.YResolution);
names[nummodes][7] = 0;
}
}
vesa_modes[nummodes].name = &names[nummodes][0];
vesa_modes[nummodes].width = vesamodeinfo.XResolution;
vesa_modes[nummodes].height = vesamodeinfo.YResolution;
//added:20-01-98:aspect ratio to be implemented...
vesa_modes[nummodes].rowbytes = vesamodeinfo.BytesPerScanLine;
vesa_modes[nummodes].windowed = 0;
vesa_modes[nummodes].pextradata = &vesa_extra[nummodes];
vesa_modes[nummodes].setmode = VID_VesaInitMode;
if (vesamodeinfo.ModeAttributes & LINEAR_FRAME_BUFFER)
{
// add linear bit to mode for linear modes
vesa_extra[nummodes].vesamode = vesamode | LINEAR_MODE;
vesa_modes[nummodes].numpages = 1; //vesamodeinfo.NumberOfImagePages;
phys_mem_info.address = (int)vesamodeinfo.PhysBasePtr;
phys_mem_info.size = 0x400000;
// returns -1 on error
if (__dpmi_physical_address_mapping(&phys_mem_info))
{
//skip this mode, it doesnt work
continue;
}
// if physical mapping was ok... convert the selector:offset
vesa_extra[nummodes].plinearmem =
real2ptr (phys_mem_info.address);
// lock the region
__dpmi_lock_linear_region (&phys_mem_info);
}
else
{
// banked at 0xA0000
vesa_extra[nummodes].vesamode = vesamode;
//vesa_extra[nummodes].pages[0] = 0;
vesa_extra[nummodes].plinearmem =
real2ptr (vesamodeinfo.WinASegment<<4);
vesa_modes[nummodes].numpages = 1; //modeinfo.numpages;
}
vesa_modes[nummodes].bytesperpixel = (vesamodeinfo.BitsPerPixel+1)/8;
nummodes++;
}
}
// add the VESA modes at the start of the mode list (if there are any)
if (nummodes)
{
vesa_modes[nummodes-1].pnext = NULL; //pvidmodes;
pvidmodes = &vesa_modes[0];
numvidmodes += nummodes;
}
}
// ========================================================================
// Free the video buffer of the last video mode,
// allocate a new buffer for the video mode to set.
// ========================================================================
static boolean VID_FreeAndAllocVidbuffer (viddef_t *lvid)
{
int vidbuffersize;
vidbuffersize = (lvid->width * lvid->height * lvid->bpp * NUMSCREENS); //status bar
// free allocated buffer for previous video mode
if (lvid->buffer!=NULL)
{
free(lvid->buffer);
}
// allocate the new screen buffer
if ( (lvid->buffer = (UINT8 *) malloc(vidbuffersize))==NULL )
return false;
// initially clear the video buffer
memset (lvid->buffer, 0x00, vidbuffersize);
#ifdef DEBUG
CONS_Printf("VID_FreeAndAllocVidbuffer done, vidbuffersize: %x\n",vidbuffersize);
#endif
return true;
}
// ========================================================================
// Set video mode routine for STANDARD VGA MODES (NO HIGHCOLOR)
// Out: 1 ok,
// 0 hardware could not set mode,
// -1 no mem
// ========================================================================
static INT32 VGA_InitMode (viddef_t *lvid, vmode_t *currentmodep)
{
__dpmi_regs regs;
if (!VID_FreeAndAllocVidbuffer (lvid))
return -1; //no mem
//added:26-01-98: should clear video mem here
//set mode 0x13
regs.h.ah = 0;
regs.h.al = 0x13;
__dpmi_int(0x10, &regs);
// here it is the standard VGA 64k window, not an LFB
// (you could have 320x200x256c with LFB in the vesa modes)
lvid->direct = (UINT8 *) real2ptr (0xa0000);
lvid->u.numpages = 1;
lvid->bpp = currentmodep->bytesperpixel;
return 1;
}
// ========================================================================
// Set video mode routine for VESA video modes, see VID_SetMode()
// Out: 1 ok,
// 0 hardware could not set mode,
// -1 no mem
// ========================================================================
INT32 VID_VesaInitMode (viddef_t *lvid, vmode_t *currentmodep)
{
vesa_extra_t *pextra;
__dpmi_regs regs;
pextra = currentmodep->pextradata;
#ifdef DEBUG
CONS_Printf("VID_VesaInitMode...\n");
CONS_Printf(" currentmodep->name %s\n",currentmodep->name);
CONS_Printf(" width %d\n",currentmodep->width);
CONS_Printf(" height %d\n",currentmodep->height);
CONS_Printf(" rowbytes %d\n",currentmodep->rowbytes);
CONS_Printf(" windowed %d\n",currentmodep->windowed);
CONS_Printf(" numpages %d\n",currentmodep->numpages);
CONS_Printf(" currentmodep->pextradata :\n");
CONS_Printf(" ->vesamode %x\n",pextra->vesamode);
CONS_Printf(" ->plinearmem %x\n\n",pextra->plinearmem);
#endif
//added:20-01-98:no page flipping now... TO DO!!!
lvid->u.numpages = 1;
// clean up any old vid buffer lying around, alloc new if needed
if (!VID_FreeAndAllocVidbuffer (lvid))
return -1; //no mem
//added:20-01-98: should clear video mem here
// set the mode
regs.x.ax = 0x4f02;
regs.x.bx = pextra->vesamode;
__dpmi_int (0x10, &regs);
if (regs.x.ax != 0x4f)
return 0; // could not set mode
//added:20-01-98: should setup wait_vsync flag, currentpage here...
// plus check for display_enable bit
//added:20-01-98: here we should set the page if page flipping...
// points to LFB, or the start of VGA mem.
lvid->direct = pextra->plinearmem;
lvid->bpp = currentmodep->bytesperpixel;
return 1;
}
// ========================================================================
// VIDEO MODE CONSOLE COMMANDS
// ========================================================================
// vid_nummodes
//
//added:21-03-98:
void VID_Command_NumModes_f (void)
{
int nummodes;
nummodes = VID_NumModes ();
CONS_Printf ("%d video mode(s) available(s)\n", nummodes);
}
// vid_modeinfo <modenum>
//
void VID_Command_ModeInfo_f (void)
{
vmode_t *pv;
int modenum;
if (COM_Argc()!=2)
modenum = vid.modenum; // describe the current mode
else
modenum = atoi (COM_Argv(1)); // .. the given mode number
if (modenum >= VID_NumModes())
{
CONS_Printf ("No such video mode\n");
return;
}
pv = VID_GetModePtr (modenum);
CONS_Printf ("%s\n", VID_ModeInfo (modenum, NULL));
CONS_Printf ("width : %d\n"
"height: %d\n"
"bytes per scanline: %d\n"
"bytes per pixel: %d\n"
"numpages: %d\n",
pv->width,
pv->height,
pv->rowbytes,
pv->bytesperpixel,
pv->numpages );
}
// vid_modelist
//
void VID_Command_ModeList_f (void)
{
int i, nummodes;
const char *pinfo;
char *pheader;
vmode_t *pv;
boolean na;
na = false;
nummodes = VID_NumModes ();
for (i=0 ; i<nummodes ; i++)
{
pv = VID_GetModePtr (i);
pinfo = VID_ModeInfo (i, &pheader);
if (i==0 || pv->bytesperpixel==1)
CONS_Printf ("%d: %s\n", i, pinfo);
else
CONS_Printf ("%d: %s (hicolor)\n", i, pinfo);
}
}
// vid_mode <modenum>
//
void VID_Command_Mode_f (void)
{
int modenum;
if (COM_Argc()!=2)
{
CONS_Printf ("vid_mode <modenum> : set video mode\n");
return;
}
modenum = atoi(COM_Argv(1));
if (modenum >= VID_NumModes())
CONS_Printf ("No such video mode\n");
else
// request vid mode change
setmodeneeded = modenum+1;
}
-109
View File
@@ -1,109 +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 VESA extra modes.
#include "../doomdef.h"
#include "../screen.h"
#define MODE_SUPPORTED_IN_HW 0x0001
#define COLOR_MODE 0x0008
#define GRAPHICS_MODE 0x0010
#define VGA_INCOMPATIBLE 0x0020
#define LINEAR_FRAME_BUFFER 0x0080
#define LINEAR_MODE 0x4000
#define MAX_VESA_MODES 30 // we'll just take the first 30 if there
// VESA information block structure
typedef struct vbeinfoblock_s
{
UINT8 VESASignature[4];
UINT16 VESAVersion;
unsigned long OemStringPtr;
UINT8 Capabilities[4];
unsigned long VideoModePtr;
UINT16 TotalMemory;
UINT8 OemSoftwareRev[2];
UINT8 OemVendorNamePtr[4];
UINT8 OemProductNamePtr[4];
UINT8 OemProductRevPtr[4];
UINT8 Reserved[222];
UINT8 OemData[256];
} ATTRPACK vbeinfoblock_t;
// VESA information for a specific mode
typedef struct vesamodeinfo_s
{
UINT16 ModeAttributes;
UINT8 WinAAttributes;
UINT8 WinBAttributes;
UINT16 WinGranularity;
UINT16 WinSize;
UINT16 WinASegment;
UINT16 WinBSegment;
unsigned long WinFuncPtr;
UINT16 BytesPerScanLine;
UINT16 XResolution;
UINT16 YResolution;
UINT8 XCharSize;
UINT8 YCharSize;
UINT8 NumberOfPlanes;
UINT8 BitsPerPixel;
UINT8 NumberOfBanks;
UINT8 MemoryModel;
UINT8 BankSize;
UINT8 NumberOfImagePages;
UINT8 Reserved_page;
UINT8 RedMaskSize;
UINT8 RedMaskPos;
UINT8 GreenMaskSize;
UINT8 GreenMaskPos;
UINT8 BlueMaskSize;
UINT8 BlueMaskPos;
UINT8 ReservedMaskSize;
UINT8 ReservedMaskPos;
UINT8 DirectColorModeInfo;
/* VBE 2.0 extensions */
unsigned long PhysBasePtr;
unsigned long OffScreenMemOffset;
UINT16 OffScreenMemSize;
/* VBE 3.0 extensions */
UINT16 LinBytesPerScanLine;
UINT8 BnkNumberOfPages;
UINT8 LinNumberOfPages;
UINT8 LinRedMaskSize;
UINT8 LinRedFieldPos;
UINT8 LinGreenMaskSize;
UINT8 LinGreenFieldPos;
UINT8 LinBlueMaskSize;
UINT8 LinBlueFieldPos;
UINT8 LinRsvdMaskSize;
UINT8 LinRsvdFieldPos;
unsigned long MaxPixelClock;
UINT8 Reserved[190];
} ATTRPACK vesamodeinfo_t;
// setup standard VGA + VESA modes list, activate the default video mode.
void VID_Init (void);
+6 -25
View File
@@ -28,12 +28,10 @@
// Use Mixer interface?
#ifdef HAVE_MIXER
//#if !defined(_WIN32_WCE) && !defined(GP2X)
#define SOUND SOUND_MIXER
#ifdef HW3SOUND
#undef HW3SOUND
#endif
//#endif
#endif
// Use generic SDL interface.
@@ -64,7 +62,7 @@
#endif
#endif
#if defined (_WIN32) || defined (_WIN32_WCE)
#ifdef _WIN32
#define ASMCALL __cdecl
#else
#define ASMCALL
@@ -81,13 +79,6 @@
// warning C4152: nonstandard extension, function/data pointer conversion in expression
// warning C4213: nonstandard extension used : cast on l-value
#if defined (_WIN32_WCE) && defined (DEBUG) && defined (ARM)
#if defined (ARMV4) || defined (ARMV4I)
//#pragma warning(disable : 1166)
// warning LNK1166: cannot adjust code at offset=
#endif
#endif
#include "doomtype.h"
@@ -104,20 +95,14 @@
#include <locale.h>
#endif
#if !defined (_WIN32_WCE)
#include <sys/types.h>
#include <sys/stat.h>
#endif
#include <ctype.h>
#if (defined (_WIN32) && !defined (_WIN32_WCE)) || defined (__DJGPP__)
#ifdef _WIN32
#include <io.h>
#endif
#ifdef PC_DOS
#include <conio.h>
#endif
//#define NOMD5
// Uncheck this to compile debugging code
@@ -126,7 +111,7 @@
//#define PARANOIA // do some tests that never fail but maybe
// turn this on by make etc.. DEBUGMODE = 1 or use the Debug profile in the VC++ projects
//#endif
#if defined (_WIN32) || (defined (__unix__) && !defined (MSDOS)) || defined(__APPLE__) || defined (UNIXCOMMON) || defined (macintosh)
#if defined (_WIN32) || defined (__unix__) || defined(__APPLE__) || defined (UNIXCOMMON) || defined (macintosh)
#define LOGMESSAGES // write message in log.txt
#endif
@@ -431,13 +416,11 @@ enum {
};
// Name of local directory for config files and savegames
#if !defined(_WIN32_WCE) && !defined(GP2X)
#if (((defined (__unix__) && !defined (MSDOS)) || defined (UNIXCOMMON)) && !defined (__CYGWIN__)) && !defined (__APPLE__)
#if (defined (__unix__) || defined (UNIXCOMMON)) && !defined (__CYGWIN__) && !defined (__APPLE__)
#define DEFAULTDIR ".srb2kart"
#else
#define DEFAULTDIR "srb2kart"
#endif
#endif
#include "g_state.h"
@@ -568,8 +551,8 @@ INT32 I_GetKey(void);
#endif
// The character that separates pathnames. Forward slash on
// most systems, but reverse solidus (\) on Windows and DOS.
#if defined (PC_DOS) || defined (_WIN32)
// most systems, but reverse solidus (\) on Windows.
#if defined (_WIN32)
#define PATHSEP "\\"
#else
#define PATHSEP "/"
@@ -617,14 +600,12 @@ extern const char *compdate, *comptime, *comprevision, *compbranch;
/// Most modifications should probably enable this.
//#define SAVEGAME_OTHERVERSIONS
#if !defined (_NDS)
/// Allow the use of the SOC RESETINFO command.
/// \note Builds that are tight on memory should disable this.
/// This stops the game from storing backups of the states, sprites, and mobjinfo tables.
/// Though this info is compressed under normal circumstances, it's still a lot of extra
/// memory that never gets touched.
#define ALLOW_RESETDATA
#endif
#ifndef NONET
/// Display a connection screen on join attempts.
+4 -29
View File
@@ -17,16 +17,12 @@
#ifndef __DOOMTYPE__
#define __DOOMTYPE__
#if defined (_WIN32) || (defined (_WIN32_WCE) && !defined (__GNUC__))
#ifdef _WIN32
//#define WIN32_LEAN_AND_MEAN
#define RPC_NO_WINDOWS_H
#include <windows.h>
#endif
#ifdef _NDS
#include <nds.h>
#endif
/* 7.18.1.1 Exact-width integer types */
#ifdef _MSC_VER
#define UINT8 unsigned __int8
@@ -52,17 +48,7 @@ typedef long ssize_t;
#define PDWORD_PTR PDWORD
#endif
#endif
#elif defined (__DJGPP__)
#define UINT8 unsigned char
#define SINT8 signed char
#define UINT16 unsigned short int
#define INT16 signed short int
#define INT32 signed long
#define UINT32 unsigned long
#define INT64 signed long long
#define UINT64 unsigned long long
#else
#define __STDC_LIMIT_MACROS
#include <stdint.h>
@@ -108,21 +94,12 @@ typedef long ssize_t;
#define strncasecmp strnicmp
#define strcasecmp strcmpi
#endif
#if (defined (__unix__) && !defined (MSDOS)) || defined(__APPLE__) || defined (UNIXCOMMON)
#if defined (__unix__) || defined (__APPLE__) || defined (UNIXCOMMON)
#undef stricmp
#define stricmp(x,y) strcasecmp(x,y)
#undef strnicmp
#define strnicmp(x,y,n) strncasecmp(x,y,n)
#endif
#ifdef _WIN32_WCE
#ifndef __GNUC__
#define stricmp(x,y) _stricmp(x,y)
#define strnicmp _strnicmp
#endif
#define strdup _strdup
#define strupr _strupr
#define strlwr _strlwr
#endif
char *strcasestr(const char *in, const char *what);
#define stristr strcasestr
@@ -145,7 +122,7 @@ char *strcasestr(const char *in, const char *what);
#endif
#endif //macintosh
#if defined (PC_DOS) || defined (_WIN32) || defined (__HAIKU__) || defined(_NDS)
#if defined (_WIN32) || defined (__HAIKU__)
#define HAVE_DOSSTR_FUNCS
#endif
@@ -188,12 +165,10 @@ size_t strlcpy(char *dst, const char *src, size_t siz);
//faB: clean that up !!
#if defined( _MSC_VER) && (_MSC_VER >= 1800) // MSVC 2013 and forward
#include "stdbool.h"
#elif defined (_WIN32) || (defined (_WIN32_WCE) && !defined (__GNUC__))
#elif defined (_WIN32)
#define false FALSE // use windows types
#define true TRUE
#define boolean BOOL
#elif defined(_NDS)
#define boolean bool
#else
typedef enum {false, true} boolean;
#endif
+1 -80
View File
@@ -21,11 +21,7 @@
#define RPC_NO_WINDOWS_H
#include <windows.h>
#endif
#ifdef _WIN32_WCE
#include "sdl12/SRB2CE/cehelp.h"
#else
#include <sys/stat.h>
#endif
#include <string.h>
#include "filesrch.h"
@@ -34,7 +30,7 @@
#include "z_zone.h"
#include "m_menu.h" // Addons_option_Onchange
#if (defined (_WIN32) && !defined (_WIN32_WCE)) && defined (_MSC_VER)
#if defined (_WIN32) && defined (_MSC_VER)
#include <errno.h>
#include <io.h>
@@ -341,79 +337,6 @@ size_t dir_on[menudepth];
UINT8 refreshdirmenu = 0;
char *refreshdirname = NULL;
#ifdef _WIN32_WCE
filestatus_t filesearch(char *filename, const char *startpath, const UINT8 *wantedmd5sum,
boolean completepath, int maxsearchdepth)
{
#ifdef __GNUC__
//NONE?
startpath = filename = NULL;
wantedmd5sum = NULL;
maxsearchdepth = 0;
completepath = false;
#else
WIN32_FIND_DATA dta;
HANDLE searchhandle = INVALID_HANDLE_VALUE;
const wchar_t wm[4] = L"*.*";
//if (startpath) SetCurrentDirectory(startpath);
if (FIL_ReadFileOK(filename))
{
// checkfilemd5 returns an FS_* value, either FS_FOUND or FS_MD5SUMBAD
return checkfilemd5(filename, wantedmd5sum);
}
ZeroMemory(&dta,sizeof (dta));
if (maxsearchdepth)
searchhandle = FindFirstFile(wm,&dta);
if (searchhandle != INVALID_HANDLE_VALUE)
{
do
{
if ((dta.cFileName[0]!='.') && (dta.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY))
{
//if (SetCurrentDirectory(dta.cFileName))
{ // can fail if we haven't the right
filestatus_t found;
found = filesearch(filename,NULL,wantedmd5sum,completepath,maxsearchdepth-1);
//SetCurrentDirectory("..");
if (found == FS_FOUND || found == FS_MD5SUMBAD)
{
if (completepath)
strcatbf(filename,(char *)dta.cFileName,"\\");
FindClose(searchhandle);
return found;
}
}
}
} while (FindNextFile(searchhandle,&dta)==0);
FindClose(searchhandle);
}
#endif
return FS_NOTFOUND;
}
void closefilemenu(boolean validsize)
{
(void)validsize;
return;
}
void searchfilemenu(char *tempname)
{
(void)tempname;
return;
}
boolean preparefilemenu(boolean samedepth, boolean replayhut)
{
(void)samedepth;
(void)replayhut;
return false;
}
#else
filestatus_t filesearch(char *filename, const char *startpath, const UINT8 *wantedmd5sum, boolean completepath, int maxsearchdepth)
{
filestatus_t retval = FS_NOTFOUND;
@@ -890,5 +813,3 @@ boolean preparefilemenu(boolean samedepth, boolean replayhut)
return true;
}
#endif
+1 -77
View File
@@ -325,39 +325,6 @@ static keyname_t keynames[] =
{KEY_2MOUSEWHEELUP, "Wheel 2 UP"},
{KEY_2MOUSEWHEELDOWN, "Wheel 2 Down"},
#ifdef _PSP
{KEY_JOY1+0, "TRIANGLE"},
{KEY_JOY1+1, "CIRCLE" },
{KEY_JOY1+2, "CROSS" },
{KEY_JOY1+3, "SQUARE" },
{KEY_JOY1+4, "LTRIGGER"},
{KEY_JOY1+5, "RTRIGGER"},
{KEY_JOY1+6, "SELECT" },
{KEY_JOY1+7, "START" },
{KEY_JOY1+8, "HOME" },
{KEY_JOY1+9, "HOLD" },
#define NOMOREJOYBTN_1S
#elif defined (GP2X)
{KEY_JOY1+0, "JOYA"},
{KEY_JOY1+1, "JOYY"},
{KEY_JOY1+2, "JOYB"},
{KEY_JOY1+3, "JOYX"},
{KEY_JOY1+4, "JOYL"},
{KEY_JOY1+5, "JOYR"},
{KEY_JOY1+6, "JOYVOLUP"},
{KEY_JOY1+7, "JOYVOLDOWN"},
{KEY_JOY1+8, "JOYSELECT"},
#elif defined (_NDS)
{KEY_JOY1+0, "JOYA"},
{KEY_JOY1+1, "JOYB"},
{KEY_JOY1+2, "JOYX"},
{KEY_JOY1+3, "JOYY"},
{KEY_JOY1+4, "JOYL"},
{KEY_JOY1+5, "JOYR"},
{KEY_JOY1+6, "JOYSTART"},
{KEY_JOY1+7, "JOYSELECT"},
#define NOMOREJOYBTN_1S
#else
{KEY_JOY1+0, "JOY1"},
{KEY_JOY1+1, "JOY2"},
{KEY_JOY1+2, "JOY3"},
@@ -367,7 +334,7 @@ static keyname_t keynames[] =
{KEY_JOY1+6, "JOY7"},
{KEY_JOY1+7, "JOY8"},
{KEY_JOY1+8, "JOY9"},
#endif
#if !defined (NOMOREJOYBTN_1S)
// we use up to 32 buttons in DirectInput
{KEY_JOY1+9, "JOY10"},
@@ -429,39 +396,6 @@ static keyname_t keynames[] =
{KEY_DBL2MOUSE1+6, "DBLSEC_MOUSE7"},
{KEY_DBL2MOUSE1+7, "DBLSEC_MOUSE8"},
#ifdef _PSP
{KEY_DBLJOY1+0, "DBLTRIANGLE"},
{KEY_DBLJOY1+1, "DBLCIRCLE" },
{KEY_DBLJOY1+2, "DBLCROSS" },
{KEY_DBLJOY1+3, "DBLSQUARE" },
{KEY_DBLJOY1+4, "DBLLTRIGGER"},
{KEY_DBLJOY1+5, "DBLRTRIGGER"},
{KEY_DBLJOY1+6, "DBLSELECT" },
{KEY_DBLJOY1+7, "DBLSTART" },
{KEY_DBLJOY1+8, "DBLHOME" },
{KEY_DBLJOY1+9, "DBLHOLD" },
#elif defined (GP2X)
{KEY_DBLJOY1+0, "DBLJOYA"},
{KEY_DBLJOY1+1, "DBLJOYY"},
{KEY_DBLJOY1+2, "DBLJOYB"},
{KEY_DBLJOY1+3, "DBLJOYX"},
{KEY_DBLJOY1+4, "DBLJOYL"},
{KEY_DBLJOY1+5, "DBLJOYR"},
{KEY_DBLJOY1+6, "DBLJOYVOLUP"},
{KEY_DBLJOY1+7, "DBLJOYVOLDOWN"},
{KEY_DBLJOY1+8, "DBLJOYSELECT"},
#define NOMOREJOYBTN_1DBL
#elif defined (_NDS)
{KEY_DBLJOY1+0, "DBLJOYA"},
{KEY_DBLJOY1+1, "DBLJOYB"},
{KEY_DBLJOY1+2, "DBLJOYX"},
{KEY_DBLJOY1+3, "DBLJOYY"},
{KEY_DBLJOY1+4, "DBLJOYL"},
{KEY_DBLJOY1+5, "DBLJOYR"},
{KEY_DBLJOY1+6, "DBLJOYSTART"},
{KEY_DBLJOY1+7, "DBLJOYSELECT"},
#define NOMOREJOYBTN_1DBL
#else
{KEY_DBLJOY1+0, "DBLJOY1"},
{KEY_DBLJOY1+1, "DBLJOY2"},
{KEY_DBLJOY1+2, "DBLJOY3"},
@@ -470,7 +404,6 @@ static keyname_t keynames[] =
{KEY_DBLJOY1+5, "DBLJOY6"},
{KEY_DBLJOY1+6, "DBLJOY7"},
{KEY_DBLJOY1+7, "DBLJOY8"},
#endif
#if !defined (NOMOREJOYBTN_1DBL)
{KEY_DBLJOY1+8, "DBLJOY9"},
{KEY_DBLJOY1+9, "DBLJOY10"},
@@ -1161,14 +1094,6 @@ static INT32 G_FilterKeyByVersion(INT32 numctrl, INT32 keyidx, INT32 player, INT
}
}
#else
#if !defined (DC) && !defined (_PSP) && !defined (GP2X) && !defined (_NDS)
if (GETMAJOREXECVERSION(cv_execversion.value) < 27 && ( // v2.1.22
numctrl == gc_weaponnext || numctrl == gc_weaponprev || numctrl == gc_tossflag ||
numctrl == gc_use || numctrl == gc_camreset || numctrl == gc_jump ||
numctrl == gc_pause || numctrl == gc_systemmenu || numctrl == gc_camtoggle ||
numctrl == gc_screenshot || numctrl == gc_talkkey || numctrl == gc_scores ||
numctrl == gc_centerview
))
{
INT32 keynum = 0, existingctrl = 0;
INT32 defaultkey;
@@ -1254,7 +1179,6 @@ static INT32 G_FilterKeyByVersion(INT32 numctrl, INT32 keyidx, INT32 player, INT
else
return 0;
}
#endif
#endif
// All's good, so pass the keynum as-is
+2 -7
View File
@@ -6135,13 +6135,8 @@ void HWR_Startup(void)
}
if (rendermode == render_opengl)
textureformat = patchformat =
#ifdef _NDS
GR_TEXFMT_P_8;
#else
GR_RGBA;
#endif
textureformat = patchformat = GR_RGBA;
startupdone = true;
// jimita
+1 -3
View File
@@ -20,11 +20,9 @@
#else
#include <winsock.h>
#endif
#elif !defined (__DJGPP__)
#else
#include <sys/socket.h>
#ifndef _NDS
#include <arpa/inet.h>
#endif
#include <netdb.h>
#endif
+6 -109
View File
@@ -27,7 +27,7 @@
#define HAVE_IPV6
#endif
#if defined (_WIN32) || defined (_WIN32_WCE)
#ifdef _WIN32
#define USE_WINSOCK
#if defined (_WIN64) || defined (HAVE_IPV6)
#define USE_WINSOCK2
@@ -74,7 +74,7 @@
#include <errno.h>
#include <time.h>
#if (defined (__unix__) && !defined (MSDOS)) || defined(__APPLE__) || defined (UNIXCOMMON)
#if defined (__unix__) || defined (__APPLE__) || defined (UNIXCOMMON)
#include <sys/time.h>
#endif // UNIXCOMMON
#endif // !NONET
@@ -117,15 +117,6 @@
#endif
#endif
#ifdef __DJGPP__
#ifdef WATTCP // Alam_GBC: Wattcp may need this
#include <tcp.h>
#define strerror strerror_s
#else // wattcp
#include <lsck/lsck.h>
#endif // libsocket
#endif // djgpp
typedef union
{
struct sockaddr any;
@@ -161,29 +152,15 @@ static UINT8 UPNP_support = TRUE;
#include "doomstat.h"
// win32 or djgpp
#if defined (USE_WINSOCK) || defined (__DJGPP__)
// win32
#ifdef USE_WINSOCK
// winsock stuff (in winsock a socket is not a file)
#define ioctl ioctlsocket
#define close closesocket
#ifdef _WIN32_WCE
#include "sdl12/SRB2CE/cehelp.h"
#endif
#endif
#include "i_addrinfo.h"
#ifdef __DJGPP__
#ifdef WATTCP
#define SELECTTEST
#endif
#else
#define SELECTTEST
#endif
#define DEFAULTPORT "5029"
@@ -191,7 +168,7 @@ static UINT8 UPNP_support = TRUE;
typedef SOCKET SOCKET_TYPE;
#define ERRSOCKET (SOCKET_ERROR)
#else
#if (defined (__unix__) && !defined (MSDOS)) || defined (__APPLE__) || defined (__HAIKU__)
#if defined (__unix__) || defined (__APPLE__) || defined (__HAIKU__)
typedef int SOCKET_TYPE;
#else
typedef unsigned long SOCKET_TYPE;
@@ -199,7 +176,7 @@ typedef unsigned long SOCKET_TYPE;
#define ERRSOCKET (-1)
#endif
#if (defined (WATTCP) && !defined (__libsocket_socklen_t)) || defined (USE_WINSOCK1)
#ifdef USE_WINSOCK1
typedef int socklen_t;
#endif
@@ -238,18 +215,6 @@ static const char *clientport_name;/* any port */
#ifndef NONET
#ifdef WATTCP
static void wattcp_outch(char s)
{
static char old = '\0';
char pr[2] = {s,0};
if (s == old && old == ' ') return;
else old = s;
if (s == '\r') CONS_Printf("\n");
else if (s != '\n') CONS_Printf(pr);
}
#endif
#ifdef USE_WINSOCK
// stupid microsoft makes things complicated
static char *get_WSAErrorStr(int e)
@@ -917,11 +882,7 @@ static SOCKET_TYPE UDP_Bind(int family, struct sockaddr *addr, socklen_t addrlen
int opt;
socklen_t opts;
#ifdef FIONBIO
#ifdef WATTCP
char trueval = true;
#else
unsigned long trueval = true;
#endif
#endif
mysockaddr_t straddr;
struct sockaddr_in sin;
@@ -1291,61 +1252,7 @@ boolean I_InitTcpDriver(void)
CONS_Debug(DBG_NETPLAY, "WinSock description: %s\n",WSAData.szDescription);
CONS_Debug(DBG_NETPLAY, "WinSock System Status: %s\n",WSAData.szSystemStatus);
#endif
#ifdef __DJGPP__
#ifdef WATTCP // Alam_GBC: survive bootp, dhcp, rarp and wattcp/pktdrv from failing to load
survive_eth = 1; // would be needed to not exit if pkt_eth_init() fails
survive_bootp = 1; // ditto for BOOTP
survive_dhcp = 1; // ditto for DHCP/RARP
survive_rarp = 1;
//_watt_do_exit = false;
//_watt_handle_cbreak = false;
//_watt_no_config = true;
_outch = wattcp_outch;
init_misc();
//#ifdef DEBUGFILE
dbug_init();
//#endif
switch (sock_init())
{
case 0:
init_tcp_driver = true;
break;
case 3:
CONS_Debug(DBG_NETPLAY, "No packet driver detected\n");
break;
case 4:
CONS_Debug(DBG_NETPLAY, "Error while talking to packet driver\n");
break;
case 5:
CONS_Debug(DBG_NETPLAY, "BOOTP failed\n");
break;
case 6:
CONS_Debug(DBG_NETPLAY, "DHCP failed\n");
break;
case 7:
CONS_Debug(DBG_NETPLAY, "RARP failed\n");
break;
case 8:
CONS_Debug(DBG_NETPLAY, "TCP/IP failed\n");
break;
case 9:
CONS_Debug(DBG_NETPLAY, "PPPoE login/discovery failed\n");
break;
default:
CONS_Debug(DBG_NETPLAY, "Unknown error with TCP/IP stack\n");
break;
}
hires_timer(0);
#else // wattcp
if (__lsck_init())
init_tcp_driver = true;
else
CONS_Debug(DBG_NETPLAY, "No TCP/IP driver detected\n");
#endif // libsocket
#endif // __DJGPP__
#ifndef __DJGPP__
init_tcp_driver = true;
#endif
}
#endif
if (!tcp_was_up && init_tcp_driver)
@@ -1370,10 +1277,8 @@ static void SOCK_CloseSocket(void)
if (mysockets[i] != (SOCKET_TYPE)ERRSOCKET
&& FD_ISSET(mysockets[i], &masterset))
{
#if !defined (__DJGPP__) || defined (WATTCP)
FD_CLR(mysockets[i], &masterset);
close(mysockets[i]);
#endif
}
mysockets[i] = ERRSOCKET;
}
@@ -1390,14 +1295,6 @@ void I_ShutdownTcpDriver(void)
WS_addrinfocleanup();
WSACleanup();
#endif
#ifdef __DJGPP__
#ifdef WATTCP // wattcp
//_outch = NULL;
sock_exit();
#else
__lsck_uninit();
#endif // libsocket
#endif // __DJGPP__
CONS_Printf("shut down\n");
init_tcp_driver = false;
#endif
+1 -3
View File
@@ -119,9 +119,7 @@
/*****************************************************************************/
/* nothing should be changed below */
#ifndef _NDS
typedef unsigned char u8;
#endif
typedef const u8 *LZF_STATE[1 << (HLOG)];
@@ -159,7 +157,7 @@ typedef const u8 *LZF_STATE[1 << (HLOG)];
* lzfP.h ends here. lzf_d.c follows.
*/
#if AVOID_ERRNO || defined(_WIN32_WCE)
#if AVOID_ERRNO
# define SET_ERRNO(n)
#else
# include <errno.h>
+3 -9
View File
@@ -80,12 +80,6 @@
#endif
#endif
#ifdef PC_DOS
#include <stdio.h> // for snprintf
int snprintf(char *str, size_t n, const char *fmt, ...);
//int vsnprintf(char *str, size_t n, const char *fmt, va_list ap);
#endif
#ifdef HAVE_DISCORDRPC
//#include "discord_rpc.h"
#include "discord.h"
@@ -1304,7 +1298,7 @@ static menuitem_t OP_Mouse2OptionsMenu[] =
static menuitem_t OP_VideoOptionsMenu[] =
{
{IT_STRING | IT_CALL, NULL, "Set Resolution...", M_VideoModeMenu, 10},
#if (defined (__unix__) && !defined (MSDOS)) || defined (UNIXCOMMON) || defined (HAVE_SDL)
#if defined (__unix__) || defined (UNIXCOMMON) || defined (HAVE_SDL)
{IT_STRING|IT_CVAR, NULL, "Fullscreen", &cv_fullscreen, 20},
#endif
{IT_STRING | IT_CVAR | IT_CV_SLIDER,
@@ -1332,7 +1326,7 @@ static menuitem_t OP_VideoOptionsMenu[] =
enum
{
op_video_res = 0,
#if (defined (__unix__) && !defined (MSDOS)) || defined (UNIXCOMMON) || defined (HAVE_SDL)
#if defined (__unix__) || defined (UNIXCOMMON) || defined (HAVE_SDL)
op_video_fullscreen,
#endif
op_video_gamma,
@@ -11876,7 +11870,7 @@ static void M_VideoModeMenu(INT32 choice)
memset(modedescs, 0, sizeof(modedescs));
#if (defined (__unix__) && !defined (MSDOS)) || defined (UNIXCOMMON) || defined (HAVE_SDL)
#if defined (__unix__) || defined (UNIXCOMMON) || defined (HAVE_SDL)
VID_PrepareModeList(); // FIXME: hack
#endif
vidm_nummodes = 0;
-4
View File
@@ -65,8 +65,6 @@ typedef off_t off64_t;
#define PRIdS "u"
#elif defined(_WIN32) && !defined(__MINGW64__)
#define PRIdS "Iu"
#elif defined (DJGPP) || defined (_NDS)
#define PRIdS "u"
#else
#define PRIdS "zu"
#endif
@@ -720,8 +718,6 @@ static void M_PNGText(png_structp png_ptr, png_infop png_info_ptr, PNG_CONST png
"SDL";
#elif defined (_WINDOWS)
"DirectX";
#elif defined (PC_DOS)
"Allegro";
#else
"Unknown";
#endif
+1 -3
View File
@@ -19,9 +19,7 @@
#endif
#include <string.h>
#ifndef _WIN32_WCE
#include <sys/types.h>
#endif
#ifdef _MSC_VER
#pragma warning(disable : 4127)
#endif
@@ -30,7 +28,7 @@
#include <stdlib.h>
#else
#ifndef HAVE_MEMCPY
#if !((defined (_WIN32) || defined (_WIN32_WCE)) && !defined (__CYGWIN__)) && !defined (__APPLE__)
#if !(defined (_WIN32) && !defined (__CYGWIN__)) && !defined (__APPLE__)
#define memcpy(d, s, n) bcopy ((s), (d), (n))
#endif
#endif
-31
View File
@@ -1,31 +0,0 @@
# Adapted in part from devkitPRO makefiles.
NOMD5=1
# Check if DEVKITARM is set in the environment. If so, continue with compilation.
.SUFFIXES:
ifeq ($(strip $(DEVKITARM)),)
$(error "Please set DEVKITARM in your environment. export DEVKITARM=<path to>devkitARM")
endif
# use absolute paths because changing PATH variable breaks distcc
PREFIX := $(DEVKITARM)/bin/arm-eabi
NDSTOOL := $(DEVKITARM)/bin/ndstool
# Disable same warning flags
WFLAGS+=-Wno-inline -Wno-cast-align
WFLAGS+=-Wno-shadow -Wno-char-subscripts
WFLAGS+=-Wno-declaration-after-statement
WFLAGS+=-Wno-old-style-definition
WFLAGS+=-Wno-undef
WFLAGS+=-Wno-unsuffixed-float-constants
ifndef NOHW
OBJS+=$(OBJDIR)/r_nds3d.o
endif
ARCH = -mthumb -mthumb-interwork
LDFLAGS += -L$(DEVKITPRO)/libnds/lib -specs=ds_arm9.specs -g $(ARCH) -mno-fpu
LIBS += -lfat -lnds9
CFLAGS += -D_NDS -DARM9 -I$(DEVKITPRO)/libnds/include $(ARCH) -march=armv5te -mtune=arm946e-s -fomit-frame-pointer -ffast-math
-37
View File
@@ -1,37 +0,0 @@
#include "../command.h"
#include "../s_sound.h"
#include "../i_sound.h"
//
// CD MUSIC I/O
//
UINT8 cdaudio_started = 0;
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};
void I_InitCD(void){}
void I_StopCD(void){}
void I_PauseCD(void){}
void I_ResumeCD(void){}
void I_ShutdownCD(void){}
void I_UpdateCD(void){}
void I_PlayCD(UINT8 track, UINT8 looping)
{
(void)track;
(void)looping;
}
boolean I_SetVolumeCD(int volume)
{
(void)volume;
return false;
}
-25
View File
@@ -1,25 +0,0 @@
#include "../doomdef.h"
#include "../d_main.h"
#include "../m_argv.h"
#include "../i_system.h"
int main(int argc, char **argv)
{
myargc = argc;
myargv = argv; /// \todo pull out path to exe from this string
CONS_Printf("I_StartupSystem...");
I_StartupSystem();
// startup SRB2
CONS_Printf("Setting up SRB2...\n");
D_SRB2Main();
CONS_Printf("Entering main game loop...\n");
// never return
D_SRB2Loop();
// return to OS
#ifndef __GNUC__
return 0;
#endif
}
-6
View File
@@ -1,6 +0,0 @@
#include "../i_net.h"
boolean I_InitNetwork(void)
{
return false;
}
-151
View File
@@ -1,151 +0,0 @@
#include "../i_sound.h"
UINT8 sound_started = 0;
void *I_GetSfx(sfxinfo_t *sfx)
{
(void)sfx;
return NULL;
}
void I_FreeSfx(sfxinfo_t *sfx)
{
(void)sfx;
}
void I_StartupSound(void){}
void I_ShutdownSound(void){}
//
// SFX I/O
//
INT32 I_StartSound(sfxenum_t id, INT32 vol, INT32 sep, INT32 pitch, INT32 priority, INT32 channel)
{
(void)id;
(void)vol;
(void)sep;
(void)pitch;
(void)priority;
(void)channel;
return -1;
}
void I_StopSound(INT32 handle)
{
(void)handle;
}
INT32 I_SoundIsPlaying(INT32 handle)
{
(void)handle;
return false;
}
void I_UpdateSoundParams(INT32 handle, INT32 vol, INT32 sep, INT32 pitch)
{
(void)handle;
(void)vol;
(void)sep;
(void)pitch;
}
void I_SetSfxVolume(INT32 volume)
{
(void)volume;
}
//
// MUSIC I/O
//
UINT8 music_started = 0;
void I_InitMusic(void){}
void I_ShutdownMusic(void){}
void I_PauseSong(INT32 handle)
{
(void)handle;
}
void I_ResumeSong(INT32 handle)
{
(void)handle;
}
//
// MIDI I/O
//
UINT8 midimusic_started = 0;
void I_InitMIDIMusic(void){}
void I_ShutdownMIDIMusic(void){}
void I_SetMIDIMusicVolume(INT32 volume)
{
(void)volume;
}
INT32 I_RegisterSong(void *data, size_t len)
{
(void)data;
(void)len;
return -1;
}
boolean I_PlaySong(INT32 handle, INT32 looping)
{
(void)handle;
(void)looping;
return false;
}
void I_StopSong(INT32 handle)
{
(void)handle;
}
void I_UnRegisterSong(INT32 handle)
{
(void)handle;
}
//
// DIGMUSIC I/O
//
UINT8 digmusic_started = 0;
void I_InitDigMusic(void){}
void I_ShutdownDigMusic(void){}
boolean I_StartDigSong(const char *musicname, INT32 looping)
{
(void)musicname;
(void)looping;
return false;
}
void I_StopDigSong(void){}
void I_SetDigMusicVolume(INT32 volume)
{
(void)volume;
}
boolean I_SetSongSpeed(float speed)
{
(void)speed;
return false;
}
boolean I_SetSongTrack(int track)
{
(void)track;
return false;
}
-286
View File
@@ -1,286 +0,0 @@
#include <nds.h>
#include <fat.h>
#include "../doomdef.h"
#include "../d_main.h"
#include "../i_system.h"
#include "../i_joy.h"
UINT8 graphics_started = 0;
UINT8 keyboard_started = 0;
static volatile tic_t ticcount;
UINT32 I_GetFreeMem(UINT32 *total)
{
*total = 0;
return 0;
}
tic_t I_GetTime(void)
{
return ticcount;
}
void I_Sleep(void){}
void I_GetEvent(void)
{
// Mappings of DS keys to SRB2 keys
UINT32 dskeys[] =
{
KEY_A,
KEY_B,
KEY_X,
KEY_Y,
KEY_L,
KEY_R,
KEY_START,
KEY_SELECT
};
event_t event;
UINT32 held, up, down;
UINT32 i;
// Check how the state has changed since last time
scanKeys();
// For the d-pad, we only care about the current state
held = keysHeld();
event.type = ev_joystick;
event.data1 = 0; // First (and only) axis set
if (held & KEY_LEFT) event.data2 = -1;
else if (held & KEY_RIGHT) event.data2 = 1;
else event.data2 = 0;
if (held & KEY_UP) event.data3 = -1;
else if (held & KEY_DOWN) event.data3 = 1;
else event.data3 = 0;
D_PostEvent(&event);
// For the buttons, we need to report changes in state
up = keysUp();
down = keysDown();
for (i = 0; i < sizeof(dskeys)/sizeof(dskeys[0]); i++)
{
// Has this button's state changed?
if ((up | down) & dskeys[i])
{
event.type = (up & dskeys[i]) ? ev_keyup : ev_keydown;
event.data1 = KEY_JOY1 + i;
D_PostEvent(&event);
}
}
}
void I_OsPolling(void)
{
I_GetEvent();
}
ticcmd_t *I_BaseTiccmd(void)
{
static ticcmd_t emptyticcmd;
return &emptyticcmd;
}
ticcmd_t *I_BaseTiccmd2(void)
{
static ticcmd_t emptyticcmd2;
return &emptyticcmd2;
}
void I_Quit(void)
{
exit(0);
}
void I_Error(const char *error, ...)
{
va_list argptr;
va_start(argptr, error);
viprintf(error, argptr);
va_end(argptr);
for(;;);
}
void I_Tactile(FFType Type, const JoyFF_t *Effect)
{
(void)Type;
(void)Effect;
}
void I_Tactile2(FFType Type, const JoyFF_t *Effect)
{
(void)Type;
(void)Effect;
}
void I_JoyScale(void){}
void I_JoyScale2(void){}
void I_InitJoystick(void)
{
Joystick.bGamepadStyle = true;
}
void I_InitJoystick2(void){}
INT32 I_NumJoys(void)
{
return 0;
}
const char *I_GetJoyName(INT32 joyindex)
{
(void)joyindex;
return NULL;
}
void I_SetupMumble(void)
{
}
#ifndef NOMUMBLE
void I_UpdateMumble(const mobj_t *mobj, const listener_t listener)
{
(void)mobj;
(void)listener;
}
#endif
void I_OutputMsg(const char *error, ...)
{
va_list argptr;
va_start(argptr, error);
viprintf(error, argptr);
va_end(argptr);
}
void I_StartupMouse(void){}
void I_StartupMouse2(void){}
void I_StartupKeyboard(void){}
INT32 I_GetKey(void)
{
return 0;
}
static void NDS_VBlankHandler(void)
{
ticcount++;
}
void I_StartupTimer(void)
{
irqSet(IRQ_VBLANK, NDS_VBlankHandler);
}
void I_AddExitFunc(void (*func)())
{
(void)func;
}
void I_RemoveExitFunc(void (*func)())
{
(void)func;
}
// Adapted in part from the devkitPro examples.
INT32 I_StartupSystem(void)
{
lcdMainOnTop();
videoSetModeSub(MODE_0_2D);
vramSetBankC(VRAM_C_MAIN_BG); // Get this mapped *out* of the sub BG
vramSetBankI(VRAM_I_SUB_BG_0x06208000);
// The background VRAM that's mapped starts at 0x06208000.
// The map base is specified in an offset of multiples of 2 KB
// from 0x06200000, and the tile base in multiples of 16 KB.
// We put the tiles at the start and the map 2 KB from the end
// (i.e. 14 KB from the start).
// The map base is then at 0x0620B800 = 0x06200000 + 16 * 0x800 + 7 * 0x800,
// and the tile base is at 0x06208000 = 0x06200000 + 2 * 0x4000.
consoleInit(NULL, 0, BgType_Text4bpp, BgSize_T_256x256, 16+7, 2, false, true);
// start FAT filesystem code, required for reading SD card
if(!fatInitDefault())
I_Error("Couldn't init FAT.");
return 0;
}
void I_ShutdownSystem(void){}
void I_GetDiskFreeSpace(INT64* freespace)
{
*freespace = 0;
}
char *I_GetUserName(void)
{
return NULL;
}
INT32 I_mkdir(const char *dirname, INT32 unixright)
{
(void)dirname;
(void)unixright;
return -1;
}
const CPUInfoFlags *I_CPUInfo(void)
{
return NULL;
}
const char *I_LocateWad(void)
{
return NULL;
}
void I_GetJoystickEvents(void){}
void I_GetJoystick2Events(void){}
void I_GetMouseEvents(void){}
char *I_GetEnv(const char *name)
{
(void)name;
return NULL;
}
INT32 I_PutEnv(char *variable)
{
(void)variable;
return -1;
}
INT32 I_ClipboardCopy(const char *data, size_t size)
{
(void)data;
(void)size;
return -1;
}
char *I_ClipboardPaste(void)
{
return NULL;
}
void I_RegisterSysCommands(void) {}
#include "../sdl/dosstr.c"
-148
View File
@@ -1,148 +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 SRB2 graphics stuff for NDS
#include "../doomdef.h"
#include "../command.h"
#include "../i_video.h"
#include "../hardware/hw_drv.h"
#include "../hardware/hw_main.h"
#include "r_nds3d.h"
rendermode_t rendermode = render_opengl;
boolean highcolor = false;
boolean allow_fullscreen = false;
consvar_t cv_vidwait = {"vid_wait", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL};
void I_StartupGraphics(void)
{
vid.width = 256;
vid.height = 192;
vid.bpp = 1;
vid.rowbytes = vid.width * vid.bpp;
vid.recalc = true;
HWD.pfnInit = NDS3D_Init;
HWD.pfnShutdown = NDS3D_Shutdown;
HWD.pfnFinishUpdate = NDS3D_FinishUpdate;
HWD.pfnDraw2DLine = NDS3D_Draw2DLine;
HWD.pfnDrawPolygon = NDS3D_DrawPolygon;
HWD.pfnSetBlend = NDS3D_SetBlend;
HWD.pfnClearBuffer = NDS3D_ClearBuffer;
HWD.pfnSetTexture = NDS3D_SetTexture;
HWD.pfnReadRect = NDS3D_ReadRect;
HWD.pfnGClipRect = NDS3D_GClipRect;
HWD.pfnClearMipMapCache = NDS3D_ClearMipMapCache;
HWD.pfnSetSpecialState = NDS3D_SetSpecialState;
HWD.pfnSetPalette = NDS3D_SetPalette;
HWD.pfnGetTextureUsed = NDS3D_GetTextureUsed;
HWD.pfnDrawMD2 = NDS3D_DrawMD2;
HWD.pfnDrawMD2i = NDS3D_DrawMD2i;
HWD.pfnSetTransform = NDS3D_SetTransform;
HWD.pfnGetRenderVersion = NDS3D_GetRenderVersion;
videoSetMode(MODE_0_3D);
vramSetBankA(VRAM_A_TEXTURE);
vramSetBankB(VRAM_B_TEXTURE);
vramSetBankC(VRAM_C_TEXTURE);
vramSetBankD(VRAM_D_TEXTURE);
vramSetBankE(VRAM_E_TEX_PALETTE);
glInit();
glEnable(GL_TEXTURE_2D);
glClearColor(16,16,16,31);
glClearPolyID(63);
glClearDepth(0x7FFF);
glViewport(0, 0, vid.width - 1, vid.height - 1);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluPerspective(fov, ASPECT_RATIO, NEAR_CLIPPING_PLANE, FAR_CLIPPING_PLANE);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glScalef(1.0f, 1.0f, -1.0f);
HWD.pfnInit(I_Error);
HWR_Startup();
}
void I_ShutdownGraphics(void){}
void I_SetPalette(RGBA_t *palette)
{
(void)palette;
}
INT32 VID_NumModes(void)
{
return 0;
}
INT32 VID_GetModeForSize(INT32 w, INT32 h)
{
(void)w;
(void)h;
return 0;
}
void VID_PrepareModeList(void){}
INT32 VID_SetMode(INT32 modenum)
{
(void)modenum;
return 0;
}
const char *VID_GetModeName(INT32 modenum)
{
(void)modenum;
return NULL;
}
void I_UpdateNoBlit(void){}
void I_FinishUpdate(void)
{
HWD.pfnFinishUpdate(true);
}
void I_UpdateNoVsync(void) {}
void I_WaitVBL(INT32 count)
{
(void)count;
}
void I_ReadScreen(UINT8 *scr)
{
(void)scr;
}
void I_BeginRead(void){}
void I_EndRead(void){}
-389
View File
@@ -1,389 +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 NDS 3D API for SRB2.
//
// In an ideal world, we would share as much code as possible with r_opengl.c,
// but this will do for now.
#include "../doomtype.h"
#include "../hardware/hw_defs.h"
#include "../hardware/hw_dll.h"
#include "../hardware/hw_md2.h"
#include "r_nds3d.h"
static I_Error_t I_Error_GL = NULL;
#define NOTEXTURE_NUM 0 // small white texture
#define FIRST_TEX_AVAIL (NOTEXTURE_NUM + 1)
#define MAX_SRB2_TEXTURES 256
FCOORD NEAR_CLIPPING_PLANE = 0.9f;
float fov = 90.0f;
static FBITFIELD CurrentPolyFlags = 0xFFFFFFFF;
static UINT32 CurrentGLPolyFmt = POLY_CULL_NONE;
static UINT8 CurrentPolyAlpha = 31;
static UINT16 myPaletteData[256];
static FTextureInfo* gr_cachetail = NULL;
static FTextureInfo* gr_cachehead = NULL;
static INT32 NextTexAvail = FIRST_TEX_AVAIL;
static UINT32 tex_downloaded = 0;
static INT32 texids[MAX_SRB2_TEXTURES];
static boolean scalehack = false;
static void GenerateTextureNames(void)
{
glGenTextures(MAX_SRB2_TEXTURES - 1, texids + 1);
texids[NOTEXTURE_NUM] = 0;
}
static void Flush(void)
{
// Delete all textures at once, since libnds's glDeleteTextures seems to be buggy.
glResetTextures();
GenerateTextureNames();
while (gr_cachehead)
{
gr_cachehead->downloaded = 0;
gr_cachehead = gr_cachehead->nextmipmap;
}
gr_cachetail = gr_cachehead = NULL;
NextTexAvail = FIRST_TEX_AVAIL;
tex_downloaded = 0;
}
static void SetNoTexture(void)
{
// Set small white texture.
if (tex_downloaded != NOTEXTURE_NUM)
{
glBindTexture(GL_TEXTURE_2D, texids[NOTEXTURE_NUM]);
tex_downloaded = NOTEXTURE_NUM;
}
}
static void SetAlpha(UINT8 alpha)
{
CurrentPolyAlpha = alpha >> 3;
glPolyFmt(CurrentGLPolyFmt | POLY_ALPHA(CurrentPolyAlpha));
}
boolean NDS3D_Init(I_Error_t ErrorFunction)
{
I_Error_GL = ErrorFunction;
glPolyFmt(CurrentGLPolyFmt | POLY_ALPHA(CurrentPolyAlpha));
GenerateTextureNames();
return true;
}
void NDS3D_Shutdown(void) {}
void NDS3D_SetPalette(RGBA_t *ppal, RGBA_t *pgamma)
{
INT32 i;
for (i = 0; i < 256; i++)
{
UINT8 red = (UINT8)min((ppal[i].s.red*pgamma->s.red)/127, 255) >> 3;
UINT8 green = (UINT8)min((ppal[i].s.green*pgamma->s.green)/127, 255) >> 3;
UINT8 blue = (UINT8)min((ppal[i].s.blue*pgamma->s.blue)/127, 255) >> 3;
myPaletteData[i] = ARGB16(ppal[i].s.alpha ? 1 : 0, red, green, blue);
}
Flush();
}
void NDS3D_FinishUpdate(INT32 waitvbl)
{
(void)waitvbl;
glFlush(0);
}
void NDS3D_Draw2DLine(F2DCoord *v1, F2DCoord *v2, RGBA_t Color)
{
(void)v1;
(void)v2;
(void)Color;
}
void NDS3D_DrawPolygon(FSurfaceInfo *pSurf, FOutVector *pOutVerts, FUINT iNumPts, FBITFIELD PolyFlags)
{
FUINT i;
NDS3D_SetBlend(PolyFlags);
// If Modulated, mix the surface colour to the texture
if ((CurrentPolyFlags & PF_Modulated) && pSurf)
{
glColor3b(pSurf->FlatColor.s.red, pSurf->FlatColor.s.green, pSurf->FlatColor.s.blue);
SetAlpha(pSurf->FlatColor.s.alpha);
}
// libnds doesn't have GL_TRIANGLE_FAN, so use GL_TRIANGLE_STRIP instead
glBegin(GL_TRIANGLE_STRIP);
for (i = 0; i < iNumPts; i++)
{
FUINT index = (i & 1) ? (i >> 1) : (iNumPts - 1 - (i >> 1));
FLOAT x, y, z;
if (scalehack)
{
x = pOutVerts[index].x/4096.0f;
y = pOutVerts[index].y/4096.0f;
z = pOutVerts[index].z/4096.0f;
}
else
{
x = pOutVerts[index].x;
y = pOutVerts[index].y;
z = pOutVerts[index].z;
}
glTexCoord2f(pOutVerts[index].s, pOutVerts[index].tow);
glVertex3f(x,y,z);
}
glEnd();
}
void NDS3D_SetBlend(FBITFIELD PolyFlags)
{
FBITFIELD Xor = PolyFlags ^ CurrentPolyFlags;
if (Xor & (PF_NoTexture|PF_Modulated))
{
if (Xor&PF_Modulated)
{
if(!(PolyFlags & PF_Modulated))
{
glColor3b(255, 255, 255);
CurrentPolyAlpha = 31;
}
}
if (PolyFlags & PF_NoTexture)
{
SetNoTexture();
}
}
CurrentPolyFlags = PolyFlags;
glPolyFmt(CurrentGLPolyFmt | POLY_ALPHA(CurrentPolyAlpha));
}
void NDS3D_ClearBuffer(FBOOLEAN ColorMask, FBOOLEAN DepthMask, FRGBAFloat *ClearColor)
{
(void)ClearColor;
if (ColorMask && ClearColor)
{
// TODO: Fixed-ify
glClearColor((uint8)(ClearColor->red*31),
(uint8)(ClearColor->green*31),
(uint8)(ClearColor->blue*31),
(uint8)(ClearColor->alpha*31));
}
if (DepthMask)
glClearDepth(GL_MAX_DEPTH);
NDS3D_SetBlend(DepthMask ? PF_Occlude | CurrentPolyFlags : CurrentPolyFlags&~PF_Occlude);
}
void NDS3D_SetTexture(FTextureInfo *TexInfo)
{
if (!TexInfo)
{
SetNoTexture();
return;
}
else if (TexInfo->downloaded)
{
if (TexInfo->downloaded != tex_downloaded)
{
glBindTexture(GL_TEXTURE_2D, texids[TexInfo->downloaded]);
tex_downloaded = TexInfo->downloaded;
}
}
else if (TexInfo->grInfo.data)
{
UINT8 wtype, htype;
INT32 texparam = GL_TEXTURE_COLOR0_TRANSPARENT;
// We rely on the numerical values of GL_TEXTURE_SIZE_ENUM here.
wtype = TEXTURE_SIZE_8;
while(TexInfo->width > 1 << (wtype + 3)) wtype++;
htype = TEXTURE_SIZE_8;
while(TexInfo->height > 1 << (htype + 3)) htype++;
TexInfo->downloaded = NextTexAvail++;
tex_downloaded = TexInfo->downloaded;
glBindTexture(GL_TEXTURE_2D, texids[TexInfo->downloaded]);
if(!glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB256, wtype, htype, 0, TEXGEN_TEXCOORD, TexInfo->grInfo.data))
{
// HACK: If we're out of memory, flush and try again.
// This will result in artefacts for one frame.
Flush();
TexInfo->downloaded = 0;
NDS3D_SetTexture(TexInfo);
return;
}
if (TexInfo->downloaded > FIRST_TEX_AVAIL)
{
// We already have a texture using the palette, so it's already in VRAM
glAssignColorTable(GL_TEXTURE_2D, texids[FIRST_TEX_AVAIL]);
}
else
{
// Generate the palette in hardware
glColorTableEXT(0, 0, 256, 0, 0, myPaletteData);
}
if (TexInfo->flags & TF_WRAPX)
texparam |= GL_TEXTURE_WRAP_S;
if (TexInfo->flags & TF_WRAPY)
texparam |= GL_TEXTURE_WRAP_T;
glTexParameter(0, texparam);
TexInfo->nextmipmap = NULL;
if (gr_cachetail)
{
gr_cachetail->nextmipmap = TexInfo;
gr_cachetail = TexInfo;
}
else
gr_cachetail = gr_cachehead = TexInfo;
}
}
void NDS3D_ReadRect(INT32 x, INT32 y, INT32 width, INT32 height, INT32 dst_stride, UINT16 *dst_data)
{
(void)x;
(void)y;
(void)width;
(void)height;
(void)dst_stride;
(void)dst_data;
}
void NDS3D_GClipRect(INT32 minx, INT32 miny, INT32 maxx, INT32 maxy, float nearclip)
{
(void)minx;
(void)miny;
(void)maxx;
(void)maxy;
//glViewport(minx, vid.height-maxy, maxx-minx, maxy-miny);
NEAR_CLIPPING_PLANE = nearclip;
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluPerspective(fov, ASPECT_RATIO, NEAR_CLIPPING_PLANE, FAR_CLIPPING_PLANE);
glMatrixMode(GL_MODELVIEW);
}
void NDS3D_ClearMipMapCache(void) {}
void NDS3D_SetSpecialState(hwdspecialstate_t IdState, INT32 Value)
{
(void)IdState;
(void)Value;
}
void NDS3D_DrawMD2(INT32 *gl_cmd_buffer, md2_frame_t *frame, FTransform *pos, float scale)
{
(void)gl_cmd_buffer;
(void)frame;
(void)pos;
(void)scale;
}
void NDS3D_DrawMD2i(INT32 *gl_cmd_buffer, md2_frame_t *frame, UINT32 duration, UINT32 tics, md2_frame_t *nextframe, FTransform *pos, float scale, UINT8 flipped, UINT8 *color)
{
(void)gl_cmd_buffer;
(void)frame;
(void)duration;
(void)tics;
(void)nextframe;
(void)pos;
(void)scale;
(void)flipped;
(void)color;
}
void NDS3D_SetTransform(FTransform *ptransform)
{
static INT32 special_splitscreen;
glLoadIdentity();
if (ptransform)
{
scalehack = true;
glScalef(ptransform->scalex*4096.0f, ptransform->scaley*4096.0f, -ptransform->scalez*4096.0f);
glRotatef(ptransform->anglex , 1.0f, 0.0f, 0.0f);
glRotatef(ptransform->angley+270.0f, 0.0f, 1.0f, 0.0f);
glTranslatef(-ptransform->x/4096.0f, -ptransform->z/4096.0f, -ptransform->y/4096.0f);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
special_splitscreen = (ptransform->splitscreen && ptransform->fovxangle == 90.0f);
if (special_splitscreen)
gluPerspective(53.13l, 2*ASPECT_RATIO, // 53.13 = 2*atan(0.5)
NEAR_CLIPPING_PLANE, FAR_CLIPPING_PLANE);
else
gluPerspective(ptransform->fovxangle, ASPECT_RATIO, NEAR_CLIPPING_PLANE, FAR_CLIPPING_PLANE);
glMatrixMode(GL_MODELVIEW);
}
else
{
scalehack = false;
glScalef(1.0f, 1.0f, -1.0f);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
if (special_splitscreen)
gluPerspective(53.13l, 2*ASPECT_RATIO, // 53.13 = 2*atan(0.5)
NEAR_CLIPPING_PLANE, FAR_CLIPPING_PLANE);
else
//Hurdler: is "fov" correct?
gluPerspective(fov, ASPECT_RATIO, NEAR_CLIPPING_PLANE, FAR_CLIPPING_PLANE);
glMatrixMode(GL_MODELVIEW);
}
}
INT32 NDS3D_GetTextureUsed(void)
{
return 0;
}
INT32 NDS3D_GetRenderVersion(void)
{
return 0;
}
-55
View File
@@ -1,55 +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 NDS 3D API for SRB2.
#ifndef __R_NDS3D__
#define __R_NDS3D__
#include "../doomtype.h"
#include "../hardware/hw_defs.h"
#include "../hardware/hw_dll.h"
#include "../hardware/hw_md2.h"
#define FAR_CLIPPING_PLANE 150000.0f
#define ASPECT_RATIO 1.0f
typedef float FCOORD;
extern FCOORD NEAR_CLIPPING_PLANE;
extern float fov;
boolean NDS3D_Init(I_Error_t ErrorFunction);
void NDS3D_Shutdown(void);
void NDS3D_SetPalette(RGBA_t *ppal, RGBA_t *pgamma);
void NDS3D_FinishUpdate(INT32 waitvbl);
void NDS3D_Draw2DLine(F2DCoord *v1, F2DCoord *v2, RGBA_t Color);
void NDS3D_DrawPolygon(FSurfaceInfo *pSurf, FOutVector *pOutVerts, FUINT iNumPts, FBITFIELD PolyFlags);
void NDS3D_SetBlend(FBITFIELD PolyFlags);
void NDS3D_ClearBuffer(FBOOLEAN ColorMask, FBOOLEAN DepthMask, FRGBAFloat *ClearColor);
void NDS3D_SetTexture(FTextureInfo *TexInfo);
void NDS3D_ReadRect(INT32 x, INT32 y, INT32 width, INT32 height, INT32 dst_stride, UINT16 *dst_data);
void NDS3D_GClipRect(INT32 minx, INT32 miny, INT32 maxx, INT32 maxy, float nearclip);
void NDS3D_ClearMipMapCache(void);
void NDS3D_SetSpecialState(hwdspecialstate_t IdState, INT32 Value);
void NDS3D_DrawMD2(INT32 *gl_cmd_buffer, md2_frame_t *frame, FTransform *pos, float scale);
void NDS3D_DrawMD2i(INT32 *gl_cmd_buffer, md2_frame_t *frame, UINT32 duration, UINT32 tics, md2_frame_t *nextframe, FTransform *pos, float scale, UINT8 flipped, UINT8 *color);
void NDS3D_SetTransform(FTransform *ptransform);
INT32 NDS3D_GetTextureUsed(void);
INT32 NDS3D_GetRenderVersion(void);
#endif
+1 -1
View File
@@ -71,7 +71,7 @@
#include <time.h>
#endif
#if defined (_WIN32) || defined (_WIN32_WCE)
#ifdef _WIN32
#include <malloc.h>
#include <math.h>
#endif
-4
View File
@@ -44,11 +44,7 @@
#endif
// Not sure if this is necessary, but it was in w_wad.c, so I'm putting it here too -Shadow Hog
#ifdef _WIN32_WCE
#define AVOID_ERRNO
#else
#include <errno.h>
#endif
mobj_t *skyboxmo[2];
+1 -1
View File
@@ -30,7 +30,7 @@
#include "hardware/hw_main.h"
#endif
#if defined (_WIN32) || defined (_WIN32_WCE)
#ifdef _WIN32
#include <malloc.h> // alloca(sizeof)
#endif
-5
View File
@@ -217,10 +217,6 @@ CV_PossibleValue_t Color_cons_t[MAXSKINCOLORS+1];
*/
void R_InitTranslationTables(void)
{
#ifdef _NDS
// Ugly temporary NDS hack.
transtables = (UINT8*)0x2000000;
#else
// Load here the transparency lookup tables 'TINTTAB'
// NOTE: the TINTTAB resource MUST BE aligned on 64k for the asm
// optimised code (in other words, transtables pointer low word is 0)
@@ -236,7 +232,6 @@ void R_InitTranslationTables(void)
W_ReadLump(W_GetNumForName("TRANS70"), transtables+0x60000);
W_ReadLump(W_GetNumForName("TRANS80"), transtables+0x70000);
W_ReadLump(W_GetNumForName("TRANS90"), transtables+0x80000);
#endif
}
+1 -16
View File
@@ -69,9 +69,7 @@ static void AmigaType_OnChange(void);
#define SURROUND
#endif
#if defined (_WIN32_WCE) || defined(GP2X)
consvar_t cv_samplerate = {"samplerate", "11025", 0, CV_Unsigned, NULL, 11025, NULL, NULL, 0, 0, NULL}; //Alam: For easy hacking?
#elif defined(_WINDOWS)
#ifdef _WINDOWS
consvar_t cv_samplerate = {"samplerate", "44100", 0, CV_Unsigned, NULL, 44100, NULL, NULL, 0, 0, NULL}; //Alam: For easy hacking?
#else
consvar_t cv_samplerate = {"samplerate", "22050", 0, CV_Unsigned, NULL, 22050, NULL, NULL, 0, 0, NULL}; //Alam: For easy hacking?
@@ -90,11 +88,7 @@ consvar_t cv_digmusicvolume = {"digmusicvolume", "18", CV_SAVE, soundvolume_cons
consvar_t cv_midimusicvolume = {"midimusicvolume", "18", CV_SAVE, soundvolume_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL};
#endif
// number of channels available
#if defined (_WIN32_WCE) || defined(GP2X)
consvar_t cv_numChannels = {"snd_channels", "8", CV_SAVE|CV_CALL, CV_Unsigned, SetChannelsNum, 0, NULL, NULL, 0, 0, NULL};
#else
consvar_t cv_numChannels = {"snd_channels", "64", CV_SAVE|CV_CALL, CV_Unsigned, SetChannelsNum, 0, NULL, NULL, 0, 0, NULL};
#endif
consvar_t surround = {"surround", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL};
//consvar_t cv_resetmusic = {"resetmusic", "No", CV_SAVE|CV_NOSHOWHELP, CV_YesNo, NULL, 0, NULL, NULL, 0, 0, NULL};
@@ -917,11 +911,9 @@ void S_SetSfxVolume(INT32 volume)
void S_ClearSfx(void)
{
#ifndef DJGPPDOS
size_t i;
for (i = 1; i < NUMSFX; i++)
I_FreeSfx(S_sfx + i);
#endif
}
static void S_StopChannel(INT32 cnum)
@@ -1735,10 +1727,6 @@ void S_ChangeMusicEx(const char *mmusic, UINT16 mflags, boolean looping, UINT32
{
char newmusic[7];
#if defined (_WIN32_WCE) || defined(GP2X)
S_ClearSfx();
#endif
if (S_MusicDisabled()
|| demo.rewinding // Don't mess with music while rewinding!
|| demo.title) // SRB2Kart: Demos don't interrupt title screen music
@@ -1890,11 +1878,8 @@ void S_SetMusicVolume(INT32 digvolume, INT32 seqvolume)
actualmidimusicvolume = cv_midimusicvolume.value; //check for change of var
#endif
#ifdef DJGPPDOS
digvolume = 31;
#ifndef NO_MIDI
seqvolume = 31;
#endif
#endif
switch(I_SongType())
Loaded 100 of 184 files, more files were not shown because too many files have changed in this diff. Show more