don't click here

Basic Questions & Answers thread

Discussion in 'Engineering & Reverse Engineering' started by Tweaker, May 29, 2008.

  1. E-122-Psi

    E-122-Psi

    Member
    2,471
    612
    93
    Yay thanx, got it running (only correction is the flag branch at the start though that's a fault on my behalf). Also used it to work out a high jump code.

    By the way how do these flags work in Sonic 2 (#7,status(a0)), they're different to the coding for them in Sonic 1. Is there a way to work out a separate new flag (I tried #8,status(a0) and it didn't work so I'm guessing it's more complex than that)?
     
  2. Well basically status(a0) refers to a byte in Sonic's SST, and each bit in that byte is used for a flag. There are 8 bits in a single byte and they're numbered from 0 (least significant) to 7 (most significant), so that's why #8,status(a0) won't work. However, if you need to store more flags you can use another byte in the SST which isn't used for any other purpose. One such byte is $20, so you have space for 8 flags in there (#0,$20(a0) to #7,$20(a0)).
     
  3. E-122-Psi

    E-122-Psi

    Member
    2,471
    612
    93
    Hmm, when I try the $20 flag it just screws up the two moves that formerly used that flag, both seem to work fine using the same status flag.

    Two more queries (sorry for asking so many, these are the last two obstacles and I think I can upload an early build of my project):

    * Does anyone know which part of the coding to alter for the breakable objects (Obj2F, 32 and 3D I believe) in the game so as another animation or flag can break them. I looked at these codes but they are unlabelled and I have no idea where the branch or coding for spin attacks to break them is.

    * My dissassembly doesn't seem to have the mapping file ObjCE meaning I can't edit the mappings for the ending animation. Is this the same with all versions of the Sonic 2 dissassembly, if so is there any way to get around it.
     
  4. Selbi

    Selbi

    The Euphonic Mess Member
    1,504
    62
    28
    Northern Germany
    Sonic ERaZor
    I didn't understand what really happens, the game checks for animations and if Sonic touched the top of the object. Take a look at this (this is for Obj2F, but the other two work like this as well):
    Code (ASM):
    1. loc_23368:
    2.     move.w  (Chain_Bonus_counter).w,objoff_38(a0)
    3. ->  move.b  (MainCharacter+anim).w,objoff_32(a0)
    4. ->  move.b  (Sidekick+anim).w,objoff_33(a0)
    5.     moveq   #0,d1
    6.     move.b  width_pixels(a0),d1
    7.     addi.w  #$B,d1
    8.     moveq   #0,d2
    9.     move.b  y_radius(a0),d2
    10.     move.w  d2,d3
    11.     addq.w  #1,d3
    12.     move.w  x_pos(a0),d4
    13.     bsr.w   JmpTo3_SolidObject
    14.     move.b  status(a0),d0
    15.     andi.b  #$18,d0
    16.     bne.s   loc_233A4
    17.  
    18. BranchTo_JmpTo9_MarkObjGone
    19.     bra.w   JmpTo9_MarkObjGone
    20. ; ===========================================================================
    21.  
    22. loc_233A4:
    23.     cmpi.b  #$18,d0
    24.     bne.s   loc_23408
    25. ->  cmpi.b  #2,objoff_32(a0)
    26. ->  bne.s   loc_233C0
    The lines are responsible for the animation check. I'm guesing you want Amy to be able to destroy the things with her hammer. If that's so, you will need to change the last line before the label BranchTo_JmpTo9_MarkObjGone (the bne.s line) to a branch and also comment out the first two lines of loc_233A4. Below that, you finally got your animation check, replace that with whatever number you have.
    However, now the player can destroy the block anywhere on the screen, so you should do a distance check somewhere (If I remember correctly, I already told you how to do that on Sonic 1, so I won't repeat myself, unless you don't understand it of course).
    Object CE is using the same mapping file as Object CF, meaning the file is called objCF.bin.
     
  5. E-122-Psi

    E-122-Psi

    Member
    2,471
    612
    93
    Well there are some elements that don't translate, the player's X and Y axis flags that subtract from the position of the object for example. Also what kind of branch do you mean for the bne.s line, to what part?

    Tried CF as well, just gives garbage sprites on SonMapEd (I think I can make out the mappings of the sprites I need but the tiles don't map properly on them).
     
  6. FraGag

    FraGag

    Tech Member
    This is because SonMapEd doesn't handle the backward references in the mappings file (like the 1/2/3 mappings). And of course, since they reference mappings outside of the file, it has no idea where they are (in fact, it probably ignores negative offsets altogether, or treats them like unsigned offsets and sees they're past the end of the file, and gives up). A solution would be to copy the missing mappings from the mappings file in which they are defined (obj34, IIRC), but I think there are a few more mappings with positive offsets after those with negative offsets, and SonMapEd stops reading the mappings as soon as it encounters one with a negative offset, so it'd be easier to do with an hex editor or ASM.
     
  7. Selbi

    Selbi

    The Euphonic Mess Member
    1,504
    62
    28
    Northern Germany
    Sonic ERaZor
    @ Psi:
    Code (ASM):
    1. [asm]loc_23368:
    2.     move.w  (Chain_Bonus_counter).w,objoff_38(a0)
    3.     move.b  (MainCharacter+anim).w,objoff_32(a0)    ; get Sonic's Animation here
    4.     move.b  (Sidekick+anim).w,objoff_33(a0)     ; get Tails' Animation here
    5.     moveq   #0,d1
    6.     move.b  width_pixels(a0),d1
    7.     addi.w  #$B,d1
    8.     moveq   #0,d2
    9.     move.b  y_radius(a0),d2
    10.     move.w  d2,d3
    11.     addq.w  #1,d3
    12.     move.w  x_pos(a0),d4
    13.     bsr.w   JmpTo3_SolidObject
    14.     move.b  status(a0),d0
    15.     andi.b  #$18,d0
    16.     bra.s   loc_233A4   ; changed from bne.s
    17.  
    18. BranchTo_JmpTo9_MarkObjGone
    19.     bra.w   JmpTo9_MarkObjGone
    20. ; ===========================================================================
    21.  
    22. loc_233A4:
    23.     ;cmpi.b #$18,d0
    24.     ;bne.s  loc_23408
    25.     cmpi.b  #2,objoff_32(a0)    ; put in your animation ID here
    26.     bne.s   loc_233C0
    This is what I meant, hopefully you understand it now.

    As for the the mappings thing, I'm lost here, sorry. =(
     
  8. E-122-Psi

    E-122-Psi

    Member
    2,471
    612
    93
    Okay I tried modifying the code as so:

    Code (ASM):
    1. [asm]   bra.s   loc_233A4
    2.  
    3. BranchTo_JmpTo9_MarkObjGone
    4.     bra.w   JmpTo9_MarkObjGone
    5. ; ===========================================================================
    6.  
    7. loc_233A4:
    8. ;   cmpi.b  #$18,d0
    9. ;   bne.s   loc_23408
    10.     cmpi.b  #$23,anim(a0)
    11.     beq.w   Break_Obj2F
    12.     cmpi.b  #2,objoff_32(a0)
    13.     bne.s   loc_233C0
    14.  
    15. Break_Obj2F:
    16.     cmpi.b  #$23,anim(a0)
    17.     beq.s   Obj2F_NoHammerAttack; if not, branch
    18.     moveq   #0,d0       ; clear d0
    19.     move.w  $8(a0),d0   ; load springs's X-pos to d0
    20.     sub.w   x_pos(a0),d0; substract Amy's X-pos from it
    21.     bpl.s   Obj2F_XPositive ; if answer is positive, branch
    22.     neg.w   d0      ; otherwise negate d0
    23.  
    24. Obj2F_XPositive:
    25.     cmpi.w  #35,d0      ; is Amy within 35 pixels of the spring (X-axis)?
    26.     bge.s   Obj2F_NoHammerAttack; if not, branch
    27.     moveq   #0,d0       ; clear d0 
    28.     move.w  $C(a0),d0   ; load springs's Y-pos to d0
    29.     sub.w   y_pos(a0),d0; substract Amy's Y-pos from it
    30.     bpl.s   Obj2F_YPositive ; if answer is positive, branch
    31.     neg.w   d0      ; otherwise negate d0
    32.  
    33. Obj2F_YPositive:
    34.     cmpi.w  #35,d0      ; is Amy within 35 pixels of the spring (Y-axis)?
    35.     bge.s   Obj2F_NoHammerAttack; if not, branch
    36.     bra.s   Hit_Obj2F   ; otherwise make spring bouncing
    37.  
    38. Obj2F_NoHammerAttack:
    39.     rts         ; return
    40.  
    41.  
    42. Spin_Obj2F:
    43.     cmpi.b  #2,objoff_32(a0)
    44.     bne.s   loc_233C0
    45.  
    46. Hit_Obj2F: 
    47.     tst.b   subtype(a0)
    48.     bmi.s   loc_233F0
    49.     cmpi.b  #$E,(MainCharacter+layer).w
    50.     beq.s   loc_233F0
    51.  
    52. loc_233C0:
    53.     move.b  #$C,(MainCharacter+layer).w
    54.     move.b  #$D,(MainCharacter+layer_plus).w
    55.     cmpi.b  #2,objoff_33(a0)
    56.     bne.s   loc_233E2
    57.     tst.b   subtype(a0)
    58.     bmi.s   loc_233F0
    59.     cmpi.b  #$E,(Sidekick+layer).w
    60.     beq.s   loc_233F0
    61.  
    62. loc_233E2:
    63.     move.b  #$C,(Sidekick+layer).w
    64.     move.b  #$D,(Sidekick+layer_plus).w
    65.     bra.w   BranchTo_JmpTo9_MarkObjGone
    [/CODE]

    I also had to edit the branch below due to the jump distance being to long. However when I try it, the objects break automatically before they are even onscreen (except in the case of the hill top loop blockades, which just screw up the loop collision).

    Ignore the spring comments, the code is copied from another part of the asm and merely notes where the player collides with the object.
     
  9. Hanoch

    Hanoch

    Also known as TheKnock, Birashot Member
    491
    0
    0
    Israel
    everything
    You loaded the anim from (a0) where it should be (a1). But you don't need to do that, you just can edit the check of objoff_32 (it loads sonic's/tails' animation there)

    Code (ASM):
    1.  
    2. cmpi.b  #$23,objoff_32(a0)  bne.s   loc_233C0
    3.  
     
  10. E-122-Psi

    E-122-Psi

    Member
    2,471
    612
    93
    While it gets obj32 (rocks) to break upon that animation it still has no distance value (eg. hammer on the other side of the screen and it still breaks). And I tried it for obj2f and it's still screws up the loop collision and the blockade won't break.
     
  11. Selbi

    Selbi

    The Euphonic Mess Member
    1,504
    62
    28
    Northern Germany
    Sonic ERaZor
    That's because you checked for the distance using the object's position, not Sonic's (or Amy's in this case). Instead of $8(a0), you should use (MainCharacter+$8).w. To avoid an endless conversation, I just put the code in here for you:
    Code (ASM):
    1. loc_233A4:
    2.     cmpi.b  #$23,objoff_32(a0)
    3.     bne.s   loc_233C0
    4.  
    5.     move.w  $8(a0),d0       ; load block's X-pos to d0
    6.     sub.w   (MainCharacter+$8).w,d0 ; substract Amy's X-pos from it
    7.     bpl.s   Obj2F_XPositive     ; if answer is positive, branch
    8.     neg.w   d0          ; otherwise negate d0
    9.  
    10. Obj2F_XPositive:
    11.     cmpi.w  #35,d0          ; is Amy within 35 pixels of the spring (X-axis)?
    12.     bge.s   Obj2F_NoHammerAttack    ; if not, branch
    13.     move.w  $C(a0),d0       ; load springs's Y-pos to d0
    14.     sub.w   (MainCharacter+$8).w,d0 ; substract Amy's Y-pos from it
    15.     bpl.s   Obj2F_YPositive     ; if answer is positive, branch
    16.     neg.w   d0          ; otherwise negate d0
    17.  
    18. Obj2F_YPositive:
    19.     cmpi.w  #35,d0          ; is Amy within 35 pixels of the spring (Y-axis)?
    20.     bge.s   Obj2F_NoHammerAttack    ; if not, branch
    21.     bra.s   Hit_Obj2F       ; otherwise make spring bouncing
    22.  
    23. Obj2F_NoHammerAttack:
    24.     rts             ; return
    25.  
    26. Hit_Obj2F:
    Since I don't have the source, I'm not sure if it works though.
     
  12. HighFrictionZone

    HighFrictionZone

    Hi. Member
    855
    0
    16
    Katy, Texas
    Nothing
    Right so. Got a question I'd like answered. Shouldn't be too hard. For whatever particularly dumb reason I have, I want to allow the extra life music to not kill the PSG. You know, so I can actually have PSG notes in my 1up sound or so that I can hear sonic's jump noise during the 1up track. I had a look at the code myself, but I can't quite wrap my head around it (I'm not entirely sure, but I think it has to do with the area around "Sound_81to9F:"

    PS, I'm using the SVN disassem
     
  13. Selbi

    Selbi

    The Euphonic Mess Member
    1,504
    62
    28
    Northern Germany
    Sonic ERaZor
    So yeah, got two questions myself:

    1: It was pretty easy to increase the number of characters per line in a the Level Select (I changed it from $17 to $1B). However, now the position of the text is messed up of course. There is this line:
    Code (ASM):
    1.         move.l  #$62100003,d4   ; screen position (text)
    But what do I need to edit move it 2 tiles to the left?

    EDIT: $620C0003, thanks to MarkeyJester on IRC.

    2: Simalar to my last question, I was wondering if something like this is possible:
    Code (ASM):
    1.         move.b  #2,($FFFFFF9F).w    ; set $FF9F to 2
    2.         ...
    3.         move.b  ($FFFFFF9F).w,d0    ; get current number of $FF9F
    4.         lea ((Some_Text)+d0).l,a1   ; this should become Some_Text2
    Thing is, I have multiple textes to be loaded like this, and I was wondering if there's something like this possible to save me time.
     
  14. Ravenfreak

    Ravenfreak

    2 Edgy 4 U Tech Member
    3,120
    204
    43
    O'Fallon Mo
    Sonic 1 Game Gear Disassembly
    I have a small question, because I am very confused. My Sonic 1 hack, somehow has SRAM, when I didn't even enable SRAM in the disassembly, let alone I didn't set an address for the SRAM to be enabled. I did add a few files to change the title screen, and I added the code to fix the Sega sound. What I am confused is, how the heck did that happen? (It doesn't work at all, but Fusion saved a SRM file and "loads" it when I play my hack...) Could it be the files I added to edit the title screen?
     
  15. Sik

    Sik

    Sik is pronounced as "seek", not as "sick". Tech Member
    6,718
    1
    0
    being an asshole =P
    If emulators detect any write to $200000-$20FFFF, they assume the game has SRAM. This is because some games don't label SRAM usage properly in the header so they just go by that assumption. Make sure you aren't writing to that area, basically. Also, get rid of the SRM file or Fusion will insist in that the game has SRAM.
     
  16. E-122-Psi

    E-122-Psi

    Member
    2,471
    612
    93
    Still doesn't work, I've tried switching the code all over the place and also tried adding a reset d0 command, but still no success. And cancelling out those first two lines in the original Obj2F code is what causes the Hill Top loops to screw up (though they revert to normal once you break the blockade). I can get the animation to activate breaking the objects, but it doesn't recognise the distance limit for them and thus you can break them from opposite ends of the screen (or even offscreen).
     
  17. It's not possible to simply concatenate labels like that, but you can use an offset table. E.g. have something like:
    Code (ASM):
    1. Text_Table:
    2.     dc.l Some_Text_0
    3.     dc.l Some_Text_1
    4.     dc.l Some_Text_2
    5.     ...
    and then to use it in your code do
    Code (ASM):
    1.     moveq   #0,d0
    2.     move.b  ($FFFFFF9F).w,d0
    3.     add.w   d0,d0
    4.     add.w   d0,d0   ; multiply by 4
    5.     movea.l Text_Table(pc,d0.w),a1  ; a1 now contains the address of the appropriate text
    This is assuming that you keep this code very close to Text_Table. If it's a bit further away change the last line to:
    Code (ASM):
    1.     lea Text_Table(pc),a1
    2.     movea.l (a1,d0.w),a1
    Another thing to note is that it's a better idea to pre-scale your index before putting it in $FFFFFF9F, I.e. instead of setting it to 0, 1, 2, 3 etc. you set it to 0, 4, 8, $C etc. That way you avoid having to manually multiply it (you can get rid of the two add.w d0,d0 lines), and it's for a similar reason that object routines are always in increments of two and game modes are always in increments of 4.
     
  18. Infiniti

    Infiniti

    ↑ & ↓ & ↻ Member
    476
    0
    0
    UK
    I can't bee 100% sure but at some point in the past, I swear someone released a collection of Samples/instruments/voices used in the sonic games/genesis, for use in a tracker program (Open MPT).
    If such a collection has been released, can someone be kind enough to point me to them? I've tried the search feature and the info section, hell even Google, with no luck :(
     
  19. Selbi

    Selbi

    The Euphonic Mess Member
    1,504
    62
    28
    Northern Germany
    Sonic ERaZor
    @Psi: I don't want pages of conversation. Go to IRC (you know which channel), we try to figure it out there.

    Probably this one: http://sonicresearch.org/smps.
     
  20. amphobius

    amphobius

    doing more important things with my life Member
    2,120
    0
    16
    life
    That's for importing the songs themselves. I believe he's looking for The Ultimate Mega Drive Soundfont.