diff options
| author | not_a_robot06 <temporarythrowaway@tutamail.com> | 2025-02-17 21:03:17 +0000 |
|---|---|---|
| committer | not_a_robot06 <temporarythrowaway@tutamail.com> | 2025-02-17 21:03:17 +0000 |
| commit | 96d1ec4bf3d8558490d5dd4fc217d8d17faeb9ce (patch) | |
| tree | b8aba43669a1ea06810caab469395e5b6b92e7b3 | |
| parent | 3fa7d73e70651dc90305f4f16a189bdd257b1c9d (diff) | |
| download | c64-life-96d1ec4bf3d8558490d5dd4fc217d8d17faeb9ce.tar.gz c64-life-96d1ec4bf3d8558490d5dd4fc217d8d17faeb9ce.tar.bz2 c64-life-96d1ec4bf3d8558490d5dd4fc217d8d17faeb9ce.zip | |
change code to deal with offsets from grid rather than addressing scren
memory directly from the get go
- this is so i can just store the current offset and modify the previous
generation and current generation in one go than changing two separate
variables
| -rw-r--r-- | life.asm | 71 |
1 files changed, 56 insertions, 15 deletions
@@ -3,12 +3,16 @@ 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 +num2L := $04 +num2H := $05 GETIN := $ffe4 CHROUT := $ffd2 CLRCHN := $e544 +; one byte for each cell, 1000 bytes because 40x25 screen; is identical to +; screen memory (i.e. $a0 is alive and $20 is dead) +prev_grid := $0801 + ; initialisation: clear screen and set num to point to screen mem start init: ; clear screen @@ -16,14 +20,14 @@ init: jsr CHROUT ldy #$00 - lda #$04 - sta numH lda #$00 + sta numH sta numL jsr CLRCHN jmp loop ; main loop +; num stores offset from grid loop: jsr GETIN beq loop @@ -68,8 +72,15 @@ if_reset: jmp loop if_space: - ldx #$00 - lda (numL,x) + lda numL + sta num2L + lda numH + clc + adc #$04 + sta num2H + + ldy #$00 + lda (num2L),y cmp #$a0 beq if_cell_filled jmp if_cell_empty @@ -82,21 +93,23 @@ if_cell_empty: jsr print_byte jmp loop -; print byte in A at location in num +; print byte in A at location in screen_mem+num; destroys Y; num2 is expected +; to be $0400 (screen_mem zero location) and is set to that at the end print_byte: - ; init: store original A in X and push Y to stack - tax - tya + tay + lda numH pha - txa + clc + adc #$04 + sta numH + + tya ldy #$00 sta (numL),y - ; deinit: pull Y from stack and transfer original A from X to A pla - tay - txa + sta numH rts ; adds A to num @@ -109,7 +122,17 @@ a16b: sta numH rts -; subtracts A from num +; adds A to num2 +a16b2: + clc + adc num2L + sta num2L + lda #$00 + adc num2H + sta num2H + rts + +; subtracts A from num (destroys X) s16b: pha lda numL @@ -124,6 +147,24 @@ s16b: pla rts +; might change functions to take from stack but this is easier for now as I +; only have 2 16 bit numbers to deal with anyways + +; subtracts A from num2 (destroys X) +s16b2: + pha + lda num2L + tsx + inx + sec + sbc $0100,x + sta num2L + lda num2H + sbc #$00 + sta num2H + pla + rts + inc_num: inc numL beq inc_H |
