@@ -73,6 +73,12 @@ copyToApuChannel:
7373 ldy #$00
7474@copyByte:
7575 lda (AUDIOTMP3),y
76+ .if SWAP_DUTY_CYCLES
77+ cpy #0
78+ bne @notFirstByte
79+ jsr swapDutyCycles
80+ @notFirstByte:
81+ .endif
7682 sta (AUDIOTMP1),y
7783 iny
7884 tya
@@ -137,15 +143,9 @@ advanceAudioSlotFrame:
137143 sta soundEffectSlot0FrameCounter,x
138144@ret: rts
139145
140- unreferenced_data3:
141- .byte $FF ,$FF ,$FF ,$FF ,$FF ,$FF ,$FF ,$FF
142- .byte $FF ,$FF ,$FF ,$FF ,$FF ,$FF ,$FF ,$FF
143- .byte $FF ,$FF ,$FF ,$FF ,$FF ,$FF ,$FF ,$FF
144- .byte $00 ,$00 ,$00 ,$00 ,$00 ,$00 ,$00 ,$00
145- .byte $00 ,$00 ,$00 ,$00 ,$00 ,$00 ,$00 ,$00
146- .byte $00 ,$00 ,$00 ,$00 ,$00 ,$00 ,$00 ,$00
147- .byte $00 ,$00 ,$00 ,$00 ,$00 ,$00 ,$00 ,$00
148- .byte $03 ,$7F ,$0F ,$C0
146+ .align $100
147+ .byte $00 ; pad so low byte is not zero. See tya in initSoundEffectShared
148+
149149; Referenced by initSoundEffectShared
150150soundEffectSlot0_gameOverCurtainInitData:
151151 .byte $1F ,$7F ,$0F ,$C0
@@ -473,6 +473,9 @@ soundEffectSlot1_chirpChirpPlaying:
473473 and #$03
474474 tay
475475 lda soundEffectSlot1_chirpChirpSq1Vol_table,y
476+ .if SWAP_DUTY_CYCLES
477+ jsr swapDutyCycles
478+ .endif
476479 sta SQ1_VOL
477480 inc soundEffectSlot1SecondaryCounter
478481 lda soundEffectSlot1SecondaryCounter
@@ -623,6 +626,10 @@ LE442: jsr copyToSq1Channel
623626 sta SQ1_LO
624627 ldy soundEffectSlot1SecondaryCounter
625628 lda sq1vol_unknown2_table,y
629+ .if SWAP_DUTY_CYCLES
630+ jsr swapDutyCycles
631+ tay ; set z flag based on a; y can be safely clobbered
632+ .endif
626633 sta SQ1_VOL
627634 bne LE46F
628635 lda soundEffectSlot1Playing
@@ -1070,6 +1077,9 @@ updateMusicFrame_setChanVol:
10701077 bne @ret
10711078 tya
10721079 ldy musicChannelOffset
1080+ .if SWAP_DUTY_CYCLES
1081+ jsr swapDutyCycles
1082+ .endif
10731083 sta SQ1_VOL,y
10741084@ret: rts
10751085
@@ -1350,6 +1360,9 @@ updateMusicFrame_updateChannel:
13501360@useDirectVolume:
13511361 lda AUDIOTMP1
13521362@setMmio:
1363+ .if SWAP_DUTY_CYCLES
1364+ jsr swapDutyCycles
1365+ .endif
13531366 sta SQ1_VOL,y
13541367 lda musicStagingSq1Sweep,x
13551368 sta SQ1_SWEEP,y
@@ -1462,6 +1475,15 @@ musicGetNextInstructionByte:
14621475 lda (musicChanTmpAddr),y
14631476 rts
14641477
1478+ .if SWAP_DUTY_CYCLES
1479+ ; input a: byte to be written to $4000 or $4004. output a: the same byte with the duty cycle index mapped from (0, 1, 2, 3) to (0, 2, 1, 3), counteracting the behavior of some clone consoles
1480+ swapDutyCycles:
1481+ cmp #%01000000
1482+ bmi @ret ; branch if upper bits are not %01 or %10
1483+ eor #%11000000 ; swap between %01 and %10
1484+ @ret: rts
1485+ .endif
1486+
14651487musicChanVolControlTable:
14661488noteToWaveTable:
14671489noteDurationTable:
0 commit comments