~rabbits/spacetime

cf0d59249e5d309fbb2ae2d72ffada5faaf66ec6 — Devine Lu Linvega 4 years ago 85fea24
Implemented most things
1 files changed, 116 insertions(+), 12 deletions(-)

M src/cart.asm
M src/cart.asm => src/cart.asm +116 -12
@@ 13,7 13,7 @@

PPUCTRL             .equ $2000 
PPUMASK             .equ $2001 
PPUSTATUS           .equ $2002 ; Using BIT PPUSTATUS preserves the previous contents of A.
PPUSTATUS           .equ $2002 
SPRADDR             .equ $2003 
PPUSCROLL           .equ $2005 
PPUADDR             .equ $2006 


@@ 51,8 51,6 @@ BUTTON_A            .equ #$80
;; variables

	.enum $0000
rate                    .dsb 1 
timer                   .dsb 1 
position                .dsb 1 
cursor                  .dsb 1 
note                    .dsb 1 


@@ 61,6 59,9 @@ selection               .dsb 1
down@input              .dsb 1 
last@input              .dsb 1 
next@input              .dsb 1 
rate                    .dsb 1 
timer                   .dsb 1 
seed                    .dsb 1 
	.ende 

;; reset


@@ 289,9 290,6 @@ RedrawOctave:
	JSR DrawAt
	RTS 

RedrawLine:
	RTS 

RedrawTimeline:
	LDX #$00
@loop:                         ;


@@ 330,6 328,110 @@ DrawAt:                        ; (a:id,x,y)
	STA PPUDATA
	RTS 

DoIncNote:
	INC note
	LDA note
	CMP #$0c
	BNE @done
	LDA #$00
	STA note
@done:
	JMP DoOperationEnd

DoDecNote:
	DEC note
	LDA note
	CMP #$ff
	BNE @done
	LDA #$0b
	STA note
@done:
	JMP DoOperationEnd

DoIncOctave:
	INC octave
	LDA octave
	CMP #$08
	BCC @done
	LDA #$00
	STA octave
@done:
	JMP DoOperationEnd

DoDecOctave:
	DEC octave
	LDA octave
	CMP #$ff
	BNE @done
	LDA #$08
	STA octave
@done:
	JMP DoOperationEnd

DoRandomNote:
	LDA seed
@loop:
	SEC 
	SBC #$0c
	CMP #$0c
	BCS @loop
	STA note
	INC seed
	JMP DoOperationEnd

DoIncMetro:
	INC rate
	LDA rate
	CMP #$08
	BCC @done
	LDA #$01
	STA rate
@done:
	JMP DoOperationEnd

DoDecMetro:
	DEC rate
	LDA rate
	CMP #$00
	BNE @done
	LDA #$08
	STA rate
@done:
	JMP DoOperationEnd

DoRandomPosition:
	LDA seed
@loop:
	SEC 
	SBC #$10
	CMP #$10
	BCS @loop
	STA position
	JMP DoOperationEnd

DoOperation:
	LDX position
	LDA $10,x
	CMP #$00                     ;
	BEQ DoIncNote
	CMP #$01
	BEQ DoDecNote
	CMP #$02
	BEQ DoIncOctave
	CMP #$03
	BEQ DoDecOctave
	CMP #$04
	BEQ DoRandomNote
	CMP #$05
	BEQ DoIncMetro
	CMP #$06
	BEQ DoDecMetro
	CMP #$07
	BEQ DoRandomPosition

DoOperationEnd:
	RTS 

;; nmi phase

NMI:                           ;


@@ 361,13 463,15 @@ SaveJoy:                       ; [skip]
	STA $4014                    ; set the high byte (02) of the RAM address, start the transfer

RunTimer:
	INC seed
	INC timer
	; check if timer has reached rate
	LDA timer
	CMP rate
	BNE @done
	BNE @done                    ; skip if timer is less than rate
	LDA #$00
	STA timer
	STA timer                    ; reset timer
	JSR DoOperation
	INC position
	; check if position has reached 16
	LDA position


@@ 377,9 481,7 @@ RunTimer:
	STA position
@done:

RunOperator:
@done:
	; cleanup
Cleanup:
	JSR Redraw
	LDA PPUSTATUS
	LDA #$00                     ; No background scrolling


@@ 400,7 502,9 @@ TimelinePositions:

Sequence:
	; .db $00,$01,$05,$01,$02,$06,$03,$04,$00,$01,$05,$01,$02,$06,$03,$07
	.db $00,$01,$02,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00
	; .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

;; Vectors