Decoded: Sopwith (1984) by David L. Clark
Source file: SWTITLE.C
Beginner friendly, line-by-line code walkthrough by MaiZure

SWTITLE.C draws the title screen at the beginning of a new game session

Original code:
http://davidlclark.com/page/sopwith-source-code

Original code with line numbers
http://www.maizure.org/projects/decoded-sopwith/SWTITLE_linenum.txt

1     COMMENT
2     COMMENT
3     BLANK
4     COMMENT
5     COMMENT
6     COMMENT
7     COMMENT
8     COMMENT
9     COMMENT
10    COMMENT
11    COMMENT
12    COMMENT
13    COMMENT
14    BLANK
15    COMMENT
16    BLANK
17    COMMENT
18    COMMENT
19    COMMENT
20    COMMENT
21    COMMENT
22    COMMENT
23    COMMENT
24    COMMENT
25    COMMENT
26    COMMENT
27    Include the main game header (sw.h)
28    BLANK
29    BLANK
30    Import the previously saved video mode (currently not initialized)
31    Import the hires flag as declared in SWMAIN and defined in SWINIT
32    Import title display flag as defined in SWMAIN. 
33    Imports tick action switch...set in several places, may be deprecated
34    Imports the performance counters as used by multiplayer
35    Import the move tick game loop delay mechanism
36    Import the display boundaries, left and right side
37    Import the display initialization status
38    Import the ground height data for use in the title display
39    BLANK
40    BLANK
41    BLANK
42    BLANK

DRAW THE TITLE SCREEN
43    Declare and define swtitln with no arguments
44    BLOCK START - swtitln, displays the title text and graphics
45    Declare a local object used to draw all title objects
46    Import the graphics for planes
47    Import the graphics for target buildings
48    Import the graphics for oxen
49    Import the graphics for hit planes (spinning and crashing)
50    Import the graphics for plane win (flying in to sunset)
51    Declare local integers for iteration and height
52    BLANK
53    Initialize savemode to the current screen mode (text/console)
54    Set the screen mode based on the high res flag. High res mode 6 is 640x200
      with 4 colors while mode 4 is 320x200 with 4 colors.
55    BLANK
56    If the title flag is set...
57    Exit this display routine
58    BLANK
59    Sets the tick mode to 1
60    BLANK
61    Prepares the title sound effect
62    Executes the title sound routine
63    BLANK
64    COMMENT
65    BLANK
66    COMMENT
67    COMMENT
68    COMMENT
69    BLANK
70    COMMENT
71    COMMENT
72    COMMENT
73    BLANK
74    COMMENT
75    COMMENT
76    COMMENT
77    BLANK
78    COMMENT
79    COMMENT
80    COMMENT
81    COMMENT
82    COMMENT
83    BLANK
84    COMMENT
85    BLANK
86    COMMENT
87    BLANK
88    Sets the active printing color to white
89    Sets the cursor position to column 13, row 4 (middle top of screen)
90    Prints "S O P W I T H"
91    BLANK
92    Sets the active color to cyan
93    Sets the cursor position to column 9, row 6
94    Prints "(The Author's Edition)"
95    BLANK
96    Sets the sctive color to white
97    Sets the cursor position to column 5, row 9
98    Prints "(c) Copyright 1984, 1985, 1987"
99    BLANK
100   Sets the active color to cyan
101   Sets the cursor position to column 6, row 10
102   Prints "BMB "
103   Sets the active color white
104   Prints "Compuscience Canada Ltd."
105   BLANK
106   Sets the active color to white
107   Sets the cursor position to column 1, row 12
108   Prints "Copyright (C) 1984-2003 David L. Clark"
109   BLANK
110   COMMENT
111   BLANK
112   Sets the primary video buffer as active
113   BLANK
114   Sets the left screen side pixel position to 700
115   Set display init to true
116   Draw the ground starting at world position 700
117   BLANK
118   Set local object type plane
119   Set plane dimensions to 16x16
120   Set plane color to 1 (player's color)
121   Set object symbol to the plane
122   Draw the plane at pixel position 260, 180. Note that drawing graphics
      uses the BOTTOM-LEFT as (0,0) instead of the more common TOP-LEFT.
123   BLANK
124   Set the object's graphic to the first winning frame (flying to sun)
125   Draw the graphic at pixel position 50, 180
126   BLANK
127   Set the object to type oxen
128   Set the object's graphic to the oxen
129   Draw object at 100 by ground position 800 + 16
130   BLANK
131   Set the object to type target
132   Set the target color to the computer player
133   Set the target type to tank
134   Draw the object at 234 by ground position 934 + 16
135   BLANK
136   Set the object type to plane
137   Set the graphic to the crashing plane
138   Draw the plane at pixel position 20, 160
139   BLANK
140   Set the object to type smoke
141   Set the smoke dimensions to 1x1
142   Set the pixel color to red with the highest bit also set (ignored?)
143   Set the temporary height to 150
144   Loop for 9 cycles
145   Draw the red pixel from 150 to 195 in steps of 5
146   BLOCK END - swtitln
147   BLANK
148   BLANK
149   BLANK
150   BLANK

END TITLE SEQUENCE
151   Declare swtitlf with no arguments
152   BLOCK START - swtitlf, finishes title sequence
153   BLANK
154   If the title flag is set..
155   Return early
156   BLANK
157   Clear the sound queue
158   Stop playing sound
159   Set the tick mode to zero (no effect)
160   BLOCK END - swtitlf
161   BLANK
162   BLANK
163   BLANK

CLOCK TICK INTERRUPT HANDLER
164   Declare swtickc with no arguments
165   BLOCK START - swtickc, perform a tick
166   BLANK
167   Increment the tick counter
168   COMMENT
169   COMMENT
170   COMMENT
171   Add 10 to the delay tick counter
172   If we're on an IBM PC
173   Check current sound for updates
174   End case for PC
175   BLOCK END - swtickc
176   EOF