Actions

SCHG How-to

Add different music per act

From Sonic Retro

Revision as of 11:11, 25 August 2018 by Black Squirrel (talk | contribs) (Text replacement - "\[\[Category:SCHG How-tos.*" to "")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

(Original guide by Lilggamegenuis)
So, you want to add separate act music huh? Well this guide is going to show you a easy way to implement this! Keep in mind that i made this with the clone driver already installed but i do believe that i added everything to implement it for stock

How sega did it

Ok, go in your S2.asm and take a look at the music list You should see this

MusicList: zoneOrderedTable 1,1
zoneTableEntry.b MusID_EHZ ; 0 ; EHZ
zoneTableEntry.b MusID_EHZ ; 1
zoneTableEntry.b MusID_MTZ ; 2
zoneTableEntry.b MusID_OOZ ; 3
zoneTableEntry.b MusID_MTZ ; 4 ; MTZ1,2
zoneTableEntry.b MusID_MTZ ; 5 ; MTZ3
zoneTableEntry.b MusID_WFZ ; 6 ; WFZ
zoneTableEntry.b MusID_HTZ ; 7 ; HTZ
zoneTableEntry.b MusID_HPZ ; 8
zoneTableEntry.b MusID_SCZ ; 9
zoneTableEntry.b MusID_OOZ ; 10 ; OOZ
zoneTableEntry.b MusID_MCZ ; 11 ; MCZ
zoneTableEntry.b MusID_CNZ ; 12 ; CNZ
zoneTableEntry.b MusID_CPZ ; 13 ; CPZ
zoneTableEntry.b MusID_DEZ ; 14 ; DEZ
zoneTableEntry.b MusID_ARZ ; 15 ; ARZ
zoneTableEntry.b MusID_SCZ ; 16 ; SCZ
zoneTableEnd
even

Now take a look at musiclist2 right beneath it It should look like this

MusicList2: zoneOrderedTable 1,1
zoneTableEntry.b MusID_EHZ_2P ; 0 ; EHZ 2P
zoneTableEntry.b MusID_EHZ ; 1
zoneTableEntry.b MusID_MTZ ; 2
zoneTableEntry.b MusID_OOZ ; 3
zoneTableEntry.b MusID_MTZ ; 4
zoneTableEntry.b MusID_MTZ ; 5
zoneTableEntry.b MusID_WFZ ; 6
zoneTableEntry.b MusID_HTZ ; 7
zoneTableEntry.b MusID_HPZ ; 8
zoneTableEntry.b MusID_SCZ ; 9
zoneTableEntry.b MusID_OOZ ; 10
zoneTableEntry.b MusID_MCZ_2P ; 11 ; MCZ 2P
zoneTableEntry.b MusID_CNZ_2P ; 12 ; CNZ 2P
zoneTableEntry.b MusID_CPZ ; 13
zoneTableEntry.b MusID_DEZ ; 14
zoneTableEntry.b MusID_ARZ ; 15
zoneTableEntry.b MusID_SCZ ; 16
zoneTableEnd
even

Ss you can see, they are practically identical with the exception of the 3 2-player specific songs

If you take a look at the code to load the bgms, you can see how this works

Level_GetBgm:
tst.w (Demo_mode_flag).w
bmi.s +
moveq #0,d0
move.b (Current_Zone).w,d0
lea MusicList(pc),a1
tst.w (Two_player_mode).w
beq.s Level_PlayBgm
lea MusicList2(pc),a1

After this piece of code has run it goes to level_playbgm with the 2p musiclist pointer in the register instead of the 1p list. Now applying this method we can do the same to make different acts run different music


Setting up the music list

Now what you'll want to do is just copy the musiclist table (doesen't matter which one) and put it beneath musiclist2 or you can use the 2p list instead. Now change each act name with a second act to XXZ2 (XX meaning the stage initials. Also you could name it something else if you want but in the guide i will use this format for act 2 songs) Note: You will need to keep all the songs that don't have a act 2 (or the act 3 for MTZ), If you remove the the ones before a act 2, As it will cause the wrong music to play. Now go back up to musiclist (the first one) and change the second MTZ to MTZ3. With metropolis zone it treats act 3 as a different zone in act 1 Now that we have set up the music list its time to add the songs to the constants to be played


Setting up the constants

Now we're going to need to setup the music so they can be played in the table. Open up your constants file and go to where the music ids start. It should look like this.

; Music IDs
offset := zMasterPlaylist
ptrsize := 1
idstart := $81
; $80 is reserved for silence, so if you make idstart $80 or less,
; you may need to insert a dummy zMusIDPtr in the $80 slot

