don't click here

Basic Questions & Answers thread

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


  1. Go to the spikes code, do the opposite of what the remove spike bug guide tells you to do, so remove a few lines.




    Most likely errors, open up your build.bat in notepad, and add 'pause' at the end. Run it again, it'll say if you have any errors.





    Use playsound #sound effect number

    It could be different in s1, to double check look at any playsound you can find, or anything similar. It follows the same rule
     
  2. nineko

    nineko

    I am the Holy Cat Tech Member
    6,171
    413
    63
    italy
    The game froze because you branch from Obj2E_ChkGoggles to Obj2E_ChkGoggles so it's stuck in an infinite loop. Assuming that 8 is the last monitor subtype you have, you should branch to the end.

    Obj2E_ChkGoggles:
    cmpi.b #8,d0 ; does monitor contain Googles?
    bne.s Obj2E_ChkEnd
    move.w #$1E,($FFFFFE14).w ; Add Oxygen to Sonic
    move.w #$AD,d0
    jmp (PlaySound_Special).l ; play collecting bubble sound
     
  3. Tweaker

    Tweaker

    Misfit
    12,389
    1
    0
    To add a sound effect, the following bit of code will do fine:
    <!--g1--><div class='geshitop'>Syntax Highlighted Code: ASM</div><div class='codemain'><!--eg1--><pre class="asm"> [color= #00bfff;]moveq[/color] [color= #ff0000;]#[/color][color= #ff0000;]$[/color]xx,<span style="font-weight:bold;">d0</span>
    [color= #00bfff;]jsr[/color] PlaySound</pre><!--gc2--><!--CQltb3ZlcQkjJiMwMzY7eHgsZDAKCQlqc3IJUGxheVNvdW5k--><!--egc2--><!--g2--></div><!--eg2-->
    ...where xx is the sound test ID of what you want to play. Pretty simple.

    EDIT: Fuck, new page. Beaten :colbert:
     
  4. Anthall

    Anthall

    Spambot Member
    235
    0
    0
    Leicester, UK
    Sonic the Hedgehog - The Final Showdown
    Thank you.

    There is only one problem though:

    When I compile the ROM I get this error:


    SN 68k version 2.53

    C:\USERS\ANTHONY HALL\DESKTOP\HACKING PROJECT\HIVEBRAIN\SONIC1.ASM(12668) : Erro
    r : Symbol 'obj2e_chkend' not defined

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

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

    Any ideas why obj2e_chkend is not defined?
     
  5. SMTP

    SMTP

    Tech Member
    obj2e_chkend I think was an example he used. You'd have to make that your self...
     
  6. nineko

    nineko

    I am the Holy Cat Tech Member
    6,171
    413
    63
    italy
    No, obj2e_chkend exists in a clean disassembly, he probably removed it by mistake. For this reason I'm not going to paste here what to put there, even if I could. He should download another clean disassembly and fix that.
     
  7. Tweaker

    Tweaker

    Misfit
    12,389
    1
    0
    Besides that, I'm pretty sure the routine is nothing but an rts, anyway. Just define the label and slap an rts in there. Sorted.
     
  8. Anthall

    Anthall

    Spambot Member
    235
    0
    0
    Leicester, UK
    Sonic the Hedgehog - The Final Showdown
    Sorry, I'm not very experienced at this.

    What do you mean, you have to make it your self?

    EDIT: Tweaker, What should I define the label?

    Thanks
     
  9. Tweaker

    Tweaker

    Misfit
    12,389
    1
    0
    Defining a label is basically sticking the name of the routine with a colon at the end. You'd want to make something like this:
    <!--g1--><div class='geshitop'>Syntax Highlighted Code: ASM</div><div class='codemain'><!--eg1--><pre class="asm">Obj2E_ChkEnd:
    [color= #00bfff;]rts[/color]</pre><!--gc2--><!--T2JqMkVfQ2hrRW5kOgoJCXJ0cw==--><!--egc2--><!--g2--></div><!--eg2-->
    ...and stick it below the end of Obj2E_ChkGoggles. That should sort everything out.
     
  10. Anthall

    Anthall

    Spambot Member
    235
    0
    0
    Leicester, UK
    Sonic the Hedgehog - The Final Showdown
    Sorry, but the file still doesn't compile (Your probably getting bored...Sorry :colbert: ),

    Here is the code I presently got:

    ; ===========================================================================

    Obj2E_ChkGoggles:
    cmpi.b #8,d0 ; does monitor contain Googles?
    bne.s Obj2E_ChkEnd
    rts
    move.w #$1E,($FFFFFE14).w ; Add Oxygen to Sonic
    move.w #$AD,d0
    jmp (PlaySound_Special).l ; play collecting bubble sound
    ; ===========================================================================

    I then tried using Tweaker's advice:

    ; ===========================================================================

    Obj2E_ChkGoggles:
    cmpi.b #8,d0 ; does monitor contain Googles?
    move.w #$1E,($FFFFFE14).w ; Add Oxygen to Sonic
    move.w #$AD,d0
    jmp (PlaySound_Special).l ; play collecting bubble sound
    bne.s Obj2E_ChkEnd
    rts
    ; ===========================================================================

    and for both attempts I got:

    The batch file output is:


    SN 68k version 2.53

    C:\USERS\ANTHONY HALL\DESKTOP\HACKING PROJECT\HIVEBRAIN\SONIC1.ASM(12668) : Erro
    r : Symbol 'obj2e_chkend' not defined

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

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

    For the first code, and for the second code it was exactly the same (Apart from the line No of course)
     
  11. Adam2k7

    Adam2k7

    22
    0
    0
    Walsall UK
    Sonic Adventures EX, Sonic 2 Redemption Edition
    I think you have to define the label then the program can call it - try this......[codebox]; ===========================================================================

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

    Obj2E_ChkEnd:
    rts
    ; ===========================================================================
    [/codebox]
     
  12. Tweaker

    Tweaker

    Misfit
    12,389
    1
    0
    Whoa, you're confusing me now! Haha.

    Okay, what you're going to want is something like this:
    <!--g1--><div class='geshitop'>Syntax Highlighted Code: ASM</div><div class='geshimain'><!--eg1--><pre class="asm">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;]FFFF[/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;]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_Special<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--><!--T2JqMkVfQ2hrR29nZ2xlczoKCQljbXBpLmIgIzgsZDAgOyBkb2VzIG1vbml0b3IgY29udGFpbiBHb29n
    bGVzPwoJCWJuZS5zIE9iajJFX0Noa0VuZAk7IGlmIG5vdCwgc3RvcCBjaGVja2luZyBmb3IgZGlmZmVyZ
    W50IG1vbml0b3IgdHlwZXMKCQltb3ZlLncgIyYjMDM2O0ZGRkYsKCYjMDM2O0ZGRkZGRTE0KS53IDsgQW
    RkIE94eWdlbiB0byBTb25pYwoJCW1vdmUudyAjJiMwMzY7QUQsZDAJOyBtb3ZlIGJ1YmJsZSBjb2xsZWN
    0aW5nIHNvdW5kIHRvIGQwCgkJam1wIChQbGF5U291bmRfU3BlY2lhbCkubCA7IHBsYXkgY29sbGVjdGlu
    ZyBidWJibGUgc291bmQgCgpPYmoyRV9DaGtFbmQ6CgkJcnRz--><!--egc2--><!--g2--></div><!--eg2-->
    Let me explain the flow of the code. The first thing we're doing is checking if the monitor contains the Goggles subtype. If it does, then it's going to skip over that branch to Obj2E_ChkEnd, which will ONLY execute if the monitor is not the Goggles subtype. That routine will pop the stack, backing out of the monitor code entirely as it should.

    The code after that branch is the stuff you wrote. It's going to set Sonic's oxygen level, as well as play the bubble collection sound. Once these two instructions are completed, it will then move onto the next routine, which is Obj2E_ChkEnd. As before, this will pop the stack and exit the monitor code. This is the correct flow of logic—once everything is done executing, it backs out so it doesn't attempt to execute unrelated code (or sometimes data, which can obviously not be exectuted).

    The code you wrote was wrong the first time because you set an rts before your custom code could execute. This means that any additions you made were null and void, and were never even parsed. The second code you wrote was wrong because it checks if the monitor is Goggle, but never exits if it's not. This would make it so any subtypes added after this monitor would always have the Goggle monitor effect, which is something you don't want.

    Anyway, the code I wrote should work fine; I also took the liberty of maxing out the oxygen level so it appears to be infinite. Is there anything you still don't understand that I can explain to you?
     
  13. Anthall

    Anthall

    Spambot Member
    235
    0
    0
    Leicester, UK
    Sonic the Hedgehog - The Final Showdown
    Ok, I tried both Tweaker's and Adam2k7's code scripts, and Adam2k7's script states that there is a "Zero Branch Length" and Tweaker's code results in the monitor still freezing the game.

    Should I post the whole monitor code from Obj2E (Monitor source code)?

    Thanks

    EDIT: I thing I was wondering:
    If I can get the monitor working, If I set the monitor to give Sonic half the air of an air bubble, If I break the monitor with full oxygen (Which I will call one unit), will I have one and a half units (It adds air), or will I have only half a unit (Overwrites the air Sonic had before breaking the box)?
     
  14. Tweaker

    Tweaker

    Misfit
    12,389
    1
    0
    OH, I know the problem. That was extremely stupid of me to overlook.

    Change the jmp to PlaySound to a jsr. That should handle everything.
     
  15. Anthall

    Anthall

    Spambot Member
    235
    0
    0
    Leicester, UK
    Sonic the Hedgehog - The Final Showdown
    What should the line be exactly, I tried three diffrent combinations, and only one compiled which still froze the game when I hit the monitor, the code I wrote was:


    jsr (PlaySound_Special).l ; play collecting bubble sound

    In the code I added the S Block which gives Sonic 50 rings, and a Robotnik which hurts Sonic

    Will any of that affect the code?
     
  16. Tweaker

    Tweaker

    Misfit
    12,389
    1
    0
    Actually, you know what, I think I might know what the problem is. Did you edit Obj2E_ChkS at all? You need to edit that to recognize the new monitor code.

    Try going to Obj2E_ChkS, and replacing that and the Obj2E_ChkGoggles you tried to put in before. This should sort everything out.
    <!--g1--><div class='geshitop'>Syntax Highlighted Code: ASM</div><div class='geshimain'><!--eg1--><pre class="asm">[color= #adadad; font-style: italic;]; ===========================================================================[/color]
    &nbsp;
    Obj2E_ChkS:
    [color= #00bfff;]cmpi[/color].[color= #00bfff;]b[/color] [color= #ff0000;]#[/color][color= #ff0000;]7[/color],<span style="font-weight:bold;">d0</span> [color= #adadad; font-style: italic;]; does monitor contain 'S'[/color]
    [color= #00bfff;]bne[/color].[color= #00bfff;]s[/color] Obj2E_ChkGoggles
    [color= #00bfff;]rts[/color]
    [color= #adadad; font-style: italic;]; ===========================================================================[/color]
    &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;]FFFF[/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;]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]
    [color= #adadad; font-style: italic;]; ===========================================================================[/color]</pre><!--gc2--><!--OyA9PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09
    PT09PT09PT09PT09PT09PT0KCk9iajJFX0Noa1M6CgkJY21waS5iCSM3LGQwCQk7IGRvZXMgbW9uaXRvc
    iBjb250YWluICYjMzk7UyYjMzk7CgkJYm5lLnMJT2JqMkVfQ2hrR29nZ2xlcwoJCXJ0cwo7ID09PT09PT
    09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT0
    9PT09PT09PQoKT2JqMkVfQ2hrR29nZ2xlczoKCQljbXBpLmIgIzgsZDAgOyBkb2VzIG1vbml0b3IgY29u
    dGFpbiBHb29nbGVzPwoJCWJuZS5zIE9iajJFX0Noa0VuZAk7IGlmIG5vdCwgc3RvcCBjaGVja2luZyBmb
    3IgZGlmZmVyZW50IG1vbml0b3IgdHlwZXMKCQltb3ZlLncgIyYjMDM2O0ZGRkYsKCYjMDM2O0ZGRkZGRT
    E0KS53IDsgQWRkIE94eWdlbiB0byBTb25pYwoJCW1vdmUudyAjJiMwMzY7QUQsZDAJOyBtb3ZlIGJ1YmJ
    sZSBjb2xsZWN0aW5nIHNvdW5kIHRvIGQwCgkJam1wIChQbGF5U291bmQpLmwgOyBwbGF5IGNvbGxlY3Rp
    bmcgYnViYmxlIHNvdW5kIAogCk9iajJFX0Noa0VuZDoKCQlydHMKOyA9PT09PT09PT09PT09PT09PT09P
    T09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT0=--><!--egc2--><!--g2--></div><!--eg2-->
     
  17. Spanner

    Spanner

    The Tool Member
    3,350
    157
    43
    United Kingdom
    Sonic Hacking Contest
    Here's an example of a working bubble monitor, I used the ring monitor but change the references to the goggles monitor:
    <!--g1--><div class='geshitop'>Syntax Highlighted Code: ASM</div><div class='geshimain'><!--eg1--><pre class="asm">&nbsp;
    &nbsp;
    Obj2E_ChkRings:
    [color= #00bfff;]move[/color].[color= #00bfff;]w[/color] <span style="">(</span>[color= #ff0000;]$[/color][color= #ff0000;]FFFFF646[/color]<span style="">)</span>.[color= #00bfff;]w[/color],<span style="font-weight:bold;">d0</span>
    [color= #00bfff;]cmp[/color].[color= #00bfff;]w[/color] [color= #ff0000;]$[/color][color= #ff0000;]C[/color]<span style="">(</span><span style="font-weight:bold;">a0</span><span style="">)</span>,<span style="font-weight:bold;">d0</span> [color= #adadad; font-style: italic;]; is Sonic above the water?[/color]
    [color= #00bfff;]beq[/color] Obj2E_Chk3End
    [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_Chk2End [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;]FFFF[/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;]bcs[/color] Obj2E_BubbleSound

    Obj2E_BubbleSound
    [color= #00bfff;]jsr[/color] ResumeMusic [color= #adadad; font-style: italic;]; cancel countdown music[/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= #00bfff;]jmp[/color] <span style="">(</span>PlaySound_Special<span style="">)</span>.[color= #00bfff;]l[/color] [color= #adadad; font-style: italic;]; play collecting bubble sound[/color]
    [color= #00bfff;]lea[/color] <span style="">(</span>[color= #ff0000;]$[/color][color= #ff0000;]FFFFD000[/color]<span style="">)</span>.[color= #00bfff;]w[/color],<span style="font-weight:bold;">a1</span>
    &nbsp;
    Obj2E_Chk3End:
    [color= #00bfff;]rts[/color]</pre><!--gc2--><!--CgpPYmoyRV9DaGtSaW5nczoKCQltb3ZlLncJKCYjMDM2O0ZGRkZGNjQ2KS53LGQwCgkJY21wLncJJiMw
    MzY7QyhhMCksZDAJOyBpcyBTb25pYyBhYm92ZSB0aGUgd2F0ZXI/CgkJYmVxCQlPYmoyRV9DaGszRW5kCgkJY21waS5iICM4LGQwIDsgZG9lcyBtb25pdG9yIGNvbnRhaW4g
    R29vZ2xlcz8KCQlibmUucyBPYmoyRV9DaGsyRW5kCTsgaWYgbm90LCBzdG9wIGNoZWNraW5nIGZvciBka
    WZmZXJlbnQgbW9uaXRvciB0eXBlcwoJCW1vdmUudyAjJiMwMzY7RkZGRiwoJiMwMzY7RkZGRkZFMTQpLn
    cgOyBBZGQgT3h5Z2VuIHRvIFNvbmljCgkJYmNzCQlPYmoyRV9CdWJibGVTb3VuZAoJCQpPYmoyRV9CdWJ
    ibGVTb3VuZAkJCgkJanNyCQlSZXN1bWVNdXNpYwk7IGNhbmNlbCBjb3VudGRvd24gbXVzaWMKCQltb3Zl
    LncJIyYjMDM2O0FELGQwCgkJam1wCShQbGF5U291bmRfU3BlY2lhbCkubCA7CXBsYXkgY29sbGVjdGluZ
    wlidWJibGUgc291bmQKCQlsZWEJKCYjMDM2O0ZGRkZEMDAwKS53LGExCiAKT2JqMkVfQ2hrM0VuZDoKCQ
    lydHM=--><!--egc2--><!--g2--></div><!--eg2-->
    For some reason, it's only working at various times.
     
  18. Anthall

    Anthall

    Spambot Member
    235
    0
    0
    Leicester, UK
    Sonic the Hedgehog - The Final Showdown
    Ahhh....
    Brilliant it works now!
    Thanks Tweaker!

    EDIT: Never mind solved it.

    Thanks
     
  19. Tweaker

    Tweaker

    Misfit
    12,389
    1
    0
    Do you mind pasting your original S monitor code? I don't mind editing the bit I have to adapt to your edits. :colbert:
     
  20. Anthall

    Anthall

    Spambot Member
    235
    0
    0
    Leicester, UK
    Sonic the Hedgehog - The Final Showdown
    Nevermind I solved it. I now know that bne.s means GOTO

    There is only two problems.
    1. When I get a bubble, the immunity to drowning is removed.
    2. When Sonic exits the water, the immunity of drowning is removed.

    Anyway Thanks for everything.