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,470
    612
    93
    Okay then two queries:

    1. Does anyone know a good resource for restoring the Wood Zone in Sonic 2 (eg. assets, tutorial, level editor files)?

    2. I'm trying to make an object that, when the player touches it, they get propelled upward. Right now the only way I've managed to get this running is by giving it enemy collision and turning off its ability to harm the player, though even this isn't exactly optimised since there's still other elements that interact with the enemy coding and it also means the propel level is based on the player holding jump button if they land on it the wrong way. Is there a better way of going about this?

    (For reference here is the object routine, it is my own crude work so I don't really mind if anyone steals it, their funeral. :P)

    Code (Text):
    1.  
    2. ObjE4:
    3.     moveq    #0,d0
    4.     move.b    routine(a0),d0
    5.     move.w    off_ObjE4(pc,d0.w),d1
    6.     jmp    off_ObjE4(pc,d1.w)
    7. ; ===========================================================================
    8. off_ObjE4:
    9.     dc.w ObjE4_Init-off_ObjE4
    10.     dc.w ObjE4_Main-off_ObjE4; 2
    11. ; ===========================================================================
    12. ObjE4_Init:
    13.     addq.b    #2,routine(a0)
    14.     move.l    #ObjE4_Mappings,mappings(a0)
    15.     move.b    #4,render_flags(a0)
    16.     move.w    #0,art_tile(a0)
    17.     jsr    (Adjust2PArtPointer).l
    18.     move.b    #$2,priority(a0)
    19.           move.b  #$20,width_pixels(a0)
    20.         move.b  #$4,y_radius(a0) ; $A  
    21.           move.b  #9,collision_flags(a0)
    22.  
    23.  
    24. ObjE4_Main:
    25.     moveq    #0,d0            ; clear d0
    26.     move.w    $8(a0),d0        ; load block's X-pos to d0
    27.     sub.w    (MainCharacter+$8).w,d0    ; substract Amy's X-pos from it
    28.     bpl.s    ObjE4_XPositive        ; if answer is positive, branch
    29.     neg.w    d0            ; otherwise negate d0
    30.  
    31. ObjE4_XPositive:
    32.     cmpi.w    #$20,d0            ; is Amy within 25 pixels of the object (X-axis)?
    33.     bge.s    ObjE4_RTS    ; if not, branch
    34.     moveq    #0,d0            ; clear d0
    35.     move.w    $C(a0),d0        ; load block's Y-pos to d0
    36.     sub.w    (MainCharacter+$C).w,d0    ; substract Amy's Y-pos from it  
    37.     bpl.s    ObjE4_YPositive        ; if answer is positive, branch  
    38.     neg.w    d0            ; otherwise negate d0
    39.  
    40. ObjE4_YPositive:
    41.     cmpi.w    #$20,d0            ; is Amy within 25 pixels of the object (Y-axis)?
    42.     bne.s    ObjE4_RTS    ; if not, branch
    43.     move.b    #1,anim(a0)
    44.  
    45. ; ===========================================================================
    46. ObjE4_RTS:
    47.     lea    (Ani_Fountain).l,a1
    48.     jsr    AnimateSprite
    49.     jmp    DisplaySprite
    The code to move the player upward is then listed in the Touch_Enemy routine.
     
  2. AppleSauce

    AppleSauce

    It's now illegal to use your meme! Member
    44
    2
    8
    I dunno, I guess I just liked the look of the level format. Apparently levels can be larger than that of Sonic 3, so... Yeah.
     
  3. MainMemory

    MainMemory

    Kate the Wolf Tech Member
    4,742
    338
    63
    SonLVL
    I know there was a project set for that stuff for SonLVL somewhere, I don't know about SonED2 though.
     
  4. MarkeyJester

    MarkeyJester

    Original, No substitute Resident Jester
    2,201
    431
    63
    Japan
    Yes, though it'll require some heavy optimisation tricks and shortcuts to keep the CPU time required to a minimum, but I believe for small Sonic sized art the CPU is more than capable.

    I would however offer the suggestion of pre-rendering though, unless you want to show off that you did it by software, it serves no purpose practically other than saving a bit of ROM space, you have plenty of ROM space for pre-rendered Sonic sprites anyway, so nothing much is gained in my opinion unless you have 3000 playable characters you wanna rotate the sets of.
     
  5. E-122-Psi

    E-122-Psi

    Member
    2,470
    612
    93
    I've heard porting the S3K rings manager to S2 can cause problems for VS mode. Is this true?
     
  6. Yes. Yes it is. All the rings go to 2P if you port it... Unfortunately I don't have a fix either.

    It also conflicts with the by-mode ring system used in the "Separating Act 2 and 2P Mode Data" guide.
     
  7. E-122-Psi

    E-122-Psi

    Member
    2,470
    612
    93
    Yikes. Won't be using that then. Thanx for the heads up on that.
     
  8. Well honestly I think it’d be best to work on fixing that. It’d be nice to have upwards of eight hundred rings without worry of breaking 2P mode.
     
  9. AppleSauce

    AppleSauce

    It's now illegal to use your meme! Member
    44
    2
    8
    I know pre rendered stuff exists, but I want my game to feel like Mania. So, if it really is possible, could you perhaps point me in the right direction?
     
  10. AppleSauce

    AppleSauce

    It's now illegal to use your meme! Member
    44
    2
    8
    I have never used SonLVL before. Come to think of it, I'm pretty sure that link was taken down too.
     
  11. MainMemory

    MainMemory

    Kate the Wolf Tech Member
    4,742
    338
    63
    SonLVL
    Knuckles' Emerald Hunt uses the S3K rings manager, and it works fine in 2P mode.
     
  12. Cyber Axe

    Cyber Axe

    Oldbie
    I can set animations fine, but cant find any info on changing the speed at which they play at, this is specifically for the sonic 1 github but I'm assuming it would be similar in the other games too.

    The two specific scenarios i wish to solve are..

    Sonic CD Style Spindash, i cant figure out how to speed up the animation like in sonic cd it just rotates at the slowest speed untill you release and start moving.

    I've also implemented the Super Peelout using the regular sonic run animation, i want to do the same here, set it to full running speed.
     
  13. I was actually just thinking about that... I think I might poke into that disasm a bit to see the differences in implementation.
     
  14. AppleSauce

    AppleSauce

    It's now illegal to use your meme! Member
    44
    2
    8
    Hi guys, just wondering; would it be worth it to try using the S3K split disasm? There's not that much documentation on it, but I'm not really in the mood to port file select to S2 or something.
     
  15. E-122-Psi

    E-122-Psi

    Member
    2,470
    612
    93
    It's possible to use, just don't expect it to be as easy as Sonic 1 and 2.
     
  16. Hano

    Hano

    Member
    2
    0
    1
    Hey everyone, i'm not sure whether this or "Sonic Mania discussion" would be right place to ask my questions but here goes.

    Earlier this week i started work on a Sonic Mania mod and while i've figured most of what i want to do out, i'm a little lost when it comes to doing 2 things, the first being making it so that Sonic's default move is the Super Peel-out, or having both the Peel-out and Drop Dash, i'm pretty sure it's possible but i don't know what to edit to achieve the result i want and can't seem to find any info on it.

    My second question is, how would I go about making a custom title card for different zones and/or custom menu? I've seen that they're both possible however just like my first question, i can't seem to find any info on them other than the fact that it's been done.

    If anyone could help me out, it would be much appreciated.
     
  17. E-122-Psi

    E-122-Psi

    Member
    2,470
    612
    93
    Hi, I'm trying to get some bounce pad type objects running in Sonic 2.

    Right now I've sort of got them running, if in a crude way. To give them collision, I tapped them to the enemy collision flag and put their effects in the Touch_Enemy routine like so:

    Code (Text):
    1.     cmp.b #$E6,(a1)
    2.     bne.s Touch_Fountain
    3.     move.b    #1,anim(a1)
    4.     bset    #2,status(a0)
    5.     move.b    #$E,y_radius(a0)
    6.     move.b    #7,x_radius(a0)
    7.     move.b    #$10,anim(a0)
    8.     clr.w    $12(a0)                    ; clear X-velocity to move sonic directly down
    9.     move.w    #-$800,y_vel(a0)
    10.     bset    #1,status(a0)
    11.     bclr    #3,status(a0)
    12.     move.b    #2,routine(a0)
    13. Touch_Flower_End:
    14.     rts
    15.  
    16. Touch_Fountain:
    17.    .......
    This kinda works though unless bounced on from directly on top, they don't propel you effectively enough unless you hold the jump button. Any idea how to fix this?


    Also one more thing. I'm trying to make it so obj40 (the spring board object) only has collision from landing on top of it. I tried branching it to platformobject instead of solidobject but it only produces buggy effects. Any idea what to do?
     
  18. Nintorch

    Nintorch

    Just another programmer. Member
    44
    33
    18
    There are a lot actually..
  19. This is the Flamedriver's DPCM player changed to PCM, can it get any more optimized?

    Code (Text):
    1. ; =============== S U B    R O U T    I N E =======================================
    2. ;
    3. ; Plays digital audio on the DAC, if any is queued. The z80 will be stuck in
    4. ; this function unless an interrupt occurs (that is, V-Int); after the V-Int
    5. ; is processed, the z80 will return back here.
    6. ;loc_108A
    7. zPlayDigitalAudio:
    8.         di                                ; Disable interrupts
    9.         ld    a, 2Bh                            ; DAC enable/disable register
    10.         ld    c, 0                            ; Value to disable DAC
    11.         call    zWriteFMI                        ; Send YM2612 command
    12.         ld    hl, zSongDAC                        ; Get pointer to DAC track
    13.         ld    a, (zDACEnable)                        ; Get DAC enable
    14.         or    a                            ; Is DAC supposed to be enabled?
    15.         jr    nz, .enabletrack                    ; Branch if yes
    16.         ld    hl, zSongFM6                        ; Get pointer to FM6 track
    17.  
    18. .enabletrack:
    19.         res    2, (hl)                            ; Mark track as no longer being overridden
    20.  
    21. .dac_idle_loop:
    22.         ei                                ; Enable interrupts
    23.         ld    a, (PlaySegaPCMFlag)                    ; a = play SEGA PCM flag
    24.         or    a                            ; Is SEGA sound being played?
    25.         jp    nz, zPlaySEGAPCM                    ; Branch if yes
    26.         ld    a, (zDACIndex)                        ; a = DAC index/flag
    27.         or    a                            ; Is DAC channel being used?
    28.         jr    z, .dac_idle_loop                    ; Loop if not
    29.         ld    a, 2Bh                            ; DAC enable/disable register
    30.         ld    c, 80h                            ; Value to enable DAC
    31.         di
    32.         call    zWriteFMI                        ; Send YM2612 command
    33.         ei
    34.         ld    hl, zDACIndex                        ; hl = pointer to DAC index/flag
    35.         ld    a, (hl)                            ; a = DAC index
    36.         dec    a                            ; a -= 1
    37.         set    7, (hl)                            ; Set bit 7 to indicate that DAC sample is being played
    38.         ld    hl, zmake68kPtr(DACPointers)                ; hl = pointer to ROM window
    39.         rst    PointerTableOffset                    ; hl = pointer to DAC data
    40.         ld    a, (hl)                            ; a = DAC rate
    41.         ld    (.sample1_rate+1), a                    ; Store into following instruction (self-modifying code)
    42.         inc    hl                            ; hl = pointer to low byte of DAC sample's length
    43.         ld    e, (hl)                            ; e = low byte of DAC sample's length
    44.         inc    hl                            ; hl = pointer to high byte of DAC sample's length
    45.         ld    d, (hl)                            ; d = high byte of DAC sample's length
    46.         inc    hl                            ; hl = pointer to low byte of DAC sample's in-bank location
    47.         ld    a, (hl)                            ; a = low byte of DAC sample's in-bank location
    48.         inc    hl                            ; hl = pointer to high byte of DAC sample's in-bank location
    49.         ld    h, (hl)                            ; h = high byte of DAC sample's in-bank location
    50.         ld    l, a                            ; l = low byte of DAC sample's in-bank location
    51.         ; hl is now pointer to DAC data, while de is the DAC sample's length
    52.  
    53. .dac_playback_loop:
    54. .sample1_rate:
    55.         ld    b, 0Ah                            ; self-modified code; b is set to DAC rate
    56.         djnz    $                            ; Loop in this instruction, decrementing b each iteration, until b = 0
    57.  
    58.         ei                                ; Enable interrupts
    59.  
    60.         ld    a, (hl)                            ; a = next byte of DAC sample
    61.         ld    (zYM2612_D0), a                        ; Send byte to DAC
    62.  
    63.         ld    a, (zDACIndex)                        ; a = DAC index/flag
    64.         or    a                            ; Is playing flag set?
    65.         jp    p, .dac_idle_loop                    ; Branch if not
    66.  
    67.         inc    hl                            ; Advance to next sample byte
    68.         dec    de                            ; Mark one byte as being done
    69.         ld    a, d                            ; a = d
    70.         or    e                            ; Is length zero?
    71.         jr    nz, .dac_playback_loop                    ; Loop if not
    72.  
    73.         xor    a                            ; a = 0
    74.         ld    (zDACIndex), a                        ; Mark DAC as being idle
    75.         jr    zPlayDigitalAudio                    ; Loop
     
  20. I’m just wondering - will the SCHG:How-to for porting Sonic 3 & Knuckles’s Object Manager to Sonic 2 perhaps be updated to better reflect the current state of the disassemblies and add 2P mode compatibility? As it stands, I’m a little scared to use it for my project due to how old it is, and also due to its lack of 2P Mode compatibility.