Documentation
ΒΆ
Index ΒΆ
- Constants
- Variables
- func CanSave() bool
- func Checksum() uint32
- func EnableQuitting(enable bool)
- func FrameBuffer() []byte
- func I_GetTimeMS() int32
- func IsMusData(data []byte) bool
- func LoadGameBytes(data []byte) error
- func Palette() []byte
- func PlayersInGame() uint8
- func Run(fg DoomFrontend, args []string)
- func SaveGameBytes() ([]byte, error)
- func SetVirtualFileSystem(a fs.FS)
- func StepInit(fe DoomFrontend, args []string)
- func StepNetTic(t *NetTic)
- func StepRender()
- func StepSetView(p int32)
- func StepTic(cmd TicCmd)
- func Stop()
- type DoomEvent
- type DoomFrontend
- type Evtype_t
- type MusEvent
- type MusEventType
- type MusMusic
- type MusSynth
- func (s *MusSynth) Duration() time.Duration
- func (s *MusSynth) OffsetToTime(offset int64) time.Duration
- func (s *MusSynth) Position() time.Duration
- func (s *MusSynth) Read(p []byte) (int, error)
- func (s *MusSynth) Seek(offset int64, whence int) (int64, error)
- func (s *MusSynth) SetLoop(loop bool)
- func (s *MusSynth) SetPaused(paused bool)
- func (s *MusSynth) SetVolume(volume int)
- func (s *MusSynth) TimeToOffset(t time.Duration) int64
- type NetTic
- type SoundEvent
- type Stats
- type TicCmd
Constants ΒΆ
const ( MusControllerInstrument = 0 MusControllerVolume = 3 MusSystemAllNotesOff = 11 )
MUS controller numbers, used by MusEventController & MusEventSystem. These are the only ones that DMX responds to.
const ( ButtonAttack = 1 ButtonUse = 2 ButtonChange = 4 // change weapon; weapon number in ButtonWeaponMask ButtonWeaponMask = 0x38 // (weapon number) << ButtonWeaponShift ButtonWeaponShift = 3 ButtonSpecial = 0x80 // pause/savegame; never valid from a remote player )
Button bits for TicCmd.Buttons. These are the engine's bt_* values from d_event.h, exported for step API hosts.
const AM_NUMMARKPOINTS = 10
const ANG1801 = 2147483648
const ANG18011 = 2147483648
const ANG18013 = 2147483648
const ANG18015 = 2147483648
const ANG1803 = 2147483648
const ANG1805 = 2147483648
const ANG1807 = 2147483648
const ANG1809 = 2147483648
const ANG2701 = 3221225472
const ANG2703 = 3221225472
const ANG2705 = 3221225472
const ANG451 = 536870912
const ANG453 = 536870912
const ANG455 = 536870912
const ANG457 = 536870912
const ANG901 = 1073741824
const ANG903 = 1073741824
const ANG905 = 1073741824
const ANG907 = 1073741824
const ANG909 = 1073741824
const ANGLETOFINESHIFT = 19
const ANGLETOSKYSHIFT = 22
const ANIM_ALWAYS = 0
const ANIM_LEVEL = 2
const ANIM_RANDOM = 1
const BACKUPTICS = 128
const BASETHRESHOLD = 100
const BASEYCENTER = 100
const BLACK = 0
const BODYQUESIZE = 32
const BONUSADD = 6
const BOXBOTTOM = 1
const BOXLEFT = 2
const BOXRIGHT = 3
const BOXTOP = 0
const BUTTONTIME = 35
const CF_GODMODE = 2
const CF_NOCLIP = 1
const CF_NOMOMENTUM = 4
const DEFAULT_FLOAT = 3
const DEFAULT_INT_HEX = 1
const DEFAULT_KEY = 4
const DEFAULT_RAM = 16
const DEFAULT_SPECHIT_MAGIC = 29400216
const DEFAULT_STRING = 2
const DEH_DEFAULT_BFG_CELLS_PER_SHOT = 40
const DEH_DEFAULT_BLUE_ARMOR_CLASS = 2
const DEH_DEFAULT_GOD_MODE_HEALTH = 100
const DEH_DEFAULT_GREEN_ARMOR_CLASS = 1
const DEH_DEFAULT_IDFA_ARMOR = 200
const DEH_DEFAULT_IDFA_ARMOR_CLASS = 2
const DEH_DEFAULT_IDKFA_ARMOR = 200
const DEH_DEFAULT_IDKFA_ARMOR_CLASS = 2
const DEH_DEFAULT_INITIAL_BULLETS = 50
const DEH_DEFAULT_INITIAL_HEALTH = 100
const DEH_DEFAULT_MAX_ARMOR = 200
const DEH_DEFAULT_MAX_HEALTH = 200
const DEH_DEFAULT_MAX_SOULSPHERE = 200
const DEH_DEFAULT_MEGASPHERE_HEALTH = 200
const DEH_DEFAULT_SOULSPHERE_HEALTH = 100
const DEH_DEFAULT_SPECIES_INFIGHTING = 0
const DEMOMARKER = 128
const DISTMAP = 2
const DI_EAST = 0
const DI_NODIR = 8
const DI_NORTH = 2
const DI_NORTHEAST = 1
const DI_NORTHWEST = 3
const DI_SOUTH = 6
const DI_SOUTHEAST = 7
const DI_SOUTHWEST = 5
const DI_WEST = 4
const DM_KILLERSX = 10
const DM_KILLERSY = 100
const DM_MATRIXX = 42
const DM_MATRIXY = 68
const DM_SPACINGX = 40
const DM_TOTALSX = 269
const DM_VICTIMSX = 5
const DM_VICTIMSY = 50
const DONUT_FLOORHEIGHT_DEFAULT = 0
const DONUT_FLOORPIC_DEFAULT = 22
const DOOM_191_VERSION = 111
const DOS_MEM_DUMP_SIZE = 10
const EISDIR = 21
const FASTDARK = 15
const FF_FRAMEMASK1 = 32767
const FF_FRAMEMASK3 = 32767
const FF_FULLBRIGHT1 = 32768
const FIELDOFVIEW = 2048
const FINEANGLES = 8192
const FRACBITS = 16
const FRACUNIT = 1 << FRACBITS
const FRICTION = 59392
const FUZZTABLE = 50
const F_PANINC = 4
const F_STAGE_ARTSCREEN = 1
const F_STAGE_CAST = 2
const F_STAGE_TEXT = 0
const GLOWSPEED = 8
const GRAYSRANGE = 16
const GREENRANGE = 16
const HEIGHTBITS = 12
const HU_BROADCAST = 5
const HU_MAXLINELENGTH = 80
const HU_MSGHEIGHT = 1
const HU_MSGX = 0
const HU_MSGY = 0
const HU_TITLEX = 0
const INFRATICS = 4200
const INT_MAX1 = 2147483647
const INT_MAX11 = 2147483647
const INT_MAX13 = 2147483647
const INT_MAX15 = 2147483647
const INT_MAX17 = 2147483647
const INT_MAX19 = 2147483647
const INT_MAX5 = 2147483647
const INT_MAX7 = 2147483647
const INT_MAX9 = 2147483647
const INVERSECOLORMAP = 32
const INVISTICS = 2100
const INVULNTICS = 1050
const IRONTICS = 2100
const ITEMQUESIZE = 128
const KEY_BACKSPACE1 = 127
const KEY_BACKSPACE3 = 127
const KEY_DOWNARROW1 = 175
const KEY_ENTER = 13
const KEY_EQUALS1 = 61
const KEY_ESCAPE = 27
const KEY_FIRE1 = 163
const KEY_LEFTARROW1 = 172
const KEY_MINUS1 = 45
const KEY_PAUSE1 = 255
const KEY_RIGHTARROW1 = 174
const KEY_STRAFE_L1 = 160
const KEY_STRAFE_R1 = 161
const KEY_TAB = 9
const KEY_UPARROW1 = 173
const KEY_USE1 = 162
const LIGHTLEVELS = 16
const LIGHTSCALESHIFT = 12
const LIGHTSEGSHIFT = 4
const LIGHTZSHIFT = 20
const LINEHEIGHT = 16
const MAPBLOCKUNITS = 128
const MAXBOB = 1048576
const MAXBUTTONS = 16
const MAXCEILINGS = 30
const MAXDRAWSEGS = 256
const MAXEVENTS = 64
const MAXHEALTH = 100
const MAXINTERCEPTS_ORIGINAL = 128
const MAXLIGHTSCALE = 48
const MAXLIGHTZ = 128
const MAXLINEANIMS = 64
const MAXPLATS = 30
const MAXPLAYERS = 4
const MAXSPECIALCROSS_ORIGINAL = 8
const MAXSWITCHES = 50
const MAX_ADJOINING_SECTORS = 20
const MAX_CAPTURES = 32
const MAX_JOY_BUTTONS = 20
const MAX_MOUSE_BUTTONS = 8
const MINFRAGMENT = 64
const MIN_RAM = 16
const MOUSE_SPEED_BOX_HEIGHT = 9
const MOUSE_SPEED_BOX_WIDTH = 120
const MTF_AMBUSH = 8
const MusPercussionChannel = 15
MusPercussionChannel is the MUS channel used for percussion (MIDI channel 10)
const MusTicksPerSecond = 140
MusTicksPerSecond is the playback rate of Doom MUS files
const MusicSampleRate = 44100
MusicSampleRate is the sample rate of the stream passed to DoomFrontend.PlayMusic
const NET_MAXPLAYERS = 8
const NF_SUBSECTOR1 = 32768
const NF_SUBSECTOR3 = 32768
const NF_SUBSECTOR5 = 32768
const NG_SPACINGX = 64
const NG_STATSY = 50
const NORM_SEP = 128
const NUMAMMO = 4
const NUMBONUSPALS = 4
const NUMCARDS = 6
const NUMCOLORMAPS = 32
const NUMKEYS = 256
const NUMMAPS = 9
const NUMMOBJTYPES = 137
const NUMMUSIC = 68
const NUMPOWERS = 6
const NUMPSPRITES = 2
const NUMREDPALS = 8
const NUMSFX = 109
const NUMWEAPONS = 9
const NUM_QUITMESSAGES = 8
const NUM_VIRTUAL_BUTTONS = 10
const NoState = -1
const PLATWAIT = 3
const PT_ADDLINES = 1
const PT_ADDTHINGS = 2
const PT_EARLYOUT = 4
const Pst_DEAD = 1
const Pst_LIVE = 0
const Pst_REBORN = 2
const QUEUESIZE = 128
const RADIATIONPAL = 13
const REDRANGE = 16
const SAVEGAMESIZE = 180224
const SAVEGAME_EOF = 29
const SAVESTRINGSIZE = 24
const SBARHEIGHT = 32
const SCREENHEIGHT = 200
const SCREENHEIGHT_4_3 = 240
const SCREENWIDTH = 320
const SCREENWIDTH_4_3 = 256
const SHOWNEXTLOCDELAY = 4
const SHRT_MAX1 = 32767
const SIL_BOTH = 3
const SIL_BOTTOM = 1
const SIL_TOP = 2
const SLOPEBITS = 11
const SLOPERANGE = 2048
const SLOWDARK = 35
const SLOWTURNTICS = 6
const SNDDEVICE_ADLIB = 2
const SNDDEVICE_GENMIDI = 8
const SNDDEVICE_GUS = 5
const SNDDEVICE_SB = 3
const SP_STATSX = 50
const SP_STATSY = 50
const SP_TIMEX = 16
const STARTBONUSPALS = 9
const STARTREDPALS = 1
const STOPSPEED = 4096
const STROBEBRIGHT = 5
const ShowNextLoc = 1
const StatCount = 0
const TEXTSPEED = 3
const TEXTWAIT = 250
const TICRATE = 35
const TURBOTHRESHOLD = 50
const VDOORWAIT = 150
const VERSIONSIZE = 16
const WI_SPACINGY = 33
const WI_TITLEY = 2
const ZONEID = 1919505
Variables ΒΆ
var DG_ScreenBuffer *image.RGBA
var EpiDef menu_t
var EpisodeMenu [4]menuitem_t
var ErrInvalidGENMIDI = errors.New("invalid GENMIDI lump")
var (
ErrInvalidMusFile = errors.New("invalid MUS file")
)
var I_VideoBuffer []byte
var LoadDef menu_t
var LoadMenu [6]menuitem_t
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() }
var MainDef menu_t
var MainMenu [6]menuitem_t
var NUMANIMS = [4]int32{ 0: int32(len(epsd0animinfo)), 1: int32(len(epsd1animinfo)), 2: int32(len(epsd2animinfo)), }
var NUMCMAPS int32
C documentation
// # of commercial levels
var NewDef menu_t
var NewGameMenu [5]menuitem_t
var OptionsDef menu_t
var OptionsMenu [8]menuitem_t
var ReadDef1 menu_t
var ReadDef2 menu_t
var ReadMenu1 [1]menuitem_t
var ReadMenu2 [1]menuitem_t
var S_music [68]musicinfo_t
var S_sfx [NUMSFX]sfxinfo_t
var SaveDef menu_t
var SaveMenu [6]menuitem_t
C documentation
// // SAVE GAME MENU //
var SoundDef menu_t
var SoundMenu [4]menuitem_t
var TRACEANGLE angle_t
Functions ΒΆ
func CanSave ΒΆ
func CanSave() bool
CanSave reports whether the game is in a state that SaveGameBytes can capture: in a level, with the player alive. In a netgame dead players are fine (they respawn when they press use), but everyone in the game must have spawned.
func Checksum ΒΆ
func Checksum() uint32
Checksum hashes the simulation state: RNG index, level time and every map object's position, momentum, angle, health and state. Two engines that have consumed the same ticcmds from the same starting point return the same value; if they don't, they have desynced.
Cost is O(n) in the number of live map objects, since it walks the thinker list. Hashing every object is deliberate: a cheaper checksum that skipped some of them would miss desyncs.
func EnableQuitting ΒΆ
func EnableQuitting(enable bool)
func FrameBuffer ΒΆ
func FrameBuffer() []byte
FrameBuffer returns the 320x200 palette-indexed frame buffer as last drawn by StepRender. The slice is owned by the engine.
func I_GetTimeMS ΒΆ
func I_GetTimeMS() int32
func LoadGameBytes ΒΆ
LoadGameBytes restores a savegame produced by SaveGameBytes. It should be called on a freshly initialised engine. If it returns an error the engine may be left partly restored, and should be re-initialised or loaded again before use.
func Palette ΒΆ
func Palette() []byte
Palette returns the current 256 entry RGB palette (768 bytes). DOOM uses palette swaps for damage/pickup flashes, so this changes over time.
func PlayersInGame ΒΆ
func PlayersInGame() uint8
PlayersInGame returns a bitmask of the players in the game.
func Run ΒΆ
func Run(fg DoomFrontend, args []string)
func SaveGameBytes ΒΆ
SaveGameBytes serialises the current level into a vanilla-format savegame, followed by a small trailer with state vanilla doesn't save (RNG indices and the tic counter). Unlike g_DoSaveGame it does not print "game saved" or otherwise touch game state.
func SetVirtualFileSystem ΒΆ
SetVirtualFileSystem sets the virtual file system
func StepInit ΒΆ
func StepInit(fe DoomFrontend, args []string)
StepInit initialises the engine for stepping. args are regular DOOM command line arguments, e.g. {"-iwad", "doom1.wad", "-warp", "1", "1", "-skill", "3"}. Only one engine may exist per process (or per WASM instance).
func StepNetTic ΒΆ
func StepNetTic(t *NetTic)
StepNetTic runs exactly one game tic of a multiplayer game.
func StepRender ΒΆ
func StepRender()
StepRender draws the current game state into the frame buffer. It only touches renderer state, never game state, so a host can render as often or as rarely as it likes without affecting determinism.
func StepSetView ΒΆ
func StepSetView(p int32)
StepSetView chooses whose eyes and status bar StepRender draws, and whose ears hear the sounds.
This sets consoleplayer, which in vanilla DOOM only affects the user interface and sound, never the simulation. So nodes looking through different players' eyes stay in sync.
Types ΒΆ
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)
// PlayMusic starts playing a stream of music, replacing any that is
// already playing. The stream is signed 16-bit little-endian stereo at
// MusicSampleRate. Pausing, volume and looping are handled within the
// stream. A nil stream means the music should stop.
PlayMusic(music io.Reader)
}
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
type MusEventType ΒΆ
type MusEventType byte
const ( MusEventRelease MusEventType = iota MusEventPlay MusEventPitchBend MusEventSystem MusEventController MusEventEndOfMeasure MusEventFinish MusEventUnused )
type MusMusic ΒΆ
type MusMusic struct {
Events []MusEvent // These are guaranteed to be in order of time
Ticks uint32 // Total length of the song, in ticks
}
MusMusic represents the content of a MUS file. See https://doomwiki.org/wiki/MUS & https://moddingwiki.shikadi.net/wiki/MUS_Format
func NewMusMusic ΒΆ
type MusSynth ΒΆ
type MusSynth struct {
// contains filtered or unexported fields
}
MusSynth plays a MusMusic through an emulated OPL FM synthesizer, using the instruments from a GENMIDI lump, the same way Doom's DMX library did.
It implements io.ReadSeeker, producing signed 16-bit little-endian stereo PCM. Offsets are measured in bytes of PCM output, so it can be handed straight to an audio player such as oto. It is safe to call its methods from multiple goroutines.
func NewMusSynth ΒΆ
NewMusSynth creates a synthesizer for the given song, producing samples at sampleRate. genmidi is the contents of the GENMIDI lump from a WAD.
func (*MusSynth) OffsetToTime ΒΆ
OffsetToTime converts a byte offset of PCM output into a time
func (*MusSynth) Read ΒΆ
Read implements io.Reader, producing signed 16-bit little-endian stereo samples
func (*MusSynth) Seek ΒΆ
Seek implements io.Seeker. The offset is in bytes of PCM output, and the resulting position is clamped to the length of the song.
func (*MusSynth) SetPaused ΒΆ
SetPaused pauses or resumes the song. As with DMX, pausing releases the notes being held, apart from percussion, and they're left to fade out.
type NetTic ΒΆ
type NetTic struct {
// Cmds holds the input of each player in the game. Entries for players
// who aren't in the game are ignored.
Cmds [MAXPLAYERS]TicCmd
// Leave and Join are bitmasks of players leaving and joining the game
// before this tic runs. Leaves are applied first, so a slot can be
// handed from one player to the next in a single tic.
Leave, Join uint8
}
NetTic is one tic of a multiplayer game.
type SoundEvent ΒΆ
type SoundEvent struct {
// Tic is the tic whose simulation produced the event (the value of
// Stats.Tic once that tic has run).
Tic int32 `json:"tic"`
// Kind is "start", "update" (volume/separation of a playing sound
// changed, e.g. because its source moved) or "stop".
Kind string `json:"kind"`
Channel int32 `json:"ch"`
// Name is the sound effect, e.g. "pistol"; its samples are in the WAD
// lump "DS" + upper(Name). Set for "start" only.
Name string `json:"name,omitempty"`
// Volume is 0-127. Sep is the stereo separation, 0 (left) to 254
// (right), with 128 in the centre.
Volume int32 `json:"vol,omitempty"`
Sep int32 `json:"sep,omitempty"`
}
SoundEvent is something the player should hear.
func StepSoundEvents ΒΆ
func StepSoundEvents() []SoundEvent
StepSoundEvents returns the sound events since the last call.
type Stats ΒΆ
type Stats struct {
Tic int32 `json:"tic"`
LevelTime int32 `json:"levelTime"`
GameState string `json:"gameState"`
Skill int32 `json:"skill"`
Episode int32 `json:"episode"`
Map int32 `json:"map"`
Health int32 `json:"health"`
Armor int32 `json:"armor"`
Weapon int32 `json:"weapon"`
Ammo int32 `json:"ammo"` // ammo for the ready weapon, -1 if it needs none
Dead bool `json:"dead"`
Kills int32 `json:"kills"`
TotalKills int32 `json:"totalKills"`
Items int32 `json:"items"`
TotalItems int32 `json:"totalItems"`
Secrets int32 `json:"secrets"`
TotalSecrets int32 `json:"totalSecrets"`
Checksum uint32 `json:"checksum"`
}
Stats is a snapshot of interesting game state. See GetStats.
func GetPlayerStats ΒΆ
GetPlayerStats returns a snapshot of the current game state, from player p's point of view.
type TicCmd ΒΆ
type TicCmd struct {
Forward int8 `json:"f,omitempty"` // forward (+) / backward (-) movement
Side int8 `json:"s,omitempty"` // strafe right (+) / left (-)
// AngleTurn turns left (+) or right (-); 65536 is a full turn. It is
// added to the top 16 bits of the 32-bit view angle.
AngleTurn int16 `json:"t,omitempty"`
Buttons uint8 `json:"b,omitempty"` // Button* bits
}
TicCmd is one tic of a player's input, as passed to StepTic. It is the part of the engine's internal ticcmd_t that a player controls; the rest of ticcmd_t is bookkeeping for the network code.
For reference, the keyboard moves at Forward 25 (50 when running), and turns at AngleTurn 640 per tic (1280 when running).
Source Files
ΒΆ
Directories
ΒΆ
| Path | Synopsis |
|---|---|
|
example
|
|
|
doomocracy
command
|
|
|
ebitengine
command
|
|
|
mus_player
command
Package main is a simple MUS music player.
|
Package main is a simple MUS music player. |
|
sdldoom
command
|
|
|
stepper
command
stepper drives the engine with the step API: no clock and no keyboard.
|
stepper drives the engine with the step API: no clock and no keyboard. |
|
termdoom
command
|
|
|
termgfx
command
|
|
|
webserver
command
|