| 1 | #ifndef WUMP_GAME |
| 2 | #define WUMP_GAME |
| 3 | |
| 4 | @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ |
| 5 | @ (c) 2019 Aaron Taylor <ataylor at subgeniuskitty dot com> |
| 6 | @ See LICENSE.txt file for copyright and license details. |
| 7 | @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ |
| 8 | |
| 9 | @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ |
| 10 | @ Name: |
| 11 | @ get_tunnel_destination |
| 12 | @ Description: |
| 13 | @ Returns the room number corresponding to the destination of a tunnel |
| 14 | @ specified by room and slot. |
| 15 | @ Call Stack: |
| 16 | @ slot |
| 17 | @ room_number <-- TOS |
| 18 | @ Return Stack: |
| 19 | @ dst_room_number <-- TOS |
| 20 | @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ |
| 21 | NSSVTSSSTSSSN | MARK: 10001000 (get_tunnel_destination) |
| 22 | @ The pointer we seek is: |
| 23 | @ (room_number * room_struct_size) + 2 + slot + ROOM_DATA_BASE |
| 24 | @ Where the '+2' accounts for the pit and bat booleans. |
| 25 | NSTTSSSTSTTN | JSR > 10001011 (get_room_struct_size) |
| 26 | TSSN | MULTIPLY |
| 27 | SSSTSN | PUSH +2 |
| 28 | TSSS | ADD |
| 29 | TSSS | ADD |
| 30 | SSSTSSSSSSSSSSSSSN | PUSH 0x2000 (ROOM_DATA_BASE address) |
| 31 | TSSS | ADD |
| 32 | TTT | LOAD |
| 33 | NTN | RTS |
| 34 | |
| 35 | @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ |
| 36 | @ Name: |
| 37 | @ get_room_struct_size |
| 38 | @ Description: |
| 39 | @ Returns the size in words of the data structure for a single room. |
| 40 | @ For example, with 3 links plus bat and pit booleans, the size is 5 words. |
| 41 | @ Call Stack: |
| 42 | @ <empty> |
| 43 | @ Return Stack: |
| 44 | @ size <-- TOS |
| 45 | @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ |
| 46 | NSSVTSSSTSTTN | MARK: 10001011 (get_room_struct_size) |
| 47 | SSSTSSSSSSSSSSTTN | PUSH 0x1003 (GAME_DATA_BASE+3 = links_per_room address) |
| 48 | TTT | LOAD |
| 49 | SSSTSN | PUSH +2 |
| 50 | TSSS | ADD |
| 51 | NTN | RTS |
| 52 | |
| 53 | @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ |
| 54 | @ Name: |
| 55 | @ room_has_bats |
| 56 | @ Description: |
| 57 | @ Check if room_number contains bats. |
| 58 | @ Returns 1 or 0 representing true or false. |
| 59 | @ Call Stack: |
| 60 | @ room_number <-- TOS |
| 61 | @ Return Stack: |
| 62 | @ 1 or 0 <-- TOS |
| 63 | @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ |
| 64 | NSSVTSSSTTSSN | MARK: 10001100 (room_has_bats) |
| 65 | @ We seek the pointer: |
| 66 | @ (room_number * room_struct_size) + 1 + ROOM_DATA_BASE |
| 67 | @ where '+1' accounts for the offset of the bat boolean in the desired room. |
| 68 | NSTTSSSTSTTN | JSR > 10001011 (get_room_struct_size) |
| 69 | TSSN | MULTIPLY |
| 70 | SSSTN | PUSH +1 |
| 71 | TSSS | ADD |
| 72 | SSSTSSSSSSSSSSSSSN | PUSH 0x2000 (GAME_DATA_BASE address) |
| 73 | TSSS | ADD |
| 74 | TTT | LOAD |
| 75 | NTN | RTS |
| 76 | |
| 77 | @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ |
| 78 | @ Name: |
| 79 | @ room_has_pits |
| 80 | @ Description: |
| 81 | @ Check if room_number contains pits. |
| 82 | @ Returns 1 or 0 representing true or false. |
| 83 | @ Call Stack: |
| 84 | @ room_number <-- TOS |
| 85 | @ Return Stack: |
| 86 | @ 1 or 0 <-- TOS |
| 87 | @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ |
| 88 | NSSVTSSSTTSTN | MARK: 10001101 (room_has_pits) |
| 89 | @ We seek the pointer: |
| 90 | @ (room_number * room_struct_size) + 0 + ROOM_DATA_BASE |
| 91 | @ where '+0' accounts for the offset of the pit boolean in the desired room. |
| 92 | NSTTSSSTSTTN | JSR > 10001011 (get_room_struct_size) |
| 93 | TSSN | MULTIPLY |
| 94 | SSSTSSSSSSSSSSSSSN | PUSH 0x2000 (GAME_DATA_BASE address) |
| 95 | TSSS | ADD |
| 96 | TTT | LOAD |
| 97 | NTN | RTS |
| 98 | |
| 99 | @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ |
| 100 | @ Name: |
| 101 | @ room_has_wumpus |
| 102 | @ Description: |
| 103 | @ Check if room contains wumpus. |
| 104 | @ Returns 1 or 0 representing true or false. |
| 105 | @ Call Stack: |
| 106 | @ room_number <-- TOS |
| 107 | @ Return Stack: |
| 108 | @ 1 or 0 <-- TOS |
| 109 | @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ |
| 110 | NSSVTSTSSSSSN | MARK: 10100000 (room_has_wumpus) |
| 111 | SSSTSSSSSSSSSTTTN | PUSH 0x1007 (wumpus_location address) |
| 112 | TTT | LOAD |
| 113 | TSST | SUBTRACT |
| 114 | NTSTSTSSSSSSSSSSSSSN | BRZ > 10100000 00000000 (room_has_wumpus:true) |
| 115 | SSSSN | PUSH 0 (false) |
| 116 | NTN | RTS |
| 117 | NSSVTSTSSSSSSSSSSSSSN | MARK: 10100000 00000000 (room_has_wumpus:true) |
| 118 | SSSTN | PUSH 1 (true) |
| 119 | NTN | RTS |
| 120 | |
| 121 | @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ |
| 122 | @ Name: |
| 123 | @ are_bats_near |
| 124 | @ Description: |
| 125 | @ Given a room number, checks rooms within one hop for bats. |
| 126 | @ Returns 1 if bats are present or 0 if no bats. |
| 127 | @ Call Stack: |
| 128 | @ room_number <-- TOS |
| 129 | @ Return Stack: |
| 130 | @ 1 or 0 <-- TOS |
| 131 | @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ |
| 132 | #include <stack.pvvs> |
| 133 | NSSVTSSTTTSSN | MARK: 10011100 (are_bats_near) |
| 134 | |
| 135 | @ Prepare the stack by loading the number of links per room and decrementing. |
| 136 | @ We will loop until this reaches 0 or we find bats. |
| 137 | SSSTSSSSSSSSSSTTN | PUSH 0x1003 (number_of_links_per_room address) |
| 138 | TTT | LOAD |
| 139 | SSSTN | PUSH 1 |
| 140 | TSST | SUBTRACT |
| 141 | |
| 142 | @ Check one nearby room on each pass through this loop. |
| 143 | @ TOS> tunnel_index, room_number |
| 144 | NSSVTSSTTTSSSSSSSSSSN | MARK: 10011100 00000000 (are_bats_near:loop) |
| 145 | SNS | DUP |
| 146 | SSSTTN | PUSH 3 |
| 147 | NSTTTSSN | JSR > 1100 (deepdup) |
| 148 | NSTTSSSTSSSN | JSR > 10001000 (get_tunnel_destination) |
| 149 | NSTTSSSTTSSN | JSR > 10001100 (room_has_bats) |
| 150 | NTSTSSTTTSSSSSSSSSTN | BRZ > 10011100 00000001 (no_bats_in_this_room) |
| 151 | @ Found bats. Clean up and return. |
| 152 | SNN | DROP |
| 153 | SNN | DROP |
| 154 | SSSTN | PUSH 1 |
| 155 | NTN | RTS |
| 156 | NSSVTSSTTTSSSSSSSSSTN | MARK: 10011100 00000001 (no_bats_in_this_room) |
| 157 | @ Test for end of loop. |
| 158 | SNS | DUP |
| 159 | NTSTSSTTTSSSSSSSSTSN | BRZ > 10011100 00000010 (are_bats_near:loop_end) |
| 160 | @ No bats found yet, but still need to check some rooms. |
| 161 | @ Decrement tunnel index and loop again. |
| 162 | SSSTN | PUSH 1 |
| 163 | TSST | SUBTRACT |
| 164 | NSNTSSTTTSSSSSSSSSSN | JMP > 10011100 00000000 (are_bats_near:loop) |
| 165 | @ No bats found in nearby rooms. Clean up and return. |
| 166 | NSSVTSSTTTSSSSSSSSTSN | MARK: 10011100 00000010 (are_bats_near:loop_end) |
| 167 | SNN | DROP |
| 168 | SNN | DROP |
| 169 | SSSSN | PUSH 0 |
| 170 | NTN | RTS |
| 171 | |
| 172 | @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ |
| 173 | @ Name: |
| 174 | @ are_pits_near |
| 175 | @ Description: |
| 176 | @ Given a room number, checks rooms within one hop for pits. |
| 177 | @ Returns 1 if pits are present or 0 if no pits. |
| 178 | @ Call Stack: |
| 179 | @ room_number <-- TOS |
| 180 | @ Return Stack: |
| 181 | @ 1 or 0 <-- TOS |
| 182 | @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ |
| 183 | #include <stack.pvvs> |
| 184 | NSSVTSSTTTSTN | MARK: 10011101 (are_pits_near) |
| 185 | |
| 186 | @ Prepare the stack by loading the number of links per room and decrementing. |
| 187 | @ We will loop until this reaches 0 or we find pits. |
| 188 | SSSTSSSSSSSSSSTTN | PUSH 0x1003 (number_of_links_per_room address) |
| 189 | TTT | LOAD |
| 190 | SSSTN | PUSH 1 |
| 191 | TSST | SUBTRACT |
| 192 | |
| 193 | @ Check one nearby room on each pass through this loop. |
| 194 | @ TOS> tunnel_index, room_number |
| 195 | NSSVTSSTTTSTSSSSSSSSN | MARK: 10011101 00000000 (are_pits_near:loop) |
| 196 | SNS | DUP |
| 197 | SSSTTN | PUSH 3 |
| 198 | NSTTTSSN | JSR > 1100 (deepdup) |
| 199 | NSTTSSSTSSSN | JSR > 10001000 (get_tunnel_destination) |
| 200 | NSTTSSSTTSTN | JSR > 10001101 (room_has_pits) |
| 201 | NTSTSSTTTSTSSSSSSSTN | BRZ > 10011101 00000001 (no_pits_in_this_room) |
| 202 | @ Found pits. Clean up and return. |
| 203 | SNN | DROP |
| 204 | SNN | DROP |
| 205 | SSSTN | PUSH 1 |
| 206 | NTN | RTS |
| 207 | NSSVTSSTTTSTSSSSSSSTN | MARK: 10011101 00000001 (no_pits_in_this_room) |
| 208 | @ Test for end of loop. |
| 209 | SNS | DUP |
| 210 | NTSTSSTTTSTSSSSSSTSN | BRZ > 10011101 00000010 (are_pits_near:loop_end) |
| 211 | @ No pits found yet, but still need to check some rooms. |
| 212 | @ Decrement tunnel index and loop again. |
| 213 | SSSTN | PUSH 1 |
| 214 | TSST | SUBTRACT |
| 215 | NSNTSSTTTSTSSSSSSSSN | JMP > 10011101 00000000 (are_pits_near:loop) |
| 216 | @ No pits found in nearby rooms. Clean up and return. |
| 217 | NSSVTSSTTTSTSSSSSSTSN | MARK: 10011101 00000010 (are_pits_near:loop_end) |
| 218 | SNN | DROP |
| 219 | SNN | DROP |
| 220 | SSSSN | PUSH 0 |
| 221 | NTN | RTS |
| 222 | |
| 223 | @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ |
| 224 | @ Name: |
| 225 | @ is_wumpus_very_near |
| 226 | @ Description: |
| 227 | @ Given a room number, checks rooms within one hop for the wumpus. |
| 228 | @ Returns 1 if wumpus is present, otherwise 0. |
| 229 | @ Call Stack: |
| 230 | @ room_number <-- TOS |
| 231 | @ Return Stack: |
| 232 | @ 1 or 0 <-- TOS |
| 233 | @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ |
| 234 | #include <stack.pvvs> |
| 235 | NSSVTSSTTTTTN | MARK: 10011111 (is_wumpus_very_near) |
| 236 | |
| 237 | @ Prepare the stack by loading the number of links per room and decrementing. |
| 238 | @ We will loop until this reaches 0 or we find the wumpus. |
| 239 | SSSTSSSSSSSSSSTTN | PUSH 0x1003 (number_of_links_per_room address) |
| 240 | TTT | LOAD |
| 241 | SSSTN | PUSH 1 |
| 242 | TSST | SUBTRACT |
| 243 | |
| 244 | @ Check one nearby room on each pass through this loop. |
| 245 | @ TOS> tunnel_index, room_number |
| 246 | NSSVTSSTTTTTSSSSSSSSN | MARK: 10011111 00000000 (is_wumpus_very_near:loop) |
| 247 | SNS | DUP |
| 248 | SSSTTN | PUSH 3 |
| 249 | NSTTTSSN | JSR > 1100 (deepdup) |
| 250 | NSTTSSSTSSSN | JSR > 10001000 (get_tunnel_destination) |
| 251 | NSTTSTSSSSSN | JSR > 10100000 (room_has_wumpus) |
| 252 | NTSTSSTTTTTSSSSSSSTN | BRZ > 10011111 00000001 (no_wumpus_in_this_room) |
| 253 | @ Found wumpus. Clean up and return. |
| 254 | SNN | DROP |
| 255 | SNN | DROP |
| 256 | SSSTN | PUSH 1 |
| 257 | NTN | RTS |
| 258 | NSSVTSSTTTTTSSSSSSSTN | MARK: 10011111 00000001 (no_wumpus_in_this_room) |
| 259 | @ Test for end of loop. |
| 260 | SNS | DUP |
| 261 | NTSTSSTTTTTSSSSSSTSN | BRZ > 10011111 00000010 (is_wumpus_very_near:loop_end) |
| 262 | @ No wumpus found yet, but still need to check some rooms. |
| 263 | @ Decrement tunnel index and loop again. |
| 264 | SSSTN | PUSH 1 |
| 265 | TSST | SUBTRACT |
| 266 | NSNTSSTTTTTSSSSSSSSN | JMP > 10011111 00000000 (is_wumpus_very_near:loop) |
| 267 | @ No wumpus found in nearby rooms. Clean up and return. |
| 268 | NSSVTSSTTTTTSSSSSSTSN | MARK: 10011111 00000010 (is_wumpus_very_near:loop_end) |
| 269 | SNN | DROP |
| 270 | SNN | DROP |
| 271 | SSSSN | PUSH 0 |
| 272 | NTN | RTS |
| 273 | |
| 274 | @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ |
| 275 | @ Name: |
| 276 | @ is_wumpus_near |
| 277 | @ Description: |
| 278 | @ Given a room number, checks rooms within two hops for the wumpus. |
| 279 | @ Returns 1 if wumpus is present, otherwise 0. |
| 280 | @ Call Stack: |
| 281 | @ room_number <-- TOS |
| 282 | @ Return Stack: |
| 283 | @ 1 or 0 <-- TOS |
| 284 | @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ |
| 285 | #include <stack.pvvs> |
| 286 | NSSVTSSTTTTSN | MARK: 10011110 (is_wumpus_near) |
| 287 | |
| 288 | @ Prepare the stack by loading the number of links per room and decrementing. |
| 289 | @ We will loop until this reaches 0 or we find the wumpus. |
| 290 | SSSTSSSSSSSSSSTTN | PUSH 0x1003 (number_of_links_per_room address) |
| 291 | TTT | LOAD |
| 292 | SSSTN | PUSH 1 |
| 293 | TSST | SUBTRACT |
| 294 | |
| 295 | @ Check one nearby room and its connecting rooms on each pass through this loop. |
| 296 | @ TOS> tunnel_index, room_number |
| 297 | NSSVTSSTTTTSSSSSSSSSN | MARK: 10011110 00000000 (is_wumpus_near:loop) |
| 298 | SNS | DUP |
| 299 | SSSTTN | PUSH 3 |
| 300 | NSTTTSSN | JSR > 1100 (deepdup) |
| 301 | NSTTSSSTSSSN | JSR > 10001000 (get_tunnel_destination) |
| 302 | @ TOS> tunnel_endpoint, tunnel_index, room_number |
| 303 | SNS | DUP |
| 304 | NSTTSTSSSSSN | JSR > 10100000 (room_has_wumpus) |
| 305 | SSSTN | PUSH 1 |
| 306 | TSST | SUBTRACT |
| 307 | NTSTSSTTTTSSSSSSSTTN | BRZ > 10011110 00000011 (found_wumpus_one_hop) |
| 308 | NSTTSSTTTTTN | JSR > 10011111 (is_wumpus_very_near) |
| 309 | SSSTN | PUSH 1 |
| 310 | TSST | SUBTRACT |
| 311 | NTSTSSTTTTSSSSSSTSSN | BRZ > 10011110 00000100 (found_wumpus_two_hops) |
| 312 | @ Test for end of loop. |
| 313 | SNS | DUP |
| 314 | NTSTSSTTTTSSSSSSSTSN | BRZ > 10011110 00000010 (is_wumpus_near:loop_end) |
| 315 | @ No wumpus found yet, but still need to check some rooms. |
| 316 | @ Decrement tunnel index and loop again. |
| 317 | SSSTN | PUSH 1 |
| 318 | TSST | SUBTRACT |
| 319 | NSNTSSTTTTSSSSSSSSSN | JMP > 10011110 00000000 (is_wumpus_near:loop) |
| 320 | |
| 321 | @ No wumpus found in nearby rooms. Clean up and return. |
| 322 | NSSVTSSTTTTSSSSSSSTSN | MARK: 10011110 00000010 (is_wumpus_near:loop_end) |
| 323 | SNN | DROP |
| 324 | SNN | DROP |
| 325 | SSSSN | PUSH 0 |
| 326 | NTN | RTS |
| 327 | |
| 328 | @ Found wumpus. Clean up and return. |
| 329 | NSSVTSSTTTTSSSSSSSTTN | MARK: 10011110 00000011 (found_wumpus_one_hop) |
| 330 | SNN | DROP |
| 331 | NSSVTSSTTTTSSSSSSTSSN | MARK: 10011110 00000100 (found_wumpus_two_hops) |
| 332 | SNN | DROP |
| 333 | SNN | DROP |
| 334 | SSSTN | PUSH 1 |
| 335 | NTN | RTS |
| 336 | |
| 337 | @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ |
| 338 | @ Name: |
| 339 | @ seed_rng |
| 340 | @ Description: |
| 341 | @ Generate seed from keyboard input. |
| 342 | @ Call Stack: |
| 343 | @ <empty> |
| 344 | @ Return Stack: |
| 345 | @ <empty> |
| 346 | @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ |
| 347 | #include <logic.pvvs> |
| 348 | NSSVTSSSSSTTN | MARK: 10000011 (seed_rng) |
| 349 | |
| 350 | SSSTSSSSN | PUSH 16 (loop counter) |
| 351 | SSSSN | PUSH 0 (rng seed) |
| 352 | |
| 353 | NSSVTSSSSSTTSSSSSSSSN | MARK: 10000011 00000000 (seed_rng:main loop) |
| 354 | @ Get character from user and print ASCII '.' as feedback. |
| 355 | SSSTTSSSSSSSSSSSSN | PUSH 0x3000 (USER_INPUT_BUFFER address) |
| 356 | TNTS | GETCHAR |
| 357 | SSSTSTTTSN | PUSH ASCII '.' |
| 358 | TNSS | PUTCHAR |
| 359 | @ Left shift the seed by 4 bits. |
| 360 | SSSTSSN | PUSH 4 (shift count) |
| 361 | NSTTSTTSTN | JSR > 101101 (lshift) |
| 362 | @ XOR seed with character from user. |
| 363 | SSSTTSSSSSSSSSSSSN | PUSH 0x3000 (USER_INPUT_BUFFER address) |
| 364 | TTT | LOAD |
| 365 | NSTTSTSTTN | JSR > 101011 (xor) |
| 366 | @ Decrement counter |
| 367 | SNT | SWAP |
| 368 | SSSTN | PUSH +1 |
| 369 | TSST | SUBTRACT |
| 370 | @ Test for loop completion |
| 371 | SNS | DUP |
| 372 | NTSTSSSSSTTSSSSSSSTN | BRZ > 10000011 00000001 (seed_rng:cleanup and return) |
| 373 | SNT | SWAP |
| 374 | NSNTSSSSSTTSSSSSSSSN | JMP > 10000011 00000000 (seed_rng:main loop) |
| 375 | |
| 376 | @ Store seed, clean up and return. |
| 377 | NSSVTSSSSSTTSSSSSSSTN | MARK: 10000011 00000001 (seed_rng:cleanup and return) |
| 378 | SNN | DROP |
| 379 | SSSSN | PUSH 0 (seed address) |
| 380 | SNT | SWAP |
| 381 | TTS | STORE |
| 382 | SSSTSTSN | PUSH ASCII '\n' |
| 383 | SSSTSTSN | PUSH ASCII '\n' |
| 384 | TNSS | PUTCHAR |
| 385 | TNSS | PUTCHAR |
| 386 | NTN | RTS |
| 387 | |
| 388 | @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ |
| 389 | @ Name: |
| 390 | @ is_room_adjacent |
| 391 | @ Description: |
| 392 | @ Checks if 'room_number' is adjacent to the current player room. |
| 393 | @ Call Stack: |
| 394 | @ room_number <-- TOS |
| 395 | @ Return Stack: |
| 396 | @ (1 or 0) for true/false <-- TOS |
| 397 | @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ |
| 398 | #include <stack.pvvs> |
| 399 | NSSVTSTSSTSSN | MARK: 10100100 (is_room_adjacent) |
| 400 | |
| 401 | SSSTSSSSSSSSSSTTN | PUSH 0x1003 (ptr to number_of_tunnels_per_room) |
| 402 | TTT | LOAD |
| 403 | SSSTN | PUSH +1 |
| 404 | TSST | SUBTRACT |
| 405 | |
| 406 | @ TOS> tunnel_index, destination_room_num |
| 407 | NSSVTSTSSTSSSSSSSSSSN | MARK: 10100100 00000000 (is_room_adjacent:main_loop) |
| 408 | SSSTSN | PUSH +2 |
| 409 | NSTTTSSN | JSR > 1100 (deepdup) |
| 410 | SSSTSN | PUSH +2 |
| 411 | NSTTTSSN | JSR > 1100 (deepdup) |
| 412 | SSSTSSSSSSSSSTTSN | PUSH 0x1006 (ptr to player_location) |
| 413 | TTT | LOAD |
| 414 | NSTTSSSTSSSN | JSR > 10001000 (get_tunnel_destination) |
| 415 | TSST | SUBTRACT |
| 416 | NTSTSTSSTSSSSSSSSSTN | BRZ > 10100100 00000001 (is_room_adjacent:found_tunnel) |
| 417 | SSSTN | PUSH +1 |
| 418 | TSST | SUBTRACT |
| 419 | SNS | DUP |
| 420 | NTTTSTSSTSSSSSSSSTSN | BMI > 10100100 00000010 (is_room_adjacent:no_match) |
| 421 | NSNTSTSSTSSSSSSSSSSN | JMP > 10100100 00000000 (is_room_adjacent:main_loop) |
| 422 | |
| 423 | NSSVTSTSSTSSSSSSSSSTN | MARK: 10100100 00000001 (is_room_adjacent:found_tunnel) |
| 424 | SNN | DROP |
| 425 | SNN | DROP |
| 426 | SSSTN | PUSH +1 |
| 427 | NTN | RTS |
| 428 | |
| 429 | NSSVTSTSSTSSSSSSSSTSN | MARK: 10100100 00000010 (is_room_adjacent:no_match) |
| 430 | SNN | DROP |
| 431 | SNN | DROP |
| 432 | SSSSN | PUSH 0 |
| 433 | NTN | RTS |
| 434 | |
| 435 | @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ |
| 436 | @ Name: |
| 437 | @ move_player |
| 438 | @ Description: |
| 439 | @ Prompts the player for a room number. Moves to that room, checking the new |
| 440 | @ environment and executing consequences (fell in a pit, etc) as appropriate. |
| 441 | @ Call Stack: |
| 442 | @ <empty> |
| 443 | @ Return Stack: |
| 444 | @ <empty> |
| 445 | @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ |
| 446 | #include <stdio.pvvs> |
| 447 | #include <convert.pvvs> |
| 448 | #include <math.pvvs> |
| 449 | #include <string.pvvs> |
| 450 | NSSVTSTSSSTTN | MARK: 10100011 (move_player) |
| 451 | |
| 452 | A"To which room do you wish to move?\n" |
| 453 | SSSSN | PUSH 0 (number of string substitutions) |
| 454 | NSTTSSSN | JSR > 1000 (printf) |
| 455 | SSSTTSSSSSSSSSSSSN | PUSH 0x3000 (buffer address) |
| 456 | SSSTTSSSSSSSSSSSSN | PUSH 0x3000 (buffer size) |
| 457 | NSTTSSSTSN | JSR > 100010 (get_user_string) |
| 458 | SSSTTSSSSSSSSSSSSN | PUSH 0x3000 (USER_INPUT_BUFFER address) |
| 459 | NSTTTSSSSN | JSR > 110000 (atoi) |
| 460 | SNN | DROP |
| 461 | |
| 462 | @ The desired room number is now on the TOS. Verify that it is valid. |
| 463 | SNS | DUP |
| 464 | NSTTSTSSTSSN | JSR > 10100100 (is_room_adjacent) |
| 465 | NTSTSTSSSTTSSSSSSSTN | BRZ > 10100011 00000001 (invalid room number) |
| 466 | NSNTSTSSSTTSSSSSSSSN | JMP > 10100011 00000000 (valid room number) |
| 467 | |
| 468 | NSSVTSTSSSTTSSSSSSSTN | MARK: 10100011 00000001 (invalid room number) |
| 469 | @ TOS> room_number |
| 470 | SNN | DROP |
| 471 | A"*Oof!* (you hit the wall)\n" |
| 472 | SSSSN | PUSH 0 (number of string substitutions) |
| 473 | NSTTSSSN | JSR > 1000 (printf) |
| 474 | NSTTSSTTN | JSR > 10011 (fastrand) |
| 475 | SSSTTSN | PUSH 6 (chance) |
| 476 | TSTT | MODULO |
| 477 | NTSTSTSSSTTSSSSSSTSN | BRZ > 10100011 00000010 (woke the wumpus) |
| 478 | NTN | RTS |
| 479 | NSSVTSTSSSTTSSSSSSTSN | MARK: 10100011 00000010 (woke the wumpus) |
| 480 | A"Your colorful comments awaken the wumpus!\n" |
| 481 | SSSSN | PUSH 0 (number of string substitutions) |
| 482 | NSTTSSSN | JSR > 1000 (printf) |
| 483 | NSTTSSTTN | JSR > 10011 (fastrand) |
| 484 | SSSTSSSSSSSSSSTTN | PUSH 0x1003 (ptr to number of tunnels per room) |
| 485 | TSTT | MODULO |
| 486 | SSSTSSSSSSSSSTTTN | PUSH 0x1007 (ptr to wumpus location) |
| 487 | TTT | LOAD |
| 488 | NSTTSSSTSSSN | JSR > 10001000 (get_tunnel_destination) |
| 489 | SSSTSSSSSSSSSTTTN | PUSH 0x1007 (ptr to wumpus location) |
| 490 | SNT | SWAP |
| 491 | TTS | STORE |
| 492 | SSSTSSSSSSSSSTTSN | PUSH 0x1006 (ptr to player location) |
| 493 | TTT | LOAD |
| 494 | NSTTSTSSSSSN | JSR > 10100000 (room_has_wumpus) |
| 495 | NTSTSTSSSTTSSSSSSTTN | BRZ > 10100011 00000011 (wumpus did not move to player) |
| 496 | NSTTTTTTTTTSSSSSSSSN | JSR > 11111111 00000000 (wump_kill) |
| 497 | SSSSN | PUSH 0 (number of string substitutions) |
| 498 | NSTTSSSN | JSR > 1000 (printf) |
| 499 | NNN | DIE |
| 500 | NSSVTSTSSSTTSSSSSSTTN | MARK: 10100011 00000011 (wumpus did not move to player) |
| 501 | NTN | RTS |
| 502 | |
| 503 | NSSVTSTSSSTTSSSSSSSSN | MARK: 10100011 00000000 (valid room number) |
| 504 | @ TOS> room_number |
| 505 | @ Move player to new room |
| 506 | SSSTSSSSSSSSSTTSN | PUSH 0x1006 (ptr to player location) |
| 507 | SNT | SWAP |
| 508 | TTS | STORE |
| 509 | @ Check for wumpus in new player location |
| 510 | SSSTSSSSSSSSSTTSN | PUSH 0x1006 (ptr to player location) |
| 511 | TTT | LOAD |
| 512 | NSTTSTSSSSSN | JSR > 10100000 (room_has_wumpus) |
| 513 | NTSTSTSSSTTSSSSSTSSN | BRZ > 10100011 00000100 (no wumpus in new room) |
| 514 | NSTTTTTTTTTSSSSSSSSN | JSR > 11111111 00000000 (wump_kill) |
| 515 | SSSSN | PUSH 0 (number of string substitutions) |
| 516 | NSTTSSSN | JSR > 1000 (printf) |
| 517 | NNN | DIE |
| 518 | NSSVTSTSSSTTSSSSSTSSN | MARK: 10100011 00000100 (no wumpus in new room) |
| 519 | @ Check for pits in new player location |
| 520 | SSSTSSSSSSSSSTTSN | PUSH 0x1006 (ptr to player location) |
| 521 | TTT | LOAD |
| 522 | NSTTSSSTTSTN | JSR > 10001101 (room_has_pits) |
| 523 | NTSTSTSSSTTSSSSSTSTN | BRZ > 10100011 00000101 (no pits in new room) |
| 524 | NSTTSSTTN | JSR > 10011 (fastrand) |
| 525 | SSSTTSN | PUSH 6 (chance) |
| 526 | TSTT | MODULO |
| 527 | NTSTSTSSSTTSSSSSTTSN | BRZ > 10100011 00000110 (survived the pits) |
| 528 | NSTTTTTTTTTSSSSSTSTN | JSR > 11111111 00000101 (pit_kill) |
| 529 | SSSSN | PUSH 0 (number of string substitutions) |
| 530 | NSTTSSSN | JSR > 1000 (printf) |
| 531 | NNN | DIE |
| 532 | NSSVTSTSSSTTSSSSSTTSN | MARK: 10100011 00000110 (survived the pits) |
| 533 | NSTTTTTTTTTSSSSSTTSN | JSR > 11111111 00000110 (pit_survive) |
| 534 | SSSSN | PUSH 0 (number of string substitutions) |
| 535 | NSTTSSSN | JSR > 1000 (printf) |
| 536 | NSSVTSTSSSTTSSSSSTSTN | MARK: 10100011 00000101 (no pits in new room) |
| 537 | @ Check for bats in new player location |
| 538 | SSSTSSSSSSSSSTTSN | PUSH 0x1006 (ptr to player location) |
| 539 | TTT | LOAD |
| 540 | NSTTSSSTTSSN | JSR > 10001100 (room_has_bats) |
| 541 | NTSTSTSSSTTSSSSSTTSN | BRZ > 10100011 00000110 (no bats in new room) |
| 542 | A"*flap* *flap* *flap* (humongous bats pick you up and move you!)\n" |
| 543 | SSSSN | PUSH 0 (number of string substitutions) |
| 544 | NSTTSSSN | JSR > 1000 (printf) |
| 545 | NSTTSSTTN | JSR > 10011 (fastrand) |
| 546 | SSSTSSSSSSSSSSTTN | PUSH 0x1003 (ptr to number of tunnels per room) |
| 547 | TSTT | MODULO |
| 548 | SSSTSSSSSSSSSTTSN | PUSH 0x1006 (ptr to player location) |
| 549 | TTT | LOAD |
| 550 | NSTTSSSTSSSN | JSR > 10001000 (get_tunnel_destination) |
| 551 | NSNTSTSSSTTSSSSSSSSN | JMP > 10100011 00000000 (valid room number) |
| 552 | NSSVTSTSSSTTSSSSSTTSN | MARK: 10100011 00000110 (no bats in new room) |
| 553 | NTN | RTS |
| 554 | |
| 555 | @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ |
| 556 | @ Name: |
| 557 | @ move_or_shoot |
| 558 | @ Description: |
| 559 | @ Parse user input, branching to the appropriate subroutine to move or shoot. |
| 560 | @ This function does not perform any boundary checks/limits. |
| 561 | @ Call Stack: |
| 562 | @ <empty> |
| 563 | @ Return Stack: |
| 564 | @ <empty> |
| 565 | @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ |
| 566 | #include <stdio.pvvs> |
| 567 | #include <string.pvvs> |
| 568 | NSSVTSTSSSTSN | MARK: 10100010 (move_or_shoot) |
| 569 | |
| 570 | SSSTTSSSSSSSSSSSSN | PUSH 0x3000 (buffer address) |
| 571 | SSSTTSSSSSSSSSSSSN | PUSH 0x3000 (buffer size) |
| 572 | NSTTSSSTSN | JSR > 100010 (get_user_string) |
| 573 | |
| 574 | @ Examine the first character of the user input buffer for 'm' or 's'. |
| 575 | @ If character is something else, prompt user to try again. |
| 576 | SSSTTSSSSSSSSSSSSN | PUSH 0x3000 (USER_INPUT_BUFFER address) |
| 577 | TTT | LOAD |
| 578 | SSSSTTSTTSTN | PUSH 109 (ASCII 'm') |
| 579 | TSST | SUBTRACT |
| 580 | NTSTSTSSSTSSSSSSSSSN | BRZ > 10100010 00000000 (move) |
| 581 | SSSTTSSSSSSSSSSSSN | PUSH 0x3000 (USER_INPUT_BUFFER address) |
| 582 | TTT | LOAD |
| 583 | SSSSTTTSSTTN | PUSH 115 (ASCII 's') |
| 584 | TSST | SUBTRACT |
| 585 | NTSTSTSSSTSSSSSSSSTN | BRZ > 10100010 00000001 (shoot) |
| 586 | NSTTTTTTTTTSSSSTSSSN | JSR > 11111111 00001000 (problem_with_input) |
| 587 | SSSSN | PUSH 0 (number of string substitutions) |
| 588 | NSTTSSSN | JSR > 1000 (printf) |
| 589 | NSNTSTSSSTSN | JMP > 10100010 (move_or_shoot) |
| 590 | |
| 591 | @ User typed 'm' |
| 592 | NSSVTSTSSSTSSSSSSSSSN | MARK: 10100010 00000000 (move) |
| 593 | NSTTSTSSSTTN | JSR > 10100011 (move_player) |
| 594 | NTN | RTS |
| 595 | |
| 596 | @ User typed 's' |
| 597 | NSSVTSTSSSTSSSSSSSSTN | MARK: 10100010 00000001 (shoot) |
| 598 | @ TODO: JSR shoot |
| 599 | NTN | RTS |
| 600 | |
| 601 | @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ |
| 602 | @ Name: |
| 603 | @ get_answer |
| 604 | @ Description: |
| 605 | @ Parse user input, returning 0 if user string started with 'n' or 1 if 'y'. |
| 606 | @ This function does not perform any boundary checks/limits. |
| 607 | @ Call Stack: |
| 608 | @ <empty> |
| 609 | @ Return Stack: |
| 610 | @ (1 or 0 for True/False) <--- TOS |
| 611 | @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ |
| 612 | #include <stdio.pvvs> |
| 613 | #include <string.pvvs> |
| 614 | NSSVTSSTTSSSN | MARK: 10011000 (get_answer) |
| 615 | |
| 616 | @ TODO: Consider extending the GETCHAR instruction in VVS to indicate an empty |
| 617 | @ buffer instead of blocking. This would allow a character by character |
| 618 | @ check without printing a slew of retry messages if the buffer is |
| 619 | @ non-empty. |
| 620 | SSSTTSSSSSSSSSSSSN | PUSH 0x3000 (buffer address) |
| 621 | SSSTTSSSSSSSSSSSSN | PUSH 0x3000 (buffer size) |
| 622 | NSTTSSSTSN | JSR > 100010 (get_user_string) |
| 623 | |
| 624 | @ Examine the first character of the user input buffer for 'y' or 'n'. |
| 625 | @ If character is something else, prompt user to try again. |
| 626 | SSSTTSSSSSSSSSSSSN | PUSH 0x3000 (USER_INPUT_BUFFER address) |
| 627 | TTT | LOAD |
| 628 | SSSSTTTTSSTN | PUSH 121 (ASCII 'y') |
| 629 | TSST | SUBTRACT |
| 630 | NTSTSSTTSSSSSSSSSSSN | BRZ > 10011000 00000000 (answer: yes) |
| 631 | SSSTTSSSSSSSSSSSSN | PUSH 0x3000 (USER_INPUT_BUFFER address) |
| 632 | TTT | LOAD |
| 633 | SSSSTTSTTTSN | PUSH 110 (ASCII 'n') |
| 634 | TSST | SUBTRACT |
| 635 | NTSTSSTTSSSSSSSSSSTN | BRZ > 10011000 00000001 (answer: no) |
| 636 | NSTTTTTTTTTSSSSTSSSN | JSR > 11111111 00001000 (problem_with_input) |
| 637 | SSSSN | PUSH 0 (number of string substitutions) |
| 638 | NSTTSSSN | JSR > 1000 (printf) |
| 639 | NSNTSSTTSSSN | JMP > 10011000 (get_answer) |
| 640 | |
| 641 | @ User typed 'y' |
| 642 | NSSVTSSTTSSSSSSSSSSSN | MARK: 10011000 00000000 (answer: yes) |
| 643 | SSSTN | PUSH 1 |
| 644 | NTN | RTS |
| 645 | |
| 646 | @ User typed 'n' |
| 647 | NSSVTSSTTSSSSSSSSSSTN | MARK: 10011000 00000001 (answer: no) |
| 648 | SSSSN | PUSH 0 |
| 649 | NTN | RTS |
| 650 | |
| 651 | @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ |
| 652 | @ Name: |
| 653 | @ print_cave_description |
| 654 | @ Description: |
| 655 | @ Prints information about the cave (number of rooms, etc). |
| 656 | @ Call Stack: |
| 657 | @ <empty> |
| 658 | @ Return Stack: |
| 659 | @ <empty> |
| 660 | @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ |
| 661 | #include <stdio.pvvs> |
| 662 | NSSVTSSTTSTTN | MARK: 10011011 (print_cave_description) |
| 663 | NSTTTTTTTTTSSSSTSTSN | JSR > 11111111 00001010 (cave_description) |
| 664 | SSSTSSSSSSSSSTSTN | PUSH 0x1005 (number_of_arrows address) |
| 665 | TTT | LOAD |
| 666 | SSSTSSSSSSSSSSSTN | PUSH 0x1001 (number_of_pits address) |
| 667 | TTT | LOAD |
| 668 | SSSTSSSSSSSSSSTSN | PUSH 0x1002 (number_of_bats address) |
| 669 | TTT | LOAD |
| 670 | SSSTSSSSSSSSSSTTN | PUSH 0x1003 (number_of_tunnels address) |
| 671 | TTT | LOAD |
| 672 | SSSTSSSSSSSSSSSSN | PUSH 0x1000 (number_of_rooms address) |
| 673 | TTT | LOAD |
| 674 | SSSTSTN | PUSH 5 (number of substitions) |
| 675 | NSTTSSSN | JSR > 1000 (printf) |
| 676 | NTN | RTS |
| 677 | |
| 678 | @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ |
| 679 | @ Name: |
| 680 | @ print_room_stats |
| 681 | @ Description: |
| 682 | @ Prints information about current room and hints about nearby rooms. |
| 683 | @ Call Stack: |
| 684 | @ <empty> |
| 685 | @ Return Stack: |
| 686 | @ <empty> |
| 687 | @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ |
| 688 | #include <wump_game.pvvs> |
| 689 | #include <stdio.pvvs> |
| 690 | #include <stack.pvvs> |
| 691 | NSSVTSTSSSSTN | MARK: 10100001 (print_room_stats) |
| 692 | |
| 693 | @ Print location and arrow quantity remaining. |
| 694 | A"You are in room %u of the cave and have %u arrows remaining.\n" |
| 695 | SSSTSSSSSSSSSTSTN | PUSH 0x1005 (number_of_arrows address) |
| 696 | TTT | LOAD |
| 697 | SSSTSSSSSSSSSTTSN | PUSH 0x1006 (player_location address) |
| 698 | TTT | LOAD |
| 699 | SSSTSN | PUSH 2 (number of substitutions) |
| 700 | NSTTSSSN | JSR > 1000 (printf) |
| 701 | |
| 702 | @ Print if bats/pits/wumpus nearby. |
| 703 | SSSTSSSSSSSSSTTSN | PUSH 0x1006 (player_location address) |
| 704 | TTT | LOAD |
| 705 | SNS | DUP |
| 706 | NSTTSSTTTSSN | JSR > 10011100 (are_bats_near) |
| 707 | NTSTSTSSSSTSSSSSSSSN | BRZ > 10100001 00000000 (no_bats) |
| 708 | A"*rustle* (Bats must be nearby.)\n" |
| 709 | SSSSN | PUSH 0 (number of substitutions) |
| 710 | NSTTSSSN | JSR > 1000 (printf) |
| 711 | NSSVTSTSSSSTSSSSSSSSN | MARK: 10100001 00000000 (no_bats) |
| 712 | SNS | DUP |
| 713 | NSTTSSTTTSTN | JSR > 10011101 (are_pits_near) |
| 714 | NTSTSTSSSSTSSSSSSSTN | BRZ > 10100001 00000001 (no_pits) |
| 715 | A"*whoosh* (You feel a draft from nearby pits.)\n" |
| 716 | SSSSN | PUSH 0 (number of substitutions) |
| 717 | NSTTSSSN | JSR > 1000 (printf) |
| 718 | NSSVTSTSSSSTSSSSSSSTN | MARK: 10100001 00000001 (no_pits) |
| 719 | NSTTSSTTTTSN | JSR > 10011110 (is_wumpus_near) |
| 720 | NTSTSTSSSSTSSSSSSTSN | BRZ > 10100001 00000010 (no_wumpus) |
| 721 | A"*sniff* (You smell the evil Wumpus nearby!)\n" |
| 722 | SSSSN | PUSH 0 (number of substitutions) |
| 723 | NSTTSSSN | JSR > 1000 (printf) |
| 724 | NSSVTSTSSSSTSSSSSSTSN | MARK: 10100001 00000010 (no_wumpus) |
| 725 | |
| 726 | @ Print a list of nearby rooms. |
| 727 | A"This room contains tunnels to the following rooms:" |
| 728 | SSSSN | PUSH 0 (number of substitutions) |
| 729 | NSTTSSSN | JSR > 1000 (printf) |
| 730 | SSSTSSSSSSSSSTTSN | PUSH 0x1006 (player_location address) |
| 731 | TTT | LOAD |
| 732 | SSSTSSSSSSSSSSTTN | PUSH 0x1003 (number_of_links_per_room address) |
| 733 | TTT | LOAD |
| 734 | SSSTN | PUSH 1 |
| 735 | TSST | SUBTRACT |
| 736 | @ Print one room on each pass through this loop. |
| 737 | @ TOS> tunnel_index, room_number |
| 738 | NSSVTSTSSSSTSSSSSSTTN | MARK: 10100001 00000011 (print_room_list_loop) |
| 739 | A" %u" |
| 740 | SSSTSTN | PUSH 5 |
| 741 | NSTTTSSN | JSR > 1100 (deepdup) |
| 742 | SSSTTTN | PUSH 7 |
| 743 | NSTTTSSN | JSR > 1100 (deepdup) |
| 744 | NSTTSSSTSSSN | JSR > 10001000 (get_tunnel_destination) |
| 745 | SSSTN | PUSH 1 (number of substitutions) |
| 746 | NSTTSSSN | JSR > 1000 (printf) |
| 747 | @ Test for end of loop |
| 748 | SNS | DUP |
| 749 | NTSTSTSSSSTSSSSSTSSN | BRZ > 10100001 00000100 (print_room_list_loop_end) |
| 750 | SSSTN | PUSH 1 |
| 751 | TSST | SUBTRACT |
| 752 | NSNTSTSSSSTSSSSSSTTN | JMP > 10100001 00000011 (print_room_list_loop) |
| 753 | @ Clean up and return. |
| 754 | NSSVTSTSSSSTSSSSSTSSN | MARK: 10100001 00000100 (print_room_list_loop_end) |
| 755 | SSSTSTSN | PUSH 10 (ASCII '\n') |
| 756 | TNSS | PUTCHAR |
| 757 | SNN | DROP |
| 758 | SNN | DROP |
| 759 | NTN | RTS |
| 760 | |
| 761 | #endif |