summaryrefslogtreecommitdiff
path: root/life.asm
diff options
context:
space:
mode:
authornot_a_robot06 <temporarythrowaway@tutamail.com>2025-02-16 10:33:39 +0000
committernot_a_robot06 <temporarythrowaway@tutamail.com>2025-02-16 10:33:39 +0000
commit3fa7d73e70651dc90305f4f16a189bdd257b1c9d (patch)
treee134bd202e26d2e4cda261a343d3db5f6d82fede /life.asm
parent4db3c9071d5a22123f3ee0d49ce709c47c4a4a71 (diff)
downloadc64-life-3fa7d73e70651dc90305f4f16a189bdd257b1c9d.tar.gz
c64-life-3fa7d73e70651dc90305f4f16a189bdd257b1c9d.tar.bz2
c64-life-3fa7d73e70651dc90305f4f16a189bdd257b1c9d.zip
handle up/down cursor movement
- use GETIN kernal routine for handling input than my old crappy way - CLRCHN clears keyboard buffer before use - reset now clears screen - add subroutines a16b and s16b to add and subtract to num, respectively
Diffstat (limited to 'life.asm')
-rw-r--r--life.asm73
1 files changed, 41 insertions, 32 deletions
diff --git a/life.asm b/life.asm
index 2745dc6..44e3996 100644
--- a/life.asm
+++ b/life.asm
@@ -5,7 +5,9 @@ numL := $02 ; low byte of a 16-bit number
numH := $03 ; low byte of a 16-bit number
key_buf_len := $c6
key_buf := $0277
+GETIN := $ffe4
CHROUT := $ffd2
+CLRCHN := $e544
; initialisation: clear screen and set num to point to screen mem start
init:
@@ -18,17 +20,22 @@ init:
sta numH
lda #$00
sta numL
+ jsr CLRCHN
jmp loop
; main loop
loop:
- jsr key_wait
- lda key_buf
+ jsr GETIN
+ beq loop
cmp #$1d ; right arrow
beq if_right
cmp #$9d ; left arrow
beq if_left
+ cmp #$91 ; up arrow
+ beq if_up
+ cmp #$11 ; down arrow
+ beq if_down
cmp #$2d ; reset if - pressed
beq if_reset
cmp #$20 ; fill cell if space pressed
@@ -45,11 +52,19 @@ if_left:
jsr dec_num
jmp loop
+if_up:
+ lda #40
+ jsr s16b
+ jmp loop
+
+if_down:
+ lda #40
+ jsr a16b
+ jmp loop
+
if_reset:
- lda #$04
- sta numH
- lda #$00
- sta numL
+ lda #$93
+ jsr CHROUT
jmp loop
if_space:
@@ -67,20 +82,6 @@ if_cell_empty:
jsr print_byte
jmp loop
-
-; loops until keyboard buffer has any number of characters in it
-key_wait:
- pha
-key_wait_loop:
- lda key_buf_len ; shows how many keys are in key buffer
- cmp #$00
- beq key_wait_loop
-
- lda #$00
- sta key_buf_len
- pla
- rts
-
; print byte in A at location in num
print_byte:
; init: store original A in X and push Y to stack
@@ -98,22 +99,30 @@ print_byte:
txa
rts
-; adds A to num (16 bit) (NOT WORKING)
-; destroys: X
+; adds A to num
a16b:
+ clc
+ adc numL
+ sta numL
+ lda #$00
+ adc numH
+ sta numH
+ rts
+
+; subtracts A from num
+s16b:
pha
- tsx
lda numL
- adc $0100,x
+ tsx
+ inx
+ sec
+ sbc $0100,x
sta numL
- bcs a16b_carry
- jmp a16b_end
- a16b_carry:
- inc numH
- a16b_end:
- clc
- pla
- rts
+ lda numH
+ sbc #$00
+ sta numH
+ pla
+ rts
inc_num:
inc numL