Sonic and Sega Retro Message Board: Update: How to port S3K Priority Manager into S2 - Sonic and Sega Retro Message Board

Jump to content

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

Update: How to port S3K Priority Manager into S2 Let's speed up your hack! (Updated 15/07/2012)

#16 User is offline KingofHarts 

Posted 27 June 2012 - 07:05 PM

  • Call me back when people stop shitting in the punch bowl...
  • Posts: 1480
  • Joined: 07-August 10
  • Gender:Male
  • Wiki edits:1

View Postredhotsonic, on 27 June 2012 - 07:24 AM, said:

View PostKingofHarts, on 27 June 2012 - 02:29 AM, said:

PLEASE look through and make sure I've made no mistakes... I will finish it and include the optional items, and fix any errors as needed later.



Looks good to me. I guess you couldn't colour code them like I did in the forums? Some instructions for labels need their own line too, like here for example:

Quote

SVN users ONLY: For first label, do a search for this line:


        _move.b d4,id(a1) ; load obj1F


Second label is "BreakObjectToPieces_InitObject:" Third label is "Obj79_MakeSpecialStars:" Fourth Label is "loc_25C24:" And fifth label is "Obj73_LoadSubObject:"

Under each of these labels, you should see this line:



This just needs neatening up a bit. Otherwise, when they read "Under each of these labels, you should see this line:", they may think it's still for SVN only.


I've fucked around with it a little bit. I'm going to give the optional item its own page, and will create the SST page today as well. Steps 1 and 12 will link to this new page instead of having excerpts put in... it just feels like the page is WAY too long.

I'll try to tidy it up a little more in the future... but with the color, it should be easy enough to follow. Lemme know if you got any issues with it that you'd like me to fix up. I will try to look into including images on the wiki... as I think almost all of the guides (Not just the ones I published on the wiki) could benefit by having the visuals.

Also, I made another page: http://info.sonicret...ove_subroutines
I'm gonna try to fix shit up this evening if I have time. Also I still gotta put together the SST guide from ages ago. Haven't forgotten. Just really backlogged...
This post has been edited by KingofHarts: 28 June 2012 - 02:29 AM

#17 User is offline Esrael 

Posted 29 June 2012 - 06:33 AM

  • Posts: 175
  • Joined: 24-July 03
  • Gender:Male
  • Location:Brazil, São Paulo, Guarulhos
  • Project:Esrael Neto Assembler Editor / Sonic 2 Delta
About processor cycles / speed up I had a question.
For the time I don't want changing all object, but using a table will make any differences?


This Code
;===============================================================================
; Sub Rotina DisplaySprite
; [ Início ]
;===============================================================================
DisplaySprite: ; Offset_0x01647A:
              ; lea     ($FFFFAC00).w, A1                     
              ; move.w  $0018(A0), D0
              ; lsr.w   #$01, D0                               
              ; andi.w  #$0380, D0                                 
              ; adda.w  D0, A1
;-------------------------------------------------------------------------------
                moveq   #$00, D0                               ; Neto - Sonic 2D    
                move.b  $0018(A0), D0                          ; Neto - Sonic 2D  
                add.w   D0, D0                                 ; Neto - Sonic 2D  
                add.w   D0, D0                                 ; Neto - Sonic 2D  
                move.l  DisplayTable(PC, D0), A1               ; Neto - Sonic 2D  
;-------------------------------------------------------------------------------              
                cmpi.w  #$007E, (A1)
                bcc.s   Exit_DisplaySprite                     ; Offset_0x016496
                addq.w  #$02, (A1)
                adda.w  (A1), A1
                move.w  A0, (A1)
Exit_DisplaySprite: ; Offset_0x016496:
                rts       
;===============================================================================
; Sub Rotina DisplaySprite
; [ Término ]
;===============================================================================  

DisplayTable:
                dc.l   $FFFFAC00, $FFFFAC80, $FFFFAD00, $FFFFAD80
                dc.l   $FFFFAE00, $FFFFAE80, $FFFFAF00, $FFFFAF80 
                dc.l   $FFFFAC00, $FFFFAC80, $FFFFAD00, $FFFFAD80
                dc.l   $FFFFAE00, $FFFFAE80, $FFFFAF00, $FFFFAF80  




vs original

