ended NDS

This commit is contained in:
Monster Iestyn 2017-09-29 22:48:14 +01:00
parent 497512ee52
commit be13f10626
27 changed files with 4 additions and 1279 deletions

View File

@ -104,12 +104,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
@ -172,18 +166,6 @@ ifdef MACOSX
UNIXCOMMON=1
endif
ifdef NDS
NOPNG=1
NONET=1
#NOHW=1
NOHS=1
NOASM=1
NOIPX=1
NONX86=1
OBJS+=$(OBJDIR)/i_video.o
LIBS+=-lm
endif
ifdef SDL
#SDL 2.0
ifndef SDL12
@ -508,10 +490,6 @@ ifdef SDL
all: pre-build $(BIN)/$(EXENAME)
endif
ifdef NDS
all: $(BIN)/$(EXENAME:.elf=.nds)
endif
ifdef DUMMY
all: $(BIN)/$(EXENAME)
endif
@ -728,13 +706,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

View File

@ -216,7 +216,6 @@ ifndef FREEBSD
ifndef CYGWIN32
ifndef MINGW
ifndef SDL
ifndef NDS
ifndef DUMMY
DJGPPDOS=1
endif
@ -226,7 +225,6 @@ endif
endif
endif
endif
endif
#determine the interface directory (where you put all i_*.c)
i_cdmus_o=$(OBJDIR)/i_cdmus.o
@ -328,13 +326,6 @@ ifdef WINCE
SDL12=1
OBJDIR:=$(OBJDIR)/WinCE
BIN:=$(BIN)/WinCE
else
ifdef NDS
INTERFACE=nds
OBJDIR:=$(OBJDIR)/nds
BIN:=$(BIN)/nds
NOUPX=1
endif
endif
endif
endif

View File

@ -44,10 +44,6 @@ static const UINT8 NOCLIMBBROWNS = (2*16);
static const UINT8 NOCLIMBYELLOWS = (11*16);
#ifdef _NDS
#undef BACKGROUND
#endif
// Automap colors
#define BACKGROUND DBLACK
#define YOURCOLORS DWHITE

View File

