tests - finish WIP - Make a 'move a pixel with the keypad' program

This commit is contained in:
n loewen 2023-08-26 14:56:01 +01:00
parent 86d0b57c7a
commit ac0fccf2e9
1 changed files with 40 additions and 19 deletions

View File

@ -1,18 +1,13 @@
; Draw a pixel, and move it when a key is pressed ; Draw a pixel, and move it when a key is pressed
; 2023-08-26 ; 2023-08-26
;; WIP - up and right should be working,
;; but currently they're being tested with a
;; faked keyboard input at the end of @xy2id
;; (and down and left are still TODO)
#flagZ 1 #flagZ 1
#flagN 2 #flagN 2
#keypad $1B ; contains latest key pressed #keypad $1B ; contains latest key pressed
; Starting (x, y) coordinates ; Starting (x, y) coordinates
#input_x 1 #input_x 0
#input_y 2 #input_y 0
; Some handy shortcuts ; Some handy shortcuts
#x $FA #x $FA
@ -59,6 +54,13 @@
fhp #flagZ fhp #flagZ
jmp @up jmp @up
; test left
lda (#keypad)
sub #left
ftg #flagZ
fhp #flagZ
jmp @left
; test right ; test right
lda (#keypad) lda (#keypad)
sub #right sub #right
@ -66,8 +68,16 @@
fhp #flagZ fhp #flagZ
jmp @right jmp @right
; TODO: down, left ; test down
end lda (#keypad)
sub #down
ftg #flagZ
fhp #flagZ
jmp @down
;; no key pressed...
jmp @stay_put
@up @up
lda (#y) lda (#y)
@ -76,9 +86,15 @@
fhp #flagN fhp #flagN
jmp @stay_put jmp @stay_put
sto #y sto #y
; redundant - it's already in there: jmp @xy2id
lda @update
sto #return_addr_ptr @left
lda (#x)
sub 1
ftg #flagN
fhp #flagN
jmp @stay_put
sto #x
jmp @xy2id jmp @xy2id
@right @right
@ -90,9 +106,17 @@
lda (#x) lda (#x)
add 1 add 1
sto #x sto #x
; redundant - it's already in there: jmp @xy2id
lda @update
sto #return_addr_ptr @down
lda (#y)
sub 4
ftg #flagZ
fhp #flagZ
jmp @stay_put
lda (#y)
add 1
sto #y
jmp @xy2id jmp @xy2id
@stay_put @stay_put
@ -100,7 +124,7 @@
LDA $FF LDA $FF
STO (#px_addr) STO (#px_addr)
; TODO ; TODO
END ; END
;; Convert a pair of (x, y) coords ;; Convert a pair of (x, y) coords
@ -138,7 +162,4 @@
STO #xy2id_y STO #xy2id_y
FHP #flagZ FHP #flagZ
JMP @xy2id_loop JMP @xy2id_loop
;; JUST TO TEST: LOAD #up INTO KEYPAD MEM:
lda #right
sto #keypad
JMP (#return_addr_ptr) JMP (#return_addr_ptr)