From f0e3023da0dabbd199dedfd00b84deb75bca8578 Mon Sep 17 00:00:00 2001 From: Aaron Taylor Date: Tue, 25 Feb 2020 23:49:40 -0800 Subject: [PATCH] Added move_or_shoot function to Wumpus example. Finished main game loop in wump.pvvs. --- examples/wump/wump.pvvs | 6 ++++- examples/wump/wump_strings.pvvs | 4 +-- examples/wump/wump_ui.pvvs | 45 ++++++++++++++++++++++++++++++++- 3 files changed, 51 insertions(+), 4 deletions(-) diff --git a/examples/wump/wump.pvvs b/examples/wump/wump.pvvs index d5c5079..799b24e 100644 --- a/examples/wump/wump.pvvs +++ b/examples/wump/wump.pvvs @@ -33,4 +33,8 @@ NSTTSSTTSTTN | JSR > 10011011 (print_cave_description) @ Main game loop NSSVTSSTTSTSN | MARK: 10011010 (wump_loop) NSTTSTSSSSTN | JSR > 10100001 (print_room_stats) -NNN | TERMINATE +A"Move or shoot? (m-s)\n" +SSSSN | PUSH 0 (number of string substitutions) +NSTTSSSN | JSR > 1000 (printf) +NSTTSTSSSTSN | JSR > 10100010 (move_or_shoot) +NSNTSSTTSTSN | JMP > 10011010 (wump_loop) diff --git a/examples/wump/wump_strings.pvvs b/examples/wump/wump_strings.pvvs index 5b85906..d8cfb69 100644 --- a/examples/wump/wump_strings.pvvs +++ b/examples/wump/wump_strings.pvvs @@ -42,8 +42,8 @@ NSSVTTTTTTTTSSSSSTTTN | Mark: 11111111 00000111 (please_seed_rng) A"\n\n\n\nWelcome to Hunt the Wumpus!\n\nPlease press 16 keys to seed the RNG.\n |\n" NTN | RTS -NSSVTTTTTTTTSSSSTSSSN | Mark: 11111111 00001000 (problem_with_yes_no_answer) -A"I don't understand your answer; please enter 'y' or 'n'!\n" +NSSVTTTTTTTTSSSSTSSSN | Mark: 11111111 00001000 (problem_with_input) +A"I don't understand!\n" NTN | RTS NSSVTTTTTTTTSSSSTSSTN | Mark: 11111111 00001001 (instructions) diff --git a/examples/wump/wump_ui.pvvs b/examples/wump/wump_ui.pvvs index 455e30d..88ff4b0 100644 --- a/examples/wump/wump_ui.pvvs +++ b/examples/wump/wump_ui.pvvs @@ -58,6 +58,49 @@ TNSS | PUTCHAR TNSS | PUTCHAR NTN | RTS +@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ +@ Name: +@ move_or_shoot +@ Description: +@ Parse user input, branching to the appropriate subroutine to move or shoot. +@ This function does not perform any boundary checks/limits. +@ Call Stack: +@ +@ Return Stack: +@ +@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ +#include +NSSVTSTSSSTSN | MARK: 10100010 (move_or_shoot) + +NSTTSSTTSSTN | JSR > 10011001 (get_line) + +@ Examine the first character of the user input buffer for 'm' or 's'. +@ If character is something else, prompt user to try again. +SSSTTSSSSSSSSSSSSN | PUSH 0x3000 (USER_INPUT_BUFFER address) +TTT | LOAD +SSSSTTSTTSTN | PUSH 109 (ASCII 'm') +TSST | SUBTRACT +NTSTSTSSSTSSSSSSSSSN | BRZ > 10100010 00000000 (move) +SSSTTSSSSSSSSSSSSN | PUSH 0x3000 (USER_INPUT_BUFFER address) +TTT | LOAD +SSSSTTTSSTTN | PUSH 115 (ASCII 's') +TSST | SUBTRACT +NTSTSTSSSTSSSSSSSSTN | BRZ > 10100010 00000001 (shoot) +NSTTTTTTTTTSSSSTSSSN | JSR > 11111111 00001000 (problem_with_input) +SSSSN | PUSH 0 (number of string substitutions) +NSTTSSSN | JSR > 1000 (printf) +NSNTSTSSSTSN | JMP > 10100010 (move_or_shoot) + +@ User typed 'm' +NSSVTSTSSSTSSSSSSSSSN | MARK: 10100010 00000000 (move) +@ TODO: JSR move +NTN | RTS + +@ User typed 's' +NSSVTSTSSSTSSSSSSSSTN | MARK: 10100010 00000001 (shoot) +@ TODO: JSR shoot +NTN | RTS + @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ @ Name: @ get_answer @@ -90,7 +133,7 @@ TTT | LOAD SSSSTTSTTTSN | PUSH 110 (ASCII 'n') TSST | SUBTRACT NTSTSSTTSSSSSSSSSSTN | BRZ > 10011000 00000001 (answer: no) -NSTTTTTTTTTSSSSTSSSN | JSR > 11111111 00001000 (problem_with_yes_no_answer) +NSTTTTTTTTTSSSSTSSSN | JSR > 11111111 00001000 (problem_with_input) SSSSN | PUSH 0 (number of string substitutions) NSTTSSSN | JSR > 1000 (printf) NSNTSSTTSSSN | JMP > 10011000 (get_answer) -- 2.20.1