summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/input.s30
1 files changed, 22 insertions, 8 deletions
diff --git a/test/input.s b/test/input.s
index 9e5ef69..b699dda 100644
--- a/test/input.s
+++ b/test/input.s
@@ -18,7 +18,7 @@ end:
buffer:
; Main program
-.org $0
+.org $8000
reset:
cps
ldx.w #$FFFF
@@ -26,7 +26,7 @@ reset:
ldy #$0
clr_buf:
lda #$0
- cpy.w #$1000
+ cpy.w #$400
beq start
sta buffer, y
iny
@@ -37,20 +37,31 @@ start:
ldy #$0 ; Reset y.
jmp print
+rset_a:
+ lda #$10
+delay:
+ beq read
+ dec
+ jmp delay
sleep:
- wai ; Sleep until we get a character.
lda end
bne spin ; Are we done with getting input?
- jmp sleep ; Loop until we get a newline.
+read:
+ nop ; Sleep until we get a character.
+ lda $C000 ; Get control register.
+ beq rset_a ; Loop until we get a character.
+ lda #$0
+ sta $C000
+ jmp getchar ; We got a key.
print:
lda string, x ; Get character at offset x.
- beq sleep ; Did we find a null terminator?
+ beq rset_a ; Did we find a null terminator?
sta $C001 ; Print character.
inx ; Increment offset.
jmp print ; Keep printing more characters.
-irq_routine:
+getchar:
lda $C002 ; Get typed character.
cmp #$A
beq nl ; Did the user type a newline?
@@ -60,8 +71,8 @@ echo:
sta $C001 ; Echo typed character.
sta buffer, y ; Store typed character into the input buffer.
iny ; Increment buffer offset.
-return:
- rti ; End of interrupt routine.
+ nop
+ jmp rset_a ; We are not, so add the backspace to the buffer.
nl:
sta $C001
@@ -98,6 +109,7 @@ fin:
sta $C001 ; Print the newline.
lda #$1 ; Tell the program that we are done.
sta end ; We are done.
+ jmp sleep
spin:
@@ -122,6 +134,8 @@ spin:
.qword irq_routine
;.org $0
;viewmem
+;.org $100
+;viewmem
;q
done