;===============================================================================
; Sub Rotina DisplaySprite
; [ Início ]
;===============================================================================
DisplaySprite: ; Offset_0x01647A:
                lea     ($FFFFAC00).w, A1                     
                move.w  $0018(A0), D0
                lsr.w   #$01, D0                               
                andi.w  #$0380, D0                                 
                adda.w  D0, A1          
                cmpi.w  #$007E, (A1)
                bcc.s   Exit_DisplaySprite                     ; Offset_0x016496
                addq.w  #$02, (A1)
                adda.w  (A1), A1
                move.w  A0, (A1)
Exit_DisplaySprite: ; Offset_0x016496:
                rts       
;===============================================================================
; Sub Rotina DisplaySprite
; [ Término ]
;===============================================================================  



Another question? where we can find fast code execution tips? Ex:

lsl #$02, D0 ; one line

same results as

add.w D0, D0
add.w D0, D0
Two lines but less processor cycles.

Sorry for posting here, but since this port is for speeding up. I want to know, more tips for improving Speed with assembler.
Sometimes less code lines does not mean fast execution.

#18 User is offline redhotsonic 

Posted 29 June 2012 - 10:51 AM

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

View PostEsrael, on 29 June 2012 - 06:33 AM, said:

About processor cycles / speed up I had a question.
For the time I don't want changing all object, but using a table will make any differences?


This Code
;===============================================================================
; Sub Rotina DisplaySprite
; [ Início ]
;===============================================================================
DisplaySprite: ; Offset_0x01647A:
              ; lea     ($FFFFAC00).w, A1                     
              ; move.w  $0018(A0), D0
              ; lsr.w   #$01, D0                               
              ; andi.w  #$0380, D0                                 
              ; adda.w  D0, A1
;-------------------------------------------------------------------------------
                moveq   #$00, D0                               ; Neto - Sonic 2D    
                move.b  $0018(A0), D0                          ; Neto - Sonic 2D  
                add.w   D0, D0                                 ; Neto - Sonic 2D  
                add.w   D0, D0                                 ; Neto - Sonic 2D  
                move.l  DisplayTable(PC, D0), A1               ; Neto - Sonic 2D  
;-------------------------------------------------------------------------------              
                cmpi.w  #$007E, (A1)
                bcc.s   Exit_DisplaySprite                     ; Offset_0x016496
                addq.w  #$02, (A1)
                adda.w  (A1), A1
                move.w  A0, (A1)
Exit_DisplaySprite: ; Offset_0x016496:
                rts       
;===============================================================================
; Sub Rotina DisplaySprite
; [ Término ]
;===============================================================================  

DisplayTable:
                dc.l   $FFFFAC00, $FFFFAC80, $FFFFAD00, $FFFFAD80
                dc.l   $FFFFAE00, $FFFFAE80, $FFFFAF00, $FFFFAF80 
                dc.l   $FFFFAC00, $FFFFAC80, $FFFFAD00, $FFFFAD80
                dc.l   $FFFFAE00, $FFFFAE80, $FFFFAF00, $FFFFAF80  







