don't click here

Basic Questions & Answers thread

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

  1. Digimaks

    Digimaks

    Member
    4
    0
    0
    My first Sonic 1 hack
    Thanks, MainMemory and Wafer.
    AH.. and I was looking for the errors log in SonLVL directory, instead of actual disasembly.. whoops....
    Yes I been digging around How-To guide, and made working Eggman monitor, was pretty simple thing.
    However when I tried making it play fireball sound using sfx sfx_Fireball,0,0,0 ; (same as in fireball object in MZ) play flame sound, it doesn't play anything, even though it can play spring or bouncer sound. From what I understand the sound I want to be played is not initialized somewhere during level load. Where do I have to make it load?

    Using same tutorial I managed to make my unique monitor from invalid monitor, add its own unique art using FLEX. It's pretty much a monitor that bounces player in random direction by using part of springs yard bouncer code. I gotta fiddle around with it, since it does pretty good kick on X axis, but very unpredictable in Y axis.

    Made working "S" monitor - (no, "S" is not for Super Sonic, that's too cheap for such superpower! "S" is for "SLOW" :eng101: ) So far it is working great using same code as speed shoes, except with reduced speed and acceleration values. Only thing I want to learn if there is a way to make level music play slower during this event?

    I have plenty more questions, but will ask it a little later. Don't want to overwhelm you with newb stuff all at once :)
     
  2. AURORA☆FIELDS

    AURORA☆FIELDS

    The cute one here Tech Member
    216
    24
    18
    Finland
    AMPS
    Relating to the object ID stuff, you want to be sure to remember we are talking about hexadecimal, not decimal; numbers go from 0 to 9, then A, B, C, D, E, F and finally 10, as opposed to from 9 to 10. This is very important, and is used because its easier to represent what the processor sees when using these numbers (approximately, but anyway).

    To make the music slow down, you have to code a special sound driver behaviour. The sound driver of the Sonic games have a special feature, where if certain music ID is played, the sound driver will update the music tempo with a new value. This value will determine how fast the song plays, or more accurately, how many frames until the sounds are delayed by 1 additional frame. To create a slowdown effect, you must create a new index for these sound tempos, similarly to what is done for speed shoes, and create your own values that make the music play slower. Then you need to add an additional flag, that will enable this slowed-down behaviour in the sound driver, and play it. IIRC the Github disassembly does a good job of documenting the sound driver code, so with a little bit of tinkering you should be able to set this new feature up.
     
  3. KrustyKong

    KrustyKong

    Member
    2
    0
    1
    I'm trying to implement Sonic Advance's double-tap air dash into Sonic 1, but having some trouble getting it to work. I'm adapting the basic function from this here http://sonicresearch.org/community/index.php?threads/the-free-assets-thread.4872/#post-73802

    In Advanace, the move seems to work by starting a counter after L/R is pressed once, then for a few frames afterward it checks if that direction gets pressed again.

    I think one of the main things I need to know are what the differences between v_jpadpress and v_jpadhold are. Do some of the instructions take a frame to execute? I think my use of obFrame could be off. i also don't think im i should be branching to start?

    ; ---------------------------------------------------------------------------
    '@Start:
    tst.b $29(a0) ; was jumpdash flag set
    bne.w JD_Move
    cmpi.b #id_Roll,obAnim(a0) ; is animation rolling?
    bne.w JD_End
    cmpi.b #2,obFrame(a0) ; Is this the second frame?
    beq.s @ReleaseButton
    cmpi.b #3,$2F(a0) ; was jumpdash flag set 3
    beq.w JDLeft
    cmpi.b #1,$2F(a0) ; was jumpdash flag set 1
    beq.w JDRight
    cmpi.b #2,$2F(a0) ; is jumpdash flag at 2?
    beq.w JD_End ;if yes, branch. ;probably need to use branch if equal or greater
    ;How long does it actually take to do all this shit.
    ;supposed to double tap a direction twice and execute the dash. trying here to make the function only go if
    tst.b obFrame(a0) ; Is this the first frame?
    beq.s @FirstCheck
    bra.w JD_End

    @FirstCheck:
    move.b #3,$2F(a0) ;was thinking of setting dif values in the flag so itll know which button you pushed.
    btst #bitL,(v_jpadpress2).w
    bne.s @Start ;if yes, start again
    move.b #1,$2F(a0)
    btst #bitR,(v_jpadpress2).w
    bne.s @Start


    @ReleaseButton:
    move.b (v_jpadpress1).w,d1
    andi.b #btnR+btnL,d1 ; is left/right pressed?
    bne.s JD_End ; if yes, branch
    bra.s @Start


    JDLeft:
    btst #bitL,(v_jpadpress2).w
    beq.s JD_End
    clr.w $12(a0)
    sub.b #1,$2F(a0) ; if not, set jumpdash flag
    move.b #$C,$29(a0) ; if not, set jumpdash flag (timer. counts down in JD_Move) probably how many frames it's active.
    move.b #$BC,d0 ; set jumpdash sound
    jsr (PlaySound_Special).l ; play jumpdash sound
    sub.w #$500,$10(a0) ;enables code to work while left facing (negative velocity)
    bra.s JD_Move

    JDRight:

    btst #bitR,(v_jpadpress2).w
    beq.s JD_End
    clr.w $12(a0)
    add.b #1,$2F(a0) ; if not, set jumpdash flag
    move.b #$C,$29(a0) ; if not, set jumpdash flag (timer. counts down in JD_Move) probably how many frames it's active.
    move.b #$BC,d0 ; set jumpdash sound
    jsr (PlaySound_Special).l ; play jumpdash sound
    add.w #$500,$10(a0)

    JD_Move:
    sub.b #1,$29(a0)

    JD_End:
    rts ; return
    ; ---------------------------------------------------------------------------

    My idea was to see if you pressed L/R on the first frame, set 3 or 1 into the dash flag im using ($2f), then restart
    then check that L/R is not being pressed on the second frame, then go to the start again
    this time you have 3 or 1 in 2f, so it takes you to JDLeft or JDRight where it checks if you pressed the correct button. I'm definitely missing some stuff but if there's anything more I should do please let me know.
     
  4. Tanman Tanner

    Tanman Tanner

    Member
    10
    0
    1
    Here's my take on the v_jpadpress and v_jpadhold variables, however anyone is welcomed to correct me, as I might not be describing it correctly.

    v_jpadpress is going "Is this button being pressed (clicked)?" while v_jpadhold is going "Is this button being held down?"

    Let's take a look at some pieces of code from some Spindash Code I have in Sonic 1.

    Code (Text):
    1.  
    2.         move.b  (v_jpadpress2).w,d0 ; read controller - let's check to see if anything is being PRESSED
    3.         andi.b  #$70,d0         ; If player is pressing A/B/C, these will allow Sonic to Spindash, and it's handled by v_jpadpress2.
    4.                 beq.w   loc2_1AD78      ; if not, branch
    5.  
    Code (Text):
    1.  
    2.         move.b  (v_jpadhold2).w,d0  ; read controller - let's check to see if anything is being HELD
    3.         btst    #1,d0           ; Sonic will duck, and will remained ducked until down is released; this is handled by v_jpadhold2.
    4.  
    As for the question on "frames to execute instructions", I can't really say off the top of my head.

    This is correct:
    Code (Text):
    1.      cmpi.b #2,obFrame(a0)
    This however... :
    Code (Text):
    1.      tst.b           obFrame(a0)
    ... doesn't look correct; tst would be comparing it to 0, not 1 if I'm not mistaken.
    Try this for now and see if this made any difference:
    Code (Text):
    1.      cmpi.b #1,obFrame(a0) ; is this the first frame?
    EDIT: Refer to Ralakimus for the correct answer, apparently I'm also somewhat rusty in more than just those variables.
     
  5. Devon

    Devon

    Down you're going... down you're going... Tech Member
    1,218
    1,374
    93
    your mom
    Just to be clear, when a button is "pressed" in this context, it means a quick press and release. The controller reading routine will set newly pressed buttons' bits in "v_jpadpress" and in the next frame will clear those bits.

    "obFrame(a0)" in this context is the object's currently displayed sprite mapping frame. If you want to check which frame in the animation script is currently being used, then you want to use "obAniFrame(a0)", instead, which is 0 based.

    And yeah "cmpi.x #0,XX" and "tst.x XX" are pretty much the same, except that TST is faster.
     
  6. KrustyKong

    KrustyKong

    Member
    2
    0
    1
    Thank you guys for the response. I got the double tap to work, but not with obAniFrame. That seems to be affecting the amount of inputs I do in air (making it to 4 made it not work if i pressed the opposite direction at any point while airborne.)

    I'm trying this, but it's still letting me wait any amount of time between the first and second press:

    ...
    Code (Text):
    1. JDRight:
    2.  
    3.         cmpi.b  #8,obAniFrame(a0)   ; Is this the ninth frame?
    4.         bhi.s   JD_End  ;branch if above the ninth frame;
    5.         btst    #bitR,(v_jpadpress2).w
    6.         beq.s    JD_End
    7.         clr.w    $12(a0)
    8. ...

    I tried putting the cmpi+bhi lines after the btst too, but it had no effect.
     
  7. MainMemory

    MainMemory

    Kate the Wolf Tech Member
    4,735
    334
    63
    SonLVL
    obAniFrame doesn't just keep counting up as long as you stay in an animation, when the animation loops back to the start it gets reset to 0. If you want to make it work, you'll have to use a new variable as a counter, starting at 0 when the first direction is pressed, incrementing by 1 every frame, and only allowing the dash when it's below a certain value.
     
  8. Burger-Meister

    Burger-Meister

    Member
    1
    0
    0
    So I've been looking into the xpac files provided with Sonic and Sega All-Stars Racing. Has there been any known way to enable a character's selection in the PC release? (All that is known is that you can edit the console exclusive characters into missions) Given that each release of the game utilizes the same files (or seemingly does), it's definitely possible. On that note though, is that really accurate?
     
  9. Tanman Tanner

    Tanman Tanner

    Member
    10
    0
    1
    I have a question regarding the Z80 Sound Driver in the Sonic 3 & Knuckles GitHub disassembly.
    How would you make it support _smps2asm_inc.asm, similar to Flamewings S3K Sound Driver?
     
  10. MainMemory

    MainMemory

    Kate the Wolf Tech Member
    4,735
    334
    63
    SonLVL
    Simply place the lines:
    Code (Text):
    1. SonicDriverVer = 3
    2.     include "_smps2asm_inc.asm"
    just before you include the music files.
     
  11. Tanman Tanner

    Tanman Tanner

    Member
    10
    0
    1
    It works now MainMemory. Thank you.

    Now, a new problem arises.
    I believe it has to do wth the size of the banks and (for some reason) how large/small the music files are.
    If I were to, say, replace Sonic & Knuckles Zone Boss Theme with Sonic 2's Boss Theme after converting the fTones to sTones, the song either doesn't play/plays random notes and kills off any sound effects, such as spindashing, jumping, ring collection, etc.
    I'm not sure what steps I can do to resolve this.

    So, here's my questions.
    1. Is it possible to get away with the banks system altogether and do something like the Sonic 1 Sound Driver (although the sound driver didn't have banks either)?
    2. If not, what are my options as to expanding the banks/making them more relaxed and willing to be moved a bit?
     
  12. AURORA☆FIELDS

    AURORA☆FIELDS

    The cute one here Tech Member
    216
    24
    18
    Finland
    AMPS
    Unlike in Sonic 1, you can not move music or sound effects around inside of the banks without issues. This is why you should disassemble all of your music and sfx and put them in as asm files. This way, they are now relocatable without issues. You do also have to make sure no song crosses a bank boundary; SMPS can not deal with this and it will cause issues.
     
  13. MEGAGEN

    MEGAGEN

    Level 3
    20
    0
    0
    England
    Optimizing Sonic Franchise
    Hello Sonic Retro Community hope everyone is good.

    First I would like to thank all the developers for the great Sonic mods out there, personally we don't want the edit the layout of levels as such, we would like to fix the FPS drops especially loosing rings when hit.

    Following these posts we have a solution to the problem but unfortunately having slight trouble locating the correct strings to edit.

    http://info.sonicretro.org/SCHG_How-to:Fix_Scattered_Rings_Underwater_Physics#Sonic_2_fix

    http://info.sonicretro.org/SCHG_How-to:Speed_Up_Ring_Loss_Process_(With_Underwater)

    May I ask if anyone could point us in the right direction regarding the location of the strings, for example if we take the first stage, ''First, in your disassembly, go to "Obj37_MakeRings:" and find this bit of coding:'' We cannot seem to locate the string 'Obj37_MakeRings'

    We are sorry for posting such a noob question but we have researched as much as possible regarding this.

    1. We have successfully disassembled the Sonic 1/2 ROM and opened up the levels in 'SonED2' but I'm not 100% sure you can locate/edit strings with this program? I'm sure SonED2 is a level/object/sprite editor.

    2 We have downloaded the disassembled ROMs from Github and found that there is more data in the SonED2 projects directory but still haven't located the correct strings.

    3. We have manually opened all of the .sep files with Notepad++ and unfortunately haven't found the correct strings.

    4. We have successfully manually patched the brilliant world class 'Sonic 2 Improvement Mod' which is fantastic, the mod fixes many bugs including the horizontal scroll bug on Emerald Hill Zone. I'm not 100% sure that the 'Speed_Up_Ring_Loss_Process' parameter has been applied, it does work better but still suffers FPS loss when hit.

    Thankyou very much for your time, expertise and hope to speak soon.
     
  14. Wafer

    Wafer

    Find me on Twitter instead Member
    255
    75
    28
    Sounds like you're trying to follow the Hivebrain instructions on the Git disasm. Follow the instructions for Git instead. Most people have moved on from SonED2 to SonLVL. And SonED2/SonLVL are for editing level art and object placement, so you're looking in the wrong place. For code changes you need to look in the .asm files with a text editor.

    It's hard to know what game you're trying to work on, because you mention both Sonic 1 and 2. The instructions you quoted are for Sonic 1, but you're talking about the Sonic 2 improvement mod. I recommend working with one game at a time until you find your feet.
     
  15. MEGAGEN

    MEGAGEN

    Level 3
    20
    0
    0
    England
    Optimizing Sonic Franchise
    Hello Wafer and thankyou for the reply.

    We have scrolled further down the page and we can see the parameters for the Github fix. Were going to start with Sonic 1 and work from there. Thanks for the update on which file extension to search but unfortunately even after checking every .asm file in the disassembled ROM we still cannot locate the string?

    We have downloaded the disassembled Sonic 1 ROM 'Sonic-The-Hedgehog-Owari-master' and we are searching for the "_incObj\25 & 37 Rings.asm" for the first stage and "RLoss_Bounce:" string for the next stage.

    Thankyou for your time and hope to speak soon.
     
  16. Wafer

    Wafer

    Find me on Twitter instead Member
    255
    75
    28
    That disasm hasn't been updated in 3 years. I'd recommend the Sonic Retro Github disasm. "_incObj\25 & 37 Rings.asm" is a file in the disasm.
     
  17. MEGAGEN

    MEGAGEN

    Level 3
    20
    0
    0
    England
    Optimizing Sonic Franchise
    Thanks for the reply.

    Going to download and study the new version you have linked, hopefully we can now locate the strings.

    Thankyou for your expertise.
     
  18. Wafer

    Wafer

    Find me on Twitter instead Member
    255
    75
    28
    No, I found it. But you should probably use this Github link instead, since it's the disasm that the guide is based on: https://github.com/sonicretro/s1disasm
     
  19. MEGAGEN

    MEGAGEN

    Level 3
    20
    0
    0
    England
    Optimizing Sonic Franchise
    Update here.

    Finally located the .asm file and now progressing through the first stage, absolutely brilliant.

    If we may ask do you have any idea where this string is located? "loc_120A2"

    We have input the parameters for the first stage which is the underwater physics but are having slight difficulty locating the next string? The link for the second stage is here. We are starting from Step 1.

    http://info.sonicretro.org/SCHG_How-to:Speed_Up_Ring_Loss_Process_(With_Underwater)


    Step 1

    (Change the max amount of rings to spill)

    In the scattered rings object, go to "loc_120A2:" and the first line you should see is this:

    moveq #$20,d0

    We have tried to search for the string 'Scattered Rings' and also searched through many .asm files to try and locate the parameters.

    Thanks again.
     
  20. Overlord

    Overlord

    Now playable in Smash Bros Ultimate Moderator
    19,218
    965
    93
    Long-term happiness
    Also, please stop referring to yourself as "we" - only one person is typing, and only one person should be using one account.