Sonic and Sega Retro Message Board: Some changes and fixes for Sonic 2 - Sonic and Sega Retro Message Board

Jump to content

Hey there, Guest!  (Log In · Register) Help
  • 16 Pages +
  • ◄ First
  • 14
  • 15
  • 16
    Locked
    Locked Forum

Some changes and fixes for Sonic 2

#226 User is online Clownacy 

Posted 06 October 2017 - 06:17 PM

  • Posts: 736
  • Joined: 06-July 13
  • Gender:Not Telling
Ever notice how rings disappear while still onscreen if you move them offscreen slightly, but only off the top of the screen? I sure didn't until my last playthrough. Anyhow, it looks like this was fixed in S3K, so let's just do what that does.

The code that causes this is under BuildRings:

	move.w	4(a0),d2	; get ring Y pos
	sub.w	4(a3),d2	; subtract camera Y pos
	andi.w	#$7FF,d2
	addi_.w	#8,d2
	bmi.s	BuildRings_NextRing	; dunno how this check is supposed to work
	cmpi.w	#240,d2
	bge.s	BuildRings_NextRing	; if the ring is not on-screen, branch


What's important to note is how d2 is AND'd, and then 8 is added to it. The reason this is a problem is, consider that the ring is slightly offscreen: d2 will be $FFFF or so, which, after ANDing, becomes $7FF. Now, when adding 8 to it, it won't wrap back around to $0007, but $0807. It's also worth noting that the 'bmi' there is broken, also because of the position of this AND.

That said, the solution is pretty obvious: just move the 'andi' to before the 'cmpi' instead.

EDIT: Bonus change - Rings don't shake with the rest of the screen in places like the HTZ earthquake sequencies. If you want to correct this (like S3K looks like it did), just change the 'lea (Camera_X_pos).w,a3' to 'lea (Camera_X_pos_copy).w,a3'.
This post has been edited by Clownacy: 06 October 2017 - 06:27 PM

#227 User is online Clownacy 

Posted 29 October 2018 - 05:21 PM

  • Posts: 736
  • Joined: 06-July 13
  • Gender:Not Telling
...It's seriously been a year? Anyway, there's this one really annoying bug where if you enter Debug Mode underwater, and then exit it above-water, Sonic will still have his underwater physics.

This is because Sonic will only trigger his 'exiting water' code if he's above the water's Y-coordinate and his 'is underwater' flag is set. The problem is, when Sonic exits Debug Mode, it clears his 'is underwater' flag. This happens in sub_41CB8:

; sub_41CB8:
Debug_ResetPlayerStats:
	move.b	d0,anim(a1)
	move.w	d0,2+x_pos(a1) ; subpixel x
	move.w	d0,2+y_pos(a1) ; subpixel y
	move.b	d0,obj_control(a1)
	move.b	d0,spindash_flag(a1)
	move.w	d0,x_vel(a1)
	move.w	d0,y_vel(a1)
	move.w	d0,inertia(a1)
	; note: this resets the 'is underwater' flag, causing the bug where
	; if you enter Debug Mode underwater, and exit it above-water, Sonic
	; will still move as if he's underwater
	move.b	#2,status(a1)
	move.b	#2,routine(a1)
	move.b	#0,routine_secondary(a1)
	rts
; End of function Debug_ResetPlayerStats



As the comment points out, it's that 'move.b #2,status(a1)' line. To fix the bug, the 6th bit of Sonic's status needs to be preserved, like this:

	andi.b	#1<<6,status(a1)
	ori.b	#2,status(a1)



Funnily enough, this bug doesn't exist in Sonic 1 since Debug Mode resets way fewer variables.
This post has been edited by Clownacy: 29 October 2018 - 07:38 PM

#228 User is offline biggestsonicfan 

Posted 29 October 2018 - 08:14 PM

  • Model2wannaB
  • Posts: 727
  • Joined: 09-May 07
  • Gender:Male
  • Project:Formerly Sonic the Fighters

View Postredhotsonic, on 07 June 2012 - 05:00 PM, said:

Something Cool for CPZ boss!

THIS IS JUST FOR LAUGHS, but I thought I'd share it anyway! Back at the label "loc_2E692:". See these two lines?

	btst	#2,$2D(a1)
	beq.s	loc_2E6CA


Comment them out! And everytime Eggman drops the gunge, this will happen!

Posted Image


Well, I found it funny =P

Since I just found this thread, can this be converted into a GameGenie code for use on hardware? I have an itching to try it out but I've never compiled S2 from scratch and feel that the time and effort spent would decrease my overall enjoyment levels.

I plan to go through this whole thread because it's absolutely fascinating. I'd love to do stuff to Sonic the Fighters like this once I understand it a little better (and I finish my decompile).

EDIT1: Actually it would make more sense to have it implemented as Esrael had it, but the download link is broken. :argh:
This post has been edited by biggestsonicfan: 29 October 2018 - 08:20 PM

#229 User is offline Wafer 

Posted 30 October 2018 - 04:14 PM

  • Posts: 7
  • Joined: 28-November 17

View Postbiggestsonicfan, on 29 October 2018 - 08:14 PM, said:

Since I just found this thread, can this be converted into a GameGenie code for use on hardware? I have an itching to try it out but I've never compiled S2 from scratch and feel that the time and effort spent would decrease my overall enjoyment levels.

I plan to go through this whole thread because it's absolutely fascinating. I'd love to do stuff to Sonic the Fighters like this once I understand it a little better (and I finish my decompile).

EDIT1: Actually it would make more sense to have it implemented as Esrael had it, but the download link is broken. :argh:/>

Honestly, don't be intimidated by the prospect of building from assembly. It's just downloading the source from Github and running build.bat. You could do it in like 5 minutes, and then you'll be able to look at doing other fixes yourself, and maybe move onto your own ideas.

  • 16 Pages +
  • ◄ First
  • 14
  • 15
  • 16
    Locked
    Locked Forum

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