@@ -89,14 +89,12 @@ ColourCycle ds 1 ; used for pause screen
89
89
; these point to memory locations that are to be played when music is on
90
90
; music should be input in reverse order because of the way the counter works!
91
91
SoundEnabled ds 1 ; set to how many frames are to be played
92
+ SoundEnabled2 ds 1
92
93
SoundTrackPtr ds 2 ; points to sound to be played
93
- SoundVolumePtr ds 1 ; points to volume for the track
94
+ SoundTrackPtr2 ds 2 ; points to sound to be played
94
95
SoundSpeed ds 1 ; speed of sound
95
-
96
- NoiseEnabled ds 1 ; set to amount of frames to play noise
97
- NoiseTrackPtr ds 2 ; points to noise to be played
98
- NoiseVolumePtr ds 1 ; points to volume for the track
99
- NoiseSpeed ds 1 ; speed of noise
96
+ SoundControl ds 2 ; sound control
97
+ SoundControl2 ds 2 ; sound control
100
98
101
99
; used by Random for an 8 bit random number
102
100
Rand8 ds 1
@@ -121,13 +119,11 @@ MAPCOUNT = 4
121
119
OFFSETPERMAP = 6
122
120
123
121
; music volumes
124
- LEVELCLEARVOLUME = $09
125
- FOODCOLLECTEDVOLUME = $09
126
- BIRDHITPLAYERVOLUME = $09
127
122
128
123
; music speed
129
- S_HALFSPEED = $1 ; and fore very other frame
130
- S_QUARTERSPEED = %11111 ; and for every 4th frame
124
+ ;S_FULLSPEED = 0 ; no delay at all
125
+ ;S_HALFSPEED = $1 ; and fore very other frame
126
+ ;S_QUARTERSPEED = %11111 ; and for every 4th frame
131
127
132
128
;===============================================================================
133
129
; Define Start of Cartridge
@@ -247,7 +243,9 @@ VerticalBlank
247
243
jsr SetObjectColours
248
244
249
245
jsr PrepScoreForDisplay
250
- jsr NoiseHandle
246
+ ldx #0 ; channel 1
247
+ jsr SoundHandle
248
+ ldx #1 ; channel 2
251
249
jsr SoundHandle
252
250
rts
253
251
@@ -623,8 +621,8 @@ leftRightBirdMoveDone
623
621
624
622
GameProgress
625
623
; first we check if required maps for next level have been reached
626
- ldx Level
627
- inx ; maps for level are always Level+1
624
+ ldx Level ; maps for level are always Level
625
+ ; inx ; maps for level are always Level+1
628
626
cpx MapsCleared ; if it is the same next level
629
627
beq NextLevelProg
630
628
ldx Score
@@ -792,122 +790,120 @@ CollisionDone
792
790
sta CXCLR ; clear collision
793
791
rts
794
792
795
- NoiseHandle
796
- ldx NoiseEnabled
797
- cpx #0 ; if it is 0, clear song and return
798
- beq ClearNoiseSet
799
- jsr Noise ; else we call sound
800
- rts
801
- ClearNoiseSet
802
- jsr ClearNoise
803
- rts
804
-
805
793
; Plays the Intro noise
806
794
SoundHandle
807
- ldx SoundEnabled
808
- cpx #0 ; if it is 0, clear song and return
795
+ ldy SoundEnabled,x
796
+ cpy #0 ; if it is 0, clear song and return
809
797
beq ClearSongSet
810
798
jsr Sound ; else we call sound
811
799
rts
812
800
ClearSongSet
813
801
jsr ClearSong
814
802
rts
815
803
816
- Noise
817
- ldy SoundEnabled
818
- sty AUDC1
819
- lda (NoiseTrackPtr),y
820
- sta AUDF1
821
-
822
- lda NoiseVolumePtr
823
- sta AUDV1
824
-
825
- ; dec every 2nd frame
826
- lda Framecount
827
- and NoiseSpeed
828
- beq DoNotDecNoise
829
- dec NoiseEnabled
830
- DoNotDecNoise
831
- rts
832
-
833
804
Sound
834
- ldy SoundEnabled
835
- sty AUDC0
805
+ ldy SoundEnabled,x
806
+ cpx #0
807
+ bne LoadTrackPtr2
836
808
lda (SoundTrackPtr),y
837
- sta AUDF0
809
+ sta AUDF0,x
838
810
839
- lda SoundVolumePtr
840
- sta AUDV0
811
+
812
+ lda (SoundControl),y ; get the combined Control and Volume value
813
+ jmp TrackPtrLoaded
814
+ LoadTrackPtr2
815
+ lda (SoundTrackPtr2),y
816
+ sta AUDF0,x
817
+ lda (SoundControl2),y
818
+ TrackPtrLoaded
819
+
820
+ sta AUDV0,x ; update the Volume register
821
+ lsr
822
+ lsr
823
+ lsr
824
+ lsr ; the lower nibble is control
825
+ sta AUDC0,x
841
826
842
827
; dec every 2nd frame
843
- lda Framecount
844
- and SoundSpeed
845
- beq DoNotDecSound
846
- dec SoundEnabled
828
+ ; lda Framecount
829
+ ; and SoundSpeed
830
+ ; beq DoNotDecSound
831
+ dec SoundEnabled,x
847
832
DoNotDecSound
848
833
rts
849
834
850
835
ClearSong
851
836
; song done, now we quit
852
837
lda #0
853
- sta AUDC0
854
- sta AUDF0
855
- sta AUDV0
856
- rts
857
-
858
- ClearNoise
859
- lda #0
860
- sta AUDC1
861
- sta AUDF1
862
- sta AUDV1
838
+ sta AUDC0,x
839
+ sta AUDF0,x
840
+ sta AUDV0,x
863
841
rts
864
842
865
843
PlayBirdHitPlayerSong
866
- lda BirdHitPlayerTrack
844
+ lda #<( BirdHitPlayerTrack)
867
845
sta SoundTrackPtr
868
- lda BirdHitPlayerTrack+ 1
846
+ lda #>( BirdHitPlayerTrack)
869
847
sta SoundTrackPtr+1
870
848
871
- lda #BIRDHITPLAYERVOLUME
872
- sta SoundVolumePtr
849
+ ; lda #BIRDHITPLAYERVOLUME
850
+ ; sta SoundVolumePtr
873
851
874
852
lda #BIRDHITPLAYERTRACKSIZE ; 4 frames long
875
853
sta SoundEnabled
876
854
877
- lda #S_HALFSPEED
878
- sta SoundSpeed
855
+ lda #<(BirdHitPlayerControl)
856
+ sta SoundControl
857
+
858
+ lda #>(BirdHitPlayerControl)
859
+ sta SoundControl+1
860
+
861
+ ;lda #S_FULLSPEED
862
+ ;sta SoundSpeed
879
863
rts
880
864
881
865
PlayFoodCollectedSong
882
- lda FoodCollectedTrack
866
+ lda #<( FoodCollectedTrack)
883
867
sta SoundTrackPtr
884
- lda FoodCollectedTrack+ 1
868
+ lda #>( FoodCollectedTrack)
885
869
sta SoundTrackPtr+1
886
870
887
- lda #FOODCOLLECTEDVOLUME
888
- sta SoundVolumePtr
871
+ ; lda #FOODCOLLECTEDVOLUME
872
+ ; sta SoundVolumePtr
889
873
890
874
lda #FOODCOLLECTEDTRACKSIZE ; 4 frames long
891
875
sta SoundEnabled
892
876
893
- lda #S_HALFSPEED
894
- sta SoundSpeed
877
+ lda #<(FoodCollectedControl)
878
+ sta SoundControl
879
+
880
+ lda #>(FoodCollectedControl)
881
+ sta SoundControl+1
882
+
883
+ ;lda #S_HALFSPEED
884
+ ;sta SoundSpeed
895
885
rts
896
886
897
887
PlayLevelClearSong
898
- lda LevelClearTrack
888
+ lda #<( LevelClearTrack)
899
889
sta SoundTrackPtr
900
- lda LevelClearTrack+ 1
890
+ lda #>( LevelClearTrack)
901
891
sta SoundTrackPtr+1
902
892
903
- lda #LEVELCLEARVOLUME
904
- sta SoundVolumePtr
893
+ ; lda #LEVELCLEARVOLUME
894
+ ; sta SoundVolumePtr
905
895
906
896
lda #LEVELCLEARTRACKSIZE ; 4 frames long
907
897
sta SoundEnabled
908
898
909
- lda #S_HALFSPEED
910
- sta SoundSpeed
899
+ lda #<(LevelClearControl)
900
+ sta SoundControl
901
+
902
+ lda #>(LevelClearControl)
903
+ sta SoundControl+1
904
+
905
+ ;lda #S_HALFSPEED
906
+ ;sta SoundSpeed
911
907
rts
912
908
913
909
SetM0Pos
@@ -1295,6 +1291,9 @@ noeor
1295
1291
sta Rand8
1296
1292
rts
1297
1293
1294
+ ; Free memory check
1295
+ ECHO ([$FFFA -*]d), "bytes free before end data segment ($FFFA)"
1296
+
1298
1297
#if SYSTEM = NTSC
1299
1298
Colours:
1300
1299
.byte $C6 ; green - goes into COLUP0, color for player1 and missile0
@@ -1826,43 +1825,30 @@ RoomTable:
1826
1825
ROOMTABLESIZE = * - RoomTable
1827
1826
1828
1827
; Sound tables
1828
+ ; frequencies in order
1829
1829
BirdHitPlayerTrack
1830
- .byte $D9
1831
- .byte $D8
1832
- .byte $D7
1833
- .byte $D6
1834
- .byte $D5
1835
- .byte $D4
1836
- .byte $D3
1837
- .byte $D2
1838
- .byte $D1
1839
- BIRDHITPLAYERTRACKSIZE = * - BirdHitPlayerTrack
1830
+ .byte 0 , 31 , 29 , 27 , 25 , 23 , 21 , 19 , 17 , 15 , 13 , 11
1831
+ BIRDHITPLAYERTRACKSIZE = * - BirdHitPlayerTrack-1
1832
+
1833
+ ; the control tables hold the control instrumnet in the first number and the volume in the 2nd
1834
+ BirdHitPlayerControl
1835
+ .byte 0 , $8F , $8F , $8F , $8F , $8F , $8F , $8F , $8F , $8F , $8F , $8F
1840
1836
1841
1837
FoodCollectedTrack
1842
- .byte $78
1843
- .byte $79
1844
- .byte $7A
1845
- .byte $7B
1846
- .byte $7C
1847
- .byte $7D
1848
- FOODCOLLECTEDTRACKSIZE = * - FoodCollectedTrack
1838
+ .byte 0 , 26 , 25 , 24 , 25 , 26
1839
+ FOODCOLLECTEDTRACKSIZE = * - FoodCollectedTrack-1
1840
+
1841
+ FoodCollectedControl
1842
+ .byte 0 , $1B , $1C , $4D , $4E , $4F
1849
1843
1850
1844
LevelClearTrack
1851
- .byte $0F
1852
- .byte $0F
1853
- .byte $0F
1854
- .byte $0F
1855
- .byte $0F
1856
- .byte $0F
1857
- .byte $0F
1858
- .byte $0F
1859
- .byte $0F
1860
- .byte $0F
1861
- .byte $0F
1862
- LEVELCLEARTRACKSIZE = * - LevelClearTrack
1863
-
1864
- GameOverTrack
1865
- GAMEOVERTRACKSIZE = * - GameOverTrack
1845
+ .byte 0 , 21 , 21 , 22 , 22 , 23 , 23 , 20 , 20 , 21 , 21 , 22 , 22 , 19 , 19 , 20 , 20 , 21 , 21
1846
+ LEVELCLEARTRACKSIZE = * - LevelClearTrack-1
1847
+
1848
+ LevelClearControl
1849
+ .byte 0 , $4F , $4F , $4F , $4F , $4F , $4F , $4F , $4F , $4F , $4F
1850
+ .byte $4F , $4F , $4F , $4F , $4F , $4F , $4F , $4F , $4F , $4F
1851
+
1866
1852
1867
1853
; Free memory check
1868
1854
ECHO ([$FFFA -*]d), "bytes free before end of cart ($FFFA)"
0 commit comments