From d053a12c0ea1cf93919ac81b160e9ac8dc8c5b9c Mon Sep 17 00:00:00 2001 From: Nihilazo Date: Wed, 26 May 2021 16:51:12 +0100 Subject: [PATCH] fix overflows in input --- main.usm | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/main.usm b/main.usm index e6c08a3..296178f 100644 --- a/main.usm +++ b/main.usm @@ -112,25 +112,29 @@ RTN RTN @handle-cursor ( controller -- ) ( handles moving the cursor around ) - DUP #10 AND #00 NEQ ,&up JCN ( check the if the four directions are pressed ) + DUP #10 AND ,&up JCN ( check the if the four directions are pressed ) DUP #20 AND ,&down JCN DUP #40 AND ,&left JCN #80 AND ,&right JCN RTN ( if none are pressed, break ) &up + POP ( pop the controller ) #00 .Edit/selection-y LDZ EQU ,&end JCN .Edit/selection-y LDZ #01 SUB .Edit/selection-y STZ RTN &down - PTN_LEN #01 SUB .Edit/selection-y LDZ EQU ,&end JCN + POP2 + PTN_LEN #0001 SUB2 .Edit/selection-y LDZ EQU ,&end JCN .Edit/selection-y LDZ #01 ADD .Edit/selection-y STZ RTN &left + POP #00 .Edit/selection-x LDZ EQU ,&end JCN .Edit/selection-x LDZ #01 SUB .Edit/selection-x STZ RTN &right - PTN_WIDTH #01 SUB .Edit/selection-x LDZ EQU ,&end JCN + POP + PTN_WIDTH #0001 SUB2 .Edit/selection-x LDZ EQU ,&end JCN .Edit/selection-x LDZ #01 ADD .Edit/selection-x STZ &end RTN @@ -163,6 +167,7 @@ RTN ( switching patterns. TODO bounds checking. TODO move into seperate routine ) DUP #3e EQU ,&next JCN DUP #3c EQU ,&prev JCN + POP BRK &next POP