From 46934dab1ba66b17a3dcf7021651ca0002c2cd3a Mon Sep 17 00:00:00 2001 From: jrhunger <1101010@gmail.com> Date: Sun, 18 Oct 2020 19:44:59 -0400 Subject: [PATCH] score and scrolling --- cart.asm | 92 +++++++++++++++++++++++++------------------- digitTableLeft.h | 17 ++++++++ digitTableLeftRev.h | 17 ++++++++ digitTableRight.h | 17 ++++++++ digitTableRightRev.h | 17 ++++++++ numberTables.h | 7 ++++ 6 files changed, 127 insertions(+), 40 deletions(-) create mode 100644 numberTables.h diff --git a/cart.asm b/cart.asm index c69aad6..04e95a9 100644 --- a/cart.asm +++ b/cart.asm @@ -29,6 +29,7 @@ Scroll2 byte ; (8a) digit 2 of scroll Scroll3 byte ; (8b) digit 3 of scroll Scroll4 byte ; (8c) digit 4 of scroll Score byte ; (8d) Actual Score +KeyIndex byte ; (8e) Index into digit key org $90 DigitOffsetL0 byte ; digit array offset for left digit 0 @@ -59,7 +60,7 @@ DigitOffsetR10 byte ; digit array offset for left digit 10 ; Pointer block org $b0 P0spritePtr word ; (b0/b1) y-adjusted sprite pointer -digitTablePointer word ; (b2/b3) pointer to digit table + ; Scroll Pointers ScrollPtr0 word ; (b4/b5) ScrollPtr1 word ; (b6/b7) @@ -71,7 +72,7 @@ ScrollPtr6 word ; (c0/c1) ScrollPtr7 word ; (c2/c3) ScorePtr0 word ; (c4/c5) ScorePtr1 word ; (c6/c7) - +KeyTablePtr word ; (c8/c9) Scroll5 byte ; (88) digit 0 of score Scroll6 byte ; (89) digit 1 of score @@ -112,8 +113,9 @@ Start: ;;; Initialize digits lda #$a0 ; blank sta DigitOffsetL4 ; initial hole 3 - lda #$00 ; 0 sta DigitOffsetL0 + sta DigitOffsetR0 + lda #$00 ; 0 sta DigitOffsetL1 sta DigitOffsetR10 lda #$10 ; 1 @@ -143,35 +145,22 @@ Start: lda #$90 sta DigitOffsetL10 sta DigitOffsetR1 - sta DigitOffsetR0 lda #$a0 -;;; Set digitTablePointer -; lda #digitTableRight - sta digitTablePointer+1 - -;; (temp) initialize score digits - lda #1 +;; initialize scroll digits + lda #$a ; blank sta Scroll0 - lda #2 sta Scroll1 - lda #3 sta Scroll2 - lda #4 sta Scroll3 - lda #5 + lda #3 ; start with pi 3. sta Scroll4 - lda #6 + lda #$b ; decimal point sta Scroll5 - lda #7 - sta Scroll6 - lda #10 ; blank - sta Scroll7 + +;; initalize score digits lda #0 ; score 10s sta Scroll8 - lda #0 ; score 1s sta Scroll9 ;; set up Scroll Pointers high bytes @@ -195,6 +184,10 @@ Start: lda #>P0bitmap sta P0spritePtr+1 +;;; Set key table to Pi digits initially + lda #>piTable + sta KeyTablePtr+1 + ;;; Initialize CTRLPF ; D0 = REF (reflect playfield) ; D1 - SCORE (color left/right of playfield like P0/P1) @@ -588,6 +581,16 @@ DigitCapture SUBROUTINE sta HoleIndex ; tya sta DigitOffsetL0,X ; store it in current hole +; check input digit vs key + tya + lsr + lsr + lsr + lsr + tax + ldy #0 + cmp (KeyTablePtr),Y + bne .IncorrectDigit ; ripple scroll digits lda Scroll1 sta Scroll0 @@ -599,14 +602,10 @@ DigitCapture SUBROUTINE sta Scroll3 lda Scroll5 sta Scroll4 - lda Scroll6 + txa sta Scroll5 - tya - lsr - lsr - lsr - lsr - sta Scroll6 +; increment lsb of KeyTablePtr + inc KeyTablePtr ; increment score clc sed @@ -614,6 +613,18 @@ DigitCapture SUBROUTINE adc #1 sta Score cld + jmp .IncorrectDone +.IncorrectDigit +; increment score + sec + sed + lda Score + sbc #1 + bmi .ScoreZero + sta Score +.ScoreZero + cld +.IncorrectDone RTS ;;; Load Scroll/Score Pointers based on corresponding values @@ -686,21 +697,11 @@ LoadScrollPointers SUBROUTINE include "digitTableLeft.h" include "digitTableRightRev.h" include "digitTableLeftRev.h" + include "numberTables.h" org $fef6 P0bitmap: ;;; pi bitmap - byte #%00000000 - byte #%11011111 - byte #%01010000 - byte #%01011000 - byte #%01000110 - byte #%01010010 - byte #%01001100 - byte #%01000000 - byte #%01111111 -/* -;;; sqrt(2) bitmap byte #%00000000 byte #%11000010 byte #%00100101 @@ -710,6 +711,17 @@ P0bitmap: byte #%00100100 byte #%00100100 byte #%11111111 +;;; sqrt(2) bitmap +/* + byte #%00000000 + byte #%11011111 + byte #%01010000 + byte #%01011000 + byte #%01000110 + byte #%01010010 + byte #%01001100 + byte #%01000000 + byte #%01111111 */ ;;;;;;;;;;;;;;;;;;;;;;;;;;;; diff --git a/digitTableLeft.h b/digitTableLeft.h index e39179f..9b5f135 100644 --- a/digitTableLeft.h +++ b/digitTableLeft.h @@ -187,3 +187,20 @@ .byte %00000000;| .byte %00000000;| .byte %00000000;| +; decimal + .byte %00000000;| + .byte %00000000;| + .byte %01000000;| + .byte %01000000;| + .byte %01000000;| + .byte %00000000;| + .byte %00000000;| + .byte %00000000;| + .byte %00000000;| + .byte %00000000;| + .byte %00000000;| + .byte %00000000;| + .byte %00000000;| + .byte %00000000;| + .byte %00000000;| + .byte %00000000;| diff --git a/digitTableLeftRev.h b/digitTableLeftRev.h index 859a4d4..2333105 100644 --- a/digitTableLeftRev.h +++ b/digitTableLeftRev.h @@ -187,3 +187,20 @@ .byte %00000000;| .byte %00000000;| .byte %00000000;| +; decimal + .byte %00000000;| + .byte %00000000;| + .byte %01000000;| + .byte %01000000;| + .byte %01000000;| + .byte %00000000;| + .byte %00000000;| + .byte %00000000;| + .byte %00000000;| + .byte %00000000;| + .byte %00000000;| + .byte %00000000;| + .byte %00000000;| + .byte %00000000;| + .byte %00000000;| + .byte %00000000;| diff --git a/digitTableRight.h b/digitTableRight.h index 5075c90..7c5fad3 100644 --- a/digitTableRight.h +++ b/digitTableRight.h @@ -187,3 +187,20 @@ .byte %00000000;| .byte %00000000;| .byte %00000000;| +; decimal + .byte %00000000;| + .byte %00000000;| + .byte %00000010;| + .byte %00000010;| + .byte %00000010;| + .byte %00000000;| + .byte %00000000;| + .byte %00000000;| + .byte %00000000;| + .byte %00000000;| + .byte %00000000;| + .byte %00000000;| + .byte %00000000;| + .byte %00000000;| + .byte %00000000;| + .byte %00000000;| diff --git a/digitTableRightRev.h b/digitTableRightRev.h index 7ac9c4d..659e221 100644 --- a/digitTableRightRev.h +++ b/digitTableRightRev.h @@ -187,3 +187,20 @@ .byte %00000000;| .byte %00000000;| .byte %00000000;| +; decimal + .byte %00000000;| + .byte %00000000;| + .byte %00000010;| + .byte %00000010;| + .byte %00000010;| + .byte %00000000;| + .byte %00000000;| + .byte %00000000;| + .byte %00000000;| + .byte %00000000;| + .byte %00000000;| + .byte %00000000;| + .byte %00000000;| + .byte %00000000;| + .byte %00000000;| + .byte %00000000;| diff --git a/numberTables.h b/numberTables.h new file mode 100644 index 0000000..baaff54 --- /dev/null +++ b/numberTables.h @@ -0,0 +1,7 @@ + align 128 +piTable: + byte 1,4,1,5,9,2,6,5,3,5,8,9,7,9,3,2,3,8,4,6 + byte 2,6,4,3,3,8,3,2,7,9,5,0,2,8,8,4,1,9,7,1 + byte 6,9,3,9,9,3,7,5,1,0,5,8,2,0,9,7,4,9,4,4 + byte 5,9,2,3,0,7,8,1,6,4,0,6,2,8,6,2,0,8,9,9 + byte 8,6,2,8,0,3,4,8,2,5,3,4,2,1,1,7,0,6,7,9