Actions

SCHG How-to

Difference between revisions of "Expand the music index to start at $00 instead of $80"

From Sonic Retro

m (Text replacement - "</asm>" to "</syntaxhighlight>")
m (Text replacement - "<asm>" to "<syntaxhighlight lang="asm">")
Line 12: Line 12:
 
Make a search for '''PlaySound:'''.
 
Make a search for '''PlaySound:'''.
 
You will see this:
 
You will see this:
<asm>PlaySound:
+
<syntaxhighlight lang="asm">PlaySound:
 
move.b d0,($FFFFF00A).w
 
move.b d0,($FFFFF00A).w
 
rts</syntaxhighlight>
 
rts</syntaxhighlight>
Line 18: Line 18:
  
 
Change to this:
 
Change to this:
<asm>PlaySound:
+
<syntaxhighlight lang="asm">PlaySound:
 
cmpi.b  #$7F,d0
 
cmpi.b  #$7F,d0
 
ble.s  ChkSounds00to7F
 
ble.s  ChkSounds00to7F
Line 36: Line 36:
 
Make a search for '''PlaySound_Special:'''
 
Make a search for '''PlaySound_Special:'''
 
You can see this:
 
You can see this:
<asm>PlaySound_Special:
+
<syntaxhighlight lang="asm">PlaySound_Special:
 
move.b d0,($FFFFF00B).w
 
move.b d0,($FFFFF00B).w
 
rts</syntaxhighlight>
 
rts</syntaxhighlight>
Line 42: Line 42:
  
 
Change to this:
 
Change to this:
<asm>PlaySound_Special:
+
<syntaxhighlight lang="asm">PlaySound_Special:
 
cmpi.b  #$7F,d0
 
cmpi.b  #$7F,d0
 
ble.s  ChkSounds00to7F_Special
 
ble.s  ChkSounds00to7F_Special
Line 60: Line 60:
  
 
Search for '''loc_7202C:''', you will see this:
 
Search for '''loc_7202C:''', you will see this:
<asm>loc_7202C:
+
<syntaxhighlight lang="asm">loc_7202C:
 
jsr sub_725CA(pc)
 
jsr sub_725CA(pc)
 
movea.l (off_719A0).l,a4
 
movea.l (off_719A0).l,a4
Line 69: Line 69:
  
 
Change to this:
 
Change to this:
<asm>loc_7202C:
+
<syntaxhighlight lang="asm">loc_7202C:
 
jsr sub_725CA(pc)
 
jsr sub_725CA(pc)
 
movea.l (off_719A0).l,a4
 
movea.l (off_719A0).l,a4
Line 88: Line 88:
  
 
Search for '''Go_MusicIndex:''', you can see this:
 
Search for '''Go_MusicIndex:''', you can see this:
<asm>Go_MusicIndex: dc.l MusicIndex; XREF: Sound_81to9F</syntaxhighlight>
+
<syntaxhighlight lang="asm">Go_MusicIndex: dc.l MusicIndex; XREF: Sound_81to9F</syntaxhighlight>
  
  
 
Below the '''Go_MusicIndex:''' code, add this:
 
Below the '''Go_MusicIndex:''' code, add this:
<asm>Go_MusicIndex00: dc.l MusicIndex00
+
<syntaxhighlight lang="asm">Go_MusicIndex00: dc.l MusicIndex00
 
Go_MusicIndexFF: dc.l MusicIndexFF</syntaxhighlight>
 
Go_MusicIndexFF: dc.l MusicIndexFF</syntaxhighlight>
  
Line 98: Line 98:
  
 
Search for '''Sound_ChkValue:''', you will see this:
 
Search for '''Sound_ChkValue:''', you will see this:
<asm>Sound_ChkValue:; XREF: sub_71B4C
+
<syntaxhighlight lang="asm">Sound_ChkValue:; XREF: sub_71B4C
 
moveq #0,d7
 
moveq #0,d7
 
move.b 9(a6),d7
 
