Sonic and Sega Retro Message Board: Sonic 3 Hacking - Sonic and Sega Retro Message Board

Jump to content

Hey there, Guest!  (Log In · Register) Help
  • 3 Pages +
  • 1
  • 2
  • 3
    Locked
    Locked Forum

Sonic 3 Hacking Because Non-Tech Members CAN'T avoid this game forever.

#31 User is offline Neo 

Posted 06 June 2017 - 03:52 AM

  • Clackerjack
  • Posts: 1315
  • Joined: 10-December 04
  • Gender:Male
  • Location:Portugal
  • Project:Sonic 3 Unlocked
  • Wiki edits:1

View PostClownacy, on 05 June 2017 - 07:14 PM, said:

And here I thought S2 was the only one to carelessly use an uninitialised register.

I was testing Sonic 3 Complete with a build of Genesis Plus GX with the error printing enabled, and noticed a warning appear at the start of HCZ when playing as Knuckles. Apparently, something was writing to an abnormal address, $2A7500. I switched to a vanilla S3K ROM, and confirmed that it happened there, too.

Luckily, the debug print gave me a PC address, so finding the cause was easy:

loc_6834:
		cmpi.w	#$100,(Current_zone_and_act).w
		bne.s	loc_6886
		move.b	#$1B,$20(a1)
		cmpi.w	#3,(Player_mode).w
		bne.s	loc_685C
		move.w	#$2121,$20(a1)
		move.b	#1,$23(a1)
		move.b	#0,$24(a0)

loc_685C:


Note that last instruction: it uses a0 instead of a1. Surprise, a0 is never initialised, hence why it writes to such a strange address.

Nothing happens though, right? I mean, $2A7500 is a ROM address.

I'm guessing that line is probably useless and $24(a1) is always 0 at that point anyway.
This post has been edited by Neo: 06 June 2017 - 03:58 AM

#32 User is offline Clownacy 

Posted 31 January 2018 - 06:46 PM

  • Layin' the Wax and Spinnin' the Sounds
  • Posts: 675
  • Joined: 06-July 13
  • Gender:Male
  • Location:Englandland
I figure it's about time I crosspost this:

So, in S&K, when you're climbing a wall with Knuckles and stop, he resets to a certain frame of his animation. In KiS2, this isn't the case - his animation just freezes. At first I thought this was a bug in KiS2, or maybe a missing feature, but upon looking at the code, it turned out to be a bug in S&K!

Basically, S&K added some extra collision code for whatever reason, but what the programmer didn't catch is that the new code overwrites a certain register, which was being used to control Knuckles's animation.

This post on Sonic 3 Unlocked, and the comment of mine that it quotes, goes into more detail.

loc_16E10:

		move.b	(Ctrl_1_logical).w,d0
		andi.b	#3,d0
		bne.s	loc_16E34
		move.b	$46(a0),d5
		move.w	$14(a0),d2
		addi.w	#9,d2
		move.w	$10(a0),d3
		bsr.w	sub_F828
		tst.w	d1
		bmi.w	loc_16D6E

loc_16E34:
		tst.w	d1
		beq.s	loc_16E60


Fixing this is a little more complex than just backing d1 up to the stack: with the way the code is arranged, you have to be careful to not cause a memory leak. The fix I used basically required I change that last check, and some of the code after it, to use a different register entirely.

#33 User is offline Neo 

Posted 01 February 2018 - 06:53 AM

  • Clackerjack
  • Posts: 1315
  • Joined: 10-December 04
  • Gender:Male
  • Location:Portugal
  • Project:Sonic 3 Unlocked
  • Wiki edits:1

View PostClownacy, on 31 January 2018 - 06:46 PM, said:

This post on Sonic 3 Unlocked, and the comment of mine that it quotes, goes into more detail.

Cheers, I figured that might have been you. Nice sleuthing.

  • 3 Pages +
  • 1
  • 2
  • 3
    Locked
    Locked Forum

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