 internal.txt  , This is part of the flight simulator 'fly8'.3 Author: Eyal Lebedinsky (eyal@ise.canberra.edu.au).      Modules  =======      portable --------   ALTITUDE.C	display HUD altitude  AUTOP.C		Auto pilot simulator  BODY.C		bodies mgmt  COCKPIT.C	draw instruments COLORS.C	color mgmt  COMMAND.C	process user commands   DEBUG.C		debug support functions DEVICE.C	graphics devices mgmt FLY8.C		main program3 GETSTR.C	accept user input with editing and history  HEADING.C	display HUD heading ( HUD.C		head-up-display painter: graphics HUDMENU.C	hud setup menus  IFUNCS.C	integer trig functions ( ILS.C		display and manage the ILS system INFO.C		screen text display  INIT.C		program initialization; ITABS.C         integer trig tables (generated by ifuncs.c) % KEYBOARD.C      keyboard devices mgmt  KEYPAD.C% LAND.C          algorithmic landscape  LOG.C		print to log 8 LOOP.C		the main busy-loop of the simulation and display& MACROS.C        handle keyboard macros MAT.C		3D matrix handling  MEMORY.C	memory mgmt  MENU.C		menu interaction support! MENUS.C		menus used by the system ( MESSAGE.C	handle display messages queue.( NETPORT.C	network access mgr (mid level)7 OBASIC.C	object: plane - cross between Classic and F16. % OBJECT.C	'object' data structure mgmt  OBJECTS.C	3D objects mgmt  OBOX.C		object: box  OBROKEN.C	object: fragment OCHUTE.C	object: ejecting pilot , OCLASSIC.C	object: plane - a wild spaceship. OCRATER.C	object: bomb crater  OGROUND.C	object: ground (land)   OGTARGET.C	object: ground target OHOUSE.C	object: house (land) . OLOW.C		object: low level ground (crash alert) OM61.C		object: M61 bullet.  OMK82.C		object: MK82 bomb OPADDOC.C	object: paddoc (land)  OPLANE.C	object: plane ORUNWAY.C	object: runway (land)  OSMOKE.C	object: smoke particle  OTARGET.C	object: target OTOWER.C	object: control tower OVIEWER.C	object: viewer$ OXPLANE.C	object: experimental plane PID.C		automatic control logic  PIPER.C		display HUD radar piper! PITCH.C		display HUD pitch ladder # PLAYER.C	remote players maintenance  POINTER.C	pointing devices mgmt  RADAR.C		display HUD radar info ( RANDOM.C	random pointing device emulator, REMOTE.C	remote comms interface (high level)' SHOW.C		3D graphics wire-frame routines  SKY.C		algorithmic sky painting  SOUND.C		sound devices mgmt  SPEED.C		display HUD speed* STFONT1.C	stroke font (square, fast, cold)) STFONT2.C	stroke font (round, slow, nice) / STROKE.C	stroke character generator used in HUD  SYSTEM.C	system-wide functions TERM.C		program termination  TUNES.C		tunes used for sound  UTIL.C		misc functions4 VIEWS.C		render ann views (cockpit, HUD and all HDD)! VMODES.C	read in the fly.vmd file , WINDOW.C	windows and screen sizing functions     Headers  -------    COLORS.H	color definitions FLY.H		the main header HUD.H		header for HUD modules 0 NOTES.H		used to define sounds (notes and tunes) KEYOFD.H	--"-- KEYOFC.H	--"--+ KEYDEF.H	key definitions (internal to fly8) & KEYMAP.H	key mapping to fly8 functions; 		in the future this may be replaced with externaly defined  		key mapping. PLANE.H		plane related stuff     MSDOS  -----   ! CONFIG.H	non portable definitions   4 DRIVERS.C	lists all drivers, but otherwise portable.D KEYPAD.C	the keyboard as a pointing device (portable code except you 		may re-assign keys).& CONSOLE.C	low level PC keyboard access6 GRQC.C		graphics device driver (using QuickC graphics)@ GRT4K.C		graphics device driver (using low-level tseng4k access)' MOUSE.C		the mouse as a pointing device < PACKET.C	low level packet net driver (ethernet packet level). PCDOS.C		miscelanious system functions (pcdos)& PCSERIAL.C	low level serial net driver3 SLIP.C		low level packet net driver (SLIP protocol) ' SPEAKER.C	PC speaker sound ouput driver * STICK.C		the joystick as a pointing device TIMER.C		timer functions9 GETTIMER.C	stanalone pgm to read the timer chip channel 0 B SETTIMER.C	stanalone pgm to set the timer chip channel 0 to mode 3  ; MSUBS.ASM	fast fixed point math, replaces some C functions.   . MAKQC.TOP	makefile for portable files (QuickC)( MAKQC		makefile for msdos files (QuickC)* MAKC7.TOP	makefile for portable files (C7)$ MAKC7		makefile for msdos files (C7)   FLY.INI		configuration file * FLY.BAT		short batch file for running fly8" GRQC.VMD	graphics modes for grqc.c$ GRT4K.VMD	graphics modes for grt4k.c     UNIX/X11 --------   CONFIG.H	as above    CONSOLE.C	as above DRIVERS.C	as above MISC.C		as above MOUSE.C		as above   UNIX.C		system services for UNIX NOSOUND.C	dummy sound driver.  TIMER.C		as above   GRX.C		graphics driver using X11   MAKEFILE.TOP	as above  MAKEFILE	as above    FLY.INI		as above " FLY		short script for running fly8 GRX.VMD		graphics modes      External support ----------------  A Interrupt driven, buffered serial line support library (com.lib).   ( Standard graphics (microsoft C library).% Fast 256 color VGA graphics (gr.lib).   ( Packet driver C interface (pktdrvr.lib).  & Input line editing routine (util.lib).) High resolution timer support (util.lib).      Other files  -----------    FLY.INI		parameters file (read)  FLY.LOG		log file (write) / FLY.MAC		keyboard macros save file (read/write)      Porting  =======   & A minimal set of drivers will include:   DRIVERS.C	adjusted lists  0 CONSOLE.C	low level non-blocking keyboard access GRxxx.C		graphics device driver * KEYPAD.C	the keyboard as a pointing device& OpSys.C		miscelanious system functions NoSound.C	dummy sound driver TIMER.C		timer functions     Program structure  =================   I main() is in fly8.c. After setting everything up (mainly initialize()) it E calls user_command() [in command.c] which talks to the user. Whenever K the program is in a busy wait it calls Sys->Poll() which calls idle_loop(). I This last one [in fly8.c] decides if it is time to show another frame and / does so. It also drives the simulation program.   N The program should have NO HARD WAITS!!!! The keyboard driver MUST do the poll when waiting for a keystroke.   " Sys->Poll(int mode) has two modes:9 	0 poll all low level devices but do not call idle_loop()  	1 do everything. N This is to allow the main body of the simulation/rendering to call Sys->Poll()1 to enable sound etc. that needs constant polling.     G  An important issue is the separation of function between the different H program layers. All objects have a 'native' world which is termed here aE 'player'. There is the one 'native' player and many remote players. A H player is identified by the pair (int netport, char address[]) which areF treated as a black box. The remote player handler (remote.c) exchangesH messages with remote users through a netport which is managed separatelyD (netport.c). The messages are moved as packets. The same packets areF then handed over to the network drivers (each enviroment had differentF ones) which does NOT have any understanding of the contents. A netportD is directly related to a network access point (usually some hardwareG device) and the program can handle nore than one of these concurrently. E While the low level programs (netport.c and net drivers) know nothing F about fly8, remote.c knows a lot about it and knows how to talk to the- netports but cannot control the net directly.   E  During the design of the program (i.e when looking back at the blind H at-the-keyboard programming sessions) various functions had to be placedG at the prefered level - not always clear were that is. For example, the B program can collect multiple logical packets and hande then to theH network as one large real packet. The mechanizm for that ended up at theH netport level. It could as easily have been left to each driver to do itG when appropriate, or it could have been pushed up to the remote handler 8 (who originally build all packets) to take care of that.  @  One day the large header (fly8.h) will be split to reflect thisA layering and enforce more structure on the whole system. One day.      e_plane.misc[20] allocation  ---------------------------   :   0	LIFETIME(p)	autopilot: millisecs to next randomization%   1	SPEED(p)	autopilot: desired speed )   2	HEADING(p)	autopilot: desired headingh+   3	ALTITUDE(p)	autopilot: desired altituded-   4	NEWTGT(p)	time left for new target notice    5			Cm"   6			high res R[Z] when on-ground	   7			...H   8			pull up time(   9			millisec life of water-line marker  10			autop: command speed.n  11			bombs in flight counter.  12			autop: command pitch  13			autop: command rollt  14			ILS glide path deviation  15			ILS localizer deviationS  16			pullup cue relative anglen  17			pullup cue time.   e_plane.opt[10] usageU ---------------------i  ?   0 [0-2]	flight model: 0=basic, 1=classic, 2=xplane, 3=yplane.u,   1 [1-9]	controls response (damping factor)"   2 [01]	use linear controls (all)&   3 [1-9]	turning speed (classic only)     e_imported.misc[5] allocationt ------------------------------     object.misc[5] allocationD --------------------------  ;  0	bullet count for non ET_PLANE objects (imported planes).p$  0	viewer type for O_VIEWER (local).     st.misc[20] allocation ----------------------     0	last elapsed time    1	last video_timet   2	last stats[27]   3	last stats[28]   4	last stats[29]   5	last stats[40]#   6	plane dynamics minimum intervale$   7	sega glasses port [0 means none]   8	buttons mode.n   9	flush log rate     st.stats[100] allocation ------------------------   alloc	used	for -----	----	---  0- 9	    comms  	 0	bytes sent 	 1	packets sent (physical)C 	 2	bytes rcvd 	 3	packets rcvd (physical)C= 	 4	rcvd bad packet: crc & player OK but not collected by any ) 		object (player.c) [but player playing].o$ 	 5	rcvd bad packet: driver internal 	 6	rcvd bad packet: bad crc6 	 7	rcvd bad packet: player unknown (if short of mem?)+ 	 8	send packet failed: sync (driver level)C, 	 9	send packet failed: async (driver level) 10-19	    graphics 	10	out->out (clipper) 	11	in->in (clipper) 	12	in->out/out->in (clipper)V 	13	hard: out (clipper)X 	14	hard: fail (clipper) 	15	hard: in (clipper) 	16	lines processed (per frame)y 	17	-d& 	18	coms: low level soft send failure. 	19	millis to next autoconnect 20-29	    misc& 	20	com test count, input [pcserial.c] 	21	com test max 	22	com test total 	23-25	same, for outputr 	26	elements in display list. 	27	time for objects display calcs (NOT video) 	28	time for objects simulationy
 	29	sync timeN 30-39	    video totals$ 	30	bg/fb time (hud, test, sky etc.) 	31	number of frames 	32	total frames time	 	33	total video time 	34	total [27] times 	35	total [28] timea 	36	total [29] timeT 	37	total [30] timet 	38	-E 	39	-r   30-39	    memory, misc 	40	debug.c error count  	41	log last write timeI 	42	-r 	43	-n 	44	-  	45	memory bytes max used  	46	memory bytes alloced 	47	memory bytes now useda 	48	memory shortage (failed) 	49	memory shortage (total)S   50-59	    coms 	50	recovered lost objects 	51	objects timed outo 	52	bad packages receivedf 	53	rcvd packagesn 	54	sent packages-' 	55	rcvd noise packets from non-playerst 	56	rcvd out of order packet 	57	-y 	58	-g 	59	-8   60-69	    graphics debug 	60	x < 0	(Move) 	61	x > width	(Move) 	62	y < 0	(Move) 	63	y > height	(Move)t 	64	x < 0	(Draw) 	65	x > width	(Draw) 	66	y < 0	(Draw) 	67	y > height	(Draw)i 	68	line draw bad op 	69	-e   70-79	    misc 	70-76	running total of 10-16e 	77( 	78	total MoveTo executed. 	79	total DrawTo executed.   80-89	    temp countersc   90-99	    temp countersc     st.flags GP* usage ------------------  & DF_GPW		activate model Y instead of F. DF_GPX		show HUD graph> DF_GPY		model F: fundamental=no-pitch, or linearized=do-pitch.% DF_GPZ		model F: set FUNDAMENTAL modem       pointer.a[4] usage ------------------   Analog functions are:r 	 0 right/left turne 	 1 up/down turn     pointer.b[30] usageE -------------------o   logical functions are: 	 0   power up 	 1   power down  	 2   level (fly straight north)  	 3   return to origin (x,y,z=0) 	 4   stop (speed=0)
 	 5   fire 	 6   rudder left/righth 	 7   rudder center3 	 8   stable (stop turning)t	 	 9   ...a 	10/a flapsn 	11/b spoilers 	12/c reset roll 	13/d air brakes 	14/e wheel brakes
 	15/f gear 	16/g power 100  	17/h after burner upp 	18/i release lock! 	19/j wheel brakes (fine control)) 	20/k air brakes (fine control)  	21/l trim right/leftl 	22/m trim down/up 	23/n trim reset     pointer.opt[10] usage	 ---------------------k     1  [pn]	set x coord directionG   2  [0-3]	set x coord functione   3  [pn]	set y coord directiona   4  [0-3]	set y coord function	#   5  [0-9]	set left button functionu$   6  [0-3]	set right button function/   7  [0-9]	set x coord sensitivity (mouse only)P/   8  [0-9]	set y coord sensitivity (mouse only)v$   9  [01]	read twice (joystick only)     Asyncronous events ------------------  H The only current such events are network traffic arrival. The two packetK drivers slip.c and packet.c work in this way. pcserial.c expects charactersVA to be delivered-to/retrieved-from routines in the serial library.   F NEW() DEL() [memory.c] and deliver_packet() [netport.c] may be called @ from interrupt routines and are protected by Disable/Enable. The' structures manipulated in this way are:    	memory allocation.s  	netport incoming packets queue.  O -------------------------------------------------------------------------------s" example of a dummy netport driver:" ==================================   static int far% com_init (NETPORT *np, char *options)eH /* Initialize netport 'np' with user options 'options'. 'options' is theL  * unparsed string that the used supplied and is a list of options separatedC  * by colons. Use the get_?arg() functions to retrieve the options.a */ {r 	return (1);	/* always fail */ }k   static void fare com_term (NETPORT *np) /* Terminate netport 'np'. */ {i 	return; }_   static int far$ com_send (NETPORT *np, PACKET *pack)& /* Send packet 'pack' to netport 'np'.L  * If 'pack' is zero then this is an indication that this is the last packetK  * so drivers that send multiple packets in one message will send what they   * have. */ {e 	return (1);	/* always fail */ }e   static int far com_receive (NETPORT *np)dM /* Receive all packets from netport 'np'. Used only by drivers that do polleda
  * receiving.  */ {l 	return (1);	/* always fail */ }l  $ extern struct NetDriver NetDummy = {	 	"Dummy",f 	0,t
 	com_init,
 	com_term,
 	com_send, 	com_receive };O -------------------------------------------------------------------------------e