Sonic and Sega Retro Message Board: Random freezing (ROM build glitch) - Sonic and Sega Retro Message Board

Jump to content

Hey there, Guest!  (Log In · Register) Help
Loading News Feed...
 
Page 1 of 1

Random freezing (ROM build glitch)

#1 User is offline redhotsonic 

Posted 16 February 2012 - 06:55 PM

  • Also known as RHS
  • Posts: 978
  • Joined: 31-January 05
  • Gender:Male
  • Location:United Kingdom
  • Project:Sonic 2 Recreation
  • Wiki edits:24
Apologies if this is in the wrong forum.

Here I am again, another problem, probably the weirdest one yet, but it gets rid of a lot of bugs! Any help would be most grateful!



You can skip this story (spoiler) if you like and get on with the real problem.



Spoiler








Anyway, I was doing some work on something to my hack, completely unrelated to the SEGA screen. I was getting frustrated at what I was doing, and kept asking REGEN to open my ROM when it was in the middle of building, and as you can imagine:



"This file does not exist" (because it's in the middle of building).



Anyway, just before it finished building, the ROM opened, and there he was! Sonic running across the SEGA screen! WTF? I was so happy he was there.



Then, when I next built the ROM, he was gone again? I haven't touched it, what happened? Then I tried building it again and tried re-opening the ROM over and over, and Sonic loaded again.





It seems if I open the ROM just before it finishes building, Sonic is there. If I reload the same ROM later, because it finished building ages ago, Sonic has gone again.





Funnily enough, if I load the ROM before it finished building and Sonic is there, all my previous bugs are gone. No more random freezes, no more sprite glitching (well I played through my whole ROM twice this way and never came across it, even by going to the places it normally happens, it was fine).





Here is a video demonstrating what I am trying to say. As you can see, after if finally opens the ROM, Sonic is there. Resetting the ROM still shows Sonic (as you can see) But when I close the ROM then reload the same ROM, Sonic has gone again. Resetting the ROM stills shows no Sonic.



Sorry for the crap sound and video quality, the video freezes at the 0:13 point for a second for some reason





Has anyone else ever encountered this bug and no how to fix it? I'd greatly appreciate it.



P.S I do have this



;---------------------------------------------------------------------------------------
;Uncompressed art
;
;Patterns for Sonic 2
;---------------------------------------------------------------------------------------
 align $20000
ArtUnc_S2sonicart:     BINCLUDE "art\uncompressed\RHSart.bin"




With the alignment, Sonic isn't there. Without the alignment, there's garbled "Knuckles" sprites.



Posted Image

Loading the ROM quickly with $20000 alignment



Posted Image

Loading the ROM anytime with $20000 alignment



Posted Image

Loading the ROM quickly without alignment



Posted Image

Loading the ROM anytime without alignment





Cheers,

redhotsonic


EDIT: Forgot to mention, I'm using Xenowhirl's 2007 disassembly
This post has been edited by redhotsonic: 18 February 2012 - 08:05 AM

#2 User is offline flamewing 

Posted 16 February 2012 - 07:54 PM

  • Posts: 563
  • Joined: 11-October 10
  • Gender:Male
  • Project:Sonic Classic Heroes; Sonic 2 Special Stage Editor; Sonic 3&K Heroes (on hold)
  • Wiki edits:12
Try doing this first: find label loc_3A246 and locate the following block of code:
	andi.w	#$FFF,d0
	lsl.w	#5,d0
	lea	(a3,d0.w),a4 ; source ROM address of tiles to copy

Replace it by this:
	andi.l	#$FFF,d0
	lsl.l	#5,d0
	lea	(a3,d0.l),a4 ; source ROM address of tiles to copy

Build and see if it works.

#3 User is offline redhotsonic 

Posted 17 February 2012 - 01:01 PM

  • Also known as RHS
  • Posts: 978
  • Joined: 31-January 05
  • Gender:Male
  • Location:United Kingdom
  • Project:Sonic 2 Recreation
  • Wiki edits:24

View Postflamewing, on 16 February 2012 - 07:54 PM, said:

Try doing this first: find label loc_3A246 and locate the following block of code:
	andi.w	#$FFF,d0
	lsl.w	#5,d0
	lea	(a3,d0.w),a4 ; source ROM address of tiles to copy

Replace it by this:
	andi.l	#$FFF,d0
	lsl.l	#5,d0
	lea	(a3,d0.l),a4 ; source ROM address of tiles to copy

Build and see if it works.


It did something, but it didn't work. With your new instructions, with or without the alignment:


Posted Image

Loading up the ROM just before building finishes.


Posted Image
Posted Image
Posted Image
Posted Image

Loading up the ROM anytime after


So, even when loading up the ROM quickly, he no longer works.

#4 User is offline flamewing 

Posted 17 February 2012 - 02:58 PM

  • Posts: 563
  • Joined: 11-October 10
  • Gender:Male
  • Project:Sonic Classic Heroes; Sonic 2 Special Stage Editor; Sonic 3&K Heroes (on hold)
  • Wiki edits:12
That was to fix the issue of needing the alignment, as well as a few other problems that could crop up; but it clearly wasn't enough. Now lets go to part 2: open build.bat and edit it; you want to find 'MapRUnc_Sonic' and replace by the mappings file name in question. The 3 numbers after it ('$2D 0 4') are the mappings frame of the first running frame to use ($2D for Sonic in vanilla S2), the destination offset (the '0'; leave it alone) and the number of frames of running (the '4' -- vanilla S2 Sonic runs with 4 frames).
This post has been edited by flamewing: 17 February 2012 - 02:58 PM

#5 User is offline redhotsonic 

Posted 17 February 2012 - 03:26 PM

  • Also known as RHS
  • Posts: 978
  • Joined: 31-January 05
  • Gender:Male
  • Location:United Kingdom
  • Project:Sonic 2 Recreation
  • Wiki edits:24
off_3A294 MapRUnc_Sonic $2D 0 4


Sonic's running maps do start at $2D, so no point changing that. So I tried this:

off_3A294 MapRUnc_RHS $2D 0 4



Now when I build, at the end of the building process, it says:

Quote

WARNING: MapRUnc_RHS not found in s2.h


but

When I now load the game, at any time, Sonic is there. So this has worked!

But if it can't find it, how did it work? =P

#6 User is offline flamewing 

Posted 17 February 2012 - 03:45 PM

  • Posts: 563
  • Joined: 11-October 10
  • Gender:Male
  • Project:Sonic Classic Heroes; Sonic 2 Special Stage Editor; Sonic 3&K Heroes (on hold)
  • Wiki edits:12
At the end of s2.asm, add MapRUnc_RHS to the 'shared' line you find there. The reason it is working anyway is because you made sure to have the correct locations in 'off_3A294'; that line in build.bat fixes several locations in ROM to point to what they should point to.

#7 User is offline redhotsonic 

Posted 17 February 2012 - 04:04 PM

  • Also known as RHS
  • Posts: 978
  • Joined: 31-January 05
  • Gender:Male
  • Location:United Kingdom
  • Project:Sonic 2 Recreation
  • Wiki edits:24
Cheers mate, it worked a treat.

EDIT:

View Postflamewing, on 17 February 2012 - 03:45 PM, said:

At the end of s2.asm, add MapRUnc_RHS to the 'shared' line you find there.


I'm sorry, I do not understand.

;---------------------------------------------------------------------------------------
;Uncompressed art
;
;Patterns for Sonic 2
;---------------------------------------------------------------------------------------
	align $20000
ArtUnc_S2sonicart:     BINCLUDE	"art\uncompressed\RHSart.bin"
 
Nem_LevSel:		binclude	"LS_BG/GFX2.bin"
			even
 
Eni_LevSel:		binclude	"LS_BG/Map2.bin"
			even
 
Pal_LevSel:		binclude	"LS_BG/Pal2.bin"
			even

EndOfRom:
	END


Where would I put it to?



Also, I have another question that is off-topic to this one but saves me making a new topic.

Is there a way to display a message in the hack when the game freezes (similar to Sonic 1)? Every now and then, my hack suddenly freezes for no reason whatsoever. Normally it happens when you're about to get hurt like in this video. (iignore the flash at the 6 second mark, that was the video, no the hack itself)




But then again, it freezes for no reason at all:

Posted Image

Sonic is just running here, but it's actually frozen at this point. Because I have no leads to why it's going wrong, can I make it display something on where it went wrong? Regen only displays this when frozen:

ErrorTrap:
	nop
	nop
	bra.s	ErrorTrap


I will say, I have recently ported the S3K object manager in, and it never froze half as bad 'til then, so maybe I've gone wrong there. But who knows...
This post has been edited by redhotsonic: 17 February 2012 - 04:28 PM

#8 User is offline flamewing 

Posted 17 February 2012 - 05:37 PM

  • Posts: 563
  • Joined: 11-October 10
  • Gender:Male
  • Project:Sonic Classic Heroes; Sonic 2 Special Stage Editor; Sonic 3&K Heroes (on hold)
  • Wiki edits:12
Just before EndOfRom, add the line
	shared EndOfRom

Indeed porting the S3K object manager is fraught with peril, and any misstep can cause problems. As for the freezes: you may want to try my address error debugger (which I will be updating as soon as I get a mod to unlock the thread). If it is an address error, it will help a great deal.


#9 User is offline redhotsonic 

Posted 17 February 2012 - 07:34 PM

  • Also known as RHS
  • Posts: 978
  • Joined: 31-January 05
  • Gender:Male
  • Location:United Kingdom
  • Project:Sonic 2 Recreation
  • Wiki edits:24

View Postflamewing, on 17 February 2012 - 05:37 PM, said:

Just before EndOfRom, add the line
	shared EndOfRom


Haha, Sonic at the SEGA logo has gone wrong again =P

I think I will just put up with the error message, at least Sonic loads up right that way =P


View Postflamewing, on 17 February 2012 - 05:37 PM, said:

Indeed porting the S3K object manager is fraught with peril, and any misstep can cause problems. As for the freezes: you may want to try my address error debugger (which I will be updating as soon as I get a mod to unlock the thread). If it is an address error, it will help a great deal.


Cheers, I will test this out and get back to see what the results are

EDIT:

Quote

[#10171] You do not have permission to view this attachment.

Can't go about trying it.
This post has been edited by redhotsonic: 17 February 2012 - 07:50 PM

#10 User is offline flamewing 

Posted 17 February 2012 - 07:52 PM

  • Posts: 563
  • Joined: 11-October 10
  • Gender:Male
  • Project:Sonic Classic Heroes; Sonic 2 Special Stage Editor; Sonic 3&K Heroes (on hold)
  • Wiki edits:12

View Postredhotsonic, on 17 February 2012 - 07:34 PM, said:

View Postflamewing, on 17 February 2012 - 05:37 PM, said:

Just before EndOfRom, add the line
	shared EndOfRom


Haha, Sonic at the SEGA logo has gone wrong again =P

Oops, sorry; that was meant to be
	shared MapRUnc_RHS

I don't know why I pasted it wrong, but I failed to notice it.

View Postredhotsonic, on 17 February 2012 - 07:34 PM, said:

Cheers, I will test this out and get back to see what the results are

For what is worth, I will be updating it tomorrow (Aquaslash has graciously unlocked the thread for me), as soon as I finish up a couple of things.

#11 User is offline redhotsonic 

Posted 17 February 2012 - 08:10 PM

  • Also known as RHS
  • Posts: 978
  • Joined: 31-January 05
  • Gender:Male
  • Location:United Kingdom
  • Project:Sonic 2 Recreation
  • Wiki edits:24

View Postflamewing, on 17 February 2012 - 07:52 PM, said:

View Postredhotsonic, on 17 February 2012 - 07:34 PM, said:

View Postflamewing, on 17 February 2012 - 05:37 PM, said:

Just before EndOfRom, add the line
	shared EndOfRom


Haha, Sonic at the SEGA logo has gone wrong again =P

Oops, sorry; that was meant to be
	shared MapRUnc_RHS

I don't know why I pasted it wrong, but I failed to notice it.


That's what I did. Sonic is all garbled again. If I don't put it in, I get the error message, but he's fine =P

View Postflamewing, on 17 February 2012 - 07:52 PM, said:

View Postredhotsonic, on 17 February 2012 - 07:34 PM, said:

Cheers, I will test this out and get back to see what the results are

For what is worth, I will be updating it tomorrow (Aquaslash has graciously unlocked the thread for me), as soon as I finish up a couple of things.


Okay, mate. Will check by tomorrow




EDIT: Okay, my game froze again. Sonic has disapeared. It's near enough the same place as the last shot.

Posted Image


But this time, REGEN chucked this at me, something different from the normal errortrap:

Posted Image

No idea what it means though.



To me, I'm thinking it's something that I've done with respawn_index:

; conventions followed by most objects:
x_vel =			$10 ; and $11 ; horizontal velocity
y_vel =			$12 ; and $13 ; vertical velocity
y_radius =		$16 ; collision width / 2
x_radius =		$17 ; collision height / 2
anim_frame =		$1B
anim =			$1C
next_anim =		$1D
respawn_index =		$1E ; and $1F, it's now a word ; was just 23.
anim_frame_duration =	$23 ; was $1E and $1F.  Changed them all to bytes and made neccessary changes
status =		$22 ; note: exact meaning depends on the object... for sonic/tails: bit 0: leftfacing. bit 1: inair. bit 2: spinning. bit 3: onobject. bit 4: rolljumping. bit 5: pushing. bit 6: underwater.
routine =		$24 ; used to be 24
routine_secondary =	$25 ; used to be 25
angle =			$26 ; angle about the z=0 axis (360 degrees = 256)
; ---------------------------------------------------------------------------
; conventions followed by many objects but NOT sonic/tails:
collision_flags =	$20
collision_property =	$21
; $23 is free
subtype =		$28



You see, respawn_index HAS to be a word, so needed to find space somewhere. I know "anim_frame_duration" used to be a word, but I made the changes to make it work as a byte. For example, here is GameOver:

loc_13FE2:
	move.b	#$F0,anim_frame_duration(a0) ; anim_frame_duration - change from .w to .b
; the above was .w $2D0, now .b $F0
	addq.b	#2,routine(a0)
	rts
; ===========================================================================

loc_13FEE:
	btst	#0,mapping_frame(a0)
	bne.w	BranchTo17_DisplaySprite
		;tst.w	(Game_paused).w	; is game already paused?
	;beq.w	loc_1407E		; if yes, branch
	move.b	(Ctrl_1_Press).w,d0
	or.b	(Ctrl_2_Press).w,d0
	andi.b	#$70,d0
	bne.s	loc_14014
	tst.b	anim_frame_duration(a0) ; anim_frame_duration - change from .w to .b
	beq.s	loc_14014
; -----------------------------------------------------------------------------------
  move.b  ($FFFFFE05).w,d0 ; Move Game Frame timer to d0
  andi.b  #3,d0 ; andi by 3
  bne.s + ; if d0 does NOT equal 0, skip subtracting 1 byte from anim_frame_duration
; otherwise, subtract 1 byte from anim_frame_duration
; -----------------------------------------------------------------------------------
	subq.b	#1,anim_frame_duration(a0) ; anim_frame_duration - change from .w to .b
+ ; new label, so the above can skip the subtraction of anim_frame_duration correctly
	bra.w	DisplaySprite


Instead of anim_frame_duration counting down every frame, it counts down every 4 frames. I tested it and it worked perfectly fine.

This is my only guess for the random freezes, 'cause it's only started to happen since the port of the S3K object manager.


EDIT: I KNOW WHAT'S CAUSING THE FREEZING. It's definately the respawn_index. Most freezing happens when I'm about to touch something that used to be there before (destroyed or not).

Check this video. Notice that I jump over the crab badnik, but when I go back to him, he's not there. Run into his location, and ta-da! Froze.

Posted Image
This post has been edited by redhotsonic: 18 February 2012 - 07:04 PM

Page 1 of 1
    Locked
    Locked Forum

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