move.b 9(a6),d7
Line 122: Line 122:
  
 
Change to this:
 
Change to this:
<asm>Sound_ChkValue:; XREF: sub_71B4C
+
<syntaxhighlight lang="asm">Sound_ChkValue:; XREF: sub_71B4C
 
moveq #0,d7
 
moveq #0,d7
 
move.b 9(a6),d7
 
move.b 9(a6),d7
Line 153: Line 153:
  
 
Search for '''Sound_81to9F:''' and above '''Sound_81to9F''', add this:
 
Search for '''Sound_81to9F:''' and above '''Sound_81to9F''', add this:
<asm>Sound_ChkValueFor00:
+
<syntaxhighlight lang="asm">Sound_ChkValueFor00:
 
cmpi.b  #$FF,d7; $FF = Last slot for musics in index $00 - $7F ($FF = $7F)
 
cmpi.b  #$FF,d7; $FF = Last slot for musics in index $00 - $7F ($FF = $7F)
 
bls.w  Sound_81to9F
 
bls.w  Sound_81to9F
Line 169: Line 169:
 
To do it for the songs $01 to $7F, create in some place a index called '''MusicIndex00:'''.
 
To do it for the songs $01 to $7F, create in some place a index called '''MusicIndex00:'''.
 
The index have to work like this:
 
The index have to work like this:
<asm>MusicIndex00:
+
<syntaxhighlight lang="asm">MusicIndex00:
 
dc.l Music01; Music for slot $01
 
dc.l Music01; Music for slot $01
 
dc.l Music02; Music for slot $02
 
dc.l Music02; Music for slot $02
Line 176: Line 176:
  
 
To the songs $E5 to $FF, create in some place a index called '''MusicIndexFF'''. The index have to work like this:
 
To the songs $E5 to $FF, create in some place a index called '''MusicIndexFF'''. The index have to work like this:
<asm>MusicIndexFF:
+
<syntaxhighlight lang="asm">MusicIndexFF:
 
dc.l MusicE5; Music for slot $E5
 
dc.l MusicE5; Music for slot $E5
 
dc.l MusicE6; Music for slot $E6
 
dc.l MusicE6; Music for slot $E6
Line 185: Line 185:
  
 
Search for '''loc_3550:''', you will see this:
 
Search for '''loc_3550:''', you will see this:
<asm> addi.w #$80,d0</syntaxhighlight>
+
<syntaxhighlight lang="asm"> addi.w #$80,d0</syntaxhighlight>
 
Remove or comment this line.
 
Remove or comment this line.
  
  
 
Make a search for '''LevelSelect:''', below from this you can see:
 
Make a search for '''LevelSelect:''', below from this you can see:
<asm> addi.w #$80,d0</syntaxhighlight>
+
<syntaxhighlight lang="asm"> addi.w #$80,d0</syntaxhighlight>
 
Remove or comment this line.
 
Remove or comment this line.
  
  
 
Search for '''LevSel_Right:''', above it you will see this:
 
Search for '''LevSel_Right:''', above it you will see this:
<asm> bcc.s LevSel_Right
+
<syntaxhighlight lang="asm"> bcc.s LevSel_Right
 
moveq #$4F,d0; if sound test moves below 0, set to $4F</syntaxhighlight>
 
moveq #$4F,d0; if sound test moves below 0, set to $4F</syntaxhighlight>
 
Change or comment these lines.
 
Change or comment these lines.
Line 201: Line 201:
  
 
Search for '''LevSel_Refresh2:''', above it you will see this:
 
Search for '''LevSel_Refresh2:''', above it you will see this:
<asm> cmpi.w #$50,d0
+
<syntaxhighlight lang="asm"> cmpi.w #$50,d0
 
bcs.s LevSel_Refresh2
 
bcs.s LevSel_Refresh2
 
moveq #0,d0; if sound test moves above $4F, set to 0</syntaxhighlight>
 