MusID__First = idstart
MusID_2PResult = id(zMusIDPtr_2PResult) ; 81
MusID_EHZ = id(zMusIDPtr_EHZ) ; 82
MusID_MCZ_2P = id(zMusIDPtr_MCZ_2P) ; 83
MusID_OOZ = id(zMusIDPtr_OOZ) ; 84
MusID_MTZ = id(zMusIDPtr_MTZ) ; 85
MusID_HTZ = id(zMusIDPtr_HTZ) ; 86
MusID_ARZ = id(zMusIDPtr_ARZ) ; 87
MusID_CNZ_2P = id(zMusIDPtr_CNZ_2P) ; 88
MusID_CNZ = id(zMusIDPtr_CNZ) ; 89
MusID_DEZ = id(zMusIDPtr_DEZ) ; 8A
MusID_MCZ = id(zMusIDPtr_MCZ) ; 8B
MusID_EHZ_2P = id(zMusIDPtr_EHZ_2P) ; 8C
MusID_SCZ = id(zMusIDPtr_SCZ) ; 8D
MusID_CPZ = id(zMusIDPtr_CPZ) ; 8E
MusID_WFZ = id(zMusIDPtr_WFZ) ; 8F
MusID_HPZ = id(zMusIDPtr_HPZ) ; 90
MusID_Options = id(zMusIDPtr_Options) ; 91
MusID_SpecStage = id(zMusIDPtr_SpecStage) ; 92
MusID_Boss = id(zMusIDPtr_Boss) ; 93
MusID_EndBoss = id(zMusIDPtr_EndBoss) ; 94
MusID_Ending = id(zMusIDPtr_Ending) ; 95
MusID_SuperSonic = id(zMusIDPtr_SuperSonic); 96
MusID_Invincible = id(zMusIDPtr_Invincible); 97
MusID_ExtraLife = id(zMusIDPtr_ExtraLife) ; 98
MusID_Title = id(zMusIDPtr_Title) ; 99
MusID_EndLevel = id(zMusIDPtr_EndLevel) ; 9A
MusID_GameOver = id(zMusIDPtr_GameOver) ; 9B
MusID_Continue = id(zMusIDPtr_Continue) ; 9C
MusID_Emerald = id(zMusIDPtr_Emerald) ; 9D
MusID_Credits = id(zMusIDPtr_Credits) ; 9E
MusID_Countdown = id(zMusIDPtr_Countdown) ; 9F
MusID__End = id(zMusIDPtr__End) ; A0

Or if you have the clone driver installed

; Music IDs
offset := MusicIndex
ptrsize := 4
idstart := 1
; $00 is reserved for silence

MusID__First = idstart
MusID_2PResult = id(ptr_mus81) ; 01
MusID_EHZ = id(ptr_mus82) ; 02
MusID_MCZ_2P = id(ptr_mus83) ; 03
MusID_OOZ = id(ptr_mus84) ; 04
MusID_MTZ = id(ptr_mus85) ; 05
MusID_HTZ = id(ptr_mus86) ; 06
MusID_ARZ = id(ptr_mus87) ; 07
MusID_CNZ_2P = id(ptr_mus88) ; 08
MusID_CNZ = id(ptr_mus89) ; 09
MusID_DEZ = id(ptr_mus8A) ; 0A
MusID_MCZ = id(ptr_mus8B) ; 0B
MusID_EHZ_2P = id(ptr_mus8C) ; 0C
MusID_SCZ = id(ptr_mus8D) ; 0D
MusID_CPZ = id(ptr_mus8E) ; 0E
MusID_WFZ = id(ptr_mus8F) ; 0F
MusID_HPZ = id(ptr_mus90) ; 10
MusID_Options = id(ptr_mus91) ; 11
MusID_SpecStage = id(ptr_mus92) ; 12
MusID_Boss = id(ptr_mus93) ; 13
MusID_EndBoss = id(ptr_mus94) ; 14
MusID_Ending = id(ptr_mus95) ; 15
MusID_SuperSonic = id(ptr_mus96) ; 16
MusID_Invincible = id(ptr_mus97) ; 17
MusID_ExtraLife = id(ptr_mus98) ; 18
MusID_Title = id(ptr_mus99) ; 19
MusID_EndLevel = id(ptr_mus9A) ; 1A
MusID_GameOver = id(ptr_mus9B) ; 1B
MusID_Continue = id(ptr_mus9C) ; 1C
MusID_Emerald = id(ptr_mus9D) ; 1D
MusID_Credits = id(ptr_mus9E) ; 1E
MusID_Countdown = id(ptr_mus9F) ; 1F
MusID__End = id(ptr_musend) ; 20

