Skip to content

Latest commit

 

History

History
executable file
·
239 lines (172 loc) · 8.3 KB

notes-on-rewriting.md

File metadata and controls

executable file
·
239 lines (172 loc) · 8.3 KB

I didn't start with much of a strategy beyond getting a previous game template I wrote running with a wad loader and doing the renderer. Later I decided that I wanted to try and rewrite the Doom source for max Doom compatibility.

At first I started to transform previous rendering stuff to Doom structure, this for the most part seems to have worked okay. Next I started to look at how the Thinker objects were done, and this lead me down a very deep rabbit hole...

There are many main areas:

  • Object storage

  • Modifying objects

  • Base object info and creation

  • Game states

  • Input

  • Rendering

Rust specific notes

Things need access to many different areas, like segs, lines, other Things. This means for Rust borrows to be satisfied some parts will need to be spit in to structs, and kept in a parent struct. Like so:

  • Game, the full game and state container. Does state management, level loads, orchestration etc
    • Map/Level, contains the level data and functions to work with it
    • Thinkers, all thinkers, these need access to the Map data
    • Functions and associated globals in their files can be encapsulated as Struct+impl

The below is copied from the FILES2 list in the Linux Doom port.

-----------------------------------------------------------------------
Global and misc. stuff
-----------------------------------------------------------------------
doomdata.h   -  external data definitions (WAD file structure)
doomdef.h    -  internal data definitions (game structs)
dstrings.h   -  printed strings for translation, english 
d_french.h   -  printed strings for translation

info.h
info.c      -  LUT's for Thing TAB, Frame TAB,
                generated by multigen utility
dutils.h
dutils.c     - Dave's utilities
                 including doubly-linked lists & simple state machines.
                 Used in WI, ST, AM, and d_main.c

------------------------------------------------------------------------
DOOM game loop and top level stuff
------------------------------------------------------------------------
g_game.c    -  Game loop functions, event handling etc.

                boolean  G_CheckDemoStatus (void); 
                void     G_ReadDemoTiccmd (ticcmd_t *cmd); 
                void     G_WriteDemoTiccmd (ticcmd_t *cmd); 
                void     G_PlayerReborn (int player); 
                void     G_InitNew (skill_t skill, int episode, int map); 
 
                void     G_DoReborn (int playernum); 
 
                void     G_DoLoadLevel (void); 
                void     G_DoNewGame (void); 
                void     G_DoLoadGame (void); 
                void     G_DoPlayDemo (void); 
                void     G_DoCompleted (void); 
                void     G_DoVictory (void); 
                void     G_DoWorldDone (void); 
                void     G_DoSaveGame (void); 

d_main.c    -  event handling, D_DoomMain() and other functions
                 NOT int main()

d_net.c     -  high level networking protocol code

------------------------------------------------------------------
I         Interfaces, system specifics
------------------------------------------------------------------    
i_main.c    -  main(), calls D_DoomMain().
i_svgalib.c -  Linux SVGAlib code, including main(),
                 replaces i_main.c

i_x.c       -  X11 with SHM code, use with i_main.c
i_dga.c     -  X11 DGA code, use with i_main.c
i_unix.c    -  fixed point, networking, and display stuff for UNIX

i_ibm.c     -  IBM DOS VGA graphics and key/mouse/joystick,
                 use with i_main.c
i_pcnet.c   -  IPX networking, DOS 

fpfunc.S     - fixed point assembly and (currently) duplicate of
tmap.S       - texture mapping assembly (currently unused)

------------------------------------------------------------------
AM        AutoMap
------------------------------------------------------------------
am_data.h    -  vector graphics for the automap

am_map.h
am_map.c     -  automap code

------------------------------------------------------------------
HU         Heads Up
------------------------------------------------------------------
hu_lib.h
hu_lib.c    -  heads-up text and input code

hu_stuff.h
hu_stuff.c  -  Heads-up displays


-------------------------------------------------------------------
M          Menu
-------------------------------------------------------------------
m_menu.c    -  DOOM options code and leaving messages

m_misc.c    -  misc. HUD text display, input checks, and
                random table, file I/O


-------------------------------------------------------------------
P          Play???
-------------------------------------------------------------------
p_local.h   -  header for all play modules

p_spec.h    -  specials, lighting, doors, plats, texture animation
p_spec.c    -  specials, texture animation

p_doors.c   -  door code
p_plats.c   -  platform raising/lowering code
p_ceilng.c  -  active (e.g. crushing) ceilings
p_floor.c   -  active (e.g. raising) floors
p_lights.c  -  dynamic (e.g. flickering) lighting
p_switch.c  -  button switches and animation

p_enemy.c   -  enemy AI and animation
p_inter.c   -  object/object interaction?
p_map.c     -  movement objects, handling of collisions
p_maputl.c  -  distance, position etc. utilities for movement
p_mobj.c    -  mobile objects handling, spawn etc.
p_user.c    -  more movement, bobbing etc.

p_telept.c  -  teleportation code

p_sight.c   -  LOS checks, REJECT


p_pspr.c    -  weapon overlays, bobbing, raising, sprite tables,
               firing, ammo bookkeeping

p_setup.c   -  load map from WAF file, setup code


p_tick.c    -  savegame function (archive/unarchive),
                thinker list handling, allocation,
                game tick execution (updates)


-------------------------------------------------------------------
R          Rendering    
-------------------------------------------------------------------
r_local.h   - header for all rendering modules,
                internal map data structure definitions

r_bsp.c     - BSP seg's clipping

r_data.c    - texture column caching, patch assembly, 
                 flats, colormaps, sprites,
                 lookup by name

r_draw.c    - access to framebuffer API, drawing C functions


r_main.c    - geometry functions, trigonometry lookups, 
                 R_RenderPlayerView

r_plane.c   - floor/ceiling visplanes, sky

r_segs.c    - drawing segs, marking hslices for floors/ceilings

r_things.c  - sprite and sprite frame/rotation handling, drawing


tables.c    - trigonometry lookup tables, static

v_video.c   - gamma correction lookup, patch drawing to rectangle

-------------------------------------------------------------------
S          Sound
-------------------------------------------------------------------
s_sound.c   - more sound and music handling

soundst.h   - sound and music data structures
sounds.h
sounds.c    - sound and music lump LUT's (manually maintained)

sndserver.h
sndserver.c -  (Irix) sndserver code

irix.h
irix.c      -  SGI Irix sound/sndserver support code

linux.c     -  Linux voxware sound/sndserver support code,
                 replaces irix.c, uses irix.h
sun.c       -  SUN replacement for irix.c


i_sound.h
i_sound.c   -  DOS DMX music and sound interface 

-------------------------------------------------------------------
ST         STatus bar
-------------------------------------------------------------------
st_lib.h
st_lib.c    -  status bar widget code

st_stuff.c
st_stuff.h  -  status bar code


-------------------------------------------------------------------
W          Wad file I/O
-------------------------------------------------------------------
w_wad.c     -  lump based functions
wadread.h
wadread.c   -  lump I/O, get SFX

-------------------------------------------------------------------
WI         WIn / level end screens
-------------------------------------------------------------------
wi_data.h   -  lookups for intermission screens, patch positions

wi_stuff.h  
wi_stuff.c  -  intermission animation patchwork

-------------------------------------------------------------------
Z          Zone memory allocation
-------------------------------------------------------------------
z_zone.c

-------------------------------------------------------------------
F          Final screen animation
-------------------------------------------------------------------
f_finale.c   - DOOM mission end screens? (bunny)