moveq #0,d0; if sound test moves above $4F, set to 0</syntaxhighlight>
Line 211: Line 211:
  
 
Go to '''SoundTypes:''', you can see this:
 
Go to '''SoundTypes:''', you can see this:
<asm>SoundTypes: dc.b $90, $90, $90, $90, $90, $90, $90, $90, $90, $90, $90, $90, $90, $90, $90, $90
+
<syntaxhighlight lang="asm">SoundTypes: dc.b $90, $90, $90, $90, $90, $90, $90, $90, $90, $90, $90, $90, $90, $90, $90, $90
 
dc.b $90, $90, $90, $90, $90, $90, $90, $90, $90, $90, $90, $90, $90, $90, $90, $80
 
dc.b $90, $90, $90, $90, $90, $90, $90, $90, $90, $90, $90, $90, $90, $90, $90, $80
 
dc.b $70, $70, $70, $70, $70, $70, $70, $70, $70, $68, $70, $70, $70, $60, $70, $70
 
dc.b $70, $70, $70, $70, $70, $70, $70, $70, $70, $68, $70, $70, $70, $60, $70, $70
Line 221: Line 221:
  
 
Change to this:
 
Change to this:
<asm>SoundTypes: dc.b $90, $90, $90, $90, $90, $90, $90, $90, $90, $90, $90, $90, $90, $90, $90, $90
+
<syntaxhighlight lang="asm">SoundTypes: dc.b $90, $90, $90, $90, $90, $90, $90, $90, $90, $90, $90, $90, $90, $90, $90, $90
 
dc.b $90, $90, $90, $90, $90, $90, $90, $90, $90, $90, $90, $90, $90, $90, $90, $90
 
dc.b $90, $90, $90, $90, $90, $90, $90, $90, $90, $90, $90, $90, $90, $90, $90, $90
 
dc.b $90, $90, $90, $90, $90, $90, $90, $90, $90, $90, $90, $90, $90, $90, $90, $90
 
dc.b $90, $90, $90, $90, $90, $90, $90, $90, $90, $90, $90, $90, $90, $90, $90, $90

Revision as of 21:45, 20 December 2015

(Original guide by HPZMan)

Here's a easy way on how to use all slots from $00 to $FF on the Sonic 1 M68K Sound Driver.

Some notes:

After the changes, the addresses $FFFFFFFC and $FFFFFFFD will be used. Technically, it aren't new slots. Instead of this, it is a duplication from the slots $80 using a unique different index.

Slots $00 to $7F

Make a search for PlaySound:. You will see this:

PlaySound:
		move.b	d0,($FFFFF00A).w
		rts


Change to this:

PlaySound:
		cmpi.b  #$7F,d0
		ble.s   ChkSounds00to7F
		jmp	 NormalSoundRequest
ChkSounds00to7F:
		cmpi.b  #$01,d0
		bge.s   LoadSlots00to7F
		jmp	 NormalSoundRequest
LoadSlots00to7F:
		add.b   #$80,d0; Add $80 to get slot to starts at $81			
		move.b  #$01,($FFFFFFFC).w; Move $01 to $FFFFFC to make sound driver to load the secound index
NormalSoundRequest:
		move.b	d0,($FFFFF00A).w
		rts


Make a search for PlaySound_Special: You can see this:

PlaySound_Special:
		move.b	d0,($FFFFF00B).w
		rts


Change to this:

PlaySound_Special:
		cmpi.b  #$7F,d0
		ble.s   ChkSounds00to7F_Special
		jmp	 NormalSoundRequest_Special
ChkSounds00to7F_Special:

		cmpi.b  #$01,d0
		bge.s   LoadSlots00to7F_Special
		jmp	 NormalSoundRequest_Special
LoadSlots00to7F_Special:
		add.b   #$80,d0; Add $80 to get slot to starts at $81			
		move.b  #$01,($FFFFFFFC).w; Move $01 to $FFFFFC to make the sound driver to load the secound index
NormalSoundRequest_Special:
		move.b	d0,($FFFFF00B).w
		rts


