diff options
Diffstat (limited to 'life.asm')
| -rw-r--r-- | life.asm | 73 |
1 files changed, 41 insertions, 32 deletions
@@ -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 |