I would have thought it's faster than the original Sonic 2 way, but it wouldn't be by much. But then this way, obviously uses more space (because you've inserted a table). You've used more space but a little bit of time saving. This is the type of thing where you ask yourself, "Speed or Size?"




If you're asking if it's faster then the S3K way, then it's definitely not. Your way, it still have to convert the byte into a word every single frame for every object (like normal Sonic2). And like said, the S3K way, it's already a word, and can just get on with things.





View PostEsrael, on 29 June 2012 - 06:33 AM, said:

Another question? where we can find fast code execution tips?


I do not know, but I would like to know this myself.

#19 User is offline Esrael 

Posted 29 June 2012 - 11:13 AM

  • Posts: 175
  • Joined: 24-July 03
  • Gender:Male
  • Location:Brazil, São Paulo, Guarulhos
  • Project:Esrael Neto Assembler Editor / Sonic 2 Delta

View Postredhotsonic, on 29 June 2012 - 10:51 AM, said:

View PostEsrael, on 29 June 2012 - 06:33 AM, said:

....




I would have thought it's faster than the original Sonic 2 way, but it wouldn't be by much. But then this way, obviously uses more space (because you've inserted a table). You've used more space but a little bit of time saving. This is the type of thing where you ask yourself, "Speed or Size?"




If you're asking if it's faster then the S3K way, then it's definitely not. Your way, it still have to convert the byte into a word every single frame for every object (like normal Sonic2). And like said, the S3K way, it's already a word, and can just get on with things.





View PostEsrael, on 29 June 2012 - 06:33 AM, said:

Another question? where we can find fast code execution tips?


I do not know, but I would like to know this myself.



Thanks for reply.

I do know which your method is more faster, but I am trying to improve without doing a lot of change.
This post has been edited by Esrael: 29 June 2012 - 11:16 AM

#20 User is offline flamewing 

Posted 29 June 2012 - 11:48 AM

  • Emerald Hunter
  • Posts: 831
  • Joined: 11-October 10
  • Gender:Male
  • Location:Brasil
  • Project:Sonic Classic Heroes; Sonic 2 Special Stage Editor; Sonic 3&K Heroes (on hold)
  • Wiki edits:12
Here it goes the speed analysis of the 3 versions:
The common code runs in 38 cycles (9 read cycles/0 write cycles) if branch taken, 68 cycles (13 read cycles/2 write cycles) if not; this should be added to all the following figures for the total function time.

The original S2 code runs in 44 cycles (9 read cycles/0 write cycles); Esrael's version is slightly faster at 42 cycles (10 read cycles/0 write cycles); the S3&K version presented by RedHotSonic* clocks 24 cycles (5 read cycles/0 write cycles), being the fastest. By pre-computing the multiplication by 4 when the priority is being assigned, Esrael's version can be go down by 8 cycles (2 read cycles/0 write cycles), down to a final speed of 34 cycles (8 read cycles/0 write cycles), being still slower than S3&K's.

Here is the breakdown:

; S2's version:
DisplaySprite:
        lea     (Sprite_Table_Input).w,a1       ;  8 (2/0)
        move.w  priority(a0),d0                 ; 12 (3/0)
        lsr.w   #1,d0                                   ;  8 (1/0)
        andi.w  #$380,d0                                ;  8 (2/0)
        adda.w  d0,a1                                   ;  8 (1/0)
; Total for S2's version:                         44 (9/0)

; S3&K's version:
DisplaySprite:
        lea     (Sprite_Table_Input).w,a1       ;  8 (2/0)
        adda.w  priority(a0),a1                 ; 16 (3/0)
; Total for S3&K's version:                       24 (5/0)

; Esrael's version:
DisplaySprite:
        moveq   #0,d0                                   ;  4 (1/0)
        move.b  priority(a0),d0                 ; 12 (3/0)
        add.w   d0,d0                                   ;  4 (1/0)
        add.w   d0,d0                                   ;  4 (1/0)
        move.l  DisplayTable(pc,d0),a1  ; 18 (4/0)
; Total for Esrael's version:             42 (10/0)

; Common to all:
        cmpi.w  #$7E,(a1)                               ; 12 (3/0)
        bcc.s   return_16510                    ; 10 (2/0) if taken, 8 (1/0) if not
        addq.w  #2,(a1)                                 ; 12 (2/1)
        adda.w  (a1),a1                                 ; 12 (2/0)
        move.w  a0,(a1)                                 ;  8 (1/1)
return_16510:
        rts                                                             ; 16 (4/0)
; Total for common code:                          38 (9/0) if branch taken, 68 (13/2) if not


* The actual version in S3&K has priority promotion code: if an object does not fit on its given priority slot, it is successively tries to promote to a lesser priority (higher value). This slows it down slightly if implemented; how much depends on how many sprites are on-screen of any given priority, but it probably runs at the best speed in most scenarios. For reference, here is the version I use in my hack:
DisplaySprite:
        lea     (Sprite_Table_Input).w,a1
        adda.w  priority(a0),a1

DisplaySprite_part2:
        cmpi.w  #$7E,(a1)
        bhs.s   DisplaySprite_part3
        addq.w  #2,(a1)
        adda.w  (a1),a1
        move.w  a0,(a1)

return_16510:
        rts
        
DisplaySprite_part3:
        cmpa.w  #Sprite_Table_Input+7*$80,a1
        beq.s   return_16510
        adda.w  #$80,a1
        bra.s   DisplaySprite_part2
; End of function DisplaySprite


View PostEsrael, on 29 June 2012 - 11:13 AM, said:

Thanks for reply.

I do know which your method is more faster, but I am trying to improve without doing a lot of change.

If you search the net for the m68000 user's manual, you can see it has a list of instruction speeds; this can be quite handy for evaluating code speed.

Edit: Fixed as discussed below.
This post has been edited by flamewing: 29 June 2012 - 09:05 PM

#21 User is offline redhotsonic 

Posted 29 June 2012 - 05:56 PM

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

View Postflamewing, on 29 June 2012 - 11:48 AM, said:

The original S2 code runs in 68 cycles (14 read cycles/0 write cycles); Esrael's version is faster at 42 cycles (10 read cycles/0 write cycles); the S3&K version presented by RedHotSonic* clocks 24 cycles (5 read cycles/0 write cycles), being the fastest. By pre-computing the multiplication by 4 when the priority is being assigned, Esrael's version can be go down by 8 cycles (2 read cycles/0 write cycles), down to a final speed of 34 cycles (8 read cycles/0 write cycles), being still slower than S3&K's.

Here is the breakdown:

; S2's version:
DisplaySprite:
	lea	(Sprite_Table_Input).w,a1	;  8 (2/0)
	move.w	priority(a0),d0			; 12 (3/0)
	lsr.w	#1,d0					;  8 (1/0)
	andi.w	#$380,d0				;  8 (2/0)
	adda.w	d0,a1					;  8 (1/0)
; Total for S2's version:			  68 (14/0)

; S3&K's version:
DisplaySprite:
	lea	(Sprite_Table_Input).w,a1	;  8 (2/0)
	adda.w	priority(a0),a1			; 16 (3/0)
; Total for S3&K's version:			  24 (5/0)

; Esrael's version:
DisplaySprite:
	moveq	#0,d0					;  4 (1/0)
	move.b	priority(a0),d0			; 12 (3/0)
	add.w	d0,d0					;  4 (1/0)
	add.w	d0,d0					;  4 (1/0)
	move.l	DisplayTable(pc,d0),a1	; 18 (4/0)
; Total for Esrael's version:		  42 (10/0)




I might be wrong here, but the break-down to S2, doesn't the cycles actually read 44, not 68 (making Esrael's version 2 cycles faster and not 26)? Or am I missing the point?






View PostMoDule, on 25 June 2012 - 09:19 AM, said:

One thing:
	move.b  (a1)+,priority(a0)
	move.w  priority(a0),d0
	lsr.w   #1,d0
	andi.w  #$380,d0
	move.w  d0,priority(a0)

I'd change it to this:
	moveq	#0,d0
	move.b  (a1)+,d0
	lsr.w   #1,d0
	andi.w  #$380,d0
	move.w  d0,priority(a0)


View PostTets, on 27 June 2012 - 06:32 AM, said:

Not sure if this is another case of my doing something wrong, but the control window in the Silver Sonic fight in DEZ appears in front of the player character. I've double- and triple-checked the priority values and they're exactly what they should be ($100 for Sonic/Tails and $180 for ObjAF).



Tets, have you followed Module's advice? If so, this is the problem. You need to do it my way (like I showed in the guide). I realised this when I implemented it to the Egg Prison. When I tried Module's code on the Egg Prison, all the priorities went wrong. I then tried it to "LoadSubObject_Part3:" then I got the same problem you are experiencing in DEZ. Changing it to the way I originally showed fixes this.


Although, why it does this, I actually do not know.

#22 User is offline flamewing 

Posted 29 June 2012 - 09:05 PM

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

View Postredhotsonic, on 29 June 2012 - 05:56 PM, said:

I might be wrong here, but the break-down to S2, doesn't the cycles actually read 44, not 68 (making Esrael's version 2 cycles faster and not 26)? Or am I missing the point?

