don't click here

Basic Questions & Answers thread

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

  1. Jayextee

    Jayextee

    Unpopular Opinions™ Member
    3,253
    61
    28
    Atro City
    I DONE MAKED GAMES.
    Thanks. I know my limit now. Good job I'm preferring good poses and spacing over simply adding millions of frames.
     
  2. lightningrod

    lightningrod

    Banned
    1
    0
    0
    Hello. I am new here and I wish to ask a question.

    I am making a Sonic 1 hack at the moment and I wish to add different music from Sonic 2, Sonic 3 and Sonic&K to the game via SNASM68K but I am not sure how.

    I HAVE looked through the posts to see if anyone else has asked this and they have but they are just directed to tweaker's music guide which I have look through and I am just as confused as sin!

    I wish that there was a simple step by step way of doing this, is there any where there is an idiot's guide to do this please?

    Thanks
     
  3. Why is he banned? It does say he looked at Tweaker's guide >_> (If he was banned for that post. Says he has two, one is probably validation and this is his second one?)
     
  4. nineko

    nineko

    I am the Holy Cat Tech Member
    6,298
    475
    63
    italy
    He made a page-long post full of "SPAMSPAMSPAMSPAMSPAMSPAM" in another thread.
     
  5. Anthall

    Anthall

    Spambot Member
    235
    0
    0
    Leicester, UK
    Sonic the Hedgehog - The Final Showdown
    Hello again!

    The bubble ASM code is working correctly , only there is only one problem with it, I have the code below, but when Sonic gets the bubble monitor when the air timer music is on, Sonic does get the oxygen as usual, but the countdown music continues, then the music stops. But when Sonic get's an air bubble, the music behaves as usual.(Note: The monitor now gives a one use oxygen supply not infinite oxygen) Anyway here is my source code for it:

    Obj2E_ChkGoggles:
    cmpi.b #8,d0 ; does monitor contain Googles?
    bne.s Obj2E_ChkEnd ; if not, stop checking for different monitor types
    move.w #$1E,($FFFFFE14).w ; Add Oxygen to Sonic
    move.w #$AD,d0 ; move bubble collecting sound to d0
    jmp (PlaySound).l ; play collecting bubble sound

    Obj2E_ChkEnd:
    rts

    Any assistance will be much appreciated. Thanks!
     
  6. Spanner

    Spanner

    The Tool Member
    You forgot to add a branch to ResumeMusic.
    Code (ASM):
    1.  
    2. Obj2E_ChkGoggles:
    3.     cmpi.b #8,d0 ; does monitor contain Googles?
    4.     bne.s Obj2E_ChkEnd ; if not, stop checking for different monitor types
    5.     move.w #$1E,($FFFFFE14).w ; Add Oxygen to Sonic
    6.     bsr.w ResumeMusic ; resumes music, change to jsr ResumeMusic if there's a build error
    7.     move.w #$AD,d0 ; move bubble collecting sound to d0
    8.     jmp (PlaySound).l ; play collecting bubble sound
    9.  
    10. Obj2E_ChkEnd:
    11.    rts
     
  7. Anthall

    Anthall

    Spambot Member
    235
    0
    0
    Leicester, UK
    Sonic the Hedgehog - The Final Showdown
    Thanks SOTI, but the resultant code from build.bat is:

    SN 68k version 2.53

    C:\USERS\ANTHONY HALL\DESKTOP\HACKING PROJECT\HIVEBRAIN\SONIC1.ASM(12672) : Erro
    r : Branch (40206 bytes) is out of range

    Assembly completed.
    1 error(s) from 47606 lines in 0.18 seconds
    Lightning's ROM Padder

    Reported Size: 0 Reported Checksum: 0
    Size applied: 7F Checksum Applied: 0
    Press any key to continue . . .



    Thanks
     
  8. Polygon Jim

    Polygon Jim

    Eternal Tech Member
    0
    3
    0
    across town from Hinchy
    All the bitches.
    Isn't that a bit far from the root drive? I've always had problems unless I have it in something like C:/sonhack.
     
  9. Spanner

    Spanner

    The Tool Member
    Change it to jsr ResumeMusic then.
     
  10. Anthall

    Anthall

    Spambot Member
    235
    0
    0
    Leicester, UK
    Sonic the Hedgehog - The Final Showdown
    Oh I thought that was a piece of code for some reason (Stupid me), but it DOES build now but the music still doesn't change back to normal.
     
  11. nineko

    nineko

    I am the Holy Cat Tech Member
    6,298
    475
    63
    italy
    No. Branch out of range means that the bsr to ResumeMusic is too far from that routine. A bsr.w can jump only from -32768 to +32767 bytes from your current position. So he has to change that to jsr, which can jump everywhere.
     
  12. Why does bsr even exist if you have JSR?
     
  13. Polygon Jim

    Polygon Jim

    Eternal Tech Member
    0
    3
    0
    across town from Hinchy
    All the bitches.

    I wasn't talking about the error, I was just saying it seemed like they had thier disassembly a bit far, I just always had problems when it was on my desktop.
     
  14. nineko

    nineko

    I am the Holy Cat Tech Member
    6,298
    475
    63
    italy
    It takes less bytes in the ROM. A JSR uses absolute 32-bit addresses, so 4 bytes other than the ones used by the opcode itself. A bxx.b or bxx.s can jump from -128 to +127, so one byte other than the opcode, and a bxx.w can jump from -32768 to +32767, so two bytes other than the opcode.

    A long path can give errors, but not in this case. The ROM can't compile because of the branching error, which invalidates the whole file.
     
  15. Anthall

    Anthall

    Spambot Member
    235
    0
    0
    Leicester, UK
    Sonic the Hedgehog - The Final Showdown
    It does seem to bother me at all.

    Anyway I don't know what the problem is. ResumeMusic is:


    ResumeMusic: ; XREF: Obj64_Wobble; Sonic_Water; Obj0A_ReduceAir
    cmpi.w #$C,($FFFFFE14).w
    bhi.s loc_140AC
    move.w #$86,d0 ; play SBZ music
    cmpi.w #$103,($FFFFFE10).w ; check if level is 0103 (SBZ3)
    bne.s loc_140A6
    move.w #$8D,d0 ; play FZ music

    (Yeah I know SBZ music does fit LZ, but when I will change it when I learn how to import some music from Castle of Illusion)
     
  16. nineko

    nineko

    I am the Holy Cat Tech Member
    6,298
    475
    63
    italy
    Change it to jsr ResumeMusic then.
     
  17. Anthall

    Anthall

    Spambot Member
    235
    0
    0
    Leicester, UK
    Sonic the Hedgehog - The Final Showdown
    I have already done so. (Yes, I understand your annoyance, ASM hates me and forces me to ask a lot of questions and look :thumbsup: )
     
  18. Adam2k7

    Adam2k7

    22
    0
    0
    Walsall UK
    Sonic Adventures EX, Sonic 2 Redemption Edition
    hello there, I am having a few problems with reversing the timer in Sonic 1 using ASM I really could do with an experianced eye to tell me where I have gone wrong... this is what I got but its just sat at 9.59

    Code (ASM):
    1. Hud_ChkTime:
    2.         tst.b   ($FFFFFE1E).w   ; does the time need updating?
    3.         beq.s   Hud_ChkLives    ; if not, branch
    4.         tst.w   ($FFFFF63A).w   ; is the game paused?
    5.         bne.s   Hud_ChkLives    ; if yes, branch
    6.         lea ($FFFFFE22).w,a1
    7.         cmpi.l  #$93B3B,(a1)+   ; is the time 9.59?
    8.         beq.s   TimeOver    ; if yes, branch
    9.         subq.b  #1,-(a1)
    10.         cmpi.b  #59,(a1)
    11.         bcs.s   Hud_ChkLives
    12.         move.b  #0,(a1)       ;speed
    13.         subq.b  #1,-(a1)      ;how long to add by
    14.         cmpi.b  #0,(a1)      ;when to change didgit
    15.         bcs.s   loc_1C734
    16.         move.b  #59,(a1)        ;0
    17.         subq.b  #1,-(a1)        
    18.         cmpi.b  #0,(a1)         ;9
    19.         bcs.s   loc_1C734
    20.         move.b  #9,(a1)
    any help would be greatly apreciated :)
     
  19. Actually, the limits are -32766 to +32769 from the starting address of the instruction. The reason for this is that the offset specified in the branch isn't added to the instruction start address, it's added to the instruction start address + 2.

    Additionally, branches also take less cycles than absolute jumps, and as noted above, -126 and +129, and -32766 and +32769.
     
  20. ColinC10

    ColinC10

    Tech Member
    The normal timer routine looks like this, which I've filled in comments for:

    Code (ASM):
    1. Hud_ChkTime:
    2.         tst.b   ($FFFFFE1E).w       ; does the time need updating?
    3.         beq.s   Hud_ChkLives        ; if not, branch
    4.         tst.w   ($FFFFF63A).w       ; is the game paused?
    5.         bne.s   Hud_ChkLives        ; if yes, branch
    6.         lea ($FFFFFE22).w,a1    ; load the time into a1
    7.         cmpi.l  #$93B3B,(a1)+       ; is the time 9.59?
    8.         beq.s   TimeOver        ; if yes, branch
    9.         addq.b  #1,-(a1)        ; add 1 to centiseconds
    10.         cmpi.b  #60,(a1)        ; is centiseconds < 60?
    11.         bcs.s   Hud_ChkLives        ; if yes, branch
    12.         move.b  #0,(a1)         ; reset centiseconds to 0
    13.         addq.b  #1,-(a1)        ; add 1 to seconds
    14.         cmpi.b  #60,(a1)        ; is seconds < 60?
    15.         bcs.s   loc_1C734       ; if yes, branch
    16.         move.b  #0,(a1)         ; reset seconds to 0
    17.         addq.b  #1,-(a1)        ; add 1 to minutes
    18.         cmpi.b  #9,(a1)         ; is minutes < 9?
    19.         bcs.s   loc_1C734       ; if yes, branch
    20.         move.b  #9,(a1)         ; reset minutes to 9
    Here's what I'd change it to:

    Code (ASM):
    1. Hud_ChkTime:
    2.         tst.b   ($FFFFFE1E).w       ; does the time need updating?
    3.         beq.s   Hud_ChkLives        ; if not, branch
    4.         tst.w   ($FFFFF63A).w       ; is the game paused?
    5.         bne.s   Hud_ChkLives        ; if yes, branch
    6.         lea ($FFFFFE22).w,a1    ; load the time into a1
    7.         cmpi.l  #[color="red"]0[/color],(a1)+       ; is the time [color="red"]0.00[/color]?
    8.         beq.s   TimeOver        ; if yes, branch
    9.         [color="red"]subq[/color].b #1,-(a1)        ; [color="red"]subtract[/color] 1 from centiseconds
    10.         cmpi.b  #[color="red"]0[/color],(a1)            ; is centiseconds [color="red"]>= 0[/color]?
    11.         [color="red"]bge[/color].s  Hud_ChkLives        ; if yes, branch
    12.         move.b  #[color="red"]59[/color],(a1)       ; reset centiseconds to [color="red"]59[/color]
    13.         [color="red"]subq[/color].b #1,-(a1)        ; [color="red"]subtract[/color] 1 from seconds
    14.         cmpi.b  #[color="red"]0[/color],(a1)            ; is seconds [color="red"]>= 0[/color]?
    15.         [color="red"]bge[/color].s  loc_1C734       ; if yes, branch
    16.         move.b  #[color="red"]59[/color],(a1)       ; reset seconds to [color="red"]59[/color]
    17.         [color="red"]subq[/color].b #1,-(a1)        ; [color="red"]subtract[/color] 1 from minutes
    18.         cmpi.b  #[color="red"]0[/color],(a1)            ; is minutes [color="red"]>= 0[/color]?
    19.         [color="red"]bge[/color].s  loc_1C734       ; if yes, branch
    20.         move.b  #[color="red"]0[/color],(a1)            ; reset minutes to [color="red"]0[/color]
    If you want you can change "cmpi.b #0" to "tst.b". The reason for your version not working is probably because you were still checking if the numbers were less than, not greater than.

    There are still a few fixes to make elsewhere to get this to work properly, which I'll leave for you to do. The timer will obviously need to start at something other than 0.00.00. When I tested this, the timer showed 0.00 for a second before updating - there are various ways you could fix that. You'll need to make the timer flash during minute 0 and not minute 9. And finally, the timer appears to give you a "bonus second" when it hits 0, because of the hidden centiseconds digits. If you prefer, you could make Time Over happen at 0.00.59.

    Hope that helps!