gore

package module
v0.0.0-...-77edf00 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 12, 2026 License: GPL-2.0 Imports: 17 Imported by: 0

README ΒΆ

πŸ”₯ GORE πŸ”₯

A Minimal Go Port of doomgeneric

    β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•—  β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•—  β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•— β–ˆβ–ˆβ–ˆβ•—   β–ˆβ–ˆβ–ˆβ•—
    β–ˆβ–ˆβ•”β•β•β–ˆβ–ˆβ•—β–ˆβ–ˆβ•”β•β•β•β–ˆβ–ˆβ•—β–ˆβ–ˆβ•”β•β•β•β–ˆβ–ˆβ•—β–ˆβ–ˆβ–ˆβ–ˆβ•— β–ˆβ–ˆβ–ˆβ–ˆβ•‘
    β–ˆβ–ˆβ•‘  β–ˆβ–ˆβ•‘β–ˆβ–ˆβ•‘   β–ˆβ–ˆβ•‘β–ˆβ–ˆβ•‘   β–ˆβ–ˆβ•‘β–ˆβ–ˆβ•”β–ˆβ–ˆβ–ˆβ–ˆβ•”β–ˆβ–ˆβ•‘
    β–ˆβ–ˆβ•‘  β–ˆβ–ˆβ•‘β–ˆβ–ˆβ•‘   β–ˆβ–ˆβ•‘β–ˆβ–ˆβ•‘   β–ˆβ–ˆβ•‘β–ˆβ–ˆβ•‘β•šβ–ˆβ–ˆβ•”β•β–ˆβ–ˆβ•‘
    β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•”β•β•šβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•”β•β•šβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•”β•β–ˆβ–ˆβ•‘ β•šβ•β• β–ˆβ–ˆβ•‘
    β•šβ•β•β•β•β•β•  β•šβ•β•β•β•β•β•  β•šβ•β•β•β•β•β• β•šβ•β•     β•šβ•β•
                    .GO

TLDR

Tired of reading already?

wget https://distro.ibiblio.org/slitaz/sources/packages/d/doom1.wad
go run github.com/AndreRenaud/gore/example/termdoom@latest

πŸ’€ WHAT FRESH HELL IS THIS?

This is a minimal, platform-agnostic Go port of the legendary DOOM engine, transpiled from the doomgeneric codebase. No CGo. No platform dependencies. Just pure, unadulterated demon-slaying action powered by the glory of Go's cross-compilation.

