@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@ (c) 2019 Aaron Taylor <ataylor at subgeniuskitty dot com>
@ See LICENSE.txt file for copyright and license details.
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@ Returns the room number corresponding to the destination of a tunnel
@ specified by room and slot.
@ dst_room_number <-- TOS
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
NSSVTSSSTSSSN | MARK: 10001000 (get_tunnel_destination)
@ The pointer we seek is:
@ (room_number * room_struct_size) + 2 + slot + ROOM_DATA_BASE
@ Where the '+2' accounts for the pit and bat booleans.
NSTTSSSTSTTN | JSR > 10001011 (get_room_struct_size)
SSSTSSSSSSSSSSSSSN | PUSH 0x2000 (ROOM_DATA_BASE address)
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@ Returns the size in words of the data structure for a single room.
@ For example, with 3 links plus bat and pit booleans, the size is 5 words.
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
NSSVTSSSTSTTN | MARK: 10001011 (get_room_struct_size)
SSSTSSSSSSSSSSTTN | PUSH 0x1003 (GAME_DATA_BASE+3 = links_per_room address)
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@ Check if room_number contains bats.
@ Returns 1 or 0 representing true or false.
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
NSSVTSSSTTSSN | MARK: 10001100 (room_has_bats)
@ (room_number * room_struct_size) + 1 + ROOM_DATA_BASE
@ where '+1' accounts for the offset of the bat boolean in the desired room.
NSTTSSSTSTTN | JSR > 10001011 (get_room_struct_size)
SSSTSSSSSSSSSSSSSN | PUSH 0x2000 (GAME_DATA_BASE address)
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@ Check if room_number contains pits.
@ Returns 1 or 0 representing true or false.
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
NSSVTSSSTTSTN | MARK: 10001101 (room_has_pits)
@ (room_number * room_struct_size) + 0 + ROOM_DATA_BASE
@ where '+0' accounts for the offset of the pit boolean in the desired room.
NSTTSSSTSTTN | JSR > 10001011 (get_room_struct_size)
SSSTSSSSSSSSSSSSSN | PUSH 0x2000 (GAME_DATA_BASE address)
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@ Check if room contains wumpus.
@ Returns 1 or 0 representing true or false.
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
NSSVTSTSSSSSN | MARK: 10100000 (room_has_wumpus)
SSSTSSSSSSSSSTTTN | PUSH 0x1007 (wumpus_location address)
NTSTSTSSSSSSSSSSSSSN | BRZ > 10100000 00000000 (room_has_wumpus:true)
NSSVTSTSSSSSSSSSSSSSN | MARK: 10100000 00000000 (room_has_wumpus:true)
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@ Given a room number, checks rooms within one hop for bats.
@ Returns 1 if bats are present or 0 if no bats.
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
NSSVTSSTTTSSN | MARK: 10011100 (are_bats_near)
@ Prepare the stack by loading the number of links per room and decrementing.
@ We will loop until this reaches 0 or we find bats.
SSSTSSSSSSSSSSTTN | PUSH 0x1003 (number_of_links_per_room address)
@ Check one nearby room on each pass through this loop.
@ TOS> tunnel_index, room_number
NSSVTSSTTTSSSSSSSSSSN | MARK: 10011100 00000000 (are_bats_near:loop)
NSTTTSSN | JSR > 1100 (deepdup)
NSTTSSSTSSSN | JSR > 10001000 (get_tunnel_destination)
NSTTSSSTTSSN | JSR > 10001100 (room_has_bats)
NTSTSSTTTSSSSSSSSSTN | BRZ > 10011100 00000001 (no_bats_in_this_room)
@ Found bats. Clean up and return.
NSSVTSSTTTSSSSSSSSSTN | MARK: 10011100 00000001 (no_bats_in_this_room)
NTSTSSTTTSSSSSSSSTSN | BRZ > 10011100 00000010 (are_bats_near:loop_end)
@ No bats found yet, but still need to check some rooms.
@ Decrement tunnel index and loop again.
NSNTSSTTTSSSSSSSSSSN | JMP > 10011100 00000000 (are_bats_near:loop)
@ No bats found in nearby rooms. Clean up and return.
NSSVTSSTTTSSSSSSSSTSN | MARK: 10011100 00000010 (are_bats_near:loop_end)
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@ Given a room number, checks rooms within one hop for pits.
@ Returns 1 if pits are present or 0 if no pits.
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
NSSVTSSTTTSTN | MARK: 10011101 (are_pits_near)
@ Prepare the stack by loading the number of links per room and decrementing.
@ We will loop until this reaches 0 or we find pits.
SSSTSSSSSSSSSSTTN | PUSH 0x1003 (number_of_links_per_room address)
@ Check one nearby room on each pass through this loop.
@ TOS> tunnel_index, room_number
NSSVTSSTTTSTSSSSSSSSN | MARK: 10011101 00000000 (are_pits_near:loop)
NSTTTSSN | JSR > 1100 (deepdup)
NSTTSSSTSSSN | JSR > 10001000 (get_tunnel_destination)
NSTTSSSTTSTN | JSR > 10001101 (room_has_pits)
NTSTSSTTTSTSSSSSSSTN | BRZ > 10011101 00000001 (no_pits_in_this_room)
@ Found pits. Clean up and return.
NSSVTSSTTTSTSSSSSSSTN | MARK: 10011101 00000001 (no_pits_in_this_room)
NTSTSSTTTSTSSSSSSTSN | BRZ > 10011101 00000010 (are_pits_near:loop_end)
@ No pits found yet, but still need to check some rooms.
@ Decrement tunnel index and loop again.
NSNTSSTTTSTSSSSSSSSN | JMP > 10011101 00000000 (are_pits_near:loop)
@ No pits found in nearby rooms. Clean up and return.
NSSVTSSTTTSTSSSSSSTSN | MARK: 10011101 00000010 (are_pits_near:loop_end)
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@ Given a room number, checks rooms within one hop for the wumpus.
@ Returns 1 if wumpus is present, otherwise 0.
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
NSSVTSSTTTTTN | MARK: 10011111 (is_wumpus_very_near)
@ Prepare the stack by loading the number of links per room and decrementing.
@ We will loop until this reaches 0 or we find the wumpus.
SSSTSSSSSSSSSSTTN | PUSH 0x1003 (number_of_links_per_room address)
@ Check one nearby room on each pass through this loop.
@ TOS> tunnel_index, room_number
NSSVTSSTTTTTSSSSSSSSN | MARK: 10011111 00000000 (is_wumpus_very_near:loop)
NSTTTSSN | JSR > 1100 (deepdup)
NSTTSSSTSSSN | JSR > 10001000 (get_tunnel_destination)
NSTTSTSSSSSN | JSR > 10100000 (room_has_wumpus)
NTSTSSTTTTTSSSSSSSTN | BRZ > 10011111 00000001 (no_wumpus_in_this_room)
@ Found wumpus. Clean up and return.
NSSVTSSTTTTTSSSSSSSTN | MARK: 10011111 00000001 (no_wumpus_in_this_room)
NTSTSSTTTTTSSSSSSTSN | BRZ > 10011111 00000010 (is_wumpus_very_near:loop_end)
@ No wumpus found yet, but still need to check some rooms.
@ Decrement tunnel index and loop again.
NSNTSSTTTTTSSSSSSSSN | JMP > 10011111 00000000 (is_wumpus_very_near:loop)
@ No wumpus found in nearby rooms. Clean up and return.
NSSVTSSTTTTTSSSSSSTSN | MARK: 10011111 00000010 (is_wumpus_very_near:loop_end)
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@ Given a room number, checks rooms within two hops for the wumpus.
@ Returns 1 if wumpus is present, otherwise 0.
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
NSSVTSSTTTTSN | MARK: 10011110 (is_wumpus_near)
@ Prepare the stack by loading the number of links per room and decrementing.
@ We will loop until this reaches 0 or we find the wumpus.
SSSTSSSSSSSSSSTTN | PUSH 0x1003 (number_of_links_per_room address)
@ Check one nearby room and its connecting rooms on each pass through this loop.
@ TOS> tunnel_index, room_number
NSSVTSSTTTTSSSSSSSSSN | MARK: 10011110 00000000 (is_wumpus_near:loop)
NSTTTSSN | JSR > 1100 (deepdup)
NSTTSSSTSSSN | JSR > 10001000 (get_tunnel_destination)
@ TOS> tunnel_endpoint, tunnel_index, room_number
NSTTSTSSSSSN | JSR > 10100000 (room_has_wumpus)
NTSTSSTTTTSSSSSSSTTN | BRZ > 10011110 00000011 (found_wumpus_one_hop)
NSTTSSTTTTTN | JSR > 10011111 (is_wumpus_very_near)
NTSTSSTTTTSSSSSSTSSN | BRZ > 10011110 00000100 (found_wumpus_two_hops)
NTSTSSTTTTSSSSSSSTSN | BRZ > 10011110 00000010 (is_wumpus_near:loop_end)
@ No wumpus found yet, but still need to check some rooms.
@ Decrement tunnel index and loop again.
NSNTSSTTTTSSSSSSSSSN | JMP > 10011110 00000000 (is_wumpus_near:loop)
@ No wumpus found in nearby rooms. Clean up and return.
NSSVTSSTTTTSSSSSSSTSN | MARK: 10011110 00000010 (is_wumpus_near:loop_end)
@ Found wumpus. Clean up and return.
NSSVTSSTTTTSSSSSSSTTN | MARK: 10011110 00000011 (found_wumpus_one_hop)
NSSVTSSTTTTSSSSSSTSSN | MARK: 10011110 00000100 (found_wumpus_two_hops)