Skip to content

Commit

Permalink
score and scrolling
Browse files Browse the repository at this point in the history
  • Loading branch information
jrhunger committed Oct 18, 2020
1 parent 70c9f7b commit 46934da
Show file tree
Hide file tree
Showing 6 changed files with 127 additions and 40 deletions.
92 changes: 52 additions & 40 deletions cart.asm
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -143,35 +145,22 @@ Start:
lda #$90
sta DigitOffsetL10
sta DigitOffsetR1
sta DigitOffsetR0
lda #$a0
;;; Set digitTablePointer
; lda #<digitTableRight
; sta 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
Expand All @@ -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)
Expand Down Expand Up @@ -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
Expand All @@ -599,21 +602,29 @@ 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
lda Score
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
Expand Down Expand Up @@ -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
Expand All @@ -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
*/

;;;;;;;;;;;;;;;;;;;;;;;;;;;;
Expand Down
17 changes: 17 additions & 0 deletions digitTableLeft.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;|
17 changes: 17 additions & 0 deletions digitTableLeftRev.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;|
17 changes: 17 additions & 0 deletions digitTableRight.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;|
17 changes: 17 additions & 0 deletions digitTableRightRev.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;|
7 changes: 7 additions & 0 deletions numberTables.h
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 46934da

Please sign in to comment.