Sonic and Sega Retro Message Board: Is it possible to make characters invincible to elements? - Sonic and Sega Retro Message Board

Jump to content

Hey there, Guest!  (Log In · Register) Help
Page 1 of 1
    Locked
    Locked Forum

Is it possible to make characters invincible to elements? For sonic 3, I was just wondering.

#1 User is offline Jakobuniverse 

  Posted 29 August 2017 - 02:23 PM

  • Posts: 3
  • Joined: 11-August 16
I was wondering if it was possible to make it so each character has the ability to be invincible to a specific hazard. For example, Sonic could be resistent to fire, tails to water, and knuckles to electric. I'd imagine it's possible to do with a lot of hex editing. If it isn't, is there a way to make it so you'd always have the elemental shields, sorta like hard coding a cheat code?

#2 User is offline MarkeyJester 

Posted 29 August 2017 - 03:23 PM

  • The architect of the universe, didn't build a stairway, leading nowhere.
  • Posts: 1819
  • Joined: 22-July 08
  • Gender:Male
  • Location:Japan
  • Wiki edits:16
Yes, it is possible, and there are multiple ways to go about it.

You mentioned a hex editor, so I would suggest searching for this:

	08 (28-2F) 00 (04-06) 00 2B (67/66)

And swapping them for:

	0C (28-2F) 00 (00-02) 00 38 (66/67)

You'd get something like this: http://mrjester.hapisan.com/Dump.bin

This will effect everything though, so you'll find Sonic will have the fireshield attack, Knuckles may attempt to attract rings, and so forth. By swapping only a selected number of the instances above, you can fine tune this to your desire.

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

I would however recommend that you look into a disassembly instead, and the CPU instruction set for the Mega Drive's main CPU. This'll allow you better and easier control over the code in question, and you'd have the ability to understand how it works too. You can obtain a copy of the disassembly right here.

#3 User is offline Jakobuniverse 

Posted 29 August 2017 - 06:33 PM

  • Posts: 3
  • Joined: 11-August 16
Oh, thanks! My only question is,which one of these control which character, so if for example i wanted to switch them around?

#4 User is offline MarkeyJester 

Posted 29 August 2017 - 09:46 PM

  • The architect of the universe, didn't build a stairway, leading nowhere.
  • Posts: 1819
  • Joined: 22-July 08
  • Gender:Male
  • Location:Japan
  • Wiki edits:16
Well alright, I'll break down these values:

	08 (28-2F) 00 (04-06) 00 2B (67/66)

  • The 08 28-2F together form the instruction "btst" (Bit TeST).
  • The actual 28-2F part, decides the indirect address register (28 = register a0, 29 = register a1, 2A = register a2, 2B = register a3, etc...).
  • The 00 04-06 together form the bit value to be tested (00 04 = 4th bit, 00 05 = 5th bit, 00 06 = 6th bit), this will be the shield type, of which 4 is fire, 5 is lightning, and 6 is bubble, the other values like 0, 1, 2, etc will be other things, like invincible.
  • The 00 2B is the indexing displacement of a0 - a7, this is part of the object relative index.
  • The 67/66 is the beginning part of a conditional branch instruction that occurs after the "btst" instruction. 66 = bne, 67 = beq.

So, effectively, when you see 08 28 00 05 00 2B 66 ..., what you'll be seeing is:

		btst	#$0005,$002B(a0)
		bne ...

This is effectively testing to see if you have the lightning shield.

What we're swapping it with is this:

	0C (28-2F) 00 (00-02) 00 38 (66/67)

  • The 0C 28-2F together form the instruction "cmp" (CoMPare).
  • The actual 28-2F part, decides the indirect address register (28 = register a0, 29 = register a1, 2A = register a2, 2B = register a3, etc...).
  • The 00 00-02 together form the byte value to be compared (00 00 = Sonic, 00 01 = Tails, 00 02 = Knuckles).
  • The 00 38 is the indexing displacement of a0 - a7, this is part of the object relative index.
  • The 67/66 is the beginning part of a conditional branch instruction that occurs after the "cmp" instruction. 66 = bne, 67 = beq.

So, effectively, when you swap it with 0C 28 00 02 00 38 67 ..., what you'll be seeing is:

		cmp.b	#$0002,$0038(a0)
		beq ...

In the ROM I've sent, 08 has been changed to 0C, the 28-2F has been left alone (to use the same intended register), the 00 04-06 part has been swapped such that 00 04 becomes 00 00 (fire to Sonic), 00 05 becomes 00 02 (lightning to Knuckles), 00 06 becomes 00 01 (bubble to Tails). The 00 2B has been changed to 00 38 so it indexes the right byte. Finally, the 66/67, if it's 66 (bne), it needs to be changed to 67 (beq), if it's 67, it needs to be changed to 66. The beq/bne needs to be reversed due to the nature of "cmp" being subtract in disguise.

Once again, I strongly recommend looking into the disassembly itself, it'll serve you better than modifying the ROM in binary. But, this information should at least open your mind up the possibilities that; realistically speaking... Nothing is impossible.

#5 User is offline Jakobuniverse 

Posted 29 August 2017 - 09:54 PM

  • Posts: 3
  • Joined: 11-August 16
Oh, thanks! Sorry for bothering you, but i got one more question. I have a disassembly, but where would i find the code for the game, exactly?

#6 User is offline MarkeyJester 

Posted 29 August 2017 - 10:09 PM

  • The architect of the universe, didn't build a stairway, leading nowhere.
  • Posts: 1819
  • Joined: 22-July 08
  • Gender:Male
  • Location:Japan
  • Wiki edits:16
"sonic3k.asm" would be a good start, you can open it with notepad (or plenty of other text editing programs on the internet if you'd prefer).

I'll give you a little headstart and a nudge, if you opening up and search for "loc_6A02:", you'll find this:

loc_6A02:
					; SpawnLevelMainSprites_SpawnPowerup+46j
		btst	#4,d0
		beq.s	loc_6A28
		andi.b	#$8E,$2B(a1)
		bset	#0,$2B(a1)
		bset	#4,$2B(a1)
		move.l	#Obj_Fire_Shield,(Shield).w
		move.w	a1,($FFFFCD2A).w
		rts

As you can no doubt guess, this will spawn/create the fire shield (when a monitor is destroyed), the "bset #4,$2B(a1)" should be familiar~ "bset" (Bit SET).

If you keep searching for "#4,$2B", you can find various instances, specifically beginning with "bset" (Bit SET - for enabling the shield), "bclr" (Bit CLeaR - for disabling the shield), and "btst" (Bit TeST - for checking if it was set or not). Have a good look around, play with the numbers, if you save the file after you've edited it in some form. Then go into the "Build Scripts" folder, and run the "buildS3Complete.bat" file, it'll assemble your changes, and it'll spit out a "sonic3k.bin" ROM (at the root of the disassembly), which will be Sonic 3 & Knuckles, but with your changes. Make backups though, this is just in case you make a mistake and don't know how to fix it, you've got a copy of the project, before you broke it, thus, nothing is lost, and you can try again without worrying about making mistakes (which you will do, and are an important part of learning), but believe me when I say that learning can be compared to digging into a vien of pure solid gold, setting you onto a wonderful course of programming, gaining knowledge, and understanding your favourite games.

Good luck!

Page 1 of 1
    Locked
    Locked Forum

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users