@ -244,17 +244,10 @@ INT32 cv_debug;
consvar_t cv_usemouse = {"use_mouse", "On", CV_SAVE|CV_CALL,usemouse_cons_t, I_StartupMouse, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_usemouse2 = {"use_mouse2", "Off", CV_SAVE|CV_CALL,usemouse_cons_t, I_StartupMouse2, 0, NULL, NULL, 0, 0, NULL};
#if defined (_NDS) //only one joystick
consvar_t cv_usejoystick = {"use_joystick", "1", CV_SAVE|CV_CALL, usejoystick_cons_t,
I_InitJoystick, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_usejoystick2 = {"use_joystick2", "0", CV_SAVE|CV_CALL, usejoystick_cons_t,
I_InitJoystick2, 0, NULL, NULL, 0, 0, NULL};
#else //all esle, no joystick
consvar_t cv_usejoystick = {"use_joystick", "0", CV_SAVE|CV_CALL, usejoystick_cons_t,
I_InitJoystick, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_usejoystick2 = {"use_joystick2", "0", CV_SAVE|CV_CALL, usejoystick_cons_t,
I_InitJoystick2, 0, NULL, NULL, 0, 0, NULL};
#endif
#if (defined (LJOYSTICK) || defined (HAVE_SDL))
#ifdef LJOYSTICK
consvar_t cv_joyport = {"joyport", "/dev/js0", CV_SAVE, joyport_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL};

View File

@ -548,19 +548,15 @@ extern const char *compdate, *comptime, *comprevision, *compbranch;
/// Most modifications should probably enable this.
//#define SAVEGAME_OTHERVERSIONS
#if !defined (_NDS)
/// Shuffle's incomplete OpenGL sorting code.
#define SHUFFLE // This has nothing to do with sorting, why was it disabled?
#endif
#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.

View File

@ -23,10 +23,6 @@
#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
@ -139,7 +135,7 @@ typedef long ssize_t;
#endif
#endif //macintosh
#if defined (PC_DOS) || defined (_WIN32) || defined (__HAIKU__) || defined(_NDS)
#if defined (PC_DOS) || defined (_WIN32) || defined (__HAIKU__)
#define HAVE_DOSSTR_FUNCS
#endif
@ -175,8 +171,6 @@ size_t strlcpy(char *dst, const char *src, size_t siz);
#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

View File

@ -286,17 +286,6 @@ static keyname_t keynames[] =
{KEY_2MOUSEWHEELUP, "Wheel 2 UP"},
{KEY_2MOUSEWHEELDOWN, "Wheel 2 Down"},
#if 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"},
@ -306,7 +295,6 @@ 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"},
@ -368,17 +356,6 @@ static keyname_t keynames[] =
{KEY_DBL2MOUSE1+6, "DBLSEC_MOUSE7"},
{KEY_DBL2MOUSE1+7, "DBLSEC_MOUSE8"},
#if 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"},
@ -387,7 +364,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"},
@ -635,22 +611,6 @@ INT32 G_KeyStringtoNum(const char *keystr)
return 0;
}
#if defined (_NDS)
void G_Controldefault(void)
{
gamecontrol[gc_fire ][0] = KEY_JOY1+2; //X
gamecontrol[gc_forward ][0] = KEY_UPARROW;
gamecontrol[gc_backward ][0] = KEY_DOWNARROW;
gamecontrol[gc_jump ][0] = KEY_JOY1+0; //A
gamecontrol[gc_use ][0] = KEY_JOY1+3; //Y
gamecontrol[gc_strafeleft ][0] = KEY_JOY1+4; //L
gamecontrol[gc_straferight][0] = KEY_JOY1+5; //R
gamecontrol[gc_turnleft ][0] = KEY_LEFTARROW;
gamecontrol[gc_turnright ][0] = KEY_RIGHTARROW;
gamecontrol[gc_pause ][0] = KEY_JOY1+6; //Start
gamecontrol[gc_weaponnext ][0] = KEY_JOY1+7; //Select
}
#else
void G_Controldefault(void)
{
gamecontrol[gc_forward ][0] = 'w';
@ -688,7 +648,6 @@ void G_Controldefault(void)
gamecontrol[gc_console ][0] = KEY_CONSOLE;
gamecontrol[gc_pause ][0] = KEY_PAUSE;
}
#endif
void G_SaveKeySetting(FILE *f)
{

View File

@ -41,14 +41,8 @@ typedef unsigned char FBOOLEAN;
// ==========================================================================
// byte value for paletted graphics, which represent the transparent color
#ifdef _NDS
// NDS is hardwired to use zero as transparent color
#define HWR_PATCHES_CHROMAKEY_COLORINDEX 0
#define HWR_CHROMAKEY_EQUIVALENTCOLORINDEX 1
#else
#define HWR_PATCHES_CHROMAKEY_COLORINDEX 255
#define HWR_CHROMAKEY_EQUIVALENTCOLORINDEX 130
#endif
// the chroma key color shows on border sprites, set it to black
#define HWR_PATCHES_CHROMAKEY_COLORVALUE (0x00000000) //RGBA format as in grSstWinOpen()

View File

@ -5726,12 +5726,8 @@ if (0)
HWD.pfnSetSpecialState(HWD_SET_FOG_MODE, 0); // Turn it off
}
#ifndef _NDS
if (drawsky)
HWR_DrawSkyBackground(player);
#else
(void)HWR_DrawSkyBackground;
#endif
//Hurdler: it doesn't work in splitscreen mode
drawsky = splitscreen;
@ -5970,12 +5966,8 @@ if (0)
HWD.pfnSetSpecialState(HWD_SET_FOG_MODE, 0); // Turn it off
}
#ifndef _NDS
if (!skybox && drawsky) // Don't draw the regular sky if there's a skybox
HWR_DrawSkyBackground(player);
#else
(void)HWR_DrawSkyBackground;
#endif
//Hurdler: it doesn't work in splitscreen mode
drawsky = splitscreen;
@ -6225,12 +6217,7 @@ 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;
}

View File

@ -22,9 +22,7 @@
#endif
#elif !defined (__DJGPP__)
#include <sys/socket.h>
#ifndef _NDS
#include <arpa/inet.h>
#endif
#include <netdb.h>
#endif

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)];

View File

