summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authormrb0nk500 <b0nk@b0nk.xyz>2019-12-17 16:43:39 -0500
committermrb0nk500 <b0nk@b0nk.xyz>2019-12-17 16:43:39 -0500
commit7948288a0b694215167da6d1dce315d4ef44dd7b (patch)
tree01a21ee206d1e36f0313bea80eb1fb2718b3f970 /test
parent0b81224b6ab8cd6da45039525962c6490ed2df56 (diff)
Revamped how the keyboard works.
It now does not use an interrupt, although, in the emulator, it does act like an interrupt, when the keypoll macro is set to 0.
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