Actions

Difference between revisions of "Sandbox"

From Sonic Retro

Line 3: Line 3:
 
It surprises me that nobody else took up responsibility for making this guide, considering I, as a major fan of hacks, have seen Knuckles implemented in Sonic 2 on more than one occasion. Today, I'll be explaining how you, too, can implement Knuckles into your hack.
 
It surprises me that nobody else took up responsibility for making this guide, considering I, as a major fan of hacks, have seen Knuckles implemented in Sonic 2 on more than one occasion. Today, I'll be explaining how you, too, can implement Knuckles into your hack.
 
===What You'll Need===
 
===What You'll Need===
-This guide (no duh, really)
+
*This guide (no duh, really)
-The Hg disassembly of Sonic 2
+
*The Hg disassembly of Sonic 2
-The one known disassembly of Knuckles in Sonic 2, found on the following page: [http://info.sonicretro.org/Disassemblies/ Disassemblies]
+
*The one known disassembly of Knuckles in Sonic 2, found on the following page: http://info.sonicretro.org/Disassemblies
-The ConTEXT text editor (because Notepad will take WAY too long)
+
*The ConTEXT text editor (because Notepad will take WAY too long)
-Your favorite Genesis emulator (a.k.a. Kega Fusion)
+
*Your favorite Genesis emulator (a.k.a. Kega Fusion)
  
===Step 1: Creating the Knuckles object===
+
==Step 1: Creating the Knuckles object==
 
First, open up s2.asm in ConTEXT and search for "dc.l ObjNull." This should come up:
 
First, open up s2.asm in ConTEXT and search for "dc.l ObjNull." This should come up:
 
<asm>
 
<asm>

Revision as of 07:38, 13 January 2013

The following guide was made by Tailsguy24, and is not yet complete. DO NOT edit/delete it for any reason.

How to Port Knuckles into Sonic 2

It surprises me that nobody else took up responsibility for making this guide, considering I, as a major fan of hacks, have seen Knuckles implemented in Sonic 2 on more than one occasion. Today, I'll be explaining how you, too, can implement Knuckles into your hack.

What You'll Need

  • This guide (no duh, really)
  • The Hg disassembly of Sonic 2
  • The one known disassembly of Knuckles in Sonic 2, found on the following page: http://info.sonicretro.org/Disassemblies
  • The ConTEXT text editor (because Notepad will take WAY too long)
  • Your favorite Genesis emulator (a.k.a. Kega Fusion)

Step 1: Creating the Knuckles object

First, open up s2.asm in ConTEXT and search for "dc.l ObjNull." This should come up: <asm>

               dc.l ObjNull ; Obj4C
               dc.l ObjNull ; Obj4D
               dc.l ObjNull ; Obj4E
               dc.l ObjNull ; Obj4F

</asm> Change this line: <asm>

               dc.l ObjNull ; Obj4C

</asm>

To this: <asm>

               dc.l Obj4C   ; Knuckles

</asm>

We've now created our Knuckles object. Now let's get started.

Step 2: Creating the offset table

Now that you have your Knuckles object, go to whatever folder you saved the Knuckles in Sonic 2 disassembly to, open s2k.asm, and scroll down or search until you find the following code: <asm> Obj01_Index: dc.w Obj01_Init-Obj01_Index  ; 0 ; ... dc.w Obj01_Control-Obj01_Index  ; 1 dc.w Obj01_Hurt-Obj01_Index  ; 2 dc.w Obj01_Dead-Obj01_Index  ; 3 dc.w Obj01_Gone-Obj01_Index  ; 4 dc.w Obj01_Respawning-Obj01_Index ; 5 </asm> Back in s2.asm, copy and paste the following piece of code above the description of the Masher object: <asm>

----------------------------------------------------------------------------
Object 01 - Knuckles
----------------------------------------------------------------------------

Obj01: ; a0=character tst.w (Debug_placement_mode).w ; is debug mode being used? beq.s Obj01_Normal ; if not, branch jmp (DebugMode).l

---------------------------------------------------------------------------
loc_19F5C

Obj01_Normal: moveq #0,d0 move.b routine(a0),d0 move.w Obj01_Index(pc,d0.w),d1 jmp Obj01_Index(pc,d1.w)

End of function Obj01
----------------------------------------------------------------------------

</asm> Now copy the code I mentioned earlier in this step, and paste it below the code displayed above. Then, replace all of the "dc.w"'s with "offsetTableEntry.w"'s, delete the "-Obj01_Index" on the end of each line, move all of the entries down one line, add "offsetTable" to the top, and change all of the 01's in the whole section of code to 4C's. If you're following this guide correctly, your code should look like this: <asm>

----------------------------------------------------------------------------
Object 4C - Knuckles
----------------------------------------------------------------------------

Obj01: ; a0=character tst.w (Debug_placement_mode).w ; is debug mode being used? beq.s Obj4C_Normal ; if not, branch jmp (DebugMode).l

---------------------------------------------------------------------------
loc_19F5C

Obj4C_Normal: moveq #0,d0 move.b routine(a0),d0 move.w Obj4C_Index(pc,d0.w),d1 jmp Obj4C_Index(pc,d1.w)

End of function Obj4C
----------------------------------------------------------------------------

Obj4C_Index: offsetTable

       	offsetTableEntry.w Obj4C_Init           	  ; 0

offsetTableEntry.w Obj4C_Control  ; 2 offsetTableEntry.w Obj4C_Hurt  ; 4 offsetTableEntry.w Obj4C_Dead  ; 6 offsetTableEntry.w Obj4C_Gone  ; 8 offsetTableEntry.w Obj4C_Respawning  ; $A ... </asm> Now that THAT is done and over with, let's continue to importing Knuckles' many modes (or whatever you people call them).

Step 3: Obj4C_Init:

Right below the original code I mentioned earlier in Step 2, you should see this code: <asm>

---------------------------------------------------------------------------

Obj01_Init:  ; ... addq.b #2,$24(a0) move.b #$13,$16(a0) move.b #9,$17(a0) move.l #SK_Map_Knuckles,4(a0)  ; SK_Map_Knuckles move.b #2,$18(a0) move.b #$18,$19(a0) move.b #4,1(a0) move.w #$600,($FFFFF760).w move.w #$C,($FFFFF762).w move.w #$80,($FFFFF764).w tst.b ($FFFFFE30).w bne.s Obj01_Init_Continued move.w #$780,2(a0) bsr.w Adjust2PArtPointer2_Useless move.b #$C,$3E(a0) move.b #$D,$3F(a0) move.w 8(a0),($FFFFFE32).w move.w $C(a0),($FFFFFE34).w move.w 2(a0),($FFFFFE3C).w move.w $3E(a0),($FFFFFE3E).w

Obj01_Init_Continued:  ; ... move.b #0,$2C(a0) move.b #4,$2D(a0) move.b #0,($FFFFFE19).w move.b #$1E,$28(a0) sub.w #$20,8(a0) add.w #4,$C(a0) move.w #0,($FFFFEED2).w move.w #$3F,d2

loc_3153EC:  ; ... bsr.w Knuckles_RecordPositions subq.w #4,a1 move.l #0,(a1) dbf d2,loc_3153EC add.w #$20,8(a0) sub.w #4,$C(a0) </asm>

Test this

Follow what is currently in this guide and see if I'm doing this right. I don't want to write the next section if I'm not doing it right.