Search for loc_7202C:, you will see this:

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


Change to this:

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
		cmpi.b  #$01,($FFFFFFFD).w
		bne.s   CheckSounds00to80
		movea.l	(Go_MusicIndexFF).l,a4
		jmp	 NormalIndexLoad
CheckSounds00to80:
		cmpi.b  #$01,($FFFFFFFC).w
		bne.s   NormalIndexLoad
		movea.l	(Go_MusicIndex00).l,a4		
NormalIndexLoad:
		clr.w   ($FFFFFFFC).w


Search for Go_MusicIndex:, you can see this:

Go_MusicIndex:	dc.l MusicIndex; XREF: Sound_81to9F


Below the Go_MusicIndex: code, add this:

Go_MusicIndex00:	dc.l MusicIndex00
Go_MusicIndexFF:	dc.l MusicIndexFF

Slots $E5 to $FF

Search for Sound_ChkValue:, you will see this:

Sound_ChkValue:; XREF: sub_71B4C
		moveq	#0,d7
		move.b	9(a6),d7
		beq.w	Sound_E4
		bpl.s	locret_71F8C
		move.b	#$80,9(a6); reset	music flag
		cmpi.b	#$9F,d7
		bls.w	Sound_81to9F; music	$81-$9F
		cmpi.b	#$A0,d7
		bcs.w	locret_71F8C
		cmpi.b	#$CF,d7
		bls.w	Sound_A0toCF; sound	$A0-$CF
		cmpi.b	#$D0,d7
		bcs.w	locret_71F8C
		cmpi.b	#$E0,d7
		bcs.w	Sound_D0toDF; sound	$D0-$DF
		cmpi.b	#$E4,d7
		bls.s	Sound_E0toE4; sound	$E0-$E4

locret_71F8C:
		rts


Change to this:

Sound_ChkValue:; XREF: sub_71B4C
		moveq	#0,d7
		move.b	9(a6),d7
		beq.w	Sound_E4
		bpl.s	locret_71F8C
		move.b	#$80,9(a6); reset	music flag
		cmpi.b  #$01,($FFFFFFFC).w
		bne.s   Load81to9F
		jmp	 Sound_ChkValueFor00
Load81to9F:
		cmpi.b	#$9F,d7
		bls.w	Sound_81to9F; music	$81-$9F
ContinueSound_ChkValue:
		cmpi.b	#$A0,d7
		bcs.w	locret_71F8C
		cmpi.b	#$CF,d7
		bls.w	Sound_A0toCF; sound	$A0-$CF
		cmpi.b	#$D0,d7
		bcs.w	locret_71F8C
		cmpi.b	#$E0,d7
		bcs.w	Sound_D0toDF; sound	$D0-$DF
		cmpi.b	#$E4,d7
		bls.s	Sound_E0toE4; sound	$E0-$E4
		cmpi.b  #$FF,d7
		bls.w   Sound_E5toFF

locret_71F8C:
		rts


Search for Sound_81to9F: and above Sound_81to9F, add this:

Sound_ChkValueFor00:
		cmpi.b  #$FF,d7; $FF = Last slot for musics in index $00 - $7F ($FF = $7F)
		bls.w   Sound_81to9F
		rts

Sound_E5toFF:
		move.b  #$01,($FFFFFFFD).w
		sub.b   #$64,d7

Inserting new songs

Now you just need to create the pointers for the songs at the index, and include them! To do it for the songs $01 to $7F, create in some place a index called MusicIndex00:. The index have to work like this:

MusicIndex00:
		dc.l	Music01; Music for slot $01
		dc.l	Music02; Music for slot $02
......


To the songs $E5 to $FF, create in some place a index called MusicIndexFF. The index have to work like this:

MusicIndexFF:
		dc.l	MusicE5; Music for slot $E5
		dc.l	MusicE6; Music for slot $E6
......


Making the Sound Test values to start at $00

Search for loc_3550:, you will see this:

		addi.w	#$80,d0

Remove or comment this line.


