다마고치 연구소 한국어판 소스 공개
Paramix Studio / build (push) Canceled after 0s
Paramix Studio / pages (push) Canceled after 0s

This commit is contained in:
syskiller committed 2026-11-10 21:17:44 +09:00
commit db23855630
661 files changed
+503597

No files matched your search

+90
View File
@@ -0,0 +1,90 @@
/**
* Doom Port to the nRF52840 by Nicola Wrachien (next-hack in the comments)
*
* This port is based on the excellent doomhack's GBA Doom Port,
* with Kippykip additions.
*
* Several data structures and functions have been optimized
* to fit in only 256kB RAM of nRF52840 (GBA has 384 kB RAM).
* Z-Depth Light has been restored with almost no RAM consumption!
* Tons of speed optimizations have been done, and the game now
* runs extremely fast, despite the much higher 3D resolution with
* respect to GBA.
*
* PrBoom: a Doom port merged with LxDoom and LSDLDoom
* based on BOOM, a modified and improved DOOM engine
* Copyright (C) 1999 by
* id Software, Chi Hoang, Lee Killough, Jim Flynn, Rand Phares, Ty Halderman
* Copyright (C) 1999-2000 by
* Jess Haas, Nicolas Kalkhof, Colin Phipps, Florian Schulze
* Copyright 2005, 2006 by
* Florian Schulze, Colin Phipps, Neil Stevens, Andrey Budko
* Copyright (C) 2021 Nicola Wrachien (next-hack in the comments)
* on nRF52840 port.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
* 02111-1307, USA.
*
* DESCRIPTION:
* AutoMap module.
*
*-----------------------------------------------------------------------------*/
#ifndef __AMMAP_H__
#define __AMMAP_H__
#include "d_event.h"
#define MAPBITS 12
#define FRACTOMAPBITS (FRACBITS-MAPBITS)
// Used by ST StatusBar stuff.
#define AM_MSGHEADER (('a'<<24)+('m'<<16))
#define AM_MSGENTERED (AM_MSGHEADER | ('e'<<8))
#define AM_MSGEXITED (AM_MSGHEADER | ('x'<<8))
// scale on entry
#define INITSCALEMTOF (.2*FRACUNIT)
// Called by main loop.
boolean AM_Responder(event_t *ev);
// Called by main loop.
void AM_Ticker(void);
// Called by main loop,
// called instead of view drawer if automap active.
void AM_Drawer(void);
// Called to force the automap to quit
// if the level is completed while it is up.
void AM_Stop(void);
// killough 2/22/98: for saving automap information in savegame:
extern void AM_Start(void);
//jff 4/16/98 make externally available
extern void AM_clearMarks(void);
typedef struct
{
fixed_t x, y;
} mpoint_t;
// end changes -- killough 2/22/98
#endif
+185
View File
@@ -0,0 +1,185 @@
/* config.h. Generated from config.h.in by configure. */
/* config.h.in. Generated from configure.ac by autoheader. */
#ifdef _MSC_VER
#define __WINS__
#endif
/* Uncomment this to exhaustively run memory checks while the game is running
(this is EXTREMELY slow). */
/* #undef CHECKHEAP */
/* Define for support for MBF helper dogs */
//#define DOGS 1
/* Define to be the path where Doom WADs are stored */
#define DOOMWADDIR "/usr/local/share/games/doom"
/* Define to 1 if you have the <asm/byteorder.h> header file. */
//#define HAVE_ASM_BYTEORDER_H 1
/* Define to 1 if you have the declaration of `sys_siglist', and to 0 if you
don't. */
//#define HAVE_DECL_SYS_SIGLIST 1
/* Define to 1 if you have the `getopt' function. */
//#define HAVE_GETOPT 1
/* Define to 1 if you have the `inet_aton' function. */
//#define HAVE_INET_ATON 1
/* Define to 1 if you have the `inet_ntop' function. */
//#define HAVE_INET_NTOP 1
/* Define to 1 if you have the `inet_pton' function. */
//#define HAVE_INET_PTON 1
/* Define to 1 if you have the <inttypes.h> header file. */
//#define HAVE_INTTYPES_H 1
/* Define if you have struct sockaddr_in6 */
//#define HAVE_IPv6 1
/* Define to 1 if you have the `m' library (-lm). */
//#define HAVE_LIBM 1
/* Define to 1 if you have the `png' library (-lpng). */
//#define HAVE_LIBPNG 1
/* Define to 1 if you have the `SDL_mixer' library (-lSDL_mixer). */
/* #undef HAVE_LIBSDL_MIXER */
/* Define if you have the SDL net library -lSDL_net */
/* #undef HAVE_LIBSDL_NET */
/* Define to 1 if you have the <memory.h> header file. */
#define HAVE_MEMORY_H 1
/* Define to 1 if you have the `mmap' function. */
//#define HAVE_MMAP 1
/* Define to 1 if you have the <sched.h> header file. */
//#define HAVE_SCHED_H 1
/* Define to 1 if you have the `sched_setaffinity' function. */
//#define HAVE_SCHED_SETAFFINITY 1
/* Define to 1 if you have the `SDL_JoystickGetAxis' function. */
//#define HAVE_SDL_JOYSTICKGETAXIS 1
/* Define to 1 if you have the `snprintf' function. */
//#define HAVE_SNPRINTF 1
/* Define to 1 if you have the <stdint.h> header file. */
//#define HAVE_STDINT_H 1
/* Define to 1 if you have the <stdlib.h> header file. */
#define HAVE_STDLIB_H 1
/* Define to 1 if you have the <strings.h> header file. */
//#define HAVE_STRINGS_H 1
/* Define to 1 if you have the <string.h> header file. */
#define HAVE_STRING_H 1
/* Define to 1 if you have the <sys/stat.h> header file. */
#define HAVE_SYS_STAT_H 1
/* Define to 1 if you have the <sys/types.h> header file. */
#define HAVE_SYS_TYPES_H 1
/* Define to 1 if you have <sys/wait.h> that is POSIX.1 compatible. */
#define HAVE_SYS_WAIT_H 1
/* Define to 1 if you have the <unistd.h> header file. */
//#define HAVE_UNISTD_H 1
/* Define to 1 if you have the `usleep' function. */
//#define HAVE_USLEEP 1
/* Define to 1 if you have the `vsnprintf' function. */
//#define HAVE_VSNPRINTF 1
/* Uncomment this to cause heap dumps to be generated. Only useful if
INSTRUMENTED is also defined. */
/* #undef HEAPDUMP */
/* Define for high resolution support */
//#define HIGHRES 1
/* Define on targets supporting 386 assembly */
//#define I386_ASM 1
/* Define this to see real-time memory allocation statistics, and enable extra
debugging features */
/* #undef INSTRUMENTED */
/* If your platform has a fast version of max, define MAX to it */
/* #undef MAX */
/* If your platform has a fast version of min, define MIN to it */
/* #undef MIN */
/* Define to the address where bug reports for this package should be sent. */
#define PACKAGE_BUGREPORT ""
/* Define to the full name of this package. */
#define PACKAGE_NAME "prboom"
/* Define to the full name and version of this package. */
#define PACKAGE_STRING "prboom 2.5.0"
/* Define to the one symbol short name of this package. */
#define PACKAGE_TARNAME "prboom"
/* Define to the version of this package. */
#define PACKAGE_VERSION "2.5.0"
/* Set to the attribute to apply to struct definitions to make them packed */
#ifndef __WINS__
#define PACKEDATTR __attribute__((packed))
#else
#define PACKEDATTR
#endif
/* Define to enable internal range checking */
/* Define to 1 if you have the ANSI C header files. */
#define STDC_HEADERS 1
/* Defining this causes time stamps to be created each time a lump is locked,
and lumps locked for long periods of time are reported */
/* #undef TIMEDIAG */
/* Define if you want to use gluImageScale */
//#define USE_GLU_IMAGESCALE 1
/* Define if you want to use gluBuild2DMipmaps */
//#define USE_GLU_MIPMAP 1
/* Define if you want to use the SDL net lib */
/* #undef USE_SDL_NET */
/* Version number of package */
#define VERSION "2.5.0"
/* Define if using the dmalloc debugging malloc package */
/* #undef WITH_DMALLOC */
/* Define to 1 if your processor stores words with the most significant byte
first (like Motorola and SPARC, unlike Intel and VAX). */
/* #undef WORDS_BIGENDIAN */
/* Define this to perform id checks on zone blocks, to detect corrupted and
illegally freed blocks */
#ifdef DEBUG
#define ZONEIDCHECK 1
#endif
/* Define to empty if `const' does not conform to ANSI C. */
/* #undef const */
/* Define to `int' if <sys/types.h> doesn't define. */
/* #undef gid_t */
/* Define to `__inline__' or `__inline' if that's what the C compiler
calls it, or to nothing if 'inline' is not supported under any name. */
//#ifndef __cplusplus
#ifdef __WINS__
#define inline __inline
#else
#define inline __inline__
#endif
/* Define to `unsigned int' if <sys/types.h> does not define. */
/* #undef size_t */
#ifdef __WINS__
#define strncasecmp _strnicmp
#define strcasecmp _stricmp
#endif
/* Define to strcasecmp, if we have it */
#define stricmp strcasecmp
/* Define to strncasecmp, if we have it */
#define strnicmp strncasecmp
/* Define to `int' if <sys/types.h> doesn't define. */
/* #undef uid_t */
+701
View File
@@ -0,0 +1,701 @@
/**
* Doom Port to the nRF52840 by Nicola Wrachien (next-hack in the comments)
*
* This port is based on the excellent doomhack's GBA Doom Port,
* with Kippykip additions.
*
* Several data structures and functions have been optimized
* to fit in only 256kB RAM of nRF52840 (GBA has 384 kB RAM).
* Z-Depth Light has been restored with almost no RAM consumption!
* Tons of speed optimizations have been done, and the game now
* runs extremely fast, despite the much higher 3D resolution with
* respect to GBA.
*
* PrBoom: a Doom port merged with LxDoom and LSDLDoom
* based on BOOM, a modified and improved DOOM engine
* Copyright (C) 1999 by
* id Software, Chi Hoang, Lee Killough, Jim Flynn, Rand Phares, Ty Halderman
* Copyright (C) 1999-2000 by
* Jess Haas, Nicolas Kalkhof, Colin Phipps, Florian Schulze
* Copyright 2005, 2006 by
* Florian Schulze, Colin Phipps, Neil Stevens, Andrey Budko
* Copyright (C) 2021 Nicola Wrachien (next-hack in the comments)
* on nRF52840 port.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
* 02111-1307, USA.
*
* DESCRIPTION:
* Printed strings for translation.
* English language support (default).
* See dstrings.h for suggestions about foreign language BEX support
*
*-----------------------------------------------------------------------------*/
#ifndef __D_ENGLSH__
#define __D_ENGLSH__
/* d_main.c */
#define D_DEVSTR "Development mode ON.\n"
#define D_CDROM "CD-ROM Version: default.cfg from c:\\doomdata\n"
/* m_menu.c */
#define PRESSKEY "press a key."
#define PRESSYN "FIRE to confirm."
#define QUITMSG "are you sure you want to\nquit this great game?"
#define LOADNET "you can't do load while in a net game!\n\n"PRESSKEY
#define QLOADNET "you can't quickload during a netgame!\n\n"PRESSKEY
#define QSAVESPOT "you haven't picked a quicksave slot yet!\n\n"PRESSKEY
#define SAVEDEAD "you can't save if\nyou aren't playing!\n\n"PRESSKEY
#define QSPROMPT "quicksave over your game named\n\n'%s'?\n\n"PRESSYN
#define QLPROMPT "do you want to quickload the game named\n\n'%s'?\n\n"PRESSYN
#define NEWGAME \
"you can't start a new game\n"\
"while in a network game.\n\n"PRESSKEY
#define NIGHTMARE \
"are you sure?\n this skill level\n"\
"isn't even\n remotely fair.\n\n"PRESSYN
#define SWSTRING \
"this is the\nshareware version\n"\
"of doom.\n You need to order\n"\
"the entire trilogy.\n\n"PRESSKEY
#define MSGOFF "Messages OFF"
#define MSGON "Messages ON"
#define RUNOFF "Take your time."
#define RUNON "In a hurry, marine?"
#define NETEND "you can't end a netgame!\n\n"PRESSKEY
#define ENDGAME "are you sure you want to\nend the game?\n\n"PRESSYN
#define RESTARTLEVEL "restart the level?\n\n"PRESSYN
#define DOSY "(press y to quit)"
#define DETAILHI "High detail"
#define DETAILLO "Low detail"
#define GAMMALVL0 "Gamma correction OFF"
//Unused ~Kippykip
//#define GAMMALVL1 "Gamma correction level 1"
//#define GAMMALVL2 "Gamma correction level 2"
//#define GAMMALVL3 "Gamma correction level 3"
//#define GAMMALVL4 "Gamma correction level 4"
#define GAMMALVL4 "Gamma correction ON"
#define EMPTYSTRING "empty slot"
/* p_inter.c */
#define GOTARMOR "Picked up the armor."
#define GOTMEGA "Picked up the MegaArmor!"
#define GOTHTHBONUS "Picked up a health bonus."
#define GOTARMBONUS "Picked up an armor bonus."
#define GOTSTIM "Picked up a stimpack."
#define GOTMEDIKIT "Picked up a medikit."
//#define GOTMEDINEED "Picked up a medikit that you REALLY need!" - String is too long for GBA res
#define GOTMEDINEED "Picked up a medikit."
#define GOTSUPER "Supercharge!"
#define GOTBLUECARD "Picked up a blue keycard."
#define GOTYELWCARD "Picked up a yellow keycard."
#define GOTREDCARD "Picked up a red keycard."
#define GOTBLUESKUL "Picked up a blue skull key."
#define GOTYELWSKUL "Picked up a yellow skull key."
#define GOTREDSKULL "Picked up a red skull key."
#define GOTINVUL "Invulnerability!"
#define GOTBERSERK "Berserk!"
#define GOTINVIS "Partial Invisibility"
#define GOTSUIT "Radiation Shielding Suit"
#define GOTMAP "Computer Area Map"
#define GOTVISOR "Light Amplification Visor"
#define GOTMSPHERE "MegaSphere!"
#define GOTCLIP "Picked up a clip."
#define GOTCLIPBOX "Picked up a box of bullets."
#define GOTROCKET "Picked up a rocket."
#define GOTROCKBOX "Picked up a box of rockets."
#define GOTCELL "Picked up an energy cell."
#define GOTCELLBOX "Picked up an energy cell pack."
#define GOTSHELLS "Picked up 4 shotgun shells."
#define GOTSHELLBOX "Picked up a box of shotgun shells."
#define GOTBACKPACK "Picked up a backpack full of ammo!"
#define GOTBFG9000 "You got the BFG9000! Oh, yes."
#define GOTCHAINGUN "You got the chaingun!"
#define GOTCHAINSAW "A chainsaw! Find some meat!"
#define GOTLAUNCHER "You got the rocket launcher!"
#define GOTPLASMA "You got the plasma gun!"
#define GOTSHOTGUN "You got the shotgun!"
#define GOTSHOTGUN2 "You got the super shotgun!"
/* p_doors.c */
#define PD_BLUEO "You need a blue key to activate this object"
#define PD_REDO "You need a red key to activate this object"
#define PD_YELLOWO "You need a yellow key to activate this object"
#define PD_BLUEK "You need a blue key to open this door"
#define PD_REDK "You need a red key to open this door"
#define PD_YELLOWK "You need a yellow key to open this door"
/* jff 02/05/98 Create messages specific to card and skull keys */
#define PD_BLUEC "You need a blue card to open this door"
#define PD_REDC "You need a red card to open this door"
#define PD_YELLOWC "You need a yellow card to open this door"
#define PD_BLUES "You need a blue skull to open this door"
#define PD_REDS "You need a red skull to open this door"
#define PD_YELLOWS "You need a yellow skull to open this door"
#define PD_ANY "Any key will open this door"
#define PD_ALL3 "You need all three keys to open this door"
#define PD_ALL6 "You need all six keys to open this door"
/* g_game.c */
#define GGSAVED "game saved."
/* hu_stuff.c */
#define HUSTR_MSGU "[Message unsent]"
#define HUSTR_E1M1 "E1M1: Hangar"
#define HUSTR_E1M2 "E1M2: Nuclear Plant"
#define HUSTR_E1M3 "E1M3: Toxin Refinery"
#define HUSTR_E1M4 "E1M4: Command Control"
#define HUSTR_E1M5 "E1M5: Phobos Lab"
#define HUSTR_E1M6 "E1M6: Central Processing"
#define HUSTR_E1M7 "E1M7: Computer Station"
#define HUSTR_E1M8 "E1M8: Phobos Anomaly"
#define HUSTR_E1M9 "E1M9: Military Base"
#define HUSTR_E2M1 "E2M1: Deimos Anomaly"
#define HUSTR_E2M2 "E2M2: Containment Area"
#define HUSTR_E2M3 "E2M3: Refinery"
#define HUSTR_E2M4 "E2M4: Deimos Lab"
#define HUSTR_E2M5 "E2M5: Command Center"
#define HUSTR_E2M6 "E2M6: Halls of the Damned"
#define HUSTR_E2M7 "E2M7: Spawning Vats"
#define HUSTR_E2M8 "E2M8: Tower of Babel"
#define HUSTR_E2M9 "E2M9: Fortress of Mystery"
#define HUSTR_E3M1 "E3M1: Hell Keep"
#define HUSTR_E3M2 "E3M2: Slough of Despair"
#define HUSTR_E3M3 "E3M3: Pandemonium"
#define HUSTR_E3M4 "E3M4: House of Pain"
#define HUSTR_E3M5 "E3M5: Unholy Cathedral"
#define HUSTR_E3M6 "E3M6: Mt. Erebus"
#define HUSTR_E3M7 "E3M7: Limbo"
#define HUSTR_E3M8 "E3M8: Dis"
#define HUSTR_E3M9 "E3M9: Warrens"
#define HUSTR_E4M1 "E4M1: Hell Beneath"
#define HUSTR_E4M2 "E4M2: Perfect Hatred"
#define HUSTR_E4M3 "E4M3: Sever The Wicked"
#define HUSTR_E4M4 "E4M4: Unruly Evil"
#define HUSTR_E4M5 "E4M5: They Will Repent"
#define HUSTR_E4M6 "E4M6: Against Thee Wickedly"
#define HUSTR_E4M7 "E4M7: And Hell Followed"
#define HUSTR_E4M8 "E4M8: Unto The Cruel"
#define HUSTR_E4M9 "E4M9: Fear"
#define HUSTR_1 "level 1: entryway"
#define HUSTR_2 "level 2: underhalls"
#define HUSTR_3 "level 3: the gantlet"
#define HUSTR_4 "level 4: the focus"
#define HUSTR_5 "level 5: the waste tunnels"
#define HUSTR_6 "level 6: the crusher"
#define HUSTR_7 "level 7: dead simple"
#define HUSTR_8 "level 8: tricks and traps"
#define HUSTR_9 "level 9: the pit"
#define HUSTR_10 "level 10: refueling base"
#define HUSTR_11 "level 11: 'o' of destruction!"
#define HUSTR_12 "level 12: the factory"
#define HUSTR_13 "level 13: downtown"
#define HUSTR_14 "level 14: the inmost dens"
#define HUSTR_15 "level 15: industrial zone"
#define HUSTR_16 "level 16: suburbs"
#define HUSTR_17 "level 17: tenements"
#define HUSTR_18 "level 18: the courtyard"
#define HUSTR_19 "level 19: the citadel"
#define HUSTR_20 "level 20: gotcha!"
#define HUSTR_21 "level 21: nirvana"
#define HUSTR_22 "level 22: the catacombs"
#define HUSTR_23 "level 23: barrels o' fun"
#define HUSTR_24 "level 24: the chasm"
#define HUSTR_25 "level 25: bloodfalls"
#define HUSTR_26 "level 26: the abandoned mines"
#define HUSTR_27 "level 27: monster condo"
#define HUSTR_28 "level 28: the spirit world"
#define HUSTR_29 "level 29: the living end"
#define HUSTR_30 "level 30: icon of sin"
#define HUSTR_31 "level 31: wolfenstein"
#define HUSTR_32 "level 32: grosse"
#define PHUSTR_1 "level 1: congo"
#define PHUSTR_2 "level 2: well of souls"
#define PHUSTR_3 "level 3: aztec"
#define PHUSTR_4 "level 4: caged"
#define PHUSTR_5 "level 5: ghost town"
#define PHUSTR_6 "level 6: baron's lair"
#define PHUSTR_7 "level 7: caughtyard"
#define PHUSTR_8 "level 8: realm"
#define PHUSTR_9 "level 9: abattoire"
#define PHUSTR_10 "level 10: onslaught"
#define PHUSTR_11 "level 11: hunted"
#define PHUSTR_12 "level 12: speed"
#define PHUSTR_13 "level 13: the crypt"
#define PHUSTR_14 "level 14: genesis"
#define PHUSTR_15 "level 15: the twilight"
#define PHUSTR_16 "level 16: the omen"
#define PHUSTR_17 "level 17: compound"
#define PHUSTR_18 "level 18: neurosphere"
#define PHUSTR_19 "level 19: nme"
#define PHUSTR_20 "level 20: the death domain"
#define PHUSTR_21 "level 21: slayer"
#define PHUSTR_22 "level 22: impossible mission"
#define PHUSTR_23 "level 23: tombstone"
#define PHUSTR_24 "level 24: the final frontier"
#define PHUSTR_25 "level 25: the temple of darkness"
#define PHUSTR_26 "level 26: bunker"
#define PHUSTR_27 "level 27: anti-christ"
#define PHUSTR_28 "level 28: the sewers"
#define PHUSTR_29 "level 29: odyssey of noises"
#define PHUSTR_30 "level 30: the gateway of hell"
#define PHUSTR_31 "level 31: cyberden"
#define PHUSTR_32 "level 32: go 2 it"
#define THUSTR_1 "level 1: system control"
#define THUSTR_2 "level 2: human bbq"
#define THUSTR_3 "level 3: power control"
#define THUSTR_4 "level 4: wormhole"
#define THUSTR_5 "level 5: hanger"
#define THUSTR_6 "level 6: open season"
#define THUSTR_7 "level 7: prison"
#define THUSTR_8 "level 8: metal"
#define THUSTR_9 "level 9: stronghold"
#define THUSTR_10 "level 10: redemption"
#define THUSTR_11 "level 11: storage facility"
#define THUSTR_12 "level 12: crater"
#define THUSTR_13 "level 13: nukage processing"
#define THUSTR_14 "level 14: steel works"
#define THUSTR_15 "level 15: dead zone"
#define THUSTR_16 "level 16: deepest reaches"
#define THUSTR_17 "level 17: processing area"
#define THUSTR_18 "level 18: mill"
#define THUSTR_19 "level 19: shipping/respawning"
#define THUSTR_20 "level 20: central processing"
#define THUSTR_21 "level 21: administration center"
#define THUSTR_22 "level 22: habitat"
#define THUSTR_23 "level 23: lunar mining project"
#define THUSTR_24 "level 24: quarry"
#define THUSTR_25 "level 25: baron's den"
#define THUSTR_26 "level 26: ballistyx"
#define THUSTR_27 "level 27: mount pain"
#define THUSTR_28 "level 28: heck"
#define THUSTR_29 "level 29: river styx"
#define THUSTR_30 "level 30: last call"
#define THUSTR_31 "level 31: pharaoh"
#define THUSTR_32 "level 32: caribbean"
#define HUSTR_CHATMACRO1 "I'm ready to kick butt!"
#define HUSTR_CHATMACRO2 "I'm OK."
#define HUSTR_CHATMACRO3 "I'm not looking too good!"
#define HUSTR_CHATMACRO4 "Help!"
#define HUSTR_CHATMACRO5 "You suck!"
#define HUSTR_CHATMACRO6 "Next time, scumbag..."
#define HUSTR_CHATMACRO7 "Come here!"
#define HUSTR_CHATMACRO8 "I'll take care of it."
#define HUSTR_CHATMACRO9 "Yes"
#define HUSTR_CHATMACRO0 "No"
#define HUSTR_TALKTOSELF1 "You mumble to yourself"
#define HUSTR_TALKTOSELF2 "Who's there?"
#define HUSTR_TALKTOSELF3 "You scare yourself"
#define HUSTR_TALKTOSELF4 "You start to rave"
#define HUSTR_TALKTOSELF5 "You've lost it..."
#define HUSTR_MESSAGESENT "[Message Sent]"
/* The following should NOT be changed unless it seems
* just AWFULLY necessary */
#define HUSTR_PLRGREEN "Player 1: "
#define HUSTR_PLRINDIGO "Player 2: "
#define HUSTR_PLRBROWN "Player 3: "
#define HUSTR_PLRRED "Player 4: "
#define HUSTR_KEYGREEN 'g'
#define HUSTR_KEYINDIGO 'i'
#define HUSTR_KEYBROWN 'b'
#define HUSTR_KEYRED 'r'
/* am_map.c */
#define AMSTR_FOLLOWON "Follow Mode ON"
#define AMSTR_FOLLOWOFF "Follow Mode OFF"
#define AMSTR_GRIDON "Grid ON"
#define AMSTR_GRIDOFF "Grid OFF"
#define AMSTR_MARKEDSPOT "Marked Spot"
#define AMSTR_MARKSCLEARED "All Marks Cleared"
#define AMSTR_ROTATEON "Rotate Mode ON"
#define AMSTR_ROTATEOFF "Rotate Mode OFF"
#define AMSTR_OVERLAYON "Overlay Mode ON"
#define AMSTR_OVERLAYOFF "Overlay Mode OFF"
/* st_stuff.c */
#define STSTR_MUS "Music Change"
#define STSTR_NOMUS "IMPOSSIBLE SELECTION"
#define STSTR_DQDON "Degreelessness Mode On"
#define STSTR_DQDOFF "Degreelessness Mode Off"
#define STSTR_KFAADDED "Very Happy Ammo Added"
#define STSTR_FAADDED "Ammo (no keys) Added"
#define STSTR_NCON "No Clipping Mode ON"
#define STSTR_NCOFF "No Clipping Mode OFF"
#define STSTR_BEHOLD "inVuln, Str, Inviso, Rad, Allmap, or Lite-amp"
#define STSTR_BEHOLDX "Power-up Toggled"
#define STSTR_CHOPPERS "... doesn't suck - GM"
#define STSTR_CLEV "Changing Level..."
#define STSTR_COMPON "Compatibility Mode On" /* phares */
#define STSTR_COMPOFF "Compatibility Mode Off" /* phares */
#define STSTR_ROCKETON "Enemy Rockets On"
#define STSTR_ROCKETOFF "Enemy Rockets Off"
#define STSTR_FPSON "FPS Counter On"
#define STSTR_FPSOFF "FPS Counter Off"
/* f_finale.c */
#define E1TEXT \
"Once you beat the big badasses\n"\
"and clean out the moon base\n"\
"you're supposed to win?\n"\
"Where's your ticket home?\n"\
"What the hell is this? It's not\n"\
"supposed to end this way!\n"\
"\n" \
"It stinks like rotten meat, but\n"\
"looks like the lost Deimos base.\n"\
"You're stuck on The Shores of\n"\
"Hell.\n"\
"The only way out is through."
#define E2TEXT \
"You've done it! The hideous\n"\
"cyber-demon that ruled the\n"\
"lost Deimos moon base has been\n"\
"slain and you are triumphant!\n"\
"But...where are you?\n"\
"You clamber to the edge of the\n"\
"moon and see the awful truth.\n" \
"\n"\
"Deimos floats above Hell itself!\n"\
"You've never heard of anyone\n"\
"escaping from Hell, but you'll\n"\
"make the bastards sorry they\n"\
"ever heard of you!"
#define E3TEXT \
"The loathsome spiderdemon that\n"\
"masterminded the invasion of the\n"\
"moon bases and caused so much\n"\
"death has had its ass kicked.\n"\
"\n"\
"A hidden doorway opens.\n"\
"You've proven too tough for\n"\
"Hell to contain, and now Hell at\n"\
"last plays fair -- you emerge\n"\
"from the door to see the green\n"\
"fields of Earth! Home at last.\n"
#define E4TEXT \
"the spider mastermind must have\n"\
"sent forth its legions of\n"\
"hellspawn before your final\n"\
"confrontation with that\n"\
"terrible beast from hell.\n"\
"but you stepped forward and\n"\
"brought eternal damnation\n"\
"and suffering upon the horde as\n"\
"a true hero would in the face\n"\
"of evil.\n"\
"besides, someone is gonna pay for\n"\
"what happened to daisy.\n"\
"next stop, hell on earth!"
/* after level 6, put this: */
#define C1TEXT \
"YOU HAVE ENTERED DEEPLY INTO\n"\
"THE INFESTED STARPORT. SOMETHING\n"\
"IS WRONG. THE MONSTERS HAVE\n"\
"BROUGHT THEIR OWN REALITY WITH\n"\
"THEM, AND THE STARPORT'S TECH\n" \
"IS BEING SUBVERTED BY THEM.\n" \
"AHEAD, YOU SEE AN OUTPOST OF\n"\
"HELL, A FORTIFIED ZONE. IF YOU\n"\
"CAN GET PAST YOU CAN PENETRATE\n"\
"INTO THE HAUNTED HEART OF THE\n"\
"STARBASE AND FIND THE SWITCH\n"\
"WHICH HOLDS EARTH'S POPULATION\n"\
"HOSTAGE."
/* After level 11, put this: */
#define C2TEXT \
"YOU HAVE WON! YOUR VICTORY HAS\n"\
"ENABLED HUMANKIND TO EVACUATE\n"\
"EARTH AND ESCAPE THE NIGHTMARE.\n"\
"NOW YOU ARE THE ONLY HUMAN LEFT.\n"\
"CANNIBALS, ALIENS AND EVIL\n"\
"SPIRITS ARE YOUR NEIGHBORS.\n"\
"BUT THEN, EARTH CONTROL BEAMS\n"\
"DOWN A MESSAGE: SENSORS HAVE\n"\
"LOCATED THE SOURCE OF THE ALIEN\n"\
"INVASION. THE ALIEN BASE IS IN\n"\
"THE HEART OF YOUR OWN HOME CITY.\n"\
"SLOWLY AND PAINFULLY YOU GET UP\n"\
"AND RETURN TO THE FRAY."
/* After level 20, put this: */
#define C3TEXT \
"YOU ARE AT THE CORRUPT HEART OF\n"\
"THE CITY, SURROUNDED BY THE\n"\
"CORPSES OF YOUR ENEMIES. YOU\n"\
"SEE NO WAY TO DESTROY THE\n"\
"CREATURES' ENTRYWAY ON THIS SIDE,\n"\
"SO YOU CLENCH YOUR TEETH AND\n"\
"PLUNGE THROUGH IT.\n"\
"\n"\
"THERE MUST BE A WAY TO CLOSE\n"\
"IT ON THE OTHER SIDE. WHAT DO\n"\
"YOU CARE IF YOU'VE GOT TO GO\n"\
"THROUGH HELL TO GET TO IT?"\
/* After level 29, put this: */
#define C4TEXT \
"THE HORRENDOUS VISAGE OF THE\n"\
"BIGGEST DEMON YOU'VE EVER SEEN\n"\
"CRUMBLES BEFORE YOU, AFTER YOU\n"\
"PUMP ROCKETS INTO HIS EXPOSED\n"\
"BRAIN. THE MONSTERS THRASHING\n"\
"LIMBS DEVASTATING UNTOLD MILES\n"\
"OF HELL'S SURFACE.\n"\
"YOU'VE DONE IT. THE INVASION IS\n"\
"OVER. HELL IS A WRECK.\n"\
"YOU BEGIN THE LONG TREK BACK\n"\
"HOME. REBUILDING EARTH WILL\n"\
"BE A LOT LESS FUN THAN\n"\
"RUINING IT WAS."
/* Before level 31, put this: */
#define C5TEXT \
"CONGRATULATIONS, YOU'VE FOUND\n"\
"THE SECRET LEVEL! LOOKS LIKE\n"\
"IT'S BEEN BUILT BY HUMANS,\n"\
"RATHER THAN DEMONS. YOU WONDER\n"\
"WHO THE INMATES OF THIS CORNER\n"\
"OF HELL WILL BE."
/* Before level 32, put this: */
#define C6TEXT \
"CONGRATULATIONS, YOU'VE FOUND\n"\
"THE SUPER SECRET LEVEL!\n"\
"YOU'D BETTER BLAZE THROUGH\n"\
"THIS ONE!"
/*** Plutonia ***/
/* after map 06 */
#define P1TEXT \
"You gloat over the steaming carcass of the\n"\
"Guardian. With its death, you've wrested\n"\
"the Accelerator from the stinking claws\n"\
"of Hell. You relax and glance around the\n"\
"room. Damn! There was supposed to be at\n"\
"least one working prototype, but you can't\n"\
"see it. The demons must have taken it.\n"\
"\n"\
"You must find the prototype, or all your\n"\
"struggles will have been wasted. Keep\n"\
"moving, keep fighting, keep killing.\n"\
"Oh yes, keep living, too."
/* after map 11 */
#define P2TEXT \
"Even the deadly Arch-Vile labyrinth could\n"\
"not stop you, and you've gotten to the\n"\
"prototype Accelerator which is soon\n"\
"efficiently and permanently deactivated.\n"\
"\n"\
"You're good at that kind of thing."
/* after map 20 */
#define P3TEXT \
"You've bashed and battered your way into\n"\
"the heart of the devil-hive. Time for a\n"\
"Search-and-Destroy mission, aimed at the\n"\
"Gatekeeper, whose foul offspring is\n"\
"cascading to Earth. Yeah, he's bad. But\n"\
"you know who's worse!\n"\
"\n"\
"Grinning evilly, you check your gear, and\n"\
"get ready to give the bastard a little Hell\n"\
"of your own making!"
/* after map 30 */
#define P4TEXT \
"The Gatekeeper's evil face is splattered\n"\
"all over the place. As its tattered corpse\n"\
"collapses, an inverted Gate forms and\n"\
"sucks down the shards of the last\n"\
"prototype Accelerator, not to mention the\n"\
"few remaining demons. You're done. Hell\n"\
"has gone back to pounding bad dead folks \n"\
"instead of good live ones. Remember to\n"\
"tell your grandkids to put a rocket\n"\
"launcher in your coffin. If you go to Hell\n"\
"when you die, you'll need it for some\n"\
"final cleaning-up ..."
/* before map 31 */
#define P5TEXT \
"You've found the second-hardest level we\n"\
"got. Hope you have a saved game a level or\n"\
"two previous. If not, be prepared to die\n"\
"aplenty. For master marines only."
/* before map 32 */
#define P6TEXT \
"Betcha wondered just what WAS the hardest\n"\
"level we had ready for ya? Now you know.\n"\
"No one gets out alive."
/*** TNT: Evilution ***/
#define T1TEXT \
"You've fought your way out of the infested\n"\
"experimental labs. It seems that UAC has\n"\
"once again gulped it down. With their\n"\
"high turnover, it must be hard for poor\n"\
"old UAC to buy corporate health insurance\n"\
"nowadays..\n"\
"\n"\
"Ahead lies the military complex, now\n"\
"swarming with diseased horrors hot to get\n"\
"their teeth into you. With luck, the\n"\
"complex still has some warlike ordnance\n"\
"laying around."
#define T2TEXT \
"You hear the grinding of heavy machinery\n"\
"ahead. You sure hope they're not stamping\n"\
"out new hellspawn, but you're ready to\n"\
"ream out a whole herd if you have to.\n"\
"They might be planning a blood feast, but\n"\
"you feel about as mean as two thousand\n"\
"maniacs packed into one mad killer.\n"\
"\n"\
"You don't plan to go down easy."
#define T3TEXT \
"The vista opening ahead looks real damn\n"\
"familiar. Smells familiar, too -- like\n"\
"fried excrement. You didn't like this\n"\
"place before, and you sure as hell ain't\n"\
"planning to like it now. The more you\n"\
"brood on it, the madder you get.\n"\
"Hefting your gun, an evil grin trickles\n"\
"onto your face. Time to take some names."
#define T4TEXT \
"Suddenly, all is silent, from one horizon\n"\
"to the other. The agonizing echo of Hell\n"\
"fades away, the nightmare sky turns to\n"\
"blue, the heaps of monster corpses start \n"\
"to evaporate along with the evil stench \n"\
"that filled the air. Jeeze, maybe you've\n"\
"done it. Have you really won?\n"\
"\n"\
"Something rumbles in the distance.\n"\
"A blue light begins to glow inside the\n"\
"ruined skull of the demon-spitter."
#define T5TEXT \
"What now? Looks totally different. Kind\n"\
"of like King Tut's condo. Well,\n"\
"whatever's here can't be any worse\n"\
"than usual. Can it? Or maybe it's best\n"\
"to let sleeping gods lie.."
#define T6TEXT \
"Time for a vacation. You've burst the\n"\
"bowels of hell and by golly you're ready\n"\
"for a break. You mutter to yourself,\n"\
"Maybe someone else can kick Hell's ass\n"\
"next time around. Ahead lies a quiet town,\n"\
"with peaceful flowing water, quaint\n"\
"buildings, and presumably no Hellspawn.\n"\
"\n"\
"As you step off the transport, you hear\n"\
"the stomp of a cyberdemon's iron shoe."
/*
* Character cast strings F_FINALE.C
*/
#define CC_ZOMBIE "ZOMBIEMAN"
#define CC_SHOTGUN "SHOTGUN GUY"
#define CC_HEAVY "HEAVY WEAPON DUDE"
#define CC_IMP "IMP"
#define CC_DEMON "DEMON"
#define CC_LOST "LOST SOUL"
#define CC_CACO "CACODEMON"
#define CC_HELL "HELL KNIGHT"
#define CC_BARON "BARON OF HELL"
#define CC_ARACH "ARACHNOTRON"
#define CC_PAIN "PAIN ELEMENTAL"
#define CC_REVEN "REVENANT"
#define CC_MANCU "MANCUBUS"
#define CC_ARCH "ARCH-VILE"
#define CC_SPIDER "THE SPIDER MASTERMIND"
#define CC_CYBER "THE CYBERDEMON"
#define CC_HERO "OUR HERO"
#endif
+120
View File
@@ -0,0 +1,120 @@
/**
* Doom Port to the nRF52840 by Nicola Wrachien (next-hack in the comments)
*
* This port is based on the excellent doomhack's GBA Doom Port,
* with Kippykip additions.
*
* Several data structures and functions have been optimized
* to fit in only 256kB RAM of nRF52840 (GBA has 384 kB RAM).
* Z-Depth Light has been restored with almost no RAM consumption!
* Tons of speed optimizations have been done, and the game now
* runs extremely fast, despite the much higher 3D resolution with
* respect to GBA.
*
* PrBoom: a Doom port merged with LxDoom and LSDLDoom
* based on BOOM, a modified and improved DOOM engine
* Copyright (C) 1999 by
* id Software, Chi Hoang, Lee Killough, Jim Flynn, Rand Phares, Ty Halderman
* Copyright (C) 1999-2000 by
* Jess Haas, Nicolas Kalkhof, Colin Phipps, Florian Schulze
* Copyright 2005, 2006 by
* Florian Schulze, Colin Phipps, Neil Stevens, Andrey Budko
* Copyright (C) 2021 Nicola Wrachien (next-hack in the comments)
* on nRF52840 port.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
* 02111-1307, USA.
*
* DESCRIPTION:
* Event information structures.
*
*-----------------------------------------------------------------------------*/
#ifndef __D_EVENT__
#define __D_EVENT__
#include "doomtype.h"
//
// Event handling.
//
// Input event types.
typedef enum
{
ev_keydown, ev_keyup, ev_mouse, ev_joystick
} evtype_t;
// Event structure.
typedef struct
{
evtype_t type;
int data1; // keys / mouse/joystick buttons
int data2; // mouse/joystick x move
int data3; // mouse/joystick y move
} event_t;
typedef enum
{
ga_nothing,
ga_loadlevel,
ga_newgame,
ga_loadgame,
ga_savegame,
ga_playdemo,
ga_completed,
ga_victory,
ga_worlddone,
} gameaction_t;
//
// Button/action code definitions.
//
typedef enum
{
// Press "Fire".
BT_ATTACK = 1,
// Use button, to open doors, activate switches.
BT_USE = 2,
// Flag: game events, not really buttons.
BT_SPECIAL = 128,
BT_SPECIALMASK = 3,
// Flag, weapon change pending.
// If true, the next 4 bits hold weapon num.
BT_CHANGE = 4,
// The 4bit weapon mask and shift, convenience.
//BT_WEAPONMASK = (8+16+32),
BT_WEAPONMASK = (8 + 16 + 32 + 64), // extended to pick up SSG // phares
BT_WEAPONSHIFT = 3,
// Special events
BTS_LOADGAME = 0, // Loads a game
// Pause the game.
BTS_PAUSE = 1,
// Save the game at each console.
BTS_SAVEGAME = 2,
BTS_RESTARTLEVEL = 3, // Restarts the current level
// Savegame slot numbers occupy the second byte of buttons.
BTS_SAVEMASK = (4 + 8 + 16),
BTS_SAVESHIFT = 2,
} buttoncode_t;
#endif
+68
View File
@@ -0,0 +1,68 @@
/**
* Doom Port to the nRF52840 by Nicola Wrachien (next-hack in the comments)
*
* This port is based on the excellent doomhack's GBA Doom Port,
* with Kippykip additions.
*
* Several data structures and functions have been optimized
* to fit in only 256kB RAM of nRF52840 (GBA has 384 kB RAM).
* Z-Depth Light has been restored with almost no RAM consumption!
* Tons of speed optimizations have been done, and the game now
* runs extremely fast, despite the much higher 3D resolution with
* respect to GBA.
*
* PrBoom: a Doom port merged with LxDoom and LSDLDoom
* based on BOOM, a modified and improved DOOM engine
* Copyright (C) 1999 by
* id Software, Chi Hoang, Lee Killough, Jim Flynn, Rand Phares, Ty Halderman
* Copyright (C) 1999-2000 by
* Jess Haas, Nicolas Kalkhof, Colin Phipps, Florian Schulze
* Copyright 2005, 2006 by
* Florian Schulze, Colin Phipps, Neil Stevens, Andrey Budko
* Copyright (C) 2021 Nicola Wrachien (next-hack in the comments)
* on nRF52840 port.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
* 02111-1307, USA.
*
* DESCRIPTION:
* Items: key cards, artifacts, weapon, ammunition.
*
*-----------------------------------------------------------------------------*/
#ifndef __D_ITEMS__
#define __D_ITEMS__
#include "doomdef.h"
#ifdef __GNUG__
#pragma interface
#endif
/* Weapon info: sprite frames, ammunition use. */
typedef struct
{
ammotype_t ammo;
int upstate;
int downstate;
int readystate;
int atkstate;
int flashstate;
} weaponinfo_t;
extern const weaponinfo_t weaponinfo[NUMWEAPONS];
#endif
+77
View File
@@ -0,0 +1,77 @@
/**
* Doom Port to the nRF52840 by Nicola Wrachien (next-hack in the comments)
*
* This port is based on the excellent doomhack's GBA Doom Port,
* with Kippykip additions.
*
* Several data structures and functions have been optimized
* to fit in only 256kB RAM of nRF52840 (GBA has 384 kB RAM).
* Z-Depth Light has been restored with almost no RAM consumption!
* Tons of speed optimizations have been done, and the game now
* runs extremely fast, despite the much higher 3D resolution with
* respect to GBA.
*
* PrBoom: a Doom port merged with LxDoom and LSDLDoom
* based on BOOM, a modified and improved DOOM engine
* Copyright (C) 1999 by
* id Software, Chi Hoang, Lee Killough, Jim Flynn, Rand Phares, Ty Halderman
* Copyright (C) 1999-2000 by
* Jess Haas, Nicolas Kalkhof, Colin Phipps, Florian Schulze
* Copyright 2005, 2006 by
* Florian Schulze, Colin Phipps, Neil Stevens, Andrey Budko
* Copyright (C) 2021 Nicola Wrachien (next-hack in the comments)
* on nRF52840 port.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
* 02111-1307, USA.
*
* DESCRIPTION:
* Main startup and splash screenstuff.
*
*-----------------------------------------------------------------------------*/
#ifndef __D_MAIN__
#define __D_MAIN__
#include "d_event.h"
#include "w_wad.h"
#ifdef __GNUG__
#pragma interface
#endif
//jff end of external declaration of command line playmode
extern const boolean nosfxparm;
extern const boolean nomusicparm;
extern const boolean nodrawers;
// Called by IO functions when input is detected.
void D_PostEvent(event_t *ev);
// Demo stuff
void D_AdvanceDemo(void);
void D_DoAdvanceDemo(void);
//
// BASE LEVEL
//
void D_PageTicker(void);
void D_StartTitle(void);
void D_DoomMain(void);
void D_AddFile();
#endif
+62
View File
@@ -0,0 +1,62 @@
/**
* Doom Port to the nRF52840 by Nicola Wrachien (next-hack in the comments)
*
* This port is based on the excellent doomhack's GBA Doom Port,
* with Kippykip additions.
*
* Several data structures and functions have been optimized
* to fit in only 256kB RAM of nRF52840 (GBA has 384 kB RAM).
* Z-Depth Light has been restored with almost no RAM consumption!
* Tons of speed optimizations have been done, and the game now
* runs extremely fast, despite the much higher 3D resolution with
* respect to GBA.
*
* PrBoom: a Doom port merged with LxDoom and LSDLDoom
* based on BOOM, a modified and improved DOOM engine
* Copyright (C) 1999 by
* id Software, Chi Hoang, Lee Killough, Jim Flynn, Rand Phares, Ty Halderman
* Copyright (C) 1999-2000 by
* Jess Haas, Nicolas Kalkhof, Colin Phipps, Florian Schulze
* Copyright 2005, 2006 by
* Florian Schulze, Colin Phipps, Neil Stevens, Andrey Budko
* Copyright (C) 2021 Nicola Wrachien (next-hack in the comments)
* on nRF52840 port.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
* 02111-1307, USA.
*
* DESCRIPTION:
* Networking stuff.
*
*-----------------------------------------------------------------------------*/
#ifndef __D_NET__
#define __D_NET__
#include "d_player.h"
#ifdef __GNUG__
#pragma interface
#endif
void D_BuildNewTiccmds(void);
//? how many ticks to run?
void TryRunTics(void);
// CPhipps - move to header file
void D_InitNetGame(void); // This does the setup
#endif
+243
View File
@@ -0,0 +1,243 @@
/**
* Doom Port to the nRF52840 by Nicola Wrachien (next-hack in the comments)
*
* This port is based on the excellent doomhack's GBA Doom Port,
* with Kippykip additions.
*
* Several data structures and functions have been optimized
* to fit in only 256kB RAM of nRF52840 (GBA has 384 kB RAM).
* Z-Depth Light has been restored with almost no RAM consumption!
* Tons of speed optimizations have been done, and the game now
* runs extremely fast, despite the much higher 3D resolution with
* respect to GBA.
*
* PrBoom: a Doom port merged with LxDoom and LSDLDoom
* based on BOOM, a modified and improved DOOM engine
* Copyright (C) 1999 by
* id Software, Chi Hoang, Lee Killough, Jim Flynn, Rand Phares, Ty Halderman
* Copyright (C) 1999-2000 by
* Jess Haas, Nicolas Kalkhof, Colin Phipps, Florian Schulze
* Copyright 2005, 2006 by
* Florian Schulze, Colin Phipps, Neil Stevens, Andrey Budko
* Copyright (C) 2021 Nicola Wrachien (next-hack in the comments)
* on nRF52840 port.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
* 02111-1307, USA.
*
* DESCRIPTION:
* Player state structure.
*
*-----------------------------------------------------------------------------*/
#ifndef __D_PLAYER__
#define __D_PLAYER__
// The player data structure depends on a number
// of other structs: items (internal inventory),
// animation states (closely tied to the sprites
// used to represent them, unfortunately).
#include "d_items.h"
#include "p_pspr.h"
// In addition, the player is just a special
// case of the generic moving object/actor.
#include "p_mobj.h"
// Finally, for odd reasons, the player input
// is buffered within the player data struct,
// as commands per game tick.
#include "d_ticcmd.h"
#ifdef __GNUG__
#pragma interface
#endif
//
// Player states.
//
typedef enum
{
// Playing or camping.
PST_LIVE,
// Dead on the ground, view follows killer.
PST_DEAD,
// Ready to restart/respawn???
PST_REBORN
} playerstate_t;
//
// Player internal flags, for cheats and debug.
//
typedef enum
{
// No clipping, walk through barriers.
CF_NOCLIP = 1,
// No damage, no health loss.
CF_GODMODE = 2,
// Not really a cheat, just a debug aid.
CF_NOMOMENTUM = 4,
//You played goldeneye right?
CF_ENEMY_ROCKETS = 8
} cheat_t;
//
// Extended player object info: player_t
//
typedef struct player_s
{
mobj_t *mo;
playerstate_t playerstate;
ticcmd_t cmd;
// Determine POV,
// including viewpoint bobbing during movement.
// Focal origin above r.z
fixed_t viewz;
// Base height above floor for viewz.
fixed_t viewheight;
// Bob/squat speed.
fixed_t deltaviewheight;
// bounded/scaled total momentum.
fixed_t bob;
/* killough 10/98: used for realistic bobbing (i.e. not simply overall speed)
* mo->momx and mo->momy represent true momenta experienced by player.
* This only represents the thrust that the player applies himself.
* This avoids anomolies with such things as Boom ice and conveyors.
*/
fixed_t momx, momy; // killough 10/98
// This is only used between levels,
// mo->health is used during levels.
short health;
short armorpoints;
// Armor type is 0-2.
short armortype;
// Power ups. invinc and invis are tic counters.
short powers[NUMPOWERS];
boolean cards[NUMCARDS];
boolean backpack;
// Frags, kills of other players.
short frags[MAXPLAYERS];
short readyweapon;
// Is wp_nochange if not changing.
short pendingweapon;
short weaponowned[NUMWEAPONS];
short ammo[NUMAMMO];
short maxammo[NUMAMMO];
// True if button down last tic.
char attackdown;
char usedown;
// Bit flags, for cheats and debug.
// See cheat_t, above.
int cheats;
// Refired shots are less accurate.
char refire;
// For intermission stats.
short killcount;
short itemcount;
short secretcount;
// Hint messages. // CPhipps - const
const char *message;
// For screen flashing (red or bright).
short damagecount;
short bonuscount;
// Who did damage (NULL for floors/ceilings).
mobj_t *attacker;
// So gun flashes light up areas.
short extralight;
// Current PLAYPAL, ???
// can be set to REDCOLORMAP for pain, etc.
short fixedcolormap;
// Player skin colorshift,
// 0-3 for which color to draw player.
char colormap;
// Overlay view sprites (gun, etc).
pspdef_t psprites[NUMPSPRITES];
// True if secret level has been done.
boolean didsecret;
} player_t;
//
// INTERMISSION
// Structure passed e.g. to WI_Start(wb)
//
typedef struct
{
boolean in; // whether the player is in game
// Player stats, kills, collected items etc.
short skills;
short sitems;
short ssecret;
int stime;
short frags[4];
int score; // current score on entry, modified on return
} wbplayerstruct_t;
typedef struct
{
uint8_t epsd; // episode # (0-2)
// if true, splash the secret level
boolean didsecret;
// previous and next levels, origin 0
char last;
char next;
short maxkills;
short maxitems;
short maxsecret;
short maxfrags;
// the par time
int partime;
// index of this player in game
short pnum;
wbplayerstruct_t plyr[MAXPLAYERS];
// CPhipps - total game time for completed levels so far
int totaltimes;
} wbstartstruct_t;
#endif
+103
View File
@@ -0,0 +1,103 @@
/**
* Doom Port to the nRF52840 by Nicola Wrachien (next-hack in the comments)
*
* This port is based on the excellent doomhack's GBA Doom Port,
* with Kippykip additions.
*
* Several data structures and functions have been optimized
* to fit in only 256kB RAM of nRF52840 (GBA has 384 kB RAM).
* Z-Depth Light has been restored with almost no RAM consumption!
* Tons of speed optimizations have been done, and the game now
* runs extremely fast, despite the much higher 3D resolution with
* respect to GBA.
*
* PrBoom: a Doom port merged with LxDoom and LSDLDoom
* based on BOOM, a modified and improved DOOM engine
* Copyright (C) 1999 by
* id Software, Chi Hoang, Lee Killough, Jim Flynn, Rand Phares, Ty Halderman
* Copyright (C) 1999-2000 by
* Jess Haas, Nicolas Kalkhof, Colin Phipps, Florian Schulze
* Copyright 2005, 2006 by
* Florian Schulze, Colin Phipps, Neil Stevens, Andrey Budko
* Copyright (C) 2021 Nicola Wrachien (next-hack in the comments)
* on nRF52840 port.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
* 02111-1307, USA.
*
* DESCRIPTION:
* MapObj data. Map Objects or mobjs are actors, entities,
* thinker, take-your-pick... anything that moves, acts, or
* suffers state changes of more or less violent nature.
*
*-----------------------------------------------------------------------------*/
#ifndef __D_THINK__
#define __D_THINK__
#ifdef __GNUG__
#pragma interface
#endif
#include "doomdef.h"
/*
* Experimental stuff.
* To compile this as "ANSI C with classes"
* we will need to handle the various
* action functions cleanly.
*/
// killough 11/98: convert back to C instead of C++
typedef void (*actionf_t)();
//typedef void (*actionf_v)();
//typedef void (*actionf_p1)( void* );
//typedef void (*actionf_p2)( void*, void* );
/* Note: In d_deh.c you will find references to these
* wherever code pointers and function handlers exist
*/
/*
typedef union
{
actionf_p1 acp1;
actionf_v acv;
actionf_p2 acp2;
} actionf_t;
*/
/* Historically, "think_t" is yet another
* function pointer to a routine to handle
* an actor.
*/
typedef actionf_t think_t;
/* Doubly linked list of actors. */
typedef struct thinker_s
{
//struct thinker_s* prev;
unsigned short prev_sptr;
//struct thinker_s* next;
unsigned short next_sptr;
think_t function;
} thinker_t;
static inline thinker_t* getThinkerPrev(thinker_t *pthinker)
{
return (thinker_t*) getLongPtr(pthinker->prev_sptr);
}
static inline thinker_t* getThinkerNext(thinker_t *pthinker)
{
return (thinker_t*) getLongPtr(pthinker->next_sptr);
}
#endif
+70
View File
@@ -0,0 +1,70 @@
/**
* Doom Port to the nRF52840 by Nicola Wrachien (next-hack in the comments)
*
* This port is based on the excellent doomhack's GBA Doom Port,
* with Kippykip additions.
*
* Several data structures and functions have been optimized
* to fit in only 256kB RAM of nRF52840 (GBA has 384 kB RAM).
* Z-Depth Light has been restored with almost no RAM consumption!
* Tons of speed optimizations have been done, and the game now
* runs extremely fast, despite the much higher 3D resolution with
* respect to GBA.
*
* PrBoom: a Doom port merged with LxDoom and LSDLDoom
* based on BOOM, a modified and improved DOOM engine
* Copyright (C) 1999 by
* id Software, Chi Hoang, Lee Killough, Jim Flynn, Rand Phares, Ty Halderman
* Copyright (C) 1999-2000 by
* Jess Haas, Nicolas Kalkhof, Colin Phipps, Florian Schulze
* Copyright 2005, 2006 by
* Florian Schulze, Colin Phipps, Neil Stevens, Andrey Budko
* Copyright (C) 2021 Nicola Wrachien (next-hack in the comments)
* on nRF52840 port.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
* 02111-1307, USA.
*
* DESCRIPTION:
* System specific interface stuff.
*
*-----------------------------------------------------------------------------*/
#ifndef __D_TICCMD__
#define __D_TICCMD__
#include "doomtype.h"
#ifdef __GNUG__
#pragma interface
#endif
/* The data sampled per tick (single player)
* and transmitted to other peers (multiplayer).
* Mainly movements/button commands per game tick,
* plus a checksum for internal state consistency.
* CPhipps - explicitely signed the elements, since they have to be signed to work right
*/
typedef struct
{
signed char forwardmove; /* *2048 for move */
signed char sidemove; /* *2048 for move */
signed short angleturn; /* <<16 for angle delta */
short consistancy; /* checks for net game */
byte chatchar;
byte buttons;
} ticcmd_t;
#endif
+7
View File
@@ -0,0 +1,7 @@
#ifndef DOOM_IWAD_H
#define DOOM_IWAD_H
extern const unsigned char *doom_iwad;
extern const unsigned int *p_doom_iwad_len;
#endif // DOOM_IWAD_H
+227
View File
@@ -0,0 +1,227 @@
/**
* Doom Port to the nRF52840 by Nicola Wrachien (next-hack in the comments)
*
* This port is based on the excellent doomhack's GBA Doom Port,
* with Kippykip additions.
*
* Several data structures and functions have been optimized
* to fit in only 256kB RAM of nRF52840 (GBA has 384 kB RAM).
* Z-Depth Light has been restored with almost no RAM consumption!
* Tons of speed optimizations have been done, and the game now
* runs extremely fast, despite the much higher 3D resolution with
* respect to GBA.
*
* PrBoom: a Doom port merged with LxDoom and LSDLDoom
* based on BOOM, a modified and improved DOOM engine
* Copyright (C) 1999 by
* id Software, Chi Hoang, Lee Killough, Jim Flynn, Rand Phares, Ty Halderman
* Copyright (C) 1999-2000 by
* Jess Haas, Nicolas Kalkhof, Colin Phipps, Florian Schulze
* Copyright 2005, 2006 by
* Florian Schulze, Colin Phipps, Neil Stevens, Andrey Budko
* Copyright (C) 2021 Nicola Wrachien (next-hack in the comments)
* on nRF52840 port.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
* 02111-1307, USA.
*
* DESCRIPTION:
* all external data is defined here
* most of the data is loaded into different structures at run time
* some internal structures shared by many modules are here
*
*-----------------------------------------------------------------------------*/
#ifndef __DOOMDATA__
#define __DOOMDATA__
// The most basic types we use, portability.
#include "config.h"
#include "doomtype.h"
//
// Map level types.
// The following data structures define the persistent format
// used in the lumps of the WAD files.
//
// Lump order in a map WAD: each map needs a couple of lumps
// to provide a complete scene geometry description.
enum
{
ML_LABEL, // A separator, name, ExMx or MAPxx
ML_THINGS, // Monsters, items..
ML_LINEDEFS, // LineDefs, from editing
ML_SIDEDEFS, // SideDefs, from editing
ML_VERTEXES, // Vertices, edited and BSP splits generated
ML_SEGS, // LineSegs, from LineDefs split by BSP
ML_SSECTORS, // SubSectors, list of LineSegs
ML_NODES, // BSP nodes
ML_SECTORS, // Sectors, from editing
ML_REJECT, // LUT, sector-sector visibility
ML_BLOCKMAP // LUT, motion clipping, walls/grid element
};
#ifdef _MSC_VER // proff: This is the same as __attribute__ ((packed)) in GNUC
#pragma pack(push)
#pragma pack(1)
#endif //_MSC_VER
// A single Vertex.
typedef struct
{
short x, y;
} PACKEDATTR mapvertex_t;
// A SideDef, defining the visual appearance of a wall,
// by setting textures and offsets.
typedef struct
{
short textureoffset;
short rowoffset;
short toptexture;
short bottomtexture;
short midtexture;
short sector; // Front sector, towards viewer.
} PACKEDATTR mapsidedef_t;
// A LineDef, as used for editing, and as input to the BSP builder.
typedef struct
{
unsigned short v1;
unsigned short v2;
unsigned short flags;
short special;
short tag;
// proff 07/23/2006 - support more than 32768 sidedefs
// use the unsigned value and special case the -1
// sidenum[1] will be -1 (NO_INDEX) if one sided
unsigned short sidenum[2];
} PACKEDATTR maplinedef_t;
#define NO_INDEX ((unsigned short)-1)
//
// LineDef attributes.
//
// Solid, is an obstacle.
#define ML_BLOCKING 1
// Blocks monsters only.
#define ML_BLOCKMONSTERS 2
// Backside will not be drawn if not two sided.
#define ML_TWOSIDED 4
// If a texture is pegged, the texture will have
// the end exposed to air held constant at the
// top or bottom of the texture (stairs or pulled
// down things) and will move with a height change
// of one of the neighbor sectors.
// Unpegged textures always have the first row of
// the texture at the top pixel of the line for both
// top and bottom textures (use next to windows).
// upper texture unpegged
#define ML_DONTPEGTOP 8
// lower texture unpegged
#define ML_DONTPEGBOTTOM 16
// In AutoMap: don't map as two sided: IT'S A SECRET!
#define ML_SECRET 32
// Sound rendering: don't let sound cross two of these.
#define ML_SOUNDBLOCK 64
// Don't draw on the automap at all.
#define ML_DONTDRAW 128
// Set if already seen, thus drawn in automap.
#define ML_MAPPED 256
//jff 3/21/98 Set if line absorbs use by player
//allow multiple push/switch triggers to be used on one push
#define ML_PASSUSE 512
// Sector definition, from editing.
typedef struct
{
short floorheight;
short ceilingheight;
char floorpic[8];
char ceilingpic[8];
short lightlevel;
short special;
short tag;
} PACKEDATTR mapsector_t;
// SubSector, as generated by BSP.
typedef struct
{
unsigned short numsegs;
unsigned short firstseg; // Index of first one; segs are stored sequentially.
} PACKEDATTR mapsubsector_t;
// LineSeg, generated by splitting LineDefs
// using partition lines selected by BSP builder.
typedef struct
{
unsigned short v1;
unsigned short v2;
short angle;
unsigned short linedef;
short side;
short offset;
} PACKEDATTR mapseg_t;
// BSP node structure.
// Indicate a leaf.
#define NF_SUBSECTOR 0x8000
// Thing definition, position, orientation and type,
// plus skill/visibility flags and attributes.
typedef struct
{
short x;
short y;
short angle;
short type;
short options;
} PACKEDATTR mapthing_t;
#ifdef _MSC_VER
#pragma pack(pop)
#endif //_MSC_VER
//This is used at runtime so not packed.
//compiler uses byte access on packed structs.
typedef struct
{
short x; // Partition line from (x,y) to x+dx,y+dy)
short y;
short dx;
short dy;
// Bounding box for each child, clip against view frustum.
short bbox[2][4];
// If NF_SUBSECTOR its a subsector, else it's a node of another subtree.
unsigned short children[2];
} mapnode_t;
#endif // __DOOMDATA__
+317
View File
@@ -0,0 +1,317 @@
/**
* Doom Port to the nRF52840 by Nicola Wrachien (next-hack in the comments)
*
* This port is based on the excellent doomhack's GBA Doom Port,
* with Kippykip additions.
*
* Several data structures and functions have been optimized
* to fit in only 256kB RAM of nRF52840 (GBA has 384 kB RAM).
* Z-Depth Light has been restored with almost no RAM consumption!
* Tons of speed optimizations have been done, and the game now
* runs extremely fast, despite the much higher 3D resolution with
* respect to GBA.
*
* PrBoom: a Doom port merged with LxDoom and LSDLDoom
* based on BOOM, a modified and improved DOOM engine
* Copyright (C) 1999 by
* id Software, Chi Hoang, Lee Killough, Jim Flynn, Rand Phares, Ty Halderman
* Copyright (C) 1999-2000 by
* Jess Haas, Nicolas Kalkhof, Colin Phipps, Florian Schulze
* Copyright 2005, 2006 by
* Florian Schulze, Colin Phipps, Neil Stevens, Andrey Budko
* Copyright (C) 2021 Nicola Wrachien (next-hack in the comments)
* on nRF52840 port.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
* 02111-1307, USA.
*
* DESCRIPTION:
* Internally used data structures for virtually everything,
* key definitions, lots of other stuff.
*
*-----------------------------------------------------------------------------*/
#ifndef __DOOMDEF__
#define __DOOMDEF__
#include "main.h"
/* use config.h if autoconf made one -- josh */
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#define demo_compatibility 1
// killough 4/25/98: Make gcc extensions mean nothing on other compilers
#ifndef __GNUC__
#define __attribute__(x)
#endif
//
#define YCOORD_DATATYPE signed short
// This must come first, since it redefines malloc(), free(), etc. -- killough:
#include "z_zone.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <limits.h>
#include "printf.h"
// this should go here, not in makefile/configure.ac -- josh
#ifndef O_BINARY
#define O_BINARY 0
#endif
#include "m_swap.h"
#include "version.h"
#include "main.h"
#include "i_memory.h"
//
//
typedef unsigned angle_t;
// Game mode handling - identify IWAD version
// to handle IWAD dependend animations etc.
typedef enum
{
shareware, // DOOM 1 shareware, E1, M9
registered, // DOOM 1 registered, E3, M27
commercial, // DOOM 2 retail, E1 M34 (DOOM 2 german edition not handled)
retail, // DOOM 1 retail, E4, M36
indetermined // Well, no IWAD found.
} GameMode_t;
// Mission packs - might be useful for TC stuff?
typedef enum
{
doom, // DOOM 1
doom2, // DOOM 2
pack_tnt, // TNT mission pack
pack_plut, // Plutonia pack
none
} GameMission_t;
// Identify language to use, software localization.
typedef enum
{
english, french, german, unknown
} Language_t;
//
// For resize of screen, at start of game.
//
#define BASE_WIDTH 320
#define BASE_HEIGHT 200
// It is educational but futile to change this
// scaling e.g. to 2. Drawing of status bar,
// menues etc. is tied to the scale implied
// by the graphics.
#define INV_ASPECT_RATIO 0.625 /* 0.75, ideally */
// killough 2/8/98: MAX versions for maximum screen sizes
// allows us to avoid the overhead of dynamic allocation
// when multiple screen sizes are supported
// proff 08/17/98: Changed for high-res
#ifndef PDOOM_W
#define PDOOM_W 128
#define PDOOM_H 128
#endif
#define SCREENWIDTH_PHYSICAL PDOOM_W
#define MAX_SCREENHEIGHT PDOOM_H
// SCREENWIDTH and SCREENHEIGHT define the visible size
#define HIGHRES
#ifdef HIGHRES
#define MAX_SCREENWIDTH (SCREENWIDTH_PHYSICAL)
#else
#define MAX_SCREENWIDTH (SCREENWIDTH_PHYSICAL/2)
#endif
#define SCREENWIDTH MAX_SCREENWIDTH
#define SCREENHEIGHT MAX_SCREENHEIGHT
#define SCREENPITCH SCREENWIDTH //In pixels.
// SCREENPITCH is the size of one line in the buffer and
// can be bigger than the SCREENWIDTH depending on the size
// of one pixel (8, 16 or 32 bit) and the padding at the
// end of the line caused by hardware considerations
// The maximum number of players, multiplayer/networking.
#define MAXPLAYERS 1
// phares 5/14/98:
// DOOM Editor Numbers (aka doomednum in mobj_t)
#define DEN_PLAYER5 4001
#define DEN_PLAYER6 4002
#define DEN_PLAYER7 4003
#define DEN_PLAYER8 4004
// State updates, number of tics / second.
#define TICRATE 35
// The current state of the game: whether we are playing, gazing
// at the intermission screen, the game final animation, or a demo.
typedef enum
{
GS_LEVEL, GS_INTERMISSION, GS_FINALE, GS_DEMOSCREEN
} gamestate_t;
//
// Difficulty/skill settings/filters.
//
// These are Thing flags
// Skill flags.
#define MTF_EASY 1
#define MTF_NORMAL 2
#define MTF_HARD 4
// Deaf monsters/do not react to sound.
#define MTF_AMBUSH 8
/* killough 11/98 */
#define MTF_NOTSINGLE 16
#define MTF_NOTDM 32
#define MTF_NOTCOOP 64
#define MTF_FRIEND 128
#define MTF_RESERVED 256
typedef enum
{
sk_none = -1, //jff 3/24/98 create unpicked skill setting
sk_baby = 0,
sk_easy,
sk_medium,
sk_hard,
sk_nightmare
} skill_t;
//
// Key cards.
//
typedef enum
{
it_bluecard,
it_yellowcard,
it_redcard,
it_blueskull,
it_yellowskull,
it_redskull,
NUMCARDS
} card_t;
// The defined weapons, including a marker
// indicating user has not changed weapon.
typedef enum
{
wp_fist,
wp_pistol,
wp_shotgun,
wp_chaingun,
wp_missile,
wp_plasma,
wp_bfg,
wp_chainsaw,
wp_supershotgun,
NUMWEAPONS,
wp_nochange // No pending weapon change.
} weapontype_t;
// Ammunition types defined.
typedef enum
{
am_clip, // Pistol / chaingun ammo.
am_shell, // Shotgun / double barreled shotgun.
am_cell, // Plasma rifle, BFG.
am_misl, // Missile launcher.
NUMAMMO,
am_noammo // Unlimited for chainsaw / fist.
} ammotype_t;
// Power up artifacts.
typedef enum
{
pw_invulnerability,
pw_strength,
pw_invisibility,
pw_ironfeet,
pw_allmap,
pw_infrared,
NUMPOWERS
} powertype_t;
// Power up durations (how many seconds till expiration).
typedef enum
{
INVULNTICS = (30 * TICRATE),
INVISTICS = (60 * TICRATE),
INFRATICS = (120 * TICRATE),
IRONTICS = (60 * TICRATE)
} powerduration_t;
#include "keyboard.h"
//
#define KEYD_ALT 1
#define KEYD_FIRE 2
#define KEYD_USE 3
#define KEYD_CHGW 4
#define KEYD_CHGWDOWN 5
#define KEYD_UP 6
#define KEYD_DOWN 7
#define KEYD_LEFT 8
#define KEYD_RIGHT 9
#define KEYD_SL 10
#define KEYD_SR 11
#define KEYD_MENU 12
//
#define KEYD_MAP1 13
#define KEYD_SPEED 14
//
// phares 4/19/98:
// Defines Setup Screen groups that config variables appear in.
// Used when resetting the defaults for every item in a Setup group.
typedef enum
{
ss_none,
ss_keys,
ss_weap,
ss_stat,
ss_auto,
ss_enem,
ss_mess,
ss_chat,
ss_gen, /* killough 10/98 */
ss_comp, /* killough 10/98 */
ss_max
} ss_types;
typedef YCOORD_DATATYPE ycoord_t; //
// phares 3/20/98:
//
// Player friction is variable, based on controlling
// linedefs. More friction can create mud, sludge,
// magnetized floors, etc. Less friction can create ice.
#define MORE_FRICTION_MOMENTUM 15000 // mud factor based on momentum
#define ORIG_FRICTION 0xE800 // original value
#define ORIG_FRICTION_FACTOR 2048 // original value
#endif // __DOOMDEF__
+90
View File
@@ -0,0 +1,90 @@
/**
* Doom Port to the nRF52840 by Nicola Wrachien (next-hack in the comments)
*
* This port is based on the excellent doomhack's GBA Doom Port,
* with Kippykip additions.
*
* Several data structures and functions have been optimized
* to fit in only 256kB RAM of nRF52840 (GBA has 384 kB RAM).
* Z-Depth Light has been restored with almost no RAM consumption!
* Tons of speed optimizations have been done, and the game now
* runs extremely fast, despite the much higher 3D resolution with
* respect to GBA.
*
* PrBoom: a Doom port merged with LxDoom and LSDLDoom
* based on BOOM, a modified and improved DOOM engine
* Copyright (C) 1999 by
* id Software, Chi Hoang, Lee Killough, Jim Flynn, Rand Phares, Ty Halderman
* Copyright (C) 1999-2000 by
* Jess Haas, Nicolas Kalkhof, Colin Phipps, Florian Schulze
* Copyright 2005, 2006 by
* Florian Schulze, Colin Phipps, Neil Stevens, Andrey Budko
* Copyright (C) 2021 Nicola Wrachien (next-hack in the comments)
* on nRF52840 port.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
* 02111-1307, USA.
*
* DESCRIPTION:
* All the global variables that store the internal state.
* Theoretically speaking, the internal state of the engine
* should be found by looking at the variables collected
* here, and every relevant module will have to include
* this header file.
* In practice, things are a bit messy.
*
*-----------------------------------------------------------------------------*/
#ifndef __D_STATE__
#define __D_STATE__
// We need the playr data structure as well.
#include "d_player.h"
#ifdef __GNUG__
#pragma interface
#endif
// -------------------------------------------
// Selected skill type, map etc.
//
// Defaults for menu, methinks.
extern const skill_t startskill;
extern const int startepisode;
extern const int startmap;
// -------------------------
// Status flags for refresh.
//
enum automapmode_e
{
am_active = 1, // currently shown
am_overlay = 2, // covers the screen, i.e. not overlay mode
am_rotate = 4, // rotates to the player facing direction
am_follow = 8, // keep the player centred
am_grid = 16, // show grid
};
extern enum automapmode_e automapmode; // Mode that the automap is in
//-----------------------------------------
// Internal parameters, used for engine.
//
//-----------------------------------------------------------------------------
#endif
+123
View File
@@ -0,0 +1,123 @@
/**
* Doom Port to the nRF52840 by Nicola Wrachien (next-hack in the comments)
*
* This port is based on the excellent doomhack's GBA Doom Port,
* with Kippykip additions.
*
* Several data structures and functions have been optimized
* to fit in only 256kB RAM of nRF52840 (GBA has 384 kB RAM).
* Z-Depth Light has been restored with almost no RAM consumption!
* Tons of speed optimizations have been done, and the game now
* runs extremely fast, despite the much higher 3D resolution with
* respect to GBA.
*
* PrBoom: a Doom port merged with LxDoom and LSDLDoom
* based on BOOM, a modified and improved DOOM engine
* Copyright (C) 1999 by
* id Software, Chi Hoang, Lee Killough, Jim Flynn, Rand Phares, Ty Halderman
* Copyright (C) 1999-2000 by
* Jess Haas, Nicolas Kalkhof, Colin Phipps, Florian Schulze
* Copyright 2005, 2006 by
* Florian Schulze, Colin Phipps, Neil Stevens, Andrey Budko
* Copyright (C) 2021 Nicola Wrachien (next-hack in the comments)
* on nRF52840 port.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
* 02111-1307, USA.
*
* DESCRIPTION:
* Simple basic typedefs, isolated here to make it easier
* separating modules.
*
*-----------------------------------------------------------------------------*/
#ifndef __DOOMTYPE__
#define __DOOMTYPE__
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <stdbool.h>
#ifndef __BYTEBOOL__
#define __BYTEBOOL__
/* Fixed to use builtin bool type with C++. */
#if 0
#ifdef __cplusplus
typedef bool boolean;
#else
typedef enum {false, true} boolean;
#endif
#else
// next-hack
//typedef enum {false, true} boolean_t;
typedef unsigned char boolean;
#endif
typedef unsigned char byte;
#endif
// 2021-02-13 next-hack. Each pointer is 4 bytes long, and we use a lot of them.
// But since we will have less than 256kB of RAM, and since pointers to struct, int
// other zmalloc'ed things are 4-bytes aligned, we can just use one unsigned short
// In this way, we save 2 bytes per each pointer.
//e6y
#ifndef MAX
#define MAX(a,b) ((a)>(b)?(a):(b))
#endif
#ifndef MIN
#define MIN(a,b) ((a)<(b)?(a):(b))
#endif
/* cph - Wrapper for the long long type, as Win32 used a different name.
* Except I don't know what to test as it's compiler specific
* Proff - I fixed it */
#ifdef __WINS__
#define int_64_t __int64
#define uint_64_t unsigned __int64
#else
#define int_64_t long long
#define uint_64_t unsigned long long
#endif
//typedef _int64 int_64_t;
//typedef unsigned _int64 uint_64_t;
// define compiled-specific long-long contstant notation here
#define LONGLONG(num) (uint_64_t)num
#undef PATH_MAX
#define PATH_MAX 1024
#ifdef __GNUC__
#define CONSTFUNC
#define PUREFUNC
#define NORETURN __attribute__ ((noreturn))
#else
#define CONSTFUNC
#define PUREFUNC
#define NORETURN
#endif
/* CPhipps - use limits.h instead of depreciated values.h */
#include <limits.h>
/* cph - from v_video.h, needed by gl_struct.h */
enum patch_translation_e
{
VPT_NONE = 0, // Normal
VPT_FLIP = 1, // Flip image horizontally
VPT_TRANS = 2, // Translate image via a translation table
VPT_STRETCH = 4, // Stretch to compensate for high-res
};
#endif
+87
View File
@@ -0,0 +1,87 @@
/**
* Doom Port to the nRF52840 by Nicola Wrachien (next-hack in the comments)
*
* This port is based on the excellent doomhack's GBA Doom Port,
* with Kippykip additions.
*
* Several data structures and functions have been optimized
* to fit in only 256kB RAM of nRF52840 (GBA has 384 kB RAM).
* Z-Depth Light has been restored with almost no RAM consumption!
* Tons of speed optimizations have been done, and the game now
* runs extremely fast, despite the much higher 3D resolution with
* respect to GBA.
*
* PrBoom: a Doom port merged with LxDoom and LSDLDoom
* based on BOOM, a modified and improved DOOM engine
* Copyright (C) 1999 by
* id Software, Chi Hoang, Lee Killough, Jim Flynn, Rand Phares, Ty Halderman
* Copyright (C) 1999-2000 by
* Jess Haas, Nicolas Kalkhof, Colin Phipps, Florian Schulze
* Copyright 2005, 2006 by
* Florian Schulze, Colin Phipps, Neil Stevens, Andrey Budko
* Copyright (C) 2021 Nicola Wrachien (next-hack in the comments)
* on nRF52840 port.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
* 02111-1307, USA.
*
* DESCRIPTION:
* DOOM strings, by language.
* Note: In BOOM, some new strings have been defined that are
* not found in the French version. A better approach is
* to create a BEX text-replacement file for other
* languages since any language can be supported that way
* without recompiling the program.
*
*-----------------------------------------------------------------------------*/
#ifndef __DSTRINGS__
#define __DSTRINGS__
/* All important printed strings.
* Language selection (message strings).
* Use -DFRENCH etc.
*/
#ifdef FRENCH
#include "d_french.h"
#else
#include "d_englsh.h"
#endif
/* Note this is not externally modifiable through DEH/BEX
* Misc. other strings.
* #define SAVEGAMENAME "boomsav" * killough 3/22/98 *
* Ty 05/04/98 - replaced with a modifiable string, see d_deh.c
*/
/*
* File locations,
* relative to current position.
* Path names are OS-sensitive.
*/
#define DEVMAPS "devmaps"
#define DEVDATA "devdata"
/* Not done in french?
* QuitDOOM messages *
* killough 1/18/98:
* replace hardcoded limit with extern var (silly hack, I know)
*/
#include <stddef.h>
#endif
+66
View File
@@ -0,0 +1,66 @@
/**
* Doom Port to the nRF52840 by Nicola Wrachien (next-hack in the comments)
*
* This port is based on the excellent doomhack's GBA Doom Port,
* with Kippykip additions.
*
* Several data structures and functions have been optimized
* to fit in only 256kB RAM of nRF52840 (GBA has 384 kB RAM).
* Z-Depth Light has been restored with almost no RAM consumption!
* Tons of speed optimizations have been done, and the game now
* runs extremely fast, despite the much higher 3D resolution with
* respect to GBA.
*
* PrBoom: a Doom port merged with LxDoom and LSDLDoom
* based on BOOM, a modified and improved DOOM engine
* Copyright (C) 1999 by
* id Software, Chi Hoang, Lee Killough, Jim Flynn, Rand Phares, Ty Halderman
* Copyright (C) 1999-2000 by
* Jess Haas, Nicolas Kalkhof, Colin Phipps, Florian Schulze
* Copyright 2005, 2006 by
* Florian Schulze, Colin Phipps, Neil Stevens, Andrey Budko
* Copyright (C) 2021 Nicola Wrachien (next-hack in the comments)
* on nRF52840 port.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
* 02111-1307, USA.
*
* DESCRIPTION:
* Related to f_finale.c, which is called at the end of a level
*
*-----------------------------------------------------------------------------*/
#ifndef __F_FINALE__
#define __F_FINALE__
#include "doomtype.h"
#include "d_event.h"
/*
* FINALE
*/
/* Called by main loop. */
boolean F_Responder(event_t *ev);
/* Called by main loop. */
void F_Ticker(void);
/* Called by main loop. */
void F_Drawer(void);
void F_StartFinale(void);
#endif
+56
View File
@@ -0,0 +1,56 @@
/**
* Doom Port to the nRF52840 by Nicola Wrachien (next-hack in the comments)
*
* This port is based on the excellent doomhack's GBA Doom Port,
* with Kippykip additions.
*
* Several data structures and functions have been optimized
* to fit in only 256kB RAM of nRF52840 (GBA has 384 kB RAM).
* Z-Depth Light has been restored with almost no RAM consumption!
* Tons of speed optimizations have been done, and the game now
* runs extremely fast, despite the much higher 3D resolution with
* respect to GBA.
*
* PrBoom: a Doom port merged with LxDoom and LSDLDoom
* based on BOOM, a modified and improved DOOM engine
* Copyright (C) 1999 by
* id Software, Chi Hoang, Lee Killough, Jim Flynn, Rand Phares, Ty Halderman
* Copyright (C) 1999-2000 by
* Jess Haas, Nicolas Kalkhof, Colin Phipps, Florian Schulze
* Copyright 2005, 2006 by
* Florian Schulze, Colin Phipps, Neil Stevens, Andrey Budko
* Copyright (C) 2021 Nicola Wrachien (next-hack in the comments)
* on nRF52840 port.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
* 02111-1307, USA.
*
* DESCRIPTION:
* Mission start screen wipe/melt, special effects.
*
*-----------------------------------------------------------------------------*/
#ifndef __F_WIPE_H__
#define __F_WIPE_H__
#include <stdbool.h>
/*
* SCREEN WIPE PACKAGE
*/
void wipe_initMelt(short *y_lookup);
int wipe_ScreenWipe(int ticks, short *y_lookup);
int wipe_StartScreen(void);
int wipe_EndScreen(void);
#endif
+156
View File
@@ -0,0 +1,156 @@
/**
* Doom Port to the nRF52840 by Nicola Wrachien (next-hack in the comments)
*
* This port is based on the excellent doomhack's GBA Doom Port,
* with Kippykip additions.
*
* Several data structures and functions have been optimized
* to fit in only 256kB RAM of nRF52840 (GBA has 384 kB RAM).
* Z-Depth Light has been restored with almost no RAM consumption!
* Tons of speed optimizations have been done, and the game now
* runs extremely fast, despite the much higher 3D resolution with
* respect to GBA.
*
* PrBoom: a Doom port merged with LxDoom and LSDLDoom
* based on BOOM, a modified and improved DOOM engine
* Copyright (C) 1999 by
* id Software, Chi Hoang, Lee Killough, Jim Flynn, Rand Phares, Ty Halderman
* Copyright (C) 1999-2000 by
* Jess Haas, Nicolas Kalkhof, Colin Phipps, Florian Schulze
* Copyright 2005, 2006 by
* Florian Schulze, Colin Phipps, Neil Stevens, Andrey Budko
* Copyright (C) 2021 Nicola Wrachien (next-hack in the comments)
* on nRF52840 port.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
* 02111-1307, USA.
*
* DESCRIPTION: Main game control interface.
*-----------------------------------------------------------------------------*/
#ifndef __G_GAME__
#define __G_GAME__
#include "doomdef.h"
#include "d_event.h"
#include "d_ticcmd.h"
//
// GAME
//
// killough 5/2/98: number of bytes reserved for saving options
#define GAME_OPTION_SIZE 64
boolean G_Responder(event_t *ev);
boolean G_CheckDemoStatus(void);
void G_InitNew(skill_t skill, int episode, int map);
void G_DeferedInitNew(skill_t skill, int episode, int map);
void G_DeferedPlayDemo(const char *demo); // CPhipps - const
void G_LoadGame(int slot, boolean is_command); // killough 5/15/98
void G_ForcedLoadGame(void); // killough 5/15/98: forced loadgames
void G_DoLoadGame(void);
void G_SaveGame(int slot, const char *description); // Called by M_Responder.
void G_ExitLevel(void);
void G_SecretExitLevel(void);
void G_WorldDone(void);
void G_EndGame(void); /* cph - make m_menu.c call a G_* function for this */
void G_Ticker(void);
void G_ReloadDefaults(void); // killough 3/1/98: loads game defaults
void G_DoNewGame(void);
void G_DoReborn(int playernum);
void G_DoPlayDemo(void);
void G_DoCompleted(void);
void G_ReadDemoTiccmd(ticcmd_t *cmd);
void G_DoWorldDone(void);
void G_Compatibility(void);
const byte* G_ReadOptions(const byte *demo_p); /* killough 3/1/98 - cph: const byte* */
void G_PlayerReborn(int player);
void G_RestartLevel(void); // CPhipps - menu involked level restart
void G_DoVictory(void);
void G_BuildTiccmd(ticcmd_t *cmd); // CPhipps - move decl to header
void G_MakeSpecialEvent(buttoncode_t bc, ...); /* cph - new event stuff */
void G_UpdateSaveGameStrings();
void G_LoadSettings();
void G_SaveSettings();
// killough 5/2/98: moved from m_misc.c:
extern const int key_right;
extern const int key_left;
extern const int key_up;
extern const int key_down;
extern const int key_menu_right; // phares 3/7/98
extern const int key_menu_left; // |
extern const int key_menu_up; // V
extern const int key_menu_down;
extern const int key_menu_escape; // |
extern const int key_menu_enter; // phares 3/7/98
extern const int key_strafeleft;
extern const int key_straferight;
extern const int key_fire;
extern const int key_use;
extern const int key_strafe;
extern const int key_speed;
extern const int key_escape; // phares
extern const int key_savegame; // |
extern const int key_loadgame; // V
extern const int key_reverse;
extern const int key_zoomin;
extern const int key_zoomout;
extern const int key_chat;
extern const int key_backspace;
extern const int key_enter;
extern const int key_help;
extern const int key_soundvolume;
extern const int key_hud;
extern const int key_quicksave;
extern const int key_endgame;
extern const int key_messages;
extern const int key_quickload;
extern const int key_quit;
extern const int key_gamma;
extern const int key_spy;
extern const int key_pause;
extern const int key_setup;
extern const int key_forward;
extern const int key_leftturn;
extern const int key_rightturn;
extern const int key_backward;
extern const int key_map_right;
extern const int key_map_left;
extern const int key_map_up;
extern const int key_map_down;
extern const int key_map_zoomin;
extern const int key_map_zoomout;
extern const int key_map;
extern const int key_map_gobig;
extern const int key_map_follow;
extern const int key_map_mark; // ^
extern const int key_map_clear; // |
extern const int key_map_grid; // phares
// killough 5/2/98: moved from d_deh.c:
// Par times (new item with BOOM) - from g_game.c
extern const int pars[4][10]; // hardcoded array size
extern const int cpars[32]; // hardcoded array size
// CPhipps - Make savedesciption visible in wider scope
#define SAVEDESCLEN 8
#define NUMKEYS 16
#endif
File diff suppressed because it is too large. Load diff
+181
View File
@@ -0,0 +1,181 @@
/**
* Doom Port to the nRF52840 by Nicola Wrachien (next-hack in the comments)
*
* This port is based on the excellent doomhack's GBA Doom Port,
* with Kippykip additions.
*
* Several data structures and functions have been optimized
* to fit in only 256kB RAM of nRF52840 (GBA has 384 kB RAM).
* Z-Depth Light has been restored with almost no RAM consumption!
* Tons of speed optimizations have been done, and the game now
* runs extremely fast, despite the much higher 3D resolution with
* respect to GBA.
*
* PrBoom: a Doom port merged with LxDoom and LSDLDoom
* based on BOOM, a modified and improved DOOM engine
* Copyright (C) 1999 by
* id Software, Chi Hoang, Lee Killough, Jim Flynn, Rand Phares, Ty Halderman
* Copyright (C) 1999-2000 by
* Jess Haas, Nicolas Kalkhof, Colin Phipps, Florian Schulze
* Copyright 2005, 2006 by
* Florian Schulze, Colin Phipps, Neil Stevens, Andrey Budko
* Copyright (C) 2021 Nicola Wrachien (next-hack in the comments)
* on nRF52840 port.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
* 02111-1307, USA.
*
* DESCRIPTION: none
*
*-----------------------------------------------------------------------------*/
#ifndef __HULIB__
#define __HULIB__
// We are referring to patches.
#include "r_defs.h"
#include "v_video.h" //jff 2/16/52 include color range defs
/* background and foreground screen numbers
* different from other modules. */
#define HU_BG 0
#define HU_FG 0
/* font stuff
* #define HU_CHARERASE KEYD_BACKSPACE / not used / phares
*/
#define HU_MAXLINES 1
#define HU_MAXLINELENGTH 31
#define HU_REFRESHSPACING 8 /*jff 2/26/98 space lines in text refresh widget*/
/*jff 2/26/98 maximum number of messages allowed in refresh list */
#define HU_MAXMESSAGES 1
/*
* Typedefs of widgets
*/
/* Text Line widget
* (parent of Scrolling Text and Input Text widgets) */
typedef struct
{
// left-justified position of scrolling text window
short x;
short y;
const patch_t **f; // font
short sc; // start character
//const char *cr; //jff 2/16/52 output color range
// Proff - Made this an int again. Needed for OpenGL
// killough 1/23/98: Support multiple lines:
#define MAXLINES 1
short linelen;
char l[HU_MAXLINELENGTH * MAXLINES + 1]; // line of text
short len; // current line length
// whether this line needs to be udpated
short needsupdate;
} hu_textline_t;
// Scrolling Text window widget
// (child of Text Line widget)
typedef struct
{
hu_textline_t l[HU_MAXLINES]; // text lines to draw
short h; // height in lines
short cl; // current line number
// pointer to boolean stating whether to update window
boolean *on;
boolean laston; // last value of *->on.
} hu_stext_t;
//jff 2/26/98 new widget to display last hud_msg_lines of messages
// Message refresh window widget
typedef struct
{
hu_textline_t l[HU_MAXMESSAGES]; // text lines to draw
short nl; // height in lines
short nr; // total height in rows
short cl; // current line number
short x, y, w, h; // window position and size
const patch_t *bg; // patches for background
// pointer to boolean stating whether to update window
boolean *on;
boolean laston; // last value of *->on.
} hu_mtext_t;
// Input Text Line widget
// (child of Text Line widget)
typedef struct
{
hu_textline_t l; // text line to input on
// left margin past which I am not to delete characters
short lm;
// pointer to boolean stating whether to update window
boolean *on;
boolean laston; // last value of *->on;
} hu_itext_t;
//
// Widget creation, access, and update routines
//
//
// textline code
//
// clear a line of text
void HUlib_clearTextLine(hu_textline_t *t);
void HUlib_initTextLine(hu_textline_t *t, short x, short y, const patch_t *f, short sc);
// returns success
boolean HUlib_addCharToTextLine(hu_textline_t *t, char ch);
// draws tline
void HUlib_drawTextLine(hu_textline_t *l, boolean drawcursor);
// erases text line
void HUlib_eraseTextLine(hu_textline_t *l);
//
// Scrolling Text window widget routines
//
// initialize an stext widget
void HUlib_initSText(hu_stext_t *s, short x, short y, short h, const patch_t *font, short startchar, //jff 2/16/98 add color range parameter
boolean *on);
// add a text message to an stext widget
void HUlib_addMessageToSText(hu_stext_t *s, const char *prefix, const char *msg);
// draws stext
void HUlib_drawSText(hu_stext_t *s);
// erases all stext lines
void HUlib_eraseSText(hu_stext_t *s);
#endif
+87
View File
@@ -0,0 +1,87 @@
/**
* Doom Port to the nRF52840 by Nicola Wrachien (next-hack in the comments)
*
* This port is based on the excellent doomhack's GBA Doom Port,
* with Kippykip additions.
*
* Several data structures and functions have been optimized
* to fit in only 256kB RAM of nRF52840 (GBA has 384 kB RAM).
* Z-Depth Light has been restored with almost no RAM consumption!
* Tons of speed optimizations have been done, and the game now
* runs extremely fast, despite the much higher 3D resolution with
* respect to GBA.
*
* PrBoom: a Doom port merged with LxDoom and LSDLDoom
* based on BOOM, a modified and improved DOOM engine
* Copyright (C) 1999 by
* id Software, Chi Hoang, Lee Killough, Jim Flynn, Rand Phares, Ty Halderman
* Copyright (C) 1999-2000 by
* Jess Haas, Nicolas Kalkhof, Colin Phipps, Florian Schulze
* Copyright 2005, 2006 by
* Florian Schulze, Colin Phipps, Neil Stevens, Andrey Budko
* Copyright (C) 2021 Nicola Wrachien (next-hack in the comments)
* on nRF52840 port.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
* 02111-1307, USA.
*
* DESCRIPTION: Head up display
*
*-----------------------------------------------------------------------------*/
#ifndef __HU_STUFF_H__
#define __HU_STUFF_H__
#include "d_event.h"
/*
* Globally visible constants.
*/
#define HU_FONTSTART '!' /* the first font characters */
#define HU_FONTEND '_' /*jff 2/16/98 '_' the last font characters */
/* Calculate # of glyphs in font. */
#define HU_FONTSIZE (HU_FONTEND - HU_FONTSTART + 1)
#define HU_BROADCAST 5
/*#define HU_MSGREFRESH KEYD_ENTER phares */
#define HU_MSGX 0
#define HU_MSGY 0
#define HU_MSGWIDTH 64 /* in characters */
#define HU_MSGHEIGHT 1 /* in lines */
#define HU_MSGTIMEOUT (4*TICRATE)
/*
* Heads up text
*/
void HU_Init(void);
void HU_Start(void);
boolean HU_Responder(event_t *ev);
void HU_Ticker(void);
void HU_Drawer(void);
void HU_Erase(void);
void HU_MoveHud(void); // jff 3/9/98 avoid glitch in HUD display
/* killough 5/2/98: moved from m_misc.c: */
/* jff 2/26/98 hud message list color and background enable */
extern const int hud_msg_lines; /* number of message lines in window up to 16 */
/* jff 2/23/98 hud is currently displayed */
#endif
+52
View File
@@ -0,0 +1,52 @@
/**
* Doom Port to the nRF52840 by Nicola Wrachien (next-hack in the comments)
*
* This port is based on the excellent doomhack's GBA Doom Port,
* with Kippykip additions.
*
* Several data structures and functions have been optimized
* to fit in only 256kB RAM of nRF52840 (GBA has 384 kB RAM).
* Z-Depth Light has been restored with almost no RAM consumption!
* Tons of speed optimizations have been done, and the game now
* runs extremely fast, despite the much higher 3D resolution with
* respect to GBA.
*
* PrBoom: a Doom port merged with LxDoom and LSDLDoom
* based on BOOM, a modified and improved DOOM engine
* Copyright (C) 1999 by
* id Software, Chi Hoang, Lee Killough, Jim Flynn, Rand Phares, Ty Halderman
* Copyright (C) 1999-2000 by
* Jess Haas, Nicolas Kalkhof, Colin Phipps, Florian Schulze
* Copyright 2005, 2006 by
* Florian Schulze, Colin Phipps, Neil Stevens, Andrey Budko
* Copyright (C) 2021 Nicola Wrachien (next-hack in the comments)
* on nRF52840 port.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
* 02111-1307, USA.
*
* DESCRIPTION:
* General system functions. Signal related stuff, exit function
* prototypes, and programmable Doom clock.
*
*-----------------------------------------------------------------------------
*/
#ifndef __I_MAIN__
#define __I_MAIN__
void I_Init(void);
#endif
+179
View File
@@ -0,0 +1,179 @@
/**
* Doom Port to the nRF52840 by Nicola Wrachien (next-hack in the comments)
*
* This port is based on the excellent doomhack's GBA Doom Port,
* with Kippykip additions.
*
* Several data structures and functions have been optimized
* to fit in only 256kB RAM of nRF52840 (GBA has 384 kB RAM).
* Z-Depth Light has been restored with almost no RAM consumption!
* Tons of speed optimizations have been done, and the game now
* runs extremely fast, despite the much higher 3D resolution with
* respect to GBA.
*
* PrBoom: a Doom port merged with LxDoom and LSDLDoom
* based on BOOM, a modified and improved DOOM engine
* Copyright (C) 1999 by
* id Software, Chi Hoang, Lee Killough, Jim Flynn, Rand Phares, Ty Halderman
* Copyright (C) 1999-2000 by
* Jess Haas, Nicolas Kalkhof, Colin Phipps, Florian Schulze
* Copyright 2005, 2006 by
* Florian Schulze, Colin Phipps, Neil Stevens, Andrey Budko
* Copyright (C) 2021 Nicola Wrachien (next-hack in the comments)
* on nRF52840 port.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
* 02111-1307, USA.
*
* DESCRIPTION:
* next-hack: packed (24) and 16 bit pointers utility functions and other stuff
*/
#ifndef DOOM_INCLUDE_I_MEMORY_H_
#define DOOM_INCLUDE_I_MEMORY_H_
#include <stdint.h>
#ifdef PARADISE_DEV
/* Paradise: SRAM 0x18000000, flash uncached from 0x60000000 (WAD and region), program window 0x10000000 */
#define RAM_PTR_BASE 0x18000000UL
#define EXT_FLASH_BASE 0x60000000
#define FLASH_PTR_BASE 0x10000000
#define PACKED_MEMORY_ADDRESS0 RAM_PTR_BASE
#ifdef DOOM_FREE
#include "pdmcfg.h"
#define PACKED_MEMORY_ADDRESS1 g_pk_hi
#define PACKED_MEMORY_ADDRESS2 g_pk_lo
#define PACKED_MEMORY_ADDRESS2_C 0x60800000
#define PD_WAD_OFF (g_dcfg.wad_off - 4u)
#define PD_REGION_OFF (g_dcfg.region_off)
#define PD_REGION_LEN (g_dcfg.region_len)
#define PD_SAVE_ADDR (0x60000000u + g_dcfg.save_off) /* settings, then the save */
#else
#define PD_SAVE_ADDR 0x6010E000u
#define PACKED_MEMORY_ADDRESS1 0x60C00000
#define PACKED_MEMORY_ADDRESS2 0x60800000
#define PACKED_MEMORY_ADDRESS2_C PACKED_MEMORY_ADDRESS2
#endif
#define PACKED_MEMORY_ADDRESS3 FLASH_PTR_BASE
#ifndef PD_WAD_OFF
#define PD_WAD_OFF 0x830000
#define PD_REGION_OFF 0xCA0000
#define PD_REGION_LEN 0xA8000
#endif
#define WAD_ADDRESS (EXT_FLASH_BASE + PD_WAD_OFF + 4)
#define FLASH_ADDRESS (EXT_FLASH_BASE + PD_REGION_OFF)
#define FLASH_CACHE_REGION_SIZE (PD_REGION_LEN)
#else
#define RAM_PTR_BASE 0x20000000UL
#define EXT_FLASH_BASE 0x12000000
#define FLASH_PTR_BASE 0
#define PACKED_MEMORY_ADDRESS0 RAM_PTR_BASE
#define PACKED_MEMORY_ADDRESS1 RAM_PTR_BASE
#define PACKED_MEMORY_ADDRESS2 EXT_FLASH_BASE
#define PACKED_MEMORY_ADDRESS3 FLASH_PTR_BASE
//
#define WAD_ADDRESS (EXT_FLASH_BASE + 4)
#define FLASH_CODE_KB 268
#define FLASH_ADDRESS (0x00000000 + FLASH_CODE_KB * 1024)
#define FLASH_CACHE_REGION_SIZE ((1024 - FLASH_CODE_KB) * 1024)
#endif
#define isRamPtr(p) ((((uint32_t)(p)) >> 24) == (RAM_PTR_BASE >> 24))
#define FLASH_IMMUTABLE_REGION_ADDRESS FLASH_ADDRESS
#define FLASH_IMMUTABLE_REGION 0
#define FLASH_LEVEL_REGION 1
#define FLASH_BLOCK_SIZE 4096
//
#define DEBUG_GETSHORTPTR 0
//
#ifdef PARADISE
#ifdef PARADISE_DEV
/* The WAD (before the region) counts as "external": the core then copies columns into RAM buffers */
#ifdef DOOM_FREE
#define isOnExternalFlash(a) (((uint32_t)(a) - (0x60000000u + g_dcfg.wad_off - 4u)) < g_dcfg.wad_len + 4u)
#else
#define isOnExternalFlash(a) (((uint32_t)(a) - 0x60000000u) < (uint32_t) PD_REGION_OFF)
#endif
#else
#define isOnExternalFlash(a) (0) /* Paradise test run: everything directly readable */
#endif
#else
#define isOnExternalFlash(a) (((uint32_t) a & EXT_FLASH_BASE) == EXT_FLASH_BASE)
#endif
typedef struct
{
uint8_t addrBytes[3];
} __attribute((packed)) packedAddress_t;
static inline void* getLongPtr(unsigned short shortPointer)
{ // Special case: short pointer being all 0 => NULL
if (!shortPointer)
return 0;
return (void*) (((unsigned int) shortPointer << 2) | RAM_PTR_BASE);
}
static inline unsigned short getShortPtr(void *longPtr)
{
return ((unsigned int) longPtr) >> 2;
}
static inline packedAddress_t getPackedAddress(void *addr)
{
packedAddress_t ret;
unsigned int intaddr = (uint32_t) addr;
uint8_t highaddr = intaddr >> 24;
uint8_t highAddrBits = 0;
ret.addrBytes[0] = intaddr;
ret.addrBytes[1] = intaddr >> 8;
#ifdef PARADISE_DEV
if (highaddr == 0x60)
{
highAddrBits = intaddr >= PACKED_MEMORY_ADDRESS1 ? 0x40 : 0x80;
ret.addrBytes[2] = ((intaddr >> 16) & 0x3F) | highAddrBits;
return ret;
}
#endif
switch (highaddr)
{
case (PACKED_MEMORY_ADDRESS0 >> 24) & 0xFF:
highAddrBits = 0x0;
break;
/*case (PACKED_MEMORY_ADDRESS1 >> 24) & 0xFF:
highAddrBits = 0x40;
break;*/
case (PACKED_MEMORY_ADDRESS2_C >> 24) & 0xFF:
highAddrBits = 0x80;
break;
case (PACKED_MEMORY_ADDRESS3 >> 24) & 0xFF:
highAddrBits = 0xC0;
break;
}
ret.addrBytes[2] = ((intaddr >> 16) & 0x3F) | highAddrBits;
return ret;
}
static inline void* unpackAddress(packedAddress_t a) // passed by copy, because it is shorted than a pointer!
{
const uint32_t addresses[] =
{ PACKED_MEMORY_ADDRESS0, PACKED_MEMORY_ADDRESS1, PACKED_MEMORY_ADDRESS2, PACKED_MEMORY_ADDRESS3 };
if (!a.addrBytes[2] && !a.addrBytes[1] && !a.addrBytes[0])
{
return NULL;
}
return (void*) (addresses[a.addrBytes[2] >> 6] | (a.addrBytes[0]) | (a.addrBytes[1] << 8) | ((a.addrBytes[2] & 0x3F) << 16));
}
#endif /* DOOM_INCLUDE_I_MEMORY_H_ */
+68
View File
@@ -0,0 +1,68 @@
/**
* Doom Port to the nRF52840 by Nicola Wrachien (next-hack in the comments)
*
* This port is based on the excellent doomhack's GBA Doom Port,
* with Kippykip additions.
*
* Several data structures and functions have been optimized
* to fit in only 256kB RAM of nRF52840 (GBA has 384 kB RAM).
* Z-Depth Light has been restored with almost no RAM consumption!
* Tons of speed optimizations have been done, and the game now
* runs extremely fast, despite the much higher 3D resolution with
* respect to GBA.
*
* PrBoom: a Doom port merged with LxDoom and LSDLDoom
* based on BOOM, a modified and improved DOOM engine
* Copyright (C) 1999 by
* id Software, Chi Hoang, Lee Killough, Jim Flynn, Rand Phares, Ty Halderman
* Copyright (C) 1999-2000 by
* Jess Haas, Nicolas Kalkhof, Colin Phipps, Florian Schulze
* Copyright 2005, 2006 by
* Florian Schulze, Colin Phipps, Neil Stevens, Andrey Budko
* Copyright (C) 2021 Nicola Wrachien (next-hack in the comments)
* on nRF52840 port.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
* 02111-1307, USA.
*
* DESCRIPTION:
* Low level network interface.
*-----------------------------------------------------------------------------*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#define UDP_CHANNEL struct sockaddr
#ifndef IPPORT_RESERVED
#define IPPORT_RESERVED 1024
#endif
void I_InitNetwork(void);
size_t I_GetPacket(packet_header_t *buffer, size_t buflen);
void I_SendPacket(packet_header_t *packet, size_t len);
void I_WaitForPacket(int ms);
#ifdef AF_INET
void I_SendPacketTo(packet_header_t* packet, size_t len, UDP_CHANNEL *to);
void I_SetupSocket(int sock, int port, int family);
void I_PrintAddress(FILE* fp, UDP_CHANNEL *addr);
extern UDP_CHANNEL sentfrom;
extern int v4socket, v6socket;
#endif
extern size_t sentbytes, recvdbytes;
+99
View File
@@ -0,0 +1,99 @@
/**
* Doom Port to the nRF52840 by Nicola Wrachien (next-hack in the comments)
*
* This port is based on the excellent doomhack's GBA Doom Port,
* with Kippykip additions.
*
* Several data structures and functions have been optimized
* to fit in only 256kB RAM of nRF52840 (GBA has 384 kB RAM).
* Z-Depth Light has been restored with almost no RAM consumption!
* Tons of speed optimizations have been done, and the game now
* runs extremely fast, despite the much higher 3D resolution with
* respect to GBA.
*
* PrBoom: a Doom port merged with LxDoom and LSDLDoom
* based on BOOM, a modified and improved DOOM engine
* Copyright (C) 1999 by
* id Software, Chi Hoang, Lee Killough, Jim Flynn, Rand Phares, Ty Halderman
* Copyright (C) 1999-2000 by
* Jess Haas, Nicolas Kalkhof, Colin Phipps, Florian Schulze
* Copyright 2005, 2006 by
* Florian Schulze, Colin Phipps, Neil Stevens, Andrey Budko
* Copyright (C) 2021 Nicola Wrachien (next-hack in the comments)
* on nRF52840 port.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
* 02111-1307, USA.
*
* DESCRIPTION:
* System interface, sound.
*
*-----------------------------------------------------------------------------*/
#ifndef __I_SOUND__
#define __I_SOUND__
#include "sounds.h"
#include "doomtype.h"
// Init at program start...
void I_InitSound(void);
// ... shut down and relase at program termination.
void I_ShutdownSound(void);
//
// SFX I/O
//
// Starts a sound in a particular sound channel.
int I_StartSound(int id, int channel, int vol, int sep);
//
// MUSIC I/O
//
void I_InitMusic(void);
// Volume.
void I_SetMusicVolume(int volume);
// PAUSE game handling.
void I_PauseSong(int handle);
void I_ResumeSong(int handle);
// Called by anything that wishes to start music.
// plays a song, and when the song is done,
// starts playing it again in an endless loop.
// Horrible thing to do, considering.
void I_PlaySong(int handle, int looping);
// Stops a song over 3 seconds.
void I_StopSong(int handle);
// CPhipps - put these in config file
extern const int snd_samplerate;
typedef struct
{
const char *data;
const char *enddata;
int vol;
} channel_info_t;
#define MUSIC_BUFFER_SAMPLES 2048
#define MAX_CHANNELS 8
#endif
@@ -0,0 +1,87 @@
/**
* Doom Port to the nRF52840 by Nicola Wrachien (next-hack in the comments)
*
* This port is based on the excellent doomhack's GBA Doom Port,
* with Kippykip additions.
*
* Several data structures and functions have been optimized
* to fit in only 256kB RAM of nRF52840 (GBA has 384 kB RAM).
* Z-Depth Light has been restored with almost no RAM consumption!
* Tons of speed optimizations have been done, and the game now
* runs extremely fast, despite the much higher 3D resolution with
* respect to GBA.
*
* PrBoom: a Doom port merged with LxDoom and LSDLDoom
* based on BOOM, a modified and improved DOOM engine
* Copyright (C) 1999 by
* id Software, Chi Hoang, Lee Killough, Jim Flynn, Rand Phares, Ty Halderman
* Copyright (C) 1999-2000 by
* Jess Haas, Nicolas Kalkhof, Colin Phipps, Florian Schulze
* Copyright 2005, 2006 by
* Florian Schulze, Colin Phipps, Neil Stevens, Andrey Budko
* Copyright (C) 2021 Nicola Wrachien (next-hack in the comments)
* on nRF52840 port.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
* 02111-1307, USA.
*
* DESCRIPTION:
* next-hack: Some wrapper functions, to use SPI routines.
* Memory mapped code has been removed.
*/
#ifndef I_SPI_SUPPORT_H_
#define I_SPI_SUPPORT_H_
#include <stdint.h>
#include "string.h"
//
extern uint8_t *currentSpiAddress;
#ifdef PARADISE_DEV
/* Paradise: flash is only fast to read word by word (uncached byte read ~1.3 us), so read aligned words */
void plat_fcopy(void *dst, const void *src, unsigned int n);
#define FLASH_MEMCPY(d, s, n) plat_fcopy((d), (s), (n))
#else
#define FLASH_MEMCPY(d, s, n) memcpy((d), (s), (n))
#endif
static inline uint8_t spiFlashGetByte()
{
return *currentSpiAddress++;
}
static inline short spiFlashGetShort()
{
uint16_t s = *currentSpiAddress++;
s |= (*currentSpiAddress++ << 8);
return (short) s;
/*
short s = *((short*) currentSpiAddress);
currentSpiAddress+=2;
return s;*/
}
static inline uint8_t spiFlashGetByteFromAddress(const void *addr)
{
currentSpiAddress = (void*) addr;
return spiFlashGetByte();
}
static inline void* spiFlashGetData(void *dest, unsigned int length)
{
uint32_t *b = (void*) currentSpiAddress;
FLASH_MEMCPY(dest, b, length);
currentSpiAddress += length;
return dest;
}
static inline uint32_t spiFlashSetAddress(uint32_t address)
{
currentSpiAddress = (uint8_t*) address;
}
#endif /* SOURCE_I_SPI_SUPPORT_H_ */
+63
View File
@@ -0,0 +1,63 @@
/**
* Doom Port to the nRF52840 by Nicola Wrachien (next-hack in the comments)
*
* This port is based on the excellent doomhack's GBA Doom Port,
* with Kippykip additions.
*
* Several data structures and functions have been optimized
* to fit in only 256kB RAM of nRF52840 (GBA has 384 kB RAM).
* Z-Depth Light has been restored with almost no RAM consumption!
* Tons of speed optimizations have been done, and the game now
* runs extremely fast, despite the much higher 3D resolution with
* respect to GBA.
*
* PrBoom: a Doom port merged with LxDoom and LSDLDoom
* based on BOOM, a modified and improved DOOM engine
* Copyright (C) 1999 by
* id Software, Chi Hoang, Lee Killough, Jim Flynn, Rand Phares, Ty Halderman
* Copyright (C) 1999-2000 by
* Jess Haas, Nicolas Kalkhof, Colin Phipps, Florian Schulze
* Copyright 2005, 2006 by
* Florian Schulze, Colin Phipps, Neil Stevens, Andrey Budko
* Copyright (C) 2021 Nicola Wrachien (next-hack in the comments)
* on nRF52840 port.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
* 02111-1307, USA.
*
* DESCRIPTION:
* System specific interface stuff.
*
*-----------------------------------------------------------------------------*/
#ifndef __I_SYSTEM__
#define __I_SYSTEM__
#ifdef __GNUG__
#pragma interface
#endif
#include "printf.h"
boolean I_StartDisplay(void);
void I_EndDisplay(void);
unsigned int I_GetTime(void); /* killough */
unsigned int I_GetTimeMicrosecs();
/* cphipps - I_GetVersionString
* Returns a version string in the given buffer
*/
const char* I_GetVersionString(char *buf, size_t sz);
#endif
+85
View File
@@ -0,0 +1,85 @@
/**
* Doom Port to the nRF52840 by Nicola Wrachien (next-hack in the comments)
*
* This port is based on the excellent doomhack's GBA Doom Port,
* with Kippykip additions.
*
* Several data structures and functions have been optimized
* to fit in only 256kB RAM of nRF52840 (GBA has 384 kB RAM).
* Z-Depth Light has been restored with almost no RAM consumption!
* Tons of speed optimizations have been done, and the game now
* runs extremely fast, despite the much higher 3D resolution with
* respect to GBA.
*
* PrBoom: a Doom port merged with LxDoom and LSDLDoom
* based on BOOM, a modified and improved DOOM engine
* Copyright (C) 1999 by
* id Software, Chi Hoang, Lee Killough, Jim Flynn, Rand Phares, Ty Halderman
* Copyright (C) 1999-2000 by
* Jess Haas, Nicolas Kalkhof, Colin Phipps, Florian Schulze
* Copyright 2005, 2006 by
* Florian Schulze, Colin Phipps, Neil Stevens, Andrey Budko
* Copyright (C) 2021 Nicola Wrachien (next-hack in the comments)
* on nRF52840 port.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
* 02111-1307, USA.
*
* DESCRIPTION:
* System specific interface stuff.
*
*-----------------------------------------------------------------------------*/
#ifndef __I_VIDEO__
#define __I_VIDEO__
#include "doomtype.h"
#include "v_video.h"
#ifdef __GNUG__
#pragma interface
#endif
void I_PreInitGraphics(void); /* CPhipps - do stuff immediately on start */
void I_SetRes(void); /* set resolution */
void I_InitGraphics(void);
void I_UpdateVideoMode(void);
void I_ShutdownGraphics(void);
/* Takes full 8 bit values. */
void I_SetPalette(int pal); /* CPhipps - pass down palette number */
boolean I_StartDisplay(void);
void I_FinishUpdateBlock(void);
/* I_StartTic
* Called by D_DoomLoop,
* called before processing each tic in a frame.
* Quick syncronous operations are performed here.
* Can call D_PostEvent.
*/
void I_StartTic(void);
key_t keysDown();
/* I_StartFrame
* Called by D_DoomLoop,
* called before processing any tics in a frame
* (just after displaying a frame).
* Time consuming syncronous operations
* are performed here (joystick reading).
* Can call D_PostEvent.
*/
void handleDisplayBacklightToggle();
void I_StartFrame(void);
extern uint8_t displayBuffer[96 * SCREENWIDTH_PHYSICAL];
#endif
File diff suppressed because it is too large. Load diff
+98
View File
@@ -0,0 +1,98 @@
/**
* Doom Port to the nRF52840 by Nicola Wrachien (next-hack in the comments)
*
* This port is based on the excellent doomhack's GBA Doom Port,
* with Kippykip additions.
*
* Several data structures and functions have been optimized
* to fit in only 256kB RAM of nRF52840 (GBA has 384 kB RAM).
* Z-Depth Light has been restored with almost no RAM consumption!
* Tons of speed optimizations have been done, and the game now
* runs extremely fast, despite the much higher 3D resolution with
* respect to GBA.
*
* PrBoom: a Doom port merged with LxDoom and LSDLDoom
* based on BOOM, a modified and improved DOOM engine
* Copyright (C) 1999 by
* id Software, Chi Hoang, Lee Killough, Jim Flynn, Rand Phares, Ty Halderman
* Copyright (C) 1999-2000 by
* Jess Haas, Nicolas Kalkhof, Colin Phipps, Florian Schulze
* Copyright 2005, 2006 by
* Florian Schulze, Colin Phipps, Neil Stevens, Andrey Budko
* Copyright (C) 2021 Nicola Wrachien (next-hack in the comments)
* on nRF52840 port.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
* 02111-1307, USA.
*
* DESCRIPTION:
* Declarations etc. for logical console output
*
*-----------------------------------------------------------------------------*/
#ifndef __LPRINTF__
#define __LPRINTF__
#include "printf.h"
#include <stdarg.h>
typedef enum /* Logical output levels */
{
LO_INFO = 1, /* One of these is used in each physical output */
LO_CONFIRM = 2, /* call. Which are output, or echoed to console */
LO_WARN = 4, /* if output redirected is determined by the */
LO_ERROR = 8, /* global masks: cons_output_mask,cons_error_mask. */
LO_FATAL = 16, LO_DEBUG = 32, LO_ALWAYS = 64,
} OutputLevels;
//extern int lprintf(OutputLevels pri, const char *fmt, ...);
#ifdef PARADISE_DEV
void plat_plog(int n);
#define PLOG(n) plat_plog(n)
#else
#define PLOG(n)
#endif
#ifdef PARADISE_DEV
void plat_mark(int line, const char *file);
#define lprintf(pri, fmt, ...) plat_mark(__LINE__, __FILE__)
#else
#define lprintf(pri, fmt, ...) printf(fmt, ## __VA_ARGS__)
#endif
#define MIN_DEMO_GAMETIC_TO_PRINT 0
/* 1.7.2 DOOM_FREE: P_Random looked for a backslash in the file name on every call (about 15 KB backwards through the
* program part, for a debug print that is off): left out */
#ifdef DOOM_FREE
#define PRND_SCAN 0
#else
#define PRND_SCAN 1
#endif
#define DEBUG_DEMO 0
#if DEBUG_DEMO
#define demodbgprintf printf
#else
#define demodbgprintf(...)
#endif
/* killough 3/20/98: add const
* killough 4/25/98: add gcc attributes
* cphipps 01/11- moved from i_system.h */
//void I_Error (const char *error, ...);
#ifdef PARADISE_DEV
void plat_error(int line, const char *file);
#define I_Error(...) plat_error(__LINE__, __FILE__)
#else
#define I_Error printf
#endif
#endif
+64
View File
@@ -0,0 +1,64 @@
/**
* Doom Port to the nRF52840 by Nicola Wrachien (next-hack in the comments)
*
* This port is based on the excellent doomhack's GBA Doom Port,
* with Kippykip additions.
*
* Several data structures and functions have been optimized
* to fit in only 256kB RAM of nRF52840 (GBA has 384 kB RAM).
* Z-Depth Light has been restored with almost no RAM consumption!
* Tons of speed optimizations have been done, and the game now
* runs extremely fast, despite the much higher 3D resolution with
* respect to GBA.
*
* PrBoom: a Doom port merged with LxDoom and LSDLDoom
* based on BOOM, a modified and improved DOOM engine
* Copyright (C) 1999 by
* id Software, Chi Hoang, Lee Killough, Jim Flynn, Rand Phares, Ty Halderman
* Copyright (C) 1999-2000 by
* Jess Haas, Nicolas Kalkhof, Colin Phipps, Florian Schulze
* Copyright 2005, 2006 by
* Florian Schulze, Colin Phipps, Neil Stevens, Andrey Budko
* Copyright (C) 2021 Nicola Wrachien (next-hack in the comments)
* on nRF52840 port.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
* 02111-1307, USA.
*
* DESCRIPTION:
* Simple bounding box datatype and functions.
*
*-----------------------------------------------------------------------------*/
#ifndef __M_BBOX__
#define __M_BBOX__
#include <limits.h>
#include "m_fixed.h"
/* Bounding box coordinate storage. */
enum
{
BOXTOP, BOXBOTTOM, BOXLEFT, BOXRIGHT
};
/* bbox coordinates */
/* Bounding box functions. */
void M_ClearBox(fixed_t *box);
void M_AddToBox(fixed_t *box, fixed_t x, fixed_t y);
#endif
+8
View File
@@ -0,0 +1,8 @@
#ifndef M_CHEAT_H
#define M_CHEAT_H
#include "d_event.h"
boolean C_Responder(event_t *ev);
#endif // M_CHEAT_H
+167
View File
@@ -0,0 +1,167 @@
/**
* Doom Port to the nRF52840 by Nicola Wrachien (next-hack in the comments)
*
* This port is based on the excellent doomhack's GBA Doom Port,
* with Kippykip additions.
*
* Several data structures and functions have been optimized
* to fit in only 256kB RAM of nRF52840 (GBA has 384 kB RAM).
* Z-Depth Light has been restored with almost no RAM consumption!
* Tons of speed optimizations have been done, and the game now
* runs extremely fast, despite the much higher 3D resolution with
* respect to GBA.
*
* PrBoom: a Doom port merged with LxDoom and LSDLDoom
* based on BOOM, a modified and improved DOOM engine
* Copyright (C) 1999 by
* id Software, Chi Hoang, Lee Killough, Jim Flynn, Rand Phares, Ty Halderman
* Copyright (C) 1999-2000 by
* Jess Haas, Nicolas Kalkhof, Colin Phipps, Florian Schulze
* Copyright 2005, 2006 by
* Florian Schulze, Colin Phipps, Neil Stevens, Andrey Budko
* Copyright (C) 2021 Nicola Wrachien (next-hack in the comments)
* on nRF52840 port.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
* 02111-1307, USA.
*
* DESCRIPTION:
* Fixed point arithemtics, implementation.
*
*-----------------------------------------------------------------------------*/
#ifndef __M_FIXED__
#define __M_FIXED__
#include "config.h"
#include "doomtype.h"
#include <stdlib.h>
// to count divisions per frame
extern int divisions;
/*
* Fixed point, 32bit as 16.16.
*/
#define FRACBITS 16
#define FRACUNIT (1<<FRACBITS)
typedef int fixed_t;
/*
* Absolute Value
*
* killough 5/10/98: In djgpp, use inlined assembly for performance
* killough 9/05/98: better code seems to be gotten from using inlined C
* next-hack: standard library implements this function in 2 asm instructions.
*/
inline static int CONSTFUNC D_abs(fixed_t x)
{
return abs(x);
/*fixed_t _t = (x), _s;
_s = _t >> (8 * sizeof _t - 1);
return (_t ^ _s) - _s;*/
}
/*
* Fixed Point Multiplication
*/
/* CPhipps - made __inline__ to inline, as specified in the gcc docs
* Also made const */
fixed_t CONSTFUNC FixedMul(fixed_t a, fixed_t b);
/*
* Fixed Point Division
*/
/* CPhipps - made __inline__ to inline, as specified in the gcc docs
* Also made const */
inline static fixed_t CONSTFUNC FixedDiv(fixed_t a, fixed_t b)
{
divisions++;
return ((unsigned)D_abs(a)>>14) >= (unsigned)D_abs(b) ? ((a^b)>>31) ^ INT_MAX : (fixed_t)(((int_64_t) a << FRACBITS) / b);
// this is much faster as we have a FPU..
// float r = ((float) a) / b;
// return (fixed_t) 65536 * r;
}
/* CPhipps -
* FixedMod - returns a % b, guaranteeing 0<=a<b
* (notice that the C standard for % does not guarantee this)
*/
inline static fixed_t CONSTFUNC FixedMod(fixed_t a, fixed_t b)
{
divisions++;
if (!a)
return 0;
if (b & (b - 1))
{
fixed_t r = a % b;
return ((r < 0) ? r + b : r);
}
else
return (a & (b - 1));
}
//Approx Reciprocal of v
inline static CONSTFUNC fixed_t FixedReciprocal(fixed_t v)
{
divisions++;
fixed_t result;
// CORTEX M4 and M33 have FPU. Let's use it (we can't afford 64k of flash for reciprocals!) .
if (0 == v)
return 0; // we should return infinity, but the table returned 0
#ifdef PARADISE
/* Cortex-M3 without floating point: integer 2^32 / v */
(void) result;
if (v == 1 || v == -1) return v > 0 ? INT_MAX : -INT_MAX;
return (fixed_t) (0x100000000LL / v);
#else
float r;
r = 65536.0 / v;
result = (fixed_t) (r * 65536);
return result;
#endif
}
//Count leading zeros. 16bit.
inline static CONSTFUNC unsigned int clz16(unsigned int x)
{
return __builtin_clz(x);
}
//Approx fixed point divide of a/b using reciprocal. -> a * (1/b).
inline static CONSTFUNC fixed_t FixedApproxDiv(fixed_t a, fixed_t b)
{
divisions++;
#ifdef PARADISE
if (!b) return 0;
return (fixed_t) (((int_64_t) a << FRACBITS) / b);
#else
float r = ((float) a) / b;
return (fixed_t) 65536 * r;
#endif
// return FixedMul(a, FixedReciprocal(b));
}
#endif
+162
View File
@@ -0,0 +1,162 @@
/**
* Doom Port to the nRF52840 by Nicola Wrachien (next-hack in the comments)
*
* This port is based on the excellent doomhack's GBA Doom Port,
* with Kippykip additions.
*
* Several data structures and functions have been optimized
* to fit in only 256kB RAM of nRF52840 (GBA has 384 kB RAM).
* Z-Depth Light has been restored with almost no RAM consumption!
* Tons of speed optimizations have been done, and the game now
* runs extremely fast, despite the much higher 3D resolution with
* respect to GBA.
*
* PrBoom: a Doom port merged with LxDoom and LSDLDoom
* based on BOOM, a modified and improved DOOM engine
* Copyright (C) 1999 by
* id Software, Chi Hoang, Lee Killough, Jim Flynn, Rand Phares, Ty Halderman
* Copyright (C) 1999-2000 by
* Jess Haas, Nicolas Kalkhof, Colin Phipps, Florian Schulze
* Copyright 2005, 2006 by
* Florian Schulze, Colin Phipps, Neil Stevens, Andrey Budko
* Copyright (C) 2021 Nicola Wrachien (next-hack in the comments)
* on nRF52840 port.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
* 02111-1307, USA.
*
* DESCRIPTION:
* Menu widget stuff, episode selection and such.
*
*-----------------------------------------------------------------------------*/
#ifndef __M_MENU__
#define __M_MENU__
#include "d_event.h"
//
// MENUS
//
// Called by main loop,
// saves config file and calls I_Quit when user exits.
// Even when the menu is not displayed,
// this can resize the view and change game parameters.
// Does all the real work of the menu interaction.
boolean M_Responder(event_t *ev);
// Called by main loop,
// only used for menu (skull cursor) animation.
void M_Ticker(void);
// Called by main loop,
// draws the menus directly into the screen buffer.
void M_Drawer(void);
// Called by D_DoomMain,
// loads the config file.
void M_Init(void);
// Called by intro code to force menu up upon a keypress,
// does nothing if menu is already up.
void M_StartControlPanel(void);
void M_ResetMenu(void); // killough 11/98: reset main menu ordering
void M_DrawCredits(void); // killough 11/98
void M_ChangeGamma(int choice); // Adafruit Clue onboard button gamma adjust
/****************************
*
* The following #defines are for the m_flags field of each item on every
* Setup Screen. They can be OR'ed together where appropriate
*/
#define S_HILITE 0x1 // Cursor is sitting on this item
#define S_SELECT 0x2 // We're changing this item
#define S_TITLE 0x4 // Title item
#define S_YESNO 0x8 // Yes or No item
#define S_CRITEM 0x10 // Message color
#define S_COLOR 0x20 // Automap color
#define S_CHAT 0x40 // Chat String
#define S_RESET 0x80 // Reset to Defaults Button
#define S_PREV 0x100 // Previous menu exists
#define S_NEXT 0x200 // Next menu exists
#define S_KEY 0x400 // Key Binding
#define S_WEAP 0x800 // Weapon #
#define S_NUM 0x1000 // Numerical item
#define S_SKIP 0x2000 // Cursor can't land here
#define S_KEEP 0x4000 // Don't swap key out
#define S_END 0x8000 // Last item in list (dummy)
#define S_LEVWARN 0x10000// killough 8/30/98: Always warn about pending change
#define S_PRGWARN 0x20000// killough 10/98: Warn about change until next run
#define S_BADVAL 0x40000// killough 10/98: Warn about bad value
#define S_FILE 0x80000// killough 10/98: Filenames
#define S_LEFTJUST 0x100000 // killough 10/98: items which are left-justified
#define S_CREDIT 0x200000 // killough 10/98: credit
#define S_BADVID 0x400000 // killough 12/98: video mode change error
#define S_CHOICE 0x800000 // this item has several values
/* S_SHOWDESC = the set of items whose description should be displayed
* S_SHOWSET = the set of items whose setting should be displayed
* S_STRING = the set of items whose settings are strings -- killough 10/98:
* S_HASDEFPTR = the set of items whose var field points to default array
*/
#define S_SHOWDESC (S_TITLE|S_YESNO|S_CRITEM|S_COLOR|S_CHAT|S_RESET|S_PREV|S_NEXT|S_KEY|S_WEAP|S_NUM|S_FILE|S_CREDIT|S_CHOICE)
#define S_SHOWSET (S_YESNO|S_CRITEM|S_COLOR|S_CHAT|S_KEY|S_WEAP|S_NUM|S_FILE|S_CHOICE)
#define S_STRING (S_CHAT|S_FILE)
#define S_HASDEFPTR (S_STRING|S_YESNO|S_NUM|S_WEAP|S_COLOR|S_CRITEM|S_CHOICE)
#define SAVESTRINGSIZE 8
//
// MENU TYPEDEFS
//
typedef struct
{
short status; // 0 = no cursor here, 1 = ok, 2 = arrows ok
char name[10];
// choice = menu item #.
// if status = 2,
// choice=0:leftarrow,1:rightarrow
void (*routine)(int choice);
} menuitem_t;
typedef struct menu_s
{
short numitems; // # of menu items
const menuitem_t *menuitems; // menu items
void (*routine)(); // draw routine
short x;
short y; // x,y of menu
const struct menu_s *prevMenu; // previous menu
short previtemOn;
} menu_t;
extern char savegamestrings[8][8];
#endif
+51
View File
@@ -0,0 +1,51 @@
/**
* Doom Port to the nRF52840 by Nicola Wrachien (next-hack in the comments)
*
* This port is based on the excellent doomhack's GBA Doom Port,
* with Kippykip additions.
*
* Several data structures and functions have been optimized
* to fit in only 256kB RAM of nRF52840 (GBA has 384 kB RAM).
* Z-Depth Light has been restored with almost no RAM consumption!
* Tons of speed optimizations have been done, and the game now
* runs extremely fast, despite the much higher 3D resolution with
* respect to GBA.
*
* PrBoom: a Doom port merged with LxDoom and LSDLDoom
* based on BOOM, a modified and improved DOOM engine
* Copyright (C) 1999 by
* id Software, Chi Hoang, Lee Killough, Jim Flynn, Rand Phares, Ty Halderman
* Copyright (C) 1999-2000 by
* Jess Haas, Nicolas Kalkhof, Colin Phipps, Florian Schulze
* Copyright 2005, 2006 by
* Florian Schulze, Colin Phipps, Neil Stevens, Andrey Budko
* Copyright (C) 2021 Nicola Wrachien (next-hack in the comments)
* on nRF52840 port.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
* 02111-1307, USA.
*
* DESCRIPTION:
* External non-system-specific stuff, like storing config settings,
* simple file handling, and saving screnshots.
*
*-----------------------------------------------------------------------------*/
#ifndef __M_MISC__
#define __M_MISC__
#include "doomtype.h"
#endif
+62
View File
@@ -0,0 +1,62 @@
/**
* Doom Port to the nRF52840 by Nicola Wrachien (next-hack in the comments)
*
* This port is based on the excellent doomhack's GBA Doom Port,
* with Kippykip additions.
*
* Several data structures and functions have been optimized
* to fit in only 256kB RAM of nRF52840 (GBA has 384 kB RAM).
* Z-Depth Light has been restored with almost no RAM consumption!
* Tons of speed optimizations have been done, and the game now
* runs extremely fast, despite the much higher 3D resolution with
* respect to GBA.
*
* PrBoom: a Doom port merged with LxDoom and LSDLDoom
* based on BOOM, a modified and improved DOOM engine
* Copyright (C) 1999 by
* id Software, Chi Hoang, Lee Killough, Jim Flynn, Rand Phares, Ty Halderman
* Copyright (C) 1999-2000 by
* Jess Haas, Nicolas Kalkhof, Colin Phipps, Florian Schulze
* Copyright 2005, 2006 by
* Florian Schulze, Colin Phipps, Neil Stevens, Andrey Budko
* Copyright (C) 2021 Nicola Wrachien (next-hack in the comments)
* on nRF52840 port.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
* 02111-1307, USA.
*
* DESCRIPTION:
* Functions to return random numbers.
*
*-----------------------------------------------------------------------------*/
#ifndef __M_RANDOM__
#define __M_RANDOM__
#include "doomtype.h"
#include "doomtype.h"
// Returns a number from 0 to 255,
// from a lookup table.
int M_Random(void);
// As M_Random, but used only by the play simulation.
int P_Random(const char *, int, const char *);
// Fix randoms for demos.
void M_ClearRandom(void);
#endif
+110
View File
@@ -0,0 +1,110 @@
/**
* Doom Port to the nRF52840 by Nicola Wrachien (next-hack in the comments)
*
* This port is based on the excellent doomhack's GBA Doom Port,
* with Kippykip additions.
*
* Several data structures and functions have been optimized
* to fit in only 256kB RAM of nRF52840 (GBA has 384 kB RAM).
* Z-Depth Light has been restored with almost no RAM consumption!
* Tons of speed optimizations have been done, and the game now
* runs extremely fast, despite the much higher 3D resolution with
* respect to GBA.
*
* PrBoom: a Doom port merged with LxDoom and LSDLDoom
* based on BOOM, a modified and improved DOOM engine
* Copyright (C) 1999 by
* id Software, Chi Hoang, Lee Killough, Jim Flynn, Rand Phares, Ty Halderman
* Copyright (C) 1999-2000 by
* Jess Haas, Nicolas Kalkhof, Colin Phipps, Florian Schulze
* Copyright 2005, 2006 by
* Florian Schulze, Colin Phipps, Neil Stevens, Andrey Budko
* Copyright (C) 2021 Nicola Wrachien (next-hack in the comments)
* on nRF52840 port.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
* 02111-1307, USA.
*
* DESCRIPTION:
* Endianess handling, swapping 16bit and 32bit.
*
*-----------------------------------------------------------------------------*/
#ifndef __M_SWAP__
#define __M_SWAP__
#ifdef __GNUG__
#pragma interface
#endif
/* CPhipps - now the endianness handling, converting input or output to/from
* the machine's endianness to that wanted for this type of I/O
*
* To find our own endianness, use config.h
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
/* Endianess handling. */
/* cph - First the macros to do the actual byte swapping */
/* leban
* rather than continue the confusing tradition of redefining the
* stardard macro, we now present the doom_ntoh and doom_hton macros....
* might as well use the xdoom macros.
*/
#ifndef doom_swap_l
#define doom_swap_l(x) \
((long int)((((unsigned long int)(x) & 0x000000ffU) << 24) | \
(((unsigned long int)(x) & 0x0000ff00U) << 8) | \
(((unsigned long int)(x) & 0x00ff0000U) >> 8) | \
(((unsigned long int)(x) & 0xff000000U) >> 24)))
#endif
#ifndef doom_swap_s
#define doom_swap_s(x) \
((short int)((((unsigned short int)(x) & 0x00ff) << 8) | \
(((unsigned short int)(x) & 0xff00) >> 8)))
#endif
/* Macros are named doom_XtoYT, where
* X is thing to convert from, Y is thing to convert to, chosen from
* n for network, h for host (i.e our machine's), w for WAD (Doom data files)
* and T is the type, l or s for long or short
*
* CPhipps - all WADs and network packets will be little endian for now
* Use separate macros so network could be converted to big-endian later.
*/
#define doom_wtohl(x) (long int)(x)
#define doom_htowl(x) (long int)(x)
#define doom_wtohs(x) (short int)(x)
#define doom_htows(x) (short int)(x)
#define doom_ntohl(x) (long int)(x)
#define doom_htonl(x) (long int)(x)
#define doom_ntohs(x) (short int)(x)
#define doom_htons(x) (short int)(x)
/* CPhipps - Boom's old LONG and SHORT endianness macros are for WAD stuff */
#define LONG(x) doom_wtohl(x)
#define SHORT(x) doom_htows(x)
#endif
+129
View File
@@ -0,0 +1,129 @@
/**
* Doom Port to the nRF52840 by Nicola Wrachien (next-hack in the comments)
*
* This port is based on the excellent doomhack's GBA Doom Port,
* with Kippykip additions.
*
* Several data structures and functions have been optimized
* to fit in only 256kB RAM of nRF52840 (GBA has 384 kB RAM).
* Z-Depth Light has been restored with almost no RAM consumption!
* Tons of speed optimizations have been done, and the game now
* runs extremely fast, despite the much higher 3D resolution with
* respect to GBA.
*
* PrBoom: a Doom port merged with LxDoom and LSDLDoom
* based on BOOM, a modified and improved DOOM engine
* Copyright (C) 1999 by
* id Software, Chi Hoang, Lee Killough, Jim Flynn, Rand Phares, Ty Halderman
* Copyright (C) 1999-2000 by
* Jess Haas, Nicolas Kalkhof, Colin Phipps, Florian Schulze
* Copyright 2005, 2006 by
* Florian Schulze, Colin Phipps, Neil Stevens, Andrey Budko
* Copyright (C) 2021 Nicola Wrachien (next-hack in the comments)
* on nRF52840 port.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
* 02111-1307, USA.
*
* DESCRIPTION:
* Enemy thinking, AI.
* Action Pointer Functions
* that are associated with states/frames.
*
*-----------------------------------------------------------------------------*/
#ifndef __P_ENEMY__
#define __P_ENEMY__
#include "p_mobj.h"
void P_NoiseAlert(mobj_t *target, mobj_t *emmiter);
void P_SpawnBrainTargets(void); /* killough 3/26/98: spawn icon landings */
typedef struct brain_t
{ /* killough 3/26/98: global state of boss brain */
int easy, targeton;
} brain_t;
// ********************************************************************
// Function addresses or Code Pointers
// ********************************************************************
// These function addresses are the Code Pointers that have been
// modified for years by Dehacked enthusiasts. The new BEX format
// allows more extensive changes (see d_deh.c)
// Doesn't work with g++, needs actionf_p1
void A_Explode();
void A_Pain();
void A_PlayerScream();
void A_Fall();
void A_XScream();
void A_Look();
void A_Chase();
void A_FaceTarget();
void A_PosAttack();
void A_Scream();
void A_SPosAttack();
void A_VileChase();
void A_VileStart();
void A_VileTarget();
void A_VileAttack();
void A_StartFire();
void A_Fire();
void A_FireCrackle();
void A_Tracer();
void A_SkelWhoosh();
void A_SkelFist();
void A_SkelMissile();
void A_FatRaise();
void A_FatAttack1();
void A_FatAttack2();
void A_FatAttack3();
void A_BossDeath();
void A_CPosAttack();
void A_CPosRefire();
void A_TroopAttack();
void A_SargAttack();
void A_HeadAttack();
void A_BruisAttack();
void A_SkullAttack();
void A_Metal();
void A_SpidRefire();
void A_BabyMetal();
void A_BspiAttack();
void A_Hoof();
void A_CyberAttack();
void A_PainAttack();
void A_PainDie();
void A_KeenDie();
void A_BrainPain();
void A_BrainScream();
void A_BrainDie();
void A_BrainAwake();
void A_BrainSpit();
void A_SpawnSound();
void A_SpawnFly();
void A_BrainExplode();
void A_Die();
void A_Detonate(); /* killough 8/9/98: detonate a bomb or other device */
void A_Mushroom(); /* killough 10/98: mushroom effect */
void A_Spawn(); // killough 11/98
void A_Turn(); // killough 11/98
void A_Face(); // killough 11/98
void A_Scratch(); // killough 11/98
void A_PlaySound(); // killough 11/98
void A_RandomJump(); // killough 11/98
#endif // __P_ENEMY__
+85
View File
@@ -0,0 +1,85 @@
/**
* Doom Port to the nRF52840 by Nicola Wrachien (next-hack in the comments)
*
* This port is based on the excellent doomhack's GBA Doom Port,
* with Kippykip additions.
*
* Several data structures and functions have been optimized
* to fit in only 256kB RAM of nRF52840 (GBA has 384 kB RAM).
* Z-Depth Light has been restored with almost no RAM consumption!
* Tons of speed optimizations have been done, and the game now
* runs extremely fast, despite the much higher 3D resolution with
* respect to GBA.
*
* PrBoom: a Doom port merged with LxDoom and LSDLDoom
* based on BOOM, a modified and improved DOOM engine
* Copyright (C) 1999 by
* id Software, Chi Hoang, Lee Killough, Jim Flynn, Rand Phares, Ty Halderman
* Copyright (C) 1999-2000 by
* Jess Haas, Nicolas Kalkhof, Colin Phipps, Florian Schulze
* Copyright 2005, 2006 by
* Florian Schulze, Colin Phipps, Neil Stevens, Andrey Budko
* Copyright (C) 2021 Nicola Wrachien (next-hack in the comments)
* on nRF52840 port.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
* 02111-1307, USA.
*
* DESCRIPTION:
* Thing events, and dehacked specified numbers controlling them.
*
*-----------------------------------------------------------------------------*/
#ifndef __P_INTER__
#define __P_INTER__
#include "d_player.h"
#include "p_mobj.h"
#ifdef __GNUG__
#pragma interface
#endif
/* Ty 03/09/98 Moved to an int in p_inter.c for deh and externalization */
#define MAXHEALTH maxhealth
/* follow a player exlusively for 3 seconds */
#define BASETHRESHOLD (100)
boolean P_GivePower(player_t*, int);
void P_TouchSpecialThing(mobj_t *special, mobj_t *toucher);
void P_DamageMobj(mobj_t *target, mobj_t *inflictor, mobj_t *source, int damage);
/* killough 5/2/98: moved from d_deh.c, g_game.c, m_misc.c, others: */
extern const int god_health; /* Ty 03/09/98 - deh support, see also p_inter.c */
extern const int idfa_armor;
extern const int idfa_armor_class;
extern const int idkfa_armor;
extern const int idkfa_armor_class; /* Ty - end */
/* Ty 03/13/98 - externalized initial settings for respawned player */
extern const int initial_health;
extern const int initial_bullets;
extern const int maxhealth;
extern const int max_armor;
extern const int green_armor_class;
extern const int blue_armor_class;
extern const int max_soul;
extern const int soul_health;
extern const int mega_health;
extern const int bfgcells;
extern const int maxammo[], clipammo[];
#endif
+86
View File
@@ -0,0 +1,86 @@
/**
* Doom Port to the nRF52840 by Nicola Wrachien (next-hack in the comments)
*
* This port is based on the excellent doomhack's GBA Doom Port,
* with Kippykip additions.
*
* Several data structures and functions have been optimized
* to fit in only 256kB RAM of nRF52840 (GBA has 384 kB RAM).
* Z-Depth Light has been restored with almost no RAM consumption!
* Tons of speed optimizations have been done, and the game now
* runs extremely fast, despite the much higher 3D resolution with
* respect to GBA.
*
* PrBoom: a Doom port merged with LxDoom and LSDLDoom
* based on BOOM, a modified and improved DOOM engine
* Copyright (C) 1999 by
* id Software, Chi Hoang, Lee Killough, Jim Flynn, Rand Phares, Ty Halderman
* Copyright (C) 1999-2000 by
* Jess Haas, Nicolas Kalkhof, Colin Phipps, Florian Schulze
* Copyright 2005, 2006 by
* Florian Schulze, Colin Phipps, Neil Stevens, Andrey Budko
* Copyright (C) 2021 Nicola Wrachien (next-hack in the comments)
* on nRF52840 port.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
* 02111-1307, USA.
*
* DESCRIPTION:
* Map functions
*
*-----------------------------------------------------------------------------*/
#ifndef __P_MAP__
#define __P_MAP__
#include "r_defs.h"
#include "d_player.h"
#define USERANGE (64*FRACUNIT)
#define MELEERANGE (64*FRACUNIT)
#define MISSILERANGE (32*64*FRACUNIT)
#define LOOKRANGE (768*FRACUNIT) // was 768 in GBA
// MAXRADIUS is for precalculated sector block boxes the spider demon
// is larger, but we do not have any moving sectors nearby
#define MAXRADIUS (32*FRACUNIT)
// killough 3/15/98: add fourth argument to P_TryMove
boolean P_TryMove(mobj_t *thing, fixed_t x, fixed_t y, boolean dropoff);
// killough 8/9/98: extra argument for telefragging
boolean P_TeleportMove(mobj_t *thing, fixed_t x, fixed_t y, boolean boss);
void P_SlideMove(mobj_t *mo);
boolean P_CheckSight(mobj_t *t1, mobj_t *t2);
void P_UseLines(player_t *player);
// killough 8/2/98: add 'mask' argument to prevent friends autoaiming at others
fixed_t P_AimLineAttack(mobj_t *t1, angle_t angle, fixed_t distance, uint_64_t mask);
void P_LineAttack(mobj_t *t1, angle_t angle, fixed_t distance, fixed_t slope, int damage);
void P_RadiusAttack(mobj_t *spot, mobj_t *source, int damage);
boolean P_CheckPosition(mobj_t *thing, fixed_t x, fixed_t y);
//jff 3/19/98 P_CheckSector(): new routine to replace P_ChangeSector()
boolean P_CheckSector(sector_t *sector, boolean crunch);
void P_DelSeclist(msecnode_t*); // phares 3/16/98
void P_CreateSecNodeList(mobj_t*, fixed_t, fixed_t); // phares 3/14/98
boolean Check_Sides(mobj_t*, int, int); // phares
/* cphipps 2004/08/30 */
void P_MapStart(void);
void P_MapEnd(void);
#endif // __P_MAP__
+106
View File
@@ -0,0 +1,106 @@
/**
* Doom Port to the nRF52840 by Nicola Wrachien (next-hack in the comments)
*
* This port is based on the excellent doomhack's GBA Doom Port,
* with Kippykip additions.
*
* Several data structures and functions have been optimized
* to fit in only 256kB RAM of nRF52840 (GBA has 384 kB RAM).
* Z-Depth Light has been restored with almost no RAM consumption!
* Tons of speed optimizations have been done, and the game now
* runs extremely fast, despite the much higher 3D resolution with
* respect to GBA.
*
* PrBoom: a Doom port merged with LxDoom and LSDLDoom
* based on BOOM, a modified and improved DOOM engine
* Copyright (C) 1999 by
* id Software, Chi Hoang, Lee Killough, Jim Flynn, Rand Phares, Ty Halderman
* Copyright (C) 1999-2000 by
* Jess Haas, Nicolas Kalkhof, Colin Phipps, Florian Schulze
* Copyright 2005, 2006 by
* Florian Schulze, Colin Phipps, Neil Stevens, Andrey Budko
* Copyright (C) 2021 Nicola Wrachien (next-hack in the comments)
* on nRF52840 port.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
* 02111-1307, USA.
*
* DESCRIPTION:
* Map utility functions
*
*-----------------------------------------------------------------------------*/
#ifndef __P_MAPUTL__
#define __P_MAPUTL__
#include "r_defs.h"
/* mapblocks are used to check movement against lines and things */
#define MAPBLOCKUNITS 128
#define MAPBLOCKSIZE (MAPBLOCKUNITS*FRACUNIT)
#define MAPBLOCKSHIFT (FRACBITS+7)
#define MAPBMASK (MAPBLOCKSIZE-1)
#define MAPBTOFRAC (MAPBLOCKSHIFT-FRACBITS)
#define PT_ADDLINES 1
#define PT_ADDTHINGS 2
#define PT_EARLYOUT 4
#define MAXINTERCEPTS 64
typedef struct
{
fixed_t x;
fixed_t y;
fixed_t dx;
fixed_t dy;
} divline_t;
typedef struct
{
fixed_t frac; /* along trace line */
//boolean isaline;
union
{
mobj_t *thing;
const line_t *line;
} d;
} intercept_t;
typedef struct
{
fixed_t sightzstart, t2x, t2y; // eye z of looker
divline_t strace; // from t1 to t2
fixed_t topslope, bottomslope; // slopes to top and bottom of target
fixed_t bbox[4];
fixed_t maxz, minz; // cph - z optimisations for 2sided lines
} los_t;
typedef boolean (*traverser_t)(intercept_t *in);
fixed_t CONSTFUNC P_AproxDistance(fixed_t dx, fixed_t dy);
int P_PointOnLineSide(fixed_t x, fixed_t y, const line_t *line);
int P_BoxOnLineSide(const fixed_t *tmbox, const line_t *ld);
/* cph - old compatibility version below */
fixed_t P_InterceptVector2(const divline_t *v2, const divline_t *v1);
void P_LineOpening(const line_t *linedef);
void P_UnsetThingPosition(mobj_t *thing);
void P_SetThingPosition(mobj_t *thing);
boolean P_BlockLinesIterator(int x, int y, boolean func(const line_t*));
boolean P_BlockThingsIterator(int x, int y, boolean func(mobj_t*));
boolean P_PathTraverse(fixed_t x1, fixed_t y1, fixed_t x2, fixed_t y2, int flags, boolean trav(intercept_t*));
#endif /* __P_MAPUTL__ */
+507
View File
@@ -0,0 +1,507 @@
/**
* Doom Port to the nRF52840 by Nicola Wrachien (next-hack in the comments)
*
* This port is based on the excellent doomhack's GBA Doom Port,
* with Kippykip additions.
*
* Several data structures and functions have been optimized
* to fit in only 256kB RAM of nRF52840 (GBA has 384 kB RAM).
* Z-Depth Light has been restored with almost no RAM consumption!
* Tons of speed optimizations have been done, and the game now
* runs extremely fast, despite the much higher 3D resolution with
* respect to GBA.
*
* PrBoom: a Doom port merged with LxDoom and LSDLDoom
* based on BOOM, a modified and improved DOOM engine
* Copyright (C) 1999 by
* id Software, Chi Hoang, Lee Killough, Jim Flynn, Rand Phares, Ty Halderman
* Copyright (C) 1999-2000 by
* Jess Haas, Nicolas Kalkhof, Colin Phipps, Florian Schulze
* Copyright 2005, 2006 by
* Florian Schulze, Colin Phipps, Neil Stevens, Andrey Budko
* Copyright (C) 2021 Nicola Wrachien (next-hack in the comments)
* on nRF52840 port.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
* 02111-1307, USA.
*
* DESCRIPTION:
* Map Objects, MObj, definition and handling.
*
* next-hack: optimzed a lot this, bringing the structure size from 140 b
* down to 92 bytes. Added also static_mobj_t, which uses only 44 bytes.
*
*-----------------------------------------------------------------------------*/
#ifndef __P_MOBJ__
#define __P_MOBJ__
// Basics.
#include "tables.h"
#include "m_fixed.h"
// We need the thinker_t stuff.
#include "d_think.h"
// We need the WAD data structure for Map things,
// from the THINGS lump.
#include "doomdata.h"
// States are tied to finite states are
// tied to animation frames.
// Needs precompiled tables/data structures.
#include "info.h"
//
// NOTES: mobj_t
//
// mobj_ts are used to tell the refresh where to draw an image,
// tell the world simulation when objects are contacted,
// and tell the sound driver how to position a sound.
//
// The refresh uses the next and prev links to follow
// lists of things in sectors as they are being drawn.
// The sprite, frame, and angle elements determine which patch_t
// is used to draw the sprite if it is visible.
// The sprite and frame values are allmost allways set
// from state_t structures.
// The statescr.exe utility generates the states.h and states.c
// files that contain the sprite/frame numbers from the
// statescr.txt source file.
// The xyz origin point represents a point at the bottom middle
// of the sprite (between the feet of a biped).
// This is the default origin position for patch_ts grabbed
// with lumpy.exe.
// A walking creature will have its z equal to the floor
// it is standing on.
//
// The sound code uses the x,y, and subsector fields
// to do stereo positioning of any sound effited by the mobj_t.
//
// The play simulation uses the blocklinks, x,y,z, radius, height
// to determine when mobj_ts are touching each other,
// touching lines in the map, or hit by trace lines (gunshots,
// lines of sight, etc).
// The mobj_t->flags element has various bit flags
// used by the simulation.
//
// Every mobj_t is linked into a single sector
// based on its origin coordinates.
// The subsector_t is found with R_PointInSubsector(x,y),
// and the sector_t can be found with subsector->sector.
// The sector links are only used by the rendering code,
// the play simulation does not care about them at all.
//
// Any mobj_t that needs to be acted upon by something else
// in the play world (block movement, be shot, etc) will also
// need to be linked into the blockmap.
// If the thing has the MF_NOBLOCK flag set, it will not use
// the block links. It can still interact with other things,
// but only as the instigator (missiles will run into other
// things, but nothing can run into a missile).
// Each block in the grid is 128*128 units, and knows about
// every line_t that it contains a piece of, and every
// interactable mobj_t that has its origin contained.
//
// A valid mobj_t is a mobj_t that has the proper subsector_t
// filled in for its xy coordinates and is linked into the
// sector from which the subsector was made, or has the
// MF_NOSECTOR flag set (the subsector_t needs to be valid
// even if MF_NOSECTOR is set), and is linked into a blockmap
// block or has the MF_NOBLOCKMAP flag set.
// Links should only be modified by the P_[Un]SetThingPosition()
// functions.
// Do not change the MF_NO? flags while a thing is valid.
//
// Any questions?
//
//
// Misc. mobj flags
//
// Call P_SpecialThing when touched.
#define MF_SPECIAL (unsigned int)(0x0000000000000001)
// Blocks.
#define MF_SOLID (unsigned int)(0x0000000000000002)
// Can be hit.
#define MF_SHOOTABLE (unsigned int)(0x0000000000000004)
// Don't use the sector links (invisible but touchable).
#define MF_NOSECTOR (unsigned int)(0x0000000000000008)
// Don't use the blocklinks (inert but displayable)
#define MF_NOBLOCKMAP (unsigned int)(0x0000000000000010)
// Not to be activated by sound, deaf monster.
#define MF_AMBUSH (unsigned int)(0x0000000000000020)
// Will try to attack right back.
#define MF_JUSTHIT (unsigned int)(0x0000000000000040)
// Will take at least one step before attacking.
#define MF_JUSTATTACKED (unsigned int)(0x0000000000000080)
// On level spawning (initial position),
// hang from ceiling instead of stand on floor.
#define MF_SPAWNCEILING (unsigned int)(0x0000000000000100)
// Don't apply gravity (every tic),
// that is, object will float, keeping current height
// or changing it actively.
#define MF_NOGRAVITY (unsigned int)(0x0000000000000200)
// Movement flags.
// This allows jumps from high places.
#define MF_DROPOFF (unsigned int)(0x0000000000000400)
// For players, will pick up items.
#define MF_PICKUP (unsigned int)(0x0000000000000800)
// Player cheat. ???
#define MF_NOCLIP (unsigned int)(0x0000000000001000)
// Player: keep info about sliding along walls.
#define MF_SLIDE (unsigned int)(0x0000000000002000)
// Allow moves to any height, no gravity.
// For active floaters, e.g. cacodemons, pain elementals.
#define MF_FLOAT (unsigned int)(0x0000000000004000)
// Don't cross lines
// ??? or look at heights on teleport.
#define MF_TELEPORT (unsigned int)(0x0000000000008000)
// Don't hit same species, explode on block.
// Player missiles as well as fireballs of various kinds.
#define MF_MISSILE (unsigned int)(0x0000000000010000)
// Dropped by a demon, not level spawned.
// E.g. ammo clips dropped by dying former humans.
#define MF_DROPPED (unsigned int)(0x0000000000020000)
// Use fuzzy draw (shadow demons or spectres),
// temporary player invisibility powerup.
#define MF_SHADOW (unsigned int)(0x0000000000040000)
// Flag: don't bleed when shot (use puff),
// barrels and shootable furniture shall not bleed.
#define MF_NOBLOOD (unsigned int)(0x0000000000080000)
// Don't stop moving halfway off a step,
// that is, have dead bodies slide down all the way.
#define MF_CORPSE (unsigned int)(0x0000000000100000)
// Floating to a height for a move, ???
// don't auto float to target's height.
#define MF_INFLOAT (unsigned int)(0x0000000000200000)
// On kill, count this enemy object
// towards intermission kill total.
// Happy gathering.
#define MF_COUNTKILL (unsigned int)(0x0000000000400000)
// On picking up, count this item object
// towards intermission item total.
#define MF_COUNTITEM (unsigned int)(0x0000000000800000)
// Special handling: skull in flight.
// Neither a cacodemon nor a missile.
#define MF_SKULLFLY (unsigned int)(0x0000000001000000)
// Don't spawn this object
// in death match mode (e.g. key cards).
#define MF_NOTDMATCH (unsigned int)(0x0000000002000000)
// Player sprites in multiplayer modes are modified
// using an internal color lookup table for re-indexing.
// If 0x4 0x8 or 0xc,
// use a translation table for player colormaps
#define MF_TRANSLATION (unsigned int)(0x000000000c000000)
#define MF_TRANSLATION1 (unsigned int)(0x0000000004000000)
#define MF_TRANSLATION2 (unsigned int)(0x0000000008000000)
// Hmm ???.
#define MF_TRANSSHIFT 26
//#define MF_UNUSED2 (unsigned int)(0x0000000010000000)
#define MF_DECORATION (unsigned int)(0x0000000010000000) // next-hack.
#define MF_STATIC (MF_DECORATION | MF_SPECIAL) // next-hack. Objects with this flags go in the static mobj zone, and occupy less RAM
#define MF_UNUSED3 (unsigned int)(0x0000000020000000)
// Translucent sprite? // phares
#define MF_TRANSLUCENT (unsigned int)(0x0000000040000000)
#define MF_FRIEND (unsigned int)(0x0000000080000000)
// killough 9/15/98: Same, but internal flags, not intended for .deh
// (some degree of opaqueness is good, to avoid compatibility woes)
enum
{
MIF_FALLING = 1 // Object is falling
};
// Map Object definition.
//
//
// killough 2/20/98:
//
// WARNING: Special steps must be taken in p_saveg.c if C pointers are added to
// this mobj_s struct, or else savegames will crash when loaded. See p_saveg.c.
// Do not add "struct mobj_s *fooptr" without adding code to p_saveg.c to
// convert the pointers to ordinals and back for savegames. This was the whole
// reason behind monsters going to sleep when loading savegames (the "target"
// pointer was simply nullified after loading, to prevent Doom from crashing),
// and the whole reason behind loadgames crashing on savegames of AV attacks.
//
// killough 9/8/98: changed some fields to shorts,
// for better memory usage (if only for cache).
/* cph 2006/08/28 - move Prev[XYZ] fields to the end of the struct. Add any
* other new fields to the end, and make sure you don't break savegames! */
// 18/06/2021 next-hack. New Simplicity Studio 5.2 comes with a newer GNU
// toolchain version and it complains that member thinker might be unaligned as
// mobj_t and static_mobj_t are packed.
// We could pass simply the mobj address, and cast it to thinker_t*, but it is
// better to use unpacked structures at this point. Noticeably, there should
// not be any change in size because we carefully we reordered members to prevent
// paddings but to be sure we don't accidentally mess, we declare our expected
// size here, and an array that has null size if the size is correct, otherwise
// it will have a negative size, generating an error.
//
#define MOBJ_SIZE 92
#define STATIC_MOBJ_SIZE 44
//
typedef struct mobj_s
{
// WARNING: the order of these variables is important! It must be kept the same as static_mobj
// List: thinker links.
thinker_t thinker;
// killough 11/98: the lowest floor over all contacted Sectors.
unsigned int flags; // must be 32bit at least
// Interaction info, by BLOCKMAP.
// Links in blocks (if needed).
unsigned short bnext_sptr;
unsigned short bprev_sptr;
// sector linked list. Note: short pointers.
unsigned short snext_sptr;
unsigned short sprev_sptr;
// a linked list of sectors where this object appears
// For movement checking.
short tics:14; // state tic counter
unsigned short lastlook:2;
uint8_t type; // less than 255 mobjtypes.
uint8_t sprite; // used to find patch_t and flip value
//
uint16_t frame; // might be ORed with FF_FULLBRIGHT (0x8000) but we do not need an int
unsigned short state_idx :11; // there are less than 2048 states
//short movedir; // 0-8
//
unsigned short subsector_sptr;
unsigned short touching_sectorlist_sptr;
//
// Info for drawing: position.
fixed_t x;
fixed_t y;
fixed_t z;
//
// The closest interval over all contacted Sectors.
fixed_t ceilingz;
fixed_t floorz;
fixed_t dropoffz;
//
uint8_t height_s; // we could reduce this too
uint8_t radiusb; // now it is a byte...
int16_t health; // max is 4000 but we need a negative value
// AFTER THIS LINE, THE SUBSEQUENT PARAMETERS ARE MISSING IN THE STATIC MOBJ TYPE
//More drawing info: to determine current sprite.
angle_t angle; // orientation
//
// Momentums, used to update position.
fixed_t momx;
fixed_t momy;
fixed_t momz;
// Additional info record for player avatars only.
// Only valid if type == MT_PLAYER
unsigned short player_sptr;
// new field: last known enemy -- killough 2/15/98
//struct mobj_s* lastenemy;
unsigned short lastenemy_sptr;
//
// Thing being chased/attacked (or NULL),
// also the originator for missiles.
//struct mobj_s* target;
unsigned short target_sptr;
// Thing being chased/attacked for tracers.
//struct mobj_s* tracer;
unsigned short tracer_sptr;
//
//
// const state_t* state;
//
// Movement direction, movement generation (zig-zagging).
int movecount :12; // when 0, select a new dir
int strafecount :12; // killough 9/8/98: monster strafing
int movedir :5; // 0-8
// Reaction time: if non 0, don't attack yet.
// Used by player to freeze a bit after teleporting.
// short reactiontime;
uint8_t reactiontime;
//
// If >0, the current target will be chased no
// matter what (even if shot by another object)
uint8_t threshold; // could be uint8_t
//
// killough 9/9/98: How long a monster pursues a target.
uint8_t pursuecount;
uint8_t dummy;
} mobj_t;
//
typedef struct static_mobj_s
{
// WARNING: the order of these variables is important! It must be kept the same as static_mobj
// List: thinker links.
thinker_t thinker;
// The closest interval over all contacted Sectors.
// killough 11/98: the lowest floor over all contacted Sectors.
unsigned int flags; // must be 32bit at least
// Interaction info, by BLOCKMAP.
// Links in blocks (if needed).
unsigned short bnext_sptr;
unsigned short bprev_sptr;
// sector linked list. Note: short pointers.
unsigned short snext_sptr;
unsigned short sprev_sptr;
// a linked list of sectors where this object appears
// For movement checking.
short tics:14; // state tic counter
unsigned short lastlook:2;
uint8_t type; // less than 255 mobjtypes.
// Actually we do not really need a sprite, it is used very seldom
uint8_t sprite; // used to find patch_t and flip value
//
uint16_t frame; // might be ORed with FF_FULLBRIGHT (0x8000) but we do not need an int
unsigned short state_idx :11; // there are less than 2048 states
//short movedir; // 0-8
//
unsigned short subsector_sptr;
unsigned short touching_sectorlist_sptr;
//
// Info for drawing: position.
fixed_t x;
fixed_t y;
fixed_t z;
} static_mobj_t;
static inline fixed_t getMobjHeight(mobj_t *pmobj)
{
if (!(pmobj->flags & MF_STATIC))
return pmobj->height_s << FRACBITS;
else
return mobjinfo[pmobj->type].height;
}
static inline fixed_t getMobjRadius(mobj_t *pmobj)
{
if (!(pmobj->flags & MF_STATIC))
return pmobj->radiusb << FRACBITS;
else
return mobjinfo[pmobj->type].radius;
}
static inline const mobjinfo_t* getMobjInfo(mobj_t *pmobj)
{
return &mobjinfo[pmobj->type];
}
static inline mobj_t* getLastEnemy(mobj_t *pmobj)
{
return (mobj_t*) getLongPtr(pmobj->lastenemy_sptr);
}
static inline mobj_t* getTracer(mobj_t *pmobj)
{
return (mobj_t*) getLongPtr(pmobj->tracer_sptr);
}
static inline mobj_t* getTarget(mobj_t *pmobj)
{
return (mobj_t*) getLongPtr(pmobj->target_sptr);
}
static inline mobj_t* getSNext(mobj_t *pmobj)
{
return (mobj_t*) getLongPtr(pmobj->snext_sptr);
}
static inline mobj_t* getSPrev(mobj_t *pmobj)
{
return (mobj_t*) getLongPtr(pmobj->sprev_sptr);
}
static inline mobj_t* getBNext(mobj_t *pmobj)
{
return (mobj_t*) getLongPtr(pmobj->bnext_sptr);
}
static inline mobj_t* getBPrev(mobj_t *pmobj)
{
return (mobj_t*) getLongPtr(pmobj->bprev_sptr);
}
static inline struct player_s* getMobjPlayer(mobj_t *pmobj)
{
return (struct player_s*) getLongPtr(pmobj->player_sptr);
}
static inline const state_t* getMobjState(mobj_t *pmobj)
{
unsigned short index = pmobj->state_idx;
if (index >= NUMSTATES || index == S_NULL) // TODO: is really needed this one?
return NULL;
return &states[index];
}
// External declarations (fomerly in p_local.h) -- killough 5/2/98
#define VIEWHEIGHT (41*FRACUNIT)
#define GRAVITY FRACUNIT
#define MAXMOVE (30*FRACUNIT)
#define ONFLOORZ INT_MIN
#define ONCEILINGZ INT_MAX
// Time interval for item respawning.
#define ITEMQUESIZE 32
#define FLOATSPEED (FRACUNIT*4)
#define STOPSPEED (FRACUNIT/16)
// killough 11/98:
// For torque simulation:
#define OVERDRIVE 6
#define MAXGEAR (OVERDRIVE+16)
// killough 11/98:
// Whether an object is "sentient" or not. Used for environmental influences.
#define sentient(mobj) ((mobj)->health > 0 && (mobj)->info->seestate)
void P_RespawnSpecials(void);
mobj_t* P_SpawnMobj(fixed_t x, fixed_t y, fixed_t z, mobjtype_t type);
static_mobj_t* P_SpawnStaticMobj(fixed_t x, fixed_t y, fixed_t z, mobjtype_t type); // 2021-03-13 next-hack
void P_RemoveMobj(mobj_t *th);
void P_RemoveStaticMobj(static_mobj_t *mobj); // 2021-03-13 next-hack
boolean P_SetMobjState(mobj_t *mobj, statenum_t state);
void P_MobjThinker(mobj_t *mobj);
void P_MobjBrainlessThinker(mobj_t *mobj);
void P_SpawnPuff(fixed_t x, fixed_t y, fixed_t z);
void P_SpawnBlood(fixed_t x, fixed_t y, fixed_t z, int damage);
mobj_t* P_SpawnMissile(mobj_t *source, mobj_t *dest, mobjtype_t type);
void P_SpawnPlayerMissile(mobj_t *source, mobjtype_t type);
boolean P_IsDoomnumAllowed(int doomnum);
void P_SpawnMapThing(const mapthing_t *mthing);
void P_SpawnPlayer(int n, const mapthing_t *mthing);
void P_CheckMissileSpawn(mobj_t*); // killough 8/2/98
void P_ExplodeMissile(mobj_t*); // killough
#endif
+132
View File
@@ -0,0 +1,132 @@
/**
* Doom Port to the nRF52840 by Nicola Wrachien (next-hack in the comments)
*
* This port is based on the excellent doomhack's GBA Doom Port,
* with Kippykip additions.
*
* Several data structures and functions have been optimized
* to fit in only 256kB RAM of nRF52840 (GBA has 384 kB RAM).
* Z-Depth Light has been restored with almost no RAM consumption!
* Tons of speed optimizations have been done, and the game now
* runs extremely fast, despite the much higher 3D resolution with
* respect to GBA.
*
* PrBoom: a Doom port merged with LxDoom and LSDLDoom
* based on BOOM, a modified and improved DOOM engine
* Copyright (C) 1999 by
* id Software, Chi Hoang, Lee Killough, Jim Flynn, Rand Phares, Ty Halderman
* Copyright (C) 1999-2000 by
* Jess Haas, Nicolas Kalkhof, Colin Phipps, Florian Schulze
* Copyright 2005, 2006 by
* Florian Schulze, Colin Phipps, Neil Stevens, Andrey Budko
* Copyright (C) 2021 Nicola Wrachien (next-hack in the comments)
* on nRF52840 port.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
* 02111-1307, USA.
*
* DESCRIPTION:
* Sprite animation.
*
*-----------------------------------------------------------------------------*/
#ifndef __P_PSPR__
#define __P_PSPR__
/* Basic data types.
* Needs fixed point, and BAM angles. */
#include "m_fixed.h"
#include "tables.h"
/* Needs to include the precompiled sprite animation tables.
*
* Header generated by multigen utility.
* This includes all the data for thing animation,
* i.e. the Thing Atrributes table and the Frame Sequence table.
*/
#include "info.h"
#ifdef __GNUG__
#pragma interface
#endif
/*
* Frame flags:
* handles maximum brightness (torches, muzzle flare, light sources)
*/
#define FF_FULLBRIGHT 0x8000 /* flag in thing->frame */
#define FF_FRAMEMASK 0x7fff
/*
* Overlay psprites are scaled shapes
* drawn directly on the view screen,
* coordinates are given for a 320*200 view screen.
*/
typedef enum
{
ps_weapon, ps_flash, NUMPSPRITES
} psprnum_t;
typedef struct
{
const state_t *state; /* a NULL state means not active */
int tics;
fixed_t sx;
fixed_t sy;
} pspdef_t;
extern const int weapon_preferences[NUMWEAPONS + 1]; /* killough 5/2/98 */
int P_WeaponPreferred(int w1, int w2);
struct player_s;
int P_SwitchWeapon(struct player_s *player);
boolean P_CheckAmmo(struct player_s *player);
void P_SetupPsprites(struct player_s *curplayer);
void P_MovePsprites(struct player_s *curplayer);
void P_DropWeapon(struct player_s *player);
int P_WeaponCycleUp(struct player_s *player);
int P_WeaponCycleDown(struct player_s *player);
void A_Light0();
void A_WeaponReady();
void A_Lower();
void A_Raise();
void A_Punch();
void A_ReFire();
void A_FirePistol();
void A_Light1();
void A_FireShotgun();
void A_Light2();
void A_FireShotgun2();
void A_CheckReload();
void A_OpenShotgun2();
void A_LoadShotgun2();
void A_CloseShotgun2();
void A_FireCGun();
void A_GunFlash();
void A_FireMissile();
void A_Saw();
void A_FirePlasma();
void A_BFGsound();
void A_FireBFG();
void A_BFGSpray();
#endif
+57
View File
@@ -0,0 +1,57 @@
/**
* Doom Port to the nRF52840 by Nicola Wrachien (next-hack in the comments)
*
* This port is based on the excellent doomhack's GBA Doom Port,
* with Kippykip additions.
*
* Several data structures and functions have been optimized
* to fit in only 256kB RAM of nRF52840 (GBA has 384 kB RAM).
* Z-Depth Light has been restored with almost no RAM consumption!
* Tons of speed optimizations have been done, and the game now
* runs extremely fast, despite the much higher 3D resolution with
* respect to GBA.
*
* PrBoom: a Doom port merged with LxDoom and LSDLDoom
* based on BOOM, a modified and improved DOOM engine
* Copyright (C) 1999 by
* id Software, Chi Hoang, Lee Killough, Jim Flynn, Rand Phares, Ty Halderman
* Copyright (C) 1999-2000 by
* Jess Haas, Nicolas Kalkhof, Colin Phipps, Florian Schulze
* Copyright 2005, 2006 by
* Florian Schulze, Colin Phipps, Neil Stevens, Andrey Budko
* Copyright (C) 2021 Nicola Wrachien (next-hack in the comments)
* on nRF52840 port.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
* 02111-1307, USA.
*
* DESCRIPTION:
* Setup a game, startup stuff.
*
*-----------------------------------------------------------------------------*/
#ifndef __P_SETUP__
#define __P_SETUP__
#include "p_mobj.h"
#ifdef __GNUG__
#pragma interface
#endif
void P_SetupLevel(int episode, int map, int playermask, skill_t skill);
void P_Init(void); /* Called by startup code. */
#endif
+992
View File
@@ -0,0 +1,992 @@
/**
* Doom Port to the nRF52840 by Nicola Wrachien (next-hack in the comments)
*
* This port is based on the excellent doomhack's GBA Doom Port,
* with Kippykip additions.
*
* Several data structures and functions have been optimized
* to fit in only 256kB RAM of nRF52840 (GBA has 384 kB RAM).
* Z-Depth Light has been restored with almost no RAM consumption!
* Tons of speed optimizations have been done, and the game now
* runs extremely fast, despite the much higher 3D resolution with
* respect to GBA.
*
* PrBoom: a Doom port merged with LxDoom and LSDLDoom
* based on BOOM, a modified and improved DOOM engine
* Copyright (C) 1999 by
* id Software, Chi Hoang, Lee Killough, Jim Flynn, Rand Phares, Ty Halderman
* Copyright (C) 1999-2000 by
* Jess Haas, Nicolas Kalkhof, Colin Phipps, Florian Schulze
* Copyright 2005, 2006 by
* Florian Schulze, Colin Phipps, Neil Stevens, Andrey Budko
* Copyright (C) 2021 Nicola Wrachien (next-hack in the comments)
* on nRF52840 port.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
* 02111-1307, USA.
*
* DESCRIPTION: definitions, declarations and prototypes for specials
*
*-----------------------------------------------------------------------------*/
// TODO: A lot to optimize here.
#ifndef __P_SPEC__
#define __P_SPEC__
#include "r_defs.h"
#include "d_player.h"
// Define values for map objects
#define MO_TELEPORTMAN 14
// p_floor
#define ELEVATORSPEED (FRACUNIT*4)
#define FLOORSPEED FRACUNIT
// p_ceilng
#define CEILSPEED FRACUNIT
#define CEILWAIT 150
// p_doors
#define VDOORSPEED (FRACUNIT*2)
#define VDOORWAIT 150
// p_plats
#define PLATWAIT 3
#define PLATSPEED FRACUNIT
// p_switch
// 4 players, 4 buttons each at once, max.
// killough 2/14/98: redefine in terms of MAXPLAYERS
#define MAXBUTTONS (MAXPLAYERS*4)
#define MAXSWITCHES 50
// 1 second, in ticks.
#define BUTTONTIME TICRATE
// p_lights
#define GLOWSPEED 8
#define STROBEBRIGHT 5
#define FASTDARK 15
#define SLOWDARK 35
//jff 3/14/98 add bits and shifts for generalized sector types
#define DAMAGE_MASK 0x60
#define DAMAGE_SHIFT 5
#define SECRET_MASK 0x80
#define SECRET_SHIFT 7
#define FRICTION_MASK 0x100
#define FRICTION_SHIFT 8
#define PUSH_MASK 0x200
#define PUSH_SHIFT 9
//jff 02/04/98 Define masks, shifts, for fields in
// generalized linedef types
#define GenEnd 0x8000
#define GenFloorBase 0x6000
#define GenCeilingBase 0x4000
#define GenDoorBase 0x3c00
#define GenLockedBase 0x3800
#define GenLiftBase 0x3400
#define GenStairsBase 0x3000
#define GenCrusherBase 0x2F80
#define TriggerType 0x0007
#define TriggerTypeShift 0
// define masks and shifts for the floor type fields
#define FloorCrush 0x1000
#define FloorChange 0x0c00
#define FloorTarget 0x0380
#define FloorDirection 0x0040
#define FloorModel 0x0020
#define FloorSpeed 0x0018
#define FloorCrushShift 12
#define FloorChangeShift 10
#define FloorTargetShift 7
#define FloorDirectionShift 6
#define FloorModelShift 5
#define FloorSpeedShift 3
// define masks and shifts for the ceiling type fields
#define CeilingCrush 0x1000
#define CeilingChange 0x0c00
#define CeilingTarget 0x0380
#define CeilingDirection 0x0040
#define CeilingModel 0x0020
#define CeilingSpeed 0x0018
#define CeilingCrushShift 12
#define CeilingChangeShift 10
#define CeilingTargetShift 7
#define CeilingDirectionShift 6
#define CeilingModelShift 5
#define CeilingSpeedShift 3
// define masks and shifts for the lift type fields
#define LiftTarget 0x0300
#define LiftDelay 0x00c0
#define LiftMonster 0x0020
#define LiftSpeed 0x0018
#define LiftTargetShift 8
#define LiftDelayShift 6
#define LiftMonsterShift 5
#define LiftSpeedShift 3
// define masks and shifts for the stairs type fields
#define StairIgnore 0x0200
#define StairDirection 0x0100
#define StairStep 0x00c0
#define StairMonster 0x0020
#define StairSpeed 0x0018
#define StairIgnoreShift 9
#define StairDirectionShift 8
#define StairStepShift 6
#define StairMonsterShift 5
#define StairSpeedShift 3
// define masks and shifts for the crusher type fields
#define CrusherSilent 0x0040
#define CrusherMonster 0x0020
#define CrusherSpeed 0x0018
#define CrusherSilentShift 6
#define CrusherMonsterShift 5
#define CrusherSpeedShift 3
// define masks and shifts for the door type fields
#define DoorDelay 0x0300
#define DoorMonster 0x0080
#define DoorKind 0x0060
#define DoorSpeed 0x0018
#define DoorDelayShift 8
#define DoorMonsterShift 7
#define DoorKindShift 5
#define DoorSpeedShift 3
// define masks and shifts for the locked door type fields
#define LockedNKeys 0x0200
#define LockedKey 0x01c0
#define LockedKind 0x0020
#define LockedSpeed 0x0018
#define LockedNKeysShift 9
#define LockedKeyShift 6
#define LockedKindShift 5
#define LockedSpeedShift 3
// define names for the TriggerType field of the general linedefs
typedef enum
{
WalkOnce,
WalkMany,
SwitchOnce,
SwitchMany,
GunOnce,
GunMany,
PushOnce,
PushMany,
} triggertype_e;
// define names for the Speed field of the general linedefs
typedef enum
{
SpeedSlow, SpeedNormal, SpeedFast, SpeedTurbo,
} motionspeed_e;
// define names for the Target field of the general floor
typedef enum
{
FtoHnF, FtoLnF, FtoNnF, FtoLnC, FtoC, FbyST, Fby24, Fby32,
} floortarget_e;
// define names for the Changer Type field of the general floor
typedef enum
{
FNoChg, FChgZero, FChgTxt, FChgTyp,
} floorchange_e;
// define names for the Change Model field of the general floor
typedef enum
{
FTriggerModel, FNumericModel,
} floormodel_t;
// define names for the Target field of the general ceiling
typedef enum
{
CtoHnC, CtoLnC, CtoNnC, CtoHnF, CtoF, CbyST, Cby24, Cby32,
} ceilingtarget_e;
// define names for the Changer Type field of the general ceiling
typedef enum
{
CNoChg, CChgZero, CChgTxt, CChgTyp,
} ceilingchange_e;
// define names for the Change Model field of the general ceiling
typedef enum
{
CTriggerModel, CNumericModel,
} ceilingmodel_t;
// define names for the Target field of the general lift
typedef enum
{
F2LnF, F2NnF, F2LnC, LnF2HnF,
} lifttarget_e;
// define names for the door Kind field of the general ceiling
typedef enum
{
OdCDoor, ODoor, CdODoor, CDoor,
} doorkind_e;
// define names for the locked door Kind field of the general ceiling
typedef enum
{
AnyKey, RCard, BCard, YCard, RSkull, BSkull, YSkull, AllKeys,
} keykind_e;
//////////////////////////////////////////////////////////////////
//
// enums for classes of linedef triggers
//
//////////////////////////////////////////////////////////////////
//jff 2/23/98 identify the special classes that can share sectors
typedef enum
{
floor_special, ceiling_special, lighting_special,
} special_e;
//jff 3/15/98 pure texture/type change for better generalized support
typedef enum
{
trigChangeOnly, numChangeOnly,
} change_e;
// p_plats
typedef enum
{
up, down, waiting, in_stasis
} plat_e;
typedef enum
{
perpetualRaise,
downWaitUpStay,
raiseAndChange,
raiseToNearestAndChange,
blazeDWUS,
genLift, //jff added to support generalized Plat types
genPerpetual,
toggleUpDn, //jff 3/14/98 added to support instant toggle type
} plattype_e;
// p_doors
typedef enum
{
normal,
close30ThenOpen,
dclose,
dopen,
raiseIn5Mins,
blazeRaise,
blazeOpen,
blazeClose,
//jff 02/05/98 add generalize door types
genRaise,
genBlazeRaise,
genOpen,
genBlazeOpen,
genClose,
genBlazeClose,
genCdO,
genBlazeCdO,
} vldoor_e;
// p_ceilng
typedef enum
{
lowerToFloor,
raiseToHighest,
lowerToLowest,
lowerToMaxFloor,
lowerAndCrush,
crushAndRaise,
fastCrushAndRaise,
silentCrushAndRaise,
//jff 02/04/98 add types for generalized ceiling mover
genCeiling,
genCeilingChg,
genCeilingChg0,
genCeilingChgT,
//jff 02/05/98 add types for generalized ceiling mover
genCrusher,
genSilentCrusher,
} ceiling_e;
// p_floor
typedef enum
{
// lower floor to highest surrounding floor
lowerFloor,
// lower floor to lowest surrounding floor
lowerFloorToLowest,
// lower floor to highest surrounding floor VERY FAST
turboLower,
// raise floor to lowest surrounding CEILING
raiseFloor,
// raise floor to next highest surrounding floor
raiseFloorToNearest,
//jff 02/03/98 lower floor to next lowest neighbor
lowerFloorToNearest,
//jff 02/03/98 lower floor 24 absolute
lowerFloor24,
//jff 02/03/98 lower floor 32 absolute
lowerFloor32Turbo,
// raise floor to shortest height texture around it
raiseToTexture,
// lower floor to lowest surrounding floor
// and change floorpic
lowerAndChange,
raiseFloor24,
//jff 02/03/98 raise floor 32 absolute
raiseFloor32Turbo,
raiseFloor24AndChange,
raiseFloorCrush,
// raise to next highest floor, turbo-speed
raiseFloorTurbo,
donutRaise,
raiseFloor512,
//jff 02/04/98 add types for generalized floor mover
genFloor,
genFloorChg,
genFloorChg0,
genFloorChgT,
//new types for stair builders
buildStair,
genBuildStair,
} floor_e;
typedef enum
{
build8, // slowly build by 8
turbo16 // quickly build by 16
} stair_e;
typedef enum
{
elevateUp, elevateDown, elevateCurrent,
} elevator_e;
//////////////////////////////////////////////////////////////////
//
// general enums
//
//////////////////////////////////////////////////////////////////
// texture type enum
typedef enum
{
top, middle, bottom
} bwhere_e;
// crush check returns
typedef enum
{
ok, crushed, pastdest
} result_e;
//////////////////////////////////////////////////////////////////
//
// linedef and sector special data types
//
//////////////////////////////////////////////////////////////////
// p_switch
// switch animation structure type
#if defined(__MWERKS__)
#pragma options align=packed
#endif
typedef struct
{
char name1[9];
char name2[9];
short episode;
} PACKEDATTR switchlist_t; //jff 3/23/98 pack to read from memory
#if defined(__MWERKS__)
#pragma options align=reset
#endif
typedef struct
{
const line_t *line;
int btimer;
degenmobj_t *soundorg;
short btexture;
byte where;
} button_t;
// p_lights
typedef struct
{
thinker_t thinker;
sector_t *sector;
short count;
byte maxlight;
byte minlight;
} fireflicker_t;
typedef struct
{
thinker_t thinker;
sector_t *sector;
short count;
byte maxlight;
byte minlight;
short maxtime;
short mintime;
} lightflash_t;
typedef struct
{
thinker_t thinker;
sector_t *sector;
short count;
byte minlight;
byte maxlight;
short darktime;
short brighttime;
} strobe_t;
typedef struct
{
thinker_t thinker;
sector_t *sector;
byte minlight;
byte maxlight;
short direction;
} glow_t;
// p_plats
typedef struct
{
thinker_t thinker;
sector_t *sector;
fixed_t speed;
fixed_t low;
fixed_t high;
short wait;
short count;
uint8_t status;
uint8_t oldstatus;
boolean crush;
short tag;
byte type;
struct platlist *list; // killough
} plat_t;
// New limit-free plat structure -- killough
typedef struct platlist
{
plat_t *plat;
struct platlist *next, **prev;
} platlist_t;
// p_ceilng
#if 1
typedef struct
{
thinker_t thinker;
vldoor_e type;
sector_t *sector;
fixed_t topheight;
fixed_t speed;
// 1 = up, 0 = waiting at top, -1 = down
int direction;
// tics to wait at the top
int topwait;
// (keep in case a door going down is reset)
// when it reaches 0, start going down
int topcountdown;
//jff 1/31/98 keep track of line door is triggered by
const line_t *line;
/* killough 10/98: sector tag for gradual lighting effects */
int lighttag;
} vldoor_t;
#else
typedef struct
{
thinker_t thinker;
sector_t* sector;
fixed_t topheight;
fixed_t speed;
//jff 1/31/98 keep track of line door is triggered by
const line_t *line;
// tics to wait at the top
short topwait;
// (keep in case a door going down is reset)
// when it reaches 0, start going down
short topcountdown;
/* killough 10/98: sector tag for gradual lighting effects */
short lighttag;
// 1 = up, 0 = waiting at top, -1 = down
char direction;
byte type;
} vldoor_t;
#endif
// p_doors
typedef struct
{
thinker_t thinker;
ceiling_e type;
sector_t *sector;
fixed_t bottomheight;
fixed_t topheight;
fixed_t speed;
fixed_t oldspeed;
struct ceilinglist *list; // jff 2/22/98 copied from killough's plats
//jff 02/04/98 add these to support ceiling changers
short newspecial; // was int!
short oldspecial; //jff 3/14/98 add to fix bug in change transfers
short texture;
// ID
short tag;
// 1 = up, 0 = waiting, -1 = down
signed char direction;
signed char olddirection;
boolean crush;
} ceiling_t;
typedef struct ceilinglist
{
ceiling_t *ceiling;
struct ceilinglist *next, **prev;
} ceilinglist_t;
// p_floor
typedef struct
{
thinker_t thinker;
fixed_t floordestheight;
fixed_t speed;
// sector_t* sector;
unsigned short sector_sptr;
short newspecial;
short oldspecial; //jff 3/14/98 add to fix bug in change transfers
short texture;
int8_t direction;
int8_t type;
boolean crush;
} floormove_t;
static inline sector_t* getFloorMoveSector(floormove_t *p_fm)
{
return (sector_t*) getLongPtr(p_fm->sector_sptr);
}
typedef struct
{
thinker_t thinker;
sector_t *sector;
fixed_t floordestheight;
fixed_t ceilingdestheight;
fixed_t speed;
signed char direction;
byte type;
} elevator_t;
// p_spec
// killough 3/7/98: Add generalized scroll effects
typedef struct
{
thinker_t thinker; // Thinker structure for scrolling
int affectee; // Number of affected sidedef, sector, tag, or whatever
} scroll_t;
// phares 3/12/98: added new model of friction for ice/sludge effects
typedef struct
{
//thinker_t thinker; // Thinker structure for friction
int friction; // friction value (E800 = normal)
//int movefactor; // inertia factor when adding to momentum
int affectee; // Number of affected sector
} friction_t;
// phares 3/20/98: added new model of Pushers for push/pull effects
enum
{
p_push, p_pull, p_wind, p_current,
};
typedef struct
{
thinker_t thinker; // Thinker structure for Pusher
mobj_t *source; // Point source if point pusher
short x_mag; // X Strength
short y_mag; // Y Strength
short magnitude; // Vector strength for point pusher
short radius; // Effective radius for point pusher
short x; // X of point source if point pusher
short y; // Y of point source if point pusher
short affectee; // Number of affected sector
byte type;
} pusher_t;
//
// Animating textures and planes
// There is another anim_t used in wi_stuff, unrelated.
//
typedef struct
{
int picnum :12;
int basepic :10;
int numpics :10;
short speed :15;
short istexture :1;
} __attribute__ ((packed)) anim_t;
//
// source animation definition
//
//
typedef struct
{
signed char istexture; //jff 3/23/98 make char for comparison // cph - make signed
char endname[9]; // if false, it is a flat
char startname[9];
short speed;
} PACKEDATTR animdef_t; //jff 3/23/98 pack to read from memory
#define MAXANIMS 32
////////////////////////////////////////////////////////////////
//
// Linedef and sector special utility function prototypes
//
////////////////////////////////////////////////////////////////
int twoSided(int sector, int line);
side_t* getSide(int currentSector, int line, int side);
fixed_t P_FindLowestFloorSurrounding(sector_t *sec);
fixed_t P_FindHighestFloorSurrounding(sector_t *sec);
fixed_t P_FindNextHighestFloor(sector_t *sec, int currentheight);
fixed_t P_FindNextLowestFloor(sector_t *sec, int currentheight);
fixed_t P_FindLowestCeilingSurrounding(sector_t *sec); // jff 2/04/98
fixed_t P_FindHighestCeilingSurrounding(sector_t *sec); // jff 2/04/98
fixed_t P_FindNextLowestCeiling(sector_t *sec, int currentheight); // jff 2/04/98
fixed_t P_FindNextHighestCeiling(sector_t *sec, int currentheight); // jff 2/04/98
fixed_t P_FindShortestTextureAround(int secnum); // jff 2/04/98
fixed_t P_FindShortestUpperAround(int secnum); // jff 2/04/98
sector_t* P_FindModelFloorSector(fixed_t floordestheight, int secnum); //jff 02/04/98
sector_t* P_FindModelCeilingSector(fixed_t ceildestheight, int secnum); //jff 02/04/98
int P_FindSectorFromLineTag(const line_t *line, int start); // killough 4/17/98
int P_FindLineFromLineTag(const line_t *line, int start); // killough 4/17/98
int P_FindMinSurroundingLight(sector_t *sector, int max);
sector_t* getNextSector(const line_t *line, sector_t *sec);
int P_CheckTag(const line_t *line); // jff 2/27/98
boolean P_CanUnlockGenDoor(const line_t *line, player_t *player);
boolean P_SectorActive(special_e t, const sector_t *s);
boolean P_IsSecret(const sector_t *sec);
boolean P_WasSecret(const sector_t *sec);
void P_ChangeSwitchTexture(const line_t *line, int useAgain);
////////////////////////////////////////////////////////////////
//
// Linedef and sector special action function prototypes
//
////////////////////////////////////////////////////////////////
// p_lights
void T_LightFlash(lightflash_t *flash);
void T_StrobeFlash(strobe_t *flash);
// jff 8/8/98 add missing thinker for flicker
void T_FireFlicker(fireflicker_t *flick);
void T_Glow(glow_t *g);
// p_plats
void T_PlatRaise(plat_t *plat);
// p_doors
void T_VerticalDoor(vldoor_t *door);
// p_ceilng
void T_MoveCeiling(ceiling_t *ceiling);
// p_floor
result_e T_MovePlane(sector_t *sector, fixed_t speed, fixed_t dest, boolean crush, int floorOrCeiling, int direction);
void T_MoveFloor(floormove_t *floor);
void T_MoveElevator(elevator_t *elevator);
// p_spec
void T_Scroll(scroll_t*); // killough 3/7/98: scroll effect thinker
////////////////////////////////////////////////////////////////
//
// Linedef and sector special handler prototypes
//
////////////////////////////////////////////////////////////////
// p_telept
int EV_Teleport(const line_t *line, int side, mobj_t *thing);
// killough 2/14/98: Add silent teleporter
int EV_SilentTeleport(const line_t *line, int side, mobj_t *thing);
// killough 1/31/98: Add silent line teleporter
int EV_SilentLineTeleport(const line_t *line, int side, mobj_t *thing, boolean reverse);
// p_floor
int
EV_DoElevator(const line_t *line, elevator_e type);
int EV_BuildStairs(const line_t *line, stair_e type);
int EV_DoFloor(const line_t *line, floor_e floortype);
// p_ceilng
int EV_DoCeiling(const line_t *line, ceiling_e type);
int EV_CeilingCrushStop(const line_t *line);
// p_doors
int EV_VerticalDoor(const line_t *line, mobj_t *thing);
int EV_DoDoor(const line_t *line, vldoor_e type);
int EV_DoLockedDoor(const line_t *line, vldoor_e type, mobj_t *thing);
// p_lights
int EV_StartLightStrobing(const line_t *line);
int EV_TurnTagLightsOff(const line_t *line);
int EV_LightTurnOn(const line_t *line, int bright);
int EV_LightTurnOnPartway(const line_t *line, fixed_t level); // killough 10/10/98
// p_floor
int EV_DoChange(const line_t *line, change_e changetype);
int EV_DoDonut(const line_t *line);
// p_plats
int EV_DoPlat(const line_t *line, plattype_e type, int amount);
int EV_StopPlat(const line_t *line);
// p_genlin
int EV_DoGenFloor(const line_t *line);
int EV_DoGenCeiling(const line_t *line);
int EV_DoGenLift(const line_t *line);
int EV_DoGenStairs(const line_t *line);
int EV_DoGenCrusher(const line_t *line);
int EV_DoGenDoor(const line_t *line);
int EV_DoGenLockedDoor(const line_t *line);
////////////////////////////////////////////////////////////////
//
// Linedef and sector special thinker spawning
//
////////////////////////////////////////////////////////////////
// at game start
void P_InitPicAnims(void);
void P_InitSwitchList(void);
// at map load
void P_SpawnSpecials(void);
// every tic
void P_UpdateSpecials(void);
// when needed
boolean P_UseSpecialLine(mobj_t *thing, const line_t *line, int side);
void P_ShootSpecialLine(mobj_t *thing, const line_t *line);
void P_CrossSpecialLine(const line_t *line, int side, mobj_t *thing);
void P_PlayerInSpecialSector(player_t *player);
// p_lights
void P_SpawnFireFlicker(sector_t *sector);
void P_SpawnLightFlash(sector_t *sector);
void P_SpawnStrobeFlash(sector_t *sector, int fastOrSlow, int inSync);
void P_SpawnGlowingLight(sector_t *sector);
// p_plats
void P_AddActivePlat(plat_t *plat);
void P_RemoveActivePlat(plat_t *plat);
void P_RemoveAllActivePlats(void); // killough
void P_ActivateInStasis(int tag);
// p_doors
void P_SpawnDoorCloseIn30(sector_t *sec);
void P_SpawnDoorRaiseIn5Mins(sector_t *sec, int secnum);
// p_ceilng
void P_RemoveActiveCeiling(ceiling_t *ceiling); //jff 2/22/98
void P_RemoveAllActiveCeilings(void); //jff 2/22/98
void P_AddActiveCeiling(ceiling_t *c);
int P_ActivateInStasisCeiling(const line_t *line);
#endif
+84
View File
@@ -0,0 +1,84 @@
/**
* Doom Port to the nRF52840 by Nicola Wrachien (next-hack in the comments)
*
* This port is based on the excellent doomhack's GBA Doom Port,
* with Kippykip additions.
*
* Several data structures and functions have been optimized
* to fit in only 256kB RAM of nRF52840 (GBA has 384 kB RAM).
* Z-Depth Light has been restored with almost no RAM consumption!
* Tons of speed optimizations have been done, and the game now
* runs extremely fast, despite the much higher 3D resolution with
* respect to GBA.
*
* PrBoom: a Doom port merged with LxDoom and LSDLDoom
* based on BOOM, a modified and improved DOOM engine
* Copyright (C) 1999 by
* id Software, Chi Hoang, Lee Killough, Jim Flynn, Rand Phares, Ty Halderman
* Copyright (C) 1999-2000 by
* Jess Haas, Nicolas Kalkhof, Colin Phipps, Florian Schulze
* Copyright 2005, 2006 by
* Florian Schulze, Colin Phipps, Neil Stevens, Andrey Budko
* Copyright (C) 2021 Nicola Wrachien (next-hack in the comments)
* on nRF52840 port.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
* 02111-1307, USA.
*
* DESCRIPTION:
* Core thinker processing prototypes.
*-----------------------------------------------------------------------------*/
#ifndef __P_TICK__
#define __P_TICK__
#include "d_think.h"
#ifdef __GNUG__
#pragma interface
#endif
/* Called by C_Ticker, can call G_PlayerExited.
* Carries out all thinking of monsters and players. */
void P_Ticker(void);
void P_InitThinkers(void);
void P_AddThinker(thinker_t *thinker);
void P_RemoveThinker(thinker_t *thinker);
void P_RemoveStaticThinker(thinker_t *thinker);
void P_RemoveThinkerDelayed(thinker_t *thinker); // killough 4/25/98
void P_RemoveStaticThinkerDelayed(thinker_t *thinker); // 2021-03-13 next-hack
void P_UpdateThinker(thinker_t *thinker); // killough 8/29/98
void P_RunThinkers(void);
void P_SetTarget(mobj_t **mo, mobj_t *target); // killough 11/98
/* killough 8/29/98: threads of thinkers, for more efficient searches
* cph 2002/01/13: for consistency with the main thinker list, keep objects
* pending deletion on a class list too
*/
typedef enum
{
th_all = 0, /* For P_NextThinker, indicates "any class" */
} th_class;
#define thinkercap _g->thinkerclasscap[th_all]
/* cph 2002/01/13 - iterator for thinker lists */
thinker_t* P_NextThinker(thinker_t*);
#endif
+56
View File
@@ -0,0 +1,56 @@
/**
* Doom Port to the nRF52840 by Nicola Wrachien (next-hack in the comments)
*
* This port is based on the excellent doomhack's GBA Doom Port,
* with Kippykip additions.
*
* Several data structures and functions have been optimized
* to fit in only 256kB RAM of nRF52840 (GBA has 384 kB RAM).
* Z-Depth Light has been restored with almost no RAM consumption!
* Tons of speed optimizations have been done, and the game now
* runs extremely fast, despite the much higher 3D resolution with
* respect to GBA.
*
* PrBoom: a Doom port merged with LxDoom and LSDLDoom
* based on BOOM, a modified and improved DOOM engine
* Copyright (C) 1999 by
* id Software, Chi Hoang, Lee Killough, Jim Flynn, Rand Phares, Ty Halderman
* Copyright (C) 1999-2000 by
* Jess Haas, Nicolas Kalkhof, Colin Phipps, Florian Schulze
* Copyright 2005, 2006 by
* Florian Schulze, Colin Phipps, Neil Stevens, Andrey Budko
* Copyright (C) 2021 Nicola Wrachien (next-hack in the comments)
* on nRF52840 port.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
* 02111-1307, USA.
*
* DESCRIPTION:
* Player related stuff.
* Bobbing POV/weapon, movement.
* Pending weapon.
*
*-----------------------------------------------------------------------------*/
#ifndef __P_USER__
#define __P_USER__
#include "d_player.h"
void P_PlayerThink(player_t *player);
void P_CalcHeight(player_t *player);
void P_Thrust(player_t *player, angle_t angle, fixed_t move);
#endif /* __P_USER__ */
+116
View File
@@ -0,0 +1,116 @@
/**
* Doom Port to the nRF52840 by Nicola Wrachien (next-hack in the comments)
*
* This port is based on the excellent doomhack's GBA Doom Port,
* with Kippykip additions.
*
* Several data structures and functions have been optimized
* to fit in only 256kB RAM of nRF52840 (GBA has 384 kB RAM).
* Z-Depth Light has been restored with almost no RAM consumption!
* Tons of speed optimizations have been done, and the game now
* runs extremely fast, despite the much higher 3D resolution with
* respect to GBA.
*
* PrBoom: a Doom port merged with LxDoom and LSDLDoom
* based on BOOM, a modified and improved DOOM engine
* Copyright (C) 1999 by
* id Software, Chi Hoang, Lee Killough, Jim Flynn, Rand Phares, Ty Halderman
* Copyright (C) 1999-2000 by
* Jess Haas, Nicolas Kalkhof, Colin Phipps, Florian Schulze
* Copyright 2005, 2006 by
* Florian Schulze, Colin Phipps, Neil Stevens, Andrey Budko
* Copyright (C) 2021 Nicola Wrachien (next-hack in the comments)
* on nRF52840 port.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
* 02111-1307, USA.
*
* DESCRIPTION:
* Doom Network protocol packet definitions.
*-----------------------------------------------------------------------------*/
#include "doomtype.h"
#include "d_ticcmd.h"
#include "m_swap.h"
enum packet_type_e
{
PKT_INIT, // initial packet to server
PKT_SETUP, // game information packet
PKT_GO, // game has started
PKT_TICC, // tics from client
PKT_TICS, // tics from server
PKT_RETRANS, // Request for retransmission
PKT_EXTRA, // Extra info packet
PKT_QUIT, // Player quit game
PKT_DOWN, // Server downed
PKT_WAD, // Wad file request
PKT_BACKOFF, // Request for client back-off
};
typedef struct
{
byte checksum; // Simple checksum of the entire packet
byte type; /* Type of packet */
byte reserved[2]; /* Was random in prboom <=2.2.4, now 0 */
unsigned tic; // Timestamp
}PACKEDATTR packet_header_t;
static inline void packet_set(packet_header_t *p, enum packet_type_e t, unsigned long tic)
{
p->tic = doom_htonl(tic);
p->type = t;
p->reserved[0] = 0;
p->reserved[1] = 0;
}
#ifndef GAME_OPTIONS_SIZE
// From g_game.h
#define GAME_OPTIONS_SIZE 64
#endif
struct setup_packet_s
{
byte players, yourplayer, skill, episode, level, deathmatch, complevel,
ticdup, extratic;
byte game_options[GAME_OPTIONS_SIZE];
byte numwads;
byte wadnames[1]; // Actually longer
};
/* cph - convert network byte stream to usable ticcmd_t and visa-versa
* - the functions are functionally identical apart from parameters
* - the void* param can be unaligned. By using void* as the parameter
* it means gcc won't assume alignment so won't make false assumptions
* when optimising. So I'm told.
*/
inline static void RawToTic(ticcmd_t *dst, const void *src)
{
memcpy(dst, src, sizeof *dst);
dst->angleturn = doom_ntohs(dst->angleturn);
dst->consistancy = doom_ntohs(dst->consistancy);
}
inline static void TicToRaw(void *dst, const ticcmd_t *src)
{
/* We have to make a copy of the source struct, then do byte swaps,
* and fnially copy to the destination (can't do the swaps in the
* destination, because it might not be aligned).
*/
ticcmd_t tmp = *src;
tmp.angleturn = doom_ntohs(tmp.angleturn);
tmp.consistancy = doom_ntohs(tmp.consistancy);
memcpy(dst, &tmp, sizeof tmp);
}
+104
View File
@@ -0,0 +1,104 @@
/**
* Doom Port to the nRF52840 by Nicola Wrachien (next-hack in the comments)
*
* This port is based on the excellent doomhack's GBA Doom Port,
* with Kippykip additions.
*
* Several data structures and functions have been optimized
* to fit in only 256kB RAM of nRF52840 (GBA has 384 kB RAM).
* Z-Depth Light has been restored with almost no RAM consumption!
* Tons of speed optimizations have been done, and the game now
* runs extremely fast, despite the much higher 3D resolution with
* respect to GBA.
*
* PrBoom: a Doom port merged with LxDoom and LSDLDoom
* based on BOOM, a modified and improved DOOM engine
* Copyright (C) 1999 by
* id Software, Chi Hoang, Lee Killough, Jim Flynn, Rand Phares, Ty Halderman
* Copyright (C) 1999-2000 by
* Jess Haas, Nicolas Kalkhof, Colin Phipps, Florian Schulze
* Copyright 2005, 2006 by
* Florian Schulze, Colin Phipps, Neil Stevens, Andrey Budko
* Copyright (C) 2021 Nicola Wrachien (next-hack in the comments)
* on nRF52840 port.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
* 02111-1307, USA.
*
* DESCRIPTION:
* Refresh module, data I/O, caching, retrieval of graphics
* by name.
*
*-----------------------------------------------------------------------------*/
#ifndef __R_DATA__
#define __R_DATA__
#include "r_defs.h"
#include "r_state.h"
#include "r_patch.h"
#ifdef __GNUG__
#pragma interface
#endif
// A single patch from a texture definition, basically
// a rectangular area within the texture rectangle.
typedef struct
{
short originx, originy; // Block origin, which has already accounted
const patch_t *patch; // for the internal origin of the patch.
} texpatch_t;
//
// Texture definition.
// A DOOM wall texture is a list of patches
// which are to be combined in a predefined order.
//
typedef struct
{
// 2021/03/06: next-hack removed name, useless
//const char* name; // Keep name for switch changing, etc.
//int next, index; // killough 1/31/98: used in hashing algorithm
// CPhipps - moved arrays with per-texture entries to elements here
unsigned short widthmask;
// CPhipps - end of additions
short width, height;
unsigned char overlapped;
unsigned char patchcount; // All the patches[patchcount] are drawn
texpatch_t patches[1]; // back-to-front into the cached texture.
} texture_t;
// I/O, setting up the stuff.
void R_InitData(void);
// Retrieval.
// Floor/ceiling opaque texture tiles,
// lookup by name. For animation?
int R_FlatNumForName(const char *name); // killough -- const added
// R_*TextureNumForName returns the texture number for the texture name, or NO_TEXTURE if
// there is no texture (i.e. "-") specified.
/* cph 2006/07/23 - defined value for no-texture marker (texture "-" in the WAD file) */
#define NO_TEXTURE 0
int R_CheckTextureNumForName(const char *name);
const texture_t* R_GetTexture(int texture, boolean cacheToFlash, uint32_t *spaceRequired);
int R_LoadTextureByName(const char *tex_name, boolean cacheToFlash);
uint32_t getTextureStructSize(int texture_num);
void R_FillTextureHeightData();
#endif
+635
View File
@@ -0,0 +1,635 @@
/**
* Doom Port to the nRF52840 by Nicola Wrachien (next-hack in the comments)
*
* This port is based on the excellent doomhack's GBA Doom Port,
* with Kippykip additions.
*
* Several data structures and functions have been optimized
* to fit in only 256kB RAM of nRF52840 (GBA has 384 kB RAM).
* Z-Depth Light has been restored with almost no RAM consumption!
* Tons of speed optimizations have been done, and the game now
* runs extremely fast, despite the much higher 3D resolution with
* respect to GBA.
*
* PrBoom: a Doom port merged with LxDoom and LSDLDoom
* based on BOOM, a modified and improved DOOM engine
* Copyright (C) 1999 by
* id Software, Chi Hoang, Lee Killough, Jim Flynn, Rand Phares, Ty Halderman
* Copyright (C) 1999-2000 by
* Jess Haas, Nicolas Kalkhof, Colin Phipps, Florian Schulze
* Copyright 2005, 2006 by
* Florian Schulze, Colin Phipps, Neil Stevens, Andrey Budko
* Copyright (C) 2021 Nicola Wrachien (next-hack in the comments)
* on nRF52840 port.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
* 02111-1307, USA.
*
* DESCRIPTION:
* Refresh/rendering module, shared data struct definitions.
*
*-----------------------------------------------------------------------------*/
#ifndef __R_DEFS__
#define __R_DEFS__
// Screenwidth.
#include "doomdef.h"
// Some more or less basic data types
// we depend on.
#include "m_fixed.h"
// We rely on the thinker data struct
// to handle sound origins in sectors.
#include "d_think.h"
// SECTORS do store MObjs anyway.
#include "p_mobj.h"
#ifdef __GNUG__
#pragma interface
#endif
// Silhouette, needed for clipping Segs (mainly)
// and sprites representing things.
#define SIL_NONE 0
#define SIL_BOTTOM 1
#define SIL_TOP 2
#define SIL_BOTH 3
#define MAXDRAWSEGS 192 // same as doomhack GBA port
#define MAXOPENINGS (SCREENWIDTH * 16) // same as doomhack GBA port
#define MAXVISSPRITES 128
//
// INTERNAL MAP TYPES
// used by play and refresh
//
//
// Your plain vanilla vertex.
// Note: transformed values not buffered locally,
// like some DOOM-alikes ("wt", "WebView") do.
//
typedef struct
{
fixed_t x, y;
} vertex_t;
// Each sector has a degenmobj_t in its center for sound origin purposes.
typedef struct
{
fixed_t x;
fixed_t y;
} degenmobj_t;
//
// The SECTORS record, at runtime.
// Stores things/mobjs.
//
#if 0
typedef struct
{
fixed_t floorheight;
fixed_t ceilingheight;
degenmobj_t soundorg; // origin for any sounds played by the sector
int validcount : 24; // if == validcount, already checked
int lightlevel:8;
int linecount : 11; // 11 bit
int floorpic : 11; // 11 bit
int ceilingpic : 10; // 10 bit
// thinker_t for reversable actions
//void *floordata; // jff 2/22/98 make thinkers on
unsigned short floordata_sptr;
//void *ceilingdata; // floors, ceilings, lighting,
unsigned short ceilingdata_sptr;
// list of mobjs that are at least partially in the sector
// thinglist is a subset of touching_thinglist
// mobj_t *thinglist; // list of mobjs in sector
//struct msecnode_s *touching_thinglist; // phares 3/14/98
unsigned short touching_thinglist_sptr;
unsigned short thinglist_sptr;
// mobj_t *soundtarget; // thing that made a sound (or null)
unsigned short soundtarget_sptr;
//unsigned short thinglist_sptr;
//
// 2021-02-13 next-hack save some bytes...
short special;
short oldspecial; //jff 2/16/98 remembers if sector WAS secret (automap)
short tag;
//const struct line_s **lines;
packedAddress_t lines_ppptr; // packed pointer to packed address
// short lightlevel;
// short soundtraversed; // 0 = untraversed, 1,2 = sndlines-1
uint8_t soundtraversed; // 0 = untraversed, 1,2 = sndlines-1
} sector_t;
#else
typedef struct
{
fixed_t floorheight;
fixed_t ceilingheight;
degenmobj_t soundorg; // origin for any sounds played by the sector
int validcount :24; // if == validcount, already checked
int soundtraversed :8; // 0 = untraversed, 1,2 = sndlines-1
int linecount :12; // 11 bit
int floorpic :10; // 11 bit
int ceilingpic :10; // 10 bit
// thinker_t for reversable actions
//void *floordata; // jff 2/22/98 make thinkers on
unsigned short floordata_sptr;
//void *ceilingdata; // floors, ceilings, lighting,
unsigned short ceilingdata_sptr;
// list of mobjs that are at least partially in the sector
// thinglist is a subset of touching_thinglist
// mobj_t *thinglist; // list of mobjs in sector
//struct msecnode_s *touching_thinglist; // phares 3/14/98
unsigned short touching_thinglist_sptr;
unsigned short thinglist_sptr;
// mobj_t *soundtarget; // thing that made a sound (or null)
unsigned short soundtarget_sptr;
//unsigned short thinglist_sptr;
//
// 2021-02-13 next-hack save some bytes...
short special;
short oldspecial; //jff 2/16/98 remembers if sector WAS secret (automap)
short tag;
//const struct line_s **lines;
packedAddress_t lines_ppptr; // packed pointer to packed address
uint8_t lightlevel;
// short lightlevel;
// short soundtraversed; // 0 = untraversed, 1,2 = sndlines-1
} sector_t;
#endif
static inline mobj_t* getSectorThingList(sector_t *psec)
{
return (mobj_t*) getLongPtr(psec->thinglist_sptr);
}
static inline void* getSectorCeilingData(sector_t *psec)
{
return (void*) getLongPtr(psec->ceilingdata_sptr);
}
static inline void* getSectorFloorData(sector_t *psec)
{
return (void*) getLongPtr(psec->floordata_sptr);
}
//static inline packedAddress_t * getSectorLines(sector_t *psec) {return (packedAddress_t*) unpackAddress(psec->lines_ppptr);}
//static inline const struct line_s* getSectorLineByIndex(sector_t *psec, int i) {return (const struct line_s*) unpackAddress(getSectorLines(psec)[i]);}
static inline const struct line_s** getSectorLines(sector_t *psec)
{
return (const struct line_s**) unpackAddress(psec->lines_ppptr);
}
static inline const struct line_s* getSectorLineByIndex(sector_t *psec, int i)
{
return getSectorLines(psec)[i];
}
//
// The SideDef.
//
typedef struct
{
// 2021-02-13 next-hack: changed to reflect map side def, so we do not have to copy a lot of bytes in RAM
short textureoffset;
short rowoffset;
short toptexture;
short bottomtexture;
short midtexture;
short sector_num; // Front sector, towards viewer.
// sector_t* sector; // Sector the SideDef is facing.
// short textureoffset; // add this to the calculated texture column
// short rowoffset; // add this to the calculated texture top
// short toptexture; // Texture indices. We do not maintain names here.
// short bottomtexture;
// short midtexture;
} PACKEDATTR side_t;
//
// Move clipping aid for LineDefs.
//
typedef enum
{
ST_HORIZONTAL, ST_VERTICAL, ST_POSITIVE, ST_NEGATIVE
} slopetype_t;
typedef enum
{ // cph:
/* // not used
RF_TOP_TILE = 1, // Upper texture needs tiling
// not used
RF_MID_TILE = 2, // Mid texture needs tiling
// Not used
RF_BOT_TILE = 4, // Lower texture needs tiling
RF_IGNORE = 8, // Renderer can skip this line
RF_CLOSED =16, // Line blocks view
RF_MAPPED =32 // Seen so show on automap.*/
// 2020-03-14 next-hack changed value to fit 3 bits
RF_IGNORE = 1, // Renderer can skip this line
RF_CLOSED = 2, // Line blocks view
RF_MAPPED = 4 // Seen so show on automap.*/
} r_flags;
//Runtime mutable data for lines.
#define VALIDCOUNT_MASK 0xFFff
#if !USE_SEPARATE_R_VALIDCOUNT
#define r_validcount validcount
#endif
typedef struct linedata_s
{
// unsigned short validcount; // if == validcount, already checked
// unsigned short r_validcount; // cph: if == gametic, r_flags already done
uint32_t validcount :16; // if == validcount, already checked
#if USE_SEPARATE_R_VALIDCOUNT
uint32_t r_validcount :16; // cph: if == gametic, r_flags already done
#endif
uint32_t special :12;
uint32_t r_flags :3;
} PACKEDATTR linedata_t;
typedef struct line_s
{
vertex_t v1;
vertex_t v2; // Vertices, from v1 to v2.
unsigned int lineno; //line number.
fixed_t dx, dy; // Precalculated v2 - v1 for side checking.
unsigned short sidenum[2]; // Visual appearance: SideDefs.
fixed_t bbox[4]; //Line bounding box.
unsigned short flags; // Animation related.
short const_special;
short tag;
short slopetype; // To aid move clipping.
} line_t;
//#define LN_FRONTSECTOR(l) (_g->sides[(l)->sidenum[0]].sector)
#define LN_FRONTSECTOR(l) (&_g->sectors[_g->sides[(l)->sidenum[0]].sector_num]) //nh: replaced to sector num (saves ram)
#define LN_BACKSECTOR(l) ((l)->sidenum[1] != NO_INDEX ? &_g->sectors[_g->sides[(l)->sidenum[1]].sector_num] : NULL)
#define LN_SPECIAL(l) (_g->linedata[(l)->lineno].special)
// phares 3/14/98
//
// Sector list node showing all sectors an object appears in.
//
// There are two threads that flow through these nodes. The first thread
// starts at touching_thinglist in a sector_t and flows through the m_snext
// links to find all mobjs that are entirely or partially in the sector.
// The second thread starts at touching_sectorlist in an mobj_t and flows
// through the m_tnext links to find all sectors a thing touches. This is
// useful when applying friction or push effects to sectors. These effects
// can be done as thinkers that act upon all objects touching their sectors.
// As an mobj moves through the world, these nodes are created and
// destroyed, with the links changed appropriately.
//
// For the links, NULL means top or end of list.
typedef struct msecnode_s
{
// sector_t *m_sector; // a sector containing this object
unsigned short m_sector_sptr;
// struct mobj_s *m_thing; // this object
unsigned short m_thing_sptr;
//struct msecnode_s *m_tprev; // prev msecnode_t for this thing
unsigned short m_tprev_sptr;
// struct msecnode_s *m_tnext; // next msecnode_t for this thing
unsigned short m_tnext_sptr;
// struct msecnode_s *m_sprev; // prev msecnode_t for this sector
unsigned short m_sprev_sptr;
// struct msecnode_s *m_snext; // next msecnode_t for this sector
unsigned short m_snext_sptr;
// boolean visited; // killough 4/4/98, 4/7/98: used in search algorithms
} __attribute__ ((aligned (4))) msecnode_t;
static inline sector_t* getMsecnodeSector(const msecnode_t *p_msn)
{
return (sector_t*) getLongPtr(p_msn->m_sector_sptr);
}
static inline struct mobj_s* getMsecnodeThing(msecnode_t *p_msn)
{
return (struct mobj_s*) getLongPtr(p_msn->m_thing_sptr);
}
static inline msecnode_t* getMsecnodeTPrev(msecnode_t *p_msn)
{
return (msecnode_t*) getLongPtr(p_msn->m_tprev_sptr);
}
static inline msecnode_t* getMsecnodeTNext(const msecnode_t *p_msn)
{
return (msecnode_t*) getLongPtr(p_msn->m_tnext_sptr);
}
static inline msecnode_t* getMsecnodeSPrev(msecnode_t *p_msn)
{
return (msecnode_t*) getLongPtr(p_msn->m_sprev_sptr);
}
static inline msecnode_t* getMsecnodeSNext(msecnode_t *p_msn)
{
return (msecnode_t*) getLongPtr(p_msn->m_snext_sptr);
}
//
static inline msecnode_t* getSectorTouchingThingList(sector_t *psec)
{
return (msecnode_t*) getLongPtr(psec->touching_thinglist_sptr);
}
//
// The LineSeg.
//
/*
typedef struct
{
vertex_t *v1, *v2;
fixed_t offset;
angle_t angle;
side_t* sidedef;
const line_t* linedef;
// Sector references.
// Could be retrieved from linedef, too
// (but that would be slower -- killough)
// backsector is NULL for one sided lines
sector_t *frontsector, *backsector;
} seg_t;
*/
//
// The LineSeg.
//
typedef struct
{
vertex_t v1;
vertex_t v2; // Vertices, from v1 to v2.
fixed_t offset;
angle_t angle;
unsigned short sidenum;
unsigned short linenum;
unsigned short frontsectornum;
unsigned short backsectornum;
} seg_t;
#define SG_FRONTSECTOR(s) ((s)->frontsectornum != NO_INDEX ? &_g->sectors[(s)->frontsectornum] : NULL)
#define SG_BACKSECTOR(s) ((s)->backsectornum != NO_INDEX ? &_g->sectors[(s)->backsectornum] : NULL)
//
// A SubSector.
// References a Sector.
// Basically, this is a list of LineSegs,
// indicating the visible walls that define
// (all or some) sides of a convex BSP leaf.
//
typedef struct subsector_s
{
sector_t *sector;
unsigned short numlines, firstline;
} subsector_t;
static inline subsector_t* getSubSectorPtr(unsigned short shortPointer)
{
return (subsector_t*) getLongPtr(shortPointer);
}
static inline subsector_t* getMobjSubsector(mobj_t *pmobj)
{
return getSubSectorPtr(pmobj->subsector_sptr);
}
static inline subsector_t* setMobjSubesctor(mobj_t *pmobj, subsector_t *ss)
{
pmobj->subsector_sptr = getShortPtr(ss);
return ss;
}
//
// OTHER TYPES
//
// This could be wider for >8 bit display.
// Indeed, true color support is posibble
// precalculating 24bpp lightmap/colormap LUT.
// from darkening PLAYPAL to all black.
// Could use even more than 32 levels.
typedef byte lighttable_t;
//
// Masked 2s linedefs
//
typedef struct drawseg_s
{
const seg_t *curline;
fixed_t scale1, scale2, scalestep;
fixed_t bsilheight; // do not clip sprites above this
fixed_t tsilheight; // do not clip sprites below this
// short *sprtopclip, *sprbottomclip;
short *maskedtexturecol; // dropoff overflow. NOTE: can't use short ptr, as it does not point to 4-byte aligned memory.
unsigned short sprtopclip_ssptr, sprbottomclip_ssptr; // short pointer to short
// Pointers to lists for sprite clipping,
// all three adjusted so [x1] is first value.
#if SCREENWIDTH > 255
uint16_t x1, x2;
#else
uint8_t x1, x2; // the screen is 240 pix wide...
#endif
uint8_t silhouette; // 0=none, 1=bottom, 2=top, 3=both
} drawseg_t;
// Patches.
// A patch holds one or more columns.
// Patches are used for sprites and all masked pictures,
// and we compose textures from the TEXTURE1/2 lists
// of patches.
typedef struct
{
short width; // bounding box size
short height;
short leftoffset; // pixels to the left of origin
short topoffset; // pixels below the origin
int columnofs[8]; // only [width] used
// the [0] is &columnofs[width]
} patch_t;
typedef struct
{
short width; // bounding box size
short height;
short leftoffset; // pixels to the left of origin
short topoffset; // pixels below the origin
} patchsizeoffsets_t; // like patch, but only size and offset
// posts are runs of non masked source pixels
typedef struct
{
byte topdelta; // -1 is the last post in a column
byte length; // length data bytes follows
} post_t;
// column_t is a list of 0 or more post_t, (byte)-1 terminated
typedef post_t column_t;
//
// A vissprite_t is a thing that will be drawn during a refresh.
// i.e. a sprite object that is partly visible.
//
typedef struct vissprite_s
{
fixed_t gx, gy; // for line side calculation
fixed_t gz, gzt; // global bottom / top for silhouette clipping
fixed_t startfrac; // horizontal position of x1. We could reduce this...
fixed_t scale;
fixed_t xiscale; // negative if flipped
fixed_t texturemid; // we could reduce this if we need some bits...
// 2021/03/27 next-hack: removed iscale and calculated when necessary. Saved some bytes...
// fixed_t iscale;
// for color translation and shadow draw, maxbright frames as well
// const lighttable_t *colormap;
//const patch_t *patch;
uint32_t lumpNum;
//
uint8_t colormap_idx;
uint8_t mobjflags;
#if SCREENWIDTH > 255
uint16_t x1, x2;
#else
uint8_t x1, x2;
#endif
} vissprite_t;
//
// Sprites are patches with a special naming convention
// so they can be recognized by R_InitSprites.
// The base name is NNNNFx or NNNNFxFx, with
// x indicating the rotation, x = 0, 1-7.
// The sprite and frame specified by a thing_t
// is range checked at run time.
// A sprite is a patch_t that is assumed to represent
// a three dimensional object and may have multiple
// rotations pre drawn.
// Horizontal flipping is used to save space,
// thus NNNNF2F5 defines a mirrored patch.
// Some sprites will only have one picture used
// for all views: NNNNF0
//
typedef struct
{
// Lump to use for view angles 0-7.
short lump[8];
// Flip bit (1 = flip) to use for view angles 0-7.
//byte flip[8];
byte flipmask;
// If false use 0 for any position.
// Note: as eight entries are available,
// we might as well insert the same name eight times.
boolean rotate;
} spriteframe_t;
#define SPR_FLIPPED(s, r) (s->flipmask & (1 << r))
//
// A sprite definition:
// a number of animation frames.
//
typedef struct
{
short numframes;
#ifndef USE_SPRITEFRAME_SPTR
spriteframe_t *spriteframes;
#else
unsigned short spriteframes_sptr;
#endif
} spritedef_t __attribute__ ((aligned (4)));
static inline spriteframe_t* getSpriteFrames(const spritedef_t *p_sd)
{
#ifndef USE_SPRITEFRAME_SPTR
return p_sd->spriteframes;
#else
return (spriteframe_t *) getLongPtr(p_sd->spriteframes_sptr);
#endif
}
//
// Now what is a visplane, anyway?
//
// Go to http://classicgaming.com/doom/editing/ to find out -- killough
//
typedef struct visplane
{
#if 1
struct visplane *next; // Next visplane in hash chain -- killough
fixed_t height;
short picnum;
short minx, maxx;
byte modified;
byte lightlevel;
byte top[SCREENWIDTH];
byte pad2;
byte pad3;
byte bottom[SCREENWIDTH];
byte pad4;
#else
struct visplane *next; // Next visplane in hash chain -- killough
short picnum, lightlevel;
short minx, maxx;
fixed_t height;
unsigned int modified;
//byte pad1;
// Here lies the rub for all
// dynamic resize/change of resolution.
byte top[SCREENWIDTH];
byte pad2;
byte pad3;
// See above.
byte bottom[SCREENWIDTH];
byte pad4;
#endif
} visplane_t;
static inline sector_t* getSectorPtr(unsigned short shortPointer)
{
return (sector_t*) getLongPtr(shortPointer);
}
static inline msecnode_t* getTouchingSectorList(mobj_t *pmobj)
{
return (msecnode_t*) getLongPtr(pmobj->touching_sectorlist_sptr);
}
static inline mobj_t* getSectorSoundTarget(sector_t *ps)
{
return (mobj_t*) getLongPtr(ps->soundtarget_sptr);
}
//inline mobj_t * getSectorThingList(sector_t * ps) {return (mobj_t*) getLongPtr(ps->thinglist_sptr);}
#endif
+96
View File
@@ -0,0 +1,96 @@
/**
* Doom Port to the nRF52840 by Nicola Wrachien (next-hack in the comments)
*
* This port is based on the excellent doomhack's GBA Doom Port,
* with Kippykip additions.
*
* Several data structures and functions have been optimized
* to fit in only 256kB RAM of nRF52840 (GBA has 384 kB RAM).
* Z-Depth Light has been restored with almost no RAM consumption!
* Tons of speed optimizations have been done, and the game now
* runs extremely fast, despite the much higher 3D resolution with
* respect to GBA.
*
* PrBoom: a Doom port merged with LxDoom and LSDLDoom
* based on BOOM, a modified and improved DOOM engine
* Copyright (C) 1999 by
* id Software, Chi Hoang, Lee Killough, Jim Flynn, Rand Phares, Ty Halderman
* Copyright (C) 1999-2000 by
* Jess Haas, Nicolas Kalkhof, Colin Phipps, Florian Schulze
* Copyright 2005, 2006 by
* Florian Schulze, Colin Phipps, Neil Stevens, Andrey Budko
* Copyright (C) 2021 Nicola Wrachien (next-hack in the comments)
* on nRF52840 port.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
* 02111-1307, USA.
*
* DESCRIPTION:
* System specific interface stuff.
*
*-----------------------------------------------------------------------------*/
#ifndef __R_DRAW__
#define __R_DRAW__
#include "r_defs.h"
#ifdef __GNUG__
#pragma interface
#endif
// Packaged into a struct - POPE
typedef struct
{
int x;
int yl;
int yh;
fixed_t iscale;
fixed_t texturemid;
const byte *source; // first pixel in a column
const lighttable_t *colormap;
const byte *translation;
} draw_column_vars_t;
void R_SetDefaultDrawColumnVars(draw_column_vars_t *dcvars);
typedef struct
{
unsigned int position;
unsigned int step;
const byte *source; // start of a 64*64 tile image
const lighttable_t *colormap;
} draw_span_vars_t;
typedef struct
{
uint8_t *byte_topleft;
} draw_vars_t;
extern draw_vars_t drawvars;
typedef void (*R_DrawColumn_f)(const draw_column_vars_t *dcvars);
// Draw with color translation tables,
// for player sprite rendering,
// Green/Red/Blue/Indigo shirts.
void R_DrawTranslatedColumn(const draw_column_vars_t *dcvars);
void R_InitBuffer();
#endif
+110
View File
@@ -0,0 +1,110 @@
/**
* Doom Port to the nRF52840 by Nicola Wrachien (next-hack in the comments)
*
* This port is based on the excellent doomhack's GBA Doom Port,
* with Kippykip additions.
*
* Several data structures and functions have been optimized
* to fit in only 256kB RAM of nRF52840 (GBA has 384 kB RAM).
* Z-Depth Light has been restored with almost no RAM consumption!
* Tons of speed optimizations have been done, and the game now
* runs extremely fast, despite the much higher 3D resolution with
* respect to GBA.
*
* PrBoom: a Doom port merged with LxDoom and LSDLDoom
* based on BOOM, a modified and improved DOOM engine
* Copyright (C) 1999 by
* id Software, Chi Hoang, Lee Killough, Jim Flynn, Rand Phares, Ty Halderman
* Copyright (C) 1999-2000 by
* Jess Haas, Nicolas Kalkhof, Colin Phipps, Florian Schulze
* Copyright 2005, 2006 by
* Florian Schulze, Colin Phipps, Neil Stevens, Andrey Budko
* Copyright (C) 2021 Nicola Wrachien (next-hack in the comments)
* on nRF52840 port.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
* 02111-1307, USA.
*
* DESCRIPTION:
* Renderer main interface.
*
*-----------------------------------------------------------------------------*/
#ifndef __R_MAIN__
#define __R_MAIN__
#include "d_player.h"
#include "r_data.h"
#ifdef __GNUG__
#pragma interface
#endif
//
// Lighting LUT.
// Used for z-depth cuing per column/row,
// and other lighting effects (sector ambient, flash).
//
extern const int viewheight;
extern const int centery;
extern const fixed_t projection;
extern const fixed_t iprojection;
//Global vars.
extern short numnodes;
extern const mapnode_t *nodes;
extern fixed_t viewx, viewy, viewz;
extern angle_t viewangle;
//extern short *floorclip, *ceilingclip;
extern const lighttable_t *fullcolormap;
//extern const lighttable_t *colormaps;
extern const lighttable_t *fixedcolormap;
extern byte extralight; // bumped light from gun blasts
extern const texture_t **textures; // proff - 04/05/2000 removed static for OpenGL
extern fixed_t *textureheight; //needed for texture pegging (and TFE fix - killough)
extern short *flattranslation; // for global animation
extern short *texturetranslation;
extern fixed_t basexscale, baseyscale;
extern fixed_t viewcos, viewsin;
//
// Utility functions.
//
angle_t R_PointToAngle2(fixed_t x1, fixed_t y1, fixed_t x2, fixed_t y2);
subsector_t* R_PointInSubsector(fixed_t x, fixed_t y);
//
// REFRESH - the actual rendering functions.
//
void R_RenderPlayerView(player_t *player); // Called by G_Drawer.
void R_Init(void); // Called by startup code.
void R_SetupFrame(player_t *player);
#endif
+51
View File
@@ -0,0 +1,51 @@
/**
* Doom Port to the nRF52840 by Nicola Wrachien (next-hack in the comments)
*
* This port is based on the excellent doomhack's GBA Doom Port,
* with Kippykip additions.
*
* Several data structures and functions have been optimized
* to fit in only 256kB RAM of nRF52840 (GBA has 384 kB RAM).
* Z-Depth Light has been restored with almost no RAM consumption!
* Tons of speed optimizations have been done, and the game now
* runs extremely fast, despite the much higher 3D resolution with
* respect to GBA.
*
* PrBoom: a Doom port merged with LxDoom and LSDLDoom
* based on BOOM, a modified and improved DOOM engine
* Copyright (C) 1999 by
* id Software, Chi Hoang, Lee Killough, Jim Flynn, Rand Phares, Ty Halderman
* Copyright (C) 1999-2000 by
* Jess Haas, Nicolas Kalkhof, Colin Phipps, Florian Schulze
* Copyright 2005, 2006 by
* Florian Schulze, Colin Phipps, Neil Stevens, Andrey Budko
* Copyright (C) 2021 Nicola Wrachien (next-hack in the comments)
* on nRF52840 port.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
* 02111-1307, USA.
*
*-----------------------------------------------------------------------------*/
#ifndef R_PATCH_H
#define R_PATCH_H
// Size query funcs
int R_NumPatchWidth(int lump);
int R_NumPatchHeight(int lump);
//#define R_NamePatchWidth(name) R_NumPatchWidth(W_GetNumForName(name))
//#define R_NamePatchHeight(name) R_NumPatchHeight(W_GetNumForName(name))
#endif
+65
View File
@@ -0,0 +1,65 @@
/**
* Doom Port to the nRF52840 by Nicola Wrachien (next-hack in the comments)
*
* This port is based on the excellent doomhack's GBA Doom Port,
* with Kippykip additions.
*
* Several data structures and functions have been optimized
* to fit in only 256kB RAM of nRF52840 (GBA has 384 kB RAM).
* Z-Depth Light has been restored with almost no RAM consumption!
* Tons of speed optimizations have been done, and the game now
* runs extremely fast, despite the much higher 3D resolution with
* respect to GBA.
*
* PrBoom: a Doom port merged with LxDoom and LSDLDoom
* based on BOOM, a modified and improved DOOM engine
* Copyright (C) 1999 by
* id Software, Chi Hoang, Lee Killough, Jim Flynn, Rand Phares, Ty Halderman
* Copyright (C) 1999-2000 by
* Jess Haas, Nicolas Kalkhof, Colin Phipps, Florian Schulze
* Copyright 2005, 2006 by
* Florian Schulze, Colin Phipps, Neil Stevens, Andrey Budko
* Copyright (C) 2021 Nicola Wrachien (next-hack in the comments)
* on nRF52840 port.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
* 02111-1307, USA.
*
* DESCRIPTION:
* Refresh, visplane stuff (floor, ceilings).
*
*-----------------------------------------------------------------------------*/
#ifndef __R_PLANE__
#define __R_PLANE__
#include "r_data.h"
#ifdef __GNUG__
#pragma interface
#endif
void R_InitPlanes(void);
void R_ResetPlanes();
#define MAXVISPLANES 32 /* must be a power of 2 */
// killough -- hash function for visplanes
// Empirically verified to be fairly uniform:
#define visplane_hash(picnum,lightlevel,height) \
((unsigned)((picnum)*3+(lightlevel)+(height)*7) & (MAXVISPLANES-1))
#endif
+52
View File
@@ -0,0 +1,52 @@
/**
* Doom Port to the nRF52840 by Nicola Wrachien (next-hack in the comments)
*
* This port is based on the excellent doomhack's GBA Doom Port,
* with Kippykip additions.
*
* Several data structures and functions have been optimized
* to fit in only 256kB RAM of nRF52840 (GBA has 384 kB RAM).
* Z-Depth Light has been restored with almost no RAM consumption!
* Tons of speed optimizations have been done, and the game now
* runs extremely fast, despite the much higher 3D resolution with
* respect to GBA.
*
* PrBoom: a Doom port merged with LxDoom and LSDLDoom
* based on BOOM, a modified and improved DOOM engine
* Copyright (C) 1999 by
* id Software, Chi Hoang, Lee Killough, Jim Flynn, Rand Phares, Ty Halderman
* Copyright (C) 1999-2000 by
* Jess Haas, Nicolas Kalkhof, Colin Phipps, Florian Schulze
* Copyright 2005, 2006 by
* Florian Schulze, Colin Phipps, Neil Stevens, Andrey Budko
* Copyright (C) 2021 Nicola Wrachien (next-hack in the comments)
* on nRF52840 port.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
* 02111-1307, USA.
*
* DESCRIPTION:
* Refresh module, drawing LineSegs from BSP.
*
*-----------------------------------------------------------------------------*/
#ifndef __R_SEGS__
#define __R_SEGS__
#ifdef __GNUG__
#pragma interface
#endif
#endif
+60
View File
@@ -0,0 +1,60 @@
/**
* Doom Port to the nRF52840 by Nicola Wrachien (next-hack in the comments)
*
* This port is based on the excellent doomhack's GBA Doom Port,
* with Kippykip additions.
*
* Several data structures and functions have been optimized
* to fit in only 256kB RAM of nRF52840 (GBA has 384 kB RAM).
* Z-Depth Light has been restored with almost no RAM consumption!
* Tons of speed optimizations have been done, and the game now
* runs extremely fast, despite the much higher 3D resolution with
* respect to GBA.
*
* PrBoom: a Doom port merged with LxDoom and LSDLDoom
* based on BOOM, a modified and improved DOOM engine
* Copyright (C) 1999 by
* id Software, Chi Hoang, Lee Killough, Jim Flynn, Rand Phares, Ty Halderman
* Copyright (C) 1999-2000 by
* Jess Haas, Nicolas Kalkhof, Colin Phipps, Florian Schulze
* Copyright 2005, 2006 by
* Florian Schulze, Colin Phipps, Neil Stevens, Andrey Budko
* Copyright (C) 2021 Nicola Wrachien (next-hack in the comments)
* on nRF52840 port.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
* 02111-1307, USA.
*
* DESCRIPTION:
* Sky rendering.
*
*-----------------------------------------------------------------------------*/
#ifndef __R_SKY__
#define __R_SKY__
#include "m_fixed.h"
#ifdef __GNUG__
#pragma interface
#endif
/* SKY, store the number for name. */
#define SKYFLATNAME "F_SKY1"
/* The sky map is 256*128*4 maps. */
#define ANGLETOSKYSHIFT 22
#endif
+56
View File
@@ -0,0 +1,56 @@
/**
* Doom Port to the nRF52840 by Nicola Wrachien (next-hack in the comments)
*
* This port is based on the excellent doomhack's GBA Doom Port,
* with Kippykip additions.
*
* Several data structures and functions have been optimized
* to fit in only 256kB RAM of nRF52840 (GBA has 384 kB RAM).
* Z-Depth Light has been restored with almost no RAM consumption!
* Tons of speed optimizations have been done, and the game now
* runs extremely fast, despite the much higher 3D resolution with
* respect to GBA.
*
* PrBoom: a Doom port merged with LxDoom and LSDLDoom
* based on BOOM, a modified and improved DOOM engine
* Copyright (C) 1999 by
* id Software, Chi Hoang, Lee Killough, Jim Flynn, Rand Phares, Ty Halderman
* Copyright (C) 1999-2000 by
* Jess Haas, Nicolas Kalkhof, Colin Phipps, Florian Schulze
* Copyright 2005, 2006 by
* Florian Schulze, Colin Phipps, Neil Stevens, Andrey Budko
* Copyright (C) 2021 Nicola Wrachien (next-hack in the comments)
* on nRF52840 port.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
* 02111-1307, USA.
*
* DESCRIPTION:
* Refresh/render internal state variables (global).
*
*-----------------------------------------------------------------------------*/
#ifndef __R_STATE__
#define __R_STATE__
// Need data structure definitions.
#include "d_player.h"
#include "r_data.h"
#ifdef __GNUG__
#pragma interface
#endif
#endif
+64
View File
@@ -0,0 +1,64 @@
/**
* Doom Port to the nRF52840 by Nicola Wrachien (next-hack in the comments)
*
* This port is based on the excellent doomhack's GBA Doom Port,
* with Kippykip additions.
*
* Several data structures and functions have been optimized
* to fit in only 256kB RAM of nRF52840 (GBA has 384 kB RAM).
* Z-Depth Light has been restored with almost no RAM consumption!
* Tons of speed optimizations have been done, and the game now
* runs extremely fast, despite the much higher 3D resolution with
* respect to GBA.
*
* PrBoom: a Doom port merged with LxDoom and LSDLDoom
* based on BOOM, a modified and improved DOOM engine
* Copyright (C) 1999 by
* id Software, Chi Hoang, Lee Killough, Jim Flynn, Rand Phares, Ty Halderman
* Copyright (C) 1999-2000 by
* Jess Haas, Nicolas Kalkhof, Colin Phipps, Florian Schulze
* Copyright 2005, 2006 by
* Florian Schulze, Colin Phipps, Neil Stevens, Andrey Budko
* Copyright (C) 2021 Nicola Wrachien (next-hack in the comments)
* on nRF52840 port.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
* 02111-1307, USA.
*
* DESCRIPTION:
* Rendering of moving objects, sprites.
*
*-----------------------------------------------------------------------------*/
#ifndef __R_THINGS__
#define __R_THINGS__
#ifdef __GNUG__
#pragma interface
#endif
#include "r_draw.h"
/* Constant arrays used for psprite clipping and initializing clipping. */
void R_InitSprites(const char *const*namelist);
#define MAX_SPRITE_FRAMES 29 /* Macroized -- killough 1/25/98 */
#define MINZ (FRACUNIT*4)
#define MAXZ (FRACUNIT*1280)
#endif
+116
View File
@@ -0,0 +1,116 @@
/**
* Doom Port to the nRF52840 by Nicola Wrachien (next-hack in the comments)
*
* This port is based on the excellent doomhack's GBA Doom Port,
* with Kippykip additions.
*
* Several data structures and functions have been optimized
* to fit in only 256kB RAM of nRF52840 (GBA has 384 kB RAM).
* Z-Depth Light has been restored with almost no RAM consumption!
* Tons of speed optimizations have been done, and the game now
* runs extremely fast, despite the much higher 3D resolution with
* respect to GBA.
*
* PrBoom: a Doom port merged with LxDoom and LSDLDoom
* based on BOOM, a modified and improved DOOM engine
* Copyright (C) 1999 by
* id Software, Chi Hoang, Lee Killough, Jim Flynn, Rand Phares, Ty Halderman
* Copyright (C) 1999-2000 by
* Jess Haas, Nicolas Kalkhof, Colin Phipps, Florian Schulze
* Copyright 2005, 2006 by
* Florian Schulze, Colin Phipps, Neil Stevens, Andrey Budko
* Copyright (C) 2021 Nicola Wrachien (next-hack in the comments)
* on nRF52840 port.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
* 02111-1307, USA.
*
* DESCRIPTION:
* The not so system specific sound interface.
*
*-----------------------------------------------------------------------------*/
#ifndef __S_SOUND__
#define __S_SOUND__
#ifdef __GNUG__
#pragma interface
#endif
#include "p_mobj.h"
#include "r_defs.h"
#include "sounds.h"
//
// Initializes sound stuff, including volume
// Sets channels, SFX and music volume,
// allocates channel buffer, sets S_sfx lookup.
//
void S_Init(int sfxVolume, int musicVolume);
// Kills all sounds
void S_Stop(void);
//
// Per level startup code.
// Kills playing sounds at start of level,
// determines music if any, changes music.
//
void S_Start(void);
//
// Start sound for thing at <origin>
// using <sound_id> from sounds.h
//
void S_StartSound(mobj_t *origin, int sfx_id);
void S_StartSound2(degenmobj_t *origin, int sfx_id);
// killough 4/25/98: mask used to indicate sound origin is player item pickup
#define PICKUP_SOUND (0x8000)
// Stop sound for thing at <origin>
void S_StopSound(void *origin);
// Start music using <music_id> from sounds.h
void S_StartMusic(int music_id);
// Start music using <music_id> from sounds.h, and set whether looping
void S_ChangeMusic(int music_id, int looping);
// Stops the music fer sure.
void S_StopMusic(void);
// Stop and resume music, during game PAUSE.
void S_PauseSound(void);
void S_ResumeSound(void);
//
// Updates music & sounds
//
void S_UpdateSounds(void *listener);
void S_SetMusicVolume(int volume);
void S_SetSfxVolume(int volume);
typedef struct
{
const sfxinfo_t *sfxinfo; // sound information (if null, channel avail.)
int tickend;
void *origin; // origin of sound
short handle; // handle of the sound being played
short is_pickup; // killough 4/25/98: whether sound is a player's weapon
} channel_t;
#endif
+280
View File
@@ -0,0 +1,280 @@
/**
* Doom Port to the nRF52840 by Nicola Wrachien (next-hack in the comments)
*
* This port is based on the excellent doomhack's GBA Doom Port,
* with Kippykip additions.
*
* Several data structures and functions have been optimized
* to fit in only 256kB RAM of nRF52840 (GBA has 384 kB RAM).
* Z-Depth Light has been restored with almost no RAM consumption!
* Tons of speed optimizations have been done, and the game now
* runs extremely fast, despite the much higher 3D resolution with
* respect to GBA.
*
* PrBoom: a Doom port merged with LxDoom and LSDLDoom
* based on BOOM, a modified and improved DOOM engine
* Copyright (C) 1999 by
* id Software, Chi Hoang, Lee Killough, Jim Flynn, Rand Phares, Ty Halderman
* Copyright (C) 1999-2000 by
* Jess Haas, Nicolas Kalkhof, Colin Phipps, Florian Schulze
* Copyright 2005, 2006 by
* Florian Schulze, Colin Phipps, Neil Stevens, Andrey Budko
* Copyright (C) 2021 Nicola Wrachien (next-hack in the comments)
* on nRF52840 port.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
* 02111-1307, USA.
*
* DESCRIPTION:
* Created by the sound utility written by Dave Taylor.
* Kept as a sample, DOOM2 sounds. Frozen.
*
*-----------------------------------------------------------------------------*/
#ifndef __SOUNDS__
#define __SOUNDS__
//
// SoundFX struct.
//
struct sfxinfo_struct;
typedef struct sfxinfo_struct sfxinfo_t;
struct sfxinfo_struct
{
// up to 6-character name
const char *name; // CPhipps - const
int singularity;
// Sfx priority
int priority;
// referenced sound if a link
const sfxinfo_t *link;
// volume if a link
int volume;
//Length of clip
int ticks;
};
//
// MusicInfo struct.
//
// the complete set of sound effects
extern const sfxinfo_t S_sfx[];
//
// Identifiers for all music in game.
//
typedef enum
{
mus_None,
mus_e1m1,
mus_e1m2,
mus_e1m3,
mus_e1m4,
mus_e1m5,
mus_e1m6,
mus_e1m7,
mus_e1m8,
mus_e1m9,
mus_e2m1,
mus_e2m2,
mus_e2m3,
mus_e2m4,
mus_e2m5,
mus_e2m6,
mus_e2m7,
mus_e2m8,
mus_e2m9,
mus_e3m1,
mus_e3m2,
mus_e3m3,
mus_e3m4,
mus_e3m5,
mus_e3m6,
mus_e3m7,
mus_e3m8,
mus_e3m9,
mus_inter,
mus_intro,
mus_bunny,
mus_victor,
mus_introa,
mus_runnin,
mus_stalks,
mus_countd,
mus_betwee,
mus_doom,
mus_the_da,
mus_shawn,
mus_ddtblu,
mus_in_cit,
mus_dead,
mus_stlks2,
mus_theda2,
mus_doom2,
mus_ddtbl2,
mus_runni2,
mus_dead2,
mus_stlks3,
mus_romero,
mus_shawn2,
mus_messag,
mus_count2,
mus_ddtbl3,
mus_ampie,
mus_theda3,
mus_adrian,
mus_messg2,
mus_romer2,
mus_tense,
mus_shawn3,
mus_openin,
mus_evil,
mus_ultima,
mus_read_m,
mus_dm2ttl,
mus_dm2int,
NUMMUSIC
} musicenum_t;
//
// Identifiers for all sfx in game.
//
typedef enum
{
sfx_None,
sfx_pistol,
sfx_shotgn,
sfx_sgcock,
sfx_dshtgn,
sfx_dbopn,
sfx_dbcls,
sfx_dbload,
sfx_plasma,
sfx_bfg,
sfx_sawup,
sfx_sawidl,
sfx_sawful,
sfx_sawhit,
sfx_rlaunc,
sfx_rxplod,
sfx_firsht,
sfx_firxpl,
sfx_pstart,
sfx_pstop,
sfx_doropn,
sfx_dorcls,
sfx_stnmov,
sfx_swtchn,
sfx_swtchx,
sfx_plpain,
sfx_dmpain,
sfx_popain,
sfx_vipain,
sfx_mnpain,
sfx_pepain,
sfx_slop,
sfx_itemup,
sfx_wpnup,
sfx_oof,
sfx_telept,
sfx_posit1,
sfx_posit2,
sfx_posit3,
sfx_bgsit1,
sfx_bgsit2,
sfx_sgtsit,
sfx_cacsit,
sfx_brssit,
sfx_cybsit,
sfx_spisit,
sfx_bspsit,
sfx_kntsit,
sfx_vilsit,
sfx_mansit,
sfx_pesit,
sfx_sklatk,
sfx_sgtatk,
sfx_skepch,
sfx_vilatk,
sfx_claw,
sfx_skeswg,
sfx_pldeth,
sfx_pdiehi,
sfx_podth1,
sfx_podth2,
sfx_podth3,
sfx_bgdth1,
sfx_bgdth2,
sfx_sgtdth,
sfx_cacdth,
sfx_skldth,
sfx_brsdth,
sfx_cybdth,
sfx_spidth,
sfx_bspdth,
sfx_vildth,
sfx_kntdth,
sfx_pedth,
sfx_skedth,
sfx_posact,
sfx_bgact,
sfx_dmact,
sfx_bspact,
sfx_bspwlk,
sfx_vilact,
sfx_noway,
sfx_barexp,
sfx_punch,
sfx_hoof,
sfx_metal,
sfx_chgun,
sfx_tink,
sfx_bdopn,
sfx_bdcls,
sfx_itmbk,
sfx_flame,
sfx_flamst,
sfx_getpow,
sfx_bospit,
sfx_boscub,
sfx_bossit,
sfx_bospn,
sfx_bosdth,
sfx_manatk,
sfx_mandth,
sfx_sssit,
sfx_ssdth,
sfx_keenpn,
sfx_keendt,
sfx_skeact,
sfx_skesit,
sfx_skeatk,
sfx_radio,
NUMSFX
} sfxenum_t;
#endif
+7
View File
@@ -0,0 +1,7 @@
#ifndef ST_GFX_H
#define ST_GFX_H
extern const unsigned char gfx_stbar[];
extern const unsigned int gfx_stbar_len;
#endif // ST_GFX_H
+177
View File
@@ -0,0 +1,177 @@
/**
* Doom Port to the nRF52840 by Nicola Wrachien (next-hack in the comments)
*
* This port is based on the excellent doomhack's GBA Doom Port,
* with Kippykip additions.
*
* Several data structures and functions have been optimized
* to fit in only 256kB RAM of nRF52840 (GBA has 384 kB RAM).
* Z-Depth Light has been restored with almost no RAM consumption!
* Tons of speed optimizations have been done, and the game now
* runs extremely fast, despite the much higher 3D resolution with
* respect to GBA.
*
* PrBoom: a Doom port merged with LxDoom and LSDLDoom
* based on BOOM, a modified and improved DOOM engine
* Copyright (C) 1999 by
* id Software, Chi Hoang, Lee Killough, Jim Flynn, Rand Phares, Ty Halderman
* Copyright (C) 1999-2000 by
* Jess Haas, Nicolas Kalkhof, Colin Phipps, Florian Schulze
* Copyright 2005, 2006 by
* Florian Schulze, Colin Phipps, Neil Stevens, Andrey Budko
* Copyright (C) 2021 Nicola Wrachien (next-hack in the comments)
* on nRF52840 port.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
* 02111-1307, USA.
*
* DESCRIPTION:
* The status bar widget definitions and prototypes
*
*-----------------------------------------------------------------------------*/
#ifndef __STLIB__
#define __STLIB__
// We are referring to patches.
#include "r_defs.h"
#include "v_video.h" // color ranges
//
// Background and foreground screen numbers
//
#define ST_BG 1
#define ST_FG 0
//
// Typedefs of widgets
//
// Number widget
typedef struct
{
// upper right-hand corner
// of the number (right-justified)
int x;
int y;
// max # of digits in number
int width;
// last number value
int oldnum;
// pointer to current value
short *num;
// pointer to boolean stating
// whether to update number
boolean *on;
// list of patches for 0-9
const patch_t **p;
} st_number_t;
// Percent widget ("child" of number widget,
// or, more precisely, contains a number widget.)
typedef struct
{
// number information
st_number_t n;
// percent sign graphic
const patch_t *p;
} st_percent_t;
// Multiple Icon widget
typedef struct
{
// center-justified location of icons
short x;
short y;
// last icon number
short oldinum;
// pointer to current icon
short *inum;
// pointer to boolean stating
// whether to update icon
boolean *on;
// list of icons
const patch_t **p;
} st_multicon_t;
// Binary Icon widget
typedef struct
{
// center-justified location of icon
int x;
int y;
// last icon value
boolean oldval;
// pointer to current icon status
boolean *val;
// pointer to boolean
// stating whether to update icon
boolean *on;
const patch_t *p; // icon
int data; // user data
} st_binicon_t;
//
// Widget creation, access, and update routines
//
// Initializes widget library.
// More precisely, initialize STMINUS,
// everything else is done somewhere else.
//
void STlib_init(void);
// Number widget routines
void STlib_initNum(st_number_t *n, int x, int y, const patch_t **pl, short *num, boolean *on, int width);
void STlib_updateNum(st_number_t *n, int cm, boolean refresh);
// Percent widget routines
void STlib_initPercent(st_percent_t *p, int x, int y, const patch_t **pl, short *num, boolean *on, const patch_t *percent);
void STlib_updatePercent(st_percent_t *per, int cm, int refresh);
// Multiple Icon widget routines
void STlib_initMultIcon(st_multicon_t *mi, int x, int y, const patch_t **il, short *inum, boolean *on);
void STlib_updateMultIcon(st_multicon_t *mi, boolean refresh);
// Binary Icon widget routines
void STlib_initBinIcon(st_binicon_t *b, int x, int y, const patch_t *i, boolean *val, boolean *on);
void STlib_updateBinIcon(st_binicon_t *bi, boolean refresh);
void ST_refreshBackground(void);
#endif
+380
View File
@@ -0,0 +1,380 @@
/**
* Doom Port to the nRF52840 by Nicola Wrachien (next-hack in the comments)
*
* This port is based on the excellent doomhack's GBA Doom Port,
* with Kippykip additions.
*
* Several data structures and functions have been optimized
* to fit in only 256kB RAM of nRF52840 (GBA has 384 kB RAM).
* Z-Depth Light has been restored with almost no RAM consumption!
* Tons of speed optimizations have been done, and the game now
* runs extremely fast, despite the much higher 3D resolution with
* respect to GBA.
*
* PrBoom: a Doom port merged with LxDoom and LSDLDoom
* based on BOOM, a modified and improved DOOM engine
* Copyright (C) 1999 by
* id Software, Chi Hoang, Lee Killough, Jim Flynn, Rand Phares, Ty Halderman
* Copyright (C) 1999-2000 by
* Jess Haas, Nicolas Kalkhof, Colin Phipps, Florian Schulze
* Copyright 2005, 2006 by
* Florian Schulze, Colin Phipps, Neil Stevens, Andrey Budko
* Copyright (C) 2021 Nicola Wrachien (next-hack in the comments)
* on nRF52840 port.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
* 02111-1307, USA.
*
* DESCRIPTION:
* Status bar code.
* Does the face/direction indicator animatin.
* Does palette indicators as well (red pain/berserk, bright pickup)
*
* next-hack:
* pointers to patches now stored in immutable flash region, saving a few
* hundred bytes of RAM.
* modified so that instead of re-rendering, if no
* changes are required, and the status bar is already rendered in
* the previous frame buffer (but not on the current one), then the
* previous frame is copied to the current frame buffer.
*
*-----------------------------------------------------------------------------*/
#ifndef __STSTUFF_H__
#define __STSTUFF_H__
#include "doomtype.h"
#include "d_event.h"
// Size of statusbar.
// Now sensitive for scaling.
// proff 08/18/98: Changed for high-res
#define ST_HEIGHT 32
#define ST_WIDTH 320
#define ST_Y (SCREENHEIGHT - ST_HEIGHT)
#if PDOOM_W == 240
#define ST_SCALED_HEIGHT ST_HEIGHT
#else
#define ST_SCALED_HEIGHT 17 /* Paradise: status bar 240x32 scaled down to 128x17 */
#define ST_SMALL 1
#endif
#define ST_SCALED_WIDTH SCREENWIDTH
#define ST_SCALED_Y (SCREENHEIGHT - ST_SCALED_HEIGHT)
// nh: reduction constant from GBA port to ours
#define ST_C 160/160
//
// STATUS BAR DATA
//
// Palette indices.
// For damage/bonus red-/gold-shifts
#define STARTREDPALS 1
#define STARTBONUSPALS 9
#define NUMREDPALS 8
#define NUMBONUSPALS 4
// Radiation suit, green shift.
#define RADIATIONPAL 13
// Location of status bar
#define ST_X 0
#define ST_X2 104
// proff 08/18/98: Changed for high-res
#define ST_FX (ST_X+143 * ST_C)
#define ST_FY (ST_Y+1)
// Should be set to patch width
// for tall numbers later on
#define ST_TALLNUMWIDTH (tallnum[0]->width)
// Number of status faces.
#define ST_NUMPAINFACES 5
#define ST_NUMSTRAIGHTFACES 3
#define ST_NUMTURNFACES 2
#define ST_NUMSPECIALFACES 3
#define ST_FACESTRIDE \
(ST_NUMSTRAIGHTFACES+ST_NUMTURNFACES+ST_NUMSPECIALFACES)
#define ST_NUMEXTRAFACES 2
#define ST_NUMFACES \
(ST_FACESTRIDE*ST_NUMPAINFACES+ST_NUMEXTRAFACES)
#define ST_TURNOFFSET (ST_NUMSTRAIGHTFACES)
#define ST_OUCHOFFSET (ST_TURNOFFSET + ST_NUMTURNFACES)
#define ST_EVILGRINOFFSET (ST_OUCHOFFSET + 1)
#define ST_RAMPAGEOFFSET (ST_EVILGRINOFFSET + 1)
#define ST_GODFACE (ST_NUMPAINFACES*ST_FACESTRIDE)
#define ST_DEADFACE (ST_GODFACE+1)
// proff 08/18/98: Changed for high-res
#define ST_FACESX (ST_X+104 * ST_C)
#define ST_FACESY (ST_Y)
#define ST_EVILGRINCOUNT (2*TICRATE)
//Fix Status bar face timing ~Kippykip
//#define ST_STRAIGHTFACECOUNT (TICRATE*2)
#define ST_STRAIGHTFACECOUNT (18)
#define ST_TURNCOUNT (1*TICRATE)
#define ST_OUCHCOUNT (1*TICRATE)
#define ST_RAMPAGEDELAY (2*TICRATE)
#define ST_MUCHPAIN 20
// Location and size of statistics,
// justified according to widget type.
// Problem is, within which space? STbar? Screen?
// Note: this could be read in by a lump.
// Problem is, is the stuff rendered
// into a buffer,
// or into the frame buffer?
// I dunno, why don't you go and find out!!! killough
#if 1
// AMMO number pos.
#define ST_AMMOWIDTH 3
// proff 08/18/98: Changed for high-res
#define ST_AMMOX (ST_X+32 * ST_C)
#define ST_AMMOY (ST_Y+6)
//#define ST_AMMOX 44
//#define ST_AMMOY 171
// HEALTH number pos.
#define ST_HEALTHWIDTH 2
// proff 08/18/98: Changed for high-res
#define ST_HEALTHX (ST_X+66 * ST_C)
#define ST_HEALTHY (ST_Y+6)
// Weapon pos.
// proff 08/18/98: Changed for high-res
#define ST_ARMSX (ST_X+82 * ST_C)
#define ST_ARMSY (ST_Y+4)
#define ST_ARMSBGX (ST_X+104 * ST_C)
#define ST_ARMSBGY (ST_Y)
#define ST_ARMSXSPACE 8
#define ST_ARMSYSPACE 10
// Frags pos.
// proff 08/18/98: Changed for high-res
#define ST_FRAGSX (ST_X+138 * ST_C)
#define ST_FRAGSY (ST_Y+3)
//#define ST_FRAGSX 138
//#define ST_FRAGSY 171
#define ST_FRAGSWIDTH 2
// ARMOR number pos.
#define ST_ARMORWIDTH 3
// proff 08/18/98: Changed for high-res
#define ST_ARMORX (ST_X+166 * ST_C)
#define ST_ARMORY (ST_Y+6)
// Key icon positions.
#define ST_KEY0WIDTH 8
#define ST_KEY0HEIGHT 5
// proff 08/18/98: Changed for high-res
#define ST_KEY0X (ST_X+178 * ST_C)
#define ST_KEY0Y (ST_Y+3)
#define ST_KEY1WIDTH ST_KEY0WIDTH
// proff 08/18/98: Changed for high-res
#define ST_KEY1X (ST_X+178 * ST_C)
#define ST_KEY1Y (ST_Y+13)
#define ST_KEY2WIDTH ST_KEY0WIDTH
// proff 08/18/98: Changed for high-res
#define ST_KEY2X (ST_X+178 * ST_C)
#define ST_KEY2Y (ST_Y+23)
// Ammunition counter.
#define ST_AMMO0WIDTH 3
#define ST_AMMO0HEIGHT 6
// proff 08/18/98: Changed for high-res
#define ST_AMMO0X (ST_X+220 * ST_C)
#define ST_AMMO0Y (ST_Y+5)
#define ST_AMMO1WIDTH ST_AMMO0WIDTH
// proff 08/18/98: Changed for high-res
#define ST_AMMO1X (ST_X+220 * ST_C)
#define ST_AMMO1Y (ST_Y+11)
#define ST_AMMO2WIDTH ST_AMMO0WIDTH
// proff 08/18/98: Changed for high-res
#define ST_AMMO2X (ST_X+220 * ST_C)
#define ST_AMMO2Y (ST_Y+23)
#define ST_AMMO3WIDTH ST_AMMO0WIDTH
// proff 08/18/98: Changed for high-res
#define ST_AMMO3X (ST_X+220 * ST_C)
#define ST_AMMO3Y (ST_Y+17)
// Indicate maximum ammunition.
// Only needed because backpack exists.
#define ST_MAXAMMO0WIDTH 3
#define ST_MAXAMMO0HEIGHT 5
// proff 08/18/98: Changed for high-res
#define ST_MAXAMMO0X (ST_X+238 * ST_C)
#define ST_MAXAMMO0Y (ST_Y+5)
#define ST_MAXAMMO1WIDTH ST_MAXAMMO0WIDTH
// proff 08/18/98: Changed for high-res
#define ST_MAXAMMO1X (ST_X+238 * ST_C)
#define ST_MAXAMMO1Y (ST_Y+11)
#define ST_MAXAMMO2WIDTH ST_MAXAMMO0WIDTH
// proff 08/18/98: Changed for high-res
#define ST_MAXAMMO2X (ST_X+238 * ST_C)
#define ST_MAXAMMO2Y (ST_Y+23)
#define ST_MAXAMMO3WIDTH ST_MAXAMMO0WIDTH
// proff 08/18/98: Changed for high-res
#define ST_MAXAMMO3X (ST_X+238 * ST_C)
#define ST_MAXAMMO3Y (ST_Y+17)
#else
#define ST_YC 1
// AMMO number pos.
#define ST_AMMOWIDTH 3
#define ST_AMMOX 44
#define ST_AMMOY 171 * ST_YC
// HEALTH number pos.
#define ST_HEALTHWIDTH 3
#define ST_HEALTHX 90
#define ST_HEALTHY 171 * ST_YC
// Weapon pos.
#define ST_ARMSX 111
#define ST_ARMSY 172 * ST_YC
#define ST_ARMSBGX 104
#define ST_ARMSBGY 168 * ST_YC
#define ST_ARMSXSPACE 12
#define ST_ARMSYSPACE 10
// Frags pos.
#define ST_FRAGSX 138
#define ST_FRAGSY 171 * ST_YC
#define ST_FRAGSWIDTH 2
// ARMOR number pos.
#define ST_ARMORWIDTH 3
#define ST_ARMORX 221
#define ST_ARMORY 171 * ST_YC
// Key icon positions.
#define ST_KEY0WIDTH 8
#define ST_KEY0HEIGHT 5
#define ST_KEY0X 239
#define ST_KEY0Y 171 * ST_YC
#define ST_KEY1WIDTH ST_KEY0WIDTH
#define ST_KEY1X 239
#define ST_KEY1Y 181 * ST_YC
#define ST_KEY2WIDTH ST_KEY0WIDTH
#define ST_KEY2X 239
#define ST_KEY2Y 191 * ST_YC
// Ammunition counter.
#define ST_AMMO0WIDTH 3
#define ST_AMMO0HEIGHT 6
#define ST_AMMO0X 288
#define ST_AMMO0Y 173 * ST_YC
#define ST_AMMO1WIDTH ST_AMMO0WIDTH
#define ST_AMMO1X 288
#define ST_AMMO1Y 179 * ST_YC
#define ST_AMMO2WIDTH ST_AMMO0WIDTH
#define ST_AMMO2X 288
#define ST_AMMO2Y 191 * ST_YC
#define ST_AMMO3WIDTH ST_AMMO0WIDTH
#define ST_AMMO3X 288
#define ST_AMMO3Y 185 * ST_YC
// Indicate maximum ammunition.
// Only needed because backpack exists.
#define ST_MAXAMMO0WIDTH 3
#define ST_MAXAMMO0HEIGHT 5
#define ST_MAXAMMO0X 314
#define ST_MAXAMMO0Y 173 * ST_YC
#define ST_MAXAMMO1WIDTH ST_MAXAMMO0WIDTH
#define ST_MAXAMMO1X 314
#define ST_MAXAMMO1Y 179 * ST_YC
#define ST_MAXAMMO2WIDTH ST_MAXAMMO0WIDTH
#define ST_MAXAMMO2X 314
#define ST_MAXAMMO2Y 191 * ST_YC
#define ST_MAXAMMO3WIDTH ST_MAXAMMO0WIDTH
#define ST_MAXAMMO3X 314
#define ST_MAXAMMO3Y 185 * ST_YC
// pistol
#define ST_WEAPON0X 110
#define ST_WEAPON0Y 172 * ST_YC
// shotgun
#define ST_WEAPON1X 122
#define ST_WEAPON1Y 172 * ST_YC
// chain gun
#define ST_WEAPON2X 134
#define ST_WEAPON2Y 172 * ST_YC
// missile launcher
#define ST_WEAPON3X 110
#define ST_WEAPON3Y 181 * ST_YC
// plasma gun
#define ST_WEAPON4X 122
#define ST_WEAPON4Y 181 * ST_YC
// bfg
#define ST_WEAPON5X 134
#define ST_WEAPON5Y 181 * ST_YC
// WPNS title
#define ST_WPNSX 109
#define ST_WPNSY 191 * ST_YC
// DETH title
#define ST_DETHX 109
#define ST_DETHY 191 * ST_YC
#endif
//
// STATUS BAR
//
// Called by main loop.
boolean ST_Responder(const event_t *ev);
// Called by main loop.
void ST_Ticker(void);
// Called by main loop.
void ST_Drawer(boolean st_statusbaron, boolean refresh);
// Called when the console player is spawned on each level.
void ST_Start(void);
// Called by startup code.
void ST_Init(void);
// States for status bar code.
typedef enum
{
AutomapState, FirstPersonState
} st_stateenum_t;
// killough 5/2/98: moved from m_misc.c:
#endif
+137
View File
@@ -0,0 +1,137 @@
/**
* Doom Port to the nRF52840 by Nicola Wrachien (next-hack in the comments)
*
* This port is based on the excellent doomhack's GBA Doom Port,
* with Kippykip additions.
*
* Several data structures and functions have been optimized
* to fit in only 256kB RAM of nRF52840 (GBA has 384 kB RAM).
* Z-Depth Light has been restored with almost no RAM consumption!
* Tons of speed optimizations have been done, and the game now
* runs extremely fast, despite the much higher 3D resolution with
* respect to GBA.
*
* PrBoom: a Doom port merged with LxDoom and LSDLDoom
* based on BOOM, a modified and improved DOOM engine
* Copyright (C) 1999 by
* id Software, Chi Hoang, Lee Killough, Jim Flynn, Rand Phares, Ty Halderman
* Copyright (C) 1999-2000 by
* Jess Haas, Nicolas Kalkhof, Colin Phipps, Florian Schulze
* Copyright 2005, 2006 by
* Florian Schulze, Colin Phipps, Neil Stevens, Andrey Budko
* Copyright (C) 2021 Nicola Wrachien (next-hack in the comments)
* on nRF52840 port.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
* 02111-1307, USA.
*
* DESCRIPTION:
* Lookup tables.
* Do not try to look them up :-).
* In the order of appearance:
*
* int finetangent[4096] - Tangens LUT.
* Should work with BAM fairly well (12 of 16bit,
* effectively, by shifting).
*
* int finesine[10240] - Sine lookup.
* Guess what, serves as cosine, too.
* Remarkable thing is, how to use BAMs with this?
*
* int tantoangle[2049] - ArcTan LUT,
* maps tan(angle) to angle fast. Gotta search.
*
*-----------------------------------------------------------------------------*/
#ifndef __TABLES__
#define __TABLES__
#include "m_fixed.h"
#include "doomdef.h"
//
// Lighting constants.
#define LIGHTLEVELS 16
#define LIGHTSEGSHIFT 4
#define MAXLIGHTSCALE 48
#define LIGHTSCALESHIFT 12
#define MAXLIGHTZ 128
#define LIGHTZSHIFT 20
// Number of diminishing brightness levels.
// There a 0-31, i.e. 32 LUT in the COLORMAP lump.
#define NUMCOLORMAPS 32
//
#define TABULATED_VALUES 1 // use resolution-dependent tabulated values for some arrays.
#define FINEANGLES 8192
#define FINEMASK (FINEANGLES-1)
// 0x100000000 to 0x2000
#define ANGLETOFINESHIFT 19
// Binary Angle Measument, BAM.
#define ANG45 0x20000000
#define ANG90 0x40000000
#define ANG180 0x80000000
#define ANG270 0xc0000000
#ifndef M_PI
#define M_PI 3.14159265358979323846
#endif
#define SLOPERANGE 2048
#define SLOPEBITS 11
#define DBITS (FRACBITS-SLOPEBITS)
typedef unsigned angle_t;
// Load trig tables if needed
void R_LoadTrigTables(void);
// Effective size is 10240.
extern const fixed_t finesine[10240];
// Re-use data, is just PI/2 phase shift.
extern const fixed_t *const finecosine;
// Effective size is 4096.
extern const fixed_t finetangent[4096];
// Effective size is 2049;
// The +1 size is to handle the case when x==y without additional checking.
extern const angle_t tantoangle[2049];
#if TABULATED_VALUES
extern const short viewangletox[4096];
extern const angle_t xtoviewangle[SCREENWIDTH + 1];
extern const fixed_t yslope[SCREENHEIGHT];
extern const fixed_t distscale[SCREENWIDTH];
extern const uint8_t scalelight[LIGHTLEVELS][MAXLIGHTSCALE];
extern const uint8_t zlight[LIGHTLEVELS][MAXLIGHTZ];
#else
extern int viewangletox[4096];
extern angle_t xtoviewangle[SCREENWIDTH + 1];
extern fixed_t yslope[SCREENHEIGHT];
extern fixed_t distscale[SCREENWIDTH];
#endif
extern const short screenheightarray[SCREENWIDTH_PHYSICAL];
extern const short negonearray[SCREENWIDTH_PHYSICAL];
extern const unsigned char translationtables[1023];
#endif
+147
View File
@@ -0,0 +1,147 @@
/**
* Doom Port to the nRF52840 by Nicola Wrachien (next-hack in the comments)
*
* This port is based on the excellent doomhack's GBA Doom Port,
* with Kippykip additions.
*
* Several data structures and functions have been optimized
* to fit in only 256kB RAM of nRF52840 (GBA has 384 kB RAM).
* Z-Depth Light has been restored with almost no RAM consumption!
* Tons of speed optimizations have been done, and the game now
* runs extremely fast, despite the much higher 3D resolution with
* respect to GBA.
*
* PrBoom: a Doom port merged with LxDoom and LSDLDoom
* based on BOOM, a modified and improved DOOM engine
* Copyright (C) 1999 by
* id Software, Chi Hoang, Lee Killough, Jim Flynn, Rand Phares, Ty Halderman
* Copyright (C) 1999-2000 by
* Jess Haas, Nicolas Kalkhof, Colin Phipps, Florian Schulze
* Copyright 2005, 2006 by
* Florian Schulze, Colin Phipps, Neil Stevens, Andrey Budko
* Copyright (C) 2021 Nicola Wrachien (next-hack in the comments)
* on nRF52840 port.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
* 02111-1307, USA.
*
* DESCRIPTION:
* Gamma correction LUT.
* Color range translation support
* Functions to draw patches (by post) directly to screen.
* Functions to blit a block to the screen.
*
*-----------------------------------------------------------------------------*/
#ifndef __V_VIDEO__
#define __V_VIDEO__
#include "doomtype.h"
#include "doomdef.h"
// Needed because we are refering to patches.
#include "r_data.h"
#include "r_patch.h"
#define MAX_PATCH_COLOFFS 128
#define MAX_COLUMN_DATA 256
//
// VIDEO
//
#define MAX_GAMMA 4
#define CENTERY (SCREENHEIGHT/2)
extern int v_pitch;
#define ScreenYToOffset(x) (v_pitch * (x))
// symbolic indices into color translation table pointer array
typedef enum
{
CR_BRICK, //0
CR_TAN, //1
CR_GRAY, //2
CR_GREEN, //3
CR_BROWN, //4
CR_GOLD, //5
CR_RED, //6
CR_BLUE, //7
CR_ORANGE, //8
CR_YELLOW, //9
CR_BLUE2, //10 // proff
CR_LIMIT //11 //jff 2/27/98 added for range check
} crange_idx_e;
//jff 1/16/98 end palette color range additions
#define CR_DEFAULT CR_RED /* default value for out of range colors */
typedef struct
{
uint8_t *data; // pointer to the screen content
// short width; // the width of the surface
// short height; // the height of the surface, used when mallocing
} screeninfo_t;
#define NUM_SCREENS 1
// V_FillRect
void V_FillRect(int x, int y, int width, int height, byte colour);
// CPhipps - patch drawing
// Consolidated into the 3 really useful functions:
// V_DrawNumPatch - Draws the patch from lump num
void V_DrawNumPatch(int x, int y, int scrn, int lump, int cm, enum patch_translation_e flags);
void V_DrawPatch(int x, int y, int scrn, const patch_t *patch);
void V_DrawPatchXScale(int x, int y, const patch_t *patch);
void V_DrawPatchNoScale(int x, int y, const patch_t *patch);
// V_DrawNamePatch - Draws the patch from lump "name"
#define V_DrawNamePatch(x,y,s,n,t,f) V_DrawNumPatch(x,y,s,W_GetNumForName(n),t,f)
/* cph -
* Functions to return width & height of a patch.
* Doesn't really belong here, but is often used in conjunction with
* this code.
*/
#define V_NamePatchWidth(name) R_NumPatchWidth(W_GetNumForName(name))
#define V_NamePatchHeight(name) R_NumPatchHeight(W_GetNumForName(name))
/* cphipps 10/99: function to tile a flat over the screen */
void V_DrawBackground(const char *flatname);
// CPhipps - function to set the palette to palette number pal.
void V_SetPalette(int pal);
// Kippykip - Multiple colour corrected palettes
void V_SetPalLump(int pal);
// CPhipps - function to plot a pixel
typedef struct
{
int x, y;
} fpoint_t;
typedef struct
{
fpoint_t a, b;
} fline_t;
// V_DrawLine
void V_DrawLine(fline_t *fl, int color);
//
extern const byte gammatable[5][256];
#endif
+50
View File
@@ -0,0 +1,50 @@
/**
* Doom Port to the nRF52840 by Nicola Wrachien (next-hack in the comments)
*
* This port is based on the excellent doomhack's GBA Doom Port,
* with Kippykip additions.
*
* Several data structures and functions have been optimized
* to fit in only 256kB RAM of nRF52840 (GBA has 384 kB RAM).
* Z-Depth Light has been restored with almost no RAM consumption!
* Tons of speed optimizations have been done, and the game now
* runs extremely fast, despite the much higher 3D resolution with
* respect to GBA.
*
* PrBoom: a Doom port merged with LxDoom and LSDLDoom
* based on BOOM, a modified and improved DOOM engine
* Copyright (C) 1999 by
* id Software, Chi Hoang, Lee Killough, Jim Flynn, Rand Phares, Ty Halderman
* Copyright (C) 1999-2000 by
* Jess Haas, Nicolas Kalkhof, Colin Phipps, Florian Schulze
* Copyright 2005, 2006 by
* Florian Schulze, Colin Phipps, Neil Stevens, Andrey Budko
* Copyright (C) 2021 Nicola Wrachien (next-hack in the comments)
* on nRF52840 port.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
* 02111-1307, USA.
*
* DESCRIPTION:
* Doom version indicators.
*
*-----------------------------------------------------------------------------*/
#ifndef __DOOMVERSION__
#define __DOOMVERSION__
extern const char version_date[];
#endif
+167
View File
@@ -0,0 +1,167 @@
/**
* Doom Port to the nRF52840 by Nicola Wrachien (next-hack in the comments)
*
* This port is based on the excellent doomhack's GBA Doom Port,
* with Kippykip additions.
*
* Several data structures and functions have been optimized
* to fit in only 256kB RAM of nRF52840 (GBA has 384 kB RAM).
* Z-Depth Light has been restored with almost no RAM consumption!
* Tons of speed optimizations have been done, and the game now
* runs extremely fast, despite the much higher 3D resolution with
* respect to GBA.
*
* PrBoom: a Doom port merged with LxDoom and LSDLDoom
* based on BOOM, a modified and improved DOOM engine
* Copyright (C) 1999 by
* id Software, Chi Hoang, Lee Killough, Jim Flynn, Rand Phares, Ty Halderman
* Copyright (C) 1999-2000 by
* Jess Haas, Nicolas Kalkhof, Colin Phipps, Florian Schulze
* Copyright 2005, 2006 by
* Florian Schulze, Colin Phipps, Neil Stevens, Andrey Budko
* Copyright (C) 2021 Nicola Wrachien (next-hack in the comments)
* on nRF52840 port.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
* 02111-1307, USA.
*
* DESCRIPTION:
* WAD I/O functions.
* next-hack: important data internal flash caching functions.
*
*-----------------------------------------------------------------------------*/
#ifndef __W_WAD__
#define __W_WAD__
#include "doomtype.h"
#include <stdint.h>
#include "st_stuff.h"
#include "r_defs.h"
#include "i_memory.h"
//
// TYPES
//
typedef struct
{
char identification[4]; // Should be "IWAD" or "PWAD".
int numlumps;
int infotableofs;
} wadinfo_t;
typedef struct
{
int filepos;
int size;
char name[8];
} filelump_t;
// killough 4/17/98: if W_CheckNumForName() called with only
// one argument, pass ns_global as the default namespace
typedef struct
{
uint32_t dataLength;
union
{
struct
{
uint32_t map :16;
uint32_t episode :16;
};
uint32_t mapEpisode;
};
void **lumpAddressTable;
uint32_t numvertex;
vertex_t *vertexes;
uint32_t numsegs;
seg_t *segs;
int numnodes;
mapnode_t *nodes;
int numlines;
line_t *lines;
int numsides;
short *blockmaplump;
side_t *sides;
byte *rejectmatrix;
uint32_t data[0]; // textures, flats,
} wad_level_flash_data_t;
typedef struct
{
uint32_t wadCRC;
uint32_t wadSize;
uint32_t immutableDataCRC;
uint32_t immutableDataLength; // including this structure
wadinfo_t wadHeader;
uint32_t numsprites;
spritedef_t *sprites;
uint8_t *palette_lump;
lighttable_t *colormaps;
uint32_t *soundLumps;
uint32_t numtextures;
fixed_t *textureheight;
short *switchlist;
patchsizeoffsets_t *patchLumpSizeOffsets;
// 0-9, tall numbers
const patch_t *tallnum[10];
// 0-9, short, yellow (,different!) numbers
const patch_t *shortnum[10];
// tall % sign
const patch_t *tallpercent;
const patch_t *keys[NUMCARDS];
// face status patches
const patch_t *faces[ST_NUMFACES]; // >160 bytes wasted...
// weapon ownership patches
const patch_t *arms[6][2];
wad_level_flash_data_t *levelData;
// after this, immutable data:
// playpal, and some TBD
uint32_t data[0];
} wad_immutable_flash_data_t;
extern wad_immutable_flash_data_t *p_wad_immutable_flash_data;
extern wad_level_flash_data_t *p_wad_level_flash_data;
void W_Init(void); // CPhipps - uses the above array
int PUREFUNC W_CheckNumForName(const char *name); // killough 4/17/98
int PUREFUNC W_GetNumForName(const char *name);
const char* PUREFUNC W_GetNameForNum(int lump);
int PUREFUNC W_LumpLength(int lump);
// CPhipps - modified for 'new' lump locking
const void* /*PUREFUNC*/W_CacheLumpNum(int lump);
// CPhipps - convenience macros
#define W_CacheLumpName(name) W_CacheLumpNum(W_GetNumForName(name))
/*static inline void *W_CacheLumpName(char * name)
{
printf("Caching name %s\r\n", name);
return W_CacheLumpNum(W_GetNumForName(name));
}*/
void ExtractFileBase(const char*, char*); // killough
// next-hack additions
void initLumpPtrTable(void);
void* writeLumpToFlashRegion(int lumpnum, uint8_t flashRegion, boolean updateSize);
void* writeBufferToFlashRegion(void *buffer, int size, uint8_t flashRegion, boolean updateSize);
int getUserFlashRegionRemainingSpace();
void getFileLumpByNum(int n, filelump_t *fl);
void initImmutableFlashRegion();
void* getAddressOrCacheLumpNum(int lump, boolean storeInFlash, uint8_t flashRegion);
void** storeLumpArrayToFlash(boolean levelChanged);
void* storeFlashImmutableValues();
void* storeLevelValues(boolean levelChanged);
wad_level_flash_data_t* initLevelFlashRegion();
extern void **lumpPtrArray;
#endif
+76
View File
@@ -0,0 +1,76 @@
/**
* Doom Port to the nRF52840 by Nicola Wrachien (next-hack in the comments)
*
* This port is based on the excellent doomhack's GBA Doom Port,
* with Kippykip additions.
*
* Several data structures and functions have been optimized
* to fit in only 256kB RAM of nRF52840 (GBA has 384 kB RAM).
* Z-Depth Light has been restored with almost no RAM consumption!
* Tons of speed optimizations have been done, and the game now
* runs extremely fast, despite the much higher 3D resolution with
* respect to GBA.
*
* PrBoom: a Doom port merged with LxDoom and LSDLDoom
* based on BOOM, a modified and improved DOOM engine
* Copyright (C) 1999 by
* id Software, Chi Hoang, Lee Killough, Jim Flynn, Rand Phares, Ty Halderman
* Copyright (C) 1999-2000 by
* Jess Haas, Nicolas Kalkhof, Colin Phipps, Florian Schulze
* Copyright 2005, 2006 by
* Florian Schulze, Colin Phipps, Neil Stevens, Andrey Budko
* Copyright (C) 2021 Nicola Wrachien (next-hack in the comments)
* on nRF52840 port.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
* 02111-1307, USA.
*
* DESCRIPTION:
* Intermission screens.
*
*-----------------------------------------------------------------------------*/
#ifndef __WI_STUFF__
#define __WI_STUFF__
//#include "v_video.h"
#include "doomdef.h"
// States for the intermission
typedef enum
{
NoState = -1, StatCount, ShowNextLoc
} stateenum_t;
// called by the initialization
void WI_Init(void);
// Called by main loop, animate the intermission.
void WI_Ticker(void);
// Called by main loop,
// draws the intermission directly into the screen buffer.
void WI_Drawer(void);
// Setup for an intermission screen.
void WI_Start(wbstartstruct_t *wbstartstruct);
// Release intermission screen memory
void WI_End(void);
#endif
+67
View File
@@ -0,0 +1,67 @@
/**
* Doom Port to the nRF52840 by Nicola Wrachien (next-hack in the comments)
*
* This port is based on the excellent doomhack's GBA Doom Port,
* with Kippykip additions.
*
* Several data structures and functions have been optimized
* to fit in only 256kB RAM of nRF52840 (GBA has 384 kB RAM).
* Z-Depth Light has been restored with almost no RAM consumption!
* Tons of speed optimizations have been done, and the game now
* runs extremely fast, despite the much higher 3D resolution with
* respect to GBA.
*
* PrBoom: a Doom port merged with LxDoom and LSDLDoom
* based on BOOM, a modified and improved DOOM engine
* Copyright (C) 1999 by
* id Software, Chi Hoang, Lee Killough, Jim Flynn, Rand Phares, Ty Halderman
* Copyright (C) 1999-2000 by
* Jess Haas, Nicolas Kalkhof, Colin Phipps, Florian Schulze
* Copyright 2005, 2006 by
* Florian Schulze, Colin Phipps, Neil Stevens, Andrey Budko
* Copyright (C) 2021 Nicola Wrachien (next-hack in the comments)
* on nRF52840 port.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
* 02111-1307, USA.
*
* DESCRIPTION:
* Block memory allocator
* This is designed to be a fast allocator for small, regularly used block sizes
*-----------------------------------------------------------------------------*/
struct block_memory_alloc_s
{
void *firstpool;
// size_t size;
// size_t perpool;
// int tag;
unsigned short size;
unsigned short perpool :11;
unsigned short tag :5;
// const char *desc;
};
#define DECLARE_BLOCK_MEMORY_ALLOC_ZONE(name) extern struct block_memory_alloc_s name
#define IMPLEMENT_BLOCK_MEMORY_ALLOC_ZONE(name, size, tag, num, desc) \
struct block_memory_alloc_s name = { NULL, size, num, tag}
#define NULL_BLOCK_MEMORY_ALLOC_ZONE(name) name.firstpool = NULL
DECLARE_BLOCK_MEMORY_ALLOC_ZONE(mobjzone);
DECLARE_BLOCK_MEMORY_ALLOC_ZONE(static_mobjzone);
void* Z_BMalloc(struct block_memory_alloc_s *pzone);
boolean Z_BFree(struct block_memory_alloc_s *pzone, void *p);
+125
View File
@@ -0,0 +1,125 @@
/**
* Doom Port to the nRF52840 by Nicola Wrachien (next-hack in the comments)
*
* This port is based on the excellent doomhack's GBA Doom Port,
* with Kippykip additions.
*
* Several data structures and functions have been optimized
* to fit in only 256kB RAM of nRF52840 (GBA has 384 kB RAM).
* Z-Depth Light has been restored with almost no RAM consumption!
* Tons of speed optimizations have been done, and the game now
* runs extremely fast, despite the much higher 3D resolution with
* respect to GBA.
*
* PrBoom: a Doom port merged with LxDoom and LSDLDoom
* based on BOOM, a modified and improved DOOM engine
* Copyright (C) 1999 by
* id Software, Chi Hoang, Lee Killough, Jim Flynn, Rand Phares, Ty Halderman
* Copyright (C) 1999-2000 by
* Jess Haas, Nicolas Kalkhof, Colin Phipps, Florian Schulze
* Copyright 2005, 2006 by
* Florian Schulze, Colin Phipps, Neil Stevens, Andrey Budko
* Copyright (C) 2021 Nicola Wrachien (next-hack in the comments)
* on nRF52840 port.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
* 02111-1307, USA.
*
* DESCRIPTION:
* Zone Memory Allocation, perhaps NeXT ObjectiveC inspired.
* Remark: this was the only stuff that, according
* to John Carmack, might have been useful for
* Quake.
*
* Rewritten by Lee Killough, though, since it was not efficient enough.
*
* Restored back to its original form by Nicola Wrachien and optimized,
* as it was not memory efficient enough (see zone.c).
*
*---------------------------------------------------------------------*/
#ifndef __Z_ZONE__
#define __Z_ZONE__
#ifndef __GNUC__
#define __attribute__(x)
#endif
// Include system definitions so that prototypes become
// active before macro replacements below are in effect.
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
//#include <assert.h>
#define STRINGIFY(x) #x
#define TOSTRING(x) STRINGIFY(x)
// ZONE MEMORY
// PU - purge tags.
enum
{
PU_FREE, PU_STATIC, /*PU_SOUND, PU_MUSIC,*/PU_LEVEL, PU_LEVSPEC, /*PU_CACHE,*/
/* Must always be last -- killough */PU_MAX
};
#define PU_PURGELEVEL PU_MAX /* First purgable tag's level */
#define DA(x,y)
#define DAC(x,y)
void* (Z_Malloc2)(int size, int tag, void **ptr, const char *sz DA(const char *, int));
void (Z_Free)(void *ptr DA(const char *, int));
void (Z_FreeTags)(int lowtag, int hightag DA(const char *, int));
void (Z_ChangeTag)(void *ptr, int tag DA(const char *, int));
void (Z_Init)(void);
void Z_Close(void);
void* (Z_Calloc)(size_t n, size_t n2, int tag, void **user DA(const char *, int));
void* (Z_Realloc)(void *p, size_t n, int tag, void **user DA(const char *, int));
char* (Z_Strdup)(const char *s, int tag, void **user DA(const char *, int));
void (Z_CheckHeap)(DAC(const char *,int)); // killough 3/22/98: add file/line info
void Z_DumpHistory(char*);
#define Z_Malloc(n, tag, u) Z_Malloc2(n, tag, u, TOSTRING(n) )
/* cphipps 2001/11/18 -
* If we're using memory mapped file access to WADs, we won't need to maintain
* our own heap. So we *could* let "normal" malloc users use the libc malloc
* directly, for efficiency. Except we do need a wrapper to handle out of memory
* errors... damn, ok, we'll leave it for now.
*/
#ifndef HAVE_LIBDMALLOC
// Remove all definitions before including system definitions
//
#undef malloc
#undef free
#undef realloc
#undef calloc
#undef strdup
#define malloc(n) Z_Malloc(n,PU_STATIC,0)
#define free(p) Z_Free(p)
#define realloc(p,n) Z_Realloc(p,n,PU_STATIC,0)
#define calloc(n1,n2) Z_Calloc(n1,n2,PU_STATIC,0)
#define strdup(s) Z_Strdup(s,PU_STATIC,0)
#endif
void Z_ZoneHistory(char*);
#endif
File diff suppressed because it is too large. Load diff
+168
View File
@@ -0,0 +1,168 @@
/**
* Doom Port to the nRF52840 by Nicola Wrachien (next-hack in the comments)
*
* This port is based on the excellent doomhack's GBA Doom Port,
* with Kippykip additions.
*
* Several data structures and functions have been optimized
* to fit in only 256kB RAM of nRF52840 (GBA has 384 kB RAM).
* Z-Depth Light has been restored with almost no RAM consumption!
* Tons of speed optimizations have been done, and the game now
* runs extremely fast, despite the much higher 3D resolution with
* respect to GBA.
*
* PrBoom: a Doom port merged with LxDoom and LSDLDoom
* based on BOOM, a modified and improved DOOM engine
* Copyright (C) 1999 by
* id Software, Chi Hoang, Lee Killough, Jim Flynn, Rand Phares, Ty Halderman
* Copyright (C) 1999-2000 by
* Jess Haas, Nicolas Kalkhof, Colin Phipps, Florian Schulze
* Copyright 2005, 2006 by
* Florian Schulze, Colin Phipps, Neil Stevens, Andrey Budko
* Copyright (C) 2021 Nicola Wrachien (next-hack in the comments)
* on nRF52840 port.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
* 02111-1307, USA.
*
* DESCRIPTION:
* next-hack: On this port no multplayer is supported.
* Here we use the display-buffer (15kB) as stack, so we
* do not need to worry for stack overflows at least when dealing
* with Doom game-logic handling.
*
*-----------------------------------------------------------------------------
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <sys/types.h>
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
#ifdef HAVE_SYS_WAIT_H
#include <sys/wait.h>
#endif
#include "doomtype.h"
#include "doomstat.h"
#include "d_net.h"
#include "z_zone.h"
#include "d_main.h"
#include "g_game.h"
#include "m_menu.h"
#include "protocol.h"
#include "i_network.h"
#include "i_system.h"
#include "i_main.h"
#include "i_video.h"
#include "lprintf.h"
#include "global_data.h"
#include "graphics.h"
void D_InitNetGame(void)
{
_g->playeringame = true;
}
void D_BuildNewTiccmds(void)
{
int newtics = I_GetTime() - _g->lastmadetic;
_g->lastmadetic += newtics;
while (newtics--)
{
I_StartTic();
if (_g->maketic - _g->gametic > 3)
break;
G_BuildTiccmd(&_g->netcmd);
_g->maketic++;
}
}
void TryRunTics2(void)
{
int runtics;
int entertime = I_GetTime();
// Wait for tics to run
static int plog_tr; int plog_b = 0;
if (plog_tr < 3) PLOG(0x300 + plog_tr * 0x10);
while (1)
{
D_BuildNewTiccmds();
if (plog_tr < 3 && !plog_b) { PLOG(0x301 + plog_tr * 0x10); plog_b = 1; }
runtics = (_g->maketic) - _g->gametic;
if (runtics <= 0)
{
if (I_GetTime() - entertime > 10)
{
M_Ticker();
if (plog_tr < 3) { PLOG(0x30F + plog_tr * 0x10); plog_tr++; }
return;
}
}
else
break;
}
while (runtics-- > 0)
{
if (_g->advancedemo)
D_DoAdvanceDemo();
if (plog_tr < 3) PLOG(0x302 + plog_tr * 0x10);
M_Ticker();
if (plog_tr < 3) PLOG(0x303 + plog_tr * 0x10);
G_Ticker();
if (plog_tr < 3) PLOG(0x304 + plog_tr * 0x10);
_g->gametic++;
}
if (plog_tr < 3) plog_tr++;
}
void TryRunTics(void)
{
#ifdef NO_STACK_SWITCH
/* v0.1.9: game loop on the normal stack in SRAM instead of in the framebuffer (RAM20) */
TryRunTics2();
return;
#endif
// "displayData.displayFrameBuffer[displayData.workingBuffer]" is a very large buffer, which will be modified
// by the game rendering AFTER the game logic has been called, and for sure is not the one used by the DMA.
// Why not using it as stack ?
// Note, why "-SCREEN_WIDTH * ST_HEIGHT - 4"? Because in this way, when the status bar does not need an update (i.e. no change in ammo, health, etc.)
// we can avoid redrawing it, saving a lot of time.
__asm volatile
(
"STR SP, [%[newStack]], #-4\n\t"
"MOV SP, %[newStack]\n\t"
: : [newStack] "r" ((uint8_t*) displayData.displayFrameBuffer[displayData.workingBuffer] + sizeof(displayData.displayFrameBuffer[0]) - SCREENWIDTH * ST_HEIGHT - 4)
);
// actually run doom game
TryRunTics2();
// restore stack
__asm volatile
(
"LDR SP, [%[newStack]]\n\t"
: : [newStack] "r" ((uint8_t*) displayData.displayFrameBuffer[displayData.workingBuffer] + sizeof(displayData.displayFrameBuffer[0]) - SCREENWIDTH * ST_HEIGHT - 4)
);
}
+81
View File
@@ -0,0 +1,81 @@
/* Emacs style mode select -*- C++ -*-
*-----------------------------------------------------------------------------
*
*
* PrBoom: a Doom port merged with LxDoom and LSDLDoom
* based on BOOM, a modified and improved DOOM engine
* Copyright (C) 1999 by
* id Software, Chi Hoang, Lee Killough, Jim Flynn, Rand Phares, Ty Halderman
* Copyright (C) 1999-2000 by
* Jess Haas, Nicolas Kalkhof, Colin Phipps, Florian Schulze
* Copyright 2005, 2006 by
* Florian Schulze, Colin Phipps, Neil Stevens, Andrey Budko
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
* 02111-1307, USA.
*
* DESCRIPTION:
* Something to do with weapon sprite frames. Don't ask me.
*
*-----------------------------------------------------------------------------
*/
// We are referring to sprite numbers.
#include "doomtype.h"
#include "info.h"
#include "d_items.h"
//
// PSPRITE ACTIONS for waepons.
// This struct controls the weapon animations.
//
// Each entry is:
// ammo/amunition type
// upstate
// downstate
// readystate
// atkstate, i.e. attack/fire/hit frame
// flashstate, muzzle flash
//
const weaponinfo_t weaponinfo[NUMWEAPONS] = {
{// fist
am_noammo, S_PUNCHUP, S_PUNCHDOWN, S_PUNCH, S_PUNCH1, S_NULL
},
{// pistol
am_clip, S_PISTOLUP, S_PISTOLDOWN, S_PISTOL, S_PISTOL1, S_PISTOLFLASH
},
{// shotgun
am_shell, S_SGUNUP, S_SGUNDOWN, S_SGUN, S_SGUN1, S_SGUNFLASH1
},
{// chaingun
am_clip, S_CHAINUP, S_CHAINDOWN, S_CHAIN, S_CHAIN1, S_CHAINFLASH1
},
{// missile launcher
am_misl, S_MISSILEUP, S_MISSILEDOWN, S_MISSILE, S_MISSILE1, S_MISSILEFLASH1
},
{// plasma rifle
am_cell, S_PLASMAUP, S_PLASMADOWN, S_PLASMA, S_PLASMA1, S_PLASMAFLASH1
},
{// bfg 9000
am_cell, S_BFGUP, S_BFGDOWN, S_BFG, S_BFG1, S_BFGFLASH1
},
{// chainsaw
am_noammo, S_SAWUP, S_SAWDOWN, S_SAW, S_SAW1, S_NULL
},
{// super shotgun
am_shell, S_DSGUNUP, S_DSGUNDOWN, S_DSGUN, S_DSGUN1, S_DSGUNFLASH1
},
};
+981
View File
@@ -0,0 +1,981 @@
/**
* Doom Port to the nRF52840 by Nicola Wrachien (next-hack in the comments)
*
* This port is based on the excellent doomhack's GBA Doom Port,
* with Kippykip additions.
*
* Several data structures and functions have been optimized
* to fit in only 256kB RAM of nRF52840 (GBA has 384 kB RAM).
* Z-Depth Light has been restored with almost no RAM consumption!
* Tons of speed optimizations have been done, and the game now
* runs extremely fast, despite the much higher 3D resolution with
* respect to GBA.
*
* PrBoom: a Doom port merged with LxDoom and LSDLDoom
* based on BOOM, a modified and improved DOOM engine
* Copyright (C) 1999 by
* id Software, Chi Hoang, Lee Killough, Jim Flynn, Rand Phares, Ty Halderman
* Copyright (C) 1999-2000 by
* Jess Haas, Nicolas Kalkhof, Colin Phipps, Florian Schulze
* Copyright 2005, 2006 by
* Florian Schulze, Colin Phipps, Neil Stevens, Andrey Budko
* Copyright (C) 2021 Nicola Wrachien (next-hack in the comments)
* on nRF52840 port.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
* 02111-1307, USA.
*
* DESCRIPTION:
* DOOM main program (D_DoomMain) and game loop (D_DoomLoop),
* plus functions to determine game mode (shareware, registered),
* parse command line parameters, configure game parameters (turbo),
* and call the startup functions.
* next-hack: modified setup order to support flash caching.
* also removed if-less handling of input events.
*
*-----------------------------------------------------------------------------
*/
#include "doomdef.h"
#include "doomtype.h"
#include "doomstat.h"
#include "d_net.h"
#include "dstrings.h"
#include "sounds.h"
#include "z_zone.h"
#include "w_wad.h"
#include "s_sound.h"
#include "v_video.h"
#include "f_finale.h"
#include "f_wipe.h"
#include "m_misc.h"
#include "m_menu.h"
#include "i_main.h"
#include "i_system.h"
#include "i_sound.h"
#include "i_video.h"
#include "g_game.h"
#include "hu_stuff.h"
#include "wi_stuff.h"
#include "st_stuff.h"
#include "am_map.h"
#include "p_setup.h"
#include "r_draw.h"
#include "r_main.h"
#include "d_main.h"
#include "lprintf.h" // jff 08/03/98 - declaration of lprintf
#include "am_map.h"
#include "m_cheat.h"
#include "doom_iwad.h"
#include "global_data.h"
#include "i_spi_support.h"
#include "pwm_audio.h"
#include "graphics.h"
#include "main.h"
#include "delay.h"
static int g_plog_loops;
void GetFirstMap(int *ep, int *map); // Ty 08/29/98 - add "-warp x" functionality
static void D_PageDrawer(void);
static void D_UpdateFPS(void);
// CPhipps - removed wadfiles[] stuff
//jff 1/22/98 parms for disabling music and sound
const boolean nosfxparm = false;
#if defined(PARADISE_DEV) && defined(MUS_PLAY)
const boolean nomusicparm = false; /* v0.2.5: music on the buzzer */
#else
const boolean nomusicparm = true;
#endif
const skill_t startskill = sk_medium;
const int startepisode = 1;
const int startmap = 1;
const boolean nodrawers = false;
static const char *timedemo = NULL; //"demo1";
/*
* D_PostEvent - Event handling
*
* Called by I/O functions when an event is received.
* Try event handlers for each code area in turn.
* cph - in the true spirit of the Boom source, let the
* short ciruit operator madness begin!
*
* next-hack: nah, the original code was very unreadable, and threw
* a warning too, as the result of the statement was not read. Better to
* get closer to 2021 standards.
*
*/
void D_PostEvent(event_t *ev)
{
/* cph - suppress all input events at game start
* FIXME: This is a lousy kludge */
if (_g->gametic < 3)
return;
// next-hack: I understand you love short-circuits, but the original code
// was too much over the line.
if (!M_Responder(ev))
{
if (!(_g->gamestate == GS_LEVEL && (C_Responder(ev) || HU_Responder(ev) || ST_Responder(ev) || AM_Responder(ev))))
{
G_Responder(ev);
}
}
}
//
// D_Wipe
//
// CPhipps - moved the screen wipe code from D_Display to here
// The screens to wipe between are already stored, this just does the timing
// and screen updating
static void D_Wipe(void)
{
short tmp_y_lookup[SCREENWIDTH]; // on the stack. We have plenty.
boolean done = false;
int wipestart = I_GetTime() - 1;
wipe_initMelt(tmp_y_lookup);
displayData.workingBuffer = 1 - displayData.workingBuffer;
do
{
int nowtime, tics;
do
{
nowtime = I_GetTime();
tics = nowtime - wipestart;
} while (!tics);
wipestart = nowtime;
done = wipe_ScreenWipe(tics, tmp_y_lookup);
// 2021-08-08 next-hack: Due to memory constraint we cannot draw the menu over. Never mind.
// M_Drawer(); // menu is drawn even on top of wipes
I_FinishUpdateBlock(); // page flip or blit buffer
// 2021-08-08 next-hack: during wipes we use the two buffers, one contains the new scene, the other contains
// the old one. As a result we cannot use double buffering, and we need to wait for DMA to finish update
while (displayData.dmaBusy)
{
}
// I_FinishUpdateBlock will swap buffers, but we don't want it.
displayData.workingBuffer = 1 - displayData.workingBuffer;
} while (!done);
}
//
// D_Display
// draw current display, possibly wiping it from the previous
//
static void D_Display(void)
{
boolean wipe;
boolean viewactive = false;
if (nodrawers) // for comparative timing / profiling
return;
if (!I_StartDisplay())
return;
// save the current screen if about to wipe
if (g_plog_loops < 4) PLOG(0x200);
#ifdef SINGLE_FB
wipe = 0; /* one framebuffer: no wipe */
#else
if ((wipe = (_g->gamestate != _g->wipegamestate)))
wipe_StartScreen();
#endif
if (g_plog_loops < 4) PLOG(0x201);
_g->screens[0].data = displayData.displayFrameBuffer[displayData.workingBuffer];
drawvars.byte_topleft = _g->screens[0].data;
draw_stopy = SCREENHEIGHT - ST_SCALED_HEIGHT - 1;
draw_starty = 0;
if (_g->gamestate != GS_LEVEL)
{ // Not a level
if (_g->oldgamestate == GS_LEVEL)
{
V_SetPalette(0); // cph - use default (basic) palette
}
switch (_g->gamestate)
{
case GS_INTERMISSION:
WI_Drawer();
break;
case GS_FINALE:
F_Drawer();
break;
case GS_DEMOSCREEN:
if (g_plog_loops < 4) PLOG(0x202); D_PageDrawer(); if (g_plog_loops < 4) PLOG(0x203);
break;
default:
break;
}
}
else if (_g->gametic != _g->basetic)
{ // In a level
HU_Erase();
// Work out if the player view is visible, and if there is a border
// TODO: BUG if viewactive is false, then automap will lock the system.
// It seems to me that R_RenderBSPNode is required before.
viewactive = (!(_g->automapmode & am_active) || (_g->automapmode & am_overlay));
// Now do the drawing
if (viewactive)
R_RenderPlayerView(&_g->player);
if ((_g->automapmode & am_active))
AM_Drawer();
HU_Drawer();
draw_stopy = SCREENHEIGHT - 1;
ST_Drawer(true, false); // status bar on, do not force refresh
}
_g->oldgamestate = _g->wipegamestate = _g->gamestate;
// draw pause pic
if (_g->paused)
{
// Simplified the "logic" here and no need for x-coord caching - POPE
V_DrawNamePatch((320 - V_NamePatchWidth("M_PAUSE"))/2, 4, 0, "M_PAUSE", CR_DEFAULT, VPT_STRETCH);
}
// menus go directly to the screen
if (g_plog_loops < 4) PLOG(0x204);
M_Drawer(); // menu is drawn even on top of everything
if (g_plog_loops < 4) PLOG(0x205);
D_BuildNewTiccmds();
// normal update
if (!wipe)
{
I_FinishUpdateBlock(); // page flip or blit buffer
}
else
{
// wipe update
wipe_EndScreen();
{ if (g_plog_loops < 4) PLOG(0x206); D_Wipe(); if (g_plog_loops < 4) PLOG(0x207); }
}
//
//I_EndDisplay(); // removed
}
//
// D_DoomLoop()
//
// Not a globally visible function,
// just included for source reference,
// called by D_DoomMain, never exits.
// Manages timing and IO,
// calls all ?_Responder, ?_Ticker, and ?_Drawer,
// calls I_GetTime, I_StartFrame, and I_StartTic
//
int divisions;
extern int lumpByNameRequest;
static void D_DoomLoop(void)
{
int oldMaxDivisions = 0;
int oldLumpByNameRequests = 0;
#if DEBUG_SETUP
// this to launch directly a new game without having to press keys...
// useful if you are in a hurry and want to test if new code is faster or slower.
bool startedGame = false;
#endif
// set default behavior of ammo widget.
_g->fps_show = SHOW_FPS;
//
restoreWirelessAudio();
//
PLOG(6);
for (;;)
{
if (g_plog_loops < 4) PLOG(0x10 + g_plog_loops * 0x10);
if (!nosfxparm)
updateSound();
// frame syncronous IO operations
divisions = 0;
lumpByNameRequest = 0;
// process one or more tics
if (_g->singletics) // this is normally not executed
{
I_StartTic();
G_BuildTiccmd(&_g->netcmd);
if (_g->advancedemo)
D_DoAdvanceDemo();
M_Ticker();
G_Ticker();
_g->gametic++;
_g->maketic++;
}
else
{
TryRunTics(); // will run at least one tic
}
if (g_plog_loops < 4) PLOG(0x11 + g_plog_loops * 0x10);
// killough 3/16/98: change consoleplayer to displayplayer
if (_g->player.mo) // cph 2002/08/10
S_UpdateSounds(_g->player.mo); // move positional sounds
// Update display, next frame, with current state.
D_Display();
if (g_plog_loops < 4) { PLOG(0x12 + g_plog_loops * 0x10); g_plog_loops++; }
#if !MINEWDONGLE
handleDisplayBacklightToggle();
#endif
#if 0
if (oldMaxDivisions < divisions)
{
oldMaxDivisions = divisions;
printf("Max div/frame %d\r\n", oldMaxDivisions);
}
if (oldLumpByNameRequests < lumpByNameRequest)
{
oldLumpByNameRequests = lumpByNameRequest;
printf("Max lumpByNameRequest per frame increased to %d\r\n", lumpByNameRequest);
}
#endif
if (_g->fps_show)
{
D_UpdateFPS();
}
#ifdef PD_AUTOSTART
{ static int pd_started; if (!pd_started) { pd_started = 1; G_DeferedInitNew(2, 1, PD_AUTOSTART); } }
#endif
#if DEBUG_SETUP
#if AUTOSTART_GAME
if (!startedGame)
{
startedGame = true;
G_DeferedInitNew(2, 1, START_MAP);
}
#endif
#endif
}
}
static void D_UpdateFPS()
{
_g->fps_frames++;
unsigned int timenow = I_GetTimeMicrosecs(); // this is running at 10MHz.
unsigned int elapsed = timenow - _g->fps_timebefore;
if (elapsed >= 1000000UL)
{
_g->fps_framerate = (int) (_g->fps_frames * 10000000 / ((float) elapsed));
_g->fps_frames = 0;
_g->fps_timebefore = timenow;
}
}
//
// DEMO LOOP
//
//
// D_PageTicker
// Handles timing for warped projection
//
void D_PageTicker(void)
{
if (--_g->pagetic < 0)
D_AdvanceDemo();
}
//
// D_PageDrawer
//
static void D_PageDrawer(void)
{
// proff/nicolas 09/14/98 -- now stretchs bitmaps to fullscreen!
// CPhipps - updated for new patch drawing
// proff - added M_DrawCredits
if (_g->pagelump)
{
V_DrawNumPatch(0, 0, 0, _g->pagelump, CR_DEFAULT, VPT_STRETCH);
}
}
//
// D_AdvanceDemo
// Called after each demo or intro demosequence finishes
//
void D_AdvanceDemo(void)
{
_g->advancedemo = true;
}
/* killough 11/98: functions to perform demo sequences
* cphipps 10/99: constness fixes
*/
static void D_SetPageName(const char *name)
{
_g->pagelump = W_GetNumForName(name);
}
static void D_DrawTitle1(const char *name)
{
S_StartMusic(mus_intro);
_g->pagetic = (TICRATE * 30);
D_SetPageName(name);
}
static void D_DrawTitle2(const char *name)
{
S_StartMusic(mus_dm2ttl);
D_SetPageName(name);
}
/* killough 11/98: tabulate demo sequences
*/
static struct
{
void (*func)(const char*);
const char *name;
}
const demostates[][4] =
{
#if 1
{
{ D_DrawTitle1, "TITLEPIC" },
{ D_DrawTitle1, "TITLEPIC" },
{ D_DrawTitle2, "TITLEPIC" },
{ D_DrawTitle1, "TITLEPIC" },
},
#else
{
{ G_DeferedPlayDemo, "demo3" },
{ G_DeferedPlayDemo, "demo3" },
{ G_DeferedPlayDemo, "demo3" },
{ G_DeferedPlayDemo, "demo3" },
},
#if 0
{
{ D_SetPageName, "TITLEPIC" },
{ D_SetPageName, "TITLEPIC" },
{ D_SetPageName, "TITLEPIC" },
{ D_SetPageName, "TITLEPIC" },
},
{
{ G_DeferedPlayDemo, "demo2" },
{ G_DeferedPlayDemo, "demo2" },
{ G_DeferedPlayDemo, "demo2" },
{ G_DeferedPlayDemo, "demo2" },
},
{
{ D_SetPageName, "TITLEPIC" },
{ D_SetPageName, "TITLEPIC" },
{ D_SetPageName, "TITLEPIC" },
{ D_SetPageName, "TITLEPIC" },
},
{
{ G_DeferedPlayDemo, "demo3" },
{ G_DeferedPlayDemo, "demo3" },
{ G_DeferedPlayDemo, "demo3" },
{ G_DeferedPlayDemo, "demo3" },
},
#endif
#endif
{
{ NULL, NULL },
{ NULL, NULL },
{ NULL, NULL },
{ NULL, NULL },
}
};
/*
* This cycles through the demo sequences.
* killough 11/98: made table-driven
*/
void D_DoAdvanceDemo(void)
{
_g->player.playerstate = PST_LIVE; /* not reborn */
_g->advancedemo = _g->usergame = _g->paused = false;
_g->gameaction = ga_nothing;
_g->pagetic = TICRATE * 11; /* killough 11/98: default behavior */
_g->gamestate = GS_DEMOSCREEN;
/* Paradise: no demos on the title screen (the WAD may not contain all maps) */
do
{
if (!demostates[++_g->demosequence][_g->gamemode].func)
_g->demosequence = 0;
} while (demostates[_g->demosequence][_g->gamemode].func == G_DeferedPlayDemo);
demostates[_g->demosequence][_g->gamemode].func(demostates[_g->demosequence][_g->gamemode].name);
}
//
// D_StartTitle
//
void D_StartTitle(void)
{
printf("Start Title\r\n");
_g->gameaction = ga_nothing;
_g->demosequence = -1;
D_AdvanceDemo();
printf("After AdvanceDemo()\r\n");
}
//
// D_AddFile
//
// Rewritten by Lee Killough
//
// Ty 08/29/98 - add source parm to indicate where this came from
// CPhipps - static, const char* parameter
// - source is an enum
// - modified to allocate & use new wadfiles array
void D_AddFile()
{
}
//
// CheckIWAD
//
// Verify a file is indeed tagged as an IWAD
// Scan its lumps for levelnames and return gamemode as indicated
// Detect missing wolf levels in DOOM II
//
// The filename to check is passed in iwadname, the gamemode detected is
// returned in gmode, hassec returns the presence of secret levels
//
// jff 4/19/98 Add routine to test IWAD for validity and determine
// the gamemode from it. Also note if DOOM II, whether secret levels exist
// CPhipps - const char* for iwadname, made static
#ifdef PDM_ONE_EPI
int pdm_one_epi; /* the only episode of the WAD (1..3), 0: several */
#endif
static void CheckIWAD2(const unsigned char *iwad_data, const unsigned int iwad_len, GameMode_t *gmode, boolean *hassec)
{
spiFlashSetAddress((uint32_t) iwad_data);
wadinfo_t header_v;
spiFlashGetData(&header_v, sizeof(header_v));
const wadinfo_t *header = &header_v; //(const wadinfo_t*)iwad_data;
int ud = 0, rg = 0, sw = 0, cm = 0, sc = 0, e2 = 0, e3 = 0;
#ifdef PDM_E4
int credit = 0, help2 = 0; /* Paramix 1.7.3 test14: Ultimate DOOM has CREDIT but no HELP2 */
#endif
if (!strncmp(header->identification, "IWAD", 4))
{
size_t length = header->numlumps;
printf("Found %d lumps\r\n", length);
filelump_t *fileinfo = Z_Malloc(length * sizeof(*fileinfo), PU_STATIC, NULL);
spiFlashSetAddress((uint32_t) &iwad_data[header->infotableofs]);
spiFlashGetData(fileinfo, length * sizeof(*fileinfo));
while (length--)
{
#ifdef PDM_E4
if (!strncmp(fileinfo[length].name, "CREDIT", 8)) credit = 1;
if (!strncmp(fileinfo[length].name, "HELP2", 8)) help2 = 1;
#endif
if (fileinfo[length].name[0] == 'E' && fileinfo[length].name[2] == 'M' && fileinfo[length].name[4] == 0)
{
if (fileinfo[length].name[1] == '4')
++ud;
else if (fileinfo[length].name[1] == '3')
{ ++rg; ++e3; }
else if (fileinfo[length].name[1] == '2')
{ ++rg; ++e2; }
else if (fileinfo[length].name[1] == '1')
++sw;
}
else if (fileinfo[length].name[0] == 'M' && fileinfo[length].name[1] == 'A' && fileinfo[length].name[2] == 'P' && fileinfo[length].name[5] == 0)
{
++cm;
if (fileinfo[length].name[3] == '3')
{
if (fileinfo[length].name[4] == '1' || fileinfo[length].name[4] == '2')
++sc;
}
}
//Final Doom IWAD check hacks ~Kippykip
//TNT - MURAL1
else if (fileinfo[length].name[0] == 'M' && fileinfo[length].name[1] == 'U' && fileinfo[length].name[2] == 'R' && fileinfo[length].name[3] == 'A' && fileinfo[length].name[4] == 'L' && fileinfo[length].name[5] == '1' && fileinfo[length].name[6] == 0)
{
cm = 32;
sc = 2;
*gmode = commercial;
_g->gamemission = pack_tnt;
_g->gamemode = commercial;
Z_Free(fileinfo);
return;
}
//Plutonia - WFALL1
else if (fileinfo[length].name[0] == 'W' && fileinfo[length].name[1] == 'F' && fileinfo[length].name[2] == 'A' && fileinfo[length].name[3] == 'L' && fileinfo[length].name[4] == 'L' && fileinfo[length].name[5] == '1' && fileinfo[length].name[6] == 0)
{
cm = 32;
sc = 2;
*gmode = commercial;
_g->gamemission = pack_plut;
_g->gamemode = commercial;
Z_Free(fileinfo);
return;
}
}
Z_Free(fileinfo);
}
else
{
I_Error("CheckIWAD: IWAD tag not present");
}
// Determine game mode from levels present
// Must be a full set for whichever mode is present
// Lack of wolf-3d levels also detected here
*gmode = indetermined;
*hassec = false;
if (cm >= 30)
{
*gmode = commercial;
*hassec = sc >= 2;
}
else if (ud >= 9)
*gmode = retail;
else if (rg >= 18)
*gmode = registered;
else if (sw >= 9)
*gmode = shareware;
#ifdef PDM_ONE_EPI
/* Paramix 1.7.3 test12: the Studio builds one episode per DOOM. E2 or E3 alone was "indetermined" (the title
* screen then called a missing entry and crashed); it is registered now, and the new game skips the episode
* menu (pdm_one_epi). */
else if (rg >= 9)
*gmode = registered;
#ifdef PDM_LUMPTXT
else if (cm > 0)
*gmode = commercial; /* 1.7.3 test17: a DOOM II map pack alone (one-humanity: MAP01 only) */
#endif
#ifdef PDM_E4
/* 1.7.3 test14: E4 (Ultimate DOOM) too. One episode from Ultimate DOOM is retail: its pages are CREDIT, not HELP2
* (the title loop and the end of E1 would ask for HELP2). */
pdm_one_epi = (sw > 0) + (e2 > 0) + (e3 > 0) + (ud > 0) == 1 ? (sw ? 1 : e2 ? 2 : e3 ? 3 : 4) : 0;
if ((*gmode == shareware || *gmode == registered) && credit && !help2)
*gmode = retail;
#else
pdm_one_epi = (sw > 0) + (e2 > 0) + (e3 > 0) == 1 ? (sw ? 1 : e2 ? 2 : 3) : 0;
#endif
#endif
}
//
// IdentifyVersion
//
// Set the location of the defaults file and the savegame root
// Locate and validate an IWAD file
// Determine gamemode from the IWAD
//
// supports IWADs with custom names. Also allows the -iwad parameter to
// specify which iwad is being searched for if several exist in one dir.
// The -iwad parm may specify:
//
// 1) a specific pathname, which must exist (.wad optional)
// 2) or a directory, which must contain a standard IWAD,
// 3) or a filename, which must be found in one of the standard places:
// a) current dir,
// b) exe dir
// c) $DOOMWADDIR
// d) or $HOME
//
// jff 4/19/98 rewritten to use a more advanced search algorithm
static void IdentifyVersion()
{
if (doom_iwad && (p_doom_iwad_len > 0))
{
uint32_t doom_iwad_len;
spiFlashSetAddress((uint32_t) p_doom_iwad_len);
spiFlashGetData(&doom_iwad_len, sizeof(doom_iwad_len));
CheckIWAD2(doom_iwad, doom_iwad_len, &_g->gamemode, &_g->haswolflevels);
/* jff 8/23/98 set gamemission global appropriately in all cases
* cphipps 12/1999 - no version output here, leave that to the caller
*/
switch (_g->gamemode)
{
case retail:
case registered:
case shareware:
_g->gamemission = doom;
break;
case commercial:
_g->gamemission = doom2;
break;
default:
_g->gamemission = none;
break;
}
if (_g->gamemode == indetermined)
{
//jff 9/3/98 use logical output routine
lprintf(LO_WARN, "Unknown Game Version, may not work\n");
}
D_AddFile();
}
}
//
// D_DoomMainSetup
//
// CPhipps - the old contents of D_DoomMain, but moved out of the main
// line of execution so its stack space can be freed
static void D_DoomMainSetup(void)
{
IdentifyVersion();
// jff 1/24/98 end of set to both working and command line value
{
// CPhipps - localise title variable
// print title for every printed line
// cph - code cleaned and made smaller
const char *doomverstr;
switch (_g->gamemode)
{
case retail:
doomverstr = "The Ultimate DOOM";
break;
case shareware:
doomverstr = "DOOM Shareware";
break;
case registered:
doomverstr = "DOOM Registered";
break;
case commercial: // Ty 08/27/98 - fixed gamemode vs gamemission
switch (_g->gamemission)
{
case pack_plut:
doomverstr = "DOOM 2: Plutonia Experiment";
break;
case pack_tnt:
doomverstr = "DOOM 2: TNT - Evilution";
break;
default:
doomverstr = "DOOM 2: Hell on Earth";
break;
}
break;
default:
doomverstr = "Public DOOM";
break;
}
/* cphipps - the main display. This shows the build date, copyright, and game type */
lprintf(LO_ALWAYS, "\r\nPrBoom (built %s)", version_date);
lprintf(LO_ALWAYS, "\r\nPlaying: %s", doomverstr);
lprintf(LO_ALWAYS, "\r\nPrBoom is released under the");
lprintf(LO_ALWAYS, "\r\nGNU GPL v2.0.");
lprintf(LO_ALWAYS, "\r\nYou are welcome to");
lprintf(LO_ALWAYS, "\r\nredistribute it under");
lprintf(LO_ALWAYS, "\r\ncertain conditions.");
lprintf(LO_ALWAYS, "\r\nIt comes with ABSOLUTELY\r\nNO WARRANTY.\r\nSee the file COPYING for\r\ndetails.");
lprintf(LO_ALWAYS, "\r\nPhew. Thats the nasty legal\r\nstuff out of the way.\r\nLet's play Doom!\n");
}
// init subsystems
G_ReloadDefaults(); // killough 3/4/98: set defaults just loaded.
// jff 3/24/98 this sets startskill if it was -1
// CPhipps - move up netgame init
//jff 9/3/98 use logical output routine
lprintf(LO_INFO, "D_InitNetGame.\r\n");
D_InitNetGame();
//jff 9/3/98 use logical output routine
lprintf(LO_INFO, "W_Init: Init WADfiles.\r\n");
W_Init(); // CPhipps - handling of wadfiles init changed
//jff 9/3/98 use logical output routine
lprintf(LO_INFO, "R_Init: DOOM refresh daemon.\r\n");
R_Init(); // here initImmutableFlashRegion() called too
//jff 9/3/98 use logical output routine
lprintf(LO_INFO, "M_Init: Init misc info.\r\n");
M_Init();
// 2021/05/19 next-hack: added WiInit to use lump nums instead of names
lprintf(LO_INFO, "Wi_Init: Init misc info.\r\n");
WI_Init();
//jff 9/3/98 use logical output routine
lprintf(LO_INFO, "P_Init: Init Playloop state.\r\n");
P_Init();
//jff 9/3/98 use logical output routine
lprintf(LO_INFO, "I_Init: Set up machine state.\r\n");
I_Init();
//jff 9/3/98 use logical output routine
lprintf(LO_INFO, "S_Init: Setting up sound.\r\n");
S_Init(_g->snd_SfxVolume /* *8 */, _g->snd_MusicVolume /* *8*/);
//jff 9/3/98 use logical output routine
lprintf(LO_INFO, "HU_Init: Setting up HUD.\r\n");
HU_Init();
//jff 9/3/98 use logical output routine
lprintf(LO_INFO, "ST_Init: Init status bar.\r\n");
ST_Init();
lprintf(LO_INFO, "G_LoadSettings: Loading settings.\r\n");
G_LoadSettings();
PLOG(1);
_g->idmusnum = -1; //jff 3/17/98 insure idmus number is blank
_g->fps_show = false;
if (timedemo)
{
_g->singletics = true;
_g->timingdemo = true; // show stats after quit
G_DeferedPlayDemo(timedemo);
_g->singledemo = true; // quit after one demo
}
else
{
D_StartTitle(); // start up intro loop
}
PLOG(2);
// finally fill the patch lump width array
patchsizeoffsets_t *patchSizeOffsets = Z_Malloc( sizeof(patchsizeoffsets_t) * _g->numlumps, PU_STATIC, NULL);
for (int i = 0; i < _g->numlumps; i++)
{
const patch_t *patch = W_CacheLumpNum(i);
spiFlashSetAddress((uint32_t) patch);
spiFlashGetData(&patchSizeOffsets[i], sizeof (patchsizeoffsets_t));
}
PLOG(3);
p_wad_immutable_flash_data->patchLumpSizeOffsets = writeBufferToFlashRegion(patchSizeOffsets, sizeof(patchsizeoffsets_t) * _g->numlumps, FLASH_IMMUTABLE_REGION, true);
Z_Free(patchSizeOffsets);
//
//
PLOG(4);
p_wad_immutable_flash_data = storeFlashImmutableValues();
PLOG(5);
}
//
// D_DoomMain
//
void D_DoomMain(void)
{
D_DoomMainSetup(); // CPhipps - setup out of main execution stack
//
delay(100); // still have not figured why after WAD upload this has to be added: probably due to nvm programming.
//
D_DoomLoop(); // never returns
}
//
// GetFirstMap
//
// Ty 08/29/98 - determine first available map from the loaded wads and run it
//
void GetFirstMap(int *ep, int *map)
{
int i, j; // used to generate map name
boolean done = false; // Ty 09/13/98 - to exit inner loops
char test[6]; // MAPxx or ExMx plus terminator for testing
char name[6]; // MAPxx or ExMx plus terminator for display
boolean newlevel = false; // Ty 10/04/98 - to test for new level
int ix; // index for lookup
strcpy(name, ""); // initialize
if (*map == 0) // unknown so go search for first changed one
{
*ep = 1;
*map = 1; // default E1M1 or MAP01
if (_g->gamemode == commercial)
{
for (i = 1; !done && i < 33; i++) // Ty 09/13/98 - add use of !done
{
sprintf(test, "MAP%02d", i);
ix = W_CheckNumForName(test);
if (ix != -1) // Ty 10/04/98 avoid -1 subscript
{
if (!*name) // found one, not pwad. First default.
strcpy(name, test);
}
}
}
else // one of the others
{
strcpy(name, "E1M1"); // Ty 10/04/98 - default for display
for (i = 1; !done && i < 5; i++) // Ty 09/13/98 - add use of !done
{
for (j = 1; !done && j < 10; j++) // Ty 09/13/98 - add use of !done
{
sprintf(test, "E%dM%d", i, j);
ix = W_CheckNumForName(test);
if (ix != -1) // Ty 10/04/98 avoid -1 subscript
{
if (!*name) // found one, not pwad. First default.
strcpy(name, test);
}
}
}
}
//jff 9/3/98 use logical output routine
lprintf(LO_CONFIRM, "Auto-warping to first %slevel: %s\n",
newlevel ? "new " : "", name); // Ty 10/04/98 - new level test
}
}
+54
View File
@@ -0,0 +1,54 @@
/**
* Doom Port to the nRF52840 by Nicola Wrachien (next-hack in the comments)
*
* This port is based on the excellent doomhack's GBA Doom Port,
* with Kippykip additions.
*
* Several data structures and functions have been optimized
* to fit in only 256kB RAM of nRF52840 (GBA has 384 kB RAM).
* Z-Depth Light has been restored with almost no RAM consumption!
* Tons of speed optimizations have been done, and the game now
* runs extremely fast, despite the much higher 3D resolution with
* respect to GBA.
*
* PrBoom: a Doom port merged with LxDoom and LSDLDoom
* based on BOOM, a modified and improved DOOM engine
* Copyright (C) 1999 by
* id Software, Chi Hoang, Lee Killough, Jim Flynn, Rand Phares, Ty Halderman
* Copyright (C) 1999-2000 by
* Jess Haas, Nicolas Kalkhof, Colin Phipps, Florian Schulze
* Copyright 2005, 2006 by
* Florian Schulze, Colin Phipps, Neil Stevens, Andrey Budko
* Copyright (C) 2021 Nicola Wrachien (next-hack in the comments)
* on nRF52840 port.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
* 02111-1307, USA.
*
* DESCRIPTION:
* wad pointers.
*
*/
#pragma GCC optimize ("-O0")
#include "w_wad.h"
#include "doom_iwad.h"
#ifdef DOOM_FREE
const unsigned char *doom_iwad; /* set at start from the settings block */
const unsigned int *p_doom_iwad_len;
#else
const unsigned char *doom_iwad = (const unsigned char*) WAD_ADDRESS;
const unsigned int *p_doom_iwad_len = (const unsigned int*) (WAD_ADDRESS - 4);
#endif
+687
View File
@@ -0,0 +1,687 @@
/* Emacs style mode select -*- C++ -*-
*-----------------------------------------------------------------------------
*
*
* PrBoom: a Doom port merged with LxDoom and LSDLDoom
* based on BOOM, a modified and improved DOOM engine
* Copyright (C) 1999 by
* id Software, Chi Hoang, Lee Killough, Jim Flynn, Rand Phares, Ty Halderman
* Copyright (C) 1999-2000 by
* Jess Haas, Nicolas Kalkhof, Colin Phipps, Florian Schulze
* Copyright 2005, 2006 by
* Florian Schulze, Colin Phipps, Neil Stevens, Andrey Budko
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
* 02111-1307, USA.
*
* DESCRIPTION:
* Game completion, final screen animation.
*
*-----------------------------------------------------------------------------
*/
#include "doomstat.h"
#include "d_event.h"
#include "v_video.h"
#include "w_wad.h"
#include "s_sound.h"
#include "sounds.h"
#include "f_finale.h" // CPhipps - hmm...
#include "dstrings.h"
#include "global_data.h"
// defines for the end mission display text // phares
#define TEXTSPEED 3 // original value // phares
#define TEXTWAIT 250 // original value // phares
#define NEWTEXTSPEED 0.01f // new value // phares
#define NEWTEXTWAIT 1000 // new value // phares
// CPhipps - removed the old finale screen text message strings;
// they were commented out for ages already
// Ty 03/22/98 - ... the new s_WHATEVER extern variables are used
// in the code below instead.
void F_StartCast(void);
void F_CastTicker(void);
boolean F_CastResponder(event_t *ev);
void F_CastDrawer(void);
void WI_checkForAccelerate(void); // killough 3/28/98: used to
//
// F_StartFinale
//
void F_StartFinale(void)
{
_g->gameaction = ga_nothing;
_g->gamestate = GS_FINALE;
_g->automapmode &= ~am_active;
// killough 3/28/98: clear accelerative text flags
_g->acceleratestage = _g->midstage = 0;
// Okay - IWAD dependend stuff.
// This has been changed severly, and
// some stuff might have changed in the process.
switch (_g->gamemode)
{
// DOOM 1 - E1, E3 or E4, but each nine missions
case shareware:
case registered:
case retail:
{
S_ChangeMusic(mus_victor, true);
switch (_g->gameepisode)
{
case 1:
_g->finaleflat = "FLOOR4_8";
_g->finaletext = E1TEXT;
break;
case 2:
_g->finaleflat = "SFLR6_1";
_g->finaletext = E2TEXT;
break;
case 3:
_g->finaleflat = "MFLR8_4";
_g->finaletext = E3TEXT;
break;
case 4:
_g->finaleflat = "MFLR8_3";
_g->finaletext = E4TEXT;
#ifdef PDM_LUMPTXT
/* 1.7.3 test17: the text of an episode in the place of E4 (Sigil), written by the Studio with a 0 */
{ int l = W_CheckNumForName("PDMTXT4"); if (l >= 0) _g->finaletext = (const char*) W_CacheLumpNum(l); }
#endif
break;
default:
// Ouch.
break;
}
break;
}
// DOOM II and missions packs with E1, M34
case commercial:
{
S_ChangeMusic(mus_read_m, true);
// Ty 08/27/98 - added the gamemission logic
switch (_g->gamemap)
{
case 6:
_g->finaleflat = "SLIME16";
_g->finaletext =
(_g->gamemission == pack_tnt) ? T1TEXT :
(_g->gamemission == pack_plut) ? P1TEXT : C1TEXT;
break;
case 11:
_g->finaleflat = "RROCK14";
_g->finaletext =
(_g->gamemission == pack_tnt) ? T2TEXT :
(_g->gamemission == pack_plut) ? P2TEXT : C2TEXT;
break;
case 20:
_g->finaleflat = "RROCK07";
_g->finaletext =
(_g->gamemission == pack_tnt) ? T3TEXT :
(_g->gamemission == pack_plut) ? P3TEXT : C3TEXT;
break;
case 30:
_g->finaleflat = "RROCK17";
_g->finaletext =
(_g->gamemission == pack_tnt) ? T4TEXT :
(_g->gamemission == pack_plut) ? P4TEXT : C4TEXT;
break;
case 15:
_g->finaleflat = "RROCK13";
_g->finaletext =
(_g->gamemission == pack_tnt) ? T5TEXT :
(_g->gamemission == pack_plut) ? P5TEXT : C5TEXT;
break;
case 31:
_g->finaleflat = "RROCK19";
_g->finaletext =
(_g->gamemission == pack_tnt) ? T6TEXT :
(_g->gamemission == pack_plut) ? P6TEXT : C6TEXT;
break;
default:
// Ouch.
break;
}
break;
// Ty 08/27/98 - end gamemission logic
}
// Indeterminate.
default: // Ty 03/30/98 - not externalized
S_ChangeMusic(mus_read_m, true);
_g->finaleflat = "F_SKY1"; // Not used anywhere else.
_g->finaletext = C1TEXT; // FIXME - other text, music?
break;
}
_g->finalestage = 0;
_g->finalecount = 0;
}
boolean F_Responder(event_t *event)
{
if (_g->finalestage == 2)
return F_CastResponder(event);
return false;
}
// Get_TextSpeed() returns the value of the text display speed // phares
// Rewritten to allow user-directed acceleration -- killough 3/28/98
static float Get_TextSpeed(void)
{
return _g->midstage ? NEWTEXTSPEED :
((_g->midstage = _g->acceleratestage)) ? _g->acceleratestage = 0, NEWTEXTSPEED : TEXTSPEED;
}
//
// F_Ticker
//
// killough 3/28/98: almost totally rewritten, to use
// player-directed acceleration instead of constant delays.
// Now the player can accelerate the text display by using
// the fire/use keys while it is being printed. The delay
// automatically responds to the user, and gives enough
// time to read.
//
// killough 5/10/98: add back v1.9 demo compatibility
//
void F_Ticker(void)
{
WI_checkForAccelerate(); // killough 3/28/98: check for acceleration
// advance animation
_g->finalecount++;
if (_g->finalestage == 2)
F_CastTicker();
if (!_g->finalestage)
{
float speed = Get_TextSpeed();
/* killough 2/28/98: changed to allow acceleration */
if (_g->finalecount > strlen(_g->finaletext) * speed + (
_g->midstage ? NEWTEXTWAIT : TEXTWAIT) || (_g->midstage && _g->acceleratestage))
{
if (_g->gamemode != commercial) // Doom 1 / Ultimate Doom episode end
{ // with enough time, it's automatic
_g->finalecount = 0;
_g->finalestage = 1;
_g->wipegamestate = -1; // force a wipe
if (_g->gameepisode == 3)
S_StartMusic(mus_bunny);
}
else // you must press a button to continue in Doom 2
if (_g->midstage)
{
if (_g->gamemap == 30)
F_StartCast(); // cast of Doom 2 characters
else
_g->gameaction = ga_worlddone; // next level, e.g. MAP07
}
}
}
}
//
// F_TextWrite
//
// This program displays the background and text at end-mission // phares
// text time. It draws both repeatedly so that other displays, // |
// like the main menu, can be drawn over it dynamically and // V
// erased dynamically. The TEXTSPEED constant is changed into
// the Get_TextSpeed function so that the speed of writing the // ^
// text can be increased, and there's still time to read what's // |
// written. // phares
// CPhipps - reformatted
#include "hu_stuff.h"
static void F_TextWrite(void)
{
V_DrawBackground(_g->finaleflat);
{ // draw some of the text onto the screen
int cx = 10;
int cy = 10;
const char *ch = _g->finaletext; // CPhipps - const
int count = (int) ((float) (_g->finalecount - 10) / Get_TextSpeed()); // phares
int w;
if (count < 0)
count = 0;
for (; count; count--)
{
int c = *ch++;
if (!c)
break;
if (c == '\n')
{
cx = 10;
cy += 11;
continue;
}
c = toupper(c) - HU_FONTSTART;
if (c < 0 || c > HU_FONTSIZE)
{
cx += 4;
continue;
}
w = hu_font[c]->width;
// CPhipps - patch drawing updated
V_DrawPatchNoScale(cx, cy, hu_font[c]);
cx += w;
}
}
}
//
// Final DOOM 2 animation
// Casting by id Software.
// in order of appearance
//
typedef struct
{
const char *name; // CPhipps - const**
mobjtype_t type;
} castinfo_t;
#define MAX_CASTORDER 18 /* Ty - hard coded for now */
static const castinfo_t castorder[] =
{ // CPhipps - static const, initialised here
{ CC_ZOMBIE, MT_POSSESSED },
{ CC_SHOTGUN, MT_SHOTGUY },
{ CC_HEAVY, MT_CHAINGUY },
{ CC_IMP, MT_TROOP },
{ CC_DEMON, MT_SERGEANT },
{ CC_LOST, MT_SKULL },
{ CC_CACO, MT_HEAD },
{ CC_HELL, MT_KNIGHT },
{ CC_BARON, MT_BRUISER },
{ CC_ARACH, MT_BABY },
{ CC_PAIN, MT_PAIN },
{ CC_REVEN, MT_UNDEAD },
{ CC_MANCU, MT_FATSO },
{ CC_ARCH, MT_VILE },
{ CC_SPIDER, MT_SPIDER },
{ CC_CYBER, MT_CYBORG },
{ CC_HERO, MT_PLAYER },
{ NULL, 0 }
};
//
// F_StartCast
//
void F_StartCast(void)
{
_g->wipegamestate = -1; // force a screen wipe
_g->castnum = 0;
_g->caststate = &states[mobjinfo[castorder[_g->castnum].type].seestate];
_g->casttics = _g->caststate->tics;
_g->castdeath = false;
_g->finalestage = 2;
_g->castframes = 0;
_g->castonmelee = 0;
_g->castattacking = false;
S_ChangeMusic(mus_evil, true);
}
//
// F_CastTicker
//
void F_CastTicker(void)
{
int st;
int sfx;
if (--_g->casttics > 0)
return; // not time to change state yet
if (_g->caststate->tics == -1 || _g->caststate->nextstate == S_NULL)
{
// switch from deathstate to next monster
_g->castnum++;
_g->castdeath = false;
if (castorder[_g->castnum].name == NULL)
_g->castnum = 0;
if (mobjinfo[castorder[_g->castnum].type].seesound)
S_StartSound(NULL, mobjinfo[castorder[_g->castnum].type].seesound);
_g->caststate = &states[mobjinfo[castorder[_g->castnum].type].seestate];
_g->castframes = 0;
}
else
{
// just advance to next state in animation
if (_g->caststate == &states[S_PLAY_ATK1])
goto stopattack;
// Oh, gross hack!
st = _g->caststate->nextstate;
_g->caststate = &states[st];
_g->castframes++;
// sound hacks....
switch (st)
{
case S_PLAY_ATK1:
sfx = sfx_dshtgn;
break;
case S_POSS_ATK2:
sfx = sfx_pistol;
break;
case S_SPOS_ATK2:
sfx = sfx_shotgn;
break;
case S_VILE_ATK2:
sfx = sfx_vilatk;
break;
case S_SKEL_FIST2:
sfx = sfx_skeswg;
break;
case S_SKEL_FIST4:
sfx = sfx_skepch;
break;
case S_SKEL_MISS2:
sfx = sfx_skeatk;
break;
case S_FATT_ATK8:
case S_FATT_ATK5:
case S_FATT_ATK2:
sfx = sfx_firsht;
break;
case S_CPOS_ATK2:
case S_CPOS_ATK3:
case S_CPOS_ATK4:
sfx = sfx_shotgn;
break;
case S_TROO_ATK3:
sfx = sfx_claw;
break;
case S_SARG_ATK2:
sfx = sfx_sgtatk;
break;
case S_BOSS_ATK2:
case S_BOS2_ATK2:
case S_HEAD_ATK2:
sfx = sfx_firsht;
break;
case S_SKULL_ATK2:
sfx = sfx_sklatk;
break;
case S_SPID_ATK2:
case S_SPID_ATK3:
sfx = sfx_shotgn;
break;
case S_BSPI_ATK2:
sfx = sfx_plasma;
break;
case S_CYBER_ATK2:
case S_CYBER_ATK4:
case S_CYBER_ATK6:
sfx = sfx_rlaunc;
break;
case S_PAIN_ATK3:
sfx = sfx_sklatk;
break;
default:
sfx = 0;
break;
}
if (sfx)
S_StartSound(NULL, sfx);
}
if (_g->castframes == 12)
{
// go into attack frame
_g->castattacking = true;
if (_g->castonmelee)
_g->caststate = &states[mobjinfo[castorder[_g->castnum].type].meleestate];
else
_g->caststate = &states[mobjinfo[castorder[_g->castnum].type].missilestate];
_g->castonmelee ^= 1;
if (_g->caststate == &states[S_NULL])
{
if (_g->castonmelee)
_g->caststate = &states[mobjinfo[castorder[_g->castnum].type].meleestate];
else
_g->caststate = &states[mobjinfo[castorder[_g->castnum].type].missilestate];
}
}
if (_g->castattacking)
{
if (_g->castframes == 24 || _g->caststate == &states[mobjinfo[castorder[_g->castnum].type].seestate])
{
stopattack: _g->castattacking = false;
_g->castframes = 0;
_g->caststate = &states[mobjinfo[castorder[_g->castnum].type].seestate];
}
}
_g->casttics = _g->caststate->tics;
if (_g->casttics == -1)
_g->casttics = 15;
}
//
// F_CastResponder
//
boolean F_CastResponder(event_t *ev)
{
if (ev->type != ev_keydown)
return false;
if (_g->castdeath)
return true; // already in dying frames
// go into death frame
_g->castdeath = true;
_g->caststate = &states[mobjinfo[castorder[_g->castnum].type].deathstate];
_g->casttics = _g->caststate->tics;
_g->castframes = 0;
_g->castattacking = false;
if (mobjinfo[castorder[_g->castnum].type].deathsound)
S_StartSound(NULL, mobjinfo[castorder[_g->castnum].type].deathsound);
return true;
}
static void F_CastPrint(const char *text) // CPhipps - static, const char*
{
const char *ch; // CPhipps - const
int c;
int cx;
int w;
int width;
// find width
ch = text;
width = 0;
while (ch)
{
c = *ch++;
if (!c)
break;
c = toupper(c) - HU_FONTSTART;
if (c < 0 || c > HU_FONTSIZE)
{
width += 4;
continue;
}
w = hu_font[c]->width;
width += w;
}
// draw it
cx = SCREENWIDTH / 2 - width / 2;
ch = text;
while (ch)
{
c = *ch++;
if (!c)
break;
c = toupper(c) - HU_FONTSTART;
if (c < 0 || c > HU_FONTSIZE)
{
cx += 4;
continue;
}
w = hu_font[c]->width;
// CPhipps - patch drawing updated
V_DrawPatchNoScale(cx, 144, hu_font[c]);
cx += w;
}
}
//
// F_CastDrawer
//
void F_CastDrawer(void)
{
spritedef_t *sprdef;
spriteframe_t *sprframe;
int lump;
boolean flip;
// erase the entire screen to a background
// CPhipps - patch drawing updated
V_DrawNamePatch(0, 0, 0, "BOSSBACK", CR_DEFAULT, VPT_STRETCH); // Ty 03/30/98 bg texture extern
F_CastPrint((castorder[_g->castnum].name));
// draw the current frame in the middle of the screen
sprdef = &p_wad_immutable_flash_data->sprites[_g->caststate->sprite];
sprframe = &(getSpriteFrames(sprdef)[_g->caststate->frame & FF_FRAMEMASK]);
lump = sprframe->lump[0];
flip = (boolean) SPR_FLIPPED(sprframe, 0);
// CPhipps - patch drawing updated
V_DrawNumPatch(160, 170, 0, lump + _g->firstspritelump, CR_DEFAULT, VPT_STRETCH | (
flip ? VPT_FLIP : 0));
}
//
// F_BunnyScroll
//
static const char pfub2[] =
{ "PFUB2" };
static const char pfub1[] =
{ "PFUB1" };
static void F_BunnyScroll(void)
{
char name[10];
int stage;
{
int scrolled = 320 - (_g->finalecount - 230) / 2;
if (scrolled <= 0)
{
V_DrawNamePatch(0, 0, 0, pfub2, CR_DEFAULT, VPT_STRETCH);
}
else if (scrolled >= 320)
{
V_DrawNamePatch(0, 0, 0, pfub1, CR_DEFAULT, VPT_STRETCH);
}
else
{
V_DrawNamePatch(320 - scrolled, 0, 0, pfub1, CR_DEFAULT, VPT_STRETCH);
V_DrawNamePatch(-scrolled, 0, 0, pfub2, CR_DEFAULT, VPT_STRETCH);
}
}
if (_g->finalecount < 1130)
return;
if (_g->finalecount < 1180)
{
// CPhipps - patch drawing updated
V_DrawNamePatch((320 - 13 * 8) / 2, (200 - 8 * 8) / 2, 0, "END0", CR_DEFAULT, VPT_STRETCH);
_g->laststage = 0;
return;
}
stage = (_g->finalecount - 1180) / 5;
if (stage > 6)
stage = 6;
if (stage > _g->laststage)
{
S_StartSound(NULL, sfx_pistol);
_g->laststage = stage;
}
sprintf(name, "END%i", stage);
// CPhipps - patch drawing updated
V_DrawNamePatch((320 - 13 * 8) / 2, (200 - 8 * 8) / 2, 0, name, CR_DEFAULT, VPT_STRETCH);
}
//
// F_Drawer
//
void F_Drawer(void)
{
if (_g->finalestage == 2)
{
F_CastDrawer();
return;
}
if (!_g->finalestage)
F_TextWrite();
else
{
switch (_g->gameepisode)
{
// CPhipps - patch drawing updated
case 1:
if (_g->gamemode == retail)
V_DrawNamePatch(0, 0, 0, "CREDIT", CR_DEFAULT, VPT_STRETCH);
else
V_DrawNamePatch(0, 0, 0, "HELP2", CR_DEFAULT, VPT_STRETCH);
break;
case 2:
V_DrawNamePatch(0, 0, 0, "VICTORY2", CR_DEFAULT, VPT_STRETCH);
break;
case 3:
F_BunnyScroll();
break;
case 4:
V_DrawNamePatch(0, 0, 0, "ENDPIC", CR_DEFAULT, VPT_STRETCH);
break;
}
}
}
+159
View File
@@ -0,0 +1,159 @@
/**
* Doom Port to the nRF52840 by Nicola Wrachien (next-hack in the comments)
*
* This port is based on the excellent doomhack's GBA Doom Port,
* with Kippykip additions.
*
* Several data structures and functions have been optimized
* to fit in only 256kB RAM of nRF52840 (GBA has 384 kB RAM).
* Z-Depth Light has been restored with almost no RAM consumption!
* Tons of speed optimizations have been done, and the game now
* runs extremely fast, despite the much higher 3D resolution with
* respect to GBA.
*
* PrBoom: a Doom port merged with LxDoom and LSDLDoom
* based on BOOM, a modified and improved DOOM engine
* Copyright (C) 1999 by
* id Software, Chi Hoang, Lee Killough, Jim Flynn, Rand Phares, Ty Halderman
* Copyright (C) 1999-2000 by
* Jess Haas, Nicolas Kalkhof, Colin Phipps, Florian Schulze
* Copyright 2005, 2006 by
* Florian Schulze, Colin Phipps, Neil Stevens, Andrey Budko
* Copyright (C) 2021 Nicola Wrachien (next-hack in the comments)
* on nRF52840 port.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
* 02111-1307, USA.
*
* DESCRIPTION:
* Mission begin melt/wipe screen special effect.
* next-hack: the GBA doom port removed the screen melt effect, so the
* wipe has been reduced now to a stub function.
* I will probably remove all the functions and variables too sooner or later.
*
*-----------------------------------------------------------------------------
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include "doomdef.h"
#include "f_wipe.h"
#include "global_data.h"
#include "graphics.h"
#include "i_video.h"
#include "m_random.h"
#include "v_video.h"
#include "z_zone.h"
//
// SCREEN WIPE PACKAGE
//
int wipe_StartScreen(void)
{
_g->wipe_tick = 0;
return 0;
}
int wipe_EndScreen(void)
{
_g->wipe_tick = 0;
return 0;
}
// oh man, why aren't you commenting anything ?
// 2021-08-08 next-hack: commented and modified to use the dual buffer.
static int wipe_doMelt(int ticks, short *y_lookup)
{
boolean done = true;
int i;
while (ticks--)
{
for (i = 0; i < (SCREENWIDTH); i++)
{
if (y_lookup[i] < 0)
{
y_lookup[i]++;
done = false;
continue;
}
// scroll down columns, which are still visible
if (y_lookup[i] < SCREENHEIGHT)
{
byte *s, *d;
int j, k, dy;
/* cph 2001/07/29 -
* The original melt rate was 8 pixels/sec, i.e. 25 frames to melt
* the whole screen, so make the melt rate depend on SCREENHEIGHT
* so it takes no longer in high res
*/
dy = (y_lookup[i] < 16) ? y_lookup[i] + 1 : SCREENHEIGHT / 25;
// At most dy shall be so that the column is shifted by SCREENHEIGHT (i.e. just
// invisible)
if (y_lookup[i] + dy >= SCREENHEIGHT)
dy = SCREENHEIGHT - y_lookup[i];
s = &displayData.displayFrameBuffer[displayData.workingBuffer][i] +
((SCREENHEIGHT - dy - 1) * SCREENPITCH);
d = &displayData.displayFrameBuffer[displayData.workingBuffer][i] +
((SCREENHEIGHT - 1) * SCREENPITCH);
// scroll down the column. Of course we need to copy from the bottom... up to
// SCREENHEIGHT - yLookup - dy
for (j = SCREENHEIGHT - y_lookup[i] - dy; j; j--)
{
*d = *s;
d += -SCREENPITCH;
s += -SCREENPITCH;
}
// copy new screen. We need to copy only between y_lookup and + dy y_lookup
s = &displayData.displayFrameBuffer[1 - displayData.workingBuffer][i] + y_lookup[i] * SCREENPITCH;
d = &displayData.displayFrameBuffer[displayData.workingBuffer][i] + y_lookup[i] * SCREENPITCH;
for (j = 0 ; j < dy; j++)
{
*d = *s;
d += SCREENPITCH;
s += SCREENPITCH;
}
y_lookup[i] += dy;
done = false;
}
}
}
return done;
}
void wipe_initMelt(short *y_lookup)
{
// setup initial column positions (y<0 => not ready to scroll yet)
y_lookup[0] = -(M_Random() % 16);
for (int i = 1; i < SCREENWIDTH; i++)
{
int r = (M_Random() % 3) - 1;
y_lookup[i] = y_lookup[i - 1] + r;
if (y_lookup[i] > 0)
y_lookup[i] = 0;
else if (y_lookup[i] == -16)
y_lookup[i] = -15;
}
}
int wipe_ScreenWipe(int ticks, short *y_lookup)
{
// do a piece of wipe-in
return wipe_doMelt(ticks, y_lookup);
}
File diff suppressed because it is too large. Load diff
+122
View File
@@ -0,0 +1,122 @@
/**
* Doom Port to the nRF52840 by Nicola Wrachien (next-hack in the comments)
*
* This port is based on the excellent doomhack's GBA Doom Port,
* with Kippykip additions.
*
* Several data structures and functions have been optimized
* to fit in only 256kB RAM of nRF52840 (GBA has 384 kB RAM).
* Z-Depth Light has been restored with almost no RAM consumption!
* Tons of speed optimizations have been done, and the game now
* runs extremely fast, despite the much higher 3D resolution with
* respect to GBA.
*
* PrBoom: a Doom port merged with LxDoom and LSDLDoom
* based on BOOM, a modified and improved DOOM engine
* Copyright (C) 1999 by
* id Software, Chi Hoang, Lee Killough, Jim Flynn, Rand Phares, Ty Halderman
* Copyright (C) 1999-2000 by
* Jess Haas, Nicolas Kalkhof, Colin Phipps, Florian Schulze
* Copyright 2005, 2006 by
* Florian Schulze, Colin Phipps, Neil Stevens, Andrey Budko
* Copyright (C) 2021 Nicola Wrachien (next-hack in the comments)
* on nRF52840 port.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
* 02111-1307, USA.
*
* DESCRIPTION:
* next-hack: originally doomhack, in his GBA port, put (almost) all the global
* variables in a global structure, which was by the way Z_malloc'ed.
* Here the structure is not z_malloc'ed but it is static.
*
*-----------------------------------------------------------------------------
*/
#include <stdlib.h>
#include "global_data.h"
globals_t global;
globals_t *_g;
void InitGlobals()
{
_g = &global;
memset(_g, 0, sizeof(globals_t));
//******************************************************************************
//am_map.c
//******************************************************************************
_g->scale_mtof = (fixed_t) INITSCALEMTOF;
_g->stopped = true;
_g->lastlevel = -1;
_g->lastepisode = -1;
_g->mtof_zoommul = FRACUNIT; // how far the window zooms each tic (map coords)
_g->ftom_zoommul = FRACUNIT; // how far the window zooms each tic (fb coords)
//******************************************************************************
//d_main.c
//******************************************************************************
_g->wipegamestate = GS_DEMOSCREEN;
_g->oldgamestate = -1;
//******************************************************************************
//doomstat.c
//******************************************************************************
// Game Mode - identify IWAD as shareware, retail etc.
_g->gamemode = indetermined;
_g->gamemission = doom;
//******************************************************************************
//m_menu.c
//******************************************************************************
_g->showMessages = 1; // Show messages has default, 0 = off, 1 = on
//******************************************************************************
//p_setup.c
//******************************************************************************
// _g->rejectlump = -1;// cph - store reject lump num if cached
//******************************************************************************
//r_main.c
//******************************************************************************
_g->validcount = 1; // increment every time a check is made
_g->freehead = &_g->freetail; // killough
//******************************************************************************
//s_sounds.c
//******************************************************************************
_g->snd_SfxVolume = 15;
// Maximum volume of music. Useless so far.
_g->snd_MusicVolume = 15;
//******************************************************************************
//st_stuff.c
//******************************************************************************
_g->st_oldhealth = -1;
//
_g->tex_lookup_valid = false;
}
+312
View File
@@ -0,0 +1,312 @@
/**
* Doom Port to the nRF52840 by Nicola Wrachien (next-hack in the comments)
*
* This port is based on the excellent doomhack's GBA Doom Port,
* with Kippykip additions.
*
* Several data structures and functions have been optimized
* to fit in only 256kB RAM of nRF52840 (GBA has 384 kB RAM).
* Z-Depth Light has been restored with almost no RAM consumption!
* Tons of speed optimizations have been done, and the game now
* runs extremely fast, despite the much higher 3D resolution with
* respect to GBA.
*
* PrBoom: a Doom port merged with LxDoom and LSDLDoom
* based on BOOM, a modified and improved DOOM engine
* Copyright (C) 1999 by
* id Software, Chi Hoang, Lee Killough, Jim Flynn, Rand Phares, Ty Halderman
* Copyright (C) 1999-2000 by
* Jess Haas, Nicolas Kalkhof, Colin Phipps, Florian Schulze
* Copyright 2005, 2006 by
* Florian Schulze, Colin Phipps, Neil Stevens, Andrey Budko
* Copyright (C) 2021 Nicola Wrachien (next-hack in the comments)
* on nRF52840 port.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
* 02111-1307, USA.
*
* DESCRIPTION: heads-up text and input code
*
*-----------------------------------------------------------------------------
*/
#include "doomdef.h"
#include "doomstat.h"
#include "v_video.h"
#include "m_swap.h"
#include "hu_lib.h"
#include "hu_stuff.h"
#include "r_main.h"
#include "r_draw.h"
#include "global_data.h"
////////////////////////////////////////////////////////
//
// Basic text line widget
//
////////////////////////////////////////////////////////
//
// HUlib_clearTextLine()
//
// Blank the internal text line in a hu_textline_t widget
//
// Passed a hu_textline_t, returns nothing
//
void HUlib_clearTextLine(hu_textline_t *t)
{
t->linelen = // killough 1/23 98: support multiple lines
t->len = 0;
t->l[0] = 0;
t->needsupdate = true;
}
//
// HUlib_initTextLine()
//
// Initialize a hu_textline_t widget. Set the position, font, start char
// of the font, and color range to be used.
//
// Passed a hu_textline_t, and the values used to initialize
// Returns nothing
//
void HUlib_initTextLine(hu_textline_t *t, short x, short y, const patch_t *f, short sc)
//jff 2/16/98 add color range parameter
{
t->x = x;
t->y = y;
t->f = (const patch_t**) f;
t->sc = sc;
HUlib_clearTextLine(t);
}
//
// HUlib_addCharToTextLine()
//
// Adds a character at the end of the text line in a hu_textline_t widget
//
// Passed the hu_textline_t and the char to add
// Returns false if already at length limit, true if the character added
//
boolean HUlib_addCharToTextLine(hu_textline_t *t, char ch)
{
// killough 1/23/98 -- support multiple lines
if (t->linelen == HU_MAXLINELENGTH)
return false;
else
{
t->linelen++;
if (ch == '\n')
t->linelen = 0;
t->l[t->len++] = ch;
t->l[t->len] = 0;
t->needsupdate = 4;
return true;
}
}
//
// HUlib_drawTextLine()
//
// Draws a hu_textline_t widget
//
// Passed the hu_textline_t and flag whether to draw a cursor
// Returns nothing
//
void HUlib_drawTextLine(hu_textline_t *l, boolean drawcursor)
{
int i;
int w;
int x;
unsigned char c;
int y = l->y; // killough 1/18/98 -- support multiple lines
// draw the new stuff
x = l->x;
for (i = 0; i < l->len; i++)
{
c = toupper(l->l[i]); //jff insure were not getting a cheap toupper conv.
if (c == '\n') // killough 1/18/98 -- support multiple lines
x = 0, y += 8;
else if (c == '\t') // killough 1/23/98 -- support tab stops
x = x - x % 80 + 80;
else if (c != ' ' && c >= l->sc && c <= '_')
{
w = l->f[c - l->sc]->width;
if (x + w > SCREENWIDTH_PHYSICAL)
break;
// killough 1/18/98 -- support multiple lines:
// CPhipps - patch drawing updated
V_DrawPatchNoScale(x, y, l->f[c - l->sc]);
x += w;
}
else
{
x += 4;
if (x >= SCREENWIDTH_PHYSICAL)
break;
}
}
// draw the cursor if requested
if (drawcursor && x + l->f['_' - l->sc]->width <= BASE_WIDTH)
{
// killough 1/18/98 -- support multiple lines
// CPhipps - patch drawing updated
V_DrawPatch(x, y, HU_FG, l->f['_' - l->sc]);
}
}
//
// HUlib_eraseTextLine()
//
// Erases a hu_textline_t widget when screen border is behind text
// Sorta called by HU_Erase and just better darn get things straight
//
// Passed the hu_textline_t
// Returns nothing
//
void HUlib_eraseTextLine(hu_textline_t *l)
{
if (l->needsupdate)
l->needsupdate--;
}
////////////////////////////////////////////////////////
//
// Player message widget (up to 4 lines of text)
//
////////////////////////////////////////////////////////
//
// HUlib_initSText()
//
// Initialize a hu_stext_t widget. Set the position, number of lines, font,
// start char of the font, and color range to be used, and whether enabled.
//
// Passed a hu_stext_t, and the values used to initialize
// Returns nothing
//
void HUlib_initSText(hu_stext_t *s, short x, short y, short h, const patch_t *font, short startchar, boolean *on)
{
int i;
s->h = h;
s->on = on;
s->laston = true;
s->cl = 0;
for (i = 0; i < h; i++)
HUlib_initTextLine(&s->l[i], x, y - i * (font[0].height + 1), font, startchar);
}
//
// HUlib_addLineToSText()
//
// Adds a blank line to a hu_stext_t widget
//
// Passed a hu_stext_t
// Returns nothing
//
static void HUlib_addLineToSText(hu_stext_t *s)
{
int i;
// add a clear line
if (++s->cl == s->h)
s->cl = 0;
HUlib_clearTextLine(&s->l[s->cl]);
// everything needs updating
for (i = 0; i < s->h; i++)
s->l[i].needsupdate = 4;
}
//
// HUlib_addMessageToSText()
//
// Adds a message line with prefix to a hu_stext_t widget
//
// Passed a hu_stext_t, the prefix string, and a message string
// Returns nothing
//
void HUlib_addMessageToSText(hu_stext_t *s, const char *prefix, const char *msg)
{
HUlib_addLineToSText(s);
if (prefix)
while (*prefix)
HUlib_addCharToTextLine(&s->l[s->cl], *(prefix++));
while (*msg)
HUlib_addCharToTextLine(&s->l[s->cl], *(msg++));
}
//
// HUlib_drawSText()
//
// Displays a hu_stext_t widget
//
// Passed a hu_stext_t
// Returns nothing
//
void HUlib_drawSText(hu_stext_t *s)
{
int i, idx;
hu_textline_t *l;
if (!*s->on)
return; // if not on, don't draw
// draw everything
for (i = 0; i < s->h; i++)
{
idx = s->cl - i;
if (idx < 0)
idx += s->h; // handle queue of lines
l = &s->l[idx];
// need a decision made here on whether to skip the draw
HUlib_drawTextLine(l, false); // no cursor, please
}
}
//
// HUlib_eraseSText()
//
// Erases a hu_stext_t widget, when the screen is not fullsize
//
// Passed a hu_stext_t
// Returns nothing
//
void HUlib_eraseSText(hu_stext_t *s)
{
int i;
for (i = 0; i < s->h; i++)
{
if (s->laston && !*s->on)
s->l[i].needsupdate = 4;
HUlib_eraseTextLine(&s->l[i]);
}
s->laston = *s->on;
}
+535
View File
@@ -0,0 +1,535 @@
/**
* Doom Port to the nRF52840 by Nicola Wrachien (next-hack in the comments)
*
* This port is based on the excellent doomhack's GBA Doom Port,
* with Kippykip additions.
*
* Several data structures and functions have been optimized
* to fit in only 256kB RAM of nRF52840 (GBA has 384 kB RAM).
* Z-Depth Light has been restored with almost no RAM consumption!
* Tons of speed optimizations have been done, and the game now
* runs extremely fast, despite the much higher 3D resolution with
* respect to GBA.
*
* PrBoom: a Doom port merged with LxDoom and LSDLDoom
* based on BOOM, a modified and improved DOOM engine
* Copyright (C) 1999 by
* id Software, Chi Hoang, Lee Killough, Jim Flynn, Rand Phares, Ty Halderman
* Copyright (C) 1999-2000 by
* Jess Haas, Nicolas Kalkhof, Colin Phipps, Florian Schulze
* Copyright 2005, 2006 by
* Florian Schulze, Colin Phipps, Neil Stevens, Andrey Budko
* Copyright (C) 2021 Nicola Wrachien (next-hack in the comments)
* on nRF52840 port.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
* 02111-1307, USA.
*
* DESCRIPTION: Heads-up displays
*
*-----------------------------------------------------------------------------
*/
// killough 5/3/98: remove unnecessary headers
#include "doomstat.h"
#include "hu_stuff.h"
#include "hu_lib.h"
#include "st_stuff.h" /* jff 2/16/98 need loc of status bar */
#include "w_wad.h"
#include "s_sound.h"
#include "dstrings.h"
#include "sounds.h"
#include "g_game.h"
#include "r_main.h"
#include "global_data.h"
// global heads up display controls
//
// Locally used constants, shortcuts.
//
// Ty 03/28/98 -
// These four shortcuts modifed to reflect char ** of mapnamesx[]
#define HU_TITLE (mapnames[(_g->gameepisode-1)*9+_g->gamemap-1])
#define HU_TITLE2 (mapnames2[_g->gamemap-1])
#define HU_TITLEP (mapnamesp[_g->gamemap-1])
#define HU_TITLET (mapnamest[_g->gamemap-1])
#define HU_TITLEHEIGHT 1
#define HU_TITLEX 0
//jff 2/16/98 change 167 to ST_Y-1
// CPhipps - changed to ST_TY
// proff - changed to 200-ST_HEIGHT for stretching
#define HU_TITLEY ((SCREENHEIGHT-ST_SCALED_HEIGHT) - 1 - hu_font[0]->height)
//jff 2/16/98 add coord text widget coordinates
// proff - changed to SCREENWIDTH to 320 for stretching
#define HU_COORDX (320 - 13*hu_font['A'-HU_FONTSTART].width)
//jff 3/3/98 split coord widget into three lines in upper right of screen
#define HU_COORDX_Y (1 + 0*hu_font['A'-HU_FONTSTART].height)
#define HU_COORDY_Y (2 + 1*hu_font['A'-HU_FONTSTART].height)
#define HU_COORDZ_Y (3 + 2*hu_font['A'-HU_FONTSTART].height)
//jff 2/16/98 add ammo, health, armor widgets, 2/22/98 less gap
#define HU_GAPY 8
#define HU_HUDHEIGHT (6*HU_GAPY)
#define HU_HUDX 2
#define HU_HUDY (200-HU_HUDHEIGHT-1)
#define HU_MONSECX (HU_HUDX)
#define HU_MONSECY (HU_HUDY+0*HU_GAPY)
#define HU_KEYSX (HU_HUDX)
//jff 3/7/98 add offset for graphic key widget
#define HU_KEYSGX (HU_HUDX+4*hu_font['A'-HU_FONTSTART].width)
#define HU_KEYSY (HU_HUDY+1*HU_GAPY)
#define HU_WEAPX (HU_HUDX)
#define HU_WEAPY (HU_HUDY+2*HU_GAPY)
#define HU_AMMOX (HU_HUDX)
#define HU_AMMOY (HU_HUDY+3*HU_GAPY)
#define HU_HEALTHX (HU_HUDX)
#define HU_HEALTHY (HU_HUDY+4*HU_GAPY)
#define HU_ARMORX (HU_HUDX)
#define HU_ARMORY (HU_HUDY+5*HU_GAPY)
//jff 3/4/98 distributed HUD positions
#define HU_HUDX_LL 2
#define HU_HUDY_LL (200-2*HU_GAPY-1)
// proff/nicolas 09/20/98: Changed for high-res
//#define HU_HUDX_LR (320-120)
#define HU_HUDY_LR (200-2*HU_GAPY-1)
// proff/nicolas 09/20/98: Changed for high-res
#define HU_HUDX_UR (320-96)
#define HU_HUDY_UR 2
#define HU_MONSECX_D (HU_HUDX_LL)
#define HU_MONSECY_D (HU_HUDY_LL+0*HU_GAPY)
#define HU_KEYSX_D (HU_HUDX_LL)
#define HU_KEYSGX_D (HU_HUDX_LL+4*hu_font['A'-HU_FONTSTART].width)
#define HU_KEYSY_D (HU_HUDY_LL+1*HU_GAPY)
//#define HU_WEAPX_D (HU_HUDX_LR)
#define HU_WEAPY_D (HU_HUDY_LR+0*HU_GAPY)
//#define HU_AMMOX_D (HU_HUDX_LR)
#define HU_AMMOY_D (HU_HUDY_LR+1*HU_GAPY)
#define HU_HEALTHX_D (HU_HUDX_UR)
#define HU_HEALTHY_D (HU_HUDY_UR+0*HU_GAPY)
#define HU_ARMORX_D (HU_HUDX_UR)
#define HU_ARMORY_D (HU_HUDY_UR+1*HU_GAPY)
//#define HU_INPUTTOGGLE 't' // not used // phares
#define HU_INPUTX HU_MSGX
#define HU_INPUTY (HU_MSGY + HU_MSGHEIGHT*(hu_font[0].height) +1)
#define HU_INPUTWIDTH 64
#define HU_INPUTHEIGHT 1
#define key_alt KEYD_RALT
#define key_shift KEYD_RSHIFT
//jff 2/16/98 hud supported automap colors added
const int hudcolor_titl = 5; // color range of automap level title
//jff 2/16/98 hud text colors, controls added
const int hudcolor_mesg = 6; // color range of scrolling messages
//jff 2/26/98 hud text colors, controls added
const int hud_msg_lines = 1; // number of message lines in window
// font sets
const patch_t *hu_font[HU_FONTSIZE];
//
// Builtin map names.
// The actual names can be found in DStrings.h.
//
// Ty 03/27/98 - externalized map name arrays - now in d_deh.c
// and converted to arrays of pointers to char *
// See modified HUTITLEx macros
// DOOM shareware/registered/retail (Ultimate) names.
// CPhipps - const**const
const char *const mapnames[] =
{
HUSTR_E1M1,
HUSTR_E1M2,
HUSTR_E1M3,
HUSTR_E1M4,
HUSTR_E1M5,
HUSTR_E1M6,
HUSTR_E1M7,
HUSTR_E1M8,
HUSTR_E1M9,
HUSTR_E2M1,
HUSTR_E2M2,
HUSTR_E2M3,
HUSTR_E2M4,
HUSTR_E2M5,
HUSTR_E2M6,
HUSTR_E2M7,
HUSTR_E2M8,
HUSTR_E2M9,
HUSTR_E3M1,
HUSTR_E3M2,
HUSTR_E3M3,
HUSTR_E3M4,
HUSTR_E3M5,
HUSTR_E3M6,
HUSTR_E3M7,
HUSTR_E3M8,
HUSTR_E3M9,
HUSTR_E4M1,
HUSTR_E4M2,
HUSTR_E4M3,
HUSTR_E4M4,
HUSTR_E4M5,
HUSTR_E4M6,
HUSTR_E4M7,
HUSTR_E4M8,
HUSTR_E4M9,
};
// CPhipps - const**const
const char *const mapnames2[] = // DOOM 2 map names.
{
HUSTR_1,
HUSTR_2,
HUSTR_3,
HUSTR_4,
HUSTR_5,
HUSTR_6,
HUSTR_7,
HUSTR_8,
HUSTR_9,
HUSTR_10,
HUSTR_11,
HUSTR_12,
HUSTR_13,
HUSTR_14,
HUSTR_15,
HUSTR_16,
HUSTR_17,
HUSTR_18,
HUSTR_19,
HUSTR_20,
HUSTR_21,
HUSTR_22,
HUSTR_23,
HUSTR_24,
HUSTR_25,
HUSTR_26,
HUSTR_27,
HUSTR_28,
HUSTR_29,
HUSTR_30,
HUSTR_31,
HUSTR_32,
};
//CPhipps - const**const
const char *const mapnamesp[] = // Plutonia WAD map names.
{
PHUSTR_1,
PHUSTR_2,
PHUSTR_3,
PHUSTR_4,
PHUSTR_5,
PHUSTR_6,
PHUSTR_7,
PHUSTR_8,
PHUSTR_9,
PHUSTR_10,
PHUSTR_11,
PHUSTR_12,
PHUSTR_13,
PHUSTR_14,
PHUSTR_15,
PHUSTR_16,
PHUSTR_17,
PHUSTR_18,
PHUSTR_19,
PHUSTR_20,
PHUSTR_21,
PHUSTR_22,
PHUSTR_23,
PHUSTR_24,
PHUSTR_25,
PHUSTR_26,
PHUSTR_27,
PHUSTR_28,
PHUSTR_29,
PHUSTR_30,
PHUSTR_31,
PHUSTR_32,
};
// CPhipps - const**const
const char *const mapnamest[] = // TNT WAD map names.
{
THUSTR_1,
THUSTR_2,
THUSTR_3,
THUSTR_4,
THUSTR_5,
THUSTR_6,
THUSTR_7,
THUSTR_8,
THUSTR_9,
THUSTR_10,
THUSTR_11,
THUSTR_12,
THUSTR_13,
THUSTR_14,
THUSTR_15,
THUSTR_16,
THUSTR_17,
THUSTR_18,
THUSTR_19,
THUSTR_20,
THUSTR_21,
THUSTR_22,
THUSTR_23,
THUSTR_24,
THUSTR_25,
THUSTR_26,
THUSTR_27,
THUSTR_28,
THUSTR_29,
THUSTR_30,
THUSTR_31,
THUSTR_32,
};
//
// HU_Init()
//
// Initialize the heads-up display, text that overwrites the primary display
//
// Passed nothing, returns nothing
//
void HU_Init(void)
{
int i;
int j;
char buffer[9];
// load the heads-up font
j = HU_FONTSTART;
for (i = 0; i < HU_FONTSIZE; i++)
{
sprintf(buffer, "STCFN%.3d", j++);
hu_font[i] = (const patch_t*) writeLumpToFlashRegion(W_GetNumForName(buffer), FLASH_IMMUTABLE_REGION, true); // W_CacheLumpName(buffer);
}
}
//
// HU_Stop()
//
// Make the heads-up displays inactive
//
// Passed nothing, returns nothing
//
static void HU_Stop(void)
{
_g->headsupactive = false;
}
//
// HU_Start(void)
//
// Create and initialize the heads-up widgets, software machines to
// maintain, update, and display information over the primary display
//
// This routine must be called after any change to the heads up configuration
// in order for the changes to take effect in the actual displays
//
// Passed nothing, returns nothing
//
void HU_Start(void)
{
const char *s; /* cph - const */
if (_g->headsupactive) // stop before starting
HU_Stop();
_g->message_on = false;
_g->message_dontfuckwithme = false;
// create the message widget
// messages to player in upper-left of screen
HUlib_initSText(&_g->w_message,
HU_MSGX,
HU_MSGY,
HU_MSGHEIGHT, (const patch_t*) hu_font, // nh FIXME possible bug
HU_FONTSTART, &_g->message_on);
//jff 2/16/98 added some HUD widgets
// create the map title widget - map title display in lower left of automap
HUlib_initTextLine(&_g->w_title,
HU_TITLEX,
HU_TITLEY, (const patch_t*) hu_font, // nh FIXME possible bug
HU_FONTSTART);
// initialize the automap's level title widget
if (_g->gamestate == GS_LEVEL) /* cph - stop SEGV here when not in level */
switch (_g->gamemode)
{
case shareware:
case registered:
case retail:
s = HU_TITLE;
#ifdef PDM_LUMPTXT
/* 1.7.3 test17: names of an episode in the place of E4 (Sigil): lump PDMHU4, one line per map */
if (_g->gameepisode == 4)
{
static char t[40]; int l = W_CheckNumForName("PDMHU4");
if (l >= 0)
{
const char *p = (const char*) W_CacheLumpNum(l), *e = p + W_LumpLength(l);
for (int k = 1; k < _g->gamemap && p < e; p++) if (*p == '\n') k++;
int n = 0; while (p < e && *p != '\n' && *p && n < 39) t[n++] = *p++;
t[n] = 0; if (n) s = t;
}
}
#endif
break;
case commercial:
default: // Ty 08/27/98 - modified to check mission for TNT/Plutonia
s = (_g->gamemission == pack_tnt) ? HU_TITLET :
(_g->gamemission == pack_plut) ? HU_TITLEP : HU_TITLE2;
break;
}
else
s = "";
while (*s)
HUlib_addCharToTextLine(&_g->w_title, *(s++));
// now allow the heads-up display to run
_g->headsupactive = true;
HU_MoveHud();
}
//
// HU_MoveHud()
//
// Move the HUD display from distributed to compact mode or vice-versa
//
// Passed nothing, returns nothing
//
//jff 3/9/98 create this externally callable to avoid glitch
// when menu scatter's HUD due to delay in change of position
//
void HU_MoveHud(void)
{
}
//
// HU_Drawer()
//
// Draw all the pieces of the heads-up display
//
// Passed nothing, returns nothing
//
void HU_Drawer(void)
{
// draw the automap widgets if automap is displayed
if (_g->automapmode & am_active)
{
// map title
HUlib_drawTextLine(&_g->w_title, false);
}
//jff 3/4/98 display last to give priority
HU_Erase(); // jff 4/24/98 Erase current lines before drawing current
// needed when screen not fullsize
HUlib_drawSText(&_g->w_message);
}
//
// HU_Erase()
//
// Erase hud display lines that can be trashed by small screen display
//
// Passed nothing, returns nothing
//
void HU_Erase(void)
{
// erase the message display or the message review display
HUlib_eraseSText(&_g->w_message);
// erase the automap title
HUlib_eraseTextLine(&_g->w_title);
}
//
// HU_Ticker()
//
// Update the hud displays once per frame
//
// Passed nothing, returns nothing
//
void HU_Ticker(void)
{
player_t *plr = &_g->player; // killough 3/7/98
// tick down message counter if message is up
if (_g->message_counter && !--_g->message_counter)
{
_g->message_on = false;
}
// if messages on, or "Messages Off" is being displayed
// this allows the notification of turning messages off to be seen
if (_g->showMessages || _g->message_dontfuckwithme)
{
// display message if necessary
if (plr->message)
{
//post the message to the message widget
HUlib_addMessageToSText(&_g->w_message, 0, plr->message);
// clear the message to avoid posting multiple times
plr->message = 0;
// note a message is displayed
_g->message_on = true;
// start the message persistence counter
_g->message_counter = HU_MSGTIMEOUT;
// clear the flag that "Messages Off" is being posted
_g->message_dontfuckwithme = 0;
}
}
}
//
// HU_Responder()
//
// Responds to input events that affect the heads up displays
//
// Passed the event to respond to, returns true if the event was handled
//
boolean HU_Responder(event_t *ev)
{
return false;
}
+163
View File
@@ -0,0 +1,163 @@
/**
* Doom Port to the nRF52840 by Nicola Wrachien (next-hack in the comments)
*
* This port is based on the excellent doomhack's GBA Doom Port,
* with Kippykip additions.
*
* Several data structures and functions have been optimized
* to fit in only 256kB RAM of nRF52840 (GBA has 384 kB RAM).
* Z-Depth Light has been restored with almost no RAM consumption!
* Tons of speed optimizations have been done, and the game now
* runs extremely fast, despite the much higher 3D resolution with
* respect to GBA.
*
* PrBoom: a Doom port merged with LxDoom and LSDLDoom
* based on BOOM, a modified and improved DOOM engine
* Copyright (C) 1999 by
* id Software, Chi Hoang, Lee Killough, Jim Flynn, Rand Phares, Ty Halderman
* Copyright (C) 1999-2000 by
* Jess Haas, Nicolas Kalkhof, Colin Phipps, Florian Schulze
* Copyright 2005, 2006 by
* Florian Schulze, Colin Phipps, Neil Stevens, Andrey Budko
* Copyright (C) 2021 Nicola Wrachien (next-hack in the comments)
* on nRF52840 port.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
* 02111-1307, USA.
*
* DESCRIPTION:
* System interface for sound.
* next-hack: added support for pwm sound. Removed music.
*
*-----------------------------------------------------------------------------
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <math.h>
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
#include "z_zone.h"
#include "m_swap.h"
#include "i_sound.h"
#include "m_misc.h"
#include "w_wad.h"
#include "lprintf.h"
#include "s_sound.h"
#include "doomdef.h"
#include "doomstat.h"
#include "doomtype.h"
#include "d_main.h"
#include "m_fixed.h"
#include "global_data.h"
#include "pwm_audio.h"
//
// 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.
//
int I_StartSound(int id, int channel, int vol, int sep)
{
if ((channel < 0) || (channel >= MAX_CHANNELS))
return -1;
// 2021/05/15 next-hack
//
soundChannels[channel].lastAudioBufferIdx = 0xFFFF;
soundChannels[channel].offset = 0;
soundChannels[channel].sfxIdx = id;
soundChannels[channel].volume = vol;
#ifdef PARADISE_DEV
{ extern void plat_sound(int id); if (vol > 0) plat_sound(id); } /* v0.2.6: effects volume 0 in the menu = silent */
#endif
return channel;
}
void I_ShutdownSound(void)
{
if (_g->sound_inited)
{
lprintf(LO_INFO, "I_ShutdownSound: ");
lprintf(LO_INFO, "\n");
_g->sound_inited = false;
}
}
//static SDL_AudioSpec audio;
void I_InitSound(void)
{
if (!nomusicparm)
I_InitMusic();
// Finished initialization.
lprintf(LO_INFO, "I_InitSound: sound ready");
}
void I_InitMusic(void)
{
}
void I_PlaySong(int handle, int looping)
{
if (handle == mus_None)
return;
#if defined(PARADISE_DEV) && defined(MUS_PLAY)
{ extern void plat_music_play(int h, int l); plat_music_play(handle, looping); }
#endif
}
#if defined(PARADISE_DEV) && defined(MUS_PLAY)
extern void plat_music_pause(int p); extern void plat_music_stop(void); extern void plat_music_volume(int v);
void I_PauseSong(int handle) { plat_music_pause(1); }
void I_ResumeSong(int handle) { plat_music_pause(0); }
void I_StopSong(int handle) { plat_music_stop(); }
void I_SetMusicVolume(int volume) { plat_music_volume(volume); }
#else
void I_PauseSong(int handle)
{
}
void I_ResumeSong(int handle)
{
}
void I_StopSong(int handle)
{
}
void I_SetMusicVolume(int volume)
{
}
#endif
+106
View File
@@ -0,0 +1,106 @@
/**
* Doom Port to the nRF52840 by Nicola Wrachien (next-hack in the comments)
*
* This port is based on the excellent doomhack's GBA Doom Port,
* with Kippykip additions.
*
* Several data structures and functions have been optimized
* to fit in only 256kB RAM of nRF52840 (GBA has 384 kB RAM).
* Z-Depth Light has been restored with almost no RAM consumption!
* Tons of speed optimizations have been done, and the game now
* runs extremely fast, despite the much higher 3D resolution with
* respect to GBA.
*
* PrBoom: a Doom port merged with LxDoom and LSDLDoom
* based on BOOM, a modified and improved DOOM engine
* Copyright (C) 1999 by
* id Software, Chi Hoang, Lee Killough, Jim Flynn, Rand Phares, Ty Halderman
* Copyright (C) 1999-2000 by
* Jess Haas, Nicolas Kalkhof, Colin Phipps, Florian Schulze
* Copyright 2005, 2006 by
* Florian Schulze, Colin Phipps, Neil Stevens, Andrey Budko
* Copyright (C) 2021 Nicola Wrachien (next-hack in the comments)
* on nRF52840 port.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
* 02111-1307, USA.
*
* DESCRIPTION:
* Startup and quit functions. Handles signals, inits the
* memory management, then calls D_DoomMain. Also contains
* I_Init which does other system-related startup stuff.
*
* next-hack: put sound init and time functions
*
*-----------------------------------------------------------------------------
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
#include "doomdef.h"
#include "d_main.h"
#include "m_fixed.h"
#include "i_system.h"
#include "i_video.h"
#include "z_zone.h"
#include "lprintf.h"
#include "m_random.h"
#include "doomstat.h"
#include "g_game.h"
#include "m_misc.h"
#include "i_sound.h"
#include "i_main.h"
#include "lprintf.h"
#include "global_data.h"
#include <stdio.h>
#include <stdlib.h>
#include "nrf.h"
unsigned int plat_micros(void);
unsigned int I_GetTimeMicrosecs()
{
return plat_micros();
}
unsigned int I_GetTime(void)
{
uint32_t time = I_GetTimeMicrosecs();
if (!_g->basetime)
{
_g->basetime = time;
return 0;
}
uint32_t diff = time - _g->basetime;
#define SPEED10X 0
#if SPEED10X
#warning speed10x
diff = diff / (100000 / TICRATE);
#else
diff = diff / (1000000 / TICRATE);
#endif
return diff;
}
void I_Init(void)
{
if (!(nomusicparm && nosfxparm))
I_InitSound();
}
@@ -0,0 +1,61 @@
/**
* Doom Port to the nRF52840 by Nicola Wrachien (next-hack in the comments)
*
* This port is based on the excellent doomhack's GBA Doom Port,
* with Kippykip additions.
*
* Several data structures and functions have been optimized
* to fit in only 256kB RAM of nRF52840 (GBA has 384 kB RAM).
* Z-Depth Light has been restored with almost no RAM consumption!
* Tons of speed optimizations have been done, and the game now
* runs extremely fast, despite the much higher 3D resolution with
* respect to GBA.
*
* PrBoom: a Doom port merged with LxDoom and LSDLDoom
* based on BOOM, a modified and improved DOOM engine
* Copyright (C) 1999 by
* id Software, Chi Hoang, Lee Killough, Jim Flynn, Rand Phares, Ty Halderman
* Copyright (C) 1999-2000 by
* Jess Haas, Nicolas Kalkhof, Colin Phipps, Florian Schulze
* Copyright 2005, 2006 by
* Florian Schulze, Colin Phipps, Neil Stevens, Andrey Budko
* Copyright (C) 2021 Nicola Wrachien (next-hack in the comments)
* on nRF52840 port.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
* 02111-1307, USA.
*
* DESCRIPTION:
* next-hack: Some wrapper functions, to use SPI routines.
* Memory mapped code has been removed.
*/
#include <string.h>
#include "i_spi_support.h"
#include "printf.h"
uint8_t *currentSpiAddress;
#if NO_INLINE_SPI
uint32_t spiFlashSetAddress(uint32_t address)
{
currentSpiAddress = (uint8_t*) address;
// printf("SA 0x%08x 0x%02x\r\n", address, *currentSpiAddress);
}
void* spiFlashGetData(void *dest, unsigned int length)
{
memcpy(dest, currentSpiAddress, length);
currentSpiAddress += length;
// printf("GD: %08x, %d: %08x\r\n", currentSpiAddress, length, *((uint32_t*) dest));
return dest;
}
#endif
+297
View File
@@ -0,0 +1,297 @@
/**
* Doom Port to the nRF52840 by Nicola Wrachien (next-hack in the comments)
*
* This port is based on the excellent doomhack's GBA Doom Port,
* with Kippykip additions.
*
* Several data structures and functions have been optimized
* to fit in only 256kB RAM of nRF52840 (GBA has 384 kB RAM).
* Z-Depth Light has been restored with almost no RAM consumption!
* Tons of speed optimizations have been done, and the game now
* runs extremely fast, despite the much higher 3D resolution with
* respect to GBA.
*
* PrBoom: a Doom port merged with LxDoom and LSDLDoom
* based on BOOM, a modified and improved DOOM engine
* Copyright (C) 1999 by
* id Software, Chi Hoang, Lee Killough, Jim Flynn, Rand Phares, Ty Halderman
* Copyright (C) 1999-2000 by
* Jess Haas, Nicolas Kalkhof, Colin Phipps, Florian Schulze
* Copyright 2005, 2006 by
* Florian Schulze, Colin Phipps, Neil Stevens, Andrey Budko
* Copyright (C) 2021 Nicola Wrachien (next-hack in the comments)
* on nRF52840 port.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
* 02111-1307, USA.
*
* DESCRIPTION:
* DOOM graphics stuff.
* next-hack: and also key handling, don't ask me why they were put in
* i_video.c. Key handling and graphics I/O modified according HW...
*
*-----------------------------------------------------------------------------
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include "main.h"
#include <stdlib.h>
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
#include <math.h>
#include "main.h"
#include "doomstat.h"
#include "doomdef.h"
#include "doomtype.h"
#include "v_video.h"
#include "r_draw.h"
#include "d_main.h"
#include "d_event.h"
#include "i_video.h"
#include "i_sound.h"
#include "m_menu.h"
#include "z_zone.h"
#include "s_sound.h"
#include "sounds.h"
#include "w_wad.h"
#include "st_stuff.h"
#include "lprintf.h"
#include "doomdef.h"
#include "global_data.h"
#include "display.h"
#include "graphics.h"
#include "keyboard.h"
#define NO_PALETTE_CHANGE 255
uint16_t palette[256];
bool toggleBacklight = false;
key_t keysDown()
{
key_t buttons = 0;
getKeys(&buttons);
return buttons;
}
//
// I_StartTic
//
void I_StartTic(void)
{
static uint16_t oldGameKeyState = 0;
// get which keys are currently pressed
key_t hwKeyState = keysDown();
// translate between the hardware key state and the game key state
uint16_t gameKeyState = 0;
if (hwKeyState & KEY_ALT)
{
if (hwKeyState & KEY_RIGHT)
gameKeyState |= 1 << KEYD_SR;
if (hwKeyState & KEY_LEFT)
gameKeyState |= 1 << KEYD_SL;
if (hwKeyState & KEY_USE)
#if KEYBOARD == I2C_GAMEPAD
// USE negates always run setting, so with a dedicated MENU key the USE button
// can be freed from the ALT combo allowing it to be dual-purpose USE and SPEED button
gameKeyState |= 1 << KEYD_USE;
#else
gameKeyState |= 1 << KEYD_MENU;
#endif
if (hwKeyState & KEY_CHGW)
gameKeyState |= 1 << KEYD_CHGWDOWN;
#if OLD_KEYMAP // it was not wise setting ALT with fire to trigger automap...
if (hwKeyState & KEY_FIRE)
gameKeyState |= 1 << KEYD_MAP1;
#else
if (hwKeyState & KEY_FIRE)
gameKeyState |= 1 << KEYD_FIRE;
#endif
if (! (hwKeyState & (KEY_RIGHT | KEY_LEFT | KEY_USE | KEY_CHGW | KEY_FIRE)))
gameKeyState |= 1 << KEYD_ALT;
}
else
{
if (hwKeyState & KEY_RIGHT)
gameKeyState |= 1 << KEYD_RIGHT;
if (hwKeyState & KEY_LEFT)
gameKeyState |= 1 << KEYD_LEFT;
if (hwKeyState & KEY_FIRE)
gameKeyState |= 1 << KEYD_FIRE;
#if KEYBOARD == I2C_GAMEPAD
// remap USE+CHGW from MAP1 in other keymaps to CHGWDOWN
if ((hwKeyState & (KEY_USE | KEY_CHGW)) == (KEY_USE | KEY_CHGW))
gameKeyState |= 1 << KEYD_CHGWDOWN;
else
{
#endif
if (hwKeyState & KEY_USE)
gameKeyState |= 1 << KEYD_USE;
if (hwKeyState & KEY_CHGW)
gameKeyState |= 1 << KEYD_CHGW;
#if KEYBOARD == I2C_GAMEPAD
}
#endif
}
if (hwKeyState & KEY_UP)
gameKeyState |= 1 << KEYD_UP;
if (hwKeyState & KEY_DOWN)
gameKeyState |= 1 << KEYD_DOWN;
#if KEYBOARD == I2C_GAMEPAD
// Gamepad has 10 total buttons, with extra byte for key data can have MAP1 and MENU as dedicated buttons
if (hwKeyState & KEY_MAP)
gameKeyState |= 1 << KEYD_MAP1;
if (hwKeyState & KEY_MENU)
gameKeyState |= 1 << KEYD_MENU;
#endif
#if !OLD_KEYMAP && KEYBOARD != I2C_GAMEPAD
// automap is now enabled when use and change weapon are pressed at the same time (or chgwdown for i2c gamepad)
if ((hwKeyState & (KEY_USE | KEY_CHGW)) == (KEY_USE | KEY_CHGW))
gameKeyState |= 1 << KEYD_MAP1;
#endif
// Get which keys have changed since last time
uint16_t keys_changed = oldGameKeyState ^ gameKeyState;
event_t ev;
ev.type = ev_keydown;
for (int i = 0; i < NUMKEYS; i++)
{
if ((1 & (keys_changed >> i)) && (1 & (gameKeyState >> i)))
{
ev.data1 = i;
D_PostEvent(&ev);
}
}
ev.type = ev_keyup;
for (int i = 0; i < NUMKEYS; i++)
{
if ((1 & (keys_changed >> i)) && !(1 & (gameKeyState >> i)))
{
ev.data1 = i;
D_PostEvent(&ev);
}
}
oldGameKeyState = gameKeyState;
#if 0
// handle onboard clue buttons for gamma adjust and toggling backlight
static bool aBtnWasDown = false;
static bool bBtnWasDown = false;
bool aDown = !(GPIO_PORT(PORT_NUM_BTN_A)->IN & (1 << PIN_NUM_BTN_A));
bool bDown = !(GPIO_PORT(PORT_NUM_BTN_B)->IN & (1 << PIN_NUM_BTN_B));
if (aDown && bDown && (!aBtnWasDown || !bBtnWasDown))
toggleBacklight = true;
else if (aDown && !aBtnWasDown)
M_ChangeGamma(0);
else if (bDown && !bBtnWasDown)
M_ChangeGamma(1);
aBtnWasDown = aDown;
bBtnWasDown = bDown;
#endif
}
boolean I_StartDisplay(void)
{
_g->screens[0].data = displayData.displayFrameBuffer[displayData.workingBuffer];
// Same with base row offset.
drawvars.byte_topleft = _g->screens[0].data;
return true;
}
/////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////
// Palette stuff.
//
static void I_UploadNewPalette(int pal)
{
#ifdef PARADISE_DEV
static int lastpal = -1, lastgamma = -1;
if (pal == lastpal && _g->gamma == lastgamma && _g->current_palette == palette)
return;
lastpal = pal; lastgamma = _g->gamma;
#endif
_g->current_palette = palette;
//
if (_g->gamma)
{
for (int i = 0; i < 256; i++)
{
uint16_t r = gammatable[_g->gamma][p_wad_immutable_flash_data->palette_lump[pal * 256 * 3 + 3 * i]] >> 3;
uint16_t g = gammatable[_g->gamma][p_wad_immutable_flash_data->palette_lump[pal * 256 * 3 + 3 * i + 1]] >> 2;
uint16_t b = gammatable[_g->gamma][p_wad_immutable_flash_data->palette_lump[pal * 256 * 3 + 3 * i + 2]] >> 3;
uint16_t rgb = (r << (6 + 5)) | (g << 5) | (b << (0));
rgb = (rgb >> 8) | (rgb << 8);
_g->current_palette[i] = rgb;
}
}
else
{ // save some cycles for those playing with 0 gamma.
for (int i = 0; i < 256; i++)
{
uint16_t r = p_wad_immutable_flash_data->palette_lump[pal * 256 * 3 + 3 * i] >> 3;
uint16_t g = p_wad_immutable_flash_data->palette_lump[pal * 256 * 3 + 3 * i + 1] >> 2;
uint16_t b = p_wad_immutable_flash_data->palette_lump[pal * 256 * 3 + 3 * i + 2] >> 3;
uint16_t rgb = (r << (6 + 5)) | (g << 5) | (b << (0));
rgb = (rgb >> 8) | (rgb << 8);
_g->current_palette[i] = rgb;
}
}
displayData.pPalette = _g->current_palette;
}
//////////////////////////////////////////////////////////////////////////////
// Graphics API
//
void I_FinishUpdateBlock(void)
{
I_UploadNewPalette(_g->newpal);
startDisplayRefresh(displayData.workingBuffer);
displayData.workingBuffer = 1 - displayData.workingBuffer;
}
//
// I_SetPalette
//
void I_SetPalette(int pal)
{
_g->newpal = pal;
}
void handleDisplayBacklightToggle() {
static bool backlightOn = true;
if (toggleBacklight)
{
toggleBacklight = false;
backlightOn = !backlightOn;
SetBacklight(backlightOn);
}
}
File diff suppressed because it is too large. Load diff
+71
View File
@@ -0,0 +1,71 @@
/**
* Doom Port to the nRF52840 by Nicola Wrachien (next-hack in the comments)
*
* This port is based on the excellent doomhack's GBA Doom Port,
* with Kippykip additions.
*
* Several data structures and functions have been optimized
* to fit in only 256kB RAM of nRF52840 (GBA has 384 kB RAM).
* Z-Depth Light has been restored with almost no RAM consumption!
* Tons of speed optimizations have been done, and the game now
* runs extremely fast, despite the much higher 3D resolution with
* respect to GBA.
*
* PrBoom: a Doom port merged with LxDoom and LSDLDoom
* based on BOOM, a modified and improved DOOM engine
* Copyright (C) 1999 by
* id Software, Chi Hoang, Lee Killough, Jim Flynn, Rand Phares, Ty Halderman
* Copyright (C) 1999-2000 by
* Jess Haas, Nicolas Kalkhof, Colin Phipps, Florian Schulze
* Copyright 2005, 2006 by
* Florian Schulze, Colin Phipps, Neil Stevens, Andrey Budko
* Copyright (C) 2021 Nicola Wrachien (next-hack in the comments)
* on nRF52840 port.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
* 02111-1307, USA.
* DESCRIPTION:
* Main loop menu stuff.
* Random number LUT.
* Default Config File.
* PCX Screenshots.
*
* next-hack: I don't think the description is accurate...
* Just box structure
*-----------------------------------------------------------------------------*/
#ifdef __GNUG__
#pragma implementation "m_bbox.h"
#endif
#include "m_bbox.h"
void M_ClearBox(fixed_t *box)
{
box[BOXTOP] = box[BOXRIGHT] = INT_MIN;
box[BOXBOTTOM] = box[BOXLEFT] = INT_MAX;
}
void M_AddToBox(fixed_t *box, fixed_t x, fixed_t y)
{
if (x < box[BOXLEFT])
box[BOXLEFT] = x;
else if (x > box[BOXRIGHT])
box[BOXRIGHT] = x;
if (y < box[BOXBOTTOM])
box[BOXBOTTOM] = y;
else if (y > box[BOXTOP])
box[BOXTOP] = y;
}
+307
View File
@@ -0,0 +1,307 @@
/**
* Doom Port to the nRF52840 by Nicola Wrachien (next-hack in the comments)
*
* This port is based on the excellent doomhack's GBA Doom Port,
* with Kippykip additions.
*
* Several data structures and functions have been optimized
* to fit in only 256kB RAM of nRF52840 (GBA has 384 kB RAM).
* Z-Depth Light has been restored with almost no RAM consumption!
* Tons of speed optimizations have been done, and the game now
* runs extremely fast, despite the much higher 3D resolution with
* respect to GBA.
*
* PrBoom: a Doom port merged with LxDoom and LSDLDoom
* based on BOOM, a modified and improved DOOM engine
* Copyright (C) 1999 by
* id Software, Chi Hoang, Lee Killough, Jim Flynn, Rand Phares, Ty Halderman
* Copyright (C) 1999-2000 by
* Jess Haas, Nicolas Kalkhof, Colin Phipps, Florian Schulze
* Copyright 2005, 2006 by
* Florian Schulze, Colin Phipps, Neil Stevens, Andrey Budko
* Copyright (C) 2021 Nicola Wrachien (next-hack in the comments)
* on nRF52840 port.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
* 02111-1307, USA.
* DESCRIPTION:
* Cheat (by doomhack?)
*
* next-hack: cheat not supported yet, need to clean up.
*/
#include "m_cheat.h"
#include "doomdef.h"
#include "d_englsh.h"
#include "p_inter.h"
#include "g_game.h"
#include "global_data.h"
static void cheat_god(void);
static void cheat_choppers(void);
static void cheat_idkfa(void);
static void cheat_ammo(void);
static void cheat_noclip(void);
static void cheat_invincibility(void);
static void cheat_beserk(void);
static void cheat_invisibility(void);
static void cheat_map(void);
static void cheat_goggles(void);
static void cheat_exit(void);
static void cheat_rockets(void);
static void cheat_fps(void);
typedef struct c_cheat
{
char *name;
byte sequence[8];
unsigned int packed_sequence;
void (*cheat_function)(void);
} c_cheat;
#define CHEAT_PACK(a,b,c,d,e,f,g,h) ((a << 28)|(b << 24)|(c << 20)|(d << 16)|(e << 12)|(f << 8)|(g << 4)|(h))
#define CHEAT_SEQ(a,b,c,d,e,f,g,h) {a,b,c,d,e,f,g,h}, CHEAT_PACK(a,b,c,d,e,f,g,h)
static const c_cheat cheat_def[] =
{
{ "Chainsaw", CHEAT_SEQ(KEYD_ALT, KEYD_UP, KEYD_UP, KEYD_LEFT, KEYD_ALT, KEYD_USE, KEYD_USE, KEYD_UP), cheat_choppers },
{ "Auto-map", CHEAT_SEQ(KEYD_DOWN, KEYD_DOWN, KEYD_LEFT, KEYD_LEFT, KEYD_RIGHT, KEYD_RIGHT, KEYD_LEFT, KEYD_UP), cheat_map },
{ "God mode", CHEAT_SEQ(KEYD_UP, KEYD_UP, KEYD_DOWN, KEYD_DOWN, KEYD_LEFT, KEYD_LEFT, KEYD_RIGHT, KEYD_RIGHT), cheat_god },
{ "Ammo & Keys", CHEAT_SEQ(KEYD_ALT, KEYD_LEFT, KEYD_USE, KEYD_RIGHT, KEYD_USE, KEYD_UP, KEYD_ALT, KEYD_UP), cheat_idkfa },
{ "Ammo", CHEAT_SEQ(KEYD_ALT, KEYD_CHGW, KEYD_ALT, KEYD_CHGW, KEYD_ALT, KEYD_UP, KEYD_UP, KEYD_LEFT), cheat_ammo },
{ "No Clipping", CHEAT_SEQ(KEYD_ALT, KEYD_DOWN, KEYD_LEFT, KEYD_RIGHT, KEYD_UP, KEYD_DOWN, KEYD_LEFT, KEYD_RIGHT), cheat_noclip },
{ "Invincibility", CHEAT_SEQ(KEYD_ALT, KEYD_CHGW, KEYD_ALT, KEYD_RIGHT, KEYD_LEFT, KEYD_RIGHT, KEYD_ALT, KEYD_ALT), cheat_invincibility },
{ "Berserk", CHEAT_SEQ(KEYD_ALT, KEYD_CHGW, KEYD_ALT, KEYD_UP, KEYD_LEFT, KEYD_ALT, KEYD_RIGHT, KEYD_ALT), cheat_beserk },
{ "Invisibility", CHEAT_SEQ(KEYD_CHGW, KEYD_ALT, KEYD_CHGW, KEYD_LEFT, KEYD_LEFT, KEYD_ALT, KEYD_LEFT, KEYD_ALT), cheat_invisibility },
{ "Lite-Amp Goggles", CHEAT_SEQ(KEYD_DOWN, KEYD_LEFT, KEYD_RIGHT, KEYD_ALT, KEYD_RIGHT, KEYD_LEFT, KEYD_LEFT, KEYD_RIGHT), cheat_goggles },
{ "Exit Level", CHEAT_SEQ(KEYD_LEFT, KEYD_LEFT, KEYD_LEFT, KEYD_ALT, KEYD_CHGW, KEYD_USE, KEYD_RIGHT, KEYD_FIRE), cheat_exit },
//Because Goldeneye!
{ "Enemy Rockets", CHEAT_SEQ(KEYD_CHGW, KEYD_ALT, KEYD_CHGW, KEYD_ALT, KEYD_RIGHT, KEYD_ALT, KEYD_ALT, KEYD_RIGHT), cheat_rockets },
{ "FPS Counter Ammo", CHEAT_SEQ(KEYD_RIGHT, KEYD_RIGHT, KEYD_ALT, KEYD_UP, KEYD_DOWN, KEYD_ALT, KEYD_LEFT, KEYD_LEFT), cheat_fps },
};
static const unsigned int num_cheats = sizeof(cheat_def) / sizeof(c_cheat);
static boolean CheckCheats(unsigned int keybuff)
{
for (int i = 0; i < num_cheats; i++)
{
if (cheat_def[i].packed_sequence == keybuff)
{
if (cheat_def[i].cheat_function)
cheat_def[i].cheat_function();
return true;
}
}
return false;
}
boolean C_Responder(event_t *ev)
{
if (ev->type == ev_keydown)
{
//To enable fast cheat searching without having to
//maintain buffer of keypresses, we ensure that
//cheats are 8 keys long and the key-code is less
//than 16 so they fit in 4 bits.
//We can store a full 8 presses in a 32bit int.
//Adding a press to the list just means shifting the
//whole thing by 4 and ORing the next press into the
//low bits.
//We can test a cheat sequence with a simple int comparison.
unsigned int cb = _g->cheat_buffer << 4;
cb |= ev->data1 & 0xf;
_g->cheat_buffer = cb;
if (CheckCheats(cb))
return true; //eat last cheat key.
}
return false;
}
static void cheat_god()
{
_g->player.cheats ^= CF_GODMODE;
if (_g->player.cheats & CF_GODMODE)
{
_g->player.health = god_health;
_g->player.message = STSTR_DQDON;
}
else
{
_g->player.message = STSTR_DQDOFF;
}
}
static void cheat_choppers()
{
_g->player.weaponowned[wp_chainsaw] = true;
_g->player.pendingweapon = wp_chainsaw;
P_GivePower(&_g->player, pw_invulnerability);
_g->player.message = STSTR_CHOPPERS;
}
static void cheat_idkfa()
{
int i;
player_t *plyr = &_g->player;
if (!plyr->backpack)
{
for (i = 0; i < NUMAMMO; i++)
plyr->maxammo[i] *= 2;
plyr->backpack = true;
}
plyr->armorpoints = idfa_armor; // Ty 03/09/98 - deh
plyr->armortype = idfa_armor_class; // Ty 03/09/98 - deh
// You can't own weapons that aren't in the game // phares 02/27/98
for (i = 0; i < NUMWEAPONS; i++)
if (!(((i == wp_plasma || i == wp_bfg) && _g->gamemode == shareware) || (i == wp_supershotgun && _g->gamemode != commercial)))
plyr->weaponowned[i] = true;
for (i = 0; i < NUMAMMO; i++)
if (i != am_cell || _g->gamemode != shareware)
plyr->ammo[i] = plyr->maxammo[i];
for (i = 0; i < NUMCARDS; i++)
plyr->cards[i] = true;
plyr->message = STSTR_KFAADDED;
}
static void cheat_ammo()
{
int i;
player_t *plyr = &_g->player;
if (!plyr->backpack)
{
for (i = 0; i < NUMAMMO; i++)
plyr->maxammo[i] *= 2;
plyr->backpack = true;
}
plyr->armorpoints = idfa_armor; // Ty 03/09/98 - deh
plyr->armortype = idfa_armor_class; // Ty 03/09/98 - deh
// You can't own weapons that aren't in the game // phares 02/27/98
for (i = 0; i < NUMWEAPONS; i++)
if (!(((i == wp_plasma || i == wp_bfg) && _g->gamemode == shareware) || (i == wp_supershotgun && _g->gamemode != commercial)))
plyr->weaponowned[i] = true;
for (i = 0; i < NUMAMMO; i++)
if (i != am_cell || _g->gamemode != shareware)
plyr->ammo[i] = plyr->maxammo[i];
plyr->message = STSTR_FAADDED;
}
static void cheat_noclip()
{
_g->player.cheats ^= CF_NOCLIP;
if (_g->player.cheats & CF_NOCLIP)
{
_g->player.message = STSTR_NCON;
}
else
{
_g->player.message = STSTR_NCOFF;
}
}
static void cheat_invincibility()
{
P_GivePower(&_g->player, pw_invulnerability);
}
static void cheat_beserk()
{
P_GivePower(&_g->player, pw_strength);
}
static void cheat_invisibility()
{
P_GivePower(&_g->player, pw_invisibility);
}
static void cheat_map()
{
P_GivePower(&_g->player, pw_allmap);
}
static void cheat_goggles()
{
P_GivePower(&_g->player, pw_infrared);
}
static void cheat_exit()
{
G_ExitLevel();
}
static void cheat_rockets()
{
_g->player.cheats ^= CF_ENEMY_ROCKETS;
if (_g->player.cheats & CF_ENEMY_ROCKETS)
{
_g->player.health = god_health;
_g->player.weaponowned[wp_missile] = true;
_g->player.ammo[am_misl] = _g->player.maxammo[am_misl];
_g->player.pendingweapon = wp_missile;
_g->player.message = STSTR_ROCKETON;
}
else
{
_g->player.message = STSTR_ROCKETOFF;
}
}
static void cheat_fps()
{
_g->fps_show = !_g->fps_show;
if (_g->fps_show)
{
_g->player.message = STSTR_FPSON;
}
else
{
_g->player.message = STSTR_FPSOFF;
}
}
File diff suppressed because it is too large. Load diff
+97
View File
@@ -0,0 +1,97 @@
/* Emacs style mode select -*- C++ -*-
*-----------------------------------------------------------------------------
*
*
* PrBoom: a Doom port merged with LxDoom and LSDLDoom
* based on BOOM, a modified and improved DOOM engine
* Copyright (C) 1999 by
* id Software, Chi Hoang, Lee Killough, Jim Flynn, Rand Phares, Ty Halderman
* Copyright (C) 1999-2000 by
* Jess Haas, Nicolas Kalkhof, Colin Phipps, Florian Schulze
* Copyright 2005, 2006 by
* Florian Schulze, Colin Phipps, Neil Stevens, Andrey Budko
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
* 02111-1307, USA.
*
* DESCRIPTION:
* Random number LUT.
*
* 1/19/98 killough: Rewrote random number generator for better randomness,
* while at the same time maintaining demo sync and backward compatibility.
*
* 2/16/98 killough: Made each RNG local to each control-equivalent block,
* to reduce the chances of demo sync problems.
*
*-----------------------------------------------------------------------------*/
#include "doomstat.h"
#include "m_random.h"
#include "lprintf.h"
#include "global_data.h"
//
// M_Random
// Returns a 0-255 number
// next-hack: why using 18 rows of 14 numbers and then 4 ? 16 by 16 was bad?
static const unsigned char rndtable[256] =
{
0, 8, 109, 220, 222, 241, 149, 107, 75, 248, 254, 140, 16, 66 ,
74, 21, 211, 47, 80, 242, 154, 27, 205, 128, 161, 89, 77, 36 ,
95, 110, 85, 48, 212, 140, 211, 249, 22, 79, 200, 50, 28, 188 ,
52, 140, 202, 120, 68, 145, 62, 70, 184, 190, 91, 197, 152, 224 ,
149, 104, 25, 178, 252, 182, 202, 182, 141, 197, 4, 81, 181, 242 ,
145, 42, 39, 227, 156, 198, 225, 193, 219, 93, 122, 175, 249, 0 ,
175, 143, 70, 239, 46, 246, 163, 53, 163, 109, 168, 135, 2, 235 ,
25, 92, 20, 145, 138, 77, 69, 166, 78, 176, 173, 212, 166, 113 ,
94, 161, 41, 50, 239, 49, 111, 164, 70, 60, 2, 37, 171, 75 ,
136, 156, 11, 56, 42, 146, 138, 229, 73, 146, 77, 61, 98, 196 ,
135, 106, 63, 197, 195, 86, 96, 203, 113, 101, 170, 247, 181, 113 ,
80, 250, 108, 7, 255, 237, 129, 226, 79, 107, 112, 166, 103, 241 ,
24, 223, 239, 120, 198, 58, 60, 82, 128, 3, 184, 66, 143, 224 ,
145, 224, 81, 206, 163, 45, 63, 90, 168, 114, 59, 33, 159, 95 ,
28, 139, 123, 98, 125, 196, 15, 70, 194, 253, 54, 14, 109, 226 ,
71, 17, 161, 93, 186, 87, 244, 138, 20, 52, 123, 251, 26, 36 ,
17, 46, 52, 231, 232, 76, 31, 221, 84, 37, 216, 165, 212, 106 ,
197, 242, 98, 43, 39, 175, 254, 145, 190, 84, 118, 222, 187, 136 ,
120, 163, 236, 249
};
// Which one is deterministic?
int P_Random(const char *file, int line, const char *func)
{
_g->prndindex = (_g->prndindex + 1) & 0xff;
if (PRND_SCAN && _g->gametic >= MIN_DEMO_GAMETIC_TO_PRINT)
{
// get only last path
int l = strlen(file);
file += l - 1;
while (*file != '\\')
file--;
demodbgprintf ("File %s, Line %d, func %s MR %x\r\n", file, line, func, _g->prndindex);
}
return rndtable[_g->prndindex];
}
int M_Random(void)
{
_g->rndindex = (_g->rndindex + 1) & 0xff;
return rndtable[_g->rndindex];
}
void M_ClearRandom(void)
{
_g->rndindex = _g->prndindex = 0;
}
+467
View File
@@ -0,0 +1,467 @@
/**
* Doom Port to the nRF52840 by Nicola Wrachien (next-hack in the comments)
*
* This port is based on the excellent doomhack's GBA Doom Port,
* with Kippykip additions.
*
* Several data structures and functions have been optimized
* to fit in only 256kB RAM of nRF52840 (GBA has 384 kB RAM).
* Z-Depth Light has been restored with almost no RAM consumption!
* Tons of speed optimizations have been done, and the game now
* runs extremely fast, despite the much higher 3D resolution with
* respect to GBA.
*
* PrBoom: a Doom port merged with LxDoom and LSDLDoom
* based on BOOM, a modified and improved DOOM engine
* Copyright (C) 1999 by
* id Software, Chi Hoang, Lee Killough, Jim Flynn, Rand Phares, Ty Halderman
* Copyright (C) 1999-2000 by
* Jess Haas, Nicolas Kalkhof, Colin Phipps, Florian Schulze
* Copyright 2005, 2006 by
* Florian Schulze, Colin Phipps, Neil Stevens, Andrey Budko
* Copyright (C) 2021 Nicola Wrachien (next-hack in the comments)
* on nRF52840 port.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
* 02111-1307, USA.
*
* DESCRIPTION:
* Ceiling aninmation (lowering, crushing, raising)
*
* next-hack: modified code to work with short pointers.
*
*-----------------------------------------------------------------------------*/
#include "doomstat.h"
#include "r_main.h"
#include "p_spec.h"
#include "p_tick.h"
#include "s_sound.h"
#include "sounds.h"
#include "global_data.h"
/////////////////////////////////////////////////////////////////
//
// Ceiling action routine and linedef type handler
//
/////////////////////////////////////////////////////////////////
//
// T_MoveCeiling
//
// Action routine that moves ceilings. Called once per tick.
//
// Passed a ceiling_t structure that contains all the info about the move.
// see P_SPEC.H for fields. No return.
//
// jff 02/08/98 all cases with labels beginning with gen added to support
// generalized line type behaviors.
//
void T_MoveCeiling(ceiling_t *ceiling)
{
result_e res;
switch (ceiling->direction)
{
case 0:
// If ceiling in stasis, do nothing
break;
case 1:
// Ceiling is moving up
res = T_MovePlane(ceiling->sector, ceiling->speed, ceiling->topheight,
false, 1, ceiling->direction);
// if not a silent crusher, make moving sound
if (!(_g->leveltime & 7))
{
switch (ceiling->type)
{
case silentCrushAndRaise:
case genSilentCrusher:
break;
default:
S_StartSound2(&ceiling->sector->soundorg, sfx_stnmov);
break;
}
}
// handle reaching destination height
if (res == pastdest)
{
switch (ceiling->type)
{
// plain movers are just removed
case raiseToHighest:
case genCeiling:
P_RemoveActiveCeiling(ceiling);
break;
// movers with texture change, change the texture then get removed
case genCeilingChgT:
case genCeilingChg0:
ceiling->sector->special = ceiling->newspecial;
//jff 3/14/98 transfer old special field as well
ceiling->sector->oldspecial = ceiling->oldspecial;
case genCeilingChg:
ceiling->sector->ceilingpic = ceiling->texture;
P_RemoveActiveCeiling(ceiling);
break;
// crushers reverse direction at the top
case silentCrushAndRaise:
S_StartSound2(&ceiling->sector->soundorg, sfx_pstop);
case genSilentCrusher:
case genCrusher:
case fastCrushAndRaise:
case crushAndRaise:
ceiling->direction = -1;
break;
default:
break;
}
}
break;
case -1:
// Ceiling moving down
res = T_MovePlane(ceiling->sector, ceiling->speed, ceiling->bottomheight, ceiling->crush, 1, ceiling->direction);
// if not silent crusher type make moving sound
if (!(_g->leveltime & 7))
{
switch (ceiling->type)
{
case silentCrushAndRaise:
case genSilentCrusher:
break;
default:
S_StartSound2(&ceiling->sector->soundorg, sfx_stnmov);
}
}
// handle reaching destination height
if (res == pastdest)
{
switch (ceiling->type)
{
// 02/09/98 jff change slow crushers' speed back to normal
// start back up
case genSilentCrusher:
case genCrusher:
if (ceiling->oldspeed < CEILSPEED * 3)
ceiling->speed = ceiling->oldspeed;
ceiling->direction = 1; //jff 2/22/98 make it go back up!
break;
// make platform stop at bottom of all crusher strokes
// except generalized ones, reset speed, start back up
case silentCrushAndRaise:
S_StartSound2(&ceiling->sector->soundorg, sfx_pstop);
case crushAndRaise:
ceiling->speed = CEILSPEED;
case fastCrushAndRaise:
ceiling->direction = 1;
break;
// in the case of ceiling mover/changer, change the texture
// then remove the active ceiling
case genCeilingChgT:
case genCeilingChg0:
ceiling->sector->special = ceiling->newspecial;
//jff add to fix bug in special transfers from changes
ceiling->sector->oldspecial = ceiling->oldspecial;
case genCeilingChg:
ceiling->sector->ceilingpic = ceiling->texture;
P_RemoveActiveCeiling(ceiling);
break;
// all other case, just remove the active ceiling
case lowerAndCrush:
case lowerToFloor:
case lowerToLowest:
case lowerToMaxFloor:
case genCeiling:
P_RemoveActiveCeiling(ceiling);
break;
default:
break;
}
}
else // ( res != pastdest )
{
// handle the crusher encountering an obstacle
if (res == crushed)
{
switch (ceiling->type)
{
//jff 02/08/98 slow down slow crushers on obstacle
case genCrusher:
case genSilentCrusher:
if (ceiling->oldspeed < CEILSPEED * 3)
ceiling->speed = CEILSPEED / 8;
break;
case silentCrushAndRaise:
case crushAndRaise:
case lowerAndCrush:
ceiling->speed = CEILSPEED / 8;
break;
default:
break;
}
}
}
break;
}
}
//
// EV_DoCeiling
//
// Move a ceiling up/down or start a crusher
//
// Passed the linedef activating the function and the type of function desired
// returns true if a thinker started
//
int EV_DoCeiling(const line_t *line, ceiling_e type)
{
int secnum;
int rtn;
sector_t *sec;
ceiling_t *ceiling;
secnum = -1;
rtn = 0;
// Reactivate in-stasis ceilings...for certain types.
// This restarts a crusher after it has been stopped
switch (type)
{
case fastCrushAndRaise:
case silentCrushAndRaise:
case crushAndRaise:
//jff 4/5/98 return if activated
rtn = P_ActivateInStasisCeiling(line);
default:
break;
}
// affects all sectors with the same tag as the linedef
while ((secnum = P_FindSectorFromLineTag(line, secnum)) >= 0)
{
sec = &_g->sectors[secnum];
// if ceiling already moving, don't start a second function on it
if (P_SectorActive(ceiling_special, sec)) //jff 2/22/98
continue;
// create a new ceiling thinker
rtn = 1;
ceiling = Z_Malloc(sizeof(*ceiling), PU_LEVSPEC, 0);
memset(ceiling, 0, sizeof(*ceiling));
P_AddThinker(&ceiling->thinker);
sec->ceilingdata_sptr = getShortPtr(ceiling); //jff 2/22/98
ceiling->thinker.function = T_MoveCeiling;
ceiling->sector = sec;
ceiling->crush = false;
// setup ceiling structure according to type of function
switch (type)
{
case fastCrushAndRaise:
ceiling->crush = true;
ceiling->topheight = sec->ceilingheight;
ceiling->bottomheight = sec->floorheight + (8 * FRACUNIT);
ceiling->direction = -1;
ceiling->speed = CEILSPEED * 2;
break;
case silentCrushAndRaise:
case crushAndRaise:
ceiling->crush = true;
ceiling->topheight = sec->ceilingheight;
case lowerAndCrush:
case lowerToFloor:
ceiling->bottomheight = sec->floorheight;
if (type != lowerToFloor)
ceiling->bottomheight += 8 * FRACUNIT;
ceiling->direction = -1;
ceiling->speed = CEILSPEED;
break;
case raiseToHighest:
ceiling->topheight = P_FindHighestCeilingSurrounding(sec);
ceiling->direction = 1;
ceiling->speed = CEILSPEED;
break;
case lowerToLowest:
ceiling->bottomheight = P_FindLowestCeilingSurrounding(sec);
ceiling->direction = -1;
ceiling->speed = CEILSPEED;
break;
case lowerToMaxFloor:
ceiling->bottomheight = P_FindHighestFloorSurrounding(sec);
ceiling->direction = -1;
ceiling->speed = CEILSPEED;
break;
default:
break;
}
// add the ceiling to the active list
ceiling->tag = sec->tag;
ceiling->type = type;
P_AddActiveCeiling(ceiling);
}
return rtn;
}
//////////////////////////////////////////////////////////////////////
//
// Active ceiling list primitives
//
/////////////////////////////////////////////////////////////////////
// jff 2/22/98 - modified Lee's plat code to work for ceilings
//
// The following were all rewritten by Lee Killough
// to use the new structure which places no limits
// on active ceilings. It also avoids spending as much
// time searching for active ceilings. Previously a
// fixed-size array was used, with NULL indicating
// empty entries, while now a doubly-linked list
// is used.
//
// P_ActivateInStasisCeiling()
//
// Reactivates all stopped crushers with the right tag
//
// Passed the line reactivating the crusher
// Returns true if a ceiling reactivated
//
//jff 4/5/98 return if activated
int P_ActivateInStasisCeiling(const line_t *line)
{
ceilinglist_t *cl;
int rtn = 0;
for (cl = _g->activeceilings; cl; cl = cl->next)
{
ceiling_t *ceiling = cl->ceiling;
if (ceiling->tag == line->tag && ceiling->direction == 0)
{
ceiling->direction = ceiling->olddirection;
ceiling->thinker.function = T_MoveCeiling;
//jff 4/5/98 return if activated
rtn = 1;
}
}
return rtn;
}
//
// EV_CeilingCrushStop()
//
// Stops all active ceilings with the right tag
//
// Passed the linedef stopping the ceilings
// Returns true if a ceiling put in stasis
//
int EV_CeilingCrushStop(const line_t *line)
{
int rtn = 0;
ceilinglist_t *cl;
for (cl = _g->activeceilings; cl; cl = cl->next)
{
ceiling_t *ceiling = cl->ceiling;
if (ceiling->direction != 0 && ceiling->tag == line->tag)
{
ceiling->olddirection = ceiling->direction;
ceiling->direction = 0;
ceiling->thinker.function = NULL;
rtn = 1;
}
}
return rtn;
}
//
// P_AddActiveCeiling()
//
// Adds a ceiling to the head of the list of active ceilings
//
// Passed the ceiling motion structure
// Returns nothing
//
void P_AddActiveCeiling(ceiling_t *ceiling)
{
ceilinglist_t *old_head = _g->activeceilings;
ceilinglist_t *list = Z_Malloc(sizeof *list, PU_LEVEL, (void** ) &_g->activeceilings);
list->ceiling = ceiling;
ceiling->list = list;
if ((list->next = old_head))
list->next->prev = &list->next;
list->prev = (ceilinglist_t**) old_head;
}
//
// P_RemoveActiveCeiling()
//
// Removes a ceiling from the list of active ceilings
//
// Passed the ceiling motion structure
// Returns nothing
//
void P_RemoveActiveCeiling(ceiling_t *ceiling)
{
ceilinglist_t *list = ceiling->list;
ceiling->sector->ceilingdata_sptr = 0; //jff 2/22/98
P_RemoveThinker(&ceiling->thinker);
if ((list->prev && (*list->prev = list->next)))
list->next->prev = list->prev;
free(list);
}
//
// P_RemoveAllActiveCeilings()
//
// Removes all ceilings from the active ceiling list
//
// Passed nothing, returns nothing
//
void P_RemoveAllActiveCeilings(void)
{
while (_g->activeceilings)
{
ceilinglist_t *next = _g->activeceilings->next;
free(_g->activeceilings);
_g->activeceilings = next;
}
}
+679
View File
@@ -0,0 +1,679 @@
/**
* Doom Port to the nRF52840 by Nicola Wrachien (next-hack in the comments)
*
* This port is based on the excellent doomhack's GBA Doom Port,
* with Kippykip additions.
*
* Several data structures and functions have been optimized
* to fit in only 256kB RAM of nRF52840 (GBA has 384 kB RAM).
* Z-Depth Light has been restored with almost no RAM consumption!
* Tons of speed optimizations have been done, and the game now
* runs extremely fast, despite the much higher 3D resolution with
* respect to GBA.
*
* PrBoom: a Doom port merged with LxDoom and LSDLDoom
* based on BOOM, a modified and improved DOOM engine
* Copyright (C) 1999 by
* id Software, Chi Hoang, Lee Killough, Jim Flynn, Rand Phares, Ty Halderman
* Copyright (C) 1999-2000 by
* Jess Haas, Nicolas Kalkhof, Colin Phipps, Florian Schulze
* Copyright 2005, 2006 by
* Florian Schulze, Colin Phipps, Neil Stevens, Andrey Budko
* Copyright (C) 2021 Nicola Wrachien (next-hack in the comments)
* on nRF52840 port.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
* 02111-1307, USA.
*
*
* DESCRIPTION:
* Door animation code (opening/closing)
*
* next-hack: modified code to work with short pointers.
*-----------------------------------------------------------------------------*/
#include "doomstat.h"
#include "p_spec.h"
#include "p_tick.h"
#include "s_sound.h"
#include "sounds.h"
#include "r_main.h"
#include "dstrings.h"
#include "lprintf.h"
#include "global_data.h"
///////////////////////////////////////////////////////////////
//
// Door action routines, called once per tick
//
///////////////////////////////////////////////////////////////
//
// T_VerticalDoor
//
// Passed a door structure containing all info about the door.
// See P_SPEC.H for fields.
// Returns nothing.
//
// jff 02/08/98 all cases with labels beginning with gen added to support
// generalized line type behaviors.
void T_VerticalDoor(vldoor_t *door)
{
result_e res;
// Is the door waiting, going up, or going down?
switch (door->direction)
{
case 0:
// Door is waiting
if (!--door->topcountdown) // downcount and check
{
switch (door->type)
{
case blazeRaise:
case genBlazeRaise:
door->direction = -1; // time to go back down
S_StartSound2(&door->sector->soundorg, sfx_bdcls);
break;
case normal:
case genRaise:
door->direction = -1; // time to go back down
S_StartSound2(&door->sector->soundorg, sfx_dorcls);
break;
case close30ThenOpen:
case genCdO:
door->direction = 1; // time to go back up
S_StartSound2(&door->sector->soundorg, sfx_doropn);
break;
case genBlazeCdO:
door->direction = 1; // time to go back up
S_StartSound2(&door->sector->soundorg, sfx_bdopn);
break;
default:
break;
}
}
break;
case 2:
// Special case for sector type door that opens in 5 mins
if (!--door->topcountdown) // 5 minutes up?
{
switch (door->type)
{
case raiseIn5Mins:
door->direction = 1; // time to raise then
door->type = normal; // door acts just like normal 1 DR door now
S_StartSound2(&door->sector->soundorg, sfx_doropn);
break;
default:
break;
}
}
break;
case -1:
// Door is moving down
res = T_MovePlane(door->sector, door->speed, door->sector->floorheight,
false, 1, door->direction);
/* killough 10/98: implement gradual lighting effects */
// e6y: "Tagged doors don't trigger special lighting" handled wrong
// http://sourceforge.net/tracker/index.php?func=detail&aid=1411400&group_id=148658&atid=772943
// Old code: if (door->lighttag && door->topheight - door->sector->floorheight)
if (door->lighttag && door->topheight - door->sector->floorheight)
EV_LightTurnOnPartway(door->line, FixedDiv(door->sector->ceilingheight - door->sector->floorheight, door->topheight - door->sector->floorheight));
// handle door reaching bottom
if (res == pastdest)
{
switch (door->type)
{
// regular open and close doors are all done, remove them
case blazeRaise:
case blazeClose:
case genBlazeRaise:
case genBlazeClose:
door->sector->ceilingdata_sptr = 0; //jff 2/22/98
P_RemoveThinker(&door->thinker); // unlink and free
// killough 4/15/98: remove double-closing sound of blazing doors
break;
case normal:
case dclose:
case genRaise:
case genClose:
door->sector->ceilingdata_sptr = 0; //jff 2/22/98
P_RemoveThinker(&door->thinker); // unlink and free
break;
// close then open doors start waiting
case close30ThenOpen:
door->direction = 0;
door->topcountdown = TICRATE * 30;
break;
case genCdO:
case genBlazeCdO:
door->direction = 0;
door->topcountdown = door->topwait; // jff 5/8/98 insert delay
break;
default:
break;
}
}
/* jff 1/31/98 turn lighting off in tagged sectors of manual doors
* killough 10/98: replaced with gradual lighting code
*/
else if (res == crushed) // handle door meeting obstruction on way down
{
switch (door->type)
{
case genClose:
case genBlazeClose:
case blazeClose:
case dclose: // Close types do not bounce, merely wait
break;
case blazeRaise:
case genBlazeRaise:
door->direction = 1;
S_StartSound2(&door->sector->soundorg, sfx_bdopn);
break;
default: // other types bounce off the obstruction
door->direction = 1;
S_StartSound2(&door->sector->soundorg, sfx_doropn);
break;
}
}
break;
case 1:
// Door is moving up
res = T_MovePlane(door->sector, door->speed, door->topheight,
false, 1, door->direction);
/* killough 10/98: implement gradual lighting effects */
// e6y: "Tagged doors don't trigger special lighting" handled wrong
// http://sourceforge.net/tracker/index.php?func=detail&aid=1411400&group_id=148658&atid=772943
// Old code: if (door->lighttag && door->topheight - door->sector->floorheight)
if (door->lighttag && door->topheight - door->sector->floorheight)
EV_LightTurnOnPartway(door->line, FixedDiv(door->sector->ceilingheight - door->sector->floorheight, door->topheight - door->sector->floorheight));
// handle door reaching the top
if (res == pastdest)
{
switch (door->type)
{
case blazeRaise: // regular open/close doors start waiting
case normal:
case genRaise:
case genBlazeRaise:
door->direction = 0; // wait at top with delay
door->topcountdown = door->topwait;
break;
case close30ThenOpen: // close and close/open doors are done
case blazeOpen:
case dopen:
case genBlazeOpen:
case genOpen:
case genCdO:
case genBlazeCdO:
door->sector->ceilingdata_sptr = 0; //jff 2/22/98
P_RemoveThinker(&door->thinker); // unlink and free
break;
default:
break;
}
}
break;
}
}
///////////////////////////////////////////////////////////////
//
// Door linedef handlers
//
///////////////////////////////////////////////////////////////
//
// EV_DoLockedDoor
//
// Handle opening a tagged locked door
//
// Passed the line activating the door, the type of door,
// and the thing that activated the line
// Returns true if a thinker created
//
int EV_DoLockedDoor(const line_t *line, vldoor_e type, mobj_t *thing)
{
player_t *p;
// only players can open locked doors
p = getMobjPlayer(thing);
if (!p)
return 0;
// check type of linedef, and if key is possessed to open it
switch (LN_SPECIAL(line))
{
case 99: // Blue Lock
case 133:
if (!p->cards[it_bluecard] && !p->cards[it_blueskull])
{
p->message = PD_BLUEO; // Ty 03/27/98 - externalized
S_StartSound(p->mo, sfx_oof); // killough 3/20/98
return 0;
}
break;
case 134: // Red Lock
case 135:
if (!p->cards[it_redcard] && !p->cards[it_redskull])
{
p->message = PD_REDO; // Ty 03/27/98 - externalized
S_StartSound(p->mo, sfx_oof); // killough 3/20/98
return 0;
}
break;
case 136: // Yellow Lock
case 137:
if (!p->cards[it_yellowcard] && !p->cards[it_yellowskull])
{
p->message = PD_YELLOWO; // Ty 03/27/98 - externalized
S_StartSound(p->mo, sfx_oof); // killough 3/20/98
return 0;
}
break;
}
// got the key, so open the door
return EV_DoDoor(line, type);
}
//
// EV_DoDoor
//
// Handle opening a tagged door
//
// Passed the line activating the door and the type of door
// Returns true if a thinker created
//
int EV_DoDoor(const line_t *line, vldoor_e type)
{
int secnum, rtn;
sector_t *sec;
vldoor_t *door;
secnum = -1;
rtn = 0;
// open all doors with the same tag as the activating line
while ((secnum = P_FindSectorFromLineTag(line, secnum)) >= 0)
{
sec = &_g->sectors[secnum];
// if the ceiling already moving, don't start the door action
if (P_SectorActive(ceiling_special, sec)) //jff 2/22/98
continue;
// new door thinker
rtn = 1;
door = Z_Malloc(sizeof(*door), PU_LEVSPEC, 0);
memset(door, 0, sizeof(*door));
P_AddThinker(&door->thinker);
sec->ceilingdata_sptr = getShortPtr(door); //jff 2/22/98
door->thinker.function = T_VerticalDoor;
door->sector = sec;
door->type = type;
door->topwait = VDOORWAIT;
door->speed = VDOORSPEED;
door->line = line; // jff 1/31/98 remember line that triggered us
door->lighttag = 0; /* killough 10/98: no light effects with tagged doors */
// setup door parameters according to type of door
switch (type)
{
case blazeClose:
door->topheight = P_FindLowestCeilingSurrounding(sec);
door->topheight -= 4 * FRACUNIT;
door->direction = -1;
door->speed = VDOORSPEED * 4;
S_StartSound2(&door->sector->soundorg, sfx_bdcls);
break;
case dclose:
door->topheight = P_FindLowestCeilingSurrounding(sec);
door->topheight -= 4 * FRACUNIT;
door->direction = -1;
S_StartSound2(&door->sector->soundorg, sfx_dorcls);
break;
case close30ThenOpen:
door->topheight = sec->ceilingheight;
door->direction = -1;
S_StartSound2(&door->sector->soundorg, sfx_dorcls);
break;
case blazeRaise:
case blazeOpen:
door->direction = 1;
door->topheight = P_FindLowestCeilingSurrounding(sec);
door->topheight -= 4 * FRACUNIT;
door->speed = VDOORSPEED * 4;
if (door->topheight != sec->ceilingheight)
S_StartSound2(&door->sector->soundorg, sfx_bdopn);
break;
case normal:
case dopen:
door->direction = 1;
door->topheight = P_FindLowestCeilingSurrounding(sec);
door->topheight -= 4 * FRACUNIT;
if (door->topheight != sec->ceilingheight)
S_StartSound2(&door->sector->soundorg, sfx_doropn);
break;
default:
break;
}
}
return rtn;
}
//
// EV_VerticalDoor
//
// Handle opening a door manually, no tag value
//
// Passed the line activating the door and the thing activating it
// Returns true if a thinker created
//
// jff 2/12/98 added int return value, fixed all returns
//
int EV_VerticalDoor(const line_t *line, mobj_t *thing)
{
player_t *player;
//int secnum;
sector_t *sec;
vldoor_t *door;
// Check for locks
player = getMobjPlayer(thing);
switch (LN_SPECIAL(line))
{
case 26: // Blue Lock
case 32:
if (!player)
return 0;
if (!player->cards[it_bluecard] && !player->cards[it_blueskull])
{
player->message = PD_BLUEK; // Ty 03/27/98 - externalized
S_StartSound(player->mo, sfx_oof); // killough 3/20/98
return 0;
}
break;
case 27: // Yellow Lock
case 34:
if (!player)
return 0;
if (!player->cards[it_yellowcard] && !player->cards[it_yellowskull])
{
player->message = PD_YELLOWK; // Ty 03/27/98 - externalized
S_StartSound(player->mo, sfx_oof); // killough 3/20/98
return 0;
}
break;
case 28: // Red Lock
case 33:
if (!player)
return 0;
if (!player->cards[it_redcard] && !player->cards[it_redskull])
{
player->message = PD_REDK; // Ty 03/27/98 - externalized
S_StartSound(player->mo, sfx_oof); // killough 3/20/98
return 0;
}
break;
default:
break;
}
// if the wrong side of door is pushed, give oof sound
if (line->sidenum[1] == NO_INDEX) // killough
{
S_StartSound(player->mo, sfx_oof); // killough 3/20/98
return 0;
}
// get the sector on the second side of activating linedef
sec = &_g->sectors[_g->sides[line->sidenum[1]].sector_num];
//secnum = sec-_g->sectors;
/* if door already has a thinker, use it
* cph 2001/04/05 -
* Ok, this is a disaster area. We're assuming that sec->ceilingdata
* is a vldoor_t! What if this door is controlled by both DR lines
* and by switches? I don't know how to fix that.
* Secondly, original Doom didn't distinguish floor/lighting/ceiling
* actions, so we need to do the same in demo compatibility mode.
*/
door = getSectorCeilingData(sec);
/* If this is a repeatable line, and the door is already moving, then we can just reverse the current action. Note that in prboom 2.3.0 I erroneously removed the if-this-is-repeatable check, hence the prboom_4_compatibility clause below (foolishly assumed that already moving implies repeatable - but it could be moving due to another switch, e.g. lv19-509) */
if (door && ((LN_SPECIAL(line) == 1) || (LN_SPECIAL(line) == 117) || (LN_SPECIAL(line) == 26) || (LN_SPECIAL(line) == 27) || (LN_SPECIAL(line) == 28)))
{
/* For old demos we have to emulate the old buggy behavior and
* mess up non-T_VerticalDoor actions.
*/
if (door->thinker.function == T_VerticalDoor)
{
/* cph - we are writing outval to door->direction iff it is non-zero */
signed int outval = 0;
/* An already moving repeatable door which is being re-pressed, or a
* monster is trying to open a closing door - so change direction
* DEMOSYNC: we only read door->direction now if it really is a door.
*/
if (door->thinker.function == T_VerticalDoor && door->direction == -1)
{
outval = 1; /* go back up */
}
else if (player)
{
outval = -1; /* go back down */
}
/* Write this to the thinker. In demo compatibility mode, we might be
* overwriting a field of a non-vldoor_t thinker - we need to add any
* other thinker types here if any demos depend on specific fields
* being corrupted by this.
*/
if (outval)
{
if (door->thinker.function == T_VerticalDoor)
{
door->direction = outval;
}
else if (door->thinker.function == T_PlatRaise)
{
plat_t *p = (plat_t*) door;
p->wait = outval;
}
else
{
lprintf(LO_DEBUG, "EV_VerticalDoor: unknown thinker.function in thinker corruption emulation");
}
return 1;
}
}
/* Either we're in prboom >=v2.3 and it's not a door, or it's a door but
* we're a monster and don't want to shut it; exit with no action.
*/
return 0;
}
// emit proper sound
switch (LN_SPECIAL(line))
{
case 117: // blazing door raise
case 118: // blazing door open
S_StartSound2(&sec->soundorg, sfx_bdopn);
break;
default: // normal or locked door sound
S_StartSound2(&sec->soundorg, sfx_doropn);
break;
}
// new door thinker
door = Z_Malloc(sizeof(*door), PU_LEVSPEC, 0);
memset(door, 0, sizeof(*door));
P_AddThinker(&door->thinker);
sec->ceilingdata_sptr = getShortPtr(door); //jff 2/22/98
door->thinker.function = T_VerticalDoor;
door->sector = sec;
door->direction = 1;
door->speed = VDOORSPEED;
door->topwait = VDOORWAIT;
door->line = line; // jff 1/31/98 remember line that triggered us
/* killough 10/98: use gradual lighting changes if nonzero tag given */
door->lighttag = line->tag;
// set the type of door from the activating linedef type
switch (LN_SPECIAL(line))
{
case 1:
case 26:
case 27:
case 28:
door->type = normal;
break;
case 31:
case 32:
case 33:
case 34:
door->type = dopen;
LN_SPECIAL(line) = 0;
break;
case 117: // blazing door raise
door->type = blazeRaise;
door->speed = VDOORSPEED * 4;
break;
case 118: // blazing door open
door->type = blazeOpen;
LN_SPECIAL(line) = 0;
door->speed = VDOORSPEED * 4;
break;
default:
door->lighttag = 0; // killough 10/98
break;
}
// find the top and bottom of the movement range
door->topheight = P_FindLowestCeilingSurrounding(sec);
door->topheight -= 4 * FRACUNIT;
return 1;
}
///////////////////////////////////////////////////////////////
//
// Sector type door spawners
//
///////////////////////////////////////////////////////////////
//
// P_SpawnDoorCloseIn30()
//
// Spawn a door that closes after 30 seconds (called at level init)
//
// Passed the sector of the door, whose type specified the door action
// Returns nothing
//
void P_SpawnDoorCloseIn30(sector_t *sec)
{
vldoor_t *door;
door = Z_Malloc(sizeof(*door), PU_LEVSPEC, 0);
memset(door, 0, sizeof(*door));
P_AddThinker(&door->thinker);
sec->ceilingdata_sptr = getShortPtr(door); //jff 2/22/98
sec->special = 0;
door->thinker.function = T_VerticalDoor;
door->sector = sec;
door->direction = 0;
door->type = normal;
door->speed = VDOORSPEED;
door->topcountdown = 30 * 35;
door->line = NULL; // jff 1/31/98 remember line that triggered us
door->lighttag = 0; /* killough 10/98: no lighting changes */
}
//
// P_SpawnDoorRaiseIn5Mins()
//
// Spawn a door that opens after 5 minutes (called at level init)
//
// Passed the sector of the door, whose type specified the door action
// Returns nothing
//
void P_SpawnDoorRaiseIn5Mins(sector_t *sec, int secnum)
{
vldoor_t *door;
door = Z_Malloc(sizeof(*door), PU_LEVSPEC, 0);
memset(door, 0, sizeof(*door));
P_AddThinker(&door->thinker);
sec->ceilingdata_sptr = getShortPtr(door); //jff 2/22/98
sec->special = 0;
door->thinker.function = T_VerticalDoor;
door->sector = sec;
door->direction = 2;
door->type = raiseIn5Mins;
door->speed = VDOORSPEED;
door->topheight = P_FindLowestCeilingSurrounding(sec);
door->topheight -= 4 * FRACUNIT;
door->topwait = VDOORWAIT;
door->topcountdown = 5 * 60 * 35;
door->line = NULL; // jff 1/31/98 remember line that triggered us
door->lighttag = 0; /* killough 10/98: no lighting changes */
}
File diff suppressed because it is too large. Load diff
+933
View File
@@ -0,0 +1,933 @@
/**
* Doom Port to the nRF52840 by Nicola Wrachien (next-hack in the comments)
*
* This port is based on the excellent doomhack's GBA Doom Port,
* with Kippykip additions.
*
* Several data structures and functions have been optimized
* to fit in only 256kB RAM of nRF52840 (GBA has 384 kB RAM).
* Z-Depth Light has been restored with almost no RAM consumption!
* Tons of speed optimizations have been done, and the game now
* runs extremely fast, despite the much higher 3D resolution with
* respect to GBA.
*
* PrBoom: a Doom port merged with LxDoom and LSDLDoom
* based on BOOM, a modified and improved DOOM engine
* Copyright (C) 1999 by
* id Software, Chi Hoang, Lee Killough, Jim Flynn, Rand Phares, Ty Halderman
* Copyright (C) 1999-2000 by
* Jess Haas, Nicolas Kalkhof, Colin Phipps, Florian Schulze
* Copyright 2005, 2006 by
* Florian Schulze, Colin Phipps, Neil Stevens, Andrey Budko
* Copyright (C) 2021 Nicola Wrachien (next-hack in the comments)
* on nRF52840 port.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
* 02111-1307, USA.
*
* DESCRIPTION:
* General plane mover and floor mover action routines
* Floor motion, pure changer types, raising stairs. donuts, elevators
*
* next-hack: modified code to work with short pointers.
*
*-----------------------------------------------------------------------------*/
#include "doomstat.h"
#include "r_main.h"
#include "p_map.h"
#include "p_spec.h"
#include "p_tick.h"
#include "s_sound.h"
#include "sounds.h"
#include "global_data.h"
///////////////////////////////////////////////////////////////////////
//
// Plane (floor or ceiling), Floor motion and Elevator action routines
//
///////////////////////////////////////////////////////////////////////
//
// T_MovePlane()
//
// Move a plane (floor or ceiling) and check for crushing. Called
// every tick by all actions that move floors or ceilings.
//
// Passed the sector to move a plane in, the speed to move it at,
// the dest height it is to achieve, whether it crushes obstacles,
// whether it moves a floor or ceiling, and the direction up or down
// to move.
//
// Returns a result_e:
// ok - plane moved normally, has not achieved destination yet
// pastdest - plane moved normally and is now at destination height
// crushed - plane encountered an obstacle, is holding until removed
//
result_e T_MovePlane(sector_t *sector, fixed_t speed, fixed_t dest, boolean crush, int floorOrCeiling, int direction)
{
boolean flag;
fixed_t lastpos;
fixed_t destheight; //jff 02/04/98 used to keep floors/ceilings
// from moving thru each other
switch (floorOrCeiling)
{
case 0:
// Moving a floor
switch (direction)
{
case -1:
// Moving a floor down
if (sector->floorheight - speed < dest)
{
lastpos = sector->floorheight;
sector->floorheight = dest;
flag = P_CheckSector(sector, crush); //jff 3/19/98 use faster chk
if (flag == true)
{
sector->floorheight = lastpos;
P_CheckSector(sector, crush); //jff 3/19/98 use faster chk
}
return pastdest;
}
else
{
lastpos = sector->floorheight;
sector->floorheight -= speed;
flag = P_CheckSector(sector, crush); //jff 3/19/98 use faster chk
/* cph - make more compatible with original Doom, by
* reintroducing this code. This means floors can't lower
* if objects are stuck in the ceiling */
}
break;
case 1:
// Moving a floor up
// jff 02/04/98 keep floor from moving thru ceilings
// jff 2/22/98 weaken check to demo_compatibility
destheight =
(dest < sector->ceilingheight) ? dest : sector->ceilingheight;
if (sector->floorheight + speed > destheight)
{
lastpos = sector->floorheight;
sector->floorheight = destheight;
flag = P_CheckSector(sector, crush); //jff 3/19/98 use faster chk
if (flag == true)
{
sector->floorheight = lastpos;
P_CheckSector(sector, crush); //jff 3/19/98 use faster chk
}
return pastdest;
}
else
{
// crushing is possible
lastpos = sector->floorheight;
sector->floorheight += speed;
flag = P_CheckSector(sector, crush); //jff 3/19/98 use faster chk
if (flag == true)
{
sector->floorheight = lastpos;
P_CheckSector(sector, crush); //jff 3/19/98 use faster chk
return crushed;
}
}
break;
}
break;
case 1:
// moving a ceiling
switch (direction)
{
case -1:
// moving a ceiling down
// jff 02/04/98 keep ceiling from moving thru floors
// jff 2/22/98 weaken check to demo_compatibility
destheight =
(dest > sector->floorheight) ? dest : sector->floorheight;
if (sector->ceilingheight - speed < destheight)
{
lastpos = sector->ceilingheight;
sector->ceilingheight = destheight;
flag = P_CheckSector(sector, crush); //jff 3/19/98 use faster chk
if (flag == true)
{
sector->ceilingheight = lastpos;
P_CheckSector(sector, crush); //jff 3/19/98 use faster chk
}
return pastdest;
}
else
{
// crushing is possible
lastpos = sector->ceilingheight;
sector->ceilingheight -= speed;
flag = P_CheckSector(sector, crush); //jff 3/19/98 use faster chk
if (flag == true)
{
if (crush == true)
return crushed;
sector->ceilingheight = lastpos;
P_CheckSector(sector, crush); //jff 3/19/98 use faster chk
return crushed;
}
}
break;
case 1:
// moving a ceiling up
if (sector->ceilingheight + speed > dest)
{
lastpos = sector->ceilingheight;
sector->ceilingheight = dest;
flag = P_CheckSector(sector, crush); //jff 3/19/98 use faster chk
if (flag == true)
{
sector->ceilingheight = lastpos;
P_CheckSector(sector, crush); //jff 3/19/98 use faster chk
}
return pastdest;
}
else
{
lastpos = sector->ceilingheight;
sector->ceilingheight += speed;
flag = P_CheckSector(sector, crush); //jff 3/19/98 use faster chk
}
break;
}
break;
}
return ok;
}
//
// T_MoveFloor()
//
// Move a floor to it's destination (up or down).
// Called once per tick for each moving floor.
//
// Passed a floormove_t structure that contains all pertinent info about the
// move. See P_SPEC.H for fields.
// No return.
//
// jff 02/08/98 all cases with labels beginning with gen added to support
// generalized line type behaviors.
void T_MoveFloor(floormove_t *floor)
{
result_e res;
res = T_MovePlane // move the floor
(getFloorMoveSector(floor), floor->speed, floor->floordestheight, floor->crush, 0, floor->direction);
if (!(_g->leveltime & 7)) // make the floormove sound
S_StartSound2(&getFloorMoveSector(floor)->soundorg, sfx_stnmov);
if (res == pastdest) // if destination height is reached
{
if (floor->direction == 1) // going up
{
switch (floor->type)
// handle texture/type changes
{
case donutRaise:
getFloorMoveSector(floor)->special = floor->newspecial;
getFloorMoveSector(floor)->floorpic = floor->texture;
break;
case genFloorChgT:
case genFloorChg0:
getFloorMoveSector(floor)->special = floor->newspecial;
//jff add to fix bug in special transfers from changes
getFloorMoveSector(floor)->oldspecial = floor->oldspecial;
// fall through
case genFloorChg:
getFloorMoveSector(floor)->floorpic = floor->texture;
break;
default:
break;
}
}
else if (floor->direction == -1) // going down
{
switch (floor->type)
// handle texture/type changes
{
case lowerAndChange:
getFloorMoveSector(floor)->special = floor->newspecial;
//jff add to fix bug in special transfers from changes
getFloorMoveSector(floor)->oldspecial = floor->oldspecial;
getFloorMoveSector(floor)->floorpic = floor->texture;
break;
case genFloorChgT:
case genFloorChg0:
getFloorMoveSector(floor)->special = floor->newspecial;
//jff add to fix bug in special transfers from changes
getFloorMoveSector(floor)->oldspecial = floor->oldspecial;
//fall thru
case genFloorChg:
getFloorMoveSector(floor)->floorpic = floor->texture;
break;
default:
break;
}
}
getFloorMoveSector(floor)->floordata_sptr = 0; //jff 2/22/98
P_RemoveThinker(&floor->thinker); //remove this floor from list of movers
// make floor stop sound
S_StartSound2(&getFloorMoveSector(floor)->soundorg, sfx_pstop);
}
}
//
// T_MoveElevator()
//
// Move an elevator to it's destination (up or down)
// Called once per tick for each moving floor.
//
// Passed an elevator_t structure that contains all pertinent info about the
// move. See P_SPEC.H for fields.
// No return.
//
// jff 02/22/98 added to support parallel floor/ceiling motion
//
void T_MoveElevator(elevator_t *elevator)
{
result_e res;
if (elevator->direction < 0) // moving down
{
res = T_MovePlane //jff 4/7/98 reverse order of ceiling/floor
(elevator->sector, elevator->speed, elevator->ceilingdestheight, 0, 1, // move floor
elevator->direction);
if (res == ok || res == pastdest) // jff 4/7/98 don't move ceil if blocked
T_MovePlane(elevator->sector, elevator->speed, elevator->floordestheight, 0, 0, // move ceiling
elevator->direction);
}
else // up
{
res = T_MovePlane //jff 4/7/98 reverse order of ceiling/floor
(elevator->sector, elevator->speed, elevator->floordestheight, 0, 0, // move ceiling
elevator->direction);
if (res == ok || res == pastdest) // jff 4/7/98 don't move floor if blocked
T_MovePlane(elevator->sector, elevator->speed, elevator->ceilingdestheight, 0, 1, // move floor
elevator->direction);
}
// make floor move sound
if (!(_g->leveltime & 7))
S_StartSound2(&elevator->sector->soundorg, sfx_stnmov);
if (res == pastdest) // if destination height acheived
{
elevator->sector->floordata_sptr = 0; //jff 2/22/98
elevator->sector->ceilingdata_sptr = 0; //jff 2/22/98
P_RemoveThinker(&elevator->thinker); // remove elevator from actives
// make floor stop sound
S_StartSound2(&elevator->sector->soundorg, sfx_pstop);
}
}
///////////////////////////////////////////////////////////////////////
//
// Floor motion linedef handlers
//
///////////////////////////////////////////////////////////////////////
//
// EV_DoFloor()
//
// Handle regular and extended floor types
//
// Passed the line that activated the floor and the type of floor motion
// Returns true if a thinker was created.
//
int EV_DoFloor(const line_t *line, floor_e floortype)
{
int secnum;
int rtn;
int i;
sector_t *sec;
floormove_t *floor;
secnum = -1;
rtn = 0;
// move all floors with the same tag as the linedef
while ((secnum = P_FindSectorFromLineTag(line, secnum)) >= 0)
{
sec = &_g->sectors[secnum];
// Don't start a second thinker on the same floor
if (P_SectorActive(floor_special, sec)) //jff 2/23/98
continue;
// new floor thinker
rtn = 1;
floor = Z_Malloc(sizeof(*floor), PU_LEVSPEC, 0);
memset(floor, 0, sizeof(*floor));
P_AddThinker(&floor->thinker);
sec->floordata_sptr = getShortPtr(floor); //jff 2/22/98
floor->thinker.function = T_MoveFloor;
floor->type = floortype;
floor->crush = false;
// setup the thinker according to the linedef type
switch (floortype)
{
case lowerFloor:
floor->direction = -1;
floor->sector_sptr = getShortPtr(sec);
floor->speed = FLOORSPEED;
floor->floordestheight = P_FindHighestFloorSurrounding(sec);
break;
//jff 02/03/30 support lowering floor by 24 absolute
case lowerFloor24:
floor->direction = -1;
floor->sector_sptr = getShortPtr(sec);
floor->speed = FLOORSPEED;
floor->floordestheight = getFloorMoveSector(floor)->floorheight + 24 * FRACUNIT;
break;
//jff 02/03/30 support lowering floor by 32 absolute (fast)
case lowerFloor32Turbo:
floor->direction = -1;
floor->sector_sptr = getShortPtr(sec);
floor->speed = FLOORSPEED * 4;
floor->floordestheight = getFloorMoveSector(floor)->floorheight + 32 * FRACUNIT;
break;
case lowerFloorToLowest:
floor->direction = -1;
floor->sector_sptr = getShortPtr(sec);
floor->speed = FLOORSPEED;
floor->floordestheight = P_FindLowestFloorSurrounding(sec);
break;
//jff 02/03/30 support lowering floor to next lowest floor
case lowerFloorToNearest:
floor->direction = -1;
floor->sector_sptr = getShortPtr(sec);
floor->speed = FLOORSPEED;
floor->floordestheight = P_FindNextLowestFloor(sec, getFloorMoveSector(floor)->floorheight);
break;
case turboLower:
floor->direction = -1;
floor->sector_sptr = getShortPtr(sec);
floor->speed = FLOORSPEED * 4;
floor->floordestheight = P_FindHighestFloorSurrounding(sec);
if (floor->floordestheight != sec->floorheight)
floor->floordestheight += 8 * FRACUNIT;
break;
case raiseFloorCrush:
floor->crush = true;
case raiseFloor:
floor->direction = 1;
floor->sector_sptr = getShortPtr(sec);
floor->speed = FLOORSPEED;
floor->floordestheight = P_FindLowestCeilingSurrounding(sec);
if (floor->floordestheight > sec->ceilingheight)
floor->floordestheight = sec->ceilingheight;
floor->floordestheight -= (8 * FRACUNIT) * (floortype == raiseFloorCrush);
break;
case raiseFloorTurbo:
floor->direction = 1;
floor->sector_sptr = getShortPtr(sec);
floor->speed = FLOORSPEED * 4;
floor->floordestheight = P_FindNextHighestFloor(sec, sec->floorheight);
break;
case raiseFloorToNearest:
floor->direction = 1;
floor->sector_sptr = getShortPtr(sec);
floor->speed = FLOORSPEED;
floor->floordestheight = P_FindNextHighestFloor(sec, sec->floorheight);
break;
case raiseFloor24:
floor->direction = 1;
floor->sector_sptr = getShortPtr(sec);
floor->speed = FLOORSPEED;
floor->floordestheight = getFloorMoveSector(floor)->floorheight + 24 * FRACUNIT;
break;
// jff 2/03/30 support straight raise by 32 (fast)
case raiseFloor32Turbo:
floor->direction = 1;
floor->sector_sptr = getShortPtr(sec);
floor->speed = FLOORSPEED * 4;
floor->floordestheight = getFloorMoveSector(floor)->floorheight + 32 * FRACUNIT;
break;
case raiseFloor512:
floor->direction = 1;
floor->sector_sptr = getShortPtr(sec);
floor->speed = FLOORSPEED;
floor->floordestheight = getFloorMoveSector(floor)->floorheight + 512 * FRACUNIT;
break;
case raiseFloor24AndChange:
floor->direction = 1;
floor->sector_sptr = getShortPtr(sec);
floor->speed = FLOORSPEED;
floor->floordestheight = getFloorMoveSector(floor)->floorheight + 24 * FRACUNIT;
sec->floorpic = LN_FRONTSECTOR(line)->floorpic;
sec->special = LN_FRONTSECTOR(line)->special;
//jff 3/14/98 transfer both old and new special
sec->oldspecial = LN_FRONTSECTOR(line)->oldspecial;
break;
case raiseToTexture:
{
int minsize = INT_MAX;
side_t *side;
/* jff 3/13/98 no ovf */
minsize = 32000 << FRACBITS;
floor->direction = 1;
floor->sector_sptr = getShortPtr(sec);
floor->speed = FLOORSPEED;
for (i = 0; i < sec->linecount; i++)
{
if (twoSided(secnum, i))
{
side = getSide(secnum, i, 0);
// jff 8/14/98 don't scan texture 0, its not real
if (side->bottomtexture > 0)
if (textureheight[side->bottomtexture] < minsize)
minsize = textureheight[side->bottomtexture];
side = getSide(secnum, i, 1);
// jff 8/14/98 don't scan texture 0, its not real
if (side->bottomtexture > 0)
if (textureheight[side->bottomtexture] < minsize)
minsize = textureheight[side->bottomtexture];
}
}
{
floor->floordestheight = (getFloorMoveSector(floor)->floorheight >> FRACBITS) + (minsize >> FRACBITS);
if (floor->floordestheight > 32000)
floor->floordestheight = 32000; //jff 3/13/98 do not
floor->floordestheight <<= FRACBITS; // allow height overflow
}
}
break;
case lowerAndChange:
floor->direction = -1;
floor->sector_sptr = getShortPtr(sec);
floor->speed = FLOORSPEED;
floor->floordestheight = P_FindLowestFloorSurrounding(sec);
floor->texture = sec->floorpic;
// jff 1/24/98 make sure floor->newspecial gets initialized
// in case no surrounding sector is at floordestheight
// --> should not affect compatibility <--
floor->newspecial = sec->special;
//jff 3/14/98 transfer both old and new special
floor->oldspecial = sec->oldspecial;
//jff 5/23/98 use model subroutine to unify fixes and handling
sec = P_FindModelFloorSector(floor->floordestheight, sec - _g->sectors);
if (sec)
{
floor->texture = sec->floorpic;
floor->newspecial = sec->special;
//jff 3/14/98 transfer both old and new special
floor->oldspecial = sec->oldspecial;
}
break;
default:
break;
}
}
return rtn;
}
//
// EV_DoChange()
//
// Handle pure change types. These change floor texture and sector type
// by trigger or numeric model without moving the floor.
//
// The linedef causing the change and the type of change is passed
// Returns true if any sector changes
//
// jff 3/15/98 added to better support generalized sector types
//
int EV_DoChange(const line_t *line, change_e changetype)
{
int secnum;
int rtn;
sector_t *sec;
sector_t *secm;
secnum = -1;
rtn = 0;
// change all sectors with the same tag as the linedef
while ((secnum = P_FindSectorFromLineTag(line, secnum)) >= 0)
{
sec = &_g->sectors[secnum];
rtn = 1;
// handle trigger or numeric change type
switch (changetype)
{
case trigChangeOnly:
sec->floorpic = LN_FRONTSECTOR(line)->floorpic;
sec->special = LN_FRONTSECTOR(line)->special;
sec->oldspecial = LN_FRONTSECTOR(line)->oldspecial;
break;
case numChangeOnly:
secm = P_FindModelFloorSector(sec->floorheight, secnum);
if (secm) // if no model, no change
{
sec->floorpic = secm->floorpic;
sec->special = secm->special;
sec->oldspecial = secm->oldspecial;
}
break;
default:
break;
}
}
return rtn;
}
/*
* EV_BuildStairs()
*
* Handles staircase building. A sequence of sectors chosen by algorithm
* rise at a speed indicated to a height that increases by the stepsize
* each step.
*
* Passed the linedef triggering the stairs and the type of stair rise
* Returns true if any thinkers are created
*
* cph 2001/09/21 - compatibility nightmares again
* There are three different ways this function has, during its history, stepped
* through all the stairs to be triggered by the single switch
* - original Doom used a linear P_FindSectorFromLineTag, but failed to preserve
* the index of the previous sector found, so instead it would restart its
* linear search from the last sector of the previous staircase
* - MBF/PrBoom with comp_stairs fail to emulate this, because their
* P_FindSectorFromLineTag is a chained hash table implementation. Instead they
* start following the hash chain from the last sector of the previous
* staircase, which will (probably) have the wrong tag, so they miss any further
* stairs
* - Boom fixed the bug, and MBF/PrBoom without comp_stairs work right
*/
static inline int P_FindSectorFromLineTagWithLowerBound(const line_t *l, int start, int min)
{
/* Emulate original Doom's linear lower-bounded P_FindSectorFromLineTag
* as needed */
do
{
start = P_FindSectorFromLineTag(l, start);
} while (start >= 0 && start <= min);
return start;
}
int EV_BuildStairs(const line_t *line, stair_e type)
{
/* cph 2001/09/22 - cleaned up this function to save my sanity. A separate
* outer loop index makes the logic much cleared, and local variables moved
* into the inner blocks helps too */
int ssec = -1;
int minssec = -1;
int rtn = 0;
// start a stair at each sector tagged the same as the linedef
while ((ssec = P_FindSectorFromLineTagWithLowerBound(line, ssec, minssec)) >= 0)
{
int secnum = ssec;
sector_t *sec = &_g->sectors[secnum];
// don't start a stair if the first step's floor is already moving
if (!P_SectorActive(floor_special, sec))
{ //jff 2/22/98
floormove_t *floor;
int texture, height;
fixed_t stairsize;
fixed_t speed;
int ok;
// create new floor thinker for first step
rtn = 1;
floor = Z_Malloc(sizeof(*floor), PU_LEVSPEC, 0);
memset(floor, 0, sizeof(*floor));
P_AddThinker(&floor->thinker);
sec->floordata_sptr = getShortPtr(floor);
floor->thinker.function = T_MoveFloor;
floor->direction = 1;
floor->sector_sptr = getShortPtr(sec);
floor->type = buildStair; //jff 3/31/98 do not leave uninited
// set up the speed and stepsize according to the stairs type
switch (type)
{
default: // killough -- prevent compiler warning
case build8:
speed = FLOORSPEED / 4;
stairsize = 8 * FRACUNIT;
floor->crush = false; //jff 2/27/98 fix uninitialized crush field
break;
case turbo16:
speed = FLOORSPEED * 4;
stairsize = 16 * FRACUNIT;
floor->crush = true; //jff 2/27/98 fix uninitialized crush field
break;
}
floor->speed = speed;
height = sec->floorheight + stairsize;
floor->floordestheight = height;
texture = sec->floorpic;
// Find next sector to raise
// 1. Find 2-sided line with same sector side[0] (lowest numbered)
// 2. Other side is the next sector to raise
// 3. Unless already moving, or different texture, then stop building
do
{
int i;
ok = 0;
for (i = 0; i < sec->linecount; i++)
{
// sector_t* tsec = LN_FRONTSECTOR((sec->lines[i]));
sector_t *tsec = LN_FRONTSECTOR(getSectorLineByIndex(sec, i));
int newsecnum;
if (!(getSectorLineByIndex(sec, i)->flags & ML_TWOSIDED))
continue;
newsecnum = tsec - _g->sectors;
if (secnum != newsecnum)
continue;
tsec = LN_BACKSECTOR((getSectorLineByIndex(sec, i)));
if (!tsec)
continue; //jff 5/7/98 if no backside, continue
newsecnum = tsec - _g->sectors;
// if sector's floor is different texture, look for another
if (tsec->floorpic != texture)
continue;
// if sector's floor already moving, look for another
if (P_SectorActive(floor_special, tsec)) //jff 2/22/98
continue;
height += stairsize;
sec = tsec;
secnum = newsecnum;
// create and initialize a thinker for the next step
floor = Z_Malloc(sizeof(*floor), PU_LEVSPEC, 0);
memset(floor, 0, sizeof(*floor));
P_AddThinker(&floor->thinker);
sec->floordata_sptr = getShortPtr(floor); //jff 2/22/98
floor->thinker.function = T_MoveFloor;
floor->direction = 1;
floor->sector_sptr = getShortPtr(sec);
floor->speed = speed;
floor->floordestheight = height;
floor->type = buildStair; //jff 3/31/98 do not leave uninited
//jff 2/27/98 fix uninitialized crush field
floor->crush = type == build8 ? false : true;
ok = 1;
break;
}
} while (ok); // continue until no next step is found
}
}
return rtn;
}
//
// EV_DoDonut()
//
// Handle donut function: lower pillar, raise surrounding pool, both to height,
// texture and type of the sector surrounding the pool.
//
// Passed the linedef that triggered the donut
// Returns whether a thinker was created
//
int EV_DoDonut(const line_t *line)
{
sector_t *s1;
sector_t *s2;
sector_t *s3;
int secnum;
int rtn;
int i;
floormove_t *floor;
secnum = -1;
rtn = 0;
// do function on all sectors with same tag as linedef
while ((secnum = P_FindSectorFromLineTag(line, secnum)) >= 0)
{
s1 = &_g->sectors[secnum]; // s1 is pillar's sector
// do not start the donut if the pillar is already moving
if (P_SectorActive(floor_special, s1)) //jff 2/22/98
continue;
// s2 = getNextSector(s1->lines[0],s1); // s2 is pool's sector
s2 = getNextSector(getSectorLineByIndex(s1, 0), s1); // s2 is pool's sector
if (!s2)
continue; // note lowest numbered line around
// pillar must be two-sided
/* do not start the donut if the pool is already moving
* cph - DEMOSYNC - was !compatibility */
if (P_SectorActive(floor_special, s2))
continue; //jff 5/7/98
// find a two sided line around the pool whose other side isn't the pillar
for (i = 0; i < s2->linecount; i++)
{
if (!LN_BACKSECTOR((getSectorLineByIndex(s2, i))) || LN_BACKSECTOR((getSectorLineByIndex(s2,i))) == s1)
continue;
rtn = 1; //jff 1/26/98 no donut action - no switch change on return
s3 = LN_BACKSECTOR((getSectorLineByIndex(s2, i))); // s3 is model sector for changes
// Spawn rising slime
floor = Z_Malloc(sizeof(*floor), PU_LEVSPEC, 0);
memset(floor, 0, sizeof(*floor));
P_AddThinker(&floor->thinker);
s2->floordata_sptr = getShortPtr(floor); //jff 2/22/98
floor->thinker.function = T_MoveFloor;
floor->type = donutRaise;
floor->crush = false;
floor->direction = 1;
floor->sector_sptr = getShortPtr(s2);
floor->speed = FLOORSPEED / 2;
floor->texture = s3->floorpic;
floor->newspecial = 0;
floor->floordestheight = s3->floorheight;
// Spawn lowering donut-hole pillar
floor = Z_Malloc(sizeof(*floor), PU_LEVSPEC, 0);
memset(floor, 0, sizeof(*floor));
P_AddThinker(&floor->thinker);
s1->floordata_sptr = getShortPtr(floor); //jff 2/22/98
floor->thinker.function = T_MoveFloor;
floor->type = lowerFloor;
floor->crush = false;
floor->direction = -1;
floor->sector_sptr = getShortPtr(s1);
floor->speed = FLOORSPEED / 2;
floor->floordestheight = s3->floorheight;
break;
}
}
return rtn;
}
//
// EV_DoElevator
//
// Handle elevator linedef types
//
// Passed the linedef that triggered the elevator and the elevator action
//
// jff 2/22/98 new type to move floor and ceiling in parallel
//
int EV_DoElevator(const line_t *line, elevator_e elevtype)
{
int secnum;
int rtn;
sector_t *sec;
elevator_t *elevator;
secnum = -1;
rtn = 0;
// act on all sectors with the same tag as the triggering linedef
while ((secnum = P_FindSectorFromLineTag(line, secnum)) >= 0)
{
sec = &_g->sectors[secnum];
// If either floor or ceiling is already activated, skip it
if (sec->floordata_sptr || sec->ceilingdata_sptr) //jff 2/22/98
continue;
// create and initialize new elevator thinker
rtn = 1;
elevator = Z_Malloc(sizeof(*elevator), PU_LEVSPEC, 0);
memset(elevator, 0, sizeof(*elevator));
P_AddThinker(&elevator->thinker);
sec->floordata_sptr = getShortPtr(elevator); //jff 2/22/98
sec->ceilingdata_sptr = getShortPtr(elevator); //jff 2/22/98
elevator->thinker.function = T_MoveElevator;
elevator->type = elevtype;
// set up the fields according to the type of elevator action
switch (elevtype)
{
// elevator down to next floor
case elevateDown:
elevator->direction = -1;
elevator->sector = sec;
elevator->speed = ELEVATORSPEED;
elevator->floordestheight = P_FindNextLowestFloor(sec, sec->floorheight);
elevator->ceilingdestheight = elevator->floordestheight + sec->ceilingheight - sec->floorheight;
break;
// elevator up to next floor
case elevateUp:
elevator->direction = 1;
elevator->sector = sec;
elevator->speed = ELEVATORSPEED;
elevator->floordestheight = P_FindNextHighestFloor(sec, sec->floorheight);
elevator->ceilingdestheight = elevator->floordestheight + sec->ceilingheight - sec->floorheight;
break;
// elevator to floor height of activating switch's front sector
case elevateCurrent:
elevator->sector = sec;
elevator->speed = ELEVATORSPEED;
elevator->floordestheight = LN_FRONTSECTOR(line)->floorheight;
elevator->ceilingdestheight = elevator->floordestheight + sec->ceilingheight - sec->floorheight;
elevator->direction =
elevator->floordestheight > sec->floorheight ? 1 : -1;
break;
default:
break;
}
}
return rtn;
}
File diff suppressed because it is too large. Load diff
+866
View File
@@ -0,0 +1,866 @@
/**
* Doom Port to the nRF52840 by Nicola Wrachien (next-hack in the comments)
*
* This port is based on the excellent doomhack's GBA Doom Port,
* with Kippykip additions.
*
* Several data structures and functions have been optimized
* to fit in only 256kB RAM of nRF52840 (GBA has 384 kB RAM).
* Z-Depth Light has been restored with almost no RAM consumption!
* Tons of speed optimizations have been done, and the game now
* runs extremely fast, despite the much higher 3D resolution with
* respect to GBA.
*
* PrBoom: a Doom port merged with LxDoom and LSDLDoom
* based on BOOM, a modified and improved DOOM engine
* Copyright (C) 1999 by
* id Software, Chi Hoang, Lee Killough, Jim Flynn, Rand Phares, Ty Halderman
* Copyright (C) 1999-2000 by
* Jess Haas, Nicolas Kalkhof, Colin Phipps, Florian Schulze
* Copyright 2005, 2006 by
* Florian Schulze, Colin Phipps, Neil Stevens, Andrey Budko
* Copyright (C) 2021 Nicola Wrachien (next-hack in the comments)
* on nRF52840 port.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
* 02111-1307, USA.
*
* DESCRIPTION:
* Handling interactions (i.e., collisions).
*
* next-hack: modified code to work with short pointers.
*
*-----------------------------------------------------------------------------*/
#include "doomstat.h"
#include "dstrings.h"
#include "m_random.h"
#include "am_map.h"
#include "r_main.h"
#include "s_sound.h"
#include "sounds.h"
#include "p_tick.h"
#include "lprintf.h"
#include "p_inter.h"
#include "p_enemy.h"
#include "global_data.h"
#ifdef __GNUG__
#pragma implementation "p_inter.h"
#endif
#include "p_inter.h"
#define BONUSADD 6
// Ty 03/07/98 - add deh externals
// Maximums and such were hardcoded values. Need to externalize those for
// dehacked support (and future flexibility). Most var names came from the key
// strings used in dehacked.
const int initial_health = 100;
const int initial_bullets = 50;
const int maxhealth = 100; // was MAXHEALTH as a #define, used only in this module
const int max_armor = 200;
const int green_armor_class = 1; // these are involved with armortype below
const int blue_armor_class = 2;
const int max_soul = 200;
const int soul_health = 100;
const int mega_health = 200;
const int god_health = 100; // these are used in cheats (see st_stuff.c)
const int idfa_armor = 200;
const int idfa_armor_class = 2;
// not actually used due to pairing of cheat_k and cheat_fa
const int idkfa_armor = 200;
const int idkfa_armor_class = 2;
const int bfgcells = 40; // used in p_pspr.c
// Ty 03/07/98 - end deh externals
// a weapon is found with two clip loads,
// a big item has five clip loads
const int maxammo[NUMAMMO] = { 200, 50, 300, 50 };
const int clipammo[NUMAMMO] = { 10, 4, 20, 1 };
//
// GET STUFF
//
//
// P_GiveAmmo
// Num is the number of clip loads,
// not the individual count (0= 1/2 clip).
// Returns false if the ammo can't be picked up at all
//
static boolean P_GiveAmmo(player_t *player, ammotype_t ammo, int num)
{
int oldammo;
if (ammo == am_noammo)
return false;
#ifdef RANGECHECK
if (ammo < 0 || ammo > NUMAMMO)
I_Error ("P_GiveAmmo: bad type %i", ammo);
#endif
if (player->ammo[ammo] == player->maxammo[ammo])
return false;
if (num)
num *= clipammo[ammo];
else
num = clipammo[ammo] / 2;
// give double ammo in trainer mode, you'll need in nightmare
if (_g->gameskill == sk_baby || _g->gameskill == sk_nightmare)
num <<= 1;
oldammo = player->ammo[ammo];
player->ammo[ammo] += num;
if (player->ammo[ammo] > player->maxammo[ammo])
player->ammo[ammo] = player->maxammo[ammo];
// If non zero ammo, don't change up weapons, player was lower on purpose.
if (oldammo)
return true;
// We were down to zero, so select a new weapon.
// Preferences are not user selectable.
switch (ammo)
{
case am_clip:
if (player->readyweapon == wp_fist)
{
if (player->weaponowned[wp_chaingun])
player->pendingweapon = wp_chaingun;
else
player->pendingweapon = wp_pistol;
}
break;
case am_shell:
if (player->readyweapon == wp_fist || player->readyweapon == wp_pistol)
{
if (player->weaponowned[wp_shotgun])
player->pendingweapon = wp_shotgun;
}
break;
case am_cell:
if (player->readyweapon == wp_fist || player->readyweapon == wp_pistol)
{
if (player->weaponowned[wp_plasma])
player->pendingweapon = wp_plasma;
}
break;
case am_misl:
if (player->readyweapon == wp_fist)
{
if (player->weaponowned[wp_missile])
player->pendingweapon = wp_missile;
}
break;
default:
break;
}
return true;
}
//
// P_GiveWeapon
// The weapon name may have a MF_DROPPED flag ored in.
//
static boolean P_GiveWeapon(player_t *player, weapontype_t weapon, boolean dropped)
{
boolean gaveammo;
boolean gaveweapon;
if (weaponinfo[weapon].ammo != am_noammo)
{
// give one clip with a dropped weapon,
// two clips with a found weapon
gaveammo = P_GiveAmmo(player, weaponinfo[weapon].ammo, dropped ? 1 : 2);
}
else
gaveammo = false;
if (player->weaponowned[weapon])
gaveweapon = false;
else
{
gaveweapon = true;
player->weaponowned[weapon] = true;
player->pendingweapon = weapon;
}
return gaveweapon || gaveammo;
}
//
// P_GiveBody
// Returns false if the body isn't needed at all
//
static boolean P_GiveBody(player_t *player, int num)
{
if (player->health >= maxhealth)
return false; // Ty 03/09/98 externalized MAXHEALTH to maxhealth
player->health += num;
if (player->health > maxhealth)
player->health = maxhealth;
player->mo->health = player->health;
return true;
}
//
// P_GiveArmor
// Returns false if the armor is worse
// than the current armor.
//
static boolean P_GiveArmor(player_t *player, int armortype)
{
int hits = armortype * 100;
if (player->armorpoints >= hits)
return false; // don't pick up
player->armortype = armortype;
player->armorpoints = hits;
return true;
}
//
// P_GiveCard
//
static void P_GiveCard(player_t *player, card_t card)
{
if (player->cards[card])
return;
player->bonuscount = BONUSADD;
player->cards[card] = 1;
}
//
// P_GivePower
//
// Rewritten by Lee Killough
//
boolean P_GivePower(player_t *player, int power)
{
static const int tics[NUMPOWERS] =
{ INVULNTICS, 1 /* strength */, INVISTICS, IRONTICS, 1 /* allmap */, INFRATICS, };
switch (power)
{
case pw_invisibility:
player->mo->flags |= MF_SHADOW;
break;
case pw_allmap:
if (player->powers[pw_allmap])
return false;
break;
case pw_strength:
P_GiveBody(player, 100);
break;
}
// Unless player has infinite duration cheat, set duration (killough)
if (player->powers[power] >= 0)
player->powers[power] = tics[power];
return true;
}
//
// P_TouchSpecialThing
//
void P_TouchSpecialThing(mobj_t *special, mobj_t *toucher)
{
player_t *player;
int i;
int sound;
fixed_t delta = special->z - toucher->z;
if (delta > getMobjHeight(toucher) || delta < -8 * FRACUNIT)
return; // out of reach
sound = sfx_itemup;
player = getMobjPlayer(toucher);
// Dead thing touching.
// Can happen with a sliding player corpse.
if (toucher->health <= 0)
return;
// Identify by sprite.
switch (special->sprite)
{
// armor
case SPR_ARM1:
if (!P_GiveArmor(player, green_armor_class))
return;
player->message = GOTARMOR; // Ty 03/22/98 - externalized
break;
case SPR_ARM2:
if (!P_GiveArmor(player, blue_armor_class))
return;
player->message = GOTMEGA; // Ty 03/22/98 - externalized
break;
// bonus items
case SPR_BON1:
player->health++; // can go over 100%
if (player->health > (maxhealth * 2))
player->health = (maxhealth * 2);
player->mo->health = player->health;
player->message = GOTHTHBONUS; // Ty 03/22/98 - externalized
break;
case SPR_BON2:
player->armorpoints++; // can go over 100%
if (player->armorpoints > max_armor)
player->armorpoints = max_armor;
if (!player->armortype)
player->armortype = green_armor_class;
player->message = GOTARMBONUS; // Ty 03/22/98 - externalized
break;
case SPR_SOUL:
player->health += soul_health;
if (player->health > max_soul)
player->health = max_soul;
player->mo->health = player->health;
player->message = GOTSUPER; // Ty 03/22/98 - externalized
sound = sfx_getpow;
break;
case SPR_MEGA:
if (_g->gamemode != commercial)
return;
player->health = mega_health;
player->mo->health = player->health;
P_GiveArmor(player, blue_armor_class);
player->message = GOTMSPHERE; // Ty 03/22/98 - externalized
sound = sfx_getpow;
break;
// cards
// leave cards for everyone
case SPR_BKEY:
if (!player->cards[it_bluecard])
player->message = GOTBLUECARD; // Ty 03/22/98 - externalized
P_GiveCard(player, it_bluecard);
break;
case SPR_YKEY:
if (!player->cards[it_yellowcard])
player->message = GOTYELWCARD; // Ty 03/22/98 - externalized
P_GiveCard(player, it_yellowcard);
break;
case SPR_RKEY:
if (!player->cards[it_redcard])
player->message = GOTREDCARD; // Ty 03/22/98 - externalized
P_GiveCard(player, it_redcard);
break;
case SPR_BSKU:
if (!player->cards[it_blueskull])
player->message = GOTBLUESKUL; // Ty 03/22/98 - externalized
P_GiveCard(player, it_blueskull);
break;
case SPR_YSKU:
if (!player->cards[it_yellowskull])
player->message = GOTYELWSKUL; // Ty 03/22/98 - externalized
P_GiveCard(player, it_yellowskull);
break;
case SPR_RSKU:
if (!player->cards[it_redskull])
player->message = GOTREDSKULL; // Ty 03/22/98 - externalized
P_GiveCard(player, it_redskull);
break;
// medikits, heals
case SPR_STIM:
if (!P_GiveBody(player, 10))
return;
player->message = GOTSTIM; // Ty 03/22/98 - externalized
break;
case SPR_MEDI:
if (!P_GiveBody(player, 25))
return;
if (player->health < 50) // cph - 25 + the 25 just added, thanks to Quasar for reporting this bug
player->message = GOTMEDINEED; // Ty 03/22/98 - externalized
else
player->message = GOTMEDIKIT; // Ty 03/22/98 - externalized
break;
// power ups
case SPR_PINV:
if (!P_GivePower(player, pw_invulnerability))
return;
player->message = GOTINVUL; // Ty 03/22/98 - externalized
sound = sfx_getpow;
break;
case SPR_PSTR:
if (!P_GivePower(player, pw_strength))
return;
player->message = GOTBERSERK; // Ty 03/22/98 - externalized
if (player->readyweapon != wp_fist)
player->pendingweapon = wp_fist;
sound = sfx_getpow;
break;
case SPR_PINS:
if (!P_GivePower(player, pw_invisibility))
return;
player->message = GOTINVIS; // Ty 03/22/98 - externalized
sound = sfx_getpow;
break;
case SPR_SUIT:
if (!P_GivePower(player, pw_ironfeet))
return;
player->message = GOTSUIT; // Ty 03/22/98 - externalized
sound = sfx_getpow;
break;
case SPR_PMAP:
if (!P_GivePower(player, pw_allmap))
return;
player->message = GOTMAP; // Ty 03/22/98 - externalized
sound = sfx_getpow;
break;
case SPR_PVIS:
if (!P_GivePower(player, pw_infrared))
return;
player->message = GOTVISOR; // Ty 03/22/98 - externalized
sound = sfx_getpow;
break;
// ammo
case SPR_CLIP:
if (special->flags & MF_DROPPED)
{
if (!P_GiveAmmo(player, am_clip, 0))
return;
}
else
{
if (!P_GiveAmmo(player, am_clip, 1))
return;
}
player->message = GOTCLIP; // Ty 03/22/98 - externalized
break;
case SPR_AMMO:
if (!P_GiveAmmo(player, am_clip, 5))
return;
player->message = GOTCLIPBOX; // Ty 03/22/98 - externalized
break;
case SPR_ROCK:
if (!P_GiveAmmo(player, am_misl, 1))
return;
player->message = GOTROCKET; // Ty 03/22/98 - externalized
break;
case SPR_BROK:
if (!P_GiveAmmo(player, am_misl, 5))
return;
player->message = GOTROCKBOX; // Ty 03/22/98 - externalized
break;
case SPR_CELL:
if (!P_GiveAmmo(player, am_cell, 1))
return;
player->message = GOTCELL; // Ty 03/22/98 - externalized
break;
case SPR_CELP:
if (!P_GiveAmmo(player, am_cell, 5))
return;
player->message = GOTCELLBOX; // Ty 03/22/98 - externalized
break;
case SPR_SHEL:
if (!P_GiveAmmo(player, am_shell, 1))
return;
player->message = GOTSHELLS; // Ty 03/22/98 - externalized
break;
case SPR_SBOX:
if (!P_GiveAmmo(player, am_shell, 5))
return;
player->message = GOTSHELLBOX; // Ty 03/22/98 - externalized
break;
case SPR_BPAK:
if (!player->backpack)
{
for (i = 0; i < NUMAMMO; i++)
player->maxammo[i] *= 2;
player->backpack = true;
}
for (i = 0; i < NUMAMMO; i++)
P_GiveAmmo(player, i, 1);
player->message = GOTBACKPACK; // Ty 03/22/98 - externalized
break;
// weapons
case SPR_BFUG:
if (!P_GiveWeapon(player, wp_bfg, false))
return;
player->message = GOTBFG9000; // Ty 03/22/98 - externalized
sound = sfx_wpnup;
break;
case SPR_MGUN:
if (!P_GiveWeapon(player, wp_chaingun, (special->flags & MF_DROPPED ) != 0))
return;
player->message = GOTCHAINGUN; // Ty 03/22/98 - externalized
sound = sfx_wpnup;
break;
case SPR_CSAW:
if (!P_GiveWeapon(player, wp_chainsaw, false))
return;
player->message = GOTCHAINSAW; // Ty 03/22/98 - externalized
sound = sfx_wpnup;
break;
case SPR_LAUN:
if (!P_GiveWeapon(player, wp_missile, false))
return;
player->message = GOTLAUNCHER; // Ty 03/22/98 - externalized
sound = sfx_wpnup;
break;
case SPR_PLAS:
if (!P_GiveWeapon(player, wp_plasma, false))
return;
player->message = GOTPLASMA; // Ty 03/22/98 - externalized
sound = sfx_wpnup;
break;
case SPR_SHOT:
if (!P_GiveWeapon(player, wp_shotgun, (special->flags & MF_DROPPED ) != 0))
return;
player->message = GOTSHOTGUN; // Ty 03/22/98 - externalized
sound = sfx_wpnup;
break;
case SPR_SGN2:
if (!P_GiveWeapon(player, wp_supershotgun, (special->flags & MF_DROPPED ) != 0))
return;
player->message = GOTSHOTGUN2; // Ty 03/22/98 - externalized
sound = sfx_wpnup;
break;
default:
I_Error("P_SpecialThing: Unknown gettable thing");
}
if (special->flags & MF_COUNTITEM)
player->itemcount++;
P_RemoveMobj(special);
player->bonuscount += BONUSADD;
/* cph 20028/10 - for old-school DM addicts, allow old behavior
* where only consoleplayer's pickup sounds are heard */
// displayplayer, not consoleplayer, for viewing multiplayer demos
if (player == &_g->player)
S_StartSound(player->mo, sound | PICKUP_SOUND); // killough 4/25/98
}
//
// KillMobj
//
// killough 11/98: make static
static void P_KillMobj(mobj_t *source, mobj_t *target)
{
mobjtype_t item;
mobj_t *mo;
target->flags &= ~(MF_SHOOTABLE | MF_FLOAT | MF_SKULLFLY );
demodbgprintf("KillMobj target type %d\r\n",target->type);
if (target->type != MT_SKULL)
target->flags &= ~MF_NOGRAVITY;
// TODO: we can exploit MF_CORPSE to reuse mobjs
target->flags |= MF_CORPSE | MF_DROPOFF;
target->height_s >>= 2;
if (!((target->flags ^ MF_COUNTKILL ) & (MF_FRIEND | MF_COUNTKILL )))
_g->totallive--;
if (source && getMobjPlayer(source))
{
// count for intermission
if (target->flags & MF_COUNTKILL)
getMobjPlayer(source)->killcount++;
if (getMobjPlayer(target))
getMobjPlayer(source)->frags[getMobjPlayer(target) - &_g->player]++;
}
else if (target->flags & MF_COUNTKILL)
{ /* Add to kills tally */
// count all monster deaths,
// even those caused by other monsters
_g->player.killcount++;
}
if (target->player_sptr)
{
// count environment kills against you
if (!source)
getMobjPlayer(target)->frags[getMobjPlayer(target) - &_g->player]++;
target->flags &= ~MF_SOLID;
getMobjPlayer(target)->playerstate = PST_DEAD;
P_DropWeapon(getMobjPlayer(target));
if (getMobjPlayer(target) == &_g->player && (_g->automapmode & am_active))
AM_Stop(); // don't die in auto map; switch view prior to dying
}
if (target->health < -getMobjInfo(target)->spawnhealth && getMobjInfo(target)->xdeathstate)
P_SetMobjState(target, getMobjInfo(target)->xdeathstate);
else
P_SetMobjState(target, getMobjInfo(target)->deathstate);
target->tics -= P_Random(__FILE__, __LINE__, __FUNCTION__) & 3;
if (target->tics < 1)
target->tics = 1;
// Drop stuff.
// This determines the kind of object spawned
// during the death frame of a thing.
if ((_g->player.cheats & CF_ENEMY_ROCKETS) && (target->type >= MT_POSSESSED) && (target->type <= MT_KEEN))
{
item = MT_MISC27; //Everyone drops a rocket launcher.
}
else
{
switch (target->type)
{
case MT_WOLFSS:
case MT_POSSESSED:
item = MT_CLIP;
break;
case MT_SHOTGUY:
item = MT_SHOTGUN;
break;
case MT_CHAINGUY:
item = MT_CHAINGUN;
break;
default:
return;
}
}
mo = P_SpawnMobj(target->x, target->y, ONFLOORZ, item);
mo->flags |= MF_DROPPED; // special versions of items
}
//
// P_DamageMobj
// Damages both enemies and players
// "inflictor" is the thing that caused the damage
// creature or missile, can be NULL (slime, etc)
// "source" is the thing to target after taking damage
// creature or NULL
// Source and inflictor are the same for melee attacks.
// Source can be NULL for slime, barrel explosions
// and other environmental stuff.
//
void P_DamageMobj(mobj_t *target, mobj_t *inflictor, mobj_t *source, int damage)
{
player_t *player;
boolean justhit = false; /* killough 11/98 */
/* killough 8/31/98: allow bouncers to take damage */
if (!(target->flags & (MF_SHOOTABLE )))
return; // shouldn't happen...
if (target->health <= 0)
return;
if (target->flags & MF_SKULLFLY)
target->momx = target->momy = target->momz = 0;
player = getMobjPlayer(target);
if (player && _g->gameskill == sk_baby)
damage >>= 1; // take half damage in trainer mode
// Some close combat weapons should not
// inflict thrust and push the victim out of reach,
// thus kick away unless using the chainsaw.
if (inflictor && !(target->flags & MF_NOCLIP ) && (!source || !getMobjPlayer(source) || getMobjPlayer(source)->readyweapon != wp_chainsaw))
{
unsigned ang = R_PointToAngle2(inflictor->x, inflictor->y, target->x, target->y);
fixed_t thrust = damage * (FRACUNIT >> 3) * 100 / getMobjInfo(target)->mass;
// make fall forwards sometimes
if (damage < 40 && damage > target->health && target->z - inflictor->z > 64 * FRACUNIT && (P_Random(__FILE__, __LINE__, __FUNCTION__) & 1))
{
ang += ANG180;
thrust *= 4;
}
ang >>= ANGLETOFINESHIFT;
target->momx += FixedMul(thrust, finecosine[ang]);
target->momy += FixedMul(thrust, finesine[ang]);
}
// player specific
if (player)
{
demodbgprintf("DamageMobj: health %d, damage %d, attacker x,y %d, %d\r\n", player->health, damage, source != NULL ? source->x : -1, source != NULL ? source->y : 0);
// end of game hell hack
if (getMobjSubsector(target)->sector->special == 11 && damage >= target->health)
damage = target->health - 1;
// Below certain threshold,
// ignore damage in GOD mode, or with INVUL power.
// killough 3/26/98: make god mode 100% god mode in non-compat mode
if ((damage < 1000 || ((player->cheats & CF_GODMODE))) && ((player->cheats & CF_GODMODE) || player->powers[pw_invulnerability]))
return;
if (player->armortype)
{
int saved = player->armortype == 1 ? damage / 3 : damage / 2;
if (player->armorpoints <= saved)
{
// armor is used up
saved = player->armorpoints;
player->armortype = 0;
}
player->armorpoints -= saved;
damage -= saved;
}
player->health -= damage; // mirror mobj health here for Dave
if (player->health < 0)
player->health = 0;
player->attacker = source;
player->damagecount += damage; // add damage after armor / invuln
if (player->damagecount > 100)
player->damagecount = 100; // teleport stomp does 10k points...
}
// do the damage
target->health -= damage;
if (target->health <= 0)
{
P_KillMobj(source, target);
return;
}
if (!demo_compatibility)
{
/* If target is a player, set player's target to source,
* so that a friend can tell who's hurting a player
*/
if (player)
//P_SetTarget(&target->target, source);
target->target_sptr = getShortPtr(source);
if (P_Random(__FILE__, __LINE__, __FUNCTION__) < getMobjInfo(target)->painchance && !(target->flags & MF_SKULLFLY ))
{ //killough 11/98: see below
justhit = true;
P_SetMobjState(target, getMobjInfo(target)->painstate);
}
target->reactiontime = 0; // we're awake now...
/* killough 9/9/98: cleaned up, made more consistent: */
if (source && source != target && source->type != MT_VILE && (!target->threshold || target->type == MT_VILE))
{
/* if not intent on another player, chase after this one
*
* killough 2/15/98: remember last enemy, to prevent
* sleeping early; 2/21/98: Place priority on players
* killough 9/9/98: cleaned up, made more consistent:
*/
#warning this can be removed
if (0 == target->lastenemy_sptr || getLastEnemy(target)->health <= 0 || (!((target->flags ^ getLastEnemy(target)->flags) & MF_FRIEND ) && getTarget(target) != source)) // remember last enemy - killough
{
//P_SetTarget(getLastEnemy(target), target->target);
target->lastenemy_sptr = target->target_sptr;
}
// P_SetTarget(&target->target, source); // killough 11/98
target->target_sptr = getShortPtr(source);
target->threshold = BASETHRESHOLD;
if (getMobjState(target) == &states[getMobjInfo(target)->spawnstate] && getMobjInfo(target)->seestate != S_NULL)
P_SetMobjState(target, getMobjInfo(target)->seestate);
}
/* killough 11/98: Don't attack a friend, unless hit by that friend.
* cph 2006/04/01 - implicitly this is only if mbf_features */
{
if (justhit && (getTarget(target) == source || !getTarget(target) || !(target->flags & getTarget(target)->flags & MF_FRIEND )))
target->flags |= MF_JUSTHIT; // fight back!
}
}
else
{
if (P_Random(__FILE__, __LINE__, __FUNCTION__) < getMobjInfo(target)->painchance && !(target->flags & MF_SKULLFLY ))
{
target->flags |= MF_JUSTHIT; // fight back!
P_SetMobjState (target, getMobjInfo(target)->painstate);
}
target->reactiontime = 0; // we're awake now...
if ( (!target->threshold || target->type == MT_VILE)
&& source && source != target
&& source->type != MT_VILE)
{
// if not intent on another player,
// chase after this one
target->target_sptr = getShortPtr(source);
target->threshold = BASETHRESHOLD;
if (getMobjState(target) == &states[getMobjInfo(target)->spawnstate] && getMobjInfo(target)->seestate != S_NULL)
P_SetMobjState(target, getMobjInfo(target)->seestate);
}
}
}
+447
View File
@@ -0,0 +1,447 @@
/**
* Doom Port to the nRF52840 by Nicola Wrachien (next-hack in the comments)
*
* This port is based on the excellent doomhack's GBA Doom Port,
* with Kippykip additions.
*
* Several data structures and functions have been optimized
* to fit in only 256kB RAM of nRF52840 (GBA has 384 kB RAM).
* Z-Depth Light has been restored with almost no RAM consumption!
* Tons of speed optimizations have been done, and the game now
* runs extremely fast, despite the much higher 3D resolution with
* respect to GBA.
*
* PrBoom: a Doom port merged with LxDoom and LSDLDoom
* based on BOOM, a modified and improved DOOM engine
* Copyright (C) 1999 by
* id Software, Chi Hoang, Lee Killough, Jim Flynn, Rand Phares, Ty Halderman
* Copyright (C) 1999-2000 by
* Jess Haas, Nicolas Kalkhof, Colin Phipps, Florian Schulze
* Copyright 2005, 2006 by
* Florian Schulze, Colin Phipps, Neil Stevens, Andrey Budko
* Copyright (C) 2021 Nicola Wrachien (next-hack in the comments)
* on nRF52840 port.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
* 02111-1307, USA.
*
* DESCRIPTION:
* Action routines for lighting thinkers
* Spawn sector based lighting effects.
* Handle lighting linedef types
*
* next-hack: modified code to work with short pointers.
*
*-----------------------------------------------------------------------------*/
#include "doomstat.h" //jff 5/18/98
#include "doomdef.h"
#include "m_random.h"
#include "r_main.h"
#include "p_spec.h"
#include "p_tick.h"
#include "global_data.h"
//////////////////////////////////////////////////////////
//
// Lighting action routines, called once per tick
//
//////////////////////////////////////////////////////////
//
// T_FireFlicker()
//
// Firelight flicker action routine, called once per tick
//
// Passed a fireflicker_t structure containing light levels and timing
// Returns nothing
//
void T_FireFlicker(fireflicker_t *flick)
{
int amount;
if (--flick->count)
return;
amount = (P_Random(__FILE__, __LINE__, __FUNCTION__) & 3) * 16;
if (flick->sector->lightlevel - amount < flick->minlight)
flick->sector->lightlevel = flick->minlight;
else
flick->sector->lightlevel = flick->maxlight - amount;
flick->count = 4;
}
//
// T_LightFlash()
//
// Broken light flashing action routine, called once per tick
//
// Passed a lightflash_t structure containing light levels and timing
// Returns nothing
//
void T_LightFlash(lightflash_t *flash)
{
if (--flash->count)
return;
if (flash->sector->lightlevel == flash->maxlight)
{
flash->sector->lightlevel = flash->minlight;
flash->count = (P_Random(__FILE__, __LINE__, __FUNCTION__) & flash->mintime) + 1;
}
else
{
flash->sector->lightlevel = flash->maxlight;
flash->count = (P_Random(__FILE__, __LINE__, __FUNCTION__) & flash->maxtime) + 1;
}
}
//
// T_StrobeFlash()
//
// Strobe light flashing action routine, called once per tick
//
// Passed a strobe_t structure containing light levels and timing
// Returns nothing
//
void T_StrobeFlash(strobe_t *flash)
{
if (--flash->count)
return;
if (flash->sector->lightlevel == flash->minlight)
{
flash->sector->lightlevel = flash->maxlight;
flash->count = flash->brighttime;
}
else
{
flash->sector->lightlevel = flash->minlight;
flash->count = flash->darktime;
}
}
//
// T_Glow()
//
// Glowing light action routine, called once per tick
//
// Passed a glow_t structure containing light levels and timing
// Returns nothing
//
void T_Glow(glow_t *g)
{
switch (g->direction)
{
case -1:
// light dims
g->sector->lightlevel -= GLOWSPEED;
if (g->sector->lightlevel <= g->minlight)
{
g->sector->lightlevel += GLOWSPEED;
g->direction = 1;
}
break;
case 1:
// light brightens
g->sector->lightlevel += GLOWSPEED;
if (g->sector->lightlevel >= g->maxlight)
{
g->sector->lightlevel -= GLOWSPEED;
g->direction = -1;
}
break;
}
}
//////////////////////////////////////////////////////////
//
// Sector lighting type spawners
//
// After the map has been loaded, each sector is scanned
// for specials that spawn thinkers
//
//////////////////////////////////////////////////////////
//
// P_SpawnFireFlicker()
//
// Spawns a fire flicker lighting thinker
//
// Passed the sector that spawned the thinker
// Returns nothing
//
void P_SpawnFireFlicker(sector_t *sector)
{
fireflicker_t *flick;
// Note that we are resetting sector attributes.
// Nothing special about it during gameplay.
sector->special &= ~31; //jff 3/14/98 clear non-generalized sector type
flick = Z_Malloc(sizeof(*flick), PU_LEVSPEC, 0);
memset(flick, 0, sizeof(*flick));
P_AddThinker(&flick->thinker);
flick->thinker.function = T_FireFlicker;
flick->sector = sector;
flick->maxlight = sector->lightlevel;
flick->minlight = P_FindMinSurroundingLight(sector, sector->lightlevel) + 16;
flick->count = 4;
}
//
// P_SpawnLightFlash()
//
// Spawns a broken light flash lighting thinker
//
// Passed the sector that spawned the thinker
// Returns nothing
//
void P_SpawnLightFlash(sector_t *sector)
{
lightflash_t *flash;
// nothing special about it during gameplay
sector->special &= ~31; //jff 3/14/98 clear non-generalized sector type
flash = Z_Malloc(sizeof(*flash), PU_LEVSPEC, 0);
memset(flash, 0, sizeof(*flash));
P_AddThinker(&flash->thinker);
flash->thinker.function = T_LightFlash;
flash->sector = sector;
flash->maxlight = sector->lightlevel;
flash->minlight = P_FindMinSurroundingLight(sector, sector->lightlevel);
flash->maxtime = 64;
flash->mintime = 7;
flash->count = (P_Random(__FILE__, __LINE__, __FUNCTION__) & flash->maxtime) + 1;
}
//
// P_SpawnStrobeFlash
//
// Spawns a blinking light thinker
//
// Passed the sector that spawned the thinker, speed of blinking
// and whether blinking is to by syncrhonous with other sectors
//
// Returns nothing
//
void P_SpawnStrobeFlash(sector_t *sector, int fastOrSlow, int inSync)
{
strobe_t *flash;
flash = Z_Malloc(sizeof(*flash), PU_LEVSPEC, 0);
memset(flash, 0, sizeof(*flash));
P_AddThinker(&flash->thinker);
flash->sector = sector;
flash->darktime = fastOrSlow;
flash->brighttime = STROBEBRIGHT;
flash->thinker.function = T_StrobeFlash;
flash->maxlight = sector->lightlevel;
flash->minlight = P_FindMinSurroundingLight(sector, sector->lightlevel);
if (flash->minlight == flash->maxlight)
flash->minlight = 0;
// nothing special about it during gameplay
sector->special &= ~31; //jff 3/14/98 clear non-generalized sector type
if (!inSync)
flash->count = (P_Random(__FILE__, __LINE__, __FUNCTION__) & 7) + 1;
else
flash->count = 1;
}
//
// P_SpawnGlowingLight()
//
// Spawns a glowing light (smooth oscillation from min to max) thinker
//
// Passed the sector that spawned the thinker
// Returns nothing
//
void P_SpawnGlowingLight(sector_t *sector)
{
glow_t *g;
g = Z_Malloc(sizeof(*g), PU_LEVSPEC, 0);
memset(g, 0, sizeof(*g));
P_AddThinker(&g->thinker);
g->sector = sector;
g->minlight = P_FindMinSurroundingLight(sector, sector->lightlevel);
g->maxlight = sector->lightlevel;
g->thinker.function = T_Glow;
g->direction = -1;
sector->special &= ~31; //jff 3/14/98 clear non-generalized sector type
}
//////////////////////////////////////////////////////////
//
// Linedef lighting function handlers
//
//////////////////////////////////////////////////////////
//
// EV_StartLightStrobing()
//
// Start strobing lights (usually from a trigger)
//
// Passed the line that activated the strobing
// Returns true
//
// jff 2/12/98 added int return value, fixed return
//
int EV_StartLightStrobing(const line_t *line)
{
int secnum;
sector_t *sec;
secnum = -1;
// start lights strobing in all sectors tagged same as line
while ((secnum = P_FindSectorFromLineTag(line, secnum)) >= 0)
{
sec = &_g->sectors[secnum];
// if already doing a lighting function, don't start a second
if (P_SectorActive(lighting_special, sec)) //jff 2/22/98
continue;
P_SpawnStrobeFlash(sec, SLOWDARK, 0);
}
return 1;
}
//
// EV_TurnTagLightsOff()
//
// Turn line's tagged sector's lights to min adjacent neighbor level
//
// Passed the line that activated the lights being turned off
// Returns true
//
// jff 2/12/98 added int return value, fixed return
//
int EV_TurnTagLightsOff(const line_t *line)
{
int j;
// search sectors for those with same tag as activating line
// killough 10/98: replaced inefficient search with fast search
for (j = -1; (j = P_FindSectorFromLineTag(line, j)) >= 0;)
{
sector_t *sector = _g->sectors + j, *tsec;
int i, min = sector->lightlevel;
// find min neighbor light level
for (i = 0; i < sector->linecount; i++)
if ((tsec = getNextSector(getSectorLineByIndex(sector, i), sector)) && tsec->lightlevel < min)
min = tsec->lightlevel;
sector->lightlevel = min;
}
return 1;
}
//
// EV_LightTurnOn()
//
// Turn sectors tagged to line lights on to specified or max neighbor level
//
// Passed the activating line, and a level to set the light to
// If level passed is 0, the maximum neighbor lighting is used
// Returns true
//
// jff 2/12/98 added int return value, fixed return
//
int EV_LightTurnOn(const line_t *line, int bright)
{
int i;
// search all sectors for ones with same tag as activating line
// killough 10/98: replace inefficient search with fast search
for (i = -1; (i = P_FindSectorFromLineTag(line, i)) >= 0;)
{
sector_t *temp, *sector = _g->sectors + i;
int j, tbright = bright; //jff 5/17/98 search for maximum PER sector
// bright = 0 means to search for highest light level surrounding sector
if (!bright)
for (j = 0; j < sector->linecount; j++)
{
if ((temp = getNextSector(getSectorLineByIndex(sector, j), sector)) && temp->lightlevel > tbright)
{
tbright = temp->lightlevel;
}
sector->lightlevel = tbright;
}
}
return 1;
}
/* killough 10/98:
*
* EV_LightTurnOnPartway()
*
* Turn sectors tagged to line lights on to specified or max neighbor level
*
* Passed the activating line, and a light level fraction between 0 and 1.
* Sets the light to min on 0, max on 1, and interpolates in-between.
* Used for doors with gradual lighting effects.
*
* Returns true
*/
int EV_LightTurnOnPartway(const line_t *line, fixed_t level)
{
int i;
if (level < 0) // clip at extremes
level = 0;
if (level > FRACUNIT)
level = FRACUNIT;
// search all sectors for ones with same tag as activating line
for (i = -1; (i = P_FindSectorFromLineTag(line, i)) >= 0;)
{
sector_t *temp, *sector = _g->sectors + i;
int j, bright = 0, min = sector->lightlevel;
for (j = 0; j < sector->linecount; j++)
if ((temp = getNextSector(getSectorLineByIndex(sector, j), sector)))
{
if (temp->lightlevel > bright)
bright = temp->lightlevel;
if (temp->lightlevel < min)
min = temp->lightlevel;
}
sector->lightlevel = // Set level in-between extremes
(level * bright + (FRACUNIT - level) * min) >> FRACBITS;
}
return 1;
}
File diff suppressed because it is too large. Load diff
+962
View File
@@ -0,0 +1,962 @@
/**
* Doom Port to the nRF52840 by Nicola Wrachien (next-hack in the comments)
*
* This port is based on the excellent doomhack's GBA Doom Port,
* with Kippykip additions.
*
* Several data structures and functions have been optimized
* to fit in only 256kB RAM of nRF52840 (GBA has 384 kB RAM).
* Z-Depth Light has been restored with almost no RAM consumption!
* Tons of speed optimizations have been done, and the game now
* runs extremely fast, despite the much higher 3D resolution with
* respect to GBA.
*
* PrBoom: a Doom port merged with LxDoom and LSDLDoom
* based on BOOM, a modified and improved DOOM engine
* Copyright (C) 1999 by
* id Software, Chi Hoang, Lee Killough, Jim Flynn, Rand Phares, Ty Halderman
* Copyright (C) 1999-2000 by
* Jess Haas, Nicolas Kalkhof, Colin Phipps, Florian Schulze
* Copyright 2005, 2006 by
* Florian Schulze, Colin Phipps, Neil Stevens, Andrey Budko
* Copyright (C) 2021 Nicola Wrachien (next-hack in the comments)
* on nRF52840 port.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
* 02111-1307, USA.
*
* DESCRIPTION:
* Movement/collision utility functions,
* as used by function in p_map.c.
* BLOCKMAP Iterator functions,
* and some PIT_* functions to use for iteration.
*
* next-hack:
* modified code to work with short pointers.
* also reverted pointer-to-pointer scheme back to original because
* it is simpler to handle with short pointers.
*-----------------------------------------------------------------------------*/
#include "doomstat.h"
#include "m_bbox.h"
#include "r_main.h"
#include "p_maputl.h"
#include "p_map.h"
#include "p_setup.h"
#include "global_data.h"
intercept_t intercepts[MAXINTERCEPTS];
boolean interceptIsALine[MAXINTERCEPTS];
intercept_t *intercept_p;
//
// P_AproxDistance
// Gives an estimation of distance (not exact)
//
fixed_t CONSTFUNC P_AproxDistance(fixed_t dx, fixed_t dy)
{
dx = D_abs(dx);
dy = D_abs(dy);
if (dx < dy)
return dx + dy - (dx >> 1);
return dx + dy - (dy >> 1);
}
//
// P_PointOnLineSide
// Returns 0 or 1
//
// killough 5/3/98: reformatted, cleaned up
int PUREFUNC P_PointOnLineSide(fixed_t x, fixed_t y, const line_t *line)
{
return !line->dx ? x <= line->v1.x ? line->dy > 0 : line->dy < 0
:
!line->dy ? y <= line->v1.y ? line->dx < 0 : line->dx > 0:
FixedMul(y - line->v1.y, line->dx >> FRACBITS) >= FixedMul(line->dy >> FRACBITS, x - line->v1.x);
}
//
// P_BoxOnLineSide
// Considers the line to be infinite
// Returns side 0 or 1, -1 if box crosses the line.
//
// killough 5/3/98: reformatted, cleaned up
int PUREFUNC P_BoxOnLineSide(const fixed_t *tmbox, const line_t *ld)
{
int p;
switch (ld->slopetype)
{
default: // shut up compiler warnings -- killough
case ST_HORIZONTAL:
return (tmbox[BOXBOTTOM] > ld->v1.y) == (p = tmbox[BOXTOP] > ld->v1.y) ? p ^ (ld->dx < 0) : -1;
case ST_VERTICAL:
return (tmbox[BOXLEFT] < ld->v1.x) == (p = tmbox[BOXRIGHT] < ld->v1.x) ? p ^ (ld->dy < 0) : -1;
case ST_POSITIVE:
return P_PointOnLineSide(tmbox[BOXRIGHT], tmbox[BOXBOTTOM], ld) == (p = P_PointOnLineSide(tmbox[BOXLEFT], tmbox[BOXTOP], ld)) ? p : -1;
case ST_NEGATIVE:
return (P_PointOnLineSide(tmbox[BOXLEFT], tmbox[BOXBOTTOM], ld)) == (p = P_PointOnLineSide(tmbox[BOXRIGHT], tmbox[BOXTOP], ld)) ? p : -1;
}
}
//
// P_PointOnDivlineSide
// Returns 0 or 1.
//
// killough 5/3/98: reformatted, cleaned up
static int PUREFUNC P_PointOnDivlineSide(fixed_t x, fixed_t y, const divline_t *line)
{
return !line->dx ? x <= line->x ? line->dy > 0 : line->dy < 0
:
!line->dy ? y <= line->y ? line->dx < 0 : line->dx > 0
:
(line->dy ^ line->dx ^ (x -= line->x) ^ (y -= line->y)) < 0 ? (line->dy ^ x) < 0 : FixedMul(y >> 8, line->dx >> 8) >= FixedMul(line->dy >> 8, x >> 8);
}
//
// P_MakeDivline
//
static void P_MakeDivline(const line_t *li, divline_t *dl)
{
dl->x = li->v1.x;
dl->y = li->v1.y;
dl->dx = li->dx;
dl->dy = li->dy;
}
//
// P_InterceptVector
// Returns the fractional intercept point
// along the first divline.
// This is only called by the addthings
// and addlines traversers.
//
/* cph - this is killough's 4/19/98 version of P_InterceptVector and
* P_InterceptVector2 (which were interchangeable). We still use this
* in compatibility mode. */
fixed_t PUREFUNC P_InterceptVector2(const divline_t *v2, const divline_t *v1)
{
fixed_t den;
return ((den = FixedMul(v1->dy >> 8, v2->dx) - FixedMul(v1->dx >> 8, v2->dy))) ? FixedDiv(FixedMul((v1->x - v2->x) >> 8, v1->dy) + FixedMul((v2->y - v1->y) >> 8, v1->dx), den) : 0;
}
//
// P_LineOpening
// Sets opentop and openbottom to the window
// through a two sided line.
// OPTIMIZE: keep this precalculated
//
void P_LineOpening(const line_t *linedef)
{
if (linedef->sidenum[1] == NO_INDEX) // single sided line
{
_g->openrange = 0;
return;
}
_g->openfrontsector = LN_FRONTSECTOR(linedef);
_g->openbacksector = LN_BACKSECTOR(linedef);
if (_g->openfrontsector->ceilingheight < _g->openbacksector->ceilingheight)
_g->opentop = _g->openfrontsector->ceilingheight;
else
_g->opentop = _g->openbacksector->ceilingheight;
if (_g->openfrontsector->floorheight > _g->openbacksector->floorheight)
{
_g->openbottom = _g->openfrontsector->floorheight;
_g->lowfloor = _g->openbacksector->floorheight;
}
else
{
_g->openbottom = _g->openbacksector->floorheight;
_g->lowfloor = _g->openfrontsector->floorheight;
}
_g->openrange = _g->opentop - _g->openbottom;
}
//
// THING POSITION SETTING
//
//
// P_UnsetThingPosition
// Unlinks a thing from block map and sectors.
// On each position change, BLOCKMAP and other
// lookups maintaining lists ot things inside
// these structures need to be updated.
//
void P_UnsetThingPosition(mobj_t *thing)
{
if (!(thing->flags & MF_NOSECTOR ))
{
// invisible things don't need to be in sector list
// unlink from subsector
if (thing->snext_sptr)
getSNext(thing)->sprev_sptr = thing->sprev_sptr;
if (thing->sprev_sptr)
getSPrev(thing)->snext_sptr = thing->snext_sptr;
else
{
// getMobjSubsector(thing)->sector->thinglist = getLongPtr(thing->snext_sptr);
getMobjSubsector(thing)->sector->thinglist_sptr = thing->snext_sptr;
}
// phares 3/14/98
//
// Save the sector list pointed to by touching_sectorlist.
// In P_SetThingPosition, we'll keep any nodes that represent
// sectors the Thing still touches. We'll add new ones then, and
// delete any nodes for sectors the Thing has vacated. Then we'll
// put it back into touching_sectorlist. It's done this way to
// avoid a lot of deleting/creating for nodes, when most of the
// time you just get back what you deleted anyway.
//
// If this Thing is being removed entirely, then the calling
// routine will clear out the nodes in sector_list.
_g->sector_list = getTouchingSectorList(thing);
thing->touching_sectorlist_sptr = 0;
}
if (!(thing->flags & MF_NOBLOCKMAP ))
{
/* inert things don't need to be in blockmap
*/
int blockx;
int blocky;
if (thing->bnext_sptr)
getBNext(thing)->bprev_sptr = thing->bprev_sptr;
if (thing->bprev_sptr)
getBPrev(thing)->bnext_sptr = thing->bnext_sptr;
else
{
blockx = (thing->x - _g->bmaporgx) >> MAPBLOCKSHIFT;
blocky = (thing->y - _g->bmaporgy) >> MAPBLOCKSHIFT;
if (blockx >= 0 && blockx < _g->bmapwidth && blocky >= 0 && blocky < _g->bmapheight)
{
_g->blocklinks_sptrs[blocky * _g->bmapwidth + blockx] = thing->bnext_sptr;
}
}
}
}
//
// P_SetThingPosition
// Links a thing into both a block and a subsector
// based on it's x y.
// Sets thing->subsector properly
//
// killough 5/3/98: reformatted, cleaned up
void P_SetThingPosition(mobj_t *thing)
{ // link into subsector
subsector_t *ss = setMobjSubesctor(thing, R_PointInSubsector(thing->x, thing->y));
if (!(thing->flags & MF_NOSECTOR ))
{
// invisible things don't go into the sector links
sector_t *sec = ss->sector;
thing->sprev_sptr = 0;
thing->snext_sptr = sec->thinglist_sptr;
if (sec->thinglist_sptr)
getSectorThingList(sec)->sprev_sptr = getShortPtr(thing);
sec->thinglist_sptr = getShortPtr(thing);
// phares 3/16/98
//
// If sector_list isn't NULL, it has a collection of sector
// nodes that were just removed from this Thing.
// Collect the sectors the object will live in by looking at
// the existing sector_list and adding new nodes and deleting
// obsolete ones.
// When a node is deleted, its sector links (the links starting
// at sector_t->touching_thinglist) are broken. When a node is
// added, new sector links are created.
P_CreateSecNodeList(thing, thing->x, thing->y);
thing->touching_sectorlist_sptr = getShortPtr(_g->sector_list); // Attach to Thing's mobj_t
_g->sector_list = NULL; // clear for next time
}
// link into blockmap
if (!(thing->flags & MF_NOBLOCKMAP ))
{
// inert things don't need to be in blockmap
int blockx = (thing->x - _g->bmaporgx) >> MAPBLOCKSHIFT;
int blocky = (thing->y - _g->bmaporgy) >> MAPBLOCKSHIFT;
if (blockx >= 0 && blockx < _g->bmapwidth && blocky >= 0 && blocky < _g->bmapheight)
{
unsigned short *link = &_g->blocklinks_sptrs[blocky * _g->bmapwidth + blockx];
thing->bprev_sptr = 0;
thing->bnext_sptr = *link;
if (*link)
((mobj_t*) getLongPtr(*link))->bprev_sptr = getShortPtr(thing);
*link = getShortPtr(thing);
}
else
{
// thing is off the map
thing->bnext_sptr = thing->bprev_sptr = 0;
}
}
}
//
// BLOCK MAP ITERATORS
// For each line/thing in the given mapblock,
// call the passed PIT_* function.
// If the function returns false,
// exit with false without checking anything else.
//
//
// P_BlockLinesIterator
// The validcount flags are used to avoid checking lines
// that are marked in multiple mapblocks,
// so increment validcount before the first call
// to P_BlockLinesIterator, then make one or more calls
// to it.
//
// killough 5/3/98: reformatted, cleaned up
boolean P_BlockLinesIterator(int x, int y, boolean func(const line_t*))
{
if (x < 0 || y < 0 || x >= _g->bmapwidth || y >= _g->bmapheight)
return true;
const int offset = _g->blockmap[y * _g->bmapwidth + x];
const short *list = _g->blockmaplump + offset; // original was reading // phares
// delmiting 0 as linedef 0 // phares
// killough 1/31/98: for compatibility we need to use the old method.
// Most demos go out of sync, and maybe other problems happen, if we
// don't consider linedef 0. For safety this should be qualified.
if (!demo_compatibility) // killough 2/22/98: demo_compatibility check
list++; // skip 0 starting delimiter // phares
const uint16_t vcount = _g->validcount;
for (; *list != -1; list++) // phares
{
const int lineno = *list;
linedata_t *lt = &_g->linedata[lineno];
if (lt->validcount == vcount)
continue; // line has already been checked
lt->validcount = vcount;
const line_t *ld = &_g->lines[lineno];
if (!func(ld))
return false;
}
return true; // everything was checked
}
//
// P_BlockThingsIterator
//
// killough 5/3/98: reformatted, cleaned up
boolean P_BlockThingsIterator(int x, int y, boolean func(mobj_t*))
{
mobj_t *mobj;
if (!(x < 0 || y < 0 || x >= _g->bmapwidth || y >= _g->bmapheight))
for (mobj = getLongPtr(_g->blocklinks_sptrs[y * _g->bmapwidth + x]);
mobj; mobj = getBNext(mobj))
{
if (!func(mobj))
return false;
}
return true;
}
//
// INTERCEPT ROUTINES
//
// Check for limit and double size if necessary -- killough
static boolean check_intercept(void)
{
size_t offset = intercept_p - intercepts;
if (offset >= MAXINTERCEPTS)
{
printf ("Too many intercepts, blocking");
while(1);
}
return (offset < MAXINTERCEPTS);
}
// PIT_AddLineIntercepts.
// Looks for lines in the given block
// that intercept the given trace
// to add to the intercepts list.
//
// A line is crossed if its endpoints
// are on opposite sides of the trace.
//
// killough 5/3/98: reformatted, cleaned up
boolean PIT_AddLineIntercepts(const line_t *ld)
{
int s1;
int s2;
fixed_t frac;
divline_t dl;
// avoid precision problems with two routines
if (_g->trace.dx > FRACUNIT * 16 || _g->trace.dy > FRACUNIT * 16 || _g->trace.dx < -FRACUNIT * 16 || _g->trace.dy < -FRACUNIT * 16)
{
s1 = P_PointOnDivlineSide(ld->v1.x, ld->v1.y, &_g->trace);
s2 = P_PointOnDivlineSide(ld->v2.x, ld->v2.y, &_g->trace);
}
else
{
s1 = P_PointOnLineSide(_g->trace.x, _g->trace.y, ld);
s2 = P_PointOnLineSide(_g->trace.x + _g->trace.dx, _g->trace.y + _g->trace.dy, ld);
}
if (s1 == s2)
return true; // line isn't crossed
// hit the line
P_MakeDivline(ld, &dl);
frac = P_InterceptVector2(&_g->trace, &dl);
if (frac < 0)
return true; // behind source
if (!check_intercept())
return false;
int index = (int) (intercept_p - intercepts);
checkInterceptIndex(index);
interceptIsALine[index] = true;
//
intercept_p->frac = frac;
//intercept_p->isaline = true;
intercept_p->d.line = ld;
intercept_p++;
return true; // continue
}
//
// PIT_AddThingIntercepts
//
// killough 5/3/98: reformatted, cleaned up
boolean PIT_AddThingIntercepts(mobj_t *thing)
{
fixed_t x1, y1;
fixed_t x2, y2;
int s1, s2;
divline_t dl;
fixed_t frac;
// check a corner to corner crossection for hit
if ((_g->trace.dx ^ _g->trace.dy) > 0)
{
x1 = thing->x - getMobjRadius(thing);
y1 = thing->y + getMobjRadius(thing);
x2 = thing->x + getMobjRadius(thing);
y2 = thing->y - getMobjRadius(thing);
}
else
{
x1 = thing->x - getMobjRadius(thing);
y1 = thing->y - getMobjRadius(thing);
x2 = thing->x + getMobjRadius(thing);
y2 = thing->y + getMobjRadius(thing);
}
s1 = P_PointOnDivlineSide(x1, y1, &_g->trace);
s2 = P_PointOnDivlineSide(x2, y2, &_g->trace);
if (s1 == s2)
return true; // line isn't crossed
dl.x = x1;
dl.y = y1;
dl.dx = x2 - x1;
dl.dy = y2 - y1;
frac = P_InterceptVector2(&_g->trace, &dl);
if (frac < 0)
return true; // behind source
if (!check_intercept())
return false;
int index = (int) (intercept_p - intercepts);
checkInterceptIndex(index);
interceptIsALine[index] = false;
intercept_p->frac = frac;
// intercept_p->isaline = false;
intercept_p->d.thing = thing;
intercept_p++;
return true; // keep going
}
//
// P_TraverseIntercepts
// Returns true if the traverser function returns true
// for all lines.
//
// killough 5/3/98: reformatted, cleaned up
boolean P_TraverseIntercepts(traverser_t func, fixed_t maxfrac)
{
intercept_t *in = NULL;
int count = intercept_p - intercepts;
while (count--)
{
fixed_t dist = INT_MAX;
intercept_t *scan;
for (scan = intercepts; scan < intercept_p; scan++)
if (scan->frac < dist)
dist = (in = scan)->frac;
if (dist > maxfrac)
return true; // checked everything in range
if (!func(in))
return false; // don't bother going farther
in->frac = INT_MAX;
}
return true; // everything was traversed
}
//
// P_PathTraverse
// Traces a line from x1,y1 to x2,y2,
// calling the traverser function for each.
// Returns true if the traverser function returns true
// for all lines.
//
// killough 5/3/98: reformatted, cleaned up
#if 1
boolean P_PathTraverse(fixed_t x1, fixed_t y1, fixed_t x2, fixed_t y2, int flags, boolean trav(intercept_t*))
{
fixed_t xt1, yt1;
fixed_t xt2, yt2;
fixed_t xstep, ystep;
fixed_t partial;
fixed_t xintercept, yintercept;
int mapx, mapy;
int mapxstep, mapystep;
int count;
_g->validcount++;
intercept_p = intercepts;
if (!((x1 - _g->bmaporgx) & (MAPBLOCKSIZE - 1)))
x1 += FRACUNIT; // don't side exactly on a line
if (!((y1 - _g->bmaporgy) & (MAPBLOCKSIZE - 1)))
y1 += FRACUNIT; // don't side exactly on a line
_g->trace.x = x1;
_g->trace.y = y1;
_g->trace.dx = x2 - x1;
_g->trace.dy = y2 - y1;
x1 -= _g->bmaporgx;
y1 -= _g->bmaporgy;
xt1 = x1 >> MAPBLOCKSHIFT;
yt1 = y1 >> MAPBLOCKSHIFT;
x2 -= _g->bmaporgx;
y2 -= _g->bmaporgy;
xt2 = x2 >> MAPBLOCKSHIFT;
yt2 = y2 >> MAPBLOCKSHIFT;
if (xt2 > xt1)
{
mapxstep = 1;
partial = FRACUNIT - ((x1 >> MAPBTOFRAC) & (FRACUNIT - 1));
ystep = FixedDiv(y2 - y1, D_abs(x2 - x1));
}
else if (xt2 < xt1)
{
mapxstep = -1;
partial = (x1 >> MAPBTOFRAC) & (FRACUNIT - 1);
ystep = FixedDiv(y2 - y1, D_abs(x2 - x1));
}
else
{
mapxstep = 0;
partial = FRACUNIT;
ystep = 256 * FRACUNIT;
}
yintercept = (y1 >> MAPBTOFRAC) + FixedMul(partial, ystep);
if (yt2 > yt1)
{
mapystep = 1;
partial = FRACUNIT - ((y1 >> MAPBTOFRAC) & (FRACUNIT - 1));
xstep = FixedDiv(x2 - x1, D_abs(y2 - y1));
}
else if (yt2 < yt1)
{
mapystep = -1;
partial = (y1 >> MAPBTOFRAC) & (FRACUNIT - 1);
xstep = FixedDiv(x2 - x1, D_abs(y2 - y1));
}
else
{
mapystep = 0;
partial = FRACUNIT;
xstep = 256 * FRACUNIT;
}
xintercept = (x1 >> MAPBTOFRAC) + FixedMul(partial, xstep);
// Step through map blocks.
// Count is present to prevent a round off error
// from skipping the break.
mapx = xt1;
mapy = yt1;
for (count = 0; count < 64; count++)
{
if (flags & PT_ADDLINES)
if (!P_BlockLinesIterator(mapx, mapy, PIT_AddLineIntercepts))
return false; // early out
if (flags & PT_ADDTHINGS)
if (!P_BlockThingsIterator(mapx, mapy, PIT_AddThingIntercepts))
return false; // early out
if (mapx == xt2 && mapy == yt2)
break;
if ((yintercept >> FRACBITS) == mapy)
{
yintercept += ystep;
mapx += mapxstep;
}
else if ((xintercept >> FRACBITS) == mapx)
{
xintercept += xstep;
mapy += mapystep;
}
}
// go through the sorted list
return P_TraverseIntercepts(trav, FRACUNIT);
}
#elif 0
boolean P_PathTraverse(fixed_t x1, fixed_t y1, fixed_t x2, fixed_t y2, int flags, boolean trav(intercept_t*))
{
fixed_t xt1, yt1;
fixed_t xt2, yt2;
fixed_t xstep, ystep;
fixed_t partial;
fixed_t xintercept, yintercept;
int mapx, mapy;
int mapx1, mapy1;
int mapxstep, mapystep;
int count;
_g->validcount++;
intercept_p = intercepts;
if (!((x1 - _g->bmaporgx) & (MAPBLOCKSIZE - 1)))
x1 += FRACUNIT; // don't side exactly on a line
if (!((y1 - _g->bmaporgy) & (MAPBLOCKSIZE - 1)))
y1 += FRACUNIT; // don't side exactly on a line
_g->trace.x = x1;
_g->trace.y = y1;
_g->trace.dx = x2 - x1;
_g->trace.dy = y2 - y1;
if (demo_compatibility)
{
int_64_t _x1, _x2, _y1, _y2;
_x1 = (int_64_t)x1 - _g->bmaporgx;
_y1 = (int_64_t)y1 - _g->bmaporgy;
xt1 = (int)(_x1>>MAPBLOCKSHIFT);
yt1 = (int)(_y1>>MAPBLOCKSHIFT);
mapx1 = (int)(_x1>>MAPBTOFRAC);
mapy1 = (int)(_y1>>MAPBTOFRAC);
_x2 = (int_64_t)x2 - _g->bmaporgx;
_y2 = (int_64_t)y2 - _g->bmaporgy;
xt2 = (int)(_x2>>MAPBLOCKSHIFT);
yt2 = (int)(_y2>>MAPBLOCKSHIFT);
x1 -= _g->bmaporgx;
y1 -= _g->bmaporgy;
x2 -= _g->bmaporgx;
y2 -= _g->bmaporgy;
}
else
{
x1 -= _g->bmaporgx;
y1 -= _g->bmaporgy;
xt1 = x1>>MAPBLOCKSHIFT;
yt1 = y1>>MAPBLOCKSHIFT;
mapx1 = x1>>MAPBTOFRAC;
mapy1 = y1>>MAPBTOFRAC;
x2 -= _g->bmaporgx;
y2 -= _g->bmaporgy;
xt2 = x2>>MAPBLOCKSHIFT;
yt2 = y2>>MAPBLOCKSHIFT;
}
if (xt2 > xt1)
{
mapxstep = 1;
partial = FRACUNIT - (mapx1&(FRACUNIT-1));
ystep = FixedDiv (y2-y1,D_abs(x2-x1));
}
else
if (xt2 < xt1)
{
mapxstep = -1;
partial = mapx1&(FRACUNIT-1);
ystep = FixedDiv (y2-y1,D_abs(x2-x1));
}
else
{
mapxstep = 0;
partial = FRACUNIT;
ystep = 256 * FRACUNIT;
}
yintercept = mapy1 + FixedMul(partial, ystep);
if (yt2 > yt1)
{
mapystep = 1;
partial = FRACUNIT - (mapy1&(FRACUNIT-1));
xstep = FixedDiv (x2-x1,D_abs(y2-y1));
}
else if (yt2 < yt1)
{
mapystep = -1;
partial = mapy1&(FRACUNIT-1);
xstep = FixedDiv (x2-x1,D_abs(y2-y1));
}
else
{
mapystep = 0;
partial = FRACUNIT;
xstep = 256 * FRACUNIT;
}
xintercept = mapx1 + FixedMul(partial, xstep);
// Step through map blocks.
// Count is present to prevent a round off error
// from skipping the break.
mapx = xt1;
mapy = yt1;
for (count = 0; count < 64; count++)
{
if (flags & PT_ADDLINES)
if (!P_BlockLinesIterator(mapx, mapy, PIT_AddLineIntercepts))
return false; // early out
if (flags & PT_ADDTHINGS)
if (!P_BlockThingsIterator(mapx, mapy, PIT_AddThingIntercepts))
return false; // early out
if (mapx == xt2 && mapy == yt2)
break;
if ((yintercept >> FRACBITS) == mapy)
{
yintercept += ystep;
mapx += mapxstep;
}
else if ((xintercept >> FRACBITS) == mapx)
{
xintercept += xstep;
mapy += mapystep;
}
}
// go through the sorted list
return P_TraverseIntercepts(trav, FRACUNIT);
}
#else
boolean
P_PathTraverse
( fixed_t x1,
fixed_t y1,
fixed_t x2,
fixed_t y2,
int flags,
boolean (*trav) (intercept_t *))
{
fixed_t xt1;
fixed_t yt1;
fixed_t xt2;
fixed_t yt2;
fixed_t xstep;
fixed_t ystep;
fixed_t partial;
fixed_t xintercept;
fixed_t yintercept;
int mapx;
int mapy;
int mapxstep;
int mapystep;
int count;
//earlyout = (flags & PT_EARLYOUT) != 0;
_g->validcount++;
intercept_p = intercepts;
if ( ((x1-_g->bmaporgx)&(MAPBLOCKSIZE-1)) == 0)
x1 += FRACUNIT; // don't side exactly on a line
if ( ((y1-_g->bmaporgy)&(MAPBLOCKSIZE-1)) == 0)
y1 += FRACUNIT; // don't side exactly on a line
_g->trace.x = x1;
_g->trace.y = y1;
_g->trace.dx = x2 - x1;
_g->trace.dy = y2 - y1;
x1 -= _g->bmaporgx;
y1 -=_g-> bmaporgy;
xt1 = x1>>MAPBLOCKSHIFT;
yt1 = y1>>MAPBLOCKSHIFT;
x2 -= _g->bmaporgx;
y2 -= _g->bmaporgy;
xt2 = x2>>MAPBLOCKSHIFT;
yt2 = y2>>MAPBLOCKSHIFT;
if (xt2 > xt1)
{
mapxstep = 1;
partial = FRACUNIT - ((x1>>MAPBTOFRAC)&(FRACUNIT-1));
ystep = FixedDiv (y2-y1,abs(x2-x1));
}
else if (xt2 < xt1)
{
mapxstep = -1;
partial = (x1>>MAPBTOFRAC)&(FRACUNIT-1);
ystep = FixedDiv (y2-y1,abs(x2-x1));
}
else
{
mapxstep = 0;
partial = FRACUNIT;
ystep = 256*FRACUNIT;
}
yintercept = (y1>>MAPBTOFRAC) + FixedMul (partial, ystep);
if (yt2 > yt1)
{
mapystep = 1;
partial = FRACUNIT - ((y1>>MAPBTOFRAC)&(FRACUNIT-1));
xstep = FixedDiv (x2-x1,abs(y2-y1));
}
else if (yt2 < yt1)
{
mapystep = -1;
partial = (y1>>MAPBTOFRAC)&(FRACUNIT-1);
xstep = FixedDiv (x2-x1,abs(y2-y1));
}
else
{
mapystep = 0;
partial = FRACUNIT;
xstep = 256*FRACUNIT;
}
xintercept = (x1>>MAPBTOFRAC) + FixedMul (partial, xstep);
// Step through map blocks.
// Count is present to prevent a round off error
// from skipping the break.
mapx = xt1;
mapy = yt1;
for (count = 0 ; count < 64 ; count++)
{
if (flags & PT_ADDLINES)
{
if (!P_BlockLinesIterator (mapx, mapy,PIT_AddLineIntercepts))
return false; // early out
}
if (flags & PT_ADDTHINGS)
{
if (!P_BlockThingsIterator (mapx, mapy,PIT_AddThingIntercepts))
return false; // early out
}
if (mapx == xt2
&& mapy == yt2)
{
break;
}
if ( (yintercept >> FRACBITS) == mapy)
{
yintercept += ystep;
mapx += mapxstep;
}
else if ( (xintercept >> FRACBITS) == mapx)
{
xintercept += xstep;
mapy += mapystep;
}
}
// go through the sorted list
return P_TraverseIntercepts ( trav, FRACUNIT );
}
#endif
Loaded 100 of 661 files, more files were not shown because too many files have changed in this diff. Show more