Skip to navigation

Aviator on the BBC Micro

Aviator E source

Name: lineBufferR [Show more] Type: Variable Category: Drawing lines Summary: Line buffer storage for the start x-coordinate (R) Deep dive: Line buffers
Context: See this variable on its own page References: This variable is used as follows: * DrawClippedLine (Part 6 of 6) calls lineBufferR * EraseCanopyLines calls lineBufferR

This table stores information about lines that are drawn on-screen, so they can be quickly erased without having to spend precious time recalculating the line coordinates. The information is stored when a line is drawn by the DrawClippedLine routine, and is read by the EraseCanopyLines routine when the line is erased. The initial contents of the variable is just workspace noise and is ignored. It actually contains snippets of the original source code. We can buffer up to 96 lines, with 48 in each of the two line buffers, so the maximum number of lines on screen at any one time is 48 lines out of the 193 lines defined in the world.
.lineBufferR EQUB &64, &6C, &70, &32, &0D, &03, &B4, &19 EQUB &20, &20, &20, &20, &20, &20, &44, &45 EQUB &43, &26, &37, &34, &3A, &42, &4E, &45 EQUB &20, &64, &6C, &70, &31, &0D, &03, &B5 EQUB &0D, &20, &20, &20, &20, &20, &20, &72 EQUB &74, &73, &0D, &03, &B6, &05, &20, &0D EQUB &03, &BF, &25, &2E, &55, &42, &55, &4C EQUB &20, &4C, &44, &59, &23, &31, &35, &3A EQUB &53, &54, &59, &20, &4F, &42, &3A, &4C EQUB &44, &41, &23, &39, &38, &3A, &53, &54 EQUB &41, &20, &50, &50, &0D, &03, &C0, &1D EQUB &2E, &75, &62, &75, &32, &20, &54, &59
Name: lineBufferW [Show more] Type: Variable Category: Drawing lines Summary: Line buffer storage for the max/min x-coordinate (W) Deep dive: Line buffers
Context: See this variable on its own page References: This variable is used as follows: * DrawClippedLine (Part 6 of 6) calls lineBufferW * EraseCanopyLines calls lineBufferW

This table stores information about lines that are drawn on-screen, so they can be quickly erased without having to spend precious time recalculating the line coordinates. The information is stored when a line is drawn by the DrawClippedLine routine, and is read by the EraseCanopyLines routine when the line is erased. The initial contents of the variable is just workspace noise and is ignored. It actually contains snippets of the original source code. We can buffer up to 96 lines, with 48 in each of the two line buffers, so the maximum number of lines on screen at any one time is 48 lines out of the 193 lines defined in the world.
.lineBufferW EQUB &41, &3A, &43, &4C, &43, &3A, &41, &44 EQUB &43, &23, &26, &44, &38, &3A, &54, &41 EQUB &58, &0D, &03, &CA, &12, &20, &20, &20 EQUB &20, &20, &20, &4A, &53, &52, &20, &4D EQUB &4F, &42, &4A, &0D, &03, &D4, &12, &20 EQUB &20, &20, &20, &20, &20, &4A, &53, &52 EQUB &20, &55, &4F, &42, &4A, &0D, &03, &DE EQUB &25, &20, &20, &20, &20, &20, &20, &4C EQUB &44, &59, &20, &4F, &42, &3A, &4C, &44 EQUB &41, &20, &4F, &53, &54, &41, &54, &2C EQUB &59, &3A, &42, &4D, &49, &20, &75, &62 EQUB &75, &31, &0D, &03, &E8, &1B, &20, &20
Name: lineBufferS [Show more] Type: Variable Category: Drawing lines Summary: Line buffer storage for the start y-coordinate (S) Deep dive: Line buffers
Context: See this variable on its own page References: This variable is used as follows: * DrawClippedLine (Part 6 of 6) calls lineBufferS * EraseCanopyLines calls lineBufferS

This table stores information about lines that are drawn on-screen, so they can be quickly erased without having to spend precious time recalculating the line coordinates. The information is stored when a line is drawn by the DrawClippedLine routine, and is read by the EraseCanopyLines routine when the line is erased. The initial contents of the variable is just workspace noise and is ignored. It actually contains snippets of the original source code. We can buffer up to 96 lines, with 48 in each of the two line buffers, so the maximum number of lines on screen at any one time is 48 lines out of the 193 lines defined in the world.
.lineBufferS EQUB &20, &20, &20, &20, &4C, &44, &41, &23 EQUB &30, &3A, &53, &54, &41, &20, &46, &52 EQUB &46, &4C, &41, &47, &20, &0D, &03, &F2 EQUB &17, &2E, &75, &62, &75, &31, &20, &44 EQUB &45, &43, &20, &50, &50, &3A, &44, &45 EQUB &43, &20, &4F, &42, &0D, &03, &FC, &20 EQUB &20, &20, &20, &20, &20, &20, &4C, &44 EQUB &59, &20, &4F, &42, &3A, &43, &50, &59 EQUB &23, &31, &32, &3A, &42, &43, &53, &20 EQUB &75, &62, &75, &32, &0D, &04, &06, &0D EQUB &20, &20, &20, &20, &20, &20, &72, &74 EQUB &73, &0D, &04, &10, &05, &20, &0D, &04
Name: lineBufferG [Show more] Type: Variable Category: Drawing lines Summary: Line buffer storage for the max/min y-coordinate (G) Deep dive: Line buffers
Context: See this variable on its own page References: This variable is used as follows: * DrawClippedLine (Part 6 of 6) calls lineBufferG * EraseCanopyLines calls lineBufferG

This table stores information about lines that are drawn on-screen, so they can be quickly erased without having to spend precious time recalculating the line coordinates. The information is stored when a line is drawn by the DrawClippedLine routine, and is read by the EraseCanopyLines routine when the line is erased. The initial contents of the variable is just workspace noise and is ignored. It actually contains snippets of the original source code. We can buffer up to 96 lines, with 48 in each of the two line buffers, so the maximum number of lines on screen at any one time is 48 lines out of the 193 lines defined in the world.
.lineBufferG EQUB &1A, &24, &2E, &53, &55, &54, &52, &20 EQUB &4A, &4D, &50, &20, &54, &45, &53, &54 EQUB &3A, &42, &4D, &49, &20, &73, &75, &74 EQUB &31, &3A, &42, &45, &51, &20, &73, &75 EQUB &74, &31, &0D, &04, &24, &1B, &20, &20 EQUB &20, &20, &20, &20, &4C, &44, &41, &26 EQUB &30, &43, &43, &35, &3A, &42, &4E, &45 EQUB &20, &73, &75, &74, &31, &0D, &04, &2E EQUB &27, &20, &20, &20, &20, &20, &20, &4C EQUB &44, &41, &26, &46, &45, &36, &34, &3A EQUB &80, &23, &31, &35, &3A, &43, &4D, &50 EQUB &23, &31, &34, &3A, &42, &43, &53, &20
Name: lineBufferT [Show more] Type: Variable Category: Drawing lines Summary: Line buffer storage for the line's |x-delta| (T) Deep dive: Line buffers
Context: See this variable on its own page References: This variable is used as follows: * DrawClippedLine (Part 6 of 6) calls lineBufferT * EraseCanopyLines calls lineBufferT

This table stores information about lines that are drawn on-screen, so they can be quickly erased without having to spend precious time recalculating the line coordinates. The information is stored when a line is drawn by the DrawClippedLine routine, and is read by the EraseCanopyLines routine when the line is erased. The initial contents of the variable is just workspace noise and is ignored. It actually contains snippets of the original source code. We can buffer up to 96 lines, with 48 in each of the two line buffers, so the maximum number of lines on screen at any one time is 48 lines out of the 193 lines defined in the world.
.lineBufferT EQUB &73, &75, &74, &31, &0D, &04, &38, &0F EQUB &20, &20, &20, &20, &20, &20, &84, &41 EQUB &23, &31, &36, &0D, &04, &42, &19, &2E EQUB &73, &75, &74, &33, &20, &44, &45, &43 EQUB &20, &54, &48, &45, &4D, &45, &3A, &4C EQUB &44, &58, &23, &37, &0D, &04, &4C, &1C EQUB &2E, &73, &75, &74, &35, &20, &43, &50 EQUB &58, &20, &54, &48, &45, &4D, &45, &3A EQUB &42, &45, &51, &20, &73, &75, &74, &34 EQUB &0D, &04, &56, &1F, &2E, &73, &75, &74 EQUB &32, &20, &43, &4D, &50, &20, &46, &4C EQUB &44, &50, &54, &52, &2C, &58, &3A, &42
Name: scoreText [Show more] Type: Variable Category: Scoring Summary: The high score text
Context: See this variable on its own page References: This variable is used as follows: * PrintScoreText calls scoreText
.scoreText EQUB 31, 1, 3 \ VDU 31, 1, 3 moves the text cursor to column 1, row 3 EQUS "HIGH SCORE: " EQUB "0" EQUB 31, 3, 10 \ VDU 31, 3, 10 moves the text cursor to column 3, row \ 10 EQUB &3A, &4A \ These bytes appear to be unused and contain assembly EQUB &4D, &50 \ code EQUB &20, &73 EQUB &75, &74 EQUB &35, &0D EQUB &04, &6A
Name: lineEndPointId [Show more] Type: Variable Category: 3D geometry Summary: The point ID for a line's end point Deep dive: Lines and points
Context: See this variable on its own page References: This variable is used as follows: * DrawCanopyView calls lineEndPointId * MainLoop (Part 15 of 15) calls lineEndPointId * ProcessLine (Part 1 of 7) calls lineEndPointId * ProcessLinesToShow calls lineEndPointId

This table contains the point ID for each line's end point. The table is indexed by line ID, so for line ID X, lineEndPointId,X contains the point ID of the line's end point.
.lineEndPointId EQUB 30 \ Line ID 0 goes from point 31 to point 30 EQUB 2 \ Line ID 1 goes from point 1 to point 2 EQUB 3 \ Line ID 2 goes from point 2 to point 3 EQUB 4 \ Line ID 3 goes from point 3 to point 4 EQUB 1 \ Line ID 4 goes from point 4 to point 1 EQUB 7 \ Line ID 5 goes from point 6 to point 7 EQUB 9 \ Line ID 6 goes from point 8 to point 9 EQUB 11 \ Line ID 7 goes from point 10 to point 11 EQUB 13 \ Line ID 8 goes from point 12 to point 13 EQUB 15 \ Line ID 9 goes from point 14 to point 15 EQUB 17 \ Line ID 10 goes from point 16 to point 17 EQUB 19 \ Line ID 11 goes from point 18 to point 19 EQUB 59 \ Line ID 12 goes from point 114 to point 59 EQUB 114 \ Line ID 13 goes from point 115 to point 114 EQUB 42 \ Line ID 14 goes from point 41 to point 42 EQUB 43 \ Line ID 15 goes from point 42 to point 43 EQUB 44 \ Line ID 16 goes from point 43 to point 44 EQUB 46 \ Line ID 17 goes from point 45 to point 46 EQUB 47 \ Line ID 18 goes from point 46 to point 47 EQUB 48 \ Line ID 19 goes from point 47 to point 48 EQUB 53 \ Line ID 20 goes from point 49 to point 53 EQUB 54 \ Line ID 21 goes from point 50 to point 54 EQUB 55 \ Line ID 22 goes from point 51 to point 55 EQUB 56 \ Line ID 23 goes from point 52 to point 56 EQUB 58 \ Line ID 24 goes from point 59 to point 58 EQUB 57 \ Line ID 25 goes from point 58 to point 57 EQUB 51 \ Line ID 26 goes from point 57 to point 51 EQUB 60 \ Line ID 27 goes from point 52 to point 60 EQUB 61 \ Line ID 28 goes from point 60 to point 61 EQUB 62 \ Line ID 29 goes from point 49 to point 62 EQUB 63 \ Line ID 30 goes from point 50 to point 63 EQUB 64 \ Line ID 31 goes from point 62 to point 64 EQUB 65 \ Line ID 32 goes from point 63 to point 65 EQUB 66 \ Line ID 33 goes from point 64 to point 66 EQUB 116 \ Line ID 34 goes from point 115 to point 116 EQUB 113 \ Line ID 35 goes from point 116 to point 113 EQUB 113 \ Line ID 36 goes from point 112 to point 113 EQUB 112 \ Line ID 37 goes from point 111 to point 112 EQUB 111 \ Line ID 38 goes from point 61 to point 111 EQUB 67 \ Line ID 39 goes from point 65 to point 67 EQUB 119 \ Line ID 40 goes from point 66 to point 119 EQUB 120 \ Line ID 41 goes from point 67 to point 120 EQUB 68 \ Line ID 42 goes from point 119 to point 68 EQUB 69 \ Line ID 43 goes from point 120 to point 69 EQUB 70 \ Line ID 44 goes from point 68 to point 70 EQUB 71 \ Line ID 45 goes from point 69 to point 71 EQUB 117 \ Line ID 46 goes from point 70 to point 117 EQUB 81 \ Line ID 47 goes from point 80 to point 81 EQUB 85 \ Line ID 48 goes from point 82 to point 85 EQUB 85 \ Line ID 49 goes from point 83 to point 85 EQUB 85 \ Line ID 50 goes from point 84 to point 85 EQUB 118 \ Line ID 51 goes from point 71 to point 118 EQUB 72 \ Line ID 52 goes from point 117 to point 72 EQUB 73 \ Line ID 53 goes from point 118 to point 73 EQUB 74 \ Line ID 54 goes from point 72 to point 74 EQUB 75 \ Line ID 55 goes from point 73 to point 75 EQUB 90 \ Line ID 56 goes from point 89 to point 90 EQUB 94 \ Line ID 57 goes from point 91 to point 94 EQUB 94 \ Line ID 58 goes from point 92 to point 94 EQUB 94 \ Line ID 59 goes from point 93 to point 94 EQUB 96 \ Line ID 60 goes from point 95 to point 96 EQUB 98 \ Line ID 61 goes from point 97 to point 98 EQUB 76 \ Line ID 62 goes from point 74 to point 76 EQUB 77 \ Line ID 63 goes from point 75 to point 77 EQUB 78 \ Line ID 64 goes from point 76 to point 78 EQUB 79 \ Line ID 65 goes from point 77 to point 79 EQUB 101 \ Line ID 66 goes from point 78 to point 101 EQUB 100 \ Line ID 67 goes from point 79 to point 100 EQUB 102 \ Line ID 68 goes from point 101 to point 102 EQUB 103 \ Line ID 69 goes from point 100 to point 103 EQUB 105 \ Line ID 70 goes from point 102 to point 105 EQUB 104 \ Line ID 71 goes from point 103 to point 104 EQUB 107 \ Line ID 72 goes from point 105 to point 107 EQUB 106 \ Line ID 73 goes from point 104 to point 106 EQUB 109 \ Line ID 74 goes from point 107 to point 109 EQUB 109 \ Line ID 75 goes from point 106 to point 109 EQUB 215 \ Line ID 76 goes from point 213 to point 215 EQUB 110 \ Line ID 77 goes from point 109 to point 110 EQUB 122 \ Line ID 78 goes from point 121 to point 122 EQUB 121 \ Line ID 79 goes from point 177 to point 121 EQUB 123 \ Line ID 80 goes from point 122 to point 123 EQUB 123 \ Line ID 81 goes from point 177 to point 123 EQUB 145 \ Line ID 82 goes from point 144 to point 145 EQUB 145 \ Line ID 83 goes from point 146 to point 145 EQUB 147 \ Line ID 84 goes from point 146 to point 147 EQUB 147 \ Line ID 85 goes from point 148 to point 147 EQUB 148 \ Line ID 86 goes from point 144 to point 148 EQUB 158 \ Line ID 87 goes from point 157 to point 158 EQUB 159 \ Line ID 88 goes from point 158 to point 159 EQUB 160 \ Line ID 89 goes from point 159 to point 160 EQUB 160 \ Line ID 90 goes from point 157 to point 160 EQUB 161 \ Line ID 91 goes from point 164 to point 161 EQUB 162 \ Line ID 92 goes from point 163 to point 162 EQUB 161 \ Line ID 93 goes from point 162 to point 161 EQUB 163 \ Line ID 94 goes from point 164 to point 163 EQUB 168 \ Line ID 95 goes from point 165 to point 168 EQUB 166 \ Line ID 96 goes from point 165 to point 166 EQUB 167 \ Line ID 97 goes from point 166 to point 167 EQUB 168 \ Line ID 98 goes from point 167 to point 168 EQUB 172 \ Line ID 99 goes from point 169 to point 172 EQUB 171 \ Line ID 100 goes from point 169 to point 171 EQUB 124 \ Line ID 101 goes from point 142 to point 124 EQUB 171 \ Line ID 102 goes from point 172 to point 171 EQUB 175 \ Line ID 103 goes from point 176 to point 175 EQUB 174 \ Line ID 104 goes from point 175 to point 174 EQUB 173 \ Line ID 105 goes from point 176 to point 173 EQUB 174 \ Line ID 106 goes from point 173 to point 174 EQUB 151 \ Line ID 107 goes from point 150 to point 151 EQUB 151 \ Line ID 108 goes from point 152 to point 151 EQUB 149 \ Line ID 109 goes from point 152 to point 149 EQUB 150 \ Line ID 110 goes from point 149 to point 150 EQUB 138 \ Line ID 111 goes from point 139 to point 138 EQUB 138 \ Line ID 112 goes from point 137 to point 138 EQUB 137 \ Line ID 113 goes from point 136 to point 137 EQUB 139 \ Line ID 114 goes from point 136 to point 139 EQUB 133 \ Line ID 115 goes from point 132 to point 133 EQUB 135 \ Line ID 116 goes from point 132 to point 135 EQUB 134 \ Line ID 117 goes from point 135 to point 134 EQUB 134 \ Line ID 118 goes from point 133 to point 134 EQUB 129 \ Line ID 119 goes from point 128 to point 129 EQUB 130 \ Line ID 120 goes from point 129 to point 130 EQUB 131 \ Line ID 121 goes from point 130 to point 131 EQUB 131 \ Line ID 122 goes from point 128 to point 131 EQUB 209 \ Line ID 123 goes from point 203 to point 209 EQUB 126 \ Line ID 124 goes from point 125 to point 126 EQUB 126 \ Line ID 125 goes from point 127 to point 126 EQUB 127 \ Line ID 126 goes from point 125 to point 127 EQUB 141 \ Line ID 127 goes from point 140 to point 141 EQUB 124 \ Line ID 128 goes from point 141 to point 124 EQUB 143 \ Line ID 129 goes from point 140 to point 143 EQUB 142 \ Line ID 130 goes from point 143 to point 142 EQUB 154 \ Line ID 131 goes from point 153 to point 154 EQUB 155 \ Line ID 132 goes from point 154 to point 155 EQUB 156 \ Line ID 133 goes from point 155 to point 156 EQUB 153 \ Line ID 134 goes from point 156 to point 153 EQUB 179 \ Line ID 135 goes from point 178 to point 179 EQUB 180 \ Line ID 136 goes from point 178 to point 180 EQUB 180 \ Line ID 137 goes from point 179 to point 180 EQUB 184 \ Line ID 138 goes from point 183 to point 184 EQUB 185 \ Line ID 139 goes from point 183 to point 185 EQUB 185 \ Line ID 140 goes from point 184 to point 185 EQUB 186 \ Line ID 141 goes from point 183 to point 186 EQUB 184 \ Line ID 142 goes from point 186 to point 184 EQUB 185 \ Line ID 143 goes from point 186 to point 185 EQUB 189 \ Line ID 144 goes from point 188 to point 189 EQUB 190 \ Line ID 145 goes from point 188 to point 190 EQUB 190 \ Line ID 146 goes from point 189 to point 190 EQUB 191 \ Line ID 147 goes from point 188 to point 191 EQUB 189 \ Line ID 148 goes from point 191 to point 189 EQUB 190 \ Line ID 149 goes from point 191 to point 190 EQUB 215 \ Line ID 150 goes from point 108 to point 215 EQUB 194 \ Line ID 151 goes from point 193 to point 194 EQUB 195 \ Line ID 152 goes from point 193 to point 195 EQUB 195 \ Line ID 153 goes from point 194 to point 195 EQUB 196 \ Line ID 154 goes from point 193 to point 196 EQUB 194 \ Line ID 155 goes from point 196 to point 194 EQUB 195 \ Line ID 156 goes from point 196 to point 195 EQUB 200 \ Line ID 157 goes from point 193 to point 200 EQUB 198 \ Line ID 158 goes from point 194 to point 198 EQUB 198 \ Line ID 159 goes from point 197 to point 198 EQUB 200 \ Line ID 160 goes from point 199 to point 200 EQUB 88 \ Line ID 161 goes from point 86 to point 88 EQUB 87 \ Line ID 162 goes from point 99 to point 87 EQUB 201 \ Line ID 163 goes from point 39 to point 201 EQUB 40 \ Line ID 164 goes from point 202 to point 40 EQUB 25 \ Line ID 165 goes from point 22 to point 25 EQUB 28 \ Line ID 166 goes from point 21 to point 28 EQUB 23 \ Line ID 167 goes from point 26 to point 23 EQUB 24 \ Line ID 168 goes from point 27 to point 24 EQUB 88 \ Line ID 169 goes from point 201 to point 88 EQUB 99 \ Line ID 170 goes from point 88 to point 99 EQUB 99 \ Line ID 171 goes from point 202 to point 99 EQUB 202 \ Line ID 172 goes from point 201 to point 202 EQUB 28 \ Line ID 173 goes from point 25 to point 28 EQUB 26 \ Line ID 174 goes from point 25 to point 26 EQUB 27 \ Line ID 175 goes from point 26 to point 27 EQUB 28 \ Line ID 176 goes from point 27 to point 28 EQUB 29 \ Line ID 177 goes from point 22 to point 29 EQUB 40 \ Line ID 178 goes from point 33 to point 40 EQUB 34 \ Line ID 179 goes from point 205 to point 34 EQUB 37 \ Line ID 180 goes from point 40 to point 37 EQUB 38 \ Line ID 181 goes from point 205 to point 38 EQUB 209 \ Line ID 182 goes from point 207 to point 209 EQUB 210 \ Line ID 183 goes from point 209 to point 210 EQUB 208 \ Line ID 184 goes from point 210 to point 208 EQUB 208 \ Line ID 185 goes from point 207 to point 208 EQUB 204 \ Line ID 186 goes from point 210 to point 204 EQUB 206 \ Line ID 187 goes from point 208 to point 206 EQUB 207 \ Line ID 188 goes from point 205 to point 207 EQUB 211 \ Line ID 189 goes from point 35 to point 211 EQUB 211 \ Line ID 190 goes from point 212 to point 211 EQUB 211 \ Line ID 191 goes from point 36 to point 211 EQUB 215 \ Line ID 192 goes from point 214 to point 215 EQUB &D7, &74 \ These bytes appear to be unused EQUB &72, &75 EQUB &32, &3A EQUB &43
Name: objectGroup [Show more] Type: Variable Category: 3D geometry Summary: The current group number for object IDs 6, 7, 8 and 9 Deep dive: 3D objects
Context: See this variable on its own page References: This variable is used as follows: * NextObjectGroup calls objectGroup * SetObjectCoords (Part 4 of 11) calls objectGroup

The current object number in each of the four object groups. The values in this table cycle through the following values: * 0 to 7 the current group number for object ID 6 * 8 to 15 the current group number for object ID 7 * 16 to 23 the current group number for object ID 8 * 24 to 31 the current group number for object ID 9 and then back round to the start. The cycling is performed by successive calls to the NextObjectGroup routine.
.objectGroup EQUB 0, 8, 16, 24
Name: groupStart [Show more] Type: Variable Category: 3D geometry Summary: The starting value for each object's group number
Context: See this variable on its own page References: This variable is used as follows: * NextObjectGroup calls groupStart

The starting point for the four object groups, to which we add a number in the range 0 to 7 to get the next number, so the group numbers cycle through the following values: * 0 to 7 * 8 to 15 * 16 to 23 * 24 to 31
.groupStart EQUB 0, 8, 16, 24
Name: xGroupObjectHi [Show more] Type: Variable Category: 3D geometry Summary: High byte of the x-coordinate for objects in a group (6 to 9) Deep dive: 3D objects
Context: See this variable on its own page References: This variable is used as follows: * SetObjectCoords (Part 4 of 11) calls xGroupObjectHi
.xGroupObjectHi EQUB &C8 \ Object 6: tree 0 has coordinates (&C800, &0000, &5200) EQUB &2A \ Object 6: tree 1 has coordinates (&2A00, &0000, &D200) EQUB &CF \ Object 6: tree 2 has coordinates (&CF00, &0000, &9A00) EQUB &82 \ Object 6: tree 3 has coordinates (&8200, &0000, &C900) EQUB &1D \ Object 6: tree 4 has coordinates (&1D00, &0000, &3E00) EQUB &75 \ Object 6: tree 5 has coordinates (&7500, &0000, &3300) EQUB &1A \ Object 6: tree 6 has coordinates (&1A00, &0000, &8A00) EQUB &CF \ Object 6: tree 7 has coordinates (&CF00, &0000, &EC00) EQUB &9C \ Object 7: tree 0 has coordinates (&9C00, &0000, &C600) EQUB &43 \ Object 7: tree 1 has coordinates (&4300, &0000, &E200) EQUB &E5 \ Object 7: tree 2 has coordinates (&E500, &0000, &BA00) EQUB &8A \ Object 7: tree 3 has coordinates (&8A00, &0000, &7000) EQUB &EA \ Object 7: tree 4 has coordinates (&EA00, &0000, &6E00) EQUB &22 \ Object 7: tree 5 has coordinates (&2200, &0000, &4400) EQUB &6A \ Object 7: tree 6 has coordinates (&6A00, &0000, &2000) EQUB &C5 \ Object 7: tree 7 has coordinates (&C500, &0000, &1B00) EQUB &15 \ Object 8: hill 0 has coordinates (&1500, &0000, &2F00) EQUB &C4 \ Object 8: hill 1 has coordinates (&C400, &0000, &0500) EQUB &C4 \ Object 8: hill 2 has coordinates (&C400, &0000, &0500) EQUB &CE \ Object 8: hill 3 has coordinates (&CE00, &0000, &F500) EQUB &CE \ Object 8: hill 4 has coordinates (&CE00, &0000, &F500) EQUB &CE \ Object 8: hill 5 has coordinates (&CE00, &0000, &F500) EQUB &15 \ Object 8: hill 6 has coordinates (&1500, &0000, &2F00) EQUB &11 \ Object 8: hill 7 has coordinates (&1100, &0000, &D600) EQUB &38 \ Object 9: hill 0 has coordinates (&3800, &0000, &1C00) EQUB &D5 \ Object 9: hill 1 has coordinates (&D500, &0000, &2E00) EQUB &D5 \ Object 9: hill 2 has coordinates (&D500, &0000, &2E00) EQUB &DA \ Object 9: hill 3 has coordinates (&DA00, &0000, &D300) EQUB &DA \ Object 9: hill 4 has coordinates (&DA00, &0000, &D300) EQUB &0D \ Object 9: hill 5 has coordinates (&0D00, &0000, &D900) EQUB &38 \ Object 9: hill 6 has coordinates (&3800, &0000, &1C00) EQUB &0D \ Object 9: hill 7 has coordinates (&0D00, &0000, &D900)
Name: zGroupObjectHi [Show more] Type: Variable Category: 3D geometry Summary: High byte of the z-coordinate for objects in a group (6 to 9) Deep dive: 3D objects
Context: See this variable on its own page References: This variable is used as follows: * SetObjectCoords (Part 4 of 11) calls zGroupObjectHi
.zGroupObjectHi EQUB &52 \ Object 6: tree 0 has coordinates (&C800, &0000, &5200) EQUB &D2 \ Object 6: tree 1 has coordinates (&2A00, &0000, &D200) EQUB &9A \ Object 6: tree 2 has coordinates (&CF00, &0000, &9A00) EQUB &C9 \ Object 6: tree 3 has coordinates (&8200, &0000, &C900) EQUB &3E \ Object 6: tree 4 has coordinates (&1D00, &0000, &3E00) EQUB &33 \ Object 6: tree 5 has coordinates (&7500, &0000, &3300) EQUB &8A \ Object 6: tree 6 has coordinates (&1A00, &0000, &8A00) EQUB &EC \ Object 6: tree 7 has coordinates (&CF00, &0000, &EC00) EQUB &C6 \ Object 7: tree 0 has coordinates (&9C00, &0000, &C600) EQUB &E2 \ Object 7: tree 1 has coordinates (&4300, &0000, &E200) EQUB &BA \ Object 7: tree 2 has coordinates (&E500, &0000, &BA00) EQUB &70 \ Object 7: tree 3 has coordinates (&8A00, &0000, &7000) EQUB &6E \ Object 7: tree 4 has coordinates (&EA00, &0000, &6E00) EQUB &44 \ Object 7: tree 5 has coordinates (&2200, &0000, &4400) EQUB &20 \ Object 7: tree 6 has coordinates (&6A00, &0000, &2000) EQUB &1B \ Object 7: tree 7 has coordinates (&C500, &0000, &1B00) EQUB &2F \ Object 8: hill 0 has coordinates (&1500, &0000, &2F00) EQUB &05 \ Object 8: hill 1 has coordinates (&C400, &0000, &0500) EQUB &05 \ Object 8: hill 2 has coordinates (&C400, &0000, &0500) EQUB &F5 \ Object 8: hill 3 has coordinates (&CE00, &0000, &F500) EQUB &F5 \ Object 8: hill 4 has coordinates (&CE00, &0000, &F500) EQUB &F5 \ Object 8: hill 5 has coordinates (&CE00, &0000, &F500) EQUB &2F \ Object 8: hill 6 has coordinates (&1500, &0000, &2F00) EQUB &D6 \ Object 8: hill 7 has coordinates (&1100, &0000, &D600) EQUB &1C \ Object 9: hill 0 has coordinates (&3800, &0000, &1C00) EQUB &2E \ Object 9: hill 1 has coordinates (&D500, &0000, &2E00) EQUB &2E \ Object 9: hill 2 has coordinates (&D500, &0000, &2E00) EQUB &D3 \ Object 9: hill 3 has coordinates (&DA00, &0000, &D300) EQUB &D3 \ Object 9: hill 4 has coordinates (&DA00, &0000, &D300) EQUB &D9 \ Object 9: hill 5 has coordinates (&0D00, &0000, &D900) EQUB &1C \ Object 9: hill 6 has coordinates (&3800, &0000, &1C00) EQUB &D9 \ Object 9: hill 7 has coordinates (&0D00, &0000, &D900)
Name: CheckTimePassed [Show more] Type: Subroutine Category: Utility routines Summary: Flag whether 9 centiseconds have passed since the last call
Context: See this subroutine on its own page References: This subroutine is called as follows: * MainLoop (Part 12 of 15) calls CheckTimePassed

Arguments: P The current time, incrementing 100 times a second Returns: C flag Returns: * Clear if fewer than 9 centiseconds have passed since the last call to this routine that reset the counter * Set if 9 centiseconds or more have passed since the last call to this routine, in which case the counter resets
.CheckTimePassed LDX P \ Set X = P TXA \ Set A = P - previousTime SEC \ SBC previousTime \ so A is the number of centiseconds that have passed \ since the last call to this routine (unless the time \ has wrapped, in which case it will be negative) BPL time1 \ If A is positive, skip the following three \ instructions EOR #&FF \ A is negative, so negate A using two's complement, so: CLC \ ADC #1 \ A = |P - previousTime| .time1 CMP #9 \ If |A| < 9, skip the following instruction BCC time2 STX previousTime \ Update previousTime to the current timer in X, so the \ count of 9 centiseconds since the last call can start \ again .time2 RTS \ Return from the subroutine EQUB &3D, &41 \ These bytes appear to be unused EQUB &42, &43 EQUB &77, &78 EQUB &44, &45 EQUB &46, &50
Name: lineStartPointId [Show more] Type: Variable Category: 3D geometry Summary: The point ID for a line's start point Deep dive: Lines and points
Context: See this variable on its own page References: This variable is used as follows: * DrawCanopyView calls lineStartPointId * MainLoop (Part 15 of 15) calls lineStartPointId * ProcessLine (Part 1 of 7) calls lineStartPointId * ProcessLinesToShow calls lineStartPointId

This table contains the point ID for each line's start point. The table is indexed by line ID, so for line ID X, lineStartPointId,X contains the point ID of the line's start point.
.lineStartPointId EQUB 31 \ Line ID 0 goes from point 31 to point 30 EQUB 1 \ Line ID 1 goes from point 1 to point 2 EQUB 2 \ Line ID 2 goes from point 2 to point 3 EQUB 3 \ Line ID 3 goes from point 3 to point 4 EQUB 4 \ Line ID 4 goes from point 4 to point 1 EQUB 6 \ Line ID 5 goes from point 6 to point 7 EQUB 8 \ Line ID 6 goes from point 8 to point 9 EQUB 10 \ Line ID 7 goes from point 10 to point 11 EQUB 12 \ Line ID 8 goes from point 12 to point 13 EQUB 14 \ Line ID 9 goes from point 14 to point 15 EQUB 16 \ Line ID 10 goes from point 16 to point 17 EQUB 18 \ Line ID 11 goes from point 18 to point 19 EQUB 114 \ Line ID 12 goes from point 114 to point 59 EQUB 115 \ Line ID 13 goes from point 115 to point 114 EQUB 41 \ Line ID 14 goes from point 41 to point 42 EQUB 42 \ Line ID 15 goes from point 42 to point 43 EQUB 43 \ Line ID 16 goes from point 43 to point 44 EQUB 45 \ Line ID 17 goes from point 45 to point 46 EQUB 46 \ Line ID 18 goes from point 46 to point 47 EQUB 47 \ Line ID 19 goes from point 47 to point 48 EQUB 49 \ Line ID 20 goes from point 49 to point 53 EQUB 50 \ Line ID 21 goes from point 50 to point 54 EQUB 51 \ Line ID 22 goes from point 51 to point 55 EQUB 52 \ Line ID 23 goes from point 52 to point 56 EQUB 59 \ Line ID 24 goes from point 59 to point 58 EQUB 58 \ Line ID 25 goes from point 58 to point 57 EQUB 57 \ Line ID 26 goes from point 57 to point 51 EQUB 52 \ Line ID 27 goes from point 52 to point 60 EQUB 60 \ Line ID 28 goes from point 60 to point 61 EQUB 49 \ Line ID 29 goes from point 49 to point 62 EQUB 50 \ Line ID 30 goes from point 50 to point 63 EQUB 62 \ Line ID 31 goes from point 62 to point 64 EQUB 63 \ Line ID 32 goes from point 63 to point 65 EQUB 64 \ Line ID 33 goes from point 64 to point 66 EQUB 115 \ Line ID 34 goes from point 115 to point 116 EQUB 116 \ Line ID 35 goes from point 116 to point 113 EQUB 112 \ Line ID 36 goes from point 112 to point 113 EQUB 111 \ Line ID 37 goes from point 111 to point 112 EQUB 61 \ Line ID 38 goes from point 61 to point 111 EQUB 65 \ Line ID 39 goes from point 65 to point 67 EQUB 66 \ Line ID 40 goes from point 66 to point 119 EQUB 67 \ Line ID 41 goes from point 67 to point 120 EQUB 119 \ Line ID 42 goes from point 119 to point 68 EQUB 120 \ Line ID 43 goes from point 120 to point 69 EQUB 68 \ Line ID 44 goes from point 68 to point 70 EQUB 69 \ Line ID 45 goes from point 69 to point 71 EQUB 70 \ Line ID 46 goes from point 70 to point 117 EQUB 80 \ Line ID 47 goes from point 80 to point 81 EQUB 82 \ Line ID 48 goes from point 82 to point 85 EQUB 83 \ Line ID 49 goes from point 83 to point 85 EQUB 84 \ Line ID 50 goes from point 84 to point 85 EQUB 71 \ Line ID 51 goes from point 71 to point 118 EQUB 117 \ Line ID 52 goes from point 117 to point 72 EQUB 118 \ Line ID 53 goes from point 118 to point 73 EQUB 72 \ Line ID 54 goes from point 72 to point 74 EQUB 73 \ Line ID 55 goes from point 73 to point 75 EQUB 89 \ Line ID 56 goes from point 89 to point 90 EQUB 91 \ Line ID 57 goes from point 91 to point 94 EQUB 92 \ Line ID 58 goes from point 92 to point 94 EQUB 93 \ Line ID 59 goes from point 93 to point 94 EQUB 95 \ Line ID 60 goes from point 95 to point 96 EQUB 97 \ Line ID 61 goes from point 97 to point 98 EQUB 74 \ Line ID 62 goes from point 74 to point 76 EQUB 75 \ Line ID 63 goes from point 75 to point 77 EQUB 76 \ Line ID 64 goes from point 76 to point 78 EQUB 77 \ Line ID 65 goes from point 77 to point 79 EQUB 78 \ Line ID 66 goes from point 78 to point 101 EQUB 79 \ Line ID 67 goes from point 79 to point 100 EQUB 101 \ Line ID 68 goes from point 101 to point 102 EQUB 100 \ Line ID 69 goes from point 100 to point 103 EQUB 102 \ Line ID 70 goes from point 102 to point 105 EQUB 103 \ Line ID 71 goes from point 103 to point 104 EQUB 105 \ Line ID 72 goes from point 105 to point 107 EQUB 104 \ Line ID 73 goes from point 104 to point 106 EQUB 107 \ Line ID 74 goes from point 107 to point 109 EQUB 106 \ Line ID 75 goes from point 106 to point 109 EQUB 213 \ Line ID 76 goes from point 213 to point 215 EQUB 109 \ Line ID 77 goes from point 109 to point 110 EQUB 121 \ Line ID 78 goes from point 121 to point 122 EQUB 177 \ Line ID 79 goes from point 177 to point 121 EQUB 122 \ Line ID 80 goes from point 122 to point 123 EQUB 177 \ Line ID 81 goes from point 177 to point 123 EQUB 144 \ Line ID 82 goes from point 144 to point 145 EQUB 146 \ Line ID 83 goes from point 146 to point 145 EQUB 146 \ Line ID 84 goes from point 146 to point 147 EQUB 148 \ Line ID 85 goes from point 148 to point 147 EQUB 144 \ Line ID 86 goes from point 144 to point 148 EQUB 157 \ Line ID 87 goes from point 157 to point 158 EQUB 158 \ Line ID 88 goes from point 158 to point 159 EQUB 159 \ Line ID 89 goes from point 159 to point 160 EQUB 157 \ Line ID 90 goes from point 157 to point 160 EQUB 164 \ Line ID 91 goes from point 164 to point 161 EQUB 163 \ Line ID 92 goes from point 163 to point 162 EQUB 162 \ Line ID 93 goes from point 162 to point 161 EQUB 164 \ Line ID 94 goes from point 164 to point 163 EQUB 165 \ Line ID 95 goes from point 165 to point 168 EQUB 165 \ Line ID 96 goes from point 165 to point 166 EQUB 166 \ Line ID 97 goes from point 166 to point 167 EQUB 167 \ Line ID 98 goes from point 167 to point 168 EQUB 169 \ Line ID 99 goes from point 169 to point 172 EQUB 169 \ Line ID 100 goes from point 169 to point 171 EQUB 142 \ Line ID 101 goes from point 142 to point 124 EQUB 172 \ Line ID 102 goes from point 172 to point 171 EQUB 176 \ Line ID 103 goes from point 176 to point 175 EQUB 175 \ Line ID 104 goes from point 175 to point 174 EQUB 176 \ Line ID 105 goes from point 176 to point 173 EQUB 173 \ Line ID 106 goes from point 173 to point 174 EQUB 150 \ Line ID 107 goes from point 150 to point 151 EQUB 152 \ Line ID 108 goes from point 152 to point 151 EQUB 152 \ Line ID 109 goes from point 152 to point 149 EQUB 149 \ Line ID 110 goes from point 149 to point 150 EQUB 139 \ Line ID 111 goes from point 139 to point 138 EQUB 137 \ Line ID 112 goes from point 137 to point 138 EQUB 136 \ Line ID 113 goes from point 136 to point 137 EQUB 136 \ Line ID 114 goes from point 136 to point 139 EQUB 132 \ Line ID 115 goes from point 132 to point 133 EQUB 132 \ Line ID 116 goes from point 132 to point 135 EQUB 135 \ Line ID 117 goes from point 135 to point 134 EQUB 133 \ Line ID 118 goes from point 133 to point 134 EQUB 128 \ Line ID 119 goes from point 128 to point 129 EQUB 129 \ Line ID 120 goes from point 129 to point 130 EQUB 130 \ Line ID 121 goes from point 130 to point 131 EQUB 128 \ Line ID 122 goes from point 128 to point 131 EQUB 203 \ Line ID 123 goes from point 203 to point 209 EQUB 125 \ Line ID 124 goes from point 125 to point 126 EQUB 127 \ Line ID 125 goes from point 127 to point 126 EQUB 125 \ Line ID 126 goes from point 125 to point 127 EQUB 140 \ Line ID 127 goes from point 140 to point 141 EQUB 141 \ Line ID 128 goes from point 141 to point 124 EQUB 140 \ Line ID 129 goes from point 140 to point 143 EQUB 143 \ Line ID 130 goes from point 143 to point 142 EQUB 153 \ Line ID 131 goes from point 153 to point 154 EQUB 154 \ Line ID 132 goes from point 154 to point 155 EQUB 155 \ Line ID 133 goes from point 155 to point 156 EQUB 156 \ Line ID 134 goes from point 156 to point 153 EQUB 178 \ Line ID 135 goes from point 178 to point 179 EQUB 178 \ Line ID 136 goes from point 178 to point 180 EQUB 179 \ Line ID 137 goes from point 179 to point 180 EQUB 183 \ Line ID 138 goes from point 183 to point 184 EQUB 183 \ Line ID 139 goes from point 183 to point 185 EQUB 184 \ Line ID 140 goes from point 184 to point 185 EQUB 183 \ Line ID 141 goes from point 183 to point 186 EQUB 186 \ Line ID 142 goes from point 186 to point 184 EQUB 186 \ Line ID 143 goes from point 186 to point 185 EQUB 188 \ Line ID 144 goes from point 188 to point 189 EQUB 188 \ Line ID 145 goes from point 188 to point 190 EQUB 189 \ Line ID 146 goes from point 189 to point 190 EQUB 188 \ Line ID 147 goes from point 188 to point 191 EQUB 191 \ Line ID 148 goes from point 191 to point 189 EQUB 191 \ Line ID 149 goes from point 191 to point 190 EQUB 108 \ Line ID 150 goes from point 108 to point 215 EQUB 193 \ Line ID 151 goes from point 193 to point 194 EQUB 193 \ Line ID 152 goes from point 193 to point 195 EQUB 194 \ Line ID 153 goes from point 194 to point 195 EQUB 193 \ Line ID 154 goes from point 193 to point 196 EQUB 196 \ Line ID 155 goes from point 196 to point 194 EQUB 196 \ Line ID 156 goes from point 196 to point 195 EQUB 193 \ Line ID 157 goes from point 193 to point 200 EQUB 194 \ Line ID 158 goes from point 194 to point 198 EQUB 197 \ Line ID 159 goes from point 197 to point 198 EQUB 199 \ Line ID 160 goes from point 199 to point 200 EQUB 86 \ Line ID 161 goes from point 86 to point 88 EQUB 99 \ Line ID 162 goes from point 99 to point 87 EQUB 39 \ Line ID 163 goes from point 39 to point 201 EQUB 202 \ Line ID 164 goes from point 202 to point 40 EQUB 22 \ Line ID 165 goes from point 22 to point 25 EQUB 21 \ Line ID 166 goes from point 21 to point 28 EQUB 26 \ Line ID 167 goes from point 26 to point 23 EQUB 27 \ Line ID 168 goes from point 27 to point 24 EQUB 201 \ Line ID 169 goes from point 201 to point 88 EQUB 88 \ Line ID 170 goes from point 88 to point 99 EQUB 202 \ Line ID 171 goes from point 202 to point 99 EQUB 201 \ Line ID 172 goes from point 201 to point 202 EQUB 25 \ Line ID 173 goes from point 25 to point 28 EQUB 25 \ Line ID 174 goes from point 25 to point 26 EQUB 26 \ Line ID 175 goes from point 26 to point 27 EQUB 27 \ Line ID 176 goes from point 27 to point 28 EQUB 22 \ Line ID 177 goes from point 22 to point 29 EQUB 33 \ Line ID 178 goes from point 33 to point 40 EQUB 205 \ Line ID 179 goes from point 205 to point 34 EQUB 40 \ Line ID 180 goes from point 40 to point 37 EQUB 205 \ Line ID 181 goes from point 205 to point 38 EQUB 207 \ Line ID 182 goes from point 207 to point 209 EQUB 209 \ Line ID 183 goes from point 209 to point 210 EQUB 210 \ Line ID 184 goes from point 210 to point 208 EQUB 207 \ Line ID 185 goes from point 207 to point 208 EQUB 210 \ Line ID 186 goes from point 210 to point 204 EQUB 208 \ Line ID 187 goes from point 208 to point 206 EQUB 205 \ Line ID 188 goes from point 205 to point 207 EQUB 35 \ Line ID 189 goes from point 35 to point 211 EQUB 212 \ Line ID 190 goes from point 212 to point 211 EQUB 36 \ Line ID 191 goes from point 36 to point 211 EQUB 214 \ Line ID 192 goes from point 214 to point 215 EQUB &6C, &03 \ These bytes appear to be unused EQUB &0A, &20 EQUB &20, &20 EQUB &20, &00 EQUB &00
Name: alienScore [Show more] Type: Variable Category: The Theme Summary: The scores for killing aliens in the various feeding stages
Context: See this variable on its own page References: This variable is used as follows: * ScoreHitPoints calls alienScore
.alienScore EQUB &05 \ The score for a large feeding alien (50 points) EQUB &10 \ The score for a medium feeding alien (100 points) EQUB &15 \ The score for a small feeding alien (150 points) EQUB &25 \ The score for the smallest feeding alien (250 points) EQUB &00 \ This byte appears to be unused
Name: dormantAlienScore [Show more] Type: Variable Category: The Theme Summary: The score for killing a dormant alien
Context: See this variable on its own page References: This variable is used as follows: * ScoreHitPoints calls dormantAlienScore
.dormantAlienScore EQUB &40 \ The score for a dormant alien (400 points)
Name: sinLo [Show more] Type: Variable Category: Maths Summary: Low byte of the sine lookup table Deep dive: Trigonometry
Context: See this variable on its own page References: This variable is used as follows: * Sine16Bit calls sinLo

This table contains sine values for a quarter of a circle, i.e. for the range 0 to 90 degrees, or 0 to PI/2 radians. The table contains values for indexes 0 to 256, which cover the quarter from 0 to PI/2 radians. Entry X in the table is therefore (X / 256) * (PI / 2) radians of the way round the quarter circle, so the table at index X contains the sine of this value. The value of sine across the quarter circle ranges from 0 to 1: sin(0) = 0 sin(90) = sin(PI/2) = 1 but assembly language doesn't support fractions, so instead we store the sine in a 16-bit number that contains the sine multiplied by 65536, so the range of (sinHi sinLo) over the course of the quarter circle is 0 to 65536. It might help to think of sinHi as an integer ranging from 0 to 256 across the quarter circle, with sinLo as the fractional part ranging from 0 to 255; this is the approach taken in the Sine16Bit routine. In other words, entry X in this table contains sin(X) * 65536, where X ranges from 0 to 256 over the course of a quarter circle.
.sinLo FOR I%, 0, 256 N = SIN((I% / 256) * (PI / 2)) IF N >= 1 EQUB 255 ELSE EQUB LO(INT(N * 65536)) ENDIF NEXT
Name: sinHi [Show more] Type: Variable Category: Maths Summary: High byte of the sine lookup table Deep dive: Trigonometry
Context: See this variable on its own page References: This variable is used as follows: * Sine16Bit calls sinHi

See sinLo for an explanation of this table.
.sinHi FOR I%, 0, 256 N = SIN((I% / 256) * (PI / 2)) IF N >= 1 EQUB 255 ELSE EQUB HI(INT(N * 65536)) ENDIF NEXT
Name: alienSlot [Show more] Type: Variable Category: The Theme Summary: Slots for up to three aliens that are ready to start moving towards the town
Each slot contains the following: * If the slot contains a negative number, then the slot is empty * Otherwise the slot contains the number of the alien in that slot (0 to 7) Each slot is associated with one of the alien objects: the first slot is for object ID 30, the second for object ID 31, and the third for object ID 32. We refer to these as slots 30, 31 and 32. Note that each alien in a slot has its own object associated with it (via the alienObjectId table) that is used for displaying the alien, but when an alien finishes feeding and starts to get ready for flying, it is also associated with the special alien objects 30 to 33. Slot 30 contains dormant aliens, slots 31 and 32 contain feeding aliens and those that are waiting for slot 33 to free up, and slot 33 (at alienToMove) contains the alien that's moving towards the town (only one alien can attack at any one time).
.alienSlot EQUB &6C \ The alien number associated with object ID 30 EQUB &6B \ The alien number associated with object ID 31 EQUB &6A \ The alien number associated with object ID 32 \ \ Zeroed in ResetVariables
Name: alienToMove [Show more] Type: Variable Category: The Theme Summary: The number of the alien to move towards Acornsville in this iteration of the main loop
Context: See this variable on its own page References: This variable is used as follows: * AlienInAcornsville calls alienToMove * MainLoop (Part 5 of 15) calls alienToMove * UpdateAliens (Part 3 of 5) calls alienToMove

This slot contains the following: * If the slot contains a negative number, then the slot is empty * Otherwise the slot contains the number of the alien in that slot (0 to 7) This slot is reserved for the alien that is moving towards the town, which is the only alien shown on the radar.
.alienToMove EQUB &69 \ The alien number associated with object ID 33 \ \ Zeroed in ResetVariables
Name: mainLoopCounter [Show more] Type: Variable Category: Main loop Summary: The main loop counter Deep dive: Scheduling tasks in the main loop
.mainLoopCounter EQUB &67 \ The main loop counter, which is incremented every \ iteration of the main loop
Name: numberOfLines [Show more] Type: Variable Category: 3D geometry Summary: The total number of lines in Aviator's 3D world
Context: See this variable on its own page References: This variable is used as follows: * ResetLineLists calls numberOfLines
.numberOfLines EQUB 193 \ The total number of lines in the world
Name: alienObjectId [Show more] Type: Variable Category: The Theme Summary: Object IDs for each of the eight aliens
Contains the object ID for each of the eight aliens. A negative entry denotes that the alien has been destroyed, a positive entry denotes that the alien is still around, with the entry containing the object ID we're using for that alien. This is called FLDPTR in the original source code.
.alienObjectId EQUB &65, &64 \ Zeroed in ResetVariables EQUB &62, &61 EQUB &60, &5F EQUB &5E, &5C
Name: alienState [Show more] Type: Variable Category: The Theme Summary: The state of each of the eight aliens Deep dive: Alien feeding and growth patterns
All eight aliens start in the dormant state (state 0). They effectively live in alien slot 30, which uses an object group to manage all the alien objects. Dormant aliens are promoted to state 1 in the UpdateAliens routine. One alien will be promoted and will start feeding once there is a vacancy in one of the alien slots 31 and 32. A vacancy is produced when an alien is promoted into alien slot 33 (preparing to take off), or when a feeding alien is destroyed. Once an alien is in state 1, the state gets incremented in the UpdateAliens routine on 2 of every 256 main loop iterations, until it reaches 22. An alien is only promoted from state 22 if slot 33 becomes vacant, at which point it is bumped up to state 23 (preparing to take off). Once an alien is in state 23, the state gets incremented in the UpdateAliens routine on 2 of every 256 main loop iterations, until it reaches 27, at which point it will take off and head for the town (see the AlienInAcornsville routine), before eventually descending to the town at state 28. 0 Dormant 1-7 Feeding stage 1 8-11 Feeding stage 2 12-15 Feeding stage 3 16-21 Feeding stage 4 22 The alien has finished feeding and is ready to move to the next stage (preparing to take off). As there can be only one alien flying towards the town at any one time, we have to wait for the attack slot (slot 33) to become vacant, at which point an alien in this state will be put into slot 33, and its state bumped up to 23 23-26 Preparing to take off 27 Flying towards Acornsville 28 Descending towards Acornsville for the final attack
.alienState EQUB &5B, &5A \ Zeroed in ResetVariables EQUB &59, &58 EQUB &7D, &7C EQUB &7B, &7A
Name: alienStatus [Show more] Type: Variable Category: The Theme Summary: Storage for the object status bytes for the four alien objects
Context: See this variable on its own page References: This variable is used as follows: * MainLoop (Part 1 of 15) calls alienStatus * MainLoop (Part 6 of 15) calls alienStatus
.alienStatus EQUB &78, &77 EQUB &76, &75 EQUB &74, &72 \ These bytes appear to be unused EQUB &71, &70
Name: matrix1Lo [Show more] Type: Variable Category: Maths Summary: The low bytes of matrix 1
Context: See this variable on its own page References: This variable is used as follows: * SetMatrices calls matrix1Lo * SetMatrixEntry calls matrix1Lo * SetObjPointCoords (Part 1 of 2) calls matrix1Lo * SetPointCoords calls matrix1Lo

If bit 0 is set in the low byte of a matrix entry, then it is negative.
.matrix1Lo EQUB &31, &39, &0D EQUB &06, &18, &10 EQUB &20, &20, &20
Name: matrix2Lo [Show more] Type: Variable Category: Maths Summary: The low bytes of matrix 2
Context: See this variable on its own page References: This variable is used as follows: * SetMatrices calls matrix2Lo

If bit 0 is set in the low byte of a matrix entry, then it is negative.
.matrix2Lo EQUB &20, &20, &20 EQUB &4C, &44, &59 EQUB &23, &33, &31
Name: matrix3Lo [Show more] Type: Variable Category: Maths Summary: The low bytes of matrix 3
Context: See this variable on its own page References: This variable is used as follows: * SetMatrices calls matrix3Lo

If bit 0 is set in the low byte of a matrix entry, then it is negative.
.matrix3Lo EQUB &0D, &06, &00 EQUB &1D, &2E, &00 EQUB &00, &00, &FE
Name: matrix4Lo [Show more] Type: Variable Category: Maths Summary: The low bytes of matrix 4
Context: See this variable on its own page References: This variable is used as follows: * ArtificialHorizon calls matrix4Lo * SetMatrices calls matrix4Lo

If bit 0 is set in the low byte of a matrix entry, then it is negative.
.matrix4Lo EQUB &20, &4C, &44 EQUB &58, &20, &50 EQUB &00, &52, &4E
Name: CheckFlyingSkills (Part 1 of 2) [Show more] Type: Subroutine Category: Scoring Summary: Check whether we are performing one of the tests of flying skill Deep dive: Flying skills
Context: See this subroutine on its own page References: This subroutine is called as follows: * MainLoop (Part 5 of 15) calls CheckFlyingSkills

This routine checks where we are, and awards the following points: * 50 points for flying under the bridge the right way up * 100 points for flying under the bridge upside down * 100 points for flying down the main street of Acornsville the right way up * 200 points for flying down the main street of Acornsville upside down There are multiple skill zones defined for each object (the bridge and the main street). To earn the points, we need to fly into the correct skill zones while avoiding others, and then back out again without hitting the ground. Arguments: Y The skill to check: * 2 = Flying under the suspension bridge * 34 = Flying down the main street of Acornsville
.CheckFlyingSkills LDA xPlaneHi \ Set A = xPlaneHi - the x-coordinate of either the SEC \ bridge or town, which is the high byte of the distance SBC xObjectHi,Y \ along the x-axis between the plane and the object that \ we are checking BPL skil1 \ If A is negative, flip the bits, so A contains the EOR #&FF \ absolute value of the distance along the x-axis .skil1 CMP #5 \ If the high byte of the distance is less than 5, then BCC skil3 \ we are close enough to the bridge or town to warrant \ further checks, so jump to skil3 .skil2 RTS \ Otherwise we are too far away from the bridge and town \ to score any points, so return from the subroutine .skil3 LDA zPlaneHi \ Set A = zPlaneHi - the z-coordinate of either the SEC \ bridge or town, which is the high byte of the distance SBC zObjectHi,Y \ along the z-axis between the plane and the object that \ we are checking JMP skil4 \ Jump down to part 2 of the routine EQUB &4D, &50 \ These bytes appear to be unused
Name: matrix1Hi [Show more] Type: Variable Category: Maths Summary: The high bytes of matrix 1
Context: See this variable on its own page References: This variable is used as follows: * SetMatrices calls matrix1Hi * SetMatrixEntry calls matrix1Hi * SetObjPointCoords (Part 1 of 2) calls matrix1Hi * SetPointCoords calls matrix1Hi

If bit 0 is set in the low byte of a matrix entry, then it is negative.
.matrix1Hi EQUB &B2, &32, &AF EQUB &0B, &F2, &51 EQUB &B6, &40, &A7
Name: matrix2Hi [Show more] Type: Variable Category: Maths Summary: The high bytes of matrix 2
Context: See this variable on its own page References: This variable is used as follows: * SetMatrices calls matrix2Hi

If bit 0 is set in the low byte of a matrix entry, then it is negative.
.matrix2Hi EQUB &B2, &0B, &B6 EQUB &32, &F2, &40 EQUB &AF, &51, &A7
Name: matrix3Hi [Show more] Type: Variable Category: Maths Summary: The high bytes of matrix 3
Context: See this variable on its own page References: This variable is used as follows: * SetMatrices calls matrix3Hi

If bit 0 is set in the low byte of a matrix entry, then it is negative.
.matrix3Hi EQUB &FA, &34, &00 EQUB &34, &FA, &00 EQUB &00, &00, &FF
Name: matrix4Hi [Show more] Type: Variable Category: Maths Summary: The high bytes of matrix 4
Context: See this variable on its own page References: This variable is used as follows: * ArtificialHorizon calls matrix4Hi * SetMatrices calls matrix4Hi

If bit 0 is set in the low byte of a matrix entry, then it is negative.
.matrix4Hi EQUB &FA, &32, &0D EQUB &34, &F2, &3F EQUB &00, &40, &F7
Name: CheckFlyingSkills (Part 2 of 2) [Show more] Type: Subroutine Category: Scoring Summary: Perform finer checks to see if we are flying under the bridge or along the main street of the town Deep dive: Flying skills
Context: See this subroutine on its own page References: No direct references to this subroutine in this source file
.skil4 BPL skil5 \ If A is negative, flip the bits, so A contains the EOR #&FF \ absolute value of the distance along the z-axis .skil5 CMP #5 \ If the high byte of the distance is 5 or more, then BCS skil2 \ we are too far away from the bridge or town to warrant \ further checks, so jump to skil2 to return from the \ subroutine \ If we get here then we are within a distance of &0500 \ from the place we need to check, in both the x-axis \ and z-axis, so now we need to check exactly where we \ are CPY #2 \ If Y = 2, then we are checking against the suspension BEQ skil7 \ bridge, so jump to skil7 \ If we get here then we are checking where we are \ compared to the town LDA #12 \ If we are inside skill zone 12, jump to skil8 to crash JSR CheckBridgeAndTown \ the plane BCS skil8 LDA #15 \ If we are inside skill zone 15, jump to skil8 to crash JSR CheckBridgeAndTown \ the plane BCS skil8 LDA #9 \ If we are inside skill zone 9, jump to skil8 to crash JSR CheckBridgeAndTown \ the plane BCS skil8 LDA #18 \ If we are outside skill zone 18, jump to slip9 to add JSR CheckBridgeAndTown \ any awarded points to our score BCC skil9 \ If we get here then we are: \ \ * Outside skill zone 12 \ * Outside skill zone 15 \ * Outside skill zone 9 \ * Inside skill zone 18 \ \ This means we are flying along the main street of the \ town, so we have earned ourselves some points, to be \ awarded when we exit skill zone 18 LDA #&20 \ Set A = &20 so we award 200 points for flying down \ main street while upside down LDX row25_block13_1 \ If there is a line at the bottom of the artificial BNE skil10 \ horizon indicator, then the plane is upside down, so \ jump to skil10 to bank these points in pointsToAward \ and return from the subroutine .skil6 LDA #&10 \ Set A = &10 so we award 100 points for flying down \ main street the right way up BNE skil10 \ Jump to skil10 to bank these points in pointsToAward \ and return from the subroutine .skil7 \ If we get here then we are checking where we are \ compared to the suspension bridge LDA #6 \ If we are outside skill zone 6, jump to slip9 to add JSR CheckBridgeAndTown \ any awarded points to our score BCC skil9 LDA #3 \ If we are inside skill zone 3, jump to slip9 to add JSR CheckBridgeAndTown \ any awarded points to our score BCS skil9 LDA #0 \ If we are outside skill zone 0, jump to skil8 to crash JSR CheckBridgeAndTown \ the plane BCC skil8 \ If we get here then we are: \ \ * Inside skill zone 6 \ * Outside skill zone 3 \ * Inside skill zone 0 \ \ This means we are flying under the bridge, so we have \ earned ourselves some points, to be awarded when we \ exit skill zone 6 or enter skill zone 3 LDX row25_block13_1 \ If there is a line at the bottom of the artificial BNE skil6 \ horizon indicator, then the plane is upside down, so \ jump to skil6 to award 100 points for flying under the \ bridge upside down LDA #5 \ Set A = 5 so we award 50 points for flying under the \ bridge the right way up BNE skil10 \ Jump to skil10 to bank these points in pointsToAward \ and return from the subroutine .skil8 TSX \ Add four bytes to the top of the stack, so they can be TXA \ stripped away in Crash routine, along with the two SEC \ bytes currently on the stack SBC #4 TAX TXS JMP Crash \ Jump to the Crash routine as we have just crashed .skil9 LDA pointsToAward \ We get here when we are outside the skill zone, so BEQ skil11 \ check whether we have any points to award, and if \ not, jump to skil11 to return from the subroutine \ If we get here then we have earned ourselves some \ points and have exited the skill zone, so it's time \ to award those points and give a celebratory beep LDX #0 \ Add A * 10 points to the score and make a beep by JSR ScorePoints \ calling ScorePoints with (X A) = (0 A) = A LDA #0 \ Set A = 0 so we set pointsToAward to zero below, so \ we don't award any more points until they are earned .skil10 STA pointsToAward \ Store any points we've earned in pointsToAward, so \ they get awarded when we leave the skill zone (or, if \ A = 0, this does nothing) .skil11 RTS \ Return from the subroutine EQUB &20 \ This byte appears to be unused
Name: scaleFactor [Show more] Type: Variable Category: Flight model Summary: Scale factors for the flight forces (in signed powers of 2) Deep dive: The flight model
Context: See this variable on its own page References: This variable is used as follows: * ScaleFlightForces calls scaleFactor
.scaleFactor EQUB &00 \ xMoments is scaled by 2^0 = 1 EQUB &FE \ yMoments is scaled by 2^-2 = 1/4 EQUB &FF \ zMoments is scaled by 2^-1 = 1/2 EQUB &01 \ xLiftDrag is scaled by 2^1 = 2 EQUB &04 \ yLiftDrag is scaled by 2^4 = 16 EQUB &00 \ zLiftDrag is scaled by 2^0 = 1 EQUB &FB \ zSlipMoment is scaled by 2^-5 = 1/32 EQUB &02 \ yFlapsLift is scaled by 2^2 = 4 EQUB &33 \ Unused EQUB &3A \ Unused EQUB &FF \ xControls is scaled by 2^-1 = 1/2 EQUB &FE \ yControls is scaled by 2^-2 = 1/4 EQUB &FE \ zControls is scaled by 2^-2 = 1/4 EQUB &23, &31, &38 \ These bytes appear to be unused
Name: lowNibble [Show more] Type: Variable Category: Maths Summary: Lookup table for the low nibble of a value Deep dive: Times tables and nibble arithmetic
Context: See this variable on its own page References: This variable is used as follows: * DivideScaled calls lowNibble * Multiply4x16 calls lowNibble * Multiply8x8 calls lowNibble

In the table below, lowNibble,X contains the low nibble of X: X AND %00001111
.lowNibble FOR I%, 0, 255 EQUB I% AND %00001111 NEXT
Name: xObjectLo [Show more] Type: Variable Category: 3D geometry Summary: Low byte of the x-coordinate for an object Deep dive: 3D objects Placing objects on the map
The low byte of the x-coordinate for the object with ID X is at xObjectLo,X. This is called XALO in the original source code.
.xObjectLo EQUB &23 \ Object 0 has dynamic coordinates EQUB &66 \ Object 1 has fixed coordinates (&C666, &0000, &445C) EQUB &18 \ Object 2 has fixed coordinates (&4B18, &0000, &8666) EQUB &DD \ Object 3 has fixed coordinates (&45DD, &0000, &6333) EQUB &33 \ Object 4 has fixed coordinates (&5333, &0000, &C000) EQUB &EF \ Object 5 has fixed coordinates (&8EEF, &0000, &C111) EQUB &00 \ Object 6 is a group, coords are in x/zGroupObjectHi EQUB &00 \ Object 7 is a group, coords are in x/zGroupObjectHi EQUB &00 \ Object 8 is a group, coords are in x/zGroupObjectHi EQUB &00 \ Object 9 is a group, coords are in x/zGroupObjectHi EQUB &4F \ Object 10 is unused EQUB &58 \ Object 11 is unused EQUB &00 \ Object 12 has dynamic coordinates EQUB &00 \ Object 13 has dynamic coordinates EQUB &00 \ Object 14 has dynamic coordinates EQUB &00 \ Object 15 has dynamic coordinates EQUB &EE \ Object 16 has fixed coordinates (&8EEE, &0000, &EAA6) EQUB &AA \ Object 17 has fixed coordinates (&EAAA, &0000, &D552) EQUB &88 \ Object 18 has fixed coordinates (&0888, &0000, &6555) EQUB &55 \ Object 19 has fixed coordinates (&2555, &0000, &E999) EQUB &77 \ Object 20 has fixed coordinates (&5777, &0000, &E555) EQUB &33 \ Object 21 has fixed coordinates (&1333, &0000, &ABBC) EQUB &77 \ Object 22 has fixed coordinates (&8777, &0000, &9556) EQUB &33 \ Object 23 has fixed coordinates (&E333, &0000, &9999) EQUB &66 \ Object 24 has fixed coordinates (&8666, &0000, &4DF8) EQUB &88 \ Object 25 has fixed coordinates (&D888, &0000, &0777) EQUB &DE \ Object 26 has fixed coordinates (&EDDE, &0000, &4111) EQUB &66 \ Object 27 has fixed coordinates (&4666, &0000, &2CCD) EQUB &66 \ Object 28 has fixed coordinates (&8666, &0000, &0555) EQUB &55 \ Object 29 has fixed coordinates (&B555, &0000, &7444) EQUB &00 \ Object 30 has dynamic coordinates EQUB &00 \ Object 31 has dynamic coordinates EQUB &00 \ Object 32 has dynamic coordinates EQUB &00 \ Object 33 has dynamic coordinates EQUB &40 \ Object 34 has fixed coordinates (&0440, &0000, &0340) EQUB &23 \ Object 35 is unused EQUB &33 \ Object 36 is unused EQUB &31 \ Object 37 is unused EQUB &3A \ Object 38 is unused EQUB &42 \ Object 39 is unused
Name: yObjectLo [Show more] Type: Variable Category: 3D geometry Summary: Low byte of the y-coordinate for an object Deep dive: 3D objects Placing objects on the map
Context: See this variable on its own page References: This variable is used as follows: * AddPointToObject calls yObjectLo * AlienInAcornsville calls yObjectLo * SetObjectCoords (Part 8 of 11) calls yObjectLo * SetObjectToOrigin calls yObjectLo

The low byte of the y-coordinate for the object with ID X is at yObjectLo,X.
.yObjectLo EQUB &43 \ Object 0 has dynamic coordinates EQUB &00 \ Object 1 has fixed coordinates (&C666, &0000, &445C) EQUB &00 \ Object 2 has fixed coordinates (&4B18, &0000, &8666) EQUB &00 \ Object 3 has fixed coordinates (&45DD, &0000, &6333) EQUB &00 \ Object 4 has fixed coordinates (&5333, &0000, &C000) EQUB &00 \ Object 5 has fixed coordinates (&8EEF, &0000, &C111) EQUB &00 \ Object 6 is a group, coords are in x/zGroupObjectHi EQUB &00 \ Object 7 is a group, coords are in x/zGroupObjectHi EQUB &00 \ Object 8 is a group, coords are in x/zGroupObjectHi EQUB &00 \ Object 9 is a group, coords are in x/zGroupObjectHi EQUB &27 \ Object 10 is unused EQUB &20 \ Object 11 is unused EQUB &00 \ Object 12 has dynamic coordinates EQUB &00 \ Object 13 has dynamic coordinates EQUB &00 \ Object 14 has dynamic coordinates EQUB &00 \ Object 15 has dynamic coordinates EQUB &00 \ Object 16 has fixed coordinates (&8EEE, &0000, &EAA6) EQUB &00 \ Object 17 has fixed coordinates (&EAAA, &0000, &D552) EQUB &00 \ Object 18 has fixed coordinates (&0888, &0000, &6555) EQUB &00 \ Object 19 has fixed coordinates (&2555, &0000, &E999) EQUB &00 \ Object 20 has fixed coordinates (&5777, &0000, &E555) EQUB &00 \ Object 21 has fixed coordinates (&1333, &0000, &ABBC) EQUB &00 \ Object 22 has fixed coordinates (&8777, &0000, &9556) EQUB &00 \ Object 23 has fixed coordinates (&E333, &0000, &9999) EQUB &00 \ Object 24 has fixed coordinates (&8666, &0000, &4DF8) EQUB &00 \ Object 25 has fixed coordinates (&D888, &0000, &0777) EQUB &00 \ Object 26 has fixed coordinates (&EDDE, &0000, &4111) EQUB &00 \ Object 27 has fixed coordinates (&4666, &0000, &2CCD) EQUB &00 \ Object 28 has fixed coordinates (&8666, &0000, &0555) EQUB &00 \ Object 29 has fixed coordinates (&B555, &0000, &7444) EQUB &00 \ Object 30 has dynamic coordinates EQUB &00 \ Object 31 has dynamic coordinates EQUB &00 \ Object 32 has dynamic coordinates EQUB &00 \ Object 33 has dynamic coordinates EQUB &00 \ Object 34 has fixed coordinates (&0440, &0000, &0340) EQUB &23 \ Object 35 is unused EQUB &34 \ Object 36 is unused EQUB &3A \ Object 37 is unused EQUB &4A \ Object 38 is unused EQUB &4D \ Object 39 is unused
Name: zObjectLo [Show more] Type: Variable Category: 3D geometry Summary: Low byte of the z-coordinate for an object Deep dive: 3D objects Placing objects on the map
Context: See this variable on its own page References: This variable is used as follows: * AddPointToObject calls zObjectLo * CheckPlaneOnRunway calls zObjectLo * SetObjectCoords (Part 8 of 11) calls zObjectLo * SetObjectToOrigin calls zObjectLo

The low byte of the y-coordinate for the object with ID X is at zObjectLo,X.
.zObjectLo EQUB &50 \ Object 0 has dynamic coordinates EQUB &5C \ Object 1 has fixed coordinates (&C666, &0000, &445C) EQUB &66 \ Object 2 has fixed coordinates (&4B18, &0000, &8666) EQUB &33 \ Object 3 has fixed coordinates (&45DD, &0000, &6333) EQUB &00 \ Object 4 has fixed coordinates (&5333, &0000, &C000) EQUB &11 \ Object 5 has fixed coordinates (&8EEF, &0000, &C111) EQUB &00 \ Object 6 is a group, coords are in x/zGroupObjectHi EQUB &00 \ Object 7 is a group, coords are in x/zGroupObjectHi EQUB &00 \ Object 8 is a group, coords are in x/zGroupObjectHi EQUB &00 \ Object 9 is a group, coords are in x/zGroupObjectHi EQUB &2E \ Object 10 is unused EQUB &73 \ Object 11 is unused EQUB &00 \ Object 12 has dynamic coordinates EQUB &00 \ Object 13 has dynamic coordinates EQUB &00 \ Object 14 has dynamic coordinates EQUB &00 \ Object 15 has dynamic coordinates EQUB &A6 \ Object 16 has fixed coordinates (&8EEE, &0000, &EAA6) EQUB &52 \ Object 17 has fixed coordinates (&EAAA, &0000, &D552) EQUB &55 \ Object 18 has fixed coordinates (&0888, &0000, &6555) EQUB &99 \ Object 19 has fixed coordinates (&2555, &0000, &E999) EQUB &55 \ Object 20 has fixed coordinates (&5777, &0000, &E555) EQUB &BC \ Object 21 has fixed coordinates (&1333, &0000, &ABBC) EQUB &56 \ Object 22 has fixed coordinates (&8777, &0000, &9556) EQUB &99 \ Object 23 has fixed coordinates (&E333, &0000, &9999) EQUB &F8 \ Object 24 has fixed coordinates (&8666, &0000, &4DF8) EQUB &77 \ Object 25 has fixed coordinates (&D888, &0000, &0777) EQUB &11 \ Object 26 has fixed coordinates (&EDDE, &0000, &4111) EQUB &CD \ Object 27 has fixed coordinates (&4666, &0000, &2CCD) EQUB &55 \ Object 28 has fixed coordinates (&8666, &0000, &0555) EQUB &44 \ Object 29 has fixed coordinates (&B555, &0000, &7444) EQUB &00 \ Object 30 has dynamic coordinates EQUB &00 \ Object 31 has dynamic coordinates EQUB &00 \ Object 32 has dynamic coordinates EQUB &00 \ Object 33 has dynamic coordinates EQUB &40 \ Object 34 has fixed coordinates (&0440, &0000, &0340) EQUB &20 \ Object 35 is unused EQUB &20 \ Object 36 is unused EQUB &20 \ Object 37 is unused EQUB &20 \ Object 38 is unused EQUB &20 \ Object 39 is unused
Name: xObjectHi [Show more] Type: Variable Category: 3D geometry Summary: High byte of the x-coordinate for an object Deep dive: 3D objects Placing objects on the map
The high byte of the x-coordinate for the object with ID X is at xObjectHi,X. This is called XAHI in the original source code.
.xObjectHi EQUB &20 \ Object 0 has dynamic coordinates EQUB &C6 \ Object 1 has fixed coordinates (&C666, &0000, &445C) EQUB &4B \ Object 2 has fixed coordinates (&4B18, &0000, &8666) EQUB &45 \ Object 3 has fixed coordinates (&45DD, &0000, &6333) EQUB &53 \ Object 4 has fixed coordinates (&5333, &0000, &C000) EQUB &8E \ Object 5 has fixed coordinates (&8EEF, &0000, &C111) EQUB &00 \ Object 6 is a group, coords are in x/zGroupObjectHi EQUB &00 \ Object 7 is a group, coords are in x/zGroupObjectHi EQUB &00 \ Object 8 is a group, coords are in x/zGroupObjectHi EQUB &00 \ Object 9 is a group, coords are in x/zGroupObjectHi EQUB &4D \ Object 10 is unused EQUB &50 \ Object 11 is unused EQUB &00 \ Object 12 has dynamic coordinates EQUB &00 \ Object 13 has dynamic coordinates EQUB &00 \ Object 14 has dynamic coordinates EQUB &00 \ Object 15 has dynamic coordinates EQUB &8E \ Object 16 has fixed coordinates (&8EEE, &0000, &EAA6) EQUB &EA \ Object 17 has fixed coordinates (&EAAA, &0000, &D552) EQUB &08 \ Object 18 has fixed coordinates (&0888, &0000, &6555) EQUB &25 \ Object 19 has fixed coordinates (&2555, &0000, &E999) EQUB &57 \ Object 20 has fixed coordinates (&5777, &0000, &E555) EQUB &13 \ Object 21 has fixed coordinates (&1333, &0000, &ABBC) EQUB &87 \ Object 22 has fixed coordinates (&8777, &0000, &9556) EQUB &E3 \ Object 23 has fixed coordinates (&E333, &0000, &9999) EQUB &86 \ Object 24 has fixed coordinates (&8666, &0000, &4DF8) EQUB &D8 \ Object 25 has fixed coordinates (&D888, &0000, &0777) EQUB &ED \ Object 26 has fixed coordinates (&EDDE, &0000, &4111) EQUB &46 \ Object 27 has fixed coordinates (&4666, &0000, &2CCD) EQUB &86 \ Object 28 has fixed coordinates (&8666, &0000, &0555) EQUB &B5 \ Object 29 has fixed coordinates (&B555, &0000, &7444) EQUB &00 \ Object 30 has dynamic coordinates EQUB &00 \ Object 31 has dynamic coordinates EQUB &00 \ Object 32 has dynamic coordinates EQUB &00 \ Object 33 has dynamic coordinates EQUB &04 \ Object 34 has fixed coordinates (&0440, &0000, &0340) EQUB &41 \ Object 35 is unused EQUB &20 \ Object 36 is unused EQUB &53 \ Object 37 is unused EQUB &49 \ Object 38 is unused EQUB &5A \ Object 39 is unused
Name: yObjectHi [Show more] Type: Variable Category: 3D geometry Summary: High byte of the y-coordinate for an object Deep dive: 3D objects Placing objects on the map
Context: See this variable on its own page References: This variable is used as follows: * AddPointToObject calls yObjectHi * AlienInAcornsville calls yObjectHi * SetObjectCoords (Part 2 of 11) calls yObjectHi * SetObjectCoords (Part 8 of 11) calls yObjectHi * SetObjectToOrigin calls yObjectHi

The high byte of the y-coordinate for the object with ID X is at yObjectHi,X.
.yObjectHi EQUB &45 \ Object 0 has dynamic coordinates EQUB &00 \ Object 1 has fixed coordinates (&C666, &0000, &445C) EQUB &00 \ Object 2 has fixed coordinates (&4B18, &0000, &8666) EQUB &00 \ Object 3 has fixed coordinates (&45DD, &0000, &6333) EQUB &00 \ Object 4 has fixed coordinates (&5333, &0000, &C000) EQUB &00 \ Object 5 has fixed coordinates (&8EEF, &0000, &C111) EQUB &00 \ Object 6 is a group, coords are in x/zGroupObjectHi EQUB &00 \ Object 7 is a group, coords are in x/zGroupObjectHi EQUB &00 \ Object 8 is a group, coords are in x/zGroupObjectHi EQUB &00 \ Object 9 is a group, coords are in x/zGroupObjectHi EQUB &0D \ Object 10 is unused EQUB &07 \ Object 11 is unused EQUB &00 \ Object 12 has dynamic coordinates EQUB &00 \ Object 13 has dynamic coordinates EQUB &00 \ Object 14 has dynamic coordinates EQUB &00 \ Object 15 has dynamic coordinates EQUB &00 \ Object 16 has fixed coordinates (&8EEE, &0000, &EAA6) EQUB &00 \ Object 17 has fixed coordinates (&EAAA, &0000, &D552) EQUB &00 \ Object 18 has fixed coordinates (&0888, &0000, &6555) EQUB &00 \ Object 19 has fixed coordinates (&2555, &0000, &E999) EQUB &00 \ Object 20 has fixed coordinates (&5777, &0000, &E555) EQUB &00 \ Object 21 has fixed coordinates (&1333, &0000, &ABBC) EQUB &00 \ Object 22 has fixed coordinates (&8777, &0000, &9556) EQUB &00 \ Object 23 has fixed coordinates (&E333, &0000, &9999) EQUB &00 \ Object 24 has fixed coordinates (&8666, &0000, &4DF8) EQUB &00 \ Object 25 has fixed coordinates (&D888, &0000, &0777) EQUB &00 \ Object 26 has fixed coordinates (&EDDE, &0000, &4111) EQUB &00 \ Object 27 has fixed coordinates (&4666, &0000, &2CCD) EQUB &00 \ Object 28 has fixed coordinates (&8666, &0000, &0555) EQUB &00 \ Object 29 has fixed coordinates (&B555, &0000, &7444) EQUB &00 \ Object 30 has dynamic coordinates EQUB &00 \ Object 31 has dynamic coordinates EQUB &00 \ Object 32 has dynamic coordinates EQUB &00 \ Object 33 has dynamic coordinates EQUB &00 \ Object 34 has fixed coordinates (&0440, &0000, &0340) EQUB &38 \ Object 35 is unused EQUB &0D \ Object 36 is unused EQUB &07 \ Object 37 is unused EQUB &76 \ Object 38 is unused EQUB &1A \ Object 39 is unused
Name: zObjectHi [Show more] Type: Variable Category: 3D geometry Summary: High byte of the z-coordinate for an object Deep dive: 3D objects Placing objects on the map
The high byte of the z-coordinate for the object with ID X is at zObjectHi,X.
.zObjectHi EQUB &2E \ Object 0 has dynamic coordinates EQUB &44 \ Object 1 has fixed coordinates (&C666, &0000, &445C) EQUB &86 \ Object 2 has fixed coordinates (&4B18, &0000, &8666) EQUB &63 \ Object 3 has fixed coordinates (&45DD, &0000, &6333) EQUB &C0 \ Object 4 has fixed coordinates (&5333, &0000, &C000) EQUB &C1 \ Object 5 has fixed coordinates (&8EEF, &0000, &C111) EQUB &00 \ Object 6 is a group, coords are in x/zGroupObjectHi EQUB &00 \ Object 7 is a group, coords are in x/zGroupObjectHi EQUB &00 \ Object 8 is a group, coords are in x/zGroupObjectHi EQUB &00 \ Object 9 is a group, coords are in x/zGroupObjectHi EQUB &5A \ Object 10 is unused EQUB &52 \ Object 11 is unused EQUB &00 \ Object 12 has dynamic coordinates EQUB &00 \ Object 13 has dynamic coordinates EQUB &00 \ Object 14 has dynamic coordinates EQUB &00 \ Object 15 has dynamic coordinates EQUB &EA \ Object 16 has fixed coordinates (&8EEE, &0000, &EAA6) EQUB &D5 \ Object 17 has fixed coordinates (&EAAA, &0000, &D552) EQUB &65 \ Object 18 has fixed coordinates (&0888, &0000, &6555) EQUB &E9 \ Object 19 has fixed coordinates (&2555, &0000, &E999) EQUB &E5 \ Object 20 has fixed coordinates (&5777, &0000, &E555) EQUB &AB \ Object 21 has fixed coordinates (&1333, &0000, &ABBC) EQUB &95 \ Object 22 has fixed coordinates (&8777, &0000, &9556) EQUB &99 \ Object 23 has fixed coordinates (&E333, &0000, &9999) EQUB &4D \ Object 24 has fixed coordinates (&8666, &0000, &4DF8) EQUB &07 \ Object 25 has fixed coordinates (&D888, &0000, &0777) EQUB &41 \ Object 26 has fixed coordinates (&EDDE, &0000, &4111) EQUB &2C \ Object 27 has fixed coordinates (&4666, &0000, &2CCD) EQUB &05 \ Object 28 has fixed coordinates (&8666, &0000, &0555) EQUB &74 \ Object 29 has fixed coordinates (&B555, &0000, &7444) EQUB &00 \ Object 30 has dynamic coordinates EQUB &00 \ Object 31 has dynamic coordinates EQUB &00 \ Object 32 has dynamic coordinates EQUB &00 \ Object 33 has dynamic coordinates EQUB &03 \ Object 34 has fixed coordinates (&0440, &0000, &0340) EQUB &41 \ Object 35 is unused EQUB &3A \ Object 36 is unused EQUB &4C \ Object 37 is unused EQUB &53 \ Object 38 is unused EQUB &52 \ Object 39 is unused
Name: randomNumbers [Show more] Type: Variable Category: Utility routines Summary: A list for keeping a list of random numbers Deep dive: Random numbers
Context: See this variable on its own page References: This variable is used as follows: * ApplyFlightModel (Part 3 of 7) calls randomNumbers * ExplodeAlien calls randomNumbers * NextRandomNumber calls randomNumbers * ResetVariables calls randomNumbers * SetRandomNumber calls randomNumbers

This list contains a pointer to the current position in the first byte. This is stored as an offset in the range 0 to 10, and is incremented every time we stash a new random number in the list, wrapping round to the start when it reaches the end. The pointer gets zeroed in the ResetVariables routine.
.randomNumbers EQUB &FB, &FD, &FF, &F9, &FB, &F8, &FB, &FA EQUB &53, &52, &FF, &FE, &01, &41, &58, &0D
Name: highNibble [Show more] Type: Variable Category: Maths Summary: Lookup table for the high nibble of a value Deep dive: Times tables and nibble arithmetic
Context: See this variable on its own page References: This variable is used as follows: * DivideScaled calls highNibble * Multiply8x8 calls highNibble

In the table below, highNibble,X contains the high nibble of X: X AND %11110000
.highNibble FOR I%, 0, 255 EQUB I% AND %11110000 NEXT
Name: objectPoints [Show more] Type: Variable Category: 3D geometry Summary: Sequences of related points that together make up objects Deep dive: 3D objects
Context: See this variable on its own page References: This variable is used as follows: * ProcessLine (Part 3 of 7) calls objectPoints
.objectPoints EQUB 9 + 40 \ Object 1: 0 -> 9 EQUB 1 \ Object 1: 1 EQUB 1 \ Object 1: 2 EQUB 1 \ Object 1: 3 EQUB 1 \ Object 1: 4 EQUB 1 \ Object 1: 5 EQUB 1 \ Object 1: 6 EQUB 1 \ Object 1: 7 EQUB 1 \ Object 1: 8 EQUB 1 \ Object 1: 9 EQUB 1 \ Object 1: 10 EQUB 1 \ Object 1: 11 EQUB 1 \ Object 1: 12 EQUB 1 \ Object 1: 13 EQUB 1 \ Object 1: 14 EQUB 1 \ Object 1: 15 EQUB 1 \ Object 1: 16 EQUB 1 \ Object 1: 17 EQUB 1 \ Object 1: 18 EQUB 1 \ Object 1: 19 EQUB 1 \ Object 1: 20 EQUB 34 \ Object 34: 21 EQUB 34 \ Object 34: 22 EQUB 24 + 40 \ Object 34: 23 -> 24 EQUB 34 \ Object 34: 24 EQUB 22 + 40 \ Object 34: 25 -> 22 EQUB 23 + 40 \ Object 34: 26 -> 23 -> 24 EQUB 24 + 40 \ Object 34: 27 -> 24 EQUB 34 \ Object 34: 28 EQUB 22 + 40 \ Object 34: 29 -> 22 EQUB 0 \ Object 0: 30 EQUB 0 \ Object 0: 31 EQUB 22 + 40 \ Object 34: 32 -> 22 EQUB 34 \ Object 34: 33 EQUB 29 + 40 \ Object 34: 34 -> 29 -> 22 EQUB 8 \ Object 8: 35 EQUB 8 \ Object 8: 36 EQUB 40 + 40 \ Object 34: 37 -> 40 -> 39 EQUB 37 + 40 \ Object 34: 38 -> 37 -> 40 -> 39 EQUB 34 \ Object 34: 39 EQUB 39 + 40 \ Object 34: 40 -> 39 EQUB 2 \ Object 2: 41 EQUB 49 + 40 \ Object 2: 42 -> 49 -> 51 EQUB 50 + 40 \ Object 2: 43 -> 50 -> 52 -> 51 EQUB 48 + 40 \ Object 2: 44 -> 48 -> 52 -> 51 EQUB 2 \ Object 2: 45 EQUB 51 + 40 \ Object 2: 46 -> 51 EQUB 52 + 40 \ Object 2: 47 -> 52 -> 51 EQUB 52 + 40 \ Object 2: 48 -> 52 -> 51 EQUB 51 + 40 \ Object 2: 49 -> 51 EQUB 52 + 40 \ Object 2: 50 -> 52 -> 51 EQUB 2 \ Object 2: 51 EQUB 51 + 40 \ Object 2: 52 -> 51 EQUB 49 + 40 \ Object 2: 53 -> 49 -> 51 EQUB 50 + 40 \ Object 2: 54 -> 50 -> 52 -> 51 EQUB 51 + 40 \ Object 2: 55 -> 51 EQUB 52 + 40 \ Object 2: 56 -> 52 -> 51 EQUB 59 + 40 \ Object 3: 57 -> 59 EQUB 59 + 40 \ Object 3: 58 -> 59 EQUB 3 \ Object 3: 59 EQUB 59 + 40 \ Object 3: 60 -> 59 EQUB 59 + 40 \ Object 3: 61 -> 59 EQUB 2 \ Object 2: 62 EQUB 2 \ Object 2: 63 EQUB 2 \ Object 2: 64 EQUB 64 + 40 \ Object 2: 65 -> 64 EQUB 2 \ Object 2: 66 EQUB 66 + 40 \ Object 2: 67 -> 66 EQUB 66 + 40 \ Object 2: 68 -> 66 EQUB 68 + 40 \ Object 2: 69 -> 68 -> 66 EQUB 4 \ Object 4: 70 EQUB 4 \ Object 4: 71 EQUB 73 + 40 \ Object 4: 72 -> 73 EQUB 4 \ Object 4: 73 EQUB 75 + 40 \ Object 4: 74 -> 75 EQUB 4 \ Object 4: 75 EQUB 77 + 40 \ Object 4: 76 -> 77 -> 118 EQUB 118 + 40 \ Object 4: 77 -> 118 EQUB 79 + 40 \ Object 4: 78 -> 79 -> 77 -> 118 EQUB 77 + 40 \ Object 4: 79 -> 77 -> 118 EQUB 7 \ Object 7: 80 EQUB 80 + 40 \ Object 7: 81 -> 80 EQUB 7 \ Object 7: 82 EQUB 7 \ Object 7: 83 EQUB 7 \ Object 7: 84 EQUB 80 + 40 \ Object 7: 85 -> 80 EQUB 39 + 40 \ Object 34: 86 -> 39 EQUB 86 + 40 \ Object 34: 87 -> 86 -> 39 EQUB 86 + 40 \ Object 34: 88 -> 86 -> 39 EQUB 6 \ Object 6: 89 EQUB 89 + 40 \ Object 6: 90 -> 89 EQUB 6 \ Object 6: 91 EQUB 6 \ Object 6: 92 EQUB 6 \ Object 6: 93 EQUB 89 + 40 \ Object 6: 94 -> 89 EQUB 12 \ Object 12: 95 EQUB 13 \ Object 13: 96 EQUB 14 \ Object 14: 97 EQUB 15 \ Object 15: 98 EQUB 87 + 40 \ Object 34: 99 -> 87 -> 86 -> 39 EQUB 5 \ Object 5: 100 EQUB 5 \ Object 5: 101 EQUB 103 + 40 \ Object 5: 102 -> 103 EQUB 5 \ Object 5: 103 EQUB 5 \ Object 5: 104 EQUB 104 + 40 \ Object 5: 105 -> 104 EQUB 5 \ Object 5: 106 EQUB 106 + 40 \ Object 5: 107 -> 106 EQUB 9 \ Object 9: 108 EQUB 106 + 40 \ Object 5: 109 -> 106 EQUB 109 + 40 \ Object 5: 110 -> 109 -> 106 EQUB 3 \ Object 3: 111 EQUB 113 + 40 \ Object 3: 112 -> 113 EQUB 3 \ Object 3: 113 EQUB 3 \ Object 3: 114 EQUB 3 \ Object 3: 115 EQUB 3 \ Object 3: 116 EQUB 4 \ Object 4: 117 EQUB 4 \ Object 4: 118 EQUB 66 + 40 \ Object 2: 119 -> 66 EQUB 119 + 40 \ Object 2: 120 -> 119 -> 66 EQUB 19 \ Object 19: 121 EQUB 19 \ Object 19: 122 EQUB 19 \ Object 19: 123 EQUB 22 \ Object 22: 124 EQUB 20 \ Object 20: 125 EQUB 20 \ Object 20: 126 EQUB 20 \ Object 20: 127 EQUB 16 \ Object 16: 128 EQUB 16 \ Object 16: 129 EQUB 16 \ Object 16: 130 EQUB 16 \ Object 16: 131 EQUB 17 \ Object 17: 132 EQUB 17 \ Object 17: 133 EQUB 17 \ Object 17: 134 EQUB 17 \ Object 17: 135 EQUB 23 \ Object 23: 136 EQUB 23 \ Object 23: 137 EQUB 23 \ Object 23: 138 EQUB 23 \ Object 23: 139 EQUB 22 \ Object 22: 140 EQUB 22 \ Object 22: 141 EQUB 22 \ Object 22: 142 EQUB 22 \ Object 22: 143 EQUB 21 \ Object 21: 144 EQUB 21 \ Object 21: 145 EQUB 21 \ Object 21: 146 EQUB 21 \ Object 21: 147 EQUB 21 \ Object 21: 148 EQUB 29 \ Object 29: 149 EQUB 29 \ Object 29: 150 EQUB 29 \ Object 29: 151 EQUB 29 \ Object 29: 152 EQUB 24 \ Object 24: 153 EQUB 24 \ Object 24: 154 EQUB 24 \ Object 24: 155 EQUB 24 \ Object 24: 156 EQUB 160 + 40 \ Object 18: 157 -> 160 EQUB 159 + 40 \ Object 18: 158 -> 159 EQUB 18 \ Object 18: 159 EQUB 18 \ Object 18: 160 EQUB 27 \ Object 27: 161 EQUB 27 \ Object 27: 162 EQUB 27 \ Object 27: 163 EQUB 27 \ Object 27: 164 EQUB 28 \ Object 28: 165 EQUB 28 \ Object 28: 166 EQUB 28 \ Object 28: 167 EQUB 28 \ Object 28: 168 EQUB 25 \ Object 25: 169 EQUB 25 \ Object 25: 170 EQUB 25 \ Object 25: 171 EQUB 25 \ Object 25: 172 EQUB 26 \ Object 26: 173 EQUB 26 \ Object 26: 174 EQUB 26 \ Object 26: 175 EQUB 26 \ Object 26: 176 EQUB 19 \ Object 19: 177 EQUB 181 + 40 \ Object 30: 178 -> 181 EQUB 181 + 40 \ Object 30: 179 -> 181 EQUB 181 + 40 \ Object 30: 180 -> 181 EQUB 30 \ Object 30: 181 EQUB 31 \ Object 31: 182 EQUB 182 + 40 \ Object 31: 183 -> 182 EQUB 182 + 40 \ Object 31: 184 -> 182 EQUB 182 + 40 \ Object 31: 185 -> 182 EQUB 182 + 40 \ Object 31: 186 -> 182 EQUB 32 \ Object 32: 187 EQUB 187 + 40 \ Object 32: 188 -> 187 EQUB 187 + 40 \ Object 32: 189 -> 187 EQUB 187 + 40 \ Object 32: 190 -> 187 EQUB 187 + 40 \ Object 32: 191 -> 187 EQUB 33 \ Object 33: 192 EQUB 199 + 40 \ Object 33: 193 -> 199 -> 192 EQUB 197 + 40 \ Object 33: 194 -> 197 -> 192 EQUB 199 + 40 \ Object 33: 195 -> 199 -> 192 EQUB 199 + 40 \ Object 33: 196 -> 199 -> 192 EQUB 192 + 40 \ Object 33: 197 -> 192 EQUB 197 + 40 \ Object 33: 198 -> 197 -> 192 EQUB 192 + 40 \ Object 33: 199 -> 192 EQUB 199 + 40 \ Object 33: 200 -> 199 -> 192 EQUB 39 + 40 \ Object 34: 201 -> 39 EQUB 40 + 40 \ Object 34: 202 -> 40 -> 39 EQUB 205 + 40 \ Object 34: 203 -> 205 -> 40 -> 39 EQUB 203 + 40 \ Object 34: 204 -> 203 -> 205 -> 40 -> 39 EQUB 40 + 40 \ Object 34: 205 -> 40 -> 39 EQUB 205 + 40 \ Object 34: 206 -> 205 -> 40 -> 39 EQUB 205 + 40 \ Object 34: 207 -> 205 -> 40 -> 39 EQUB 206 + 40 \ Object 34: 208 -> 206 -> 205 -> 40 -> 39 EQUB 203 + 40 \ Object 34: 209 -> 203 -> 205 -> 40 -> 39 EQUB 204 + 40 \ Object 34: 210 -> 204 -> 203 -> 205 -> 40 -> 39 EQUB 8 \ Object 8: 211 EQUB 8 \ Object 8: 212 EQUB 9 \ Object 9: 213 EQUB 108 + 40 \ Object 9: 214 -> 108 EQUB 9 \ Object 9: 215
Name: ReadJoystick [Show more] Type: Subroutine Category: Keyboard Summary: Read the joystick axes and fire button and update the aileron, elevator and fire key values accordingly
Context: See this subroutine on its own page References: This subroutine is called as follows: * UpdateFlightModel (Part 1 of 4) calls ReadJoystick
.ReadJoystick LDA row29_block20_4 \ If the screen byte at row 29, block 20, pixel row 4 is BEQ rjoy1 \ zero (i.e. black) then the joystick is not enabled, so \ jump to rjoy1 to return from the subroutine LDX #1 \ Set aileronPosition to the value from ADC channel 1, JSR ReadADCChannel \ the joystick's x-position, inverted and clipped to the STA aileronPosition \ range -118 to +116 LDX #2 \ Set elevatorPosition to the value from ADC channel 2, JSR ReadADCChannel \ the joystick's y-position, inverted and clipped to the STA elevatorPosition \ range -118 to +116 LDX #0 \ Call OSBYTE with A = 128 and X = 0 to read the status LDA #128 \ of the joystick's fire button into X JSR OSBYTE TXA \ If bit 0 of X is zero, the fire button is not being AND #1 \ pressed, so jump to rjoy1 BEQ rjoy1 LDA #8 \ The fire button is being pressed, so update the key STA keyLoggerLo+5 \ logger at keyLoggerLo+5, which corresponds to the \ flaps and fire keys. We set the value to 8, the value \ from keyTable2Lo for the fire button .rjoy1 RTS \ Return from the subroutine EQUB &36
Name: divisionLo [Show more] Type: Variable Category: Maths Summary: Division lookup table
Context: See this variable on its own page References: This variable is used as follows: * ProjectPoint (Part 2 of 3) calls divisionLo * ScaleUp calls divisionLo

Bits 0 to 2 of divisionLo,X contain int(log2(X)) i.e. if divisionLo,X = n, then X fits into n + 1 binary digits Bits 3 to 7 contain the low byte of the division lookup, with bits 0 to 2 zeroed, and the high byte coming from divisionHi.
.divisionLo EQUB %00000000 \ Index 0 = 00000 ( 0) and 000 (0) EQUB %00000000 \ Index 1 = 00000 ( 0) and 000 (0) EQUB %00000001 \ Index 2 = 00000 ( 0) and 001 (1) EQUB %00001001 \ Index 3 = 00001 ( 1) and 001 (1) EQUB %00010010 \ Index 4 = 00010 ( 2) and 010 (2) EQUB %00011010 \ Index 5 = 00011 ( 3) and 010 (2) EQUB %00100010 \ Index 6 = 00100 ( 4) and 010 (2) EQUB %00110010 \ Index 7 = 00110 ( 6) and 010 (2) EQUB %01000011 \ Index 8 = 01000 ( 8) and 011 (3) EQUB %01010011 \ Index 9 = 01010 (10) and 011 (3) EQUB %01100011 \ Index 10 = 01100 (12) and 011 (3) EQUB %01111011 \ Index 11 = 01111 (15) and 011 (3) EQUB %10001011 \ Index 12 = 10001 (17) and 011 (3) EQUB %10100011 \ Index 13 = 10100 (20) and 011 (3) EQUB %10111011 \ Index 14 = 10111 (23) and 011 (3) EQUB %11011011 \ Index 15 = 11011 (27) and 011 (3) EQUB %11110100 \ Index 16 = 11110 (30) and 100 (4) EQUB %00010100 \ Index 17 = 00010 ( 2) and 100 (4) EQUB %00110100 \ Index 18 = 00110 ( 6) and 100 (4) EQUB %01010100 \ Index 19 = 01010 (10) and 100 (4) EQUB %01110100 \ Index 20 = 01110 (14) and 100 (4) EQUB %10011100 \ Index 21 = 10011 (19) and 100 (4) EQUB %11000100 \ Index 22 = 11000 (24) and 100 (4) EQUB %11101100 \ Index 23 = 11101 (29) and 100 (4) EQUB %00010100 \ Index 24 = 00010 ( 2) and 100 (4) EQUB %00111100 \ Index 25 = 00111 ( 7) and 100 (4) EQUB %01101100 \ Index 26 = 01101 (13) and 100 (4) EQUB %10010100 \ Index 27 = 10010 (18) and 100 (4) EQUB %11000100 \ Index 28 = 11000 (24) and 100 (4) EQUB %11110100 \ Index 29 = 11110 (30) and 100 (4) EQUB %00101100 \ Index 30 = 00101 ( 5) and 100 (4) EQUB %01011100 \ Index 31 = 01011 (11) and 100 (4) EQUB %10010101 \ Index 32 = 10010 (18) and 101 (5) EQUB %11001101 \ Index 33 = 11001 (25) and 101 (5) EQUB %00000101 \ Index 34 = 00000 ( 0) and 101 (5) EQUB %00111101 \ Index 35 = 00111 ( 7) and 101 (5) EQUB %01110101 \ Index 36 = 01110 (14) and 101 (5) EQUB %10110101 \ Index 37 = 10110 (22) and 101 (5) EQUB %11101101 \ Index 38 = 11101 (29) and 101 (5) EQUB %00101101 \ Index 39 = 00101 ( 5) and 101 (5) EQUB %01101101 \ Index 40 = 01101 (13) and 101 (5) EQUB %10101101 \ Index 41 = 10101 (21) and 101 (5) EQUB %11101101 \ Index 42 = 11101 (29) and 101 (5) EQUB %00110101 \ Index 43 = 00110 ( 6) and 101 (5) EQUB %01111101 \ Index 44 = 01111 (15) and 101 (5) EQUB %10111101 \ Index 45 = 10111 (23) and 101 (5) EQUB %00000101 \ Index 46 = 00000 ( 0) and 101 (5) EQUB %01001101 \ Index 47 = 01001 ( 9) and 101 (5) EQUB %10011101 \ Index 48 = 10011 (19) and 101 (5) EQUB %11100101 \ Index 49 = 11100 (28) and 101 (5) EQUB %00101101 \ Index 50 = 00101 ( 5) and 101 (5) EQUB %01111101 \ Index 51 = 01111 (15) and 101 (5) EQUB %11001101 \ Index 52 = 11001 (25) and 101 (5) EQUB %00011101 \ Index 53 = 00011 ( 3) and 101 (5) EQUB %01101101 \ Index 54 = 01101 (13) and 101 (5) EQUB %10111101 \ Index 55 = 10111 (23) and 101 (5) EQUB %00010101 \ Index 56 = 00010 ( 2) and 101 (5) EQUB %01100101 \ Index 57 = 01100 (12) and 101 (5) EQUB %10111101 \ Index 58 = 10111 (23) and 101 (5) EQUB %00010101 \ Index 59 = 00010 ( 2) and 101 (5) EQUB %01101101 \ Index 60 = 01101 (13) and 101 (5) EQUB %11000101 \ Index 61 = 11000 (24) and 101 (5) EQUB %00011101 \ Index 62 = 00011 ( 3) and 101 (5) EQUB %01110101 \ Index 63 = 01110 (14) and 101 (5) EQUB %11010110 \ Index 64 = 11010 (26) and 110 (6) EQUB %00101110 \ Index 65 = 00101 ( 5) and 110 (6) EQUB %10001110 \ Index 66 = 10001 (17) and 110 (6) EQUB %11101110 \ Index 67 = 11101 (29) and 110 (6) EQUB %01001110 \ Index 68 = 01001 ( 9) and 110 (6) EQUB %10101110 \ Index 69 = 10101 (21) and 110 (6) EQUB %00001110 \ Index 70 = 00001 ( 1) and 110 (6) EQUB %01101110 \ Index 71 = 01101 (13) and 110 (6) EQUB %11010110 \ Index 72 = 11010 (26) and 110 (6) EQUB %00110110 \ Index 73 = 00110 ( 6) and 110 (6) EQUB %10011110 \ Index 74 = 10011 (19) and 110 (6) EQUB %00000110 \ Index 75 = 00000 ( 0) and 110 (6) EQUB %01101110 \ Index 76 = 01101 (13) and 110 (6) EQUB %11010110 \ Index 77 = 11010 (26) and 110 (6) EQUB %00111110 \ Index 78 = 00111 ( 7) and 110 (6) EQUB %10100110 \ Index 79 = 10100 (20) and 110 (6) EQUB %00010110 \ Index 80 = 00010 ( 2) and 110 (6) EQUB %01111110 \ Index 81 = 01111 (15) and 110 (6) EQUB %11101110 \ Index 82 = 11101 (29) and 110 (6) EQUB %01010110 \ Index 83 = 01010 (10) and 110 (6) EQUB %11000110 \ Index 84 = 11000 (24) and 110 (6) EQUB %00110110 \ Index 85 = 00110 ( 6) and 110 (6) EQUB %10100110 \ Index 86 = 10100 (20) and 110 (6) EQUB %00010110 \ Index 87 = 00010 ( 2) and 110 (6) EQUB %10000110 \ Index 88 = 10000 (16) and 110 (6) EQUB %11111110 \ Index 89 = 11111 (31) and 110 (6) EQUB %01101110 \ Index 90 = 01101 (13) and 110 (6) EQUB %11100110 \ Index 91 = 11100 (28) and 110 (6) EQUB %01010110 \ Index 92 = 01010 (10) and 110 (6) EQUB %11001110 \ Index 93 = 11001 (25) and 110 (6) EQUB %01000110 \ Index 94 = 01000 ( 8) and 110 (6) EQUB %10111110 \ Index 95 = 10111 (23) and 110 (6) EQUB %00110110 \ Index 96 = 00110 ( 6) and 110 (6) EQUB %10101110 \ Index 97 = 10101 (21) and 110 (6) EQUB %00100110 \ Index 98 = 00100 ( 4) and 110 (6) EQUB %10011110 \ Index 99 = 10011 (19) and 110 (6) EQUB %00011110 \ Index 100 = 00011 ( 3) and 110 (6) EQUB %10010110 \ Index 101 = 10010 (18) and 110 (6) EQUB %00010110 \ Index 102 = 00010 ( 2) and 110 (6) EQUB %10010110 \ Index 103 = 10010 (18) and 110 (6) EQUB %00001110 \ Index 104 = 00001 ( 1) and 110 (6) EQUB %10001110 \ Index 105 = 10001 (17) and 110 (6) EQUB %00001110 \ Index 106 = 00001 ( 1) and 110 (6) EQUB %10001110 \ Index 107 = 10001 (17) and 110 (6) EQUB %00001110 \ Index 108 = 00001 ( 1) and 110 (6) EQUB %10010110 \ Index 109 = 10010 (18) and 110 (6) EQUB %00010110 \ Index 110 = 00010 ( 2) and 110 (6) EQUB %10010110 \ Index 111 = 10010 (18) and 110 (6) EQUB %00011110 \ Index 112 = 00011 ( 3) and 110 (6) EQUB %10011110 \ Index 113 = 10011 (19) and 110 (6) EQUB %00100110 \ Index 114 = 00100 ( 4) and 110 (6) EQUB %10101110 \ Index 115 = 10101 (21) and 110 (6) EQUB %00110110 \ Index 116 = 00110 ( 6) and 110 (6) EQUB %10110110 \ Index 117 = 10110 (22) and 110 (6) EQUB %00111110 \ Index 118 = 00111 ( 7) and 110 (6) EQUB %11000110 \ Index 119 = 11000 (24) and 110 (6) EQUB %01010110 \ Index 120 = 01010 (10) and 110 (6) EQUB %11011110 \ Index 121 = 11011 (27) and 110 (6) EQUB %01100110 \ Index 122 = 01100 (12) and 110 (6) EQUB %11101110 \ Index 123 = 11101 (29) and 110 (6) EQUB %01111110 \ Index 124 = 01111 (15) and 110 (6) EQUB %00000110 \ Index 125 = 00000 ( 0) and 110 (6) EQUB %10010110 \ Index 126 = 10010 (18) and 110 (6) EQUB %00100110 \ Index 127 = 00100 ( 4) and 110 (6) EQUB %10101111 \ Index 128 = 10101 (21) and 111 (7) EQUB %00111111 \ Index 129 = 00111 ( 7) and 111 (7) EQUB %11001111 \ Index 130 = 11001 (25) and 111 (7) EQUB %01011111 \ Index 131 = 01011 (11) and 111 (7) EQUB %11101111 \ Index 132 = 11101 (29) and 111 (7) EQUB %01111111 \ Index 133 = 01111 (15) and 111 (7) EQUB %00001111 \ Index 134 = 00001 ( 1) and 111 (7) EQUB %10100111 \ Index 135 = 10100 (20) and 111 (7) EQUB %00110111 \ Index 136 = 00110 ( 6) and 111 (7) EQUB %11000111 \ Index 137 = 11000 (24) and 111 (7) EQUB %01011111 \ Index 138 = 01011 (11) and 111 (7) EQUB %11101111 \ Index 139 = 11101 (29) and 111 (7) EQUB %10000111 \ Index 140 = 10000 (16) and 111 (7) EQUB %00010111 \ Index 141 = 00010 ( 2) and 111 (7) EQUB %10101111 \ Index 142 = 10101 (21) and 111 (7) EQUB %01000111 \ Index 143 = 01000 ( 8) and 111 (7) EQUB %11011111 \ Index 144 = 11011 (27) and 111 (7) EQUB %01110111 \ Index 145 = 01110 (14) and 111 (7) EQUB %00001111 \ Index 146 = 00001 ( 1) and 111 (7) EQUB %10100111 \ Index 147 = 10100 (20) and 111 (7) EQUB %00111111 \ Index 148 = 00111 ( 7) and 111 (7) EQUB %11010111 \ Index 149 = 11010 (26) and 111 (7) EQUB %01101111 \ Index 150 = 01101 (13) and 111 (7) EQUB %00001111 \ Index 151 = 00001 ( 1) and 111 (7) EQUB %10100111 \ Index 152 = 10100 (20) and 111 (7) EQUB %01000111 \ Index 153 = 01000 ( 8) and 111 (7) EQUB %11011111 \ Index 154 = 11011 (27) and 111 (7) EQUB %01111111 \ Index 155 = 01111 (15) and 111 (7) EQUB %00010111 \ Index 156 = 00010 ( 2) and 111 (7) EQUB %10110111 \ Index 157 = 10110 (22) and 111 (7) EQUB %01010111 \ Index 158 = 01010 (10) and 111 (7) EQUB %11101111 \ Index 159 = 11101 (29) and 111 (7) EQUB %10001111 \ Index 160 = 10001 (17) and 111 (7) EQUB %00101111 \ Index 161 = 00101 ( 5) and 111 (7) EQUB %11001111 \ Index 162 = 11001 (25) and 111 (7) EQUB %01101111 \ Index 163 = 01101 (13) and 111 (7) EQUB %00001111 \ Index 164 = 00001 ( 1) and 111 (7) EQUB %10101111 \ Index 165 = 10101 (21) and 111 (7) EQUB %01010111 \ Index 166 = 01010 (10) and 111 (7) EQUB %11110111 \ Index 167 = 11110 (30) and 111 (7) EQUB %10010111 \ Index 168 = 10010 (18) and 111 (7) EQUB %00110111 \ Index 169 = 00110 ( 6) and 111 (7) EQUB %11011111 \ Index 170 = 11011 (27) and 111 (7) EQUB %01111111 \ Index 171 = 01111 (15) and 111 (7) EQUB %00100111 \ Index 172 = 00100 ( 4) and 111 (7) EQUB %11000111 \ Index 173 = 11000 (24) and 111 (7) EQUB %01101111 \ Index 174 = 01101 (13) and 111 (7) EQUB %00010111 \ Index 175 = 00010 ( 2) and 111 (7) EQUB %10111111 \ Index 176 = 10111 (23) and 111 (7) EQUB %01011111 \ Index 177 = 01011 (11) and 111 (7) EQUB %00000111 \ Index 178 = 00000 ( 0) and 111 (7) EQUB %10101111 \ Index 179 = 10101 (21) and 111 (7) EQUB %01010111 \ Index 180 = 01010 (10) and 111 (7) EQUB %11111111 \ Index 181 = 11111 (31) and 111 (7) EQUB %10100111 \ Index 182 = 10100 (20) and 111 (7) EQUB %01001111 \ Index 183 = 01001 ( 9) and 111 (7) EQUB %11110111 \ Index 184 = 11110 (30) and 111 (7) EQUB %10011111 \ Index 185 = 10011 (19) and 111 (7) EQUB %01001111 \ Index 186 = 01001 ( 9) and 111 (7) EQUB %11110111 \ Index 187 = 11110 (30) and 111 (7) EQUB %10011111 \ Index 188 = 10011 (19) and 111 (7) EQUB %01001111 \ Index 189 = 01001 ( 9) and 111 (7) EQUB %11110111 \ Index 190 = 11110 (30) and 111 (7) EQUB %10100111 \ Index 191 = 10100 (20) and 111 (7) EQUB %01001111 \ Index 192 = 01001 ( 9) and 111 (7) EQUB %11111111 \ Index 193 = 11111 (31) and 111 (7) EQUB %10100111 \ Index 194 = 10100 (20) and 111 (7) EQUB %01010111 \ Index 195 = 01010 (10) and 111 (7) EQUB %00000111 \ Index 196 = 00000 ( 0) and 111 (7) EQUB %10101111 \ Index 197 = 10101 (21) and 111 (7) EQUB %01011111 \ Index 198 = 01011 (11) and 111 (7) EQUB %00001111 \ Index 199 = 00001 ( 1) and 111 (7) EQUB %10111111 \ Index 200 = 10111 (23) and 111 (7) EQUB %01101111 \ Index 201 = 01101 (13) and 111 (7) EQUB %00011111 \ Index 202 = 00011 ( 3) and 111 (7) EQUB %11001111 \ Index 203 = 11001 (25) and 111 (7) EQUB %01111111 \ Index 204 = 01111 (15) and 111 (7) EQUB %00101111 \ Index 205 = 00101 ( 5) and 111 (7) EQUB %11011111 \ Index 206 = 11011 (27) and 111 (7) EQUB %10001111 \ Index 207 = 10001 (17) and 111 (7) EQUB %01000111 \ Index 208 = 01000 ( 8) and 111 (7) EQUB %11110111 \ Index 209 = 11110 (30) and 111 (7) EQUB %10100111 \ Index 210 = 10100 (20) and 111 (7) EQUB %01011111 \ Index 211 = 01011 (11) and 111 (7) EQUB %00001111 \ Index 212 = 00001 ( 1) and 111 (7) EQUB %11000111 \ Index 213 = 11000 (24) and 111 (7) EQUB %01110111 \ Index 214 = 01110 (14) and 111 (7) EQUB %00101111 \ Index 215 = 00101 ( 5) and 111 (7) EQUB %11011111 \ Index 216 = 11011 (27) and 111 (7) EQUB %10010111 \ Index 217 = 10010 (18) and 111 (7) EQUB %01000111 \ Index 218 = 01000 ( 8) and 111 (7) EQUB %11111111 \ Index 219 = 11111 (31) and 111 (7) EQUB %10110111 \ Index 220 = 10110 (22) and 111 (7) EQUB %01101111 \ Index 221 = 01101 (13) and 111 (7) EQUB %00011111 \ Index 222 = 00011 ( 3) and 111 (7) EQUB %11010111 \ Index 223 = 11010 (26) and 111 (7) EQUB %10001111 \ Index 224 = 10001 (17) and 111 (7) EQUB %01000111 \ Index 225 = 01000 ( 8) and 111 (7) EQUB %11111111 \ Index 226 = 11111 (31) and 111 (7) EQUB %10110111 \ Index 227 = 10110 (22) and 111 (7) EQUB %01101111 \ Index 228 = 01101 (13) and 111 (7) EQUB %00100111 \ Index 229 = 00100 ( 4) and 111 (7) EQUB %11011111 \ Index 230 = 11011 (27) and 111 (7) EQUB %10010111 \ Index 231 = 10010 (18) and 111 (7) EQUB %01001111 \ Index 232 = 01001 ( 9) and 111 (7) EQUB %00001111 \ Index 233 = 00001 ( 1) and 111 (7) EQUB %11000111 \ Index 234 = 11000 (24) and 111 (7) EQUB %01111111 \ Index 235 = 01111 (15) and 111 (7) EQUB %00111111 \ Index 236 = 00111 ( 7) and 111 (7) EQUB %11110111 \ Index 237 = 11110 (30) and 111 (7) EQUB %10101111 \ Index 238 = 10101 (21) and 111 (7) EQUB %01101111 \ Index 239 = 01101 (13) and 111 (7) EQUB %00100111 \ Index 240 = 00100 ( 4) and 111 (7) EQUB %11100111 \ Index 241 = 11100 (28) and 111 (7) EQUB %10011111 \ Index 242 = 10011 (19) and 111 (7) EQUB %01011111 \ Index 243 = 01011 (11) and 111 (7) EQUB %00010111 \ Index 244 = 00010 ( 2) and 111 (7) EQUB %11010111 \ Index 245 = 11010 (26) and 111 (7) EQUB %10010111 \ Index 246 = 10010 (18) and 111 (7) EQUB %01001111 \ Index 247 = 01001 ( 9) and 111 (7) EQUB %00001111 \ Index 248 = 00001 ( 1) and 111 (7) EQUB %11001111 \ Index 249 = 11001 (25) and 111 (7) EQUB %10001111 \ Index 250 = 10001 (17) and 111 (7) EQUB %01000111 \ Index 251 = 01000 ( 8) and 111 (7) EQUB %00000111 \ Index 252 = 00000 ( 0) and 111 (7) EQUB %11000111 \ Index 253 = 11000 (24) and 111 (7) EQUB %10000111 \ Index 254 = 10000 (16) and 111 (7) EQUB %01000111 \ Index 255 = 01000 ( 8) and 111 (7)
Name: yLookupLo [Show more] Type: Variable Category: Graphics Summary: Lookup table for converting pixel y-coordinate to low byte of screen address Deep dive: Converting pixel coordinates to screen addresses
Context: See this variable on its own page References: This variable is used as follows: * DrawCanopyLine (Part 1 of 9) calls yLookupLo * DrawVectorLine (Part 3 of 3) calls yLookupLo
.yLookupLo FOR I%, 19, 0, -1 EQUB LO(&5800 + (I% * &138)) NEXT FOR I%, 31, 20, -1 EQUB LO(&5800 + (I% * &138)) NEXT
Name: yLookupHi [Show more] Type: Variable Category: Graphics Summary: Lookup table for converting pixel y-coordinate to high byte of screen address Deep dive: Converting pixel coordinates to screen addresses
Context: See this variable on its own page References: This variable is used as follows: * DrawCanopyLine (Part 1 of 9) calls yLookupHi * DrawVectorLine (Part 3 of 3) calls yLookupHi
.yLookupHi FOR I%, 19, 0, -1 EQUB HI(&5800 + (I% * &138)) NEXT FOR I%, 31, 20, -1 EQUB HI(&5800 + (I% * &138)) NEXT
Name: DrawCanopyCorners [Show more] Type: Subroutine Category: Graphics Summary: Draw the diagonal corners at the top of the canopy
Context: See this subroutine on its own page References: This subroutine is called as follows: * Crash calls DrawCanopyCorners * DrawGunSights calls DrawCanopyCorners

This routine draws the diagonal lines in the top corners of the canopy. They are drawn so that the area outside the canopy is set to black, while anything that is already on-screen inside the canopy is left alone. The diagonals are made up of four squares, each of them one pixel wide and two pixels high, so the overall size of each diagonal is one character block (four pixels wide and eight pixels high).
.DrawCanopyCorners LDX #7 \ Set X as a pixel row counter, starting with the last \ pixel row, so we draw the diagonals upwards from the \ bottom row of the character block to the top row of \ the character block LDA #%01110111 \ Set P to a pixel mask to clear the first pixel STA P LDA #%10001000 \ Set Q to a pixel byte with a white first pixel STA Q LDA #%11101110 \ Set R to a pixel mask to clear the last pixel STA R LDA #%00010001 \ Set S to a pixel byte with a white last pixel STA S .corn1 LDY #1 \ Each square in the diagonal is two pixels high, so we \ set a counter in Y to count the height of each square .corn2 LDA row1_block1_0,X \ We want to update the X-th pixel row in the character \ block in the top-left corner of the canopy, so fetch \ the current contents of the row AND P \ Clear the pixel pointed to by P, which on the first \ iteration round the loop will be the first pixel ORA Q \ Set the pixel pointed to by Q, which on the first \ iteration round the loop will be the first pixel STA row1_block1_0,X \ Store the updated pixel row back in screen memory, so \ on the first iteration round the loop, we just set the \ first pixel in the bottom pixel row, which is the \ bottom-left pixel of the diagonal in the top-left \ corner of the canopy LDA row1_block39_0,X \ We want to update the X-th pixel row in the character \ block in the top-right corner of the canopy, so fetch \ the current contents of the row AND R \ Clear the pixel pointed to by R, which on the first \ iteration round the loop will be the last pixel ORA S \ Set the pixel pointed to by S, which on the first \ iteration round the loop will be the last pixel STA row1_block39_0,X \ Store the updated pixel row back in screen memory, so \ on the first iteration round the loop, we just set the \ last pixel in the bottom pixel row, which is the \ bottom-right pixel of the diagonal in the top-right \ corner of the canopy DEX \ Decrement the pixel row counter so we move up to the \ pixel row above DEY \ Decrement the square counter in Y, and if it is still BPL corn2 \ positive, loop back to corn2 to draw the second row in \ this square, so we end up drawing the same pattern on \ two consecutive pixel rows, making each square two \ pixels high and one pixel wide LDA R \ We now shift each nibble in R to the left by one, so ASL A \ it moves through the following values: AND R \ STA R \ %11101110 -> %11001100 -> %10001000 -> %00000000 \ \ so with each step up the diagonal, the mask clears \ the area to the right of the diagonal to black \ \ We do this as follows (taking the case of the first \ transformation above): \ \ R = R AND (R << 1) \ = %11101110 AND (%11101110 << 1) \ = %11101110 AND %11011100 \ = %11001100 LDA P \ We now shift each nibble in P to the right by one, so LSR A \ it moves through the following values: AND P \ STA P \ %01110111 -> %00110011 -> %00010001 -> %00000000 \ \ so with each step up the diagonal, the mask clears \ the area to the left of the diagonal to black \ \ We do this as follows (taking the case of the first \ transformation above): \ \ P = P AND (P >> 1) \ = %01110111 AND (%01110111 >> 1) \ = %01110111 AND %00111011 \ = %00110011 ASL S \ We also shift S to the left, so the pixel we draw in \ the top-right diagonal moves to the left as we move up \ the diagonal, like this: \ \ %00010001 -> %00100010 -> %01000100 -> %10001000 \ \ or, putting them in the order on-screen with two rows \ per square, we get a top-right diagonal like this: \ \ %10001000 x... \ %10001000 x... \ %01000100 .x.. \ %01000100 .x.. \ %00100010 ..x. \ %00100010 ..x. \ %00010001 ...x \ %00010001 ...x LSR Q \ Finally, we shift Q to the right, so the pixel we draw \ in the top-left diagonal moves to the right as we move \ up the diagonal, like this: \ \ %10001000 -> %01000100 -> %00100010 -> %00010001 \ \ or, putting them in the order on-screen with two rows \ per square, we get a top-left diagonal like this: \ \ %00010001 ...x \ %00010001 ...x \ %00100010 ..x. \ %00100010 ..x. \ %01000100 .x.. \ %01000100 .x.. \ %10001000 x... \ %10001000 x... CPX #255 \ Loop back until we have drawn all eight rows in the BNE corn1 \ diagonal, at which point we will have decremented X \ from 0 to 255 RTS \ Return from the subroutine
Name: RemoveScore [Show more] Type: Subroutine Category: Scoring Summary: Remove the score display from the screen
Context: See this subroutine on its own page References: This subroutine is called as follows: * MainLoop (Part 14 of 15) calls RemoveScore
.RemoveScore LDY #HI(row3_block1_0) \ Set (Y X) to the screen address for row 3, block 1 LDX #LO(row3_block1_0) LDA #8 \ Set R = 19, so we clear 8 character rows STA R LDA #0 \ Set X = 0 so we clear the canopy to black JSR FillCanopyRows \ Fill the 8 screen rows with black, avoiding the canopy \ edges and removing the score display from the screen RTS \ Return from the subroutine EQUB &20, &20 \ These bytes appear to be unused. They actually contain EQUB &20, &4C \ snippets of the original source code EQUB &44, &41 EQUB &26, &38 EQUB &36, &3A EQUB &43, &4C EQUB &43, &3A EQUB &41
Name: lineBufferV [Show more] Type: Variable Category: Drawing lines Summary: Line buffer storage for the line direction (V) Deep dive: Source code clues hidden in the game binary Line buffers
Context: See this variable on its own page References: This variable is used as follows: * DrawClippedLine (Part 6 of 6) calls lineBufferV * EraseCanopyLines calls lineBufferV

This table stores information about lines that are drawn on-screen, so they can be quickly erased without having to spend precious time recalculating the line coordinates. The information is stored when a line is drawn by the DrawClippedLine routine, and is read by the EraseCanopyLines routine when the line is erased. We can buffer up to 96 lines, with 48 in each of the two line buffers, so the maximum number of lines on screen at any one time is 48 lines out of the 193 lines defined in the world.
.lineBufferV EQUB &A2, &07, &A9, &77, &85, &70, &A9, &88 EQUB &85, &71, &A9, &EE, &85, &72, &A9, &11 EQUB &85, &73, &A0, &01, &BD, &40, &59, &25 EQUB &70, &05, &71, &9D, &40, &59, &BD, &68 EQUB &5A, &25, &72, &05, &73, &9D, &68, &5A EQUB &CA, &88, &10, &E8, &46, &72, &46, &73 EQUB &46, &70, &46, &71, &E0, &FF, &D0, &DA EQUB &60, &A0, &5B, &A2, &C0, &A9, &08, &85 EQUB &72, &A9, &00, &20, &AB, &2E, &60, &10 EQUB &0F, &2E, &53, &54, &49, &50, &20, &4C EQUB &44, &58, &23, &32, &0D, &09, &1A, &2A EQUB &2E, &73, &74, &69, &31, &20, &4C, &44
Name: zPointHi [Show more] Type: Variable Category: 3D geometry Summary: High byte of the z-coordinate for a point Deep dive: Lines and points
The high byte of the z-coordinate for the point with ID X is at zPointHi,X. The coordinate is stored as a 16-bit value (zPointHi zPointLo). The initial contents of the variable is just workspace noise and is ignored. It actually contains snippets of the original source code.
.zPointHi EQUB &41, &20, &58, &41, &4C, &4F, &2C, &59 EQUB &3A, &43, &4C, &43, &3A, &41, &44, &43 EQUB &20, &44, &54, &49, &50, &3A, &53, &54 EQUB &41, &26, &37, &37, &2C, &58, &0D, &09 EQUB &24, &23, &20, &20, &20, &20, &20, &20 EQUB &4C, &44, &41, &20, &58, &41, &48, &49 EQUB &2C, &59, &3A, &41, &44, &43, &23, &35 EQUB &3A, &53, &54, &41, &26, &37, &41, &2C EQUB &58, &0D, &09, &2E, &1C, &2E, &73, &74 EQUB &69, &34, &20, &54, &59, &41, &3A, &43 EQUB &4C, &43, &3A, &41, &44, &43, &23, &34 EQUB &30, &3A, &54, &41, &59, &0D, &09, &38 EQUB &1A, &2E, &73, &74, &69, &32, &20, &44 EQUB &45, &58, &3A, &42, &50, &4C, &20, &73 EQUB &74, &69, &33, &3A, &72, &74, &73, &0D EQUB &09, &42, &12, &2E, &73, &74, &69, &33 EQUB &20, &42, &45, &51, &20, &73, &74, &69 EQUB &31, &0D, &09, &4C, &1D, &20, &20, &20 EQUB &20, &20, &20, &4C, &44, &41, &20, &58 EQUB &41, &4C, &4F, &2C, &59, &3A, &53, &54 EQUB &41, &26, &37, &37, &2C, &58, &0D, &09 EQUB &56, &26, &20, &20, &20, &20, &20, &20 EQUB &4C, &44, &41, &20, &58, &41, &48, &49 EQUB &2C, &59, &3A, &53, &54, &41, &26, &37 EQUB &41, &2C, &58, &3A, &4A, &4D, &50, &20 EQUB &73, &74, &69, &34, &0D, &09, &60, &05 EQUB &20, &0D, &09, &6A, &0F, &2E, &48, &49 EQUB &54, &53, &20, &4C, &44, &58, &23, &32 EQUB &0D, &09, &74, &1C, &2E, &68, &69, &74 EQUB &32, &20, &54, &59, &41, &3A, &43, &4C EQUB &43, &3A, &41, &44, &43, &23, &34, &30 EQUB &3A, &54, &41, &59 .zLinearHi EQUB &0D \ High byte of point 252 (z-coordinate) \ \ Point 252 is used to store the sum of all the forces \ on the plane when calculating the flight model \ \ Stored as a 16-bit value (zLinearHi zLinearLo) .zGravityHi EQUB &09 \ High byte of point 253 (z-coordinate) \ \ Point 253 is used to store the gravity vector when \ calculating the flight model \ \ Stored as a 16-bit value (zGravityHi zGravityLo) .zTempPoint1Hi EQUB &7E \ High byte of point 254 (z-coordinate) \ \ Used as temporary point storage when rotating points \ in space \ \ Stored as a 16-bit value (zTempPoint1Hi zTempPoint1Lo) .zTempPoint2Hi EQUB &28 \ High byte of point 255 (z-coordinate) \ \ Used as temporary point storage when rotating points \ in space \ \ Stored as a 16-bit value (zTempPoint2Hi zTempPoint2Lo)
Name: xPointHi [Show more] Type: Variable Category: 3D geometry Summary: High byte of the x-coordinate for a point Deep dive: Lines and points
The high byte of the x-coordinate for the point with ID X is at xPointHi,X. The coordinate is stored as a 16-bit value (xPointHi xPointLo). The initial contents of the variable is just workspace noise and is ignored. It actually contains snippets of the original source code.
.xPointHi EQUB &20, &20, &20, &20, &20, &20, &4C, &44 EQUB &41, &20, &58, &41, &4C, &4F, &2C, &59 EQUB &3A, &53, &45, &43, &3A, &53, &42, &43 EQUB &26, &37, &37, &2C, &58, &3A, &53, &54 EQUB &41, &26, &37, &34, &0D, &09, &88, &26 EQUB &20, &20, &20, &20, &20, &20, &4C, &44 EQUB &41, &20, &58, &41, &48, &49, &2C, &59 EQUB &3A, &53, &42, &43, &26, &37, &41, &2C EQUB &58, &3A, &42, &4E, &45, &20, &68, &69 EQUB &74, &31, &0D, &09, &92, &22, &20, &20 EQUB &20, &20, &20, &20, &4C, &44, &41, &26 EQUB &37, &34, &3A, &43, &4D, &50, &26, &38 EQUB &30, &2C, &58, &3A, &42, &43, &53, &20 EQUB &68, &69, &74, &31, &0D, &09, &9C, &26 EQUB &20, &20, &20, &20, &20, &20, &44, &45 EQUB &58, &3A, &42, &50, &4C, &20, &68, &69 EQUB &74, &32, &3A, &4C, &44, &41, &20, &4F EQUB &42, &3A, &53, &54, &41, &20, &45, &50 EQUB &54, &52, &0D, &09, &A6, &19, &20, &20 EQUB &20, &20, &20, &20, &54, &53, &58, &3A EQUB &49, &4E, &58, &3A, &49, &4E, &58, &3A EQUB &54, &58, &53, &0D, &09, &A7, &1D, &20 EQUB &20, &20, &20, &20, &20, &4C, &44, &41 EQUB &23, &32, &37, &3A, &53, &54, &41, &20 EQUB &45, &50, &4C, &4F, &3A, &72, &74, &73 EQUB &0D, &09, &B0, &0D, &2E, &68, &69, &74 EQUB &31, &20, &72, &74, &73, &0D, &09, &BA EQUB &05, &20, &0D, &09, &C4, &1D, &2E, &41 EQUB &44, &49, &46, &20, &4C, &44, &41, &23 EQUB &30, &3A, &53, &54, &41, &26, &37, &30 EQUB &3A, &53, &54, &41, &26, &37, &32, &0D EQUB &09, &CE, &1C, &20
Name: xLinearHi [Show more] Type: Variable Category: 3D geometry Summary: High byte of point 252 (x-coordinate)
Context: See this variable on its own page References: This variable is used as follows: * ApplyFlightModel (Part 4 of 7) calls xLinearHi * ApplyFlightModel (Part 5 of 7) calls xLinearHi * ApplyTurnAndThrust (Part 2 of 2) calls xLinearHi
.xLinearHi EQUB &20 \ High byte of point 252 (x-coordinate) \ \ Point 252 is used to store the sum of all the forces \ on the plane when calculating the flight model \ \ Stored as a 16-bit value (xLinearHi xLinearLo)
Name: xGravityHi [Show more] Type: Variable Category: 3D geometry Summary: High byte of point 253 (x-coordinate)
Context: See this variable on its own page References: No direct references to this variable in this source file
.xGravityHi EQUB &20 \ High byte of point 253 (x-coordinate) \ \ Point 253 is used to store the gravity vector when \ calculating the flight model \ \ Stored as a 16-bit value (xGravityHi xGravityLo)
Name: xTempPoint1Hi [Show more] Type: Variable Category: 3D geometry Summary: High byte of point 254 (x-coordinate)
Context: See this variable on its own page References: No direct references to this variable in this source file
.xTempPoint1Hi EQUB &20 \ High byte of point 254 (x-coordinate) \ \ Used as temporary point storage when rotating points \ in space \ \ Stored as a 16-bit value (xTempPoint1Hi xTempPoint1Lo)
Name: xTempPoint2Hi [Show more] Type: Variable Category: 3D geometry Summary: High byte of point 255 (x-coordinate)
Context: See this variable on its own page References: No direct references to this variable in this source file
.xTempPoint2Hi EQUB &20 \ High byte of point 255 (z-coordinate) \ \ Used as temporary point storage when rotating points \ in space \ \ Stored as a 16-bit value (xTempPoint2Hi xTempPoint2Lo)
Name: CopyWorkToPoint [Show more] Type: Subroutine Category: Utility routines Summary: Copy a point from the variable workspace to the point tables Deep dive: Multi-byte variables
Arguments: X The low byte of the x-coordinate of the 16-bit workspace point to copy: * LO(xTurnHi) = (xTurn, yTurn, zTurn) * LO(xVelocityHi) = (xVelocity, yVelocity, zVelocity) * LO(xTemp2Lo) = (xTemp2, yTemp2, zTemp2) * LO(xPlaneLo) = (xPlane, yPlane, zPlane) Y The ID of the point to update in the point tables
.CopyWorkToPoint LDA xTurnHi,X \ Copy the X-th coordinate in the variable workspace to STA xPointLo,Y \ the Y-th point coordinate, starting with the low bytes LDA yTurnHi,X STA yPointLo,Y LDA zTurnHi,X STA zPointLo,Y LDA xTurnTop,X \ And then the high bytes STA xPointHi,Y LDA yTurnTop,X STA yPointHi,Y LDA zTurnTop,X STA zPointHi,Y RTS \ Return from the subroutine
Name: CopyPointToWork [Show more] Type: Subroutine Category: Utility routines Summary: Copy a point from the point tables to the variable workspace Deep dive: Multi-byte variables
Context: See this subroutine on its own page References: This subroutine is called as follows: * ApplyFlightModel (Part 2 of 7) calls CopyPointToWork * ApplyFlightModel (Part 6 of 7) calls CopyPointToWork * ExplodeAlien calls CopyPointToWork * ProcessRunwayLine (Part 4 of 5) calls CopyPointToWork

Arguments: Y The ID of the point to copy from the point tables X The low byte of the x-coordinate of the 16-bit workspace point to update: * LO(xVelocityPLo) = (xVelocityP, yVelocityP, zVelocityP) * LO(dxVelocityLo) = (dxVelocity, dyVelocity, dzVelocity) * LO(dxRotationLo) = (dxRotation, dyRotation, dzRotation) * LO(xTemp2Lo) = (xTemp2, yTemp2, zTemp2)
.CopyPointToWork LDA xPointLo,Y \ Copy the Y-th point coordinate to the X-th coordinate STA xTurnHi,X \ in the variable workspace, starting with the low bytes LDA yPointLo,Y STA yTurnHi,X LDA zPointLo,Y STA zTurnHi,X LDA xPointHi,Y \ And then the high bytes STA xTurnTop,X LDA yPointHi,Y STA yTurnTop,X LDA zPointHi,Y STA zTurnTop,X RTS \ Return from the subroutine
Name: SetPointToOrigin [Show more] Type: Subroutine Category: 3D geometry Summary: Set a point's coordinates to the origin at (0, 0, 0)
Context: See this subroutine on its own page References: This subroutine is called as follows: * ApplyFlightModel (Part 1 of 7) calls SetPointToOrigin * FireGuns calls SetPointToOrigin * ProcessHorizonLine calls SetPointToOrigin

Arguments: X The ID of the point to set to the origin
.SetPointToOrigin LDA #0 \ Set A = 0 so we set the X-th point to (0, 0, 0) below
Name: SetPoint [Show more] Type: Subroutine Category: 3D geometry Summary: Set a point's coordinates to the value (a, a, a)
Context: See this subroutine on its own page References: This subroutine is called as follows: * FireGuns calls SetPoint

Arguments: X The ID of the point to set to the origin A The value for all three coordinates
.SetPoint STA xPointLo,X \ Set the point's x-coordinate to A STA xPointHi,X STA yPointLo,X \ Set the point's y-coordinate to A STA yPointHi,X STA zPointLo,X \ Set the point's z-coordinate to A STA zPointHi,X RTS \ Return from the subroutine
Name: CheckLineDistance [Show more] Type: Subroutine Category: Visibility Summary: Check whether a point on a line is within the visible distance for the line
Context: See this subroutine on its own page References: This subroutine is called as follows: * ProcessLine (Part 7 of 7) calls CheckLineDistance * ProcessRunwayLine (Part 3 of 5) calls CheckLineDistance * UpdateBullets calls CheckLineDistance

Arguments: X The line ID of the line to check Y The point ID of the point to check Returns: A Contains the result as follows: * The current value of showLine if the point is close enough to be visible * 1 if the point is too far away to be visible
.CheckLineDistance LDA xPointHi,Y \ Set A to the high byte of the point's x-coordinate BPL dist1 \ If the x-coordinate is positive, skip the following \ instruction EOR #&FF \ Otherwise flip the x-coordinate so it's positive, so: \ \ A = |xPointHi| .dist1 CMP maxLineDistance,X \ If A >= this line's visible distance, then the point BCS dist4 \ is too far away to be seen in the x-axis, so jump to \ dist4 to return a "not visible" result LDA yPointHi,Y \ Set A to the high byte of the point's y-coordinate BPL dist2 \ If the y-coordinate is positive, skip the following \ instruction EOR #&FF \ Otherwise flip the y-coordinate so it's positive, so: \ \ A = |yPointHi| .dist2 CMP maxLineDistance,X \ If A >= this line's visible distance, then the point BCS dist4 \ is too far away to be seen in the y-axis, so jump to \ dist4 to return a "not visible" result LDA zPointHi,Y \ Set A to the high byte of the point's z-coordinate BPL dist3 \ If the z-coordinate is positive, skip the following \ instruction EOR #&FF \ Otherwise flip the z-coordinate so it's positive, so: \ \ A = |zPointHi| .dist3 CMP maxLineDistance,X \ If A < this line's visible distance, then the point BCC dist5 \ is close enough to be visible in the z-axis, so jump \ to dist5 to return an "is visible" result .dist4 \ If we get here then the point is too far away to be \ visible in at least one axis LDA #1 \ Set A = 1 as the return value for a "not visible" \ result RTS \ Return from the subroutine .dist5 LDA #0 \ The point is close enough to be visible, so return the ORA showLine \ current value of showLine (this could be achieved by a \ simple LDA showLine instruction, so perhaps this more \ convoluted approach is left over from a different \ version of the routine) RTS \ Return from the subroutine
Name: AddTempToPoint (Part 2 of 2) [Show more] Type: Subroutine Category: 3D geometry Summary: Check whether the vector addition overflowed and set the point's visibility accordingly
Context: See this subroutine on its own page References: No direct references to this subroutine in this source file
.addv1 \ This routine follows on directly from the part 1 of \ AddTempToPoint PHP \ Store the flags for the z-axis addition on the stack, \ so we can check them below LDX #2 \ We now want to check whether the vector addition \ overflowed in any direction, so set as a counter for \ the three axes .addv2 PLP \ Retrieve the flags from the stack, so we work through \ the flags from the z-, y- and x-axes in turn BVC addv3 \ If the C flag is clear then this addition didn't \ overflow, so jump to addv3 to move on to the next axis LDA #%01000000 \ The addition overflowed for this axis, so set bit 6 of STA showLine \ showLine so the line containing this point is marked \ as not being visible .addv3 DEX \ Decrement the counter to move on to the next axis BPL addv2 \ Loop back until we have checked the flags from all \ three additions RTS \ Return from the subroutine
Name: CheckBridgeAndTown [Show more] Type: Subroutine Category: Scoring Summary: Check whether we are safely flying under the bridge or down the main street in Acornsville Deep dive: Flying skills
Context: See this subroutine on its own page References: This subroutine is called as follows: * CheckFlyingSkills (Part 2 of 2) calls CheckBridgeAndTown

This routine checks whether the plane is within a certain distance of a specific coordinate from the (skillZoneHi skillZoneLo) table. If it is within the correct distance, then it is within the skill zone. The plane is said to be within a coordinate's skill zone if the following checks are all true. They start with larger checks and whittle it down to more fine-grained checks, as follows: * The vector from the skill zone coordinate to the plane is in a positive direction along each axis, i.e. the plane is somewhere inside a cuboid that has the skill zone coordinate at its bottom-left corner, nearest the origin (the origin is at ground level level in the bottom-left corner of the map). * The length of this vector along each axis is < 1024, so the plane is close enough to the skill zone coordinate for the next check to be done, i.e. within the rectangular cuboid described above, so the plane is within a cube of size 1024 in the skill zone coordinate's corner. * The length of the vector along each axis divided by 4 is within the margin for this skill zone (as defined in the skillZoneSize table), i.e. the plane is within an even smaller rectangular cuboid, again in the skill zone coordinate's corner, with dimensions given in the skillZoneSize table. In short, the plane is in the skill zone if it's inside a box whose dimensions are given in the skillZoneSize table, and whose corner nearest the origin is at the skill zone coordinate given in the skillZone table - in other words, the cuboid at the skill zone coordinate, with the dimensions in skillZoneSize. Or, even shorter, the plane is in a skill zone if this is true for all three axes: skill zone <= plane < skill zone + skill zone coordinate coordinate coordinate size * 4 Arguments: A Determines which skill zone coordinate to check: * 0, 3, 6 = under the suspension bridge * 9, 12, 15, 18 = along main street in Acornsville Returns: C flag The result: * 0 = We are currently flying outside this skill zone * 1 = We are currently flying inside this skill zone
.CheckBridgeAndTown STA Q \ Set Q to the skill zone to check LDY #2 \ We now work through the three axes (z, y, x), so set \ Y = 2 to act as an axis counter, going 2, 1, 0 .town1 TYA \ Set X = Q + Y CLC \ ADC Q \ so X is an index into the skill zone coordinate tables TAX \ for skill zone Q and axis Y SEC \ Set (A P) = plane coordinate - skillZone coordinate LDA xPlaneLo,Y \ SBC skillZoneLo,X \ starting with the high bytes STA P LDA xPlaneHi,Y \ And then the low bytes, so (A P) contains the vector SBC skillZoneHi,X \ from the skill zone coordinate to the plane, along \ axis Y BMI town2 \ If (A P) is negative, jump to town2 to clear the C \ flag LSR A \ Set (A P) = (A P) / 4 ROR P \ LSR A \ If the high byte in A is non-zero, then the original A BNE town2 \ must be less than %10000000000 (1024), so jump to ROR P \ town2 to clear the C flag LDA P \ If the low byte in P >= the margin for this skill zone CMP skillZoneSize,X \ in this axis, jump to town2 to clear the C flag BCS town2 DEY \ Decrement the axis counter to point to the next axis BPL town1 \ Loop back until we have checked all three axes \ If we get here, then: \ \ * The vector from the skill zone coordinate to the \ plane is in a positive direction along each axis \ \ * The length of the vector along each axis is < 1024 \ \ * The length of the vector along each axis divided \ by 4 is within the margin for this skill zone \ \ which means we are currently flying within this safe \ zone SEC \ Set the C flag to indicate we are currently flying \ within this skill zone RTS \ Return from the subroutine .town2 CLC \ Clear the C flag to indicate we are currently flying \ outside this skill zone RTS \ Return from the subroutine
Name: ScorePoints [Show more] Type: Subroutine Category: Scoring Summary: Increase the score and make a beep
Context: See this subroutine on its own page References: This subroutine is called as follows: * CheckFlyingSkills (Part 2 of 2) calls ScorePoints * MainLoop (Part 10 of 15) calls ScorePoints * UpdateAliens (Part 5 of 5) calls ScorePoints

Arguments: (X A) The number of points to add to the score (in BCD), divided by 10, so adding &15 will add 150 to the score
.ScorePoints JSR UpdateScore \ Increase the score by the number of points in A LDA #3 \ Make sound #3, a long, medium beep JSR MakeSound RTS \ Return from the subroutine
Name: UpdateScore [Show more] Type: Subroutine Category: Scoring Summary: Increase the score by a specified number of points
Context: See this subroutine on its own page References: This subroutine is called as follows: * ScoreHitPoints calls UpdateScore * ScorePoints calls UpdateScore

Arguments: (X A) The number of points to add to the score (in BCD)
.UpdateScore SED \ The scores are stored in BCD format, so first of all \ we set the D flag to switch arithmetic to decimal CLC \ We now want to add (X A) points to the score in ADC scoreLo \ (scoreHi scoreLo), so we start by adding the low bytes STA scoreLo \ and store the result in scoreLo TXA \ And then we add the high bytes and store the result ADC scoreHi \ in scoreHi STA scoreHi BCS scor1 \ If the addition overflowed (so the high byte is \ greater than &99), jump to scor1 to return from the \ subroutine CPX #&99 \ If X is not &99, jump to scor1 to return from the BNE scor1 \ subroutine (in practice, this routine is only ever \ called with X = 0, so we should never get here) LDA #0 \ If we get here then X = &99 and the addition of the STA scoreLo \ high bytes overflowed, so reset the score to zero STA scoreHi .scor1 CLD \ Clear the D flag to switch arithmetic back to normal RTS \ Return from the subroutine
Name: UpdateHighScore [Show more] Type: Subroutine Category: Scoring Summary: If this is a high score, update the high score
Context: See this subroutine on its own page References: This subroutine is called as follows: * TerminateGame calls UpdateHighScore
.UpdateHighScore LDA scoreHi \ If scoreHi < highScoreHi then we have not achieved a CMP highScoreHi \ high score, so jump to high3 to return from the BCC high3 \ subroutine BNE high1 \ If the high byte of the score and high score are not \ equal, then we know scoreHi > highScoreHi, so jump to \ high1 to update the high score LDA scoreLo \ If we get here then scoreHi = highScoreHi, so now we CMP highScoreLo \ check the low bytes. If ScoreHLo < highScoreLo then we BCC high3 \ have not achieved a high score, so jump to high3 to \ return from the subroutine .high1 LDA scoreLo \ (scoreHi scoreLo) > (highScoreHi highScoreLo), so this STA highScoreLo \ is a new high score, so update the 16-bit high score LDA scoreHi \ to the new score STA highScoreHi .high3 RTS \ Return from the subroutine
Name: DisplayScore [Show more] Type: Subroutine Category: Scoring Summary: Print the scores on-screen
Context: See this subroutine on its own page References: This subroutine is called as follows: * MainLoop (Part 14 of 15) calls DisplayScore * TerminateGame calls DisplayScore
.DisplayScore LDX #0 \ Print characters 0-15 from scoreText, which moves the LDY #16 \ text cursor to column 1, row 3 and prints JSR PrintScoreText \ "HIGH SCORE: " LDA highScoreHi \ Print the high byte of the high score JSR PrintScore LDA highScoreLo \ Print the low byte of the high score JSR PrintScore LDX #16 \ Print characters 16-19 from scoreText, which prints a LDY #20 \ "0" and moves the text cursor to column 3, row 10 JSR PrintScoreText LDX #8 \ Print characters 8-15 from scoreText, which prints LDY #16 \ "SCORE: " JSR PrintScoreText LDA scoreHi \ Print the high byte of the score JSR PrintScore LDA scoreLo \ Print the low byte of the score JSR PrintScore LDA #'0' \ Print a "0" JSR OSWRCH RTS \ Return from the subroutine
Name: PrintScore [Show more] Type: Subroutine Category: Scoring Summary: Print a score
Context: See this subroutine on its own page References: This subroutine is called as follows: * DisplayScore calls PrintScore

Arguments: A The byte to print, in BCD format (so each nibble is one decimal digit)
.PrintScore STA T \ Store the byte to print in T LSR A \ Set A to the high nibble of the score (bits 4-7) LSR A LSR A LSR A CLC \ Print the high nibble as a digit ADC #'0' JSR OSWRCH LDA T \ Set A to the low nibble of the score (bits 0-3) AND #%00001111 CLC \ Print the low nibble as a digit ADC #'0' JSR OSWRCH RTS \ Return from the subroutine
Name: PrintScoreText [Show more] Type: Subroutine Category: Scoring Summary: Print text when showing the scores on-screen
Context: See this subroutine on its own page References: This subroutine is called as follows: * DisplayScore calls PrintScoreText

Arguments: X Offset of the first character to print from scoreText Y Offset of the character that's just after the end of the string that we want to print from scoreText
.PrintScoreText STY T \ Set Y to the offset of the character that's just after \ the end of the string to print .prin1 LDA scoreText,X \ Print the X-th character from scoreText JSR OSWRCH INX \ Increment X to point to the next character CPX T \ Loop back to print the next character until we have BNE prin1 \ printed all of them RTS \ Return from the subroutine
Name: Crash [Show more] Type: Subroutine Category: Flight model Summary: Make a crashing sound, flash the canopy and start a new game
Context: See this subroutine on its own page References: This subroutine is called as follows: * CheckFlyingSkills (Part 2 of 2) calls Crash * ProcessLanding (Part 6 of 7) calls Crash
.Crash LDA #0 \ Turn off the engine sound JSR ToggleEngineSound LDA #5 \ Make sound #5, the sound of a crash JSR MakeSound LDX #%11111111 \ Fill the canopy with white, leaving the canopy edges JSR FillCanopy \ alone, to give a flash effect LDA #10 \ Delay for 10^3 loop iterations JSR Delay JSR ClearCanopy \ Clear the canopy to black, leaving the canopy edges \ alone JSR DrawCanopyCorners \ Redraw the diagonal canopy corners, which were cleared \ by the flashing canopy effect LDA #90 \ Delay for 90^3 loop iterations JSR Delay JSR TerminateGame \ Terminate the game TSX \ Remove six bytes from the top of the stack, which TXA \ removes the top three return addresses that were put CLC \ there by JSR instructions. This enables us to jump ADC #6 \ straight back to NewGame without leaving any remnants TAX \ of the call stack behind TXS JMP NewGame \ Jump to NewGame to start a new game
Name: NextObjectGroup [Show more] Type: Subroutine Category: 3D geometry Summary: Cycle to the next object group
Context: See this subroutine on its own page References: This subroutine is called as follows: * ProcessLine (Part 7 of 7) calls NextObjectGroup * SetObjectCoords (Part 9 of 11) calls NextObjectGroup

If the object ID passed to the routine is 6, 7, 8 or 9, then this object is part of an object group, in which case this routine increments the value in objectGroup for this object, so: * Object 6 increments objectGroup+0 through 0 to 7 and round again * Object 7 increments objectGroup+1 through 8 to 15 and round again * Object 8 increments objectGroup+2 through 16 to 23 and round again * Object 9 increments objectGroup+3 through 24 to 31 and round again Arguments: Y The Object ID to move on to the next set of coordinates Returns: C flag The result of the operation: * Set if this object ID is 6, 7, 8 or 9 * Clear otherwise
.NextObjectGroup CPY #6 \ If Y < 6, jump to nobj1 to return from the subroutine BCC nobj1 \ with the C flag clear CPY #10 \ If Y >= 10, jump to nobj1 to return from the BCS nobj1 \ subroutine with the C flag clear \ If we get here then Y = 6, 7, 8 or 9 LDA objectGroup-6,Y \ Increment the value in objectGroup for this object CLC \ from 0-7, adding in the value from groupStart (which ADC #1 \ contains the start value for each group, i.e. 0, 8, AND #7 \ 16 and 24) ORA groupStart-6,Y STA objectGroup-6,Y SEC \ Set the C flag RTS \ Return from the subroutine .nobj1 CLC \ Clear the C flag RTS \ Return from the subroutine
Name: ExplodeAlien [Show more] Type: Subroutine Category: The Theme Summary: Explode an alien, making the alien split apart Deep dive: Explosions and turbulence
Context: See this subroutine on its own page References: This subroutine is called as follows: * MainLoop (Part 5 of 15) calls ExplodeAlien

Arguments: hitObjectId The object ID of the exploding alien (30 to 33)
.ExplodeAlien LDA hitTimer \ If hitTimer is zero then there is no exploding alien, BEQ expl6 \ so jump to expl8 via expl6 to return from the \ subroutine LDA #2 \ Otherwise we do have an exploding alien, so make sound JSR MakeSound \ #2, the sound of an alien being destroyed LDX hitObjectId \ Set X to the object ID of the object we hit (30 to 33) LDY explodeFrom-30,X \ Set Y to the "from" point ID for exploding this alien \ slot LDA explodeTo-30,X \ Set U to the "to" point ID for exploding this alien STA U \ slot LDX #2 \ Set X = 2 to act as a shift counter in the following \ loop CPX feedingStage \ If X >= feedingStage, i.e. feedingStage <= 2, then BCS expl1 \ skip the following instruction LDX feedingStage \ Set X to the feeding stage, so X now contains the \ feeding stage, capped to a maximum value of 2 .expl1 LDA #%11111111 \ We now take %11111111 and shift it right by X + 1 \ places .expl2 LSR A \ Shift X right by one place DEX \ Decrement the shift counter BPL expl2 \ Loop back until we have shifted right by X + 1 places STA P \ Store the result in P, so we get the following: \ \ * P = %01111111 if feedingStage = 0 \ * P = %00111111 if feedingStage = 1 \ * P = %00011111 if feedingStage >= 2 \ In the following outer loop, Y iterates through the \ pointIDs, starting at the "from" ID we fetched from \ above and ending at the "to" value \ \ For each point, it adds or subtracts a random number \ to the point coordinate, with the random number being \ scaled along with P (so fatter aliens have their \ points moved further) .expl3 LDX #LO(xTemp2Lo) \ Set X so the call to CopyPointToWork copies the \ coordinates to (xTemp2, yTemp2, zTemp2) JSR CopyPointToWork \ Copy the coordinates from point Y to \ (xTemp2, yTemp2, zTemp2), so it contains the \ coordinates of the next point to process in Y STY T \ Store the loop counter in T so we can retrieve it \ later \ We now add (or subtract) a random number to each \ of the three axes in the (xTemp2, yTemp2, zTemp2) \ coordinate, using a different random number for \ each axis, setting the sign of the random number \ according to bit 0 (which is random), shifting the \ number right and AND'ing with P to give us a random \ number in the following range: \ \ * -128 to +127 if feedingStage = 0 \ * -64 to +63 if feedingStage = 1 \ * -32 to +31 if feedingStage >= 2 LDY #2 \ Set an index in Y for the inner loop, to work through \ the three axes of (xTemp2, yTemp2, zTemp2), from \ zTemp2 to xTemp2 \ \ The comments below are for the x-coordinate .expl4 LDA #0 \ Set R = 0 to act as the top byte for (R A) STA R JSR NextRandomNumber \ Set A to point to the next item in the randomNumbers \ list TAX \ Set A to the random number from the randomNumbers list LDA randomNumbers+1,X LSR A \ Shift A to the right, moving bit 0 into the C flag AND P \ Set A = A AND P BCC expl5 \ If bit 0 of A before the shift was clear, skip the \ following two instructions, as we are going to leave \ (R A) as a positive number DEC R \ Otherwise we want (R A) to be negative, so decrement R \ to &FF to act as the top byte in a negative (R A) EOR #&FF \ Flip all the bits in A to negate it, so in all we have \ (R A) = ~(A AND P) .expl5 ADC xTemp2Lo,Y \ Set (xTemp2Hi xTemp2Lo) = (xTemp2Hi xTemp2Lo) + (R A) STA xTemp2Lo,Y \ \ starting with the low bytes LDA R \ And then the high bytes ADC xTemp2Hi,Y STA xTemp2Hi,Y DEY \ Decrement the loop counter to move on to the next axis BPL expl4 \ Loop back until we have done all three axes \ We have now added random numbers to all three axes in \ (xTemp2, yTemp2, zTemp2), scaled to the alien's size, \ so now to copy the result back to the original point \ coordinates LDY T \ Restore the loop counter that we stored in T, so Y now \ contains the point ID once again LDX #LO(xTemp2Lo) \ Set X so the call to CopyWorkToPoint copies the \ coordinates from (xTemp2, yTemp2, zTemp2) JSR CopyWorkToPoint \ Copy the coordinates from (xTemp2, yTemp2, zTemp2) \ to point T DEY \ Decrement the outer loop counter to move on to the \ next point in the "from" to "to" range CPY U \ Loop back until we have done the "to" point BCS expl3 DEC hitTimer \ Decrement the hit timer, to move the current explosion \ process along by 1 BNE expl6 \ If the timer is still non-zero, then the explosion \ hasn't finished, so skip the following instruction JSR ScoreHitPoints \ The alien has finished exploding, so award points for \ its destruction .expl6 LDA hitTimer \ If hitTimer <> 26, jump to expl8 to return from the CMP #26 \ subroutine BNE expl8 \ If we get here then hitTimer = 26, so it was 27 before \ the decrement above, which is right at the start \ of the explosion LDA zTemp2Hi \ Set A to the high byte of the alien's new z-coordinate LDX hitObjectId \ If we didn't hit the flying alien, jump to expl7 to CPX #33 \ set distanceFromHit to the z-coordinate BNE expl7 SEC \ We hit the flying alien, so set A = A - 8 to store in SBC #8 \ distanceFromHit, which increases the chance of \ turbulence (as turbulence only kicks in when \ distanceFromHit < 16) BPL expl7 \ If the subtraction reduced A to below zero, set A = 0 LDA #0 \ to store in distanceFromHit .expl7 STA distanceFromHit \ Store the z-coordinate (or the z-coordinate - 8) in \ distanceFromHit, so turbulence will be applied if we \ are too close to the alien .expl8 RTS \ Return from the subroutine
Name: ScoreHitPoints [Show more] Type: Subroutine Category: Scoring Summary: Award points for destroying an alien, and remove the alien from its slot and the radar, if required
Context: See this subroutine on its own page References: This subroutine is called as follows: * ExplodeAlien calls ScoreHitPoints
.ScoreHitPoints LDA #255 \ Set A to a negative number so we can clear out the \ alien slot below LDY hitObjectId \ Set Y to the ID of the object we just hit with our \ bullets CPY #30 \ If Y is not 30, then jump to hitp1 to clear out the BNE hitp1 \ slot LDX alienSlot \ Set X to the number of the alien in slot 30 JMP hitp2 \ Jump to hitp2 to skip the following .hitp1 \ If we get here then we just hit an alien in slot 31 \ to 33 LDX alienSlot-30,Y \ Set X to the number of the alien in slot Y STA alienSlot-30,Y \ Store A (which is negative) in slot Y to empty the \ slot .hitp2 STA alienObjectId,X \ Reset the object ID associated with the alien that \ we just hit (i.e. the one in the range 16 to 29) CPY #33 \ If Y is not 33, then jump to hitp3 as only alien 33 BNE hitp3 \ appears on the radar JSR ResetRadar \ Remove the alien from the radar LDA #3 \ Set A = 3 and jump down to hitp5 to award 30 points BNE hitp5 \ for destroying the flying alien (this BNE is \ effectively a JMP as A is never zero) .hitp3 LDX feedingStage \ Set X to feedingStage, the feeding stage of the alien \ we just hit (if it isn't dormant or flying) CPY #31 \ If Y >= 31, i.e. this is not alien 30, then jump to BCS hitp4 \ hitp4 to award a score based on the alien's feeding \ stage LDA dormantAlienScore \ This is alien 30, which is always dormant, so fetch JMP hitp5 \ the score for killing a dormant alien (400 points) \ and jump down to hitp5 to increase the score .hitp4 LDA alienScore,X \ Fetch the score for killing an alien in the feeding \ state in A (0 = fattest alien, 3 = slimmest alien) .hitp5 LDX #0 \ Add A * 10 points to the score by calling UpdateScore JSR UpdateScore \ with (X A) = (0 A) = A RTS \ Return from the subroutine
Name: SetRandomNumber [Show more] Type: Subroutine Category: Utility routines Summary: Set the next item in the randomNumbers list to a new random number and update the pointer to point to it Deep dive: Random numbers
Context: See this subroutine on its own page References: This subroutine is called as follows: * MainLoop (Part 13 of 15) calls SetRandomNumber
.SetRandomNumber LDX randomNumbers \ Fetch the pointer for the randomNumbers list LDA VIA+&64 \ Read the 6522 User VIA T1C-L timer 1 low-order \ counter (SHEILA &64), which decrements one million \ times a second and will therefore be pretty random STA randomNumbers+1,X \ Set the next item in the list to the random number we \ just fetched \ Fall through into NextRandomNumber to move the list \ pointer to point to the new number we just added
Name: NextRandomNumber [Show more] Type: Subroutine Category: Utility routines Summary: Point to the next item in the randomNumbers list Deep dive: Random numbers
Context: See this subroutine on its own page References: This subroutine is called as follows: * ApplyFlightModel (Part 3 of 7) calls NextRandomNumber * ExplodeAlien calls NextRandomNumber

The pointer for the randomNumbers list is stored in the first location. Each call to this routine increments the pointer through 0 to 10, after which it wraps back round to 0. Returns: A Points to the next number in the randomNumbers list
.NextRandomNumber LDA randomNumbers \ Set A = randomNumbers + 1 CLC \ ADC #1 \ so A points to the next item in the randomNumbers list CMP #11 \ If A < 11, skip the following instruction as the BCC rand1 \ pointer hasn't yet reached the end of the list LDA #0 \ A >= 11, which is past the end of the list, so set \ A = 0 to set the pointer back at the start of the list .rand1 STA randomNumbers \ Store the updated pointer in randomNumbers RTS \ Return from the subroutine
Name: MakeSound [Show more] Type: Subroutine Category: Sound Summary: Make a sound
Context: See this subroutine on its own page References: This subroutine is called as follows: * ApplyAerodynamics (Part 2 of 3) calls MakeSound * Crash calls MakeSound * ExplodeAlien calls MakeSound * MainLoop (Part 3 of 15) calls MakeSound * MakeEngineSound calls MakeSound * ProcessLanding (Part 6 of 7) calls MakeSound * ScaleFlightForces calls MakeSound * ScorePoints calls MakeSound * ToggleEngineSound calls MakeSound

Arguments: A The sound number from the soundData table (0 to 7)
.MakeSound ASL A \ Set A = A * 8 ASL A \ ASL A \ so we can use it as an index into the soundData table, \ which has 8 bytes per entry CLC \ Set (Y X) = soundData + A ADC #LO(soundData) \ TAX \ starting with the low byte in X LDA #7 \ Set A = 7 for the OSWORD command to make a sound BNE MakeSoundEnvelope \ Jump to MakeSoundEnvelope to set up Y and apply the \ OSWORD command to the (Y X) block, which makes the \ relevant sound (this BNE is effectively a JMP as A is \ never zero)
Name: TerminateGame [Show more] Type: Subroutine Category: Setup Summary: Terminate the current game
Context: See this subroutine on its own page References: This subroutine is called as follows: * AlienInAcornsville calls TerminateGame * Crash calls TerminateGame * MainLoop (Part 7 of 15) calls TerminateGame
.TerminateGame LDA #0 \ Turn off the engine sound JSR ToggleEngineSound JSR UpdateHighScore \ If this is a high score, update the high score JSR DisplayScore \ Print the scores on-screen .term1 LDX #&B6 \ Scan the keyboard to see if RETURN is being pressed JSR ScanKeyboard BNE term1 \ Loop back to keep scanning until RETURN is pressed RTS \ Return from the subroutine
Name: DefineEnvelope [Show more] Type: Subroutine Category: Sound Summary: Define a sound envelope
Context: See this subroutine on its own page References: This subroutine is called as follows: * MakeEngineSound calls DefineEnvelope * StartGame calls DefineEnvelope

Arguments: A The offset of the sound envelope data in envelopeData: * A = 0 for the first envelope definition * A = 14 for the first envelope definition
.DefineEnvelope CLC \ Set (Y X) = envelopeData + A ADC #LO(envelopeData) \ TAX \ starting with the low byte LDA #8 \ Set A = 8 for the OSWORD command to define an envelope \ Fall through into MakeSoundEnvelope to set up Y and \ apply the OSWORD command to the (Y X) block, which \ defines the relevant sound envelope
Name: MakeSoundEnvelope [Show more] Type: Subroutine Category: Sound Summary: Either make a sound or set up an envelope
Context: See this subroutine on its own page References: This subroutine is called as follows: * MakeSound calls MakeSoundEnvelope

Arguments: A The action: * A = 7 make a sound * A = 8 to define a sound envelope X The low byte of the address of the OSWORD block C flag The outcome of the addition of the low bytes of (Y X)
.MakeSoundEnvelope LDY #HI(envelopeData) \ Set y to the high byte of the envelopeData block \ address, so (Y X) now points to the relevant envelope \ or sound data block BCC senv1 \ If the addition we did before calling the routine \ didn't overflow, skip the next instruction INY \ The above addition overflowed, so increment the high \ byte of (Y X) to point to the next page in memory .senv1 JSR OSWORD \ Call OSWORD with action A, as follows: \ \ * A = 7 to make the sound at (Y X) \ \ * A = 8 to set up the sound envelope at (Y X) RTS \ Return from the subroutine NOP \ This instruction appears to be unused
Name: ToggleEngineSound [Show more] Type: Subroutine Category: Sound Summary: Turn the engine sound on or off
Context: See this subroutine on its own page References: This subroutine is called as follows: * ApplyFlightModel (Part 6 of 7) calls ToggleEngineSound * Crash calls ToggleEngineSound * SetEngine calls ToggleEngineSound * TerminateGame calls ToggleEngineSound

Arguments: A Defines the action: * 0 = turn engine sound off * Non-zero = turn engine sound on with pitch A
.ToggleEngineSound BNE MakeEngineSound \ If A is non-zero then jump to MakeEngineSound to set \ up and make the engine sound LDA #0 \ Make sound #0, to turn off the engine sound JSR MakeSound \ Fall through into ResetEngineSound to reset the pitch \ of the engine sound
Name: ResetEngineSound [Show more] Type: Subroutine Category: Sound Summary: Reset the pitch of the engine sound
Context: See this subroutine on its own page References: This subroutine is called as follows: * ProcessLanding (Part 6 of 7) calls ResetEngineSound
.ResetEngineSound LDA #255 \ Set byte #5 of sound #7 (low byte of engine pitch) to STA soundData+60 \ 255, which is the default setting RTS \ Return from the subroutine
Name: MakeEngineSound [Show more] Type: Subroutine Category: Sound Summary: Make the engine sound, with the choppiness and pitch affected by thrust and airspeed
Context: See this subroutine on its own page References: This subroutine is called as follows: * ToggleEngineSound calls MakeEngineSound
.MakeEngineSound LDA engineStatus \ If engineStatus is zero, then the engine is not BEQ engs4 \ running, so jump to engs4 to return from the \ subroutine LDA thrustHi \ Set (K A) = (Thrusthi thrustLo) STA K \ = Thrust LDA thrustLo LDY #3 \ Set Y = 3 to act as a shift counter in the following \ loop, where we right shift (K A) four times .engs1 LSR K \ Set (K A) = (R A) / 2 ROR A \ = Thrust / 2 DEY \ Decrement the shift counter BPL engs1 \ Loop back until we have shifted right by 4 places, so \ we now have: \ \ (K A) = (K A) / 8 \ = Thrust / 8 \ \ We now ignore the high byte in K, so presumably it is \ zero CLC \ Set K = A + zVelocityPHi ADC zVelocityPHi \ = (Thrust / 8) + zVelocityPHi STA K LDA #50 \ Set A = 50 - K SEC \ = 50 - ((Thrust / 8) + zVelocityPHi) SBC K BEQ engs2 \ If A = 0, jump to engs2 to set the engine choppiness \ to 1 (a very smooth engine sound) BPL engs3 \ If A is positive, jump to engs3 to set the engine \ choppiness to A .engs2 LDA #1 \ If we get here then A is either 0 or negative, so we \ set A = 1 to use as the choppiness value in the engine \ sound, giving a very smooth engine sound .engs3 \ By the time we get here, A is in the range 1 to 50 and \ represents the engine choppiness, with a lower value \ indicating a smoother engine, and a higher value \ making the sound jump up and down in pitch more \ \ In other words, the lower the forward airspeed and \ thrust, the choppier the engine sound \ \ We can apply this to the sound envelope for the engine \ by altering the amount that the pitch changes in each \ stage of the sound envelope. These values are set in \ the third, fourth and fifth values in the envelope \ definition, with larger values giving us a larger \ amount of pitch change, and hence more choppiness in \ the engine sound STA envelopeData+2 \ Set the third and fifth values of sound envelope 1 to STA envelopeData+4 \ the value in A, and set the fourth value to the EOR #&FF \ inverse of A, which is -(A + 1) as this is a signed STA envelopeData+3 \ value \ We now want to set the pitch of the engine sound so \ that higher thrust and airspeed give us a higher \ pitch, making our Spitfire scream through the air \ \ The engine pitch is controlled by byte #5 of sound #7, \ at soundData+60, which contains the low byte of the \ engine pitch, so we now need to calculate a suitable \ pitch value LDA K \ Set A = K + 80 CLC \ = (Thrust / 8) + zVelocityPHi + 50 ADC #80 \ \ so A is a higher value when we have higher thrust and \ airspeed, which is what we want CMP soundData+60 \ If the pitch in byte #5 of sound #7 is already at this BEQ engs4 \ value, jump to engs4 to return from the subroutine, as \ we don't need to change the pitch STA soundData+60 \ Otherwise set byte #5 of sound #7 to our new pitch in \ A, so the pitch of the engine sound goes up with our \ thrust and airspeed LDA #0 \ Call DefineEnvelope with A = 0 to redefine the first JSR DefineEnvelope \ sound envelope with the new choppiness values LDA #7 \ Make sound #7, the engine pitch, to change the engine JSR MakeSound \ sound's pitch and choppiness LDA #1 \ Make sound #1, the engine amplitude, to ensure that JSR MakeSound \ both engine sounds are being made, as we need to make \ both #1 and #7 for the sound to work .engs4 RTS \ Return from the subroutine
Name: DrawGunSights [Show more] Type: Subroutine Category: Graphics Summary: Draw the canopy corners and the gun sights, if shown
Context: See this subroutine on its own page References: This subroutine is called as follows: * DrawCanopyView calls DrawGunSights
.DrawGunSights JSR DrawCanopyCorners \ Draw the canopy corners LDX #&DA \ Scan the keyboard to see if "I" is being pressed JSR ScanKeyboard BNE guns1 \ If "I" is not being pressed, jump to guns1 BIT gunSights \ If bit 6 of gunSights is set, then "I" is still being BVS guns3 \ held down from a previous call to this routine, so \ jump to guns3 to move on from the subroutine LDA #%11000000 \ Set A = gunSights with bits 6 and 7 flipped, which we EOR gunSights \ will set as the new value of gunSights below BMI guns2 \ If the result has bit 7 set, that means that bit 7 of \ gunSights is currently clear, so jump to guns2 as the \ sights are not already being shown, so we don't need \ to remove them \ If we get here then bit 7 of gunSights is set, so the \ sights are already on-screen, and we aren't still \ holding down "I" from a previous call, so now we \ remove the sights PHA \ Store A on the stack so we can retrieve it below LDY #HI(row6_block1_0) \ Set (Y X) to the screen address for row 6, block 0 LDX #LO(row6_block1_0) LDA #3 \ Set R = 3, so we clear 3 character rows for the sights STA R LDA #0 \ Set X = 0 so we clear the sights to black JSR FillCanopyRows \ Fill the 3 screen rows with black, avoiding the canopy \ edges and removing the sights from the screen PLA \ Retrieve A from the stack JMP guns2 \ Jump down to guns2 to set gunSights to the value in A .guns1 \ If we get here then "I" is not being pressed LDA #%10000000 \ Extract bit 7 from gunSights into A, which clears bit AND gunSights \ 6 to indicate that "I" is not being pressed, while \ leaving the current state of bit 7 alone .guns2 STA gunSights \ Update gunSights to the new value in A .guns3 BPL ToggleJoystick \ If bit 7 of the new value of gunSights is clear, then \ the sights are no longer being shown, so jump down to \ ToggleJoystick to move on to the next routine \ If we get here, then bit 7 of gunSights is set, so we \ need to draw the sights LDY #7 \ First we draw the vertical bar in the middle of the \ sights, which runs through block 20 on rows 6 and 7, \ so we set a pixel row counter in Y to count through \ the rows in each character block .guns4 LDA #%10001000 \ Draw a vertical bar in the first pixel of the Y-th ORA row6_block20_0,Y \ pixel row in block 20 on row 6, keeping whatever is STA row6_block20_0,Y \ already on screen LDA #%10001000 \ Draw a vertical bar in the first pixel of the Y-th ORA row7_block20_0,Y \ pixel row in block 20 on row 7, keeping whatever is STA row7_block20_0,Y \ already on screen DEY \ Decrement the pixel row counter BPL guns4 \ Loop back to draw the next pixel row until we have \ drawn a vertical line through both character blocks \ Now to draw the horizontal bar of the gun sights LDA #%01110111 \ First we draw the left end of the horizontal bar, ORA row8_block11_0 \ which is starts with the three rightmost pixels in STA row8_block11_0 \ block 11 on row 8 SEC \ Set the C flag for the subtraction below LDY #136 \ The rest of the line is made up of 17 character blocks \ with four pixels in each block, so we set a counter in \ Y to work as an offset from the left end of the line, \ counting 8 bytes per character block (17 * 8 = 136), \ working from the right end of the line to the left .guns5 LDA #%11111111 \ Draw a horizontal bar of four pixels starting at the STA row8_block11_0,Y \ Y-th offset from the start of block 11 on row 8 TYA \ Set Y = Y - 8, so Y now points to the four pixels to SBC #8 \ the left, as we work or way along the line TAY BNE guns5 \ Loop back to draw the next four pixels of the line \ until we have drawn the whole horizontal line \ Fall through into ToggleJoystick to check for the \ joystick key
Name: ToggleJoystick [Show more] Type: Subroutine Category: Keyboard Summary: Toggle the joystick setting
Context: See this subroutine on its own page References: This subroutine is called as follows: * DrawGunSights calls ToggleJoystick

Note that the game uses row29_block20_4 to check the joystick status, so it is not only an on-screen indicator, it's also the joystick status variable.
.ToggleJoystick LDX #&9F \ Scan the keyboard to see if TAB is being pressed JSR ScanKeyboard BNE tjoy1 \ If TAB is not being pressed, jump to tjoy1 LDA pressingTab \ If pressingTab is non-zero, then we are still pressing BNE tjoy3 \ TAB from a previous visit to this routine, so jump to \ tjoy3 to return from the subroutine \ This is a new press of TAB, so now we want to toggle \ the joystick setting LDA row29_block20_4 \ Toggle the joystick indicator pixel above the middle EOR #%10001000 \ of the rudder indicator STA row29_block20_4 LDA #128 \ Set A = 128 to use as the value for pressingTab below, \ to indicate that TAB is being pressed BNE tjoy2 \ Jump to tjoy2 to skip the following instruction (this \ BNE is effectively a JMP as A is never zero) .tjoy1 LDA #0 \ If we get here then TAB is not being pressed, so we \ set A = 0 to set as the value for pressingTab .tjoy2 STA pressingTab \ Set pressingTab to the value in A, which will be 0 if \ TAB is not being pressed, or 128 if it is being \ pressed .tjoy3 RTS \ Return from the subroutine EQUB &8D \ This byte appears to be unused
Name: envelopeData [Show more] Type: Variable Category: Sound Summary: Data for two sound envelopes
Context: See this variable on its own page References: This variable is used as follows: * DefineEnvelope calls envelopeData * MakeEngineSound calls envelopeData * MakeSoundEnvelope calls envelopeData

There are two sound envelopes defined in Aviator. * Envelope 1 defines the engine sound. The third, fourth and fifth values (envelopeData+2, envelopeData+3 and envelopeData+4) control the choppiness of the engine sound and get altered by the MakeEngineSound routine, depending on the thrust and airspeed. These values control the change of pitch per step in the three stages of the sound envelope, so higher values make the sound jump up and down more in terms of pitch, which makes the sound more choppy and less smooth. * Envelope 2 defines the sound of gunfire, both for our Spitfire and for the Theme aliens.
.envelopeData EQUB 1, 1, 50, -50, 50, 1, 2, 1, 0, 0, 0, 0, 0, 0 EQUB 2, 1, -5, 0, 0, 10, 0, 0, 120, -1, -24, -10, 120, 116
Name: soundData [Show more] Type: Variable Category: Sound Summary: OSWORD blocks for making the various game sounds
Context: See this variable on its own page References: This variable is used as follows: * MakeEngineSound calls soundData * MakeSound calls soundData * ProcessVolumeKeys calls soundData * ResetEngineSound calls soundData

Sound data. To make a sound, the MakeSound passes the bytes in this table to OSWORD 7. These bytes are the OSWORD equivalents of the parameters passed to the SOUND keyword in BASIC. The parameters have these meanings: channel/flush, amplitude (or envelope number if 1-4), pitch, duration where each value consists of two bytes, with the low byte first and the high byte second. For the channel/flush parameter, the top nibble of the low byte is the flush control (where a flush control of 0 queues the sound, and a flush control of 1 makes the sound instantly), while the bottom nibble of the low byte is the channel number . When written in hexadecimal, the first figure gives the flush control, while the second is the channel (so &13 indicates flush control = 1 and channel = 3). So when we call MakeSound with A = 5 to make sound #5, this is what the routine effectively does: SOUND &10, -13, 4, 12 which makes a sound with flush control 1 on channel 0, and with amplitude -13, pitch 4 and duration 12. Meanwhile, sound #2 is like this: SOUND &13, 2, 220, 2 which makes a sound with flush control 1 on channel 3, using envelope 2, and with pitch 220 and duration 2. The two sound envelopes (1 and 2) are set up by the DefineEnvelope routine.
.soundData EQUB &10, &00 \ Sound #0: Stop engine sound (SOUND &10, 0, 0, 0) EQUB &00, &00 EQUB &00, &00 EQUB &00, &00 EQUB &10, &00 \ Sound #1: Engine amplitude (SOUND &10, -5, 3, 255) EQUB &FB, &FF \ EQUB &03, &00 \ Second parameter (soundData+10) gets changed in the EQUB &FF, &00 \ ProcessVolumeKeys routine to alter the volume EQUB &13, &00 \ Sound #2: Alien destroyed (SOUND &13, 2, 220, 2) EQUB &02, &00 \ EQUB &DC, &00 \ Uses sound envelope 2 EQUB &02, &00 EQUB &13, &00 \ Sound #3: High g-forces (SOUND &13, -15, 120, 7) EQUB &F1, &FF EQUB &78, &00 \ This sound is a long, medium beep that indicates the EQUB &07, &00 \ plane's wings are coming off EQUB &13, &00 \ Sound #4: Plane is stalling (SOUND &13, -12, 0, 1) EQUB &F4, &FF \ EQUB &00, &00 \ This sound is a short, low beep EQUB &01, &00 EQUB &10, &00 \ Sound #5: Crash (SOUND &10, -13, 4, 12) EQUB &F3, &FF EQUB &04, &00 EQUB &0C, &00 EQUB &13, &00 \ Sound #6: Our gunfire (SOUND &13, 2, 60, 2) EQUB &02, &00 EQUB &3C, &00 EQUB &02, &00 EQUB &11, &00 \ Sound #7: Engine pitch (SOUND &11, 1, 255, 255) EQUB &01, &00 \ EQUB &FF, &00 \ Uses sound envelope 1 EQUB &FF, &00 \ \ The fifth byte (soundData+60) is the low byte of the \ sound's pitch and gets changed in various places \ to change the pitch of the engine sound