diff options
author | Alexey 'Cluster' Avdyukhin <clusterrr@clusterrr.com> | 2021-01-05 10:08:19 +0300 |
---|---|---|
committer | Alexey 'Cluster' Avdyukhin <clusterrr@clusterrr.com> | 2021-01-05 10:31:56 +0300 |
commit | 6629bbd2125d5488ae83b6aa21c231a2a51353e2 (patch) | |
tree | 649b88208d1b5c94d2e6502d4bfeebdc8aea3f54 /sounds.asm | |
parent | edbd71ea97a50f43a4c49d69a5c034894bc84d86 (diff) |
Using reserved register names, refactoring
Diffstat (limited to 'sounds.asm')
-rw-r--r-- | sounds.asm | 240 |
1 files changed, 121 insertions, 119 deletions
@@ -1,119 +1,121 @@ - ; cursor moving sound
-bleep:
- ; enable channel
- lda #%00000001
- sta $4015
- ; square 1
- lda #%10000111
- sta $4000
- ; sweep
- lda #%10001001
- sta $4001
- lda #%11110000
- ; timer
- sta $4002
- ; length counter and timer
- lda #%00001000
- sta $4003
- rts
-
- ; beep sound
-beep:
- ; enable channel
- lda #%00000100
- sta $4015
- ; triangle
- lda #%01000000
- sta $4008
- ; timer
- lda #%1000000
- sta $400A
- ; length counter and timer
- lda #%00001000
- sta $400B
- rts
-
- ; error sound
-error_sound:
- ; enable channel
- lda #%00000100
- sta $4015
- ; triangle
- lda #%01001111
- sta $4008
- ; timer
- lda #%00000000
- sta $400A
- ; length counter and timer
- lda #%11110011
- sta $400B
- rts
-
- ; game start sound
-start_sound:
- lda <KONAMI_CODE_STATE
- cmp konami_code_length
- beq start_sound_alt
-
- ;enable channel
- lda #%00000001
- sta $4015
- ;square 1
- lda #%00011111
- sta $4000
- ; sweep
- lda #%10011010
- sta $4001
- ; timer
- lda #%11111111
- sta $4002
- ; length counter and timer
- lda #%10010000
- sta $4003
- rts
-
- ; Konami Code sound
-start_sound_alt:
- ; enable channel
- lda #%00000001
- sta $4015
- ; square 1
- lda #%10011111
- sta $4000
- ; sweep
- lda #%10000011
- sta $4001
- ; timer
- lda #%00100000
- sta $4002
- ; length counter and timer
- lda #%11000000
- sta $4003
- rts
-
-wait_sound_end:
- lda $4015
- bne wait_sound_end
- rts
-
-reset_sound:
- lda #0
- sta $4000
- sta $4001
- sta $4002
- sta $4003
- sta $4004
- sta $4005
- sta $4006
- sta $4007
- sta $4008
- sta $4009
- sta $400A
- sta $4010
- sta $4011
- sta $4012
- sta $4013
- ldx #$40
- stx $4017 ; disable APU frame IRQ
- rts
-
\ No newline at end of file + ; cursor moving sound +bleep: + ; enable channel + lda #%00000001 + sta APUSTATUS + ; square 1 + lda #%10000111 + sta SQ1VOL + ; sweep + lda #%10001001 + sta SQ1SWEEP + lda #%11110000 + ; timer + sta SQ1LO + ; length counter and timer + lda #%00001000 + sta SQ1HI + rts + + ; beep sound +beep: + ; enable channel + lda #%00000100 + sta APUSTATUS + ; triangle + lda #%01000000 + sta TRILINEAR + ; timer + lda #%1000000 + sta TRILO + ; length counter and timer + lda #%00001000 + sta TRIHI + rts + + ; error sound +error_sound: + ; enable channel + lda #%00000100 + sta APUSTATUS + ; triangle + lda #%01001111 + sta TRILINEAR + ; timer + lda #%00000000 + sta TRILO + ; length counter and timer + lda #%11110011 + sta TRIHI + rts + + ; game start sound +start_sound: + lda <KONAMI_CODE_STATE + cmp konami_code_length + beq start_sound_alt + + ;enable channel + lda #%00000001 + sta APUSTATUS + ;square 1 + lda #%00011111 + sta SQ1VOL + ; sweep + lda #%10011010 + sta SQ1SWEEP + ; timer + lda #%11111111 + sta SQ1LO + ; length counter and timer + lda #%10010000 + sta SQ1HI + rts + + ; Konami Code sound +start_sound_alt: + ; enable channel + lda #%00000001 + sta APUSTATUS + ; square 1 + lda #%10011111 + sta SQ1VOL + ; sweep + lda #%10000011 + sta SQ1SWEEP + ; timer + lda #%00100000 + sta SQ1LO + ; length counter and timer + lda #%11000000 + sta SQ1HI + rts + +wait_sound_end: + lda APUSTATUS + bne wait_sound_end + rts + +reset_sound: + lda #0 + sta SQ1_VOL + sta SQ1_SWEEP + sta SQ1_LO + sta SQ1_HI + sta SQ2_VOL + sta SQ2_SWEEP + sta SQ2_LO + sta SQ2_HI + sta TRILINEAR + sta TRI_LO + sta TRI_HI + sta NOISE_VOL + sta NOISE_LO + sta NOISE_HI + sta DMC_FREQ + sta DMC_RAW + sta DMC_START + sta DMC_LEN + ldx #$40 + stx JOY2_FRAME ; disable APU frame IRQ + rts |