Derp, you are right; where did I come up with the 68 cycles from? Anyway, I fixed the other post.

#23 User is offline redhotsonic 

Posted 30 June 2012 - 05:21 AM

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

View Postflamewing, on 29 June 2012 - 09:05 PM, said:

View Postredhotsonic, on 29 June 2012 - 05:56 PM, said:

I might be wrong here, but the break-down to S2, doesn't the cycles actually read 44, not 68 (making Esrael's version 2 cycles faster and not 26)? Or am I missing the point?

Derp, you are right; where did I come up with the 68 cycles from? Anyway, I fixed the other post.



That means for the sake of adding a table using more space, Esrael's version only makes it faster by 2 cycles. But then again, like said before, it's a matter of choice on speed vs size.

#24 User is offline flamewing 

Posted 30 June 2012 - 07:31 AM

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

View Postredhotsonic, on 30 June 2012 - 05:21 AM, said:

That means for the sake of adding a table using more space, Esrael's version only makes it faster by 2 cycles. But then again, like said before, it's a matter of choice on speed vs size.

Technically, with the improvement I suggested, it improves by 10 cycles -- priority is never more than 7 anyway, so multiplying by 4 is no biggie. But pre-multiplying by 4 takes quite more work than Esrael's original version, so yeah.

#25 User is offline BlueAuraEX 

