don't click here

Basic Questions & Answers thread

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

  1. Jayextee

    Jayextee

    Monochrome Cat Game Guy™ Member
    3,219
    5
    18
    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

    Misfit
    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,173
    419
    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
    3,350
    157
    43
    United Kingdom
    Sonic Hacking Contest
    You forgot to add a branch to ResumeMusic.
    <!--g1--><div class='geshitop'>Syntax Highlighted Code: ASM</div><div class='geshimain'><!--eg1--><pre class="asm">&nbsp;
    Obj2E_ChkGoggles:
    [color= #00bfff;]cmpi[/color].[color= #00bfff;]b[/color] [color= #ff0000;]#[/color][color= #ff0000;]8[/color],<span style="font-weight:bold;">d0</span> [color= #adadad; font-style: italic;]; does monitor contain Googles?[/color]
    [color= #00bfff;]bne[/color].[color= #00bfff;]s[/color] Obj2E_ChkEnd [color= #adadad; font-style: italic;]; if not, stop checking for different monitor types[/color]
    [color= #00bfff;]move[/color].[color= #00bfff;]w[/color] [color= #ff0000;]#[/color][color= #ff0000;]$[/color][color= #ff0000;]1E[/color],<span style="">(</span>[color= #ff0000;]$[/color][color= #ff0000;]FFFFFE14[/color]<span style="">)</span>.[color= #00bfff;]w[/color] [color= #adadad; font-style: italic;]; Add Oxygen to Sonic[/color]
    [color= #00bfff;]bsr[/color].[color= #00bfff;]w[/color] ResumeMusic [color= #adadad; font-style: italic;]; resumes music, change to jsr ResumeMusic if there's a build error[/color]
    [color= #00bfff;]move[/color].[color= #00bfff;]w[/color] [color= #ff0000;]#[/color][color= #ff0000;]$[/color][color= #ff0000;]AD[/color],<span style="font-weight:bold;">d0</span> [color= #adadad; font-style: italic;]; move bubble collecting sound to d0[/color]
    [color= #00bfff;]jmp[/color] <span style="">(</span>PlaySound<span style="">)</span>.[color= #00bfff;]l[/color] [color= #adadad; font-style: italic;]; play collecting bubble sound[/color]
    &nbsp;
    Obj2E_ChkEnd:
    [color= #00bfff;]rts[/color]</pre><!--gc2--><!--Ck9iajJFX0Noa0dvZ2dsZXM6CiAgICBjbXBpLmIgIzgsZDAgOyBkb2VzIG1vbml0b3IgY29udGFpbiBH
    b29nbGVzPwogICAgYm5lLnMgT2JqMkVfQ2hrRW5kIDsgaWYgbm90LCBzdG9wIGNoZWNraW5nIGZvciBka
    WZmZXJlbnQgbW9uaXRvciB0eXBlcwogICAgbW92ZS53ICMmIzAzNjsxRSwoJiMwMzY7RkZGRkZFMTQpLn
    cgOyBBZGQgT3h5Z2VuIHRvIFNvbmljCiAgICBic3IudyBSZXN1bWVNdXNpYyA7IHJlc3VtZXMgbXVzaWM
    sIGNoYW5nZSB0byBqc3IgUmVzdW1lTXVzaWMgaWYgdGhlcmUmIzM5O3MgYSBidWlsZCBlcnJvcgogICAg
    bW92ZS53ICMmIzAzNjtBRCxkMCA7IG1vdmUgYnViYmxlIGNvbGxlY3Rpbmcgc291bmQgdG8gZDAKICAgI
    GptcCAoUGxheVNvdW5kKS5sIDsgcGxheSBjb2xsZWN0aW5nIGJ1YmJsZSBzb3VuZAoKT2JqMkVfQ2hrRW
    5kOgogICBydHM=--><!--egc2--><!--g2--></div><!--eg2-->
     
  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
    0
    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
    3,350
    157
    43
    United Kingdom
    Sonic Hacking Contest
    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,173
    419
    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
    0
    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,173
    419
    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,173
    419
    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

    [codebox]Hud_ChkTime:
    tst.b ($FFFFFE1E).w ; does the time need updating?
    beq.s Hud_ChkLives ; if not, branch
    tst.w ($FFFFF63A).w ; is the game paused?
    bne.s Hud_ChkLives ; if yes, branch
    lea ($FFFFFE22).w,a1
    cmpi.l #$93B3B,(a1)+ ; is the time 9.59?
    beq.s TimeOver ; if yes, branch
    subq.b #1,-(a1)
    cmpi.b #59,(a1)
    bcs.s Hud_ChkLives
    move.b #0,(a1) ;speed
    subq.b #1,-(a1) ;how long to add by
    cmpi.b #0,(a1) ;when to change didgit
    bcs.s loc_1C734
    move.b #59,(a1) ;0
    subq.b #1,-(a1)
    cmpi.b #0,(a1) ;9
    bcs.s loc_1C734
    move.b #9,(a1)[/codebox]

    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:

    [codebox]Hud_ChkTime:
    tst.b ($FFFFFE1E).w ; does the time need updating?
    beq.s Hud_ChkLives ; if not, branch
    tst.w ($FFFFF63A).w ; is the game paused?
    bne.s Hud_ChkLives ; if yes, branch
    lea ($FFFFFE22).w,a1 ; load the time into a1
    cmpi.l #$93B3B,(a1)+ ; is the time 9.59?
    beq.s TimeOver ; if yes, branch
    addq.b #1,-(a1) ; add 1 to centiseconds
    cmpi.b #60,(a1) ; is centiseconds < 60?
    bcs.s Hud_ChkLives ; if yes, branch
    move.b #0,(a1) ; reset centiseconds to 0
    addq.b #1,-(a1) ; add 1 to seconds
    cmpi.b #60,(a1) ; is seconds < 60?
    bcs.s loc_1C734 ; if yes, branch
    move.b #0,(a1) ; reset seconds to 0
    addq.b #1,-(a1) ; add 1 to minutes
    cmpi.b #9,(a1) ; is minutes < 9?
    bcs.s loc_1C734 ; if yes, branch
    move.b #9,(a1) ; reset minutes to 9[/codebox]

    Here's what I'd change it to:

    [codebox]Hud_ChkTime:
    tst.b ($FFFFFE1E).w ; does the time need updating?
    beq.s Hud_ChkLives ; if not, branch
    tst.w ($FFFFF63A).w ; is the game paused?
    bne.s Hud_ChkLives ; if yes, branch
    lea ($FFFFFE22).w,a1 ; load the time into a1
    cmpi.l #0,(a1)+ ; is the time 0.00?
    beq.s TimeOver ; if yes, branch
    subq.b #1,-(a1) ; subtract 1 from centiseconds
    cmpi.b #0,(a1) ; is centiseconds >= 0?
    bge.s Hud_ChkLives ; if yes, branch
    move.b #59,(a1) ; reset centiseconds to 59
    subq.b #1,-(a1) ; subtract 1 from seconds
    cmpi.b #0,(a1) ; is seconds >= 0?
    bge.s loc_1C734 ; if yes, branch
    move.b #59,(a1) ; reset seconds to 59
    subq.b #1,-(a1) ; subtract 1 from minutes
    cmpi.b #0,(a1) ; is minutes >= 0?
    bge.s loc_1C734 ; if yes, branch
    move.b #0,(a1) ; reset minutes to 0[/codebox]

    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!