Porting Tail's tails from Nick Arcade's prototype to Sonic 1

Discussion in 'Discussion and Q&A Archive' started by MAXXX309, May 18, 2010.

Thread Status:
Not open for further replies.
  1. MAXXX309

    MAXXX309 Newcomer Exiled

    Joined:
    Mar 4, 2010
    Messages:
    19
    Location:
    Ukraine, Kiev
    Hello everybody, need some help here:


    I have successfully ported Tails to my Sonic 1 hack, but there is lack of tails (lol)


    Tails' Tails is a separate object in Sonic 2 (Obj05) and I decided to port it from Nick Arcade's prototype (as the closest to Sonic 1)


    Here's the result:



    Code:
    ;----------------------------------------------------
    
    &#59; Object 05 - Tails' tails
    
    &#59;----------------------------------------------------
    
     
    
     Obj05:					&#59; ported from Sonic 2 Nick Arcade's prototype
    
    		 moveq	#0,d0
    
    		 move.b	$24(a0),d0
    
    		 move.w	Obj05_Index(pc,d0.w),d1
    
    		 jmp	Obj05_Index(pc,d1.w)
    
    &#59; ДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДД
    
    ДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДД
    
     Obj05_Index:	dc.w Obj05_Init-Obj05_Index&#59; DATA XREF: ROM:Obj05_Indexo
    
    					&#59; ROM:00011D8Eo
    
    		 dc.w Obj05_Main-Obj05_Index
    
    &#59; ДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДД
    
    ДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДД
    
     
    
     Obj05_Init:			   &#59; DATA XREF: ROM:Obj05_Indexo
    
    		 addq.b	#2,$24(a0)
    
    		 move.l	#Map_Tails,4(a0)
    
    		 move.w	#$7B0,2(a0)
    
    		 move.b	#2,$18(a0)
    
    		 move.b	#$18,$19(a0)
    
    		 move.b	#4,1(a0)
    
     
    
     Obj05_Main:			   &#59; DATA XREF: ROM:00011D8Eo
    
    		 movea.w	$3E(a0),a2
    
    		 move.b	$26(a2),$26(a0)
    
    		 move.b	$22(a2),$22(a0)
    
    		 move.w	8(a2),8(a0)
    
    		 move.w	$C(a2),$C(a0)
    
    		 moveq	#0,d0
    
    		 move.b	$1C(a2),d0
    
    		 cmp.b	$30(a0),d0
    
    		 beq.s	loc_11DE6
    
    		 move.b	d0,$30(a0)
    
    		 move.b	Obj05_Animations(pc,d0.w),$1C(a0)
    
     
    
     loc_11DE6:			   &#59; CODE XREF: ROM:00011DDAj
    
    		 lea		(Obj05_AniData).l,a1
    
    		 bsr.w	Sonic_Animate2
    
    		 bsr.w	LoadTailsDynPLC_F600&#59; loads the tails patterns	in a buffer at F600
    
    					&#59; as opposed to	the usual F400
    
    		 jsr		(DisplaySprite).l
    
    		 rts
    
    &#59; ДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДД
    
    ДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДД
    
     Obj05_Animations:dc.b	0,  0		&#59; 0
    
    		 dc.b   3,  3	   &#59; 2
    
    		 dc.b   0,  1	   &#59; 4
    
    		 dc.b   0,  2	   &#59; 6
    
    		 dc.b   1,  7	   &#59; 8
    
    		 dc.b   0,  0	   &#59; 10
    
    		 dc.b   0,  0	   &#59; 12
    
    		 dc.b   0,  0	   &#59; 14
    
    		 dc.b   0,  0	   &#59; 16
    
    		 dc.b   0,  0	   &#59; 18
    
    		 dc.b   0,  0	   &#59; 20
    
    		 dc.b   0,  0	   &#59; 22
    
    		 dc.b   0,  0	   &#59; 24
    
    		 dc.b   0,  0	   &#59; 26
    
    		 dc.b   0,  0	   &#59; 28
    
     Obj05_AniData:	dc.w byte_11E2A-Obj05_AniData&#59;	DATA XREF: ROM:loc_11DE6o
    
    					&#59; ROM:Obj05_AniDatao ...
    
    		 dc.w byte_11E2D-Obj05_AniData
    
    		 dc.w byte_11E34-Obj05_AniData
    
    		 dc.w byte_11E3C-Obj05_AniData
    
    		 dc.w byte_11E42-Obj05_AniData
    
    		 dc.w byte_11E48-Obj05_AniData
    
    		 dc.w byte_11E4E-Obj05_AniData
    
    		 dc.w byte_11E54-Obj05_AniData
    
     byte_11E2A:	dc.b $20,  0,$FF   &#59; 0&#59; DATA XREF: ROM:Obj05_AniDatao
    
     byte_11E2D:	dc.b   7,  9, $A, $B, $C, $D,$FF; 0&#59; DATA XREF: ROM:00011E1Co
    
     byte_11E34:	dc.b   3,  9, $A, $B, $C, $D,$FD,  1; 0   &#59; DATA XREF: ROM:00011E1Eo
    
     byte_11E3C:	dc.b $FC,$49,$4A,$4B,$4C,$FF; 0   &#59; DATA XREF: Tails_Animate+22Ao
    
    					&#59; ROM:00011E20o
    
     byte_11E42:	dc.b   3,$4D,$4E,$4F,$50,$FF; 0   &#59; DATA XREF: ROM:00011E22o
    
     byte_11E48:	dc.b   3,$51,$52,$53,$54,$FF; 0   &#59; DATA XREF: ROM:00011E24o
    
     byte_11E4E:	dc.b   3,$55,$56,$57,$58,$FF; 0   &#59; DATA XREF: ROM:00011E26o
    
     byte_11E54:	dc.b   2,$81,$82,$83,$84,$FF; 0   &#59; DATA XREF: ROM:00011E28o
    
    &#59; ДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДД
    
    ДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДД
    
    		 nop
    
    		 align 4
    
     
    
    &#59; Subroutine to load tails patterns in a buffer at F600
    
    &#59; as opposed to	the usual F400 (ported from Sonic 2 Nick Arcade's prototype)
    
     LoadTailsDynPLC_F600:		   &#59; CODE XREF: ROM:00011DF0p
    
    		 moveq	#0,d0
    
    		 move.b	$1A(a0),d0
    
    		 cmp.b	($FFFFF7DF).w,d0
    
    		 beq.s	locret_11D7C
    
    		 move.b	d0,($FFFFF7DF).w
    
    		 lea	(TailsDynPLC).l,a2
    
    		 add.w	d0,d0
    
    		 adda.w	(a2,d0.w),a2
    
    		 move.w	(a2)+,d5
    
    		 subq.w	#1,d5
    
    		 bmi.s	locret_11D7C
    
    		 move.w	#$F600,d4
    
     
    
     TPLC_ReadEntry:			   &#59; ported from Sonic 2 Nick Arcade's prototype
    
    		 moveq	#0,d1
    
    		 move.w	(a2)+,d1
    
    		 move.w	d1,d3
    
    		 lsr.w	#8,d3
    
    		 andi.w	#$F0,d3   &#59; 'р'
    
    		 addi.w	#$10,d3
    
    		 andi.w	#$FFF,d1
    
    		 lsl.l	#5,d1
    
    		 addi.l	#Art_Tails,d1
    
    		 move.w	d4,d2
    
    		 add.w	d3,d4
    
    		 add.w	d3,d4
    
    		 jsr		(QueueDMATransfer).l
    
    		 dbf	d5,TPLC_ReadEntry
    
    		 
    
     locret_11D7C:			   &#59; CODE XREF: LoadTailsDynPLC_F600+Aj
    
    					&#59; LoadTailsDynPLC_F600+20j ...
    
    		 rts
    
    &#59; End of function LoadTailsDynPLC_F600


    ... but this shit is not going to be displayed. In LoadTailsDynPLC_F600: used non-changed RAM address $FFFFF7DF from S2. Shoult I change it?

    BTW, I load entire Obj05: object with this line:



    Code:
    move.b	#5,($FFFFD580).w   &#59; load Tails' Tails object
    as said, Vladikcomper, it is free.


    Its still not working, HELP!
     
  2. Hanoch

    Hanoch Well-Known Member Member

    Joined:
    Aug 3, 2008
    Messages:
    312
    Location:
    Israel
    $F7DF is like sonic has $F766 which is the last frame number (IIRC) so you need to use a free address that isn't used by tails or sonic (so it wont cause sprite messups)


    You also forgot to load the miles object into the parent address of the tail object. I see you are using $D580 as the address for the tail object, load a word from object SST 0(a0) into $3E of the tail object ($D580+$3E which is of course $D5BE)


    It is important that you load the tail object from the player object code and NOT from the level loading sequence, as there is no player object in a0 on the level loading sequence but a few stuff related to water palette/title cards which causes to load random stuff and sometimes illegal instructions.
     
    Last edited by a moderator: May 18, 2010
  3. Irixion

    Irixion Well-Known Member Member

    Joined:
    Aug 11, 2007
    Messages:
    670
    Location:
    Ontario, Canada
    I don't see why you would want to do this from nick arcade, it's just a copy of sonic mirroring his moves with a second or so delay. Not to mention all the raw code--port from s2 final, it'll be simpler.


    Basically, to port a character, you need to pay attention to a few points:


    RAM Addresses--if you get these wrong, any simple function could go bork.


    Art formats


    Last but not least, game specific routines.
     
  4. MarkeyJester

    MarkeyJester ♡ ! Member

    Joined:
    Jun 27, 2009
    Messages:
    2,867
    Another issue I could see here (in addition to those above) would be if..


    "_inc\Object pointers.asm"



    dc.l Obj01, ObjectFall, ObjectFall, ObjectFall
    dc.l ObjectFall, ObjectFall, ObjectFall, Obj08


    dc.l Obj09, Obj0A, Obj0B, Obj0C


    dc.l Obj0D, Obj0E, Obj0F, Obj10


    ...



    ..you might catch where I'm going with this =)
     
  5. Animemaster

    Animemaster Lets get to work! Member

    Joined:
    Mar 20, 2009
    Messages:
    1,229
    Location:
    UK
    I'm curious about this aswell, do you need to port the tails object over? or can you do compares in the sonic object?
     
  6. MarkeyJester

    MarkeyJester ♡ ! Member

    Joined:
    Jun 27, 2009
    Messages:
    2,867
    There are thousands of ways to do it, that's the beauty of assembly, but which one is the best way to go, is up to you to figure.
     
  7. MAXXX309

    MAXXX309 Newcomer Exiled

    Joined:
    Mar 4, 2010
    Messages:
    19
    Location:
    Ukraine, Kiev
    I added pointer to the list already <_<

    Damny damn, I forgot! OK, Now it looks like this:


    [​IMG]


    [​IMG]


    Tail object loads properly, but I think that problem with graphics is in $FFFFF7DF address.


    As Hanoch said, I should change it, but I really don't know, which one is free for use.
     
    Last edited by a moderator: May 19, 2010
  8. shobiz

    shobiz Well-Known Member Member

    Joined:
    Aug 11, 2007
    Messages:
    198
    Location:
    Karachi, Pakistan
    http://info.sonicretro.org/SCHG:Sonic_the_...ng_from_.24FF90


    I believe $FEB2-$FEBF are also unused.
     
  9. MAXXX309

    MAXXX309 Newcomer Exiled

    Joined:
    Mar 4, 2010
    Messages:
    19
    Location:
    Ukraine, Kiev
    shobiz, using any of that addresses cause no effect: the result is the same as in my previous post. <_<


    Any other ideas?
     
  10. Hanoch

    Hanoch Well-Known Member Member

    Joined:
    Aug 3, 2008
    Messages:
    312
    Location:
    Israel
    My only guess is that you are using the sonic 2 final art for tails and the tail is from sonic 2 beta, which causes this.


    On the other hand, try making the tail PLC routine use a different vram than tails'.


    Also I noticed that the tail object loads miles' tile buffer and not the tails.


    Edit:


    This:




    move.w #$F600,d4



    is (supposed to be) this:




    move.w #$7B0,2(a0)



    Times $20.
     
    Last edited by a moderator: May 20, 2010
Thread Status:
Not open for further replies.