Posted 30 June 2012 - 08:33 AM

  • The Blue Aura
  • Posts: 20
  • Joined: 15-April 10
  • Gender:Male
  • Location:????
  • Project:Nothing..."Yet"
Whoa! I'm loving that large increase in lag speed! This could most definitely help out Sonic 2 hacks in a massive way. Sure, it's a small, aesthetic change, but man does it make a big difference. Hoping to see this tool used in future Sonic 2 hacks! (especially a few that I'm waiting for personally, winkwink, nudgenudge)

#26 User is offline redhotsonic 

Posted 15 July 2012 - 05:09 AM

  • Also known as RHS
  • Posts: 1128
  • Joined: 31-January 05
  • Gender:Male
  • Location:United Kingdom
  • Project:Sonic 2 Recreation
  • Wiki edits:24
Hello, all! There is an update to the priority guide. 2 extra steps! These steps are actually bug fixes caused by the new priority manager, and you may want to implement these if you've followed my guide.


Thanks to flamewing for the help and advice on these fixes.




Step 10 update - Fix the priority for when the main character is dead


In my priority guide, for step 10, I explained that when you're dead, all the objects stop moving. And they all jump to "DisplaySprite:" via "RunObjectDisplayOnly:". Because of this, some objects that use priority for different reason will cause the game to crash. The way I showed you was that we had to make all objects use the same priority, so that it wouldn't freeze. Most of the time, this isn't a problem, but then, you'll may notice things like this:


Posted Image

Posted Image


This is because, when you die, all objects jump to the "RunObjectDisplayOnly:". As they're all using the same priority, a newer one will overlap. Take the EHZ boss. His drill gets displayed first, then his wheels (so they overlap), then the cockpit (so they overlap the rest), then finally Eggman (which overlaps all). See what I mean?


To fix this, it's simple, and I should have thought of it before (Sonic 2 Recreation has different coding and doesn't suffer this). Anyway, go to "RunObjectDisplayOnly:", and change from this:

RunObjectDisplayOnly:
	moveq	#0,d0
	move.b	(a0),d0	; get the object's ID
	beq.s	+	; if it's obj00, skip it
	tst.b	render_flags(a0)	; should we render it?
	bpl.s	+			; if not, skip it
	move.w	#$200,d0
	bsr.w	DisplaySprite3
+
	lea	next_object(a0),a0 ; load 0bj address
	dbf	d7,RunObjectDisplayOnly
	rts
; End of function RunObjectDisplayOnly



to this:

RunObjectDisplayOnly:
	moveq	#0,d0			; Clear d0 quickly
	move.b	(a0),d0			; get the object's ID
	beq.s	++			; if it's obj00, skip it
	tst.b	render_flags(a0)	; should we render it?
	bpl.s	++			; if not, skip it
	move.w	priority(a0),d0		; move object's priority to d0
	btst	#6,render_flags(a0)	; is the compound sprites flag set?
	beq.s	+			; if not, branch
	move.w	#$200,d0		; move $200 to d0
+
	bsr.w	DisplaySprite3		; Display the object with whatever is set at d0
+
	lea	next_object(a0),a0	; load 0bj address
	dbf	d7,RunObjectDisplayOnly
	rts
; End of function RunObjectDisplayOnly



So now, when all objects jump here, it will ask first, does it have the compound sprite flag set? If not, branch and continue, and use the object's original priority. If it IS set, it means that the current object's status table also contains information about other child sprites which need to be drawn using the current object's mappings. In other words, for our sake, it's using priority for something different. Therefore, it will NOT branch and it will move $200 to d0 instead.



That's it. Done, you'll now get stuff like this:

Posted Image

Posted Image


It was that simple.






Step 13 - Fix the priority for Tails' tails


This bug I only noticed the other day (was also present in S2R). The fix was a bit more involved than I thought.

