don't click here

In need of some help.

Discussion in 'Engineering & Reverse Engineering' started by Hitaxas, Mar 2, 2008.

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

    Hitaxas

    Retro 80's themed Twitch streamer ( on hiatus) Member
    Alright. So, I have attempted to port the motobug enemy from Sonic 1 into Sonic 2. The code compiles and all, but if fails to show up at all. I am not exactly sure what I have done wrong/haven't done to make this not work.


    Code (ASM):
    1. ; ===========================================================================
    2. ; ---------------------------------------------------------------------------
    3. ; Object 4C -  Bug enemy (AHZ)
    4. ; ---------------------------------------------------------------------------
    5.  
    6. obj4C:                  ; XREF: Obj_Index
    7.         moveq   #0,d0
    8.         move.b  $24(a0),d0
    9.         move.w  obj4C_Index(pc,d0.w),d1
    10.         jmp obj4C_Index(pc,d1.w)
    11. ; ===========================================================================
    12. obj4C_Index:    dc.w obj4C_Main-obj4C_Index
    13.         dc.w obj4C_Action-obj4C_Index
    14.         dc.w obj4C_Animate-obj4C_Index
    15.         dc.w obj4C_Delete-obj4C_Index
    16. ; ===========================================================================
    17.  
    18. obj4C_Main:             ; XREF: obj4C_Index
    19.         move.l  #Map_obj4C,4(a0)
    20.         move.w  #$4F0,2(a0)
    21.         move.b  #4,1(a0)
    22.         move.b  #4,$18(a0)
    23.         move.b  #$14,$19(a0)
    24.         tst.b   $1C(a0)     ; is object a smoke trail?
    25.         bne.s   obj4C_SetSmoke  ; if yes, branch
    26.         move.b  #$E,$16(a0)
    27.         move.b  #8,$17(a0)
    28.         move.b  #$C,$20(a0)
    29.         bsr.w   ObjectmoveandFall
    30.         jsr ObjCheckFloorDist
    31.         tst.w   d1
    32.         bpl.s   locret_F68A
    33.         add.w   d1,$C(a0)   ; match object's position with the floor
    34.         move.w  #0,$12(a0)
    35.         addq.b  #2,$24(a0)
    36.         bchg    #0,$22(a0)
    37.  
    38. locret_F68A:
    39.         rts
    40. ; ===========================================================================
    41.  
    42. obj4C_SetSmoke:             ; XREF: obj4C_Main
    43.         addq.b  #4,$24(a0)
    44.         bra.w   obj4C_Animate
    45. ; ===========================================================================
    46.  
    47. obj4C_Action:               ; XREF: obj4C_Index
    48.         moveq   #0,d0
    49.         move.b  $25(a0),d0
    50.         move.w  obj4C_Index2(pc,d0.w),d1
    51.         jsr obj4C_Index2(pc,d1.w)
    52.         lea (Ani_obj4C).l,a1
    53.         bsr.w   AnimateSprite
    54.  
    55. ; ---------------------------------------------------------------------------
    56. ; Routine to mark an enemy/monitor/ring as destroyed
    57. ; ---------------------------------------------------------------------------
    58.  
    59. MarkObjGonem:
    60.         move.w  8(a0),d0
    61.         andi.w  #$FF80,d0
    62.         move.w  ($FFFFF700).w,d1
    63.         subi.w  #$80,d1
    64.         andi.w  #$FF80,d1
    65.         sub.w   d1,d0
    66.         cmpi.w  #$280,d0
    67.         bhi.w   Mark_ChkGone
    68.         bra.w   DisplaySprite
    69. ; ===========================================================================
    70.  
    71. Mark_ChkGone:
    72.         lea ($FFFFFC00).w,a2
    73.         moveq   #0,d0
    74.         move.b  $23(a0),d0
    75.         beq.s   Mark_Delete
    76.         bclr    #7,2(a2,d0.w)
    77.  
    78. Mark_Delete:
    79.         bra.w   DeleteObject
    80.  
    81. ; ===========================================================================
    82. obj4C_Index2:   dc.w obj4C_Move-obj4C_Index2
    83.         dc.w obj4C_FixToFloor-obj4C_Index2
    84. ; ===========================================================================
    85.  
    86. obj4C_Move:             ; XREF: obj4C_Index2
    87.         subq.w  #1,$30(a0)  ; subtract 1 from pause time
    88.         bpl.s   locret_F70A ; if time remains, branch
    89.         addq.b  #2,$25(a0)
    90.         move.w  #-$100,$10(a0)  ; move object to the left
    91.         move.b  #1,$1C(a0)
    92.         bchg    #0,$22(a0)
    93.         bne.s   locret_F70A
    94.         neg.w   $10(a0)     ; change direction
    95.  
    96. locret_F70A:
    97.         rts
    98. ; ===========================================================================
    99.  
    100. obj4C_FixToFloor:           ; XREF: obj4C_Index2
    101.         bsr.w   ObjectMove
    102.         jsr ObjCheckFloorDist
    103.         cmpi.w  #-8,d1
    104.         blt.s   obj4C_Pause
    105.         cmpi.w  #$C,d1
    106.         bge.s   obj4C_Pause
    107.         add.w   d1,$C(a0)   ; match object's position with the floor
    108.         subq.b  #1,$33(a0)
    109.         bpl.s   locret_F756
    110.         move.b  #$F,$33(a0)
    111.         bsr.w   SingleObjLoad
    112.         bne.s   locret_F756
    113.         move.b  #$40,0(a1)  ; load exhaust smoke object
    114.         move.w  8(a0),8(a1)
    115.         move.w  $C(a0),$C(a1)
    116.         move.b  $22(a0),$22(a1)
    117.         move.b  #2,$1C(a1)
    118.  
    119. locret_F756:
    120.         rts
    121. ; ===========================================================================
    122.  
    123. obj4C_Pause:                ; XREF: obj4C_FixToFloor
    124.         subq.b  #2,$25(a0)
    125.         move.w  #59,$30(a0) ; set pause time to 1 second
    126.         move.w  #0,$10(a0)  ; stop the object moving
    127.         move.b  #0,$1C(a0)
    128.         rts
    129. ; ===========================================================================
    130.  
    131. obj4C_Animate:              ; XREF: obj4C_Index
    132.         lea (Ani_obj4C).l,a1
    133.         bsr.w   AnimateSprite
    134.         bra.w   DisplaySprite
    135. ; ===========================================================================
    136.  
    137. obj4C_Delete:               ; XREF: obj4C_Index
    138.         bra.w   DeleteObject
    139. ; ===========================================================================
    140. Ani_obj4C: BINCLUDE "mappings\spriteDPLC\obj4C.asm"
    141.  
    142. ; ---------------------------------------------------------------------------
    143. ; Sprite mappings - Moto Bug enemy (GHZ)
    144. ; ---------------------------------------------------------------------------
    145. Map_obj4C: BINCLUDE "mappings\sprite\obj4C.asm"
    146.  
    147. ; ---------------------------------------------------------------------------
    148. Nem_Motobug:    BINCLUDE    "art\nemesis\motobug.bin"   ; moto bug
    149.  
    150. ; ---------------------------------------------------------------------------
     
  2. Sonic 65

    Sonic 65

    Tech Member
    Change:

    Code (ASM):
    1. obj4C_Action:               ; XREF: obj4C_Index
    2.         moveq   #0,d0
    3.         move.b  $25(a0),d0
    4.         move.w  obj4C_Index2(pc,d0.w),d1
    5.         jsr obj4C_Index2(pc,d1.w)
    6.         lea (Ani_obj4C).l,a1
    7.         bsr.w   AnimateSprite
    to:

    Code (ASM):
    1. obj4C_Action:               ; XREF: obj4C_Index
    2.         moveq   #0,d0
    3.         move.b  $25(a0),d0
    4.         move.w  obj4C_Index2(pc,d0.w),d1
    5.         jsr obj4C_Index2(pc,d1.w)
    6.         lea (Ani_obj4C).l,a1
    7.         bra.s   AnimateSprite
    EDIT: wait no. fixed.
     
  3. Hitaxas

    Hitaxas

    Retro 80's themed Twitch streamer ( on hiatus) Member
    Thanks, now all I have to do is fix the mappings and art.

    (go figure all my errors are 1-liners >.>;)


    EDIT:now the jump distance is "too big". 0.o
     
  4. Sonic 65

    Sonic 65

    Tech Member
    Replace bra.s with bra.w.

    also are the mappings at least in S2 format? because that might have been your problem all along.
     
  5. Hitaxas

    Hitaxas

    Retro 80's themed Twitch streamer ( on hiatus) Member
    No, they aren't. It'd be good if I knew how to convert/rewrite, huh?
     
  6. Sonic 65

    Sonic 65

    Tech Member
    It's actually really simple with SonMapEd.

    load up your mappings in S1 format, go to Settings -> Game Format, set it to Sonic 2, and save the new mappings.

    I don't think art needs to be changed, just add it into the PLC table.
     
  7. Tweaker

    Tweaker

    Banned
    12,387
    2
    0
    You can just open them up in SonMapEd, switch to Sonic 2 format, then export. Instant conversion.
     
  8. Hitaxas

    Hitaxas

    Retro 80's themed Twitch streamer ( on hiatus) Member
    What about the _anim file? That won't convert in SonMapEd.
     
  9. Tweaker

    Tweaker

    Banned
    12,387
    2
    0
    ...you don't need to change the animation script.
     
  10. Hitaxas

    Hitaxas

    Retro 80's themed Twitch streamer ( on hiatus) Member
    Ignore the extra sonic.

    I am sure the enemy should not look like and act like a spring... this is strange. Because I believe I have the art set up correctly and the mappings.

    [​IMG]
     
  11. JoseTB

    JoseTB

    Tech Member
    716
    59
    28
    Did you add your art to the Pattern Load cue of the level? In any case, I'd suggest to check the VRAM to verify that the tiles have been loaded AND make sure the address where you load them match with the value set to 2(a0).
     
  12. Hitaxas

    Hitaxas

    Retro 80's themed Twitch streamer ( on hiatus) Member
    It is in the PLC for EHZ (AHZ), but it still shows up that way. As for checking the VRAM stuff, I wouldn't know where to start. But I do know that the Tiles are loaded, just not where they should be.


    Code (ASM):
    1. PlrList_Ehz1: plrlistheader
    2.     plreq $73C0, ArtNem_Waterfall
    3.     plreq $76C0, ArtNem_EHZ_Bridge
    4.     plreq $77C0, ArtNem_Buzzer_Fireball
    5.     plreq $7A40, ArtNem_Buzzer
    6.     plreq $7DC0, ArtNem_Coconuts
    7.     plreq $8280, ArtNem_Masher
    8.     plreq $7A80, Nem_Motobug
    9. PlrList_Ehz1_End
    I am guessing "$7A80" is incorrect, but I really have no clue.
     
  13. Basically, the value you put into $2(a0) has to be equal to the VRAM address of the art divided by twenty. In your case, since you're loading the art at $7A80, you should change

    Code (ASM):
    1. move.w  #$4F0,2(a0)
    to

    Code (ASM):
    1. move.w  #$3D4,2(a0)
     
  14. Rika Chou

    Rika Chou

    Tech Member
    5,276
    169
    43
    It looks like you have it loading a spring instread of the smoke trail...
    Find:
    Code (ASM):
    1.         move.b  #$41,0(a1)
    Change the $41 to the same object id as the motobug. (actually, in S1 it's originally set to 40, not 41...)
     
  15. Hitaxas

    Hitaxas

    Retro 80's themed Twitch streamer ( on hiatus) Member
    Thanks, Now I understand how that works. But the object still ends up like a bunch of springs...

    Isn't present in my code.


    Code (ASM):
    1.         move.b  #$40,0(a1)
    That was.

    Well, even with that changed to $4C (the motobug object number), I still get springs.
     
  16. What Rika means is that:

    Code (ASM):
    1. move.b  #$40,0(a1)
    needs to be changed to

    Code (ASM):
    1. move.b  #$4C,0(a1)
    The current line is loading up a pressure spring instead of a smoke trail.
     
  17. Hitaxas

    Hitaxas

    Retro 80's themed Twitch streamer ( on hiatus) Member
    I fixed my last post. I did just that, and it still loaded springs.
     
  18. Wait, are the mappings and the animations in actual ASM files? If they are, you're supposed to INCLUDE them not BINCLUDE them.
     
  19. Hitaxas

    Hitaxas

    Retro 80's themed Twitch streamer ( on hiatus) Member
    How can I include them in the 2007 disassembly? Whenever I tried something like that, I'd get an error.



    Mappings are BIN, Animations are ASM.
     
  20. Well, if the mappings are in binary form, BINCLUDING them should be fine. Includes use pretty much the same syntax as BINCLUDES - an example from the 2007 disasm:

    Code (ASM):
    1.     include "s2.macrosetup.asm"
    If that doesn't work for whatever reason, you can try actually copy-pasting the animation script into the disassembly.
     
Thread Status:
Not open for further replies.