D1 X Project
Source Notes
In an attempt to keep up notes on information that is often useful, especially
for people new to the descent source code, I have created this page as a
place to put valuable notes that various people have made. I took the
beginnings of this information from the descent source info pages on
descent2.com, and thank them for storing it up until now.
(I'll pretty this up later)
02/02/98 15:40 - David Gentry - Notes from source
[I haven't reviewed the consistancy of this information with d1->d1x changes -VR]
Function prefixes
VR_ Video RAM related functions (also used in VRAM flags)
gr_ Graphics related functions (most in 2d directory)
Variable/Define prefixes
CT_ control type (defines)
MT_ movement type (defines)
AS_ animation states (defines)
SM_ screenmodes (defines) width/height/colordepth
Global Variables
grs_curcanv global canvas on which to draw
grs_curscreen global screen struct that hold grs_canvas
Controls holds info in pitch, heading, and banking time as well as
info on vertical, sideways, and forward thrust times, state and count
on rearview, automap, primary, secondary and bomb dropping
ConsoleObject object that is the player
GameTime time in the game (sum of FrameTime)
FrameTime time in seconds since last frame
Highest_segment_index highest index in Segments (blocks/cubes)
Awareness_events array of structs holding info segment number,
position, and event type
Robot_info big list of robot types with internal info on sounds,
weapons,which explosion, id number, gun points/models, mass, drag,
strength, etc.
VR_offscreen_buffer offscreen data buffer
Code flow
main [ in inferno.c ... I highly recommending getting some grep functionality - VR]
* calls InitArgs,
* calls load_text (loads text messages),
* calls check_id_checksum_and_date,
* calls FindArgs (for help),
* calls init_graphics (does nothing in mac source),
* calls ReadConfigFile,
* calls timer_init, timer_set_rate, joy_timer_set_rate, key_init,
mouse_init,
* calls digi_init (sound system)
* calls ipx_init (if network)
* sets up VR tracking variables if VR unit used
* sets graphics mode (gr_set_mode), inits fonts, loads and plays
title song, display title screen
* calls g3_init (to initialize 3d system)
* calls texmerge_init (sets up texture caching system)
* calls init_game
* calls RegisterPlayer (gets player name)
* calls build_mission_list (and load mission 0 in the process)
* if in menu mode, call create_new_mine, then call
SetPlayerFromCurseg
* if in game mode, call keyboard_update, then call game()
* on return from game(), call WriteConfigFile and shut down
init_game
* calls functions to init: hostages, ai system, special effects,
objects, the gauge canvas, exploding walls
game
* sets screen mode for the game (set_screen_mode)
* calls init_cockpit, and init_gauges
* sets the camera to be the player view (Viewer=ConsoleObject)
* calls fly_init for ConsoleObject
* calls fix_object_segs, and game_flush_inputs
* goes into a while(1) loop
* this while loop does a keyboard-update and then calls GameLoop
with Render and Input turned on
* when returning from GameLoop and jumping out of while loop, call
digi_stop_all
* shuts down network game (if in progress)
* fades out
GameLoop [ in game.c - VR ]
* calls following functions: update_player_stats, do_cloak_stuff,
do_invulnerability_stuff, remove_obsolete_stuck_objects,
* calls init_cockpit
* calls game_render_frame
* calls calc_frame_time
* calls ReadControls
* updates GameTime counter by FrameTime (calculated in
calc_frame_time)
* calls digi_sync_sounds
* calls do_exploding_wall_frame, do_special_effects,
wall_frame_process, triggers_frame_process
* calls object_move_all, powerup_grab_cheat_all
* calls fuelcen_update_all, do_ai_frame_all
* take care of weapons handling, damage handling, sounds, power
updating, collisions,
* if just appearing, call create_player_appearance_effect
game_render_frame
* calls game_render_frame_mono if not using VR device
game_render_frame_mono
* does some canvas stuff
* calls render_frame with an eye_offset of 0
render_frame
* calls g3_start_frame
* does some vector math
* calls g3_set_view_matrix
* calls render_mine
* calls g3_end_frame
g3_start_frame
* computes aspect ratios for the canvas
* calls init_free_points, init_interface_vars_to_assembler (for tmap
interface)
render_mine
* calls render_start_frame
* calls build_segment_list
* calls build_object_list
* calls set_dynamic_light
* loops through the number of segments(most likely, just visible
segments)
* calls render_segment, with clipping
Functions of note
game calls GameLoop, called after mode selected, sets up things
GameLoop main loop in the game, takes flags for rendering and reading
controls.
game_render_frame does homing sound, calls appropriate rendering
module based on whether 3d glasses used or not.
init_cockpit draws view of cockpit based on front, rear or fullscreen.
calc_frame_time does the timing control, also account for turbo mode
dead_player_frame pull back camera and show ship exploding
ReadControls take care of cheats, calls control_read_all to get input,
process keystrokes, do debugging of control reading and processing
control_read_all reads from joystick, mouse, keyboard, etc and puts
into a control_info structure called Controls
digi_sync_sound calls digi_get_sound_loc to do panning stuff, calls
digi_start_sound_object to playback, determines if a sound if
finished, stops sound, changes volume, etc
do_special_effects changing textures, etc
wall_frame_process doors opening/closing/waiting
triggers_frame_process decrement time on all triggers active
object_move_all free up object slots with function call, get rid of
'dead' objects, take care of autoleveling flag, iterate throught
object list, moving one at a time with call to object_move_one
object_move_one update player fuel if in fuel center, calls controls
processing function depending on control type (CT_*), takes care of
movement (based on MT_NONE, _PHYSICS, or _SPINNING), checks to see if
any triggers set when moving from one segment to another
do_physics_sim vector motion, object collision, etc
spin_object matrix rotation
powerup_grab_cheat_all pick up powerups when certain distance away
find_connect_side find side index of connected segment
fuelcen_update_all replenish fuel supply
do_ai_frame_all calls set_player_awareness_all...and nothing else
set_player_awareness_all calls process_awareness_events, updates the
player_awareness_type and _time if necessary
process_awareness_events calls pae_aux for all Segments
(Highest_segment_index)
apply_damage_to_player flash, decrease shields (if not invulnerable),
set 'dead' flag if needed
bump_one_object collision, do phys_apply_force
phys_apply_force changes velocity and direction if movement of the
object is MT_PHYSICS
create_player_appearance_effect flash in a player (whether externally
in multiplayer, or internally)
game_init_render_buffers setup canvases to draw to
Misc Notes
* A grs_screen has a grs_canvas which has a grs_bitmap.
* A grs_canvas also has a grs_font.
* The entry point of the program is in INFERNO.C
* Important directories are: 2d, 3d, bios, cfile, fix, iff, mem,
misc, texmap, vecmat, main
[ some of these dirs are phased out. namely, bios, replaced by files in the arch/* dirs -VR ]