The problem is, Tails' tail's priority has been affected. Even though Tails' priority is $100, and his tails' priority is $100. Here is an example:

Posted Image


It seems that his tails are not as much as a priority anymore. Anyway, flamewing had a solution, which he uses for his hack; Sonic 2 Heroes.



Anyway, the fix:


First, you're going to have to use some RAM. Only a word. So, go to your list of equates. I used $FFFFF5C0 (it's free whether you use the S1 sound driver or not). Call the RAM "Tails_Tails_ptr"

Tails_Tails_ptr =		ramaddr( $FFFFF5C0 )



Our new RAM is ready for use. First, go to "InitPlayers:" and under the line:

	move.b	#2,(Sidekick).w ; load Obj02 Tails object at $FFFFB040



SVN users, yours will say:

	move.b	#ObjID_Tails,(Sidekick+id).w ; load Obj02 Tails object at $FFFFB040



Insert this:

	move.w	#Tails_Tails,(Tails_Tails_ptr).w



So you have something like this (SVN users, reference only):

	move.b	#2,(Sidekick).w ; load Obj02 Tails object at $FFFFB040
	move.w	#Tails_Tails,(Tails_Tails_ptr).w
	move.w	(MainCharacter+x_pos).w,(Sidekick+x_pos).w
	move.w	(MainCharacter+y_pos).w,(Sidekick+y_pos).w
	subi.w	#$20,(Sidekick+x_pos).w
	addi.w	#4,(Sidekick+y_pos).w
	move.b	#8,(Tails_Dust).w ; load Obj08 Tails' spindash dust/splash object at $FFFFD140




Do the same at label "InitPlayers_TailsAlone:", so you have something like this (SVN users, reference only):

InitPlayers_TailsAlone:
	move.b	#2,(MainCharacter).w ; load Obj02 Tails object at $FFFFB000
	move.w	#Tails_Tails,(Tails_Tails_ptr).w
	move.b	#8,(Tails_Dust).w ; load Obj08 Tails' spindash dust/splash object at $FFFFD100
	addi.w	#4,(MainCharacter+y_pos).w
	rts
; End of function InitPlayers





Next, go to "loc_A2F2:". This is for when you're at the cutscene at the end of the game.


XenoWhirl users. Change this:

loc_A2F2:
	moveq	#$E,d0
	move.b	#2,(a1) ; load Tails object
	move.b	#$81,$2A(a1)
	move.b	#5,(Object_RAM+$80).w ; load Obj05 (Tails' tails) at $FFFFB080
	move.w	a1,(Object_RAM+$80+parent).w
	rts



to this:

loc_A2F2:
	moveq	#$E,d0
	move.b	#2,(a1) ; load Tails object
	move.b	#$81,$2A(a1)
	move.w	#Object_RAM+$80,(Tails_Tails_ptr).w
	rts




SVN users, change this:

loc_A2F2:
	moveq	#$E,d0
	move.b	#ObjID_Tails,id(a1) ; load Tails object
	move.b	#$81,obj_control(a1)
	move.b	#ObjID_TailsTails,(Tails_Tails_Cutscene+id).w ; load Obj05 (Tails' tails) at $FFFFB080
	move.w	a1,(Tails_Tails_Cutscene+parent).w
	rts



to this:

loc_A2F2:
	moveq	#$E,d0
	move.b	#ObjID_Tails,id(a1) ; load Tails object
	move.b	#$81,obj_control(a1)
	move.w	#Tails_Tails_Cutscene,(Tails_Tails_ptr).w ; Tails' tails at $FFFFB080
	rts





Next, go to "Obj02_Init_Continued:", and change the last few lines. Change this:

	move.b	#5,(Tails_Tails).w ; load Obj05 (Tails' Tails) at $FFFFD000
	move.w	a0,(Tails_Tails+parent).w ; set its parent object to this



SVN users, yours will say:

	move.b	#ObjID_TailsTails,(Tails_Tails+id).w ; load Obj05 (Tails' Tails) at $FFFFD000
	move.w	a0,(Tails_Tails+parent).w ; set its parent object to this



And change it to this:

	movea.w	(Tails_Tails_ptr).w,a1
	move.b	#5,0(a1) ; load Obj05 (Tails' Tails) at $FFFFD000
	move.w	a0,parent(a1) ; set its parent object to this