Make a search for LevelSelect:, below from this you can see:

		addi.w	#$80,d0

Remove or comment this line.


Search for LevSel_Right:, above it you will see this:

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

Change or comment these lines.


Search for LevSel_Refresh2:, above it you will see this:

		cmpi.w	#$50,d0
		bcs.s	LevSel_Refresh2
		moveq	#0,d0; if sound test	moves above $4F, set to	0

Remove or comment these lines.


Fixing possible problems with sound effects and songs

Go to SoundTypes:, you can see this:

SoundTypes:	dc.b $90, $90, $90, $90, $90, $90, $90,	$90, $90, $90, $90, $90, $90, $90, $90,	$90
		dc.b $90, $90, $90, $90, $90, $90, $90,	$90, $90, $90, $90, $90, $90, $90, $90,	$80
		dc.b $70, $70, $70, $70, $70, $70, $70,	$70, $70, $68, $70, $70, $70, $60, $70,	$70
		dc.b $60, $70, $60, $70, $70, $70, $70,	$70, $70, $70, $70, $70, $70, $70, $7F,	$60
		dc.b $70, $70, $70, $70, $70, $70, $70,	$70, $70, $70, $70, $70, $70, $70, $70,	$80
		dc.b $80, $80, $80, $80, $80, $80, $80,	$80, $80, $80, $80, $80, $80, $80, $80,	$90
		dc.b $90, $90, $90, $90


Change to this:

SoundTypes:	dc.b $90, $90, $90, $90, $90, $90, $90,	$90, $90, $90, $90, $90, $90, $90, $90,	$90
		dc.b $90, $90, $90, $90, $90, $90, $90,	$90, $90, $90, $90, $90, $90, $90, $90,	$90
		dc.b $90, $90, $90, $90, $90, $90, $90,	$90, $90, $90, $90, $90, $90, $90, $90,	$90
		dc.b $90, $90, $90, $90, $90, $90, $90,	$90, $90, $90, $90, $90, $90, $90, $90,	$90
		dc.b $90, $90, $90, $90, $90, $90, $90,	$90, $90, $90, $90, $90, $90, $90, $90,	$90
		dc.b $90, $90, $90, $90, $90, $90, $90,	$90, $90, $90, $90, $90, $90, $90, $90,	$90
		dc.b $90, $90, $90, $90, $90, $90, $90,	$90, $90, $90, $90, $90, $90, $90, $90,	$90
		dc.b $90, $90, $90, $90, $90, $90, $90,	$90, $90, $90, $90, $90, $90, $90, $90,	$90
		dc.b $90, $90, $90, $90, $90, $90, $90,	$90, $90, $90, $90, $90, $90, $90, $90,	$90
		dc.b $90, $90, $90, $90, $90, $90, $90,	$90, $90, $90, $90, $90, $90, $90, $90,	$90
		dc.b $90, $90, $90, $90, $90, $90, $90,	$90, $90, $90, $90, $90, $90, $90, $90,	$90
		dc.b $90, $90, $90, $90, $90, $90, $90,	$90, $90, $90, $90, $90, $90, $90, $90,	$90
		dc.b $90, $90, $90, $90, $90, $90, $90,	$90, $90, $90, $90, $90, $90, $90, $90,	$90
		dc.b $90, $90, $90, $90, $90, $90, $90,	$90, $90, $90, $90, $90, $90, $90, $90,	$90
		dc.b $90, $90, $90, $90, $90, $90, $90,	$90, $90, $90, $90, $90, $90, $90, $90,	$90
		dc.b $90, $90, $90, $90, $90, $90, $90,	$90, $90, $90, $90, $90, $90, $90, $90, $90


It should fix possible problems on play songs/sound effects and will not interfere the original songs and sound effects.

Optional - Putting the default Sonic 1 songs at the $0X slots index

Go to the index for songs $8X, MusicIndex.

Copy the pointers from it, remove them and paste it at the begin from the $0X slot index MusicIndex00.

Done.

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)