Actions

SCHG How-to

Difference between revisions of "Extend Music Slots in Sonic 1"

From Sonic Retro

m (Text replacement - "<asm>" to "<syntaxhighlight lang="asm">")
(rewrote most of the guide, added sound priority fix)
Line 1: Line 1:
{{GuideBy|Mikel}}
+
{{GuideBy|Mikel|ValleyBell}}
 +
 
 +
'' '''Important note:''' This guide prefers label names of the Sonic 1 GitHub disassembly, but labels of the 2005 disassembly are also mentioned.''
  
 
You may notice that in the Sound Test stops on $CF, and can't go any further than $CF. So here are instructions on how to extend the Music Slots to $FF in Sonic 1.
 
You may notice that in the Sound Test stops on $CF, and can't go any further than $CF. So here are instructions on how to extend the Music Slots to $FF in Sonic 1.
 +
 +
=== Step 1: editing the sound driver ===
  
 
To start go to Sound_ChkValue, if you see this line:
 
To start go to Sound_ChkValue, if you see this line:
 
 
<syntaxhighlight lang="asm"> cmpi.b #$E4,d7
 
<syntaxhighlight lang="asm"> cmpi.b #$E4,d7
 
bls.s Sound_E0toE4</syntaxhighlight>
 
bls.s Sound_E0toE4</syntaxhighlight>
 +
 
Add this under Sound_E0toE4:
 
Add this under Sound_E0toE4:
 
 
<syntaxhighlight lang="asm"> cmpi.b #$FF,d7
 
<syntaxhighlight lang="asm"> cmpi.b #$FF,d7
bls.w Sound_E5toFF</syntaxhighlight>
+
bls.w Sound_PlayMoreBGM</syntaxhighlight>
Then, go to Sound_81to9F, and add this above Sound_81to9F:
 
  
<syntaxhighlight lang="asm">Sound_E5toFF:
+
Then, go to Sound_PlayBGM (''Sound_81to9F'' in the 2005 disassembly), and add this right above Sound_PlayBGM:
jsr sub_725CA(pc)
+
<syntaxhighlight lang="asm">Sound_PlayMoreBGM: ; Sound_E5toFF
movea.l (off_719A0).l,a4
+
subi.b #$45, d7 ; map E5-FF range to A0-BA
subi.b #$E5,d7
+
; fall through to Sound_PlayBGM</syntaxhighlight>
move.b (a4,d7.w),$29(a6)
 
movea.l (Go_MusicIndex_E5toFF).l,a4
 
                  jmp Music_Continue</syntaxhighlight>
 
Then go to loc_7202C, and change it to:
 
  
<syntaxhighlight lang="asm">
 
loc_7202C:
 
jsr sub_725CA(pc)
 
movea.l (off_719A0).l,a4
 
subi.b #$81,d7
 
move.b (a4,d7.w),$29(a6)
 
movea.l (Go_MusicIndex).l,a4
 
Music_Continue:
 
lsl.w #2,d7
 
movea.l (a4,d7.w),a4
 
moveq #0,d0
 
move.w (a4),d0
 
add.l a4,d0
 
move.l d0,$18(a6)
 
move.b 5(a4),d0
 
move.b d0,$28(a6)
 
tst.b $2A(a6)
 
beq.s loc_72068
 
move.b $29(a6),d0</syntaxhighlight>
 
