don't click here

Basic Questions & Answers thread

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

  1. `Ilio Huhu

    `Ilio Huhu

    Member
    11
    0
    0
    Sonic Generations (Volcano Valley)
    Is there any other way I can do this? The "split" program doesn't seem to want to take my sa2.cdi iso. :/
     
  2. MainMemory

    MainMemory

    Kate the Wolf Tech Member
    4,742
    338
    63
    SonLVL
    You can load the levels from the STG##.PRS files directly in SALVL, however the wiki only has addresses for the US version.
     
  3. Devon

    Devon

    I'm a loser, baby, so why don't you kill me? Tech Member
    1,251
    1,421
    93
    your mom
    I asked this on SSRG, but just in case any of you know the answer, here it is.

    As some of you know, I'm making a guide for porting flamewing's S3K driver into Sonic 1. I'm trying to get it to be incbin'd, but it won't assemble. Every time I build I get this error:

    "ERROR: Second segment of sound driver at $1300 MUST follow directly after the first".

    I know what that means, but I've checked every aspect and it appears to be fine, so I have no idea what's going on.

    Apparently, when you add any 68k assembly code before the Z80 code, it assembles just fine, but without it, it gives the error. Even if it assembles, it's broken. I even removed the assembled 68k code from the bin file, but no luck.
     
  4. E-122-Psi

    E-122-Psi

    Member
    2,470
    612
    93
    is there an equivalent to the (maincharacter+anim) command in Sonic 1's asm? I try using the standard one ($1C) and it doesn't work, suggesting it needs to know it's Sonic as well.
     
  5. Thorn

    Thorn

    Tech Member
    335
    19
    18
    Home
    Sonic 2 Retro Remix
    ^ I haven't touched Sonic 1 in forever, but I'm pretty sure that Sonic's data is still loaded at $FFFFB000, so adding the offset for an object's animation ID to that value is the same thing that MainCharacter+anim equates to in Sonic 2.
     
  6. E-122-Psi

    E-122-Psi

    Member
    2,470
    612
    93
    So ($FFFFB000+$1C) then?

    EDIT: Oh also concerning Sonic 2 this time, does anyone know how to get breakable objects such as obj32 (CPZ/HTZ blocks) to react with another object than Sonic or Tails?
     
  7. Thorn

    Thorn

    Tech Member
    335
    19
    18
    Home
    Sonic 2 Retro Remix
    ^ IF $1C is an object's animation offset in Sonic 1, then that's correct. The other possibility is to load $FFFFB000 into a register aN and then check $1C(aN).
     
  8. MarkeyJester

    MarkeyJester

    Original, No substitute Resident Jester
    2,202
    432
    63
    Japan
    The SST (Sprite Status Table) for Sonic 1 is held in RAM from D000 to EFFF, what you're looking for is; $FFFFD01C or $FFFFD000+$1C. But pretty much what Thorn said...
     
  9. Thorn

    Thorn

    Tech Member
    335
    19
    18
    Home
    Sonic 2 Retro Remix
    ^ Welp, I take fault for having the wrong address. Disregard me, I hack Sonic 2, I'm strange, etc.

    Regarding the other question E-122-Psi edited in, it's really dependent on what you're doing. In some situations, it may be necessary to run other objects through the same routines Sonic and Tails use, but in other cases, it may make more sense to code a special routine just for the object doing the interacting. Can you elaborate on what you need?
     
  10. E-122-Psi

    E-122-Psi

    Member
    2,470
    612
    93
    Okay I think that's given results. Thanx. That's okay, working on Sonic 2's the reason I needed that in the first place. :P

    To elaborate it's for my Sally in Sonic 2 hack. She has a projectile attack and I want the projectile object (objDE) to react with rocks,plugs,etc to smash them.
     
  11. Caverns 4

    Caverns 4

    Member
    346
    0
    16
    Sonic: Retold
    In all current disassemblies of Sonic 1, what you're looking for is v_player+obAnim.
     
  12. AURORA☆FIELDS

    AURORA☆FIELDS

    The cute one here Tech Member
    216
    24
    18
    Finland
    AMPS
    For older disassemblies (Such as Hivebrain 2005), you would want to use $FFFFD000+$1C
     
  13. E-122-Psi

    E-122-Psi

    Member
    2,470
    612
    93
    The older one seemed to work (there are some oddities, but I think that's more down to some other coding I need to fine tune).

    I'm having a concern with a new object I've made, I've got it to mostly run as it should, however no matter how much I edit, it just won't display it's sprite. It's a bit of mess here, it was translated from some Sonic 2 coding and originally used a unique compression which I've altered to see if it makes things any clearer here:

    Code (ASM):
    1. Obj10:                  ; XREF: Obj_Index
    2.     moveq   #0,d0
    3.     move.b  $24(a0),d0
    4.     move.w  Obj_Blob_Index(pc,d0),d0
    5.     jmp Obj_Blob_Index(pc,d0)
    6.  
    7. Obj_Blob_Index:
    8.     dc.w    Obj_Blob_Init-Obj_Blob_Index
    9.     dc.w    Obj_Blob_Move-Obj_Blob_Index
    10.     dc.w    Obj_Blob_Destroy-Obj_Blob_Index
    11.  
    12. Obj_Blob_Init:
    13.     lea ($FFFFD000).w,a1
    14.     move.l  #Map_obj10,4(a0) ; ($C)
    15.     move.w  #$7A0,2(a0)
    16.     move.w  #$2,$18(a0)
    17.     move.b  #$8,$19(a0)
    18.     move.b  #$4,1(a0)
    19.     move.b  #$4,$16(a0) ; $A
    20.     move.b  #$20,$30(a0)                ; distance laser will travel
    21.     cmpi.b  #$25,$1C(a1)    ; is NICOLE attack being performed?
    22.     beq.w   ObjDE_DownwardNICOLE        ; if not, branch
    23.     move.w  #$700,$10(a0)               ; speed of laser
    24.     jmp ObjDE_ForwardNICOLE
    25. ObjDE_DownwardNICOLE:
    26.     move.w  #$700,$12(a0)               ; speed of laser
    27. ObjDE_ForwardNICOLE:
    28.     add.w   #$10,8(a0)
    29.     btst    #0,$22(a1)
    30.     beq.s Obj10_Cont
    31.     neg.w   $10(a0)
    32.     sub.w   #$20,8(a0)
    33.  
    34. Obj10_Cont:
    35.     lea (Art_Lazerart).l,a1
    36.     move.w #$7A0*$20,d2
    37.     addq.b  #2,$24(a0) ;
    38.  
    39.  
    40. Obj_Blob_Move:
    41.     cmp.b   #$0,$30(a0)
    42.     beq.w   Obj_Blob_Destroy
    43.     sub.b   #$1,$30(a0)
    44.     jsr SpeedToPos2
    45.     move.b  $40,$20(a0) ; lol
    46.    
    47.     clr.w d0
    48.     move.b $1A(a0),d0
    49.     asl.w #$1,d0    ; *2 for correct offset
    50.     adda.w (a1,d0.w),a1
    51.     move.w #$7A0*$20,d2
    52.    
    53.     lea (Ani_Laser).l,a1
    54.     jsr AnimateSprite
    55.     jsr (TouchResponse).l ;Touch_KillEnemy, Touch_Monitor  
    56.     jmp DisplaySprite
    57.  
    58. Obj_Blob_Destroy:
    59.     clr.b   ($FFFFFFA4).w   ; clear missle flag
    60.     jmp DeleteObject
    61.    
    62. Ani_Laser:
    63.     dc.w laser0-Ani_Laser
    64. laser0: dc.b 3,0,1,1,1,2,2,2,3,3,3,$FD,0
    65.     even
    66.  
    It seems to recognise the object itself but it's invisible and never shows any art unless it merges into another objects VRAM (I moved the lamp post's VRAM before you point that out by the way). Anyone have any idea why it won't display?
     
  14. flamewing

    flamewing

    Emerald Hunter Tech Member
    1,161
    65
    28
    France
    Sonic Classic Heroes; Sonic 2 Special Stage Editor; Sonic 3&K Heroes (on hold)
    Is the art actually being loaded? I ask because there is nothing in the code that suggests it, but you could be loading it with PLCs elsewhere, so I don't know. I do see fragments of code that could indicate art being loaded (the bits with "$7A0*$20"), but they are incomplete.
     
  15. AURORA☆FIELDS

    AURORA☆FIELDS

    The cute one here Tech Member
    216
    24
    18
    Finland
    AMPS
    Just looking at the code, I found few possible causes for it not to work:
    • Your object will be created at either x $10, or x -$10, and y 0. You never copy X and Y positions from Sonic's RAM in above code.
    • Most of the time, when running the object, a1 will not point to Art_Lazerart, with the exception of initializing frame, because you define it at Obj10_Cont, which isn't accessed if routine counter is 2 or above.
    • It seems you are trying to do some kind of Dynamic art loading method in the routine as well, but it doesnt seem you actually ever load the art
     
  16. E-122-Psi

    E-122-Psi

    Member
    2,470
    612
    93
    This version I admit probably isn't done right. The original coding uses a unique compression provided by snkenjoi that I wasn't sure people would be able to help with, so I tried haphazardly to make one using uncompressed art. Here's the original if it helps:

    Code (ASM):
    1. Obj10:
    2.     moveq   #0,d0
    3.     move.b  $24(a0),d0
    4.     move.w  Obj_Blob_Index(pc,d0),d0
    5.     jmp Obj_Blob_Index(pc,d0)
    6.  
    7. Obj_Blob_Index:
    8.     dc.w    Obj_Blob_Init-Obj_Blob_Index
    9.     dc.w    Obj_Blob_Move-Obj_Blob_Index
    10.     dc.w    Obj_Blob_Destroy-Obj_Blob_Index
    11.  
    12. Obj_Blob_Init:
    13.     lea ($FFFFD000).w,a1
    14.     move.l  #SME_0iwB5,4(a0) ; ($C)
    15.     move.w  #$7A0,2(a0)
    16.     move.w  #$2,$18(a0)
    17.     move.b  #$8,$19(a0)
    18.     move.b  #$4,1(a0)
    19.     move.b  #$4,$16(a0) ; $A
    20.     move.b  #$20,$30(a0)                ; distance laser will travel
    21.     cmpi.b  #$25,$1C(a1)    ; is NICOLE attack being performed?
    22.     beq.w   ObjDE_DownwardNICOLE        ; if not, branch
    23.     move.w  #$700,$10(a0)               ; speed of laser
    24.     jmp ObjDE_ForwardNICOLE
    25. ObjDE_DownwardNICOLE:
    26.     move.w  #$700,$12(a0)               ; speed of laser
    27. ObjDE_ForwardNICOLE:
    28.     add.w   #$10,8(a0)
    29.     btst    #0,$22(a1)
    30.     beq.s Obj10_Cont
    31.     neg.w   $10(a0)
    32.     sub.w   #$20,8(a0)
    33.  
    34. Obj10_Cont:
    35.     lea (ArtSNK_Laser0).l,a1
    36.     move.w #$7A0*$20,d2
    37.     jsr (SNKDec).l
    38.     addq.b  #2,$24(a0) ;
    39.  
    40. Obj_Blob_Move:
    41.     cmp.b   #$0,$30(a0)
    42.     beq.w   Obj_Blob_Destroy
    43.     sub.b   #$1,$30(a0)
    44.     jsr SpeedToPos2
    45.     move.b  $40,$20(a0) ; lol
    46.    
    47.     clr.w d0
    48.     move.b $1A(a0),d0
    49.     asl.w #$1,d0    ; *2 for correct offset
    50.     lea (LaserArtPointers).l,a1
    51.     adda.w (a1,d0.w),a1
    52.     move.w #$7A0*$20,d2
    53.     jsr     (SNKDec).l
    54.    
    55.     lea (Ani_Laser).l,a1
    56.     jsr AnimateSprite
    57.     jsr (TouchResponse).l ;Touch_KillEnemy, Touch_Monitor  
    58.     jmp DisplaySprite
    59.  
    60. Obj_Blob_Destroy:
    61.     clr.b   ($FFFFFFA4).w   ; clear NICOLE flag
    62.     jmp DeleteObject
    63.    
    64. Ani_Laser:
    65.     dc.w laser0-Ani_Laser
    66. laser0: dc.b 3,0,1,1,1,2,2,2,3,3,3,$FD,0
    67.     even
    68.  
    69. SME_0iwB5: 
    70.         dc.w SME_0iwB5_8-SME_0iwB5, SME_0iwB5_12-SME_0iwB5 
    71.         dc.w SME_0iwB5_1C-SME_0iwB5, SME_0iwB5_26-SME_0iwB5
    72. SME_0iwB5_8:    dc.b 0, 1  
    73.         dc.b $F8, 5, 0, 0, 0, 0, $FF, $F8  
    74. SME_0iwB5_12:   dc.b 0, 1  
    75.         dc.b $F8, 5, 0, 0, 0, 0, $FF, $F8  
    76. SME_0iwB5_1C:   dc.b 0, 1  
    77.         dc.b $F8, 5, 0, 0, 0, 0, $FF, $F8  
    78. SME_0iwB5_26:   dc.b 0, 1  
    79.         dc.b $F8, 5, 0, 0, 0, 0, $FF, $F8  
    80.         even
     
  17. RetroKoH

    RetroKoH

    Member
    1,662
    22
    18
    Project Sonic 8x16
    So I ported the S2 Rings Manager to S1... having a priority issue, in which the rings appear over the title card, in instances like Marble Zone 1. Normally rings in S2 and S3K get drawn over everything else... whereas that wasn't the case with Sonic 1, where they'd have a priority of 2 and then after Sonic collected them, they'd get a priority of 1....

    Anyone know how I can mod a Ring Manager to emulate this priority change in any way?
     
  18. flamewing

    flamewing

    Emerald Hunter Tech Member
    1,161
    65
    28
    France
    Sonic Classic Heroes; Sonic 2 Special Stage Editor; Sonic 3&K Heroes (on hold)
    You actually have to mod the BuildSprites routine (or whatever it is called in S1) to render the rings at the right priority. Using S2's BuildSprites as an example, since you probably used it as a base: in stock S2, you have this:
    [68k]BuildSprites:
    tst.w (Two_player_mode).w
    bne.w BuildSprites_2P
    lea (Sprite_Table).w,a2
    moveq #0,d5
    moveq #0,d4
    tst.b (Level_started_flag).w
    beq.s +
    bsr.w JmpTo_BuildHUD
    bsr.w BuildRings
    +
    lea (Sprite_Table_Input).w,a4
    moveq #7,d7 ; 8 priority levels
    ; loc_16628:
    BuildSprites_LevelLoop:
    tst.w (a4) ; does this level have any objects?
    beq.w BuildSprites_NextLevel ; if not, check the next one
    moveq #2,d6
    ; loc_16630:
    BuildSprites_ObjLoop:[/68k]
    You want something like this:
    [68k]BuildSprites:
    tst.w (Two_player_mode).w
    bne.w BuildSprites_2P
    lea (Sprite_Table).w,a2
    moveq #0,d5
    moveq #0,d4
    tst.b (Level_started_flag).w
    beq.s +
    bsr.w JmpTo_BuildHUD
    +
    lea (Sprite_Table_Input).w,a4
    moveq #7,d7 ; 8 priority levels
    ; loc_16628:
    BuildSprites_LevelLoop:
    tst.b (Level_started_flag).w
    beq.s +
    cmpa.w #Sprite_Table_Input+$80,a4
    bne.s +
    bsr.w BuildRings
    +
    tst.w (a4) ; does this level have any objects?
    beq.w BuildSprites_NextLevel ; if not, check the next one
    moveq #2,d6
    ; loc_16630:
    BuildSprites_ObjLoop:[/68k]
    This will render all rings and ring sparkles as priority 1; you won't be able to render them with different priorities in S2 or S3&K engines. Using priority 1 will generally not make much difference in practice, but if you want to have rings and sparkles render with priority 2 instead, just change this line:
    [68k] cmpa.w #Sprite_Table_Input+$80,a4[/68k]
    to this:
    [68k] cmpa.w #Sprite_Table_Input+2*$80,a4[/68k]

    Edit:
    @E-122-Psi: Is this code for S1 or S2? If for S2, then this code:
    [68k] lea ($FFFFD000).w,a1[/68k]
    is wrong and should be this:
    [68k] lea ($FFFFB000).w,a1[/68k]
    (another reason to use symbolic constants instead of raw addresses, but I digress)
    Other than this, the only other thing I can think of is what Green Snake mentioned about starting X and Y not being initialized in this code (which could simply mean it is being initialized when the object is created).

    Out of curiosity, would SNKDec be this function?
     
  19. E-122-Psi

    E-122-Psi

    Member
    2,470
    612
    93
    I believe it is, yes.

    The coding is for Sonic 1, but I've converted it from Sonic 2 coding.

    The objects positioning is loaded at the end of the routine for whatever move uses it, like so:

    Code (ASM):
    1.         move.b  #1,($FFFFFFA4).w    ; if not, set jumpdash flag
    2.         move.b  #$20,$1C(a0)        ; show NICOLE animation
    3.         bsr.w   SingleObjLoad
    4.         bne.s   NoProjectile_NICOLE
    5.         move.b  #$10,0(a1) ;Obj10
    6.         move.w  8(a0),8(a1)
    7.         move.w  $C(a0),$C(a1)
    8. NoProjectile_NICOLE:
    9.  
    Out of interest would the fact that the actual object routine comes before Sonic's in Sonic 2 but after in Sonic 1 make any difference here?
     
  20. RetroKoH

    RetroKoH

    Member
    1,662
    22
    18
    Project Sonic 8x16
    I tried that... IDK if it is something with Sonic 1, but when I built and ran, I got an empty black screen after the SEGA screen...