@ -58,7 +58,7 @@ typedef off_t off64_t;
#if defined (_WIN32)
#define PRIdS "Iu"
#elif defined (DJGPP) || defined (_NDS)
#elif defined (DJGPP)
#define PRIdS "u"
#else
#define PRIdS "zu"

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

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

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
}

View File

@ -1,6 +0,0 @@
#include "../i_net.h"
boolean I_InitNetwork(void)
{
return false;
}

View File

@ -1,150 +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)
{
(void)id;
(void)vol;
(void)sep;
(void)pitch;
(void)priority;
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;
}

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"

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", "On", 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){}

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].sow, 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;
}

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

View File

@ -431,10 +431,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)
@ -450,7 +446,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
}

View File

@ -43,7 +43,7 @@
// we try to re-allocate a minimum of buffers for stability of the memory,
// so all the small-enough tables based on screen size, are allocated once
// and for all at the maximum size.
#if defined (_WIN32_WCE) || defined (_NDS)
#if defined (_WIN32_WCE)
#define MAXVIDWIDTH 320
#define MAXVIDHEIGHT 200
#else

View File

@ -159,12 +159,10 @@ angle_t FixedAngle(fixed_t fa)
}
#if !(defined _NDS) || !(defined NONET)
#include "t_ftan.c"
#include "t_fsin.c"
fixed_t *finecosine = &finesine[FINEANGLES/4];
#endif
#include "t_tan2a.c"

View File

@ -25,7 +25,6 @@
#define ANGLETOFINESHIFT 19 // 0x100000000 to 0x2000
#define FINEANGLE_C(x) ((FixedAngle((x)*FRACUNIT)>>ANGLETOFINESHIFT) & FINEMASK) // ((x*(ANGLE_45/45))>>ANGLETOFINESHIFT) & FINEMASK
#if !(defined _NDS) || !(defined NONET)
// Effective size is 10240.
extern fixed_t finesine[5*FINEANGLES/4];
@ -34,7 +33,6 @@ extern fixed_t *finecosine;
// Effective size is 4096.
extern fixed_t finetangent[FINEANGLES/2];
#endif
#define ANG1 0x00B60B61 //0.B6~
#define ANG2 0x016C16C1 //.6C1~
@ -112,17 +110,9 @@ void FM_Rotate(matrix_t *dest, angle_t angle, fixed_t x, fixed_t y, fixed_t z);
// The table values in tables.c are calculated with this many fractional bits.
#define FINE_FRACBITS 16
#if (defined _NDS) && (defined NONET)
// Use the NDS's trig functions. This would break netplay, so we only do
// it if NONET is defined.
#define FINESINE(n) ((fixed_t)sinLerp((INT16)(((INT32)(n))<<(ANGLETOFINESHIFT-17))) << (FRACBITS - 12))
#define FINECOSINE(n) ((fixed_t)cosLerp((INT16)(((INT32)(n))<<(ANGLETOFINESHIFT-17))) << (FRACBITS - 12))
#define FINETANGENT(n) ((fixed_t)tanLerp((INT16)(((INT32)(n)-(FINEANGLES>>2))<<(ANGLETOFINESHIFT-17))) << (FRACBITS - 12))
#else
// These macros should be used in case FRACBITS < FINE_FRACBITS.
#define FINESINE(n) (finesine[n]>>(FINE_FRACBITS-FRACBITS))
#define FINECOSINE(n) (finecosine[n]>>(FINE_FRACBITS-FRACBITS))
#define FINETANGENT(n) (finetangent[n]>>(FINE_FRACBITS-FRACBITS))
#endif
#endif

View File

@ -220,10 +220,6 @@ static void *xm(size_t size)
if (p == NULL)
{
#if defined (_NDS)
// Temporary-ish debugging measure
Command_Memfree_f();
#endif
I_Error("Out of memory allocating %s bytes", sizeu1(size));
}
}

View File

@ -116,10 +116,6 @@ char *Z_StrDup(const char *in);
#define Z_SetUser(p,u) Z_SetUser2(p, u)
#endif
#ifdef _NDS ///TODO: need a lock reference system
#define Z_Unlock(p) Z_ChangeTag(p, PU_CACHE_UNLOCKED)
#else
#define Z_Unlock(p) (void)p
#endif
#endif