~rabbits/donsol

013f0d6a1e95e0fcafec8e882ec52821996c8a94 — Devine Lu Linvega 1 year, 1 month ago 542c87a
Started adding sounds
8 files changed, 115 insertions(+), 29 deletions(-)

M src/cart.asm
M src/game.asm
M src/head.asm
M src/init.asm
M src/main.asm
M src/nmi.asm
M src/room.asm
A src/sound.asm
M src/cart.asm => src/cart.asm +1 -0
@@ 23,6 23,7 @@ __NMI:                         ;

;; includes

	INCLUDE "src/sound.asm"
	INCLUDE "src/helpers.asm"
	INCLUDE "src/splash.asm"
	INCLUDE "src/game.asm"

M src/game.asm => src/game.asm +3 -0
@@ 1,10 1,13 @@

;; Game

show@game:                     ;
	LDA #$01
	STA reqdraw_game
	STA reqdraw_cursor
	STA view@game                ; set view
	JSR restart@game             ; restart
	JSR Enter@sound
	RTS 

restart@game:                  ;

M src/head.asm => src/head.asm +9 -1
@@ 17,8 17,16 @@ SPRADDR             .equ $2003
PPUSCROLL           .equ $2005 
PPUADDR             .equ $2006 
PPUDATA             .equ $2007 
APUCH1VOL           .equ $4000 ; APU
APUCH1SWP           .equ $4001 
APUCH1FRQ           .equ $4002 
APUCH1LEN           .equ $4003 
APUCH2VOL           .equ $4004 
APUCH2SWP           .equ $4005 
APUCH2FRQ           .equ $4006 
APUCH2LEN           .equ $4007 
SPRDMA              .equ $4014 
SNDCHN              .equ $4015 
APUCTRL             .equ $4015 
JOY1                .equ $4016 
JOY2                .equ $4017 
BUTTON_RIGHT        .equ #$01 

M src/init.asm => src/init.asm +1 -0
@@ 51,4 51,5 @@ loadPalette:                   ; [skip]

;; Run tests

	JSR Init@sound
	; JSR run@tests

M src/main.asm => src/main.asm +5 -4
@@ 1,8 1,5 @@

;; main


;; timers
;; Main

handleTimer:                   ; when auto@room is 1, do post flip actions
	LDA auto@room


@@ 67,6 64,7 @@ onRight@splash:                ;
@done:                         ;
	LDA #$01                     ; request draw for cursor
	STA reqdraw_cursor
	JSR MoveAlt@sound
	JMP __MAIN

onLeft@splash:                 ;


@@ 80,6 78,7 @@ onLeft@splash:                 ;
@done:                         ;
	LDA #$01                     ; request draw for cursor
	STA reqdraw_cursor
	JSR MoveAlt@sound
	JMP __MAIN

onB@splash:                    ;


@@ 106,6 105,7 @@ onRight@game:                  ;
	LDA #$01                     ; request draw for cursor
	STA reqdraw_cursor
	STA reqdraw_name
	JSR Move@sound
	JMP __MAIN

onLeft@game:                   ;


@@ 120,6 120,7 @@ onLeft@game:                   ;
	LDA #$01                     ; request draw for cursor
	STA reqdraw_cursor
	STA reqdraw_name
	JSR Move@sound
	JMP __MAIN

onSelect@game:                 ;

M src/nmi.asm => src/nmi.asm +21 -24
@@ 1,16 1,13 @@

;; nmi
;; NMI


;; detect joy

readJoy:                       ; [skip]
readJoy:
	LDA #$01
	STA JOY1                     ; start reading
	STA down@input
	LSR a
	STA JOY1
@loop:                         ;
@loop:
	LDA JOY1
	LSR a
	ROL down@input


@@ 24,22 21,22 @@ saveJoy:                       ; [skip]
	CMP #$00
	BEQ @done
	STA next@input
@done:                         ;
@done:

;; route screens

sendView:                      ;
sendView:
	LDX view@game
	CPX #$00
	BNE viewGame

viewSplash:                    ;
@splashScreen:                 ;
viewSplash:
@splashScreen:
	LDA reqdraw_splash           ; splash-screen
	CMP #$01
	BNE @splashCursor
	JMP redrawScreen@splash
@splashCursor:                 ;
@splashCursor:
	LDA reqdraw_cursor           ; splash-cursor
	CMP #$01
	BNE @done


