Difference between revisions of "Add Spin Dash to Sonic 1/Part 1"
From Sonic Retro
(2 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
{{GuideBy|Lightning}}<br> | {{GuideBy|Lightning}}<br> | ||
− | This tutorial was made possible thanks to the references, guides, and information found at [[Hacking CulT]], [[The Sonic 2 Beta Page]], [[Sonic Retro]], and [[Sonicology]]. | + | This tutorial was made possible thanks to the references, guides, and information found at [[Hacking CulT]], [[The Sonic 2 Beta Page]], [[Sonic Retro]], and [[Sonicology]]. I made this for the newest Github Disassembly. Thanks to [[User:Kramlat|Kramlat]] for the latest guide before this one. |
− | This SCHG is property of [[User:DikinBaus|DikinBaus]]. Sonic and all related characters and graphics that appear on this page are property of | + | This SCHG is property of [[User:DikinBaus|DikinBaus]]. Sonic and all related characters and graphics that appear on this page are property of SEGA and are used without permission for no profit. |
==Requirements== | ==Requirements== | ||
* [https://github.com/sonicretro/s1disasm Sonic 1 Disassembly Main] | * [https://github.com/sonicretro/s1disasm Sonic 1 Disassembly Main] | ||
− | * | + | * A plain text editor of your choice |
− | * [https:// | + | * [https://github.com/kirjavascript/Flex2/releases/tag/1.3.3 Flex 2] |
− | + | * A Sega Genesis Emulator ([https://retrocdn.net/images/6/6c/Fusion364.7z Kega Fusion] or [https://www.retrodev.com/blastem/ BlastEm] recommended) | |
− | |||
− | * A Sega Genesis | ||
In making this tutorial, I used: | In making this tutorial, I used: | ||
− | * Clownacys Sonic 1 Disassembly | + | * Clownacys Sonic 1 Disassembly (newest) |
− | |||
− | |||
* Windows' Notepad | * Windows' Notepad | ||
* Flex 2 | * Flex 2 | ||
* Kega Fusion | * Kega Fusion | ||
+ | == Importing the Spindash == | ||
− | == Adding a | + | |
+ | ===Adding a New Flag=== | ||
Alright, lets get started shall we? Open Constants.asm and scroll down to line 154. Now make a new space (or press enter) and define a new RAM equate by adding this line: | Alright, lets get started shall we? Open Constants.asm and scroll down to line 154. Now make a new space (or press enter) and define a new RAM equate by adding this line: | ||
Line 36: | Line 34: | ||
</syntaxhighlight> the code below '''bsr.w Sonic_Jump''' should not be worried about. | </syntaxhighlight> the code below '''bsr.w Sonic_Jump''' should not be worried about. | ||
− | Now, to actually copy the Spin Dash subroutine. You have to add a new .asm file. To do that go into Sonic 1's disassembly, create a new file within '''_incObj''' folder named Sonic Spindash.asm, for the sake of this SCHG I will add a download [https://cdn.discordapp.com/attachments/1166564744149336064/1188752933941153812/Sonic_Spindash.asm?ex=659bab71&is=65893671&hm=52ff2413b09201d6cc6fa636a8b36d5bc1e23da2bd5a5972be85d8b3ce86ce37& right here] with all the code. | + | Now, to actually copy the Spin Dash subroutine. You have to add a new .asm file. To do that go into Sonic 1's disassembly, create a new file within '''_incObj''' folder named Sonic Spindash.asm, for the sake of this SCHG I will add a download [https://cdn.discordapp.com/attachments/1166564744149336064/1188752933941153812/Sonic_Spindash.asm?ex=659bab71&is=65893671&hm=52ff2413b09201d6cc6fa636a8b36d5bc1e23da2bd5a5972be85d8b3ce86ce37& right here] with all the code. |
− | + | after that has been download and put in the '''_incObj''' folder. Go back to sonic.asm and go to '''loc_12EA6:''' (line 6996) scroll until you see '''include "_incObj/Sonic JumpDirection.asm"'''. | |
− | after that has been download and put in the '''_incObj''' folder. Go back to sonic.asm and go to '''loc_12EA6:''' (line 6996 | ||
Copy it, and right below it paste it but replace '''Sonic JumpDirection''' with '''Sonic SpinDash''' it should look something like this: | Copy it, and right below it paste it but replace '''Sonic JumpDirection''' with '''Sonic SpinDash''' it should look something like this: | ||
<syntaxhighlight lang="asm"> include "_incObj/Sonic Move.asm" | <syntaxhighlight lang="asm"> include "_incObj/Sonic Move.asm" | ||
Line 47: | Line 44: | ||
===First Bug=== | ===First Bug=== | ||
− | Uh-oh, so, as expected, | + | Uh-oh, so, as expected, there's bugs. The first being, if you collect a few rings then start SpinDashing, as you can see, the badnik(s) can hurt you in your SpinDash state. If you get hit while in state as said before, you'll still be in the SpinDashing state when you land, Sonic will charge forward (depends which way you got hit, forwards or backwards) usually it would destroy whatever badnik touches you in the first place, but that didn't happen. Second, go to high ground or somewhere where the camera can pan downward. Wait for the camera to fully pan down and start SpinDashing. The camera will continue to stay downwards until you stop SpinDashing/Rolling. Third, if you hold the Spindash button for long enough, your game will crash. Another problem that the camera can result is that if you SpinDash before an area where your vertical position radically changes (a great example is the double S-Tube in GHZ1), the camera is too slow to catch up to Sonic in time. |
− | |||
− | |||
[[Image:testing-2b.png|camera lagging behind]] | [[Image:testing-2b.png|camera lagging behind]] | ||
− | + | ===Animation Bugs=== | |
− | + | Now, you'll see that if you hold the Spindash button for long enough, it will show a few varieties of animations. Don't worry as we will fix this later on. | |
− | === | ||
− | Now, | ||
− | |||
− | |||
===Fixing Bugs/Errors=== | ===Fixing Bugs/Errors=== | ||
− | First of all, the camera issue is already fixed. But there is one thing | + | First of all, the camera issue is already fixed. But there is one thing, the camera is still too slow. So, if you go down an S-Tube, the camera will be too slow and you'll die due to the bottom boundary. Now for the Spindash badnik hurt bug. Go to '''_incObj/sub ReactToItem''' and look for '''React_Enemy:''' (line 167) and find this peice of code: |
+ | <syntaxhighlight lang="asm">React_Enemy: | ||
+ | tst.b (v_invinc).w ; is Sonic invincible? | ||
+ | bne.s .donthurtsonic ; if yes, branch | ||
+ | cmpi.b #id_Roll,obAnim(a0) ; is Sonic rolling/jumping? | ||
+ | bne.w React_ChkHurt ; if not, branch</syntaxhighlight> | ||
+ | and replace it with this, | ||
+ | <syntaxhighlight lang="asm">React_Enemy: | ||
+ | tst.b (v_invinc).w ; is Sonic invincible? | ||
+ | bne.s .donthurtsonic ; if yes, branch | ||
+ | cmpi.b #$1F,$1C(a0) ; is Sonic Spin Dashing? | ||
+ | beq.w .donthurtsonic ; if yes, branch | ||
+ | cmpi.b #id_Roll,obAnim(a0) ; is Sonic rolling/jumping? | ||
+ | bne.w React_ChkHurt ; if not, branch</syntaxhighlight> | ||
So, to fix this go into the '''_incObj''' folder and look for '''Sonic LevelBound''' once you find it, open it. Look for '''.bottom:''' (line 48) You should see this, | So, to fix this go into the '''_incObj''' folder and look for '''Sonic LevelBound''' once you find it, open it. Look for '''.bottom:''' (line 48) You should see this, | ||
Line 92: | Line 96: | ||
===Sonic Spindash Sprites=== | ===Sonic Spindash Sprites=== | ||
− | As you can see, Sonic doesn't have a SpinDash sprite as it's not present in Sonic 1, so open up [https:// | + | As you can see, Sonic doesn't have a SpinDash sprite as it's not present in Sonic 1, so open up Flex 2. |
− | + | Now, [https://cdn.discordapp.com/attachments/1213547116480172034/1213547665204322304/Sonic_1_Sprites.zip?ex=65f5df56&is=65e36a56&hm=1773aa71cb69861752e56625bcb18384bc3c1acb5c108e110442eac4426aca83& download] Sonic 1 Sprites (needed) and [https://cdn.discordapp.com/attachments/1213547116480172034/1213547949963870281/Spindash_Sprites.zip?ex=65f5df99&is=65e36a99&hm=bdda9188ada07f22415ca0672ef4fe1a0520f562c061a8151c486f9c7ac67bed& the Spindash sprites.] Extract the file if not yet, and go back in Flex 2. Now, go to the File section in Flex, and make sure to turn on DPLCs (look to the right until you see it) and put the following sprites as shown in this picture. | |
[[File:Sonic-Flex.png]] | [[File:Sonic-Flex.png]] | ||
− | If all is well, your sprites should be correct. | + | If all is well, your sprites should be correct. Here comes the part if gets confusing. Find the SpinDash sprites you downloaded earlier, and extract them if not yet, |
− | once | + | once extracted. Go to the Mappings section in Flex 2 and scroll down until you see a '''Import Spritesheet''' button (It's in the blue buttons to the right) and select the SpinDash sprite. Click '''Detect Sprites''' and then '''Import Sprites''' (You have to do it for each SpinDash sprite.) Once finished, while on the '''Mapping''' section, go on the right where the sprites are and scroll to the bottom until you see the SpinDash sprites you added. Select the sprites, and on the display select the whole sprite and press the down arrow key 9 times. (Do this for each sprite.) If you're confused, I'll add an image right below. |
+ | |||
[[File:Sonic-spindash-flex.png]] | [[File:Sonic-spindash-flex.png]] | ||
− | Once that's finished, go back and build your ROM. Awesome! You now have a functional SpinDash | + | |
− | <syntaxhighlight lang="asm"> | + | Once that's finished, go back and build your ROM. Awesome! You now have a functional SpinDash! Remember when I said, "Now, you'll see that if you hold the Spindash button for long enough, it will show a few varieties of animations. Don't worry as we will fix this later on."? This is later on, go to '''_anim/Sonic.asm''' and go to the very bottom. Once there, paste this in. |
− | + | ||
− | + | <syntaxhighlight lang="asm">id_Spindash: equ (ptr_Spindash-Ani_Sonic)/2 ; $1F</syntaxhighlight> | |
− | + | ||
− | + | Once that's done, go below the line, | |
− | and | + | |
− | <syntaxhighlight lang="asm"> | + | <syntaxhighlight lang="asm">SonAni_Float4: dc.b 3, fr_Float1, afChange, id_Walk |
− | + | even</syntaxhighlight> (line ''101'') | |
− | + | ||
− | + | and paste this in. | |
− | + | ||
− | + | <syntaxhighlight lang="asm">SonAni_SpinDash: dc.b 0, $5A, $59, $5A, $5A, $5A, $5B, $5A, $5C, $5A, $5D, afEnd | |
− | + | even</syntaxhighlight> | |
− | + | ||
+ | We're one step away from getting a functioning Spindash! Now go below, | ||
+ | |||
+ | <syntaxhighlight lang="asm">ptr_Float4: dc.w SonAni_Float4-Ani_Sonic</syntaxhighlight> (line ''36'') | ||
+ | and paste this in. | ||
+ | |||
+ | <syntaxhighlight lang="asm">ptr_Spindash: dc.w SonAni_SpinDash-Ani_Sonic ;1F</syntaxhighlight> | ||
+ | |||
+ | We did it! We successfully imported the Spindash into Sonic 1! It's still not fully complete though. No need to worry for Pu7o has written a [[SCHG How-to:Add Spin Dash to Sonic 1/Part 2|wonderful guide that picks up from this point.]] | ||
+ | |||
− | |||
− | |||
{{S1Howtos}} | {{S1Howtos}} | ||
|Add Spin Dash to Sonic 1 (GitHub)]] | |Add Spin Dash to Sonic 1 (GitHub)]] |
Latest revision as of 14:16, 2 March 2024
(Original guide by Lightning)
This tutorial was made possible thanks to the references, guides, and information found at Hacking CulT, The Sonic 2 Beta Page, Sonic Retro, and Sonicology. I made this for the newest Github Disassembly. Thanks to Kramlat for the latest guide before this one.
This SCHG is property of DikinBaus. Sonic and all related characters and graphics that appear on this page are property of SEGA and are used without permission for no profit.
Contents
Requirements
- Sonic 1 Disassembly Main
- A plain text editor of your choice
- Flex 2
- A Sega Genesis Emulator (Kega Fusion or BlastEm recommended)
In making this tutorial, I used:
- Clownacys Sonic 1 Disassembly (newest)
- Windows' Notepad
- Flex 2
- Kega Fusion
Importing the Spindash
Adding a New Flag
Alright, lets get started shall we? Open Constants.asm and scroll down to line 154. Now make a new space (or press enter) and define a new RAM equate by adding this line:
spindash_flag: equ $39
Adding the SpinDash to the Player
Open sonic.asm in your text editor, and search for the phrase Sonic_MdNormal: (line 6948) and above bsr.w Sonic_Jump, make a new line and add bsr.w Sonic_SpinDash to it you should end up with this:Sonic_MdNormal:
bsr.w Sonic_SpinDash
bsr.w Sonic_Jump
Now, to actually copy the Spin Dash subroutine. You have to add a new .asm file. To do that go into Sonic 1's disassembly, create a new file within _incObj folder named Sonic Spindash.asm, for the sake of this SCHG I will add a download right here with all the code. after that has been download and put in the _incObj folder. Go back to sonic.asm and go to loc_12EA6: (line 6996) scroll until you see include "_incObj/Sonic JumpDirection.asm". Copy it, and right below it paste it but replace Sonic JumpDirection with Sonic SpinDash it should look something like this:
include "_incObj/Sonic Move.asm"
include "_incObj/Sonic RollSpeed.asm"
include "_incObj/Sonic JumpDirection.asm"
include "_incObj/Sonic SpinDash.asm"
Save your changes, navigate back to the main part of the disassembly and run build.bat
First Bug
Uh-oh, so, as expected, there's bugs. The first being, if you collect a few rings then start SpinDashing, as you can see, the badnik(s) can hurt you in your SpinDash state. If you get hit while in state as said before, you'll still be in the SpinDashing state when you land, Sonic will charge forward (depends which way you got hit, forwards or backwards) usually it would destroy whatever badnik touches you in the first place, but that didn't happen. Second, go to high ground or somewhere where the camera can pan downward. Wait for the camera to fully pan down and start SpinDashing. The camera will continue to stay downwards until you stop SpinDashing/Rolling. Third, if you hold the Spindash button for long enough, your game will crash. Another problem that the camera can result is that if you SpinDash before an area where your vertical position radically changes (a great example is the double S-Tube in GHZ1), the camera is too slow to catch up to Sonic in time.
Animation Bugs
Now, you'll see that if you hold the Spindash button for long enough, it will show a few varieties of animations. Don't worry as we will fix this later on.
Fixing Bugs/Errors
First of all, the camera issue is already fixed. But there is one thing, the camera is still too slow. So, if you go down an S-Tube, the camera will be too slow and you'll die due to the bottom boundary. Now for the Spindash badnik hurt bug. Go to _incObj/sub ReactToItem and look for React_Enemy: (line 167) and find this peice of code:
React_Enemy:
tst.b (v_invinc).w ; is Sonic invincible?
bne.s .donthurtsonic ; if yes, branch
cmpi.b #id_Roll,obAnim(a0) ; is Sonic rolling/jumping?
bne.w React_ChkHurt ; if not, branch
and replace it with this,
React_Enemy:
tst.b (v_invinc).w ; is Sonic invincible?
bne.s .donthurtsonic ; if yes, branch
cmpi.b #$1F,$1C(a0) ; is Sonic Spin Dashing?
beq.w .donthurtsonic ; if yes, branch
cmpi.b #id_Roll,obAnim(a0) ; is Sonic rolling/jumping?
bne.w React_ChkHurt ; if not, branch
So, to fix this go into the _incObj folder and look for Sonic LevelBound once you find it, open it. Look for .bottom: (line 48) You should see this,
.bottom:
cmpi.w #(id_SBZ<<8)+1,(v_zone).w ; is level SBZ2 ?
bne.w KillSonic ; if not, kill Sonic
cmpi.w #$2000,(v_player+obX).w
blo.w KillSonic
clr.b (v_lastlamp).w ; clear lamppost counter
move.w #1,(f_restart).w ; restart the level
move.w #(id_LZ<<8)+3,(v_zone).w ; set level to SBZ3 (LZ4)
rts
Replace that whole code with this one
.bottom:
move.w (v_limitbtm1).w,d0
move.w (v_limitbtm2).w,d1
cmp.w d0,d1 ; screen still scrolling down?
blt.s .dontkill; if so, don't kill Sonic
cmpi.w #(id_SBZ<<8)+1,(v_zone).w ; is level SBZ2 ?
bne.w KillSonic ; if not, kill Sonic
cmpi.w #$2000,(v_player+obX).w
blo.w KillSonic
clr.b (v_lastlamp).w ; clear lamppost counter
move.w #1,(f_restart).w ; restart the level
move.w #(id_LZ<<8)+3,(v_zone).w ; set level to SBZ3 (LZ4)
rts
.dontkill:
rts
Sonic Spindash Sprites
As you can see, Sonic doesn't have a SpinDash sprite as it's not present in Sonic 1, so open up Flex 2. Now, download Sonic 1 Sprites (needed) and the Spindash sprites. Extract the file if not yet, and go back in Flex 2. Now, go to the File section in Flex, and make sure to turn on DPLCs (look to the right until you see it) and put the following sprites as shown in this picture. If all is well, your sprites should be correct. Here comes the part if gets confusing. Find the SpinDash sprites you downloaded earlier, and extract them if not yet, once extracted. Go to the Mappings section in Flex 2 and scroll down until you see a Import Spritesheet button (It's in the blue buttons to the right) and select the SpinDash sprite. Click Detect Sprites and then Import Sprites (You have to do it for each SpinDash sprite.) Once finished, while on the Mapping section, go on the right where the sprites are and scroll to the bottom until you see the SpinDash sprites you added. Select the sprites, and on the display select the whole sprite and press the down arrow key 9 times. (Do this for each sprite.) If you're confused, I'll add an image right below.
Once that's finished, go back and build your ROM. Awesome! You now have a functional SpinDash! Remember when I said, "Now, you'll see that if you hold the Spindash button for long enough, it will show a few varieties of animations. Don't worry as we will fix this later on."? This is later on, go to _anim/Sonic.asm and go to the very bottom. Once there, paste this in.
id_Spindash: equ (ptr_Spindash-Ani_Sonic)/2 ; $1F
Once that's done, go below the line,
SonAni_Float4: dc.b 3, fr_Float1, afChange, id_Walk
even
and paste this in.
SonAni_SpinDash: dc.b 0, $5A, $59, $5A, $5A, $5A, $5B, $5A, $5C, $5A, $5D, afEnd
even
We're one step away from getting a functioning Spindash! Now go below,
ptr_Float4: dc.w SonAni_Float4-Ani_Sonic
and paste this in.
ptr_Spindash: dc.w SonAni_SpinDash-Ani_Sonic ;1F
We did it! We successfully imported the Spindash into Sonic 1! It's still not fully complete though. No need to worry for Pu7o has written a wonderful guide that picks up from this point.
|Add Spin Dash to Sonic 1 (GitHub)]]