@@ 55,7 55,6 @@ position .dsb 1
cursor .dsb 1
note .dsb 1
octave .dsb 1
-selection .dsb 1
down@input .dsb 1
last@input .dsb 1
next@input .dsb 1
@@ 130,14 129,6 @@ SetupAttributes:
CPX #$40
BNE @loop
-SetupVariables:
- LDA #$08
- STA rate
- LDA #$01
- STA note
- LDA #$03
- STA octave
-
SetupSequence:
LDX #$00
@loop:
@@ 147,7 138,15 @@ SetupSequence:
CPX #$10
BNE @loop
-SetupPlayer:
+SetupVariables:
+ LDA #$08
+ STA rate
+ LDA #$01
+ STA note
+ LDA #$03
+ STA octave
+
+SetupSprite:
LDA #$88
ADC timer
STA $0200 ; set tile.y pos
@@ 170,7 169,6 @@ EnableSprites:
;; main phase
MAIN:
- ; route inputs
LDA next@input
CMP BUTTON_LEFT
BEQ MoveLeft
@@ 192,11 190,8 @@ MoveLeft:
; wrap around
LDA #$0f
STA cursor
-@done: ;
- LDA #$00
- STA next@input
- STA RedrawTimeline
- JMP MAIN
+@done:
+ JMP MoveEnd
MoveRight:
INC cursor
@@ 206,11 201,8 @@ MoveRight:
; wrap around
LDA #$00
STA cursor
-@done: ;
- LDA #$00
- STA next@input
- STA RedrawTimeline
- JMP MAIN
+@done:
+ JMP MoveEnd
MoveDown:
LDX cursor
@@ 221,11 213,8 @@ MoveDown:
; wrap around
LDA #$07
STA $10,x
-@done: ;
- LDA #$00
- STA next@input
- STA RedrawTimeline
- JMP MAIN
+@done:
+ JMP MoveEnd
MoveUp:
LDX cursor
@@ 236,7 225,10 @@ MoveUp:
; wrap around
LDA #$00
STA $10,x
-@done: ;
+@done:
+ JMP MoveEnd
+
+MoveEnd:
LDA #$00
STA next@input
STA RedrawTimeline
@@ 244,7 236,31 @@ MoveUp:
;; interface
-RedrawPlayer:
+RedrawTimeline:
+ LDX #$00
+@loop: ;
+ LDA #$22 ; v pos
+ STA PPUADDR
+ LDA TimelinePositions, x ; x pos
+ STA PPUADDR
+ LDA #$10, x
+ CLC
+ ADC #$10
+ ; selection
+ CPX cursor
+ BNE @continue
+ CLC
+ ADC #$08
+@continue:
+ STA PPUDATA ; sprite id
+ INX
+ CPX #$10
+ BNE @loop
+ RTS
+
+RedrawInterface:
+ LDA PPUSTATUS
+ ; RedrawSprite
LDA position
ASL
ASL
@@ 252,74 268,34 @@ RedrawPlayer:
CLC
ADC #$40
STA $0203 ; set tile.x pos
- RTS
-
-RedrawPosition:
+ ; RedrawPosition
LDA position
CLC
ADC #$20
LDX #$48
LDY #$22
JSR DrawAt
- RTS
-
-RedrawRate:
+ ; RedrawRate
LDA rate
CLC
ADC #$20
LDX #$49
LDY #$22
JSR DrawAt
- RTS
-
-RedrawNote:
- LDA note
- CLC
- ADC #$30
- LDX #$4a
- LDY #$22
- JSR DrawAt
- RTS
-
-RedrawOctave:
+ ; RedrawOctave
LDA octave
CLC
ADC #$20
LDX #$4b
LDY #$22
JSR DrawAt
- RTS
-
-RedrawTimeline:
- LDX #$00
-@loop: ;
- LDA #$22 ; v pos
- STA PPUADDR
- LDA TimelinePositions, x ; x pos
- STA PPUADDR
- LDA #$10, x
- CLC
- ADC #$10
- ; selection
- CPX cursor
- BNE @continue
+ ; RedrawNote
+ LDA note
CLC
- ADC #$08
-@continue:
- STA PPUDATA ; sprite id
- INX
- CPX #$10
- BNE @loop
- RTS
-
-Redraw:
- LDA PPUSTATUS
- JSR RedrawTimeline
- JSR RedrawPlayer
- JSR RedrawPosition
- JSR RedrawRate
- JSR RedrawOctave
- JSR RedrawNote
+ ADC #$30
+ LDX #$4a
+ LDY #$22
+ JSR DrawAt
RTS
DrawAt: ; (a:id,x,y)
@@ 448,7 424,7 @@ ReadJoy:
ROL down@input
BCC @loop
-SaveJoy: ; [skip]
+SaveJoy:
LDA down@input
CMP last@input
BEQ @done
@@ 482,14 458,15 @@ RunTimer:
@done:
Cleanup:
- JSR Redraw
+ JSR RedrawTimeline
+ JSR RedrawInterface
LDA PPUSTATUS
LDA #$00 ; No background scrolling
STA PPUSCROLL
STA PPUSCROLL
RTI ; return from interrupt
-;; Tables
+;; tables
.org $E000
@@ 503,8 480,8 @@ TimelinePositions:
Sequence:
; .db $00,$01,$05,$01,$02,$06,$03,$04,$00,$01,$05,$01,$02,$06,$03,$07
; .db $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00
- ; .db $01,$01,$01,$01,$01,$01,$01,$01,$01,$01,$01,$01,$01,$01,$01,$01
- .db $04,$04,$04,$04,$04,$04,$04,$04,$04,$04,$04,$04,$04,$04,$04,$04
+ .db $01,$01,$01,$01,$01,$01,$01,$01,$01,$01,$01,$01,$01,$01,$01,$01
+ ; .db $04,$04,$04,$04,$04,$04,$04,$04,$04,$04,$04,$04,$04,$04,$04,$04
;; Vectors