Now add the extra music ids for the new zones. If you add a second one for each zone with a act 2, the last entry should be A9.

Now go to where the music is included. If you have the clone driver installed it is in the Sonic 2 Clone Driver v2 - Music.asm which is normally in the sound folder (Don't forget to add the pointers at the top!). If you are not using the clone driver go to s2.asm and find the loc_F803C: label.

Now add to the lists the correct ids (used in the constants). After you finish that go down to where the files are included (or bincluded if you do not have ASM music support). And make them match the ids above, just change the labels on the left but don't change the filenames yet, thats for the next section


Filenames

Now, for those that don't have ASM'd music, it will a easy copy, paste, and rename. But for those with ASM'd music you will need to go into each one and change the main project names and labels to something else or you will get double defined errors. You should be able to take the song name and simply do a find and replace on it. Now after you finished doing what you need to do, go back and change the includes to reflect the filenames you changed. Almost done, just have to edit the music loading code to use the new musiclist


Editing the game code

Now the easy and short part. Go to the label Level_GetBgm Now what you'll want to do is add at the end a new label. Ex level_GetAct Now go back up to where it says to branch to Level_PlayBgm and replace it with the new label you just added. Go to where is says lea MusicList2(pc),a1 and add bra.s Level_PlayBgm after that to make sure 2 player works. now in the level_GetAct add this

tst.b (Current_Act).w
beq.s Level_PlayBgm
lea MusicList3(pc),a1

This will check if its act 2 and play the correct list Go ahead and build, it should work but if you just copied and pasted the song files it will still play the same music.


If there is something wrong or it doesn't work right, add a comment and i'll try and fix it.

SCHG How-To Guide: Sonic the Hedgehog 2 (16-bit)
Fixing Bugs
Fix Demo Playback | Fix a Race Condition with Pattern Load Cues | Fix Super Sonic Bugs | Use Correct Height When Roll Jumping | Fix Jump Height Bug When Exiting Water | Fix Screen Boundary Spin Dash Bug | Correct Drowning Bugs | Fix Camera Y Position for Tails | Fix Tails Subanimation Error | Fix Tails' Respawn Speeds | Fix Accidental Deletion of Scattered Rings | Fix Ring Timers | Fix Rexon Crash | Fix Monitor Collision Bug | Fix EHZ Deformation Bug | Correct CPZ Boss Attack Behavior | Fix Bug in ARZ Boss Arrow's Platform Behavior | Fix ARZ Boss Walking on Air Glitch | Fix ARZ Boss Sprite Behavior | Fix Multiple CNZ Boss Bugs | Fix HTZ Background Scrolling Mountains | Fix OOZ Launcher Speed Up Glitch | Fix DEZ Giant Mech Collision Glitch | Fix Boss Deconstruction Behavior | Fix Speed Bugs | Fix 14 Continues Cheat | Fix Debug Mode Crash | Fix 99+ Lives | Fix Sonic 2's Sega Screen
Design Choices
Remove the Air Speed Cap | Disable Floor Collision While Dying | Modify Super Sonic Transformation Methods & Behavior | Enable/Disable Tails in Certain Levels | Collide with Water After Being Hurt | Retain Rings When Returning at a Star Post | Improve the Fade In\Fade Out Progression Routines | Fix Scattered Rings' Underwater Physics | Insert LZ Water Ripple Effect | Restore Lost CPZ Boss Feature | Prevent SCZ Tornado Spin Dash Death | Improve ObjectMove Subroutines | Port S3K Rings Manager | Port S3K Object Manager | Port S3K Priority Manager | Edit Level Order with ASM‎ | Alter Ring Requirements in Special Stages | Make Special Stage Characters Use Normal DPLCs | Speed Up Ring Loss Process | Change spike behaviour in Sonic 2
Adding Features
Create Insta-kill and High Jump Monitors | Create Clone and Special Stage Monitors | Port Knuckles
Sound Features
Expand Music Index to Start at $00 | Port Sonic 1 Sound Driver | Port Sonic 2 Clone Driver | Port Sonic 3 Sound Driver | Port Flamewing's Sonic 3 & Knuckles Sound Driver | Expand the Music Index to Start at $00 (Sonic 2 Clone Driver Version) | Play Different Songs Per Act
Extending the Game
Extend the Level Index Past $10 | Extend the Level Select | Extend Water Tables | Add Extra Characters | Free Up 2 Universal SSTs

|Add different music per act]]