And change it to this:

	movea.w  (Tails_Tails_ptr).w,a1
  	move.b	#ObjID_TailsTails,id(a1) ; load Obj05 (Tails' Tails)
	move.w	a0,parent(a1) ; set its parent object to this





One more step! Go to "Obj02:" See the command jmp Obj02_States(pc,d1.w) (jmp Obj02_Index(pc,d1.w))? Change the "jmp" to a "jsr".


And directly underneath it, add this:

	movea.w	(Tails_Tails_ptr).w,a1
	tst.b	routine(a1)
	beq.s	+
	jmp	(DisplaySprite2).l
+
	rts



So you have something like this (SVN users, reference only):

Obj02:
	; a0=character
	cmpi.w	#2,(Player_mode).w
	bne.s	+
	move.w	(Camera_Min_X_pos).w,(Tails_Min_X_pos).w
	move.w	(Camera_Max_X_pos).w,(Tails_Max_X_pos).w
	move.w	(Camera_Max_Y_pos_now).w,(Tails_Max_Y_pos).w
+
	moveq	#0,d0
	move.b	routine(a0),d0
	move.w	Obj02_States(pc,d0.w),d1
	jsr	Obj02_States(pc,d1.w)
	movea.w	(Tails_Tails_ptr).w,a1
	tst.b	routine(a1)
	beq.s	+
	jmp	(DisplaySprite2).l
+
	rts





Done! Tails' tails should now work with the right priority! Tails will now queue his tails for drawing right after himself. Without this, the tails will be queued for drawing after all objects between Tails and the tails that have the same priority. And that's why before, Tails' tails had less priority.



Posted Image




I'll update my first post containing the guide with this information. Any bugs/troubles, reply here. If anyone wants to add this extra bit to the SCHG, feel free.



Cheers,
redhotsonic

#27 User is offline KingofHarts 

Posted 15 July 2012 - 06:25 AM

  • Call me back when people stop shitting in the punch bowl...
  • Posts: 1480
  • Joined: 07-August 10
  • Gender:Male
  • Wiki edits:1
You finally gave me something to do! Gives me an excuse to take a break from Triad (though not before I fixed the palette editor's greyscale & inversion effects)

EDIT: DONE! And I only put in one image... I don't know how to put the image in without uploading the damn thing.... and I don't want to upload 500 images (That is unless it's ok to upload the necessary imagery for these pages I've posted)

I put up the pic for the Tails error. Could someone with authority fill me in? Is it ok for me to upload any and all necessary images for these pages?
This post has been edited by KingofHarts: 15 July 2012 - 09:33 AM

#28 User is offline redhotsonic 

Posted 16 July 2012 - 06:18 AM

  • Also known as RHS
  • Posts: 1128
  • Joined: 31-January 05
  • Gender:Male
  • Location:United Kingdom
  • Project:Sonic 2 Recreation
  • Wiki edits:24
Thanks, mate. That great.

Yeah, it would be useful for more pictures, but until someone is able to help you out, it doesn't matter too much (for this priority guide anyway).

#29 User is offline redhotsonic 

Posted 20 September 2012 - 03:46 PM

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


There seems to be a bug with following this guide with the SVN disassembly. If you're a XenoWhirl's user, you're safe and can ignore this post and go on with your day. SVN user? Read on.


Seems that if you follow this guide as an SVN user, there may be a glitch with the Special Stages. Sonic and Tails act like they're being hit by the bombs object over and over, making it impossible to get any emeralds in the special stages. The reason? inertia is being used for something else in the special stages. This doesn't seem to be the case in Xenowhirl's dis.


So, in your SST table, you're better off switching inertia with something else. invulnerable_time seems to be the best to swap it with. So change them so you end up with this:


invulnerable_time =	$20 ; and $21 ; time remaining until you stop blinking


inertia =		$30 ; and $31 ; directionless representation of speed... not updated in the air




Any more problems, with either disassembly, give me a shout.



My SST guide has been updated as well to provide this bit of information
This post has been edited by redhotsonic: 20 September 2012 - 03:54 PM

#30 User is offline KingofHarts 

Posted 21 September 2012 - 01:27 AM

  • Call me back when people stop shitting in the punch bowl...
  • Posts: 1480
  • Joined: 07-August 10
  • Gender:Male
  • Wiki edits:1
This step has been added to the wiki. Step 11.b

Any errors or omissions lemme know.

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

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