@@ 47,65 44,65 @@ viewSplash:                    ;
@done:
	RTI 

viewGame:                      ;
viewGame:
	JSR animateTimer@game
	JSR interpolateStats@game
@checkReqGame:                 ;
@checkReqGame:
	LDA reqdraw_game
	CMP #$01
	BNE @checkReqSP
	JMP redrawScreen@game
@checkReqSP:                   ; [skip]
@checkReqSP:
	LDA redraws@game
	AND REQ_SP
	BEQ @checkReqHP
	JMP redrawShield@game
@checkReqHP:                   ;
@checkReqHP:
	LDA redraws@game
	AND REQ_HP
	BEQ @checkReqCursor
	JMP redrawHealth@game
@checkReqCursor:               ;
@checkReqCursor:
	LDA reqdraw_cursor
	CMP #$01
	BNE @checkName
	JMP redrawCursor@game
@checkName:                    ;
@checkName:
	LDA reqdraw_name
	CMP #$01
	BNE @checkReqCard1
	JMP redrawName@game
@checkReqCard1:                ;
@checkReqCard1:
	LDA redraws@game
	AND REQ_CARD1
	BEQ @checkReqCard2
	JMP redrawCard1@game
@checkReqCard2:                ;
@checkReqCard2:
	LDA redraws@game
	AND REQ_CARD2
	BEQ @checkReqCard3
	JMP redrawCard2@game
@checkReqCard3:                ;
@checkReqCard3:
	LDA redraws@game
	AND REQ_CARD3
	BEQ @checkReqCard4
	JMP redrawCard3@game
@checkReqCard4:                ;
@checkReqCard4:
	LDA redraws@game
	AND REQ_CARD4
	BEQ @checkReqXP
	JMP redrawCard4@game
@checkReqXP:                   ;
@checkReqXP:
	LDA redraws@game
	AND REQ_XP
	BEQ @checkReqRun
	JMP redrawExperience@game
@checkReqRun:                  ;
@checkReqRun:
	LDA redraws@game
	AND REQ_RUN
	BEQ @checkReqDialog
	JMP redrawRun@game
@checkReqDialog:               ;
@checkReqDialog:
	LDA reqdraw_dialog
	CMP #$01
	BNE @done

M src/room.asm => src/room.asm +2 -0
@@ 27,6 27,7 @@ enter@room:                    ;
	; new draws
	LDA #%11111111
	STA redraws@game
	JSR Enter@sound
	RTS 

;; flip card from the table, used in controls when press


@@ 60,6 61,7 @@ flipCard@room:                 ; (x:card_pos) ->
	; start timer
	LDA #$20                     ; timer length before running flipPost@room
	STA timer@room
	JSR Select@sound
@skip:
	RTS 


A src/sound.asm => src/sound.asm +73 -0
@@ 0,0 1,73 @@

;; Sound

Init@sound:
	LDA #%00000011               ; ch1 + ch2
	STA APUCTRL
	RTS 

Move@sound:
	PHA 
	LDA #%10011000
	STA APUCH1VOL
	LDA #$A9
	STA APUCH1FRQ
	LDA #%00011010
	STA APUCH1LEN
	PLA 
	RTS 

MoveAlt@sound:
	PHA 
	LDA #%10011000
	STA APUCH1VOL
	LDA #$A9
	STA APUCH1FRQ
	LDA #%00011011
	STA APUCH1LEN
	PLA 
	RTS 

Select@sound:
	PHA 
	LDA #%10011000
	STA APUCH2VOL
	LDA #$31
	STA APUCH2FRQ
	LDA #%00011010
	STA APUCH2LEN
	PLA 
	RTS 

Enter@sound:
	PHA 
	LDA #%10011000
	STA APUCH2VOL
	LDA #$21
	STA APUCH2FRQ
	LDA #%00111010
	STA APUCH2LEN
	PLA 
	RTS 

Error@sound:
	PHA 
	LDA #%10011000
	STA APUCH1VOL
	LDA #$A9
	STA APUCH1FRQ
	LDA #%00011010
	STA APUCH1LEN
	PLA 
	RTS 

Cancel@sound:
	PHA 
	LDA #%10011000
	STA APUCH1VOL
	LDA #$A9
	STA APUCH1FRQ
	LDA #%00011010
	STA APUCH1LEN
	PLA 
	RTS