Then, change:
 
  
<syntaxhighlight lang="asm">
+
Then, go to MusicIndex. At first make sure that Music81 to Music9F are listed. If the list contains only Music81 to Music93, add Music94 to Music9F (and don't forget to define/include those songs).<br/>
Go_SoundTypes: dc.l SoundTypes ; XREF: Sound_Play
+
Then add MusicE5 to MusicFF to the end of the list, after Music9F:
Go_SoundD0: dc.l SoundD0Index ; XREF: Sound_D0toDF
+
<syntaxhighlight lang="asm"> dc.l MusicE5, MusicE6, MusicE7, MusicE8
Go_MusicIndex: dc.l MusicIndex ; XREF: Sound_81to9F
+
dc.l MusicE9, MusicEA, MusicEB, MusicEC
Go_SoundIndex: dc.l SoundIndex ; XREF: Sound_A0toCF
+
dc.l MusicED, MusicEE, MusicEF, MusicF0
off_719A0: dc.l byte_71A94 ; XREF: Sound_81to9F
+
dc.l MusicF1, MusicF2, MusicF3, MusicF4
Go_PSGIndex: dc.l PSG_Index ; XREF: sub_72926</syntaxhighlight>
+
dc.l MusicF5, MusicF6, MusicF7, MusicF8
To:
+
dc.l MusicF9, MusicFA, MusicFB, MusicFC
 
+
dc.l MusicFD, MusicFE, MusicFF</syntaxhighlight>
<syntaxhighlight lang="asm"> align $10
 
Go_SoundTypes: dc.l SoundTypes ; XREF: Sound_Play
 
Go_SoundD0: dc.l SoundD0Index ; XREF: Sound_D0toDF
 
Go_MusicIndex: dc.l MusicIndex ; XREF: Sound_81to9F
 
Go_MusicIndex_E5toFF: dc.l MusicIndex_E5plus ; XREF: Sound_81to9F
 
Go_SoundIndex: dc.l SoundIndex ; XREF: Sound_A0toCF
 
off_719A0: dc.l byte_71A94 ; XREF: Sound_81to9F
 
Go_PSGIndex: dc.l PSG_Index ; XREF: sub_72926</syntaxhighlight>
 
Then, go to:
 
  
 +
Then search for Music9F:
 
<syntaxhighlight lang="asm">Music9F: incbin sound\music9F.bin
 
<syntaxhighlight lang="asm">Music9F: incbin sound\music9F.bin
 
even</syntaxhighlight>
 
even</syntaxhighlight>
And add the following lines under the line I posted above:
+
and add these lines:
 
 
<syntaxhighlight lang="asm">MusicIndex_E5plus:
 
                                dc.l MusicE5, MusicE6
 
dc.l MusicE7, MusicE8
 
dc.l MusicE9, MusicEA
 
dc.l MusicEB, MusicEC
 
dc.l MusicED, MusicEE
 
dc.l MusicEF, MusicF0
 
dc.l MusicF1, MusicF2
 
dc.l MusicF3, MusicF4
 
                                dc.l MusicF5, MusicF6
 
dc.l MusicF7, MusicF8
 
dc.l MusicF9, MusicFA
 
dc.l MusicFB, MusicFC
 
dc.l MusicFD, MusicFE
 
dc.l MusicFF</syntaxhighlight>
 
 
 
Then, under MusicIndex_E5toFF, add these lines:
 
 
 
 
<syntaxhighlight lang="asm">MusicE5: incbin sound\musicE5.bin
 
<syntaxhighlight lang="asm">MusicE5: incbin sound\musicE5.bin
 
even
 
even
Line 138: Line 89:
 
MusicFF: incbin sound\musicFF.bin
 
MusicFF: incbin sound\musicFF.bin
 
even</syntaxhighlight>
 
even</syntaxhighlight>
Next, we are going to extend the slots in the Sound Test, first go to LevSel_SndTest, and change:
 
  
 +
 +
If you would try to play songs in the range E5-FF now, they might not always play.
 +
The reason for this is, that the sound priority list has values for sound IDs 81-E4 only.
 +
So go to SoundPriorities (''SoundTypes'' in the 2005 disassembly). The last line of the array is:
 +
<syntaxhighlight lang="asm"> dc.b $90,$90,$90,$90,$90                                            ; $E0</syntaxhighlight>
 +
Now add the additional values for sound IDs E5-FF by replacing the line with:
 +
<syntaxhighlight lang="asm"> dc.b $90,$90,$90,$90,$90,$90,$90,$90,$90,$90,$90,$90,$90,$90,$90,$90 ; $E0
 +
dc.b $90,$90,$90,$90,$90,$90,$90,$90,$90,$90,$90,$90,$90,$90,$90,$90 ; $F0</syntaxhighlight>
 +
 +
 +
=== Step 2: extending the sound test ===
 +
Next, we are going to extend the slots in the Sound Test.
 +
First go to LevSel_SndTest, and change:
 
<syntaxhighlight lang="asm"> moveq #$4F,d0 ; if sound test moves below 0, set to $4F</syntaxhighlight>
 
<syntaxhighlight lang="asm"> moveq #$4F,d0 ; if sound test moves below 0, set to $4F</syntaxhighlight>
 
To:
 
To:
 +
<syntaxhighlight lang="asm"> moveq #$7F,d0 ; if sound test moves below 0, set to $7F</syntaxhighlight>
  
<syntaxhighlight lang="asm"> moveq #$7F,d0 ; if sound test moves below 0, set to $7F</syntaxhighlight>
 
 
Then, go to LevSel_Right, and change:
 
Then, go to LevSel_Right, and change:
 
 
<syntaxhighlight lang="asm"> cmpi.w #$50,d0</syntaxhighlight>
 
<syntaxhighlight lang="asm"> cmpi.w #$50,d0</syntaxhighlight>
 
To:
 
To:
 
 
<syntaxhighlight lang="asm"> cmpi.w #$80,d0</syntaxhighlight>
 
<syntaxhighlight lang="asm"> cmpi.w #$80,d0</syntaxhighlight>
Last but not least, we are going to allow the Sound Test to read slots $E5 to $FF, so go to LevSel_NoCheat, and change:
 
  
<syntaxhighlight lang="asm"> cmpi.w #$9F,d0 ; is sound $80-$9F being played?
+
Last but not least, we are going to allow the Sound Test to read slots $E5 to $FF, so go to LevSel_NoCheat, and comment all lines until LevSel_PlaySnd out. (It should be 4 instructions.)
ble.s LevSel_PlaySnd ; if yes, branch</syntaxhighlight>
 
To:
 
  
<syntaxhighlight lang="asm"> cmpi.w #$FF,d0 ; is sound $E5-$FF being played?
 
ble.s LevSel_PlaySnd ; if yes, branch</syntaxhighlight>
 
 
Then, build the rom and check out your newly added tunes.
 
Then, build the rom and check out your newly added tunes.
  
 
{{S1Howtos}}
 
{{S1Howtos}}
 
[[Category:SCHG_How-tos|{{PAGENAME}}]]
 
[[Category:SCHG_How-tos|{{PAGENAME}}]]

Revision as of 10:34, 29 August 2016

(Original guide by Mikel and ValleyBell)

Important note: This guide prefers label names of the Sonic 1 GitHub disassembly, but labels of the 2005 disassembly are also mentioned.

You may notice that in the Sound Test stops on $CF, and can't go any further than $CF. So here are instructions on how to extend the Music Slots to $FF in Sonic 1.

Step 1: editing the sound driver

To start go to Sound_ChkValue, if you see this line:

		cmpi.b	#$E4,d7
		bls.s	Sound_E0toE4

Add this under Sound_E0toE4:

		cmpi.b	#$FF,d7
		bls.w	Sound_PlayMoreBGM

Then, go to Sound_PlayBGM (Sound_81to9F in the 2005 disassembly), and add this right above Sound_PlayBGM:

Sound_PlayMoreBGM:	; Sound_E5toFF
		subi.b	#$45, d7	; map E5-FF range to A0-BA
		; fall through to Sound_PlayBGM


Then, go to MusicIndex. At first make sure that Music81 to Music9F are listed. If the list contains only Music81 to Music93, add Music94 to Music9F (and don't forget to define/include those songs).
Then add MusicE5 to MusicFF to the end of the list, after Music9F:

		dc.l MusicE5, MusicE6, MusicE7, MusicE8
		dc.l MusicE9, MusicEA, MusicEB, MusicEC
		dc.l MusicED, MusicEE, MusicEF, MusicF0
		dc.l MusicF1, MusicF2, MusicF3, MusicF4
		dc.l MusicF5, MusicF6, MusicF7, MusicF8
		dc.l MusicF9, MusicFA, MusicFB, MusicFC
		dc.l MusicFD, MusicFE, MusicFF

Then search for Music9F:

Music9F:	incbin	sound\music9F.bin
		even

and add these lines:

MusicE5:	incbin	sound\musicE5.bin
		even
MusicE6:	incbin	sound\musicE6.bin
		even
MusicE7:	incbin	sound\musicE7.bin
		even
MusicE8:	incbin	sound\musicE8.bin
		even
MusicE9:	incbin	sound\musicE9.bin
		even
MusicEA:	incbin	sound\musicEA.bin
		even
MusicEB:	incbin	sound\musicEB.bin
		even
MusicEC:	incbin	sound\musicEC.bin
		even
MusicED:	incbin	sound\musicED.bin
		even
MusicEE:	incbin	sound\musicEE.bin
		even
MusicEF:	incbin	sound\musicEF.bin
		even
MusicF0:	incbin	sound\musicF0.bin
		even
MusicF1:	incbin	sound\musicF1.bin
		even
MusicF2:	incbin	sound\musicF2.bin
		even
MusicF3:	incbin	sound\musicF3.bin
		even
MusicF4:	incbin	sound\musicF4.bin
		even
MusicF5:	incbin	sound\musicF5.bin
		even
MusicF6:	incbin	sound\musicF6.bin
		even
MusicF7:	incbin	sound\musicF7.bin
		even
MusicF8:	incbin	sound\musicF8.bin
		even
MusicF9:	incbin	sound\musicF9.bin
		even
MusicFA:	incbin	sound\musicFA.bin
		even
MusicFB:	incbin	sound\musicFB.bin
		even
MusicFC:	incbin	sound\musicFC.bin
		even
MusicFD:	incbin	sound\musicFD.bin
		even
MusicFE:	incbin	sound\musicFE.bin
		even
MusicFF:	incbin	sound\musicFF.bin
		even


If you would try to play songs in the range E5-FF now, they might not always play. The reason for this is, that the sound priority list has values for sound IDs 81-E4 only. So go to SoundPriorities (SoundTypes in the 2005 disassembly). The last line of the array is:

		dc.b $90,$90,$90,$90,$90                                            	; $E0

Now add the additional values for sound IDs E5-FF by replacing the line with:

		dc.b $90,$90,$90,$90,$90,$90,$90,$90,$90,$90,$90,$90,$90,$90,$90,$90	; $E0
		dc.b $90,$90,$90,$90,$90,$90,$90,$90,$90,$90,$90,$90,$90,$90,$90,$90	; $F0


Step 2: extending the sound test

Next, we are going to extend the slots in the Sound Test. First go to LevSel_SndTest, and change:

		moveq	#$4F,d0		; if sound test	moves below 0, set to $4F

To:

		moveq	#$7F,d0		; if sound test	moves below 0, set to $7F

Then, go to LevSel_Right, and change:

		cmpi.w	#$50,d0

To:

		cmpi.w	#$80,d0

Last but not least, we are going to allow the Sound Test to read slots $E5 to $FF, so go to LevSel_NoCheat, and comment all lines until LevSel_PlaySnd out. (It should be 4 instructions.)

Then, build the rom and check out your newly added tunes.

SCHG How-To Guide: Sonic the Hedgehog (16-bit)
Fixing Bugs
Fix Demo Playback | Fix a Race Condition with Pattern Load Cues | Fix the SEGA Sound | Display the Press Start Button Text | Fix the Level Select Menu | Fix the Hidden Points Bug | Fix Accidental Deletion of Scattered Rings | Fix Ring Timers | Fix the Walk-Jump Bug | Correct Drowning Bugs | Fix the Death Boundary Bug | Fix the Camera Follow Bug | Fix Song Restoration Bugs | Fix the HUD Blinking | Fix the Level Select Graphics Bug | Fix a remember sprite related bug
Changing Design Choices
Change Spike Behavior | Collide with Water After Being Hurt | Fix Special Stage Jumping Physics | Improve the Fade In\Fade Out Progression Routines | Fix Scattered Rings' Underwater Physics | Remove the Speed Cap | Port the REV01 Background Effects | Port Sonic 2's Level Art Loader | Retain Rings Between Acts | Add Sonic 2 (Simon Wai Prototype) Level Select | Improve ObjectMove Subroutines | Port Sonic 2 Level Select
Adding Features
Add Spin Dash ( Part 1 / Part 2 / Part 3 / Part 4 ) | Add Eggman Monitor | Add Super Sonic | Add the Air Roll
Sound Features
Expand the Sound Index | Play Different Songs Per Act | Port Sonic 2 Final Sound Driver | Port Sonic 3's Sound Driver | Port Flamewing's Sonic 3 & Knuckles Sound Driver | Change The SEGA Sound
Extending the Game
Load Chunks From ROM | Add Extra Characters | Make an Alternative Title Screen | Use Dynamic Tilesets | Make GHZ Load Alternate Art | Make Ending Load Alternate Art | Add a New Zone | Set Up the Goggle Monitor | Add New Moves | Add a Dynamic Collision System | Dynamic Special Stage Walls System | Extend Sprite Mappings and Art Limit | Enigma Credits | Use Dynamic Palettes
Miscellaneous
Convert the Hivebrain 2005 Disassembly to ASM68K
Split Disassembly Guides
Set Up a Split Disassembly | Basic Level Editing | Basic Art Editing | Basic ASM Editing (Spin Dash)