The original C code was converted to Go using (modernc.org/ccgo/v4), by cznic (https://gitlab.com/cznic/doomgeneric.git). This was then manually cleaned up to remove a lot of manual pointer manipulation, and make things more Go-ish, whilst still maintaining compatibility with the original Doom, and its overall structure.

πŸ”« FEATURES

  • βœ… Platform Agnostic: Runs anywhere Go runs
  • βœ… Minimal Dependencies: Only requires Go standard library
  • βœ… Multiple DOOM Versions: Supports DOOM, DOOM II, Ultimate DOOM, Final DOOM
  • βœ… WAD File Support: Bring your own demons via WAD files
  • βœ… Memory Safe: Go's GC protects you from buffer overflows (but not from Cacodemons) (WIP - 95% complete)
  • βœ… Cross Compilation: Build for any target from any platform
Missing Features
  • One instance per process: Still has a lot of the original global variables, which prevent multiple instances from running
  • Random exported consts: The original C code used the standard convention of all upper case for const/enum values. This results in the Go code assuming these are exported values, when really they're internal state info
  • Nice external API for state inspection: It would be good to be able to change the running state externally, without exposing everything in such a raw way
  • unsafe: There are still some instances of unsafe in the code. It would be good to get rid of these to have better bounds access guarantees

πŸš€ INSTALLATION

Prerequisites
  • Go 1.24+
  • A WAD file
Running the examples

These examples are both very minimal, and whilst technically run the game, they are not really fully complete games in their own right (ie: Missing key bindings etc...). They all assume that a Doom wad is available in the current directory. The shareware Doom wad is available at https://www.doomworld.com/classicdoom/info/shareware.php, or bring your own from a commercial copy.

git clone https://github.com/AndreRenaud/gore
cd gore
Terminal based

This example renders the Doom output using ANSI color codes suitable for a 256-bit color capable terminal. It has very limited input support, as terminals typically do not support key-up events, or control-key support. So fire has been remapped to ,, and it is necessary to repeatedly tap keys to get them to continue, as opposed to press & hold.

go run ./example/termdoom -iwad doom1.wad

Web based
go run ./example/webserver

Now browse to http://localhost:8080 to play

Ebitengine
go run ./example/ebitengine

The window should pop up to run Doom

Getting WAD Files

You need the game data files (WAD) to run DOOM:

  • Shareware: Download doom1.wad (free)
  • Retail: Use your legally owned copy of DOOM.WAD or doom2.wad
  • Ultimate DOOM: doom.wad from Ultimate DOOM
  • Final DOOM: tnt.wad or plutonia.wad

πŸ”§ PLATFORM IMPLEMENTATION

Similar to doomgeneric, the actual input/output is provided externally. The following interface is required:

type DoomFrontend interface {
    DrawFrame(img *image.RGBA)
    SetTitle(title string)
    GetEvent(event *DoomEvent) bool
    CacheSound(name string, data []byte)
    PlaySound(name string, channel, vol, sep int)
}
Function Purpose
DrawFrame() Render the frame to your display
SetTitle() Set the window title as appropriate to the given WAD
GetEvent() Report key presses/mouse movements
CacheSound() This will supply sound effect 8-bit 11025Hz mono audio samples
PlaySound() Play a given sound effect

Only DrawFrame and GetEvent are vital to implement to get a functioning game. The others can be left blank, and things will still basically function fine.

πŸ“œ LICENSE

DOOM source code is released under the GNU General Public License.
This Go port maintains the same licensing terms.

Documentation ΒΆ

Index ΒΆ

Constants ΒΆ

View Source
const AM_NUMMARKPOINTS = 10
View Source
const ANG1801 = 2147483648
View Source
const ANG18011 = 2147483648
View Source
const ANG18013 = 2147483648
View Source
const ANG18015 = 2147483648
View Source
const ANG1803 = 2147483648
View Source
const ANG1805 = 2147483648
View Source
const ANG1807 = 2147483648
View Source
const ANG1809 = 2147483648
View Source
const ANG2701 = 3221225472
View Source
const ANG2703 = 3221225472
View Source
const ANG2705 = 3221225472
View Source
const ANG451 = 536870912
View Source
const ANG453 = 536870912
View Source
const ANG455 = 536870912
View Source
const ANG457 = 536870912
View Source
const ANG901 = 1073741824
View Source
const ANG903 = 1073741824
View Source
const ANG905 = 1073741824
View Source
const ANG907 = 1073741824
View Source
const ANG909 = 1073741824
View Source
const ANGLETOFINESHIFT = 19
View Source
const ANGLETOSKYSHIFT = 22
View Source
const ANIM_ALWAYS = 0
View Source
const ANIM_LEVEL = 2
View Source
const ANIM_RANDOM = 1
View Source
const BACKUPTICS = 128
View Source
const BASETHRESHOLD = 100
View Source
const BASEYCENTER = 100
View Source
const BLACK = 0
View Source
const BODYQUESIZE = 32
View Source
const BONUSADD = 6
View Source
const BOXBOTTOM = 1
View Source
const BOXLEFT = 2
View Source
const BOXRIGHT = 3
View Source
const BOXTOP = 0
View Source
const BUTTONTIME = 35
View Source
const CF_GODMODE = 2
View Source
const CF_NOCLIP = 1
View Source
const CF_NOMOMENTUM = 4
View Source
const DEFAULT_FLOAT = 3
View Source
const DEFAULT_INT_HEX = 1
View Source
const DEFAULT_KEY = 4
View Source
const DEFAULT_RAM = 16
View Source
const DEFAULT_SPECHIT_MAGIC = 29400216
View Source
const DEFAULT_STRING = 2
View Source
const DEH_DEFAULT_BFG_CELLS_PER_SHOT = 40
View Source
const DEH_DEFAULT_BLUE_ARMOR_CLASS = 2
View Source
const DEH_DEFAULT_GOD_MODE_HEALTH = 100
View Source
const DEH_DEFAULT_GREEN_ARMOR_CLASS = 1
View Source
const DEH_DEFAULT_IDFA_ARMOR = 200
View Source
const DEH_DEFAULT_IDFA_ARMOR_CLASS = 2
View Source
const DEH_DEFAULT_IDKFA_ARMOR = 200
View Source
const DEH_DEFAULT_IDKFA_ARMOR_CLASS = 2
View Source
const DEH_DEFAULT_INITIAL_BULLETS = 50
View Source
const DEH_DEFAULT_INITIAL_HEALTH = 100
View Source
const DEH_DEFAULT_MAX_ARMOR = 200
View Source
const DEH_DEFAULT_MAX_HEALTH = 200
View Source
const DEH_DEFAULT_MAX_SOULSPHERE = 200
View Source
const DEH_DEFAULT_MEGASPHERE_HEALTH = 200
View Source
const DEH_DEFAULT_SOULSPHERE_HEALTH = 100
View Source
const DEH_DEFAULT_SPECIES_INFIGHTING = 0
View Source
const DEMOMARKER = 128
View Source
const DISTMAP = 2
View Source
const DI_EAST = 0
View Source
const DI_NODIR = 8
View Source
const DI_NORTH = 2
View Source
const DI_NORTHEAST = 1
View Source
const DI_NORTHWEST = 3
View Source
const DI_SOUTH = 6
View Source
const DI_SOUTHEAST = 7
View Source
const DI_SOUTHWEST = 5
View Source
const DI_WEST = 4
View Source
const DM_KILLERSX = 10
View Source
const DM_KILLERSY = 100
View Source
const DM_MATRIXX = 42
View Source
const DM_MATRIXY = 68
View Source
const DM_SPACINGX = 40
View Source
const DM_TOTALSX = 269
View Source
const DM_VICTIMSX = 5
View Source
const DM_VICTIMSY = 50
View Source
const DONUT_FLOORHEIGHT_DEFAULT = 0
View Source
const DONUT_FLOORPIC_DEFAULT = 22
View Source
const DOOM_191_VERSION = 111
View Source
const DOS_MEM_DUMP_SIZE = 10
View Source
const EISDIR = 21
View Source
const FASTDARK = 15
View Source
const FF_FRAMEMASK1 = 32767
View Source
const FF_FRAMEMASK3 = 32767
View Source
const FF_FULLBRIGHT1 = 32768
View Source
const FIELDOFVIEW = 2048
View Source
const FINEANGLES = 8192
View Source
const FRACBITS = 16
View Source
const FRACUNIT = 1 << FRACBITS
View Source
const FRICTION = 59392
View Source
const FUZZTABLE = 50
View Source
const F_PANINC = 4
View Source
const F_STAGE_ARTSCREEN = 1
View Source
const F_STAGE_CAST = 2
View Source
const F_STAGE_TEXT = 0
View Source
const GLOWSPEED = 8
View Source
const GRAYSRANGE = 16
View Source
const GREENRANGE = 16
View Source
const HEIGHTBITS = 12
View Source
const HU_BROADCAST = 5
View Source
const HU_MAXLINELENGTH = 80
View Source
const HU_MSGHEIGHT = 1
View Source
const HU_MSGX = 0
View Source
const HU_MSGY = 0
View Source
const HU_TITLEX = 0
View Source
const INFRATICS = 4200
View Source
const INT_MAX1 = 2147483647
View Source
const INT_MAX11 = 2147483647
View Source
const INT_MAX13 = 2147483647
View Source
const INT_MAX15 = 2147483647
View Source
const INT_MAX17 = 2147483647
View Source
const INT_MAX19 = 2147483647
View Source
const INT_MAX5 = 2147483647
View Source
const INT_MAX7 = 2147483647
View Source
const INT_MAX9 = 2147483647
View Source
const INVERSECOLORMAP = 32
View Source
const INVISTICS = 2100
View Source
const INVULNTICS = 1050
View Source
const IRONTICS = 2100
View Source
const ITEMQUESIZE = 128
View Source
const KEY_BACKSPACE1 = 127
View Source
const KEY_BACKSPACE3 = 127
View Source
const KEY_DOWNARROW1 = 175
View Source
const KEY_ENTER = 13
View Source
const KEY_EQUALS1 = 61
View Source
const KEY_ESCAPE = 27
View Source
const KEY_FIRE1 = 163
View Source
const KEY_LEFTARROW1 = 172
View Source
const KEY_MINUS1 = 45
View Source
const KEY_PAUSE1 = 255
View Source
const KEY_RIGHTARROW1 = 174
View Source
const KEY_STRAFE_L1 = 160
View Source
const KEY_STRAFE_R1 = 161
View Source
const KEY_TAB = 9
View Source
const KEY_UPARROW1 = 173
View Source
const KEY_USE1 = 162
View Source
const LIGHTLEVELS = 16
View Source
const LIGHTSCALESHIFT = 12
View Source
const LIGHTSEGSHIFT = 4
View Source
const LIGHTZSHIFT = 20
View Source
const LINEHEIGHT = 16
View Source
const MAPBLOCKUNITS = 128
View Source
const MAXBOB = 1048576
View Source
const MAXBUTTONS = 16
View Source
const MAXCEILINGS = 30
View Source
const MAXDRAWSEGS = 256
View Source
const MAXEVENTS = 64
View Source
const MAXHEALTH = 100
View Source
const MAXINTERCEPTS_ORIGINAL = 128
View Source
const MAXLIGHTSCALE = 48
View Source
const MAXLIGHTZ = 128
View Source
const MAXLINEANIMS = 64
View Source
const MAXPLATS = 30
View Source
const MAXPLAYERS = 4
View Source
const MAXSPECIALCROSS_ORIGINAL = 8
View Source
const MAXSWITCHES = 50
View Source
const MAX_ADJOINING_SECTORS = 20
View Source
const MAX_CAPTURES = 32
View Source
const MAX_JOY_BUTTONS = 20
View Source
const MAX_MOUSE_BUTTONS = 8
View Source
const MINFRAGMENT = 64
View Source
const MIN_RAM = 16
View Source
const MOUSE_SPEED_BOX_HEIGHT = 9
View Source
const MOUSE_SPEED_BOX_WIDTH = 120
View Source
const MTF_AMBUSH = 8
View Source
const NET_MAXPLAYERS = 8
View Source
const NF_SUBSECTOR1 = 32768
View Source
const NF_SUBSECTOR3 = 32768
View Source
const NF_SUBSECTOR5 = 32768
View Source
const NG_SPACINGX = 64
View Source
const NG_STATSY = 50
View Source
const NORM_SEP = 128
View Source
const NUMAMMO = 4
View Source
const NUMBONUSPALS = 4
View Source
const NUMCARDS = 6
View Source
const NUMCOLORMAPS = 32
View Source
const NUMKEYS = 256
View Source
const NUMMAPS = 9
View Source
const NUMMOBJTYPES = 137
View Source
const NUMMUSIC = 68
View Source
const NUMPOWERS = 6
View Source
const NUMPSPRITES = 2
View Source
const NUMREDPALS = 8
View Source
const NUMSFX = 109
View Source
const NUMWEAPONS = 9
View Source
const NUM_QUITMESSAGES = 8
View Source
const NUM_VIRTUAL_BUTTONS = 10
View Source
const NoState = -1
View Source
const PLATWAIT = 3
View Source
const PT_ADDLINES = 1
View Source
const PT_ADDTHINGS = 2
View Source
const PT_EARLYOUT = 4
View Source
const Pst_DEAD = 1
View Source
const Pst_LIVE = 0
View Source
const Pst_REBORN = 2
View Source
const QUEUESIZE = 128
View Source
const RADIATIONPAL = 13
View Source
const REDRANGE = 16
View Source
const SAVEGAMESIZE = 180224
View Source
const SAVEGAME_EOF = 29
View Source
const SAVESTRINGSIZE = 24
View Source
const SBARHEIGHT = 32
View Source
const SCREENHEIGHT = 200
View Source
const SCREENHEIGHT_4_3 = 240
View Source
const SCREENWIDTH = 320
View Source
const SCREENWIDTH_4_3 = 256
View Source
const SHOWNEXTLOCDELAY = 4
View Source
const SHRT_MAX1 = 32767
View Source
const SIL_BOTH = 3
View Source
const SIL_BOTTOM = 1
View Source
const SIL_TOP = 2
View Source
const SLOPEBITS = 11
View Source
const SLOPERANGE = 2048
View Source
const SLOWDARK = 35
View Source
const SLOWTURNTICS = 6
View Source
const SNDDEVICE_ADLIB = 2
View Source
const SNDDEVICE_GENMIDI = 8
View Source
const SNDDEVICE_GUS = 5
View Source
const SNDDEVICE_SB = 3
View Source
const SP_STATSX = 50
View Source
const SP_STATSY = 50
View Source
const SP_TIMEX = 16
View Source
const STARTBONUSPALS = 9
View Source
const STARTREDPALS = 1
View Source
const STOPSPEED = 4096
View Source
const STROBEBRIGHT = 5
View Source
const ShowNextLoc = 1
View Source
const StatCount = 0
View Source
const TEXTSPEED = 3
View Source
const TEXTWAIT = 250
View Source
const TICRATE = 35
View Source
const TURBOTHRESHOLD = 50
View Source
const VDOORWAIT = 150
View Source
const VERSIONSIZE = 16
View Source
const WI_SPACINGY = 33
View Source
const WI_TITLEY = 2
View Source
const ZONEID = 1919505

Variables ΒΆ

View Source
var DG_ScreenBuffer *image.RGBA
View Source
var EpiDef menu_t
View Source
var EpisodeMenu [4]menuitem_t
View Source
var I_VideoBuffer []byte
View Source
var LoadDef menu_t
View Source
var LoadMenu [6]menuitem_t
View Source
var M_QuitResponse = func(key int32) {
	if key != key_menu_confirm {
		return
	}
	if netgame == 0 {
		if gamemode == commercial {
			s_StartSound(nil, quitsounds2[gametic>>2&7])
		} else {
			s_StartSound(nil, quitsounds[gametic>>2&7])
		}
	}
	i_Quit()
}
View Source
var MainDef menu_t
View Source
var MainMenu [6]menuitem_t
View Source
var NUMANIMS = [4]int32{
	0: int32(len(epsd0animinfo)),
	1: int32(len(epsd1animinfo)),
	2: int32(len(epsd2animinfo)),
}
View Source
var NUMCMAPS int32

C documentation

// # of commercial levels
View Source
var NewDef menu_t
View Source
var NewGameMenu [5]menuitem_t
View Source
var OptionsDef menu_t
View Source
var OptionsMenu [8]menuitem_t
View Source
var ReadDef1 menu_t
View Source
var ReadDef2 menu_t
View Source
var ReadMenu1 [1]menuitem_t
View Source
var ReadMenu2 [1]menuitem_t
View Source
var S_music [68]musicinfo_t
View Source
var S_sfx [NUMSFX]sfxinfo_t
View Source
var SaveDef menu_t
View Source
var SaveMenu [6]menuitem_t

C documentation

//
// SAVE GAME MENU
//
View Source
var SoundDef menu_t
View Source
var SoundMenu [4]menuitem_t
View Source
var TRACEANGLE angle_t

Functions ΒΆ

func EnableQuitting ΒΆ

func EnableQuitting(enable bool)

func I_GetTimeMS ΒΆ

func I_GetTimeMS() int32

func Run ΒΆ

func Run(fg DoomFrontend, args []string)

func SetVirtualFileSystem ΒΆ

func SetVirtualFileSystem(a fs.FS)

SetVirtualFileSystem sets the virtual file system

func Stop ΒΆ

func Stop()

Types ΒΆ

type DoomEvent ΒΆ

type DoomEvent struct {
	Type  Evtype_t
	Key   uint8
	Mouse struct {
		Button1 bool
		Button2 bool
		XPos    float64 // from 0-1
		YPos    float64 // from 0-1
	}
}

type DoomFrontend ΒΆ

type DoomFrontend interface {
	DrawFrame(img *image.RGBA)
	SetTitle(title string)
	GetEvent(event *DoomEvent) bool

	CacheSound(name string, data []byte)
	PlaySound(name string, channel, volume, sep int)
}

type Evtype_t ΒΆ

type Evtype_t int32
const Ev_joystick Evtype_t = 3
const Ev_keydown Evtype_t = 0
const Ev_keyup Evtype_t = 1
const Ev_mouse Evtype_t = 2
const Ev_quit Evtype_t = 4

Directories ΒΆ

Path Synopsis
example
doomocracy command
ebitengine command
sdldoom command
termdoom command
webserver command

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL