does anyone know how to get a ring when you destory an enemy

Discussion in 'Discussion and Q&A Archive' started by sonicrules, Sep 28, 2008.

Thread Status:
Not open for further replies.
  1. sonicrules

    sonicrules Newcomer In Limbo

    Joined:
    Sep 14, 2008
    Messages:
    19
    i went searching the sonic 1 .asm file and found something that said bsr.w CollectRing and I copied and pasted it to touch_kill_enemy


    but i didn't build i just said jump height too big.The problem is fixed thanks.
     
    Last edited by a moderator: Sep 29, 2008
  2. Centurey

    Centurey Well-Known Member Member

    Joined:
    Aug 28, 2008
    Messages:
    114
    Location:
    New York
    please clear this up? I really cant understand a word you said :/
     
  3. Qjimbo

    Qjimbo Well-Known Member Member

    Joined:
    Feb 27, 2008
    Messages:
    850
    Location:
    Vancouver, BC
    Yes, there is a limit in how far you can jump within a ROM, due to the fact when you use functions like bsr, they place how many bytes you jumped from on the stack, and sometimes the distance is so great it cannot fit (I believe the max distance you can jump is $FF, or 255 bytes). The solution is to create a function halfway between called CollectRing_jmp or something, and then within that add the bsr.w CollectRing code. In the touch_kill_enemy, you would then want to add


    jmp CollectRing_jmp


    :tks_return



    Then in your CollectRing_jmp routine add jmp tks_return below the CollectRing bsr. I think thats the best way to do it.


    An easier solution, if you want Sonic to simply get an extra ring on the counter, would be to simply add 1 to the ring counter area of RAM.
     
  4. SonicVaan

    SonicVaan I'm a cyberpunk with a taste for guns Member

    Joined:
    Sep 12, 2008
    Messages:
    456
    Location:
    Germany, Cologne
    Huh? I don
     
  5. sonicrules

    sonicrules Newcomer In Limbo

    Joined:
    Sep 14, 2008
    Messages:
    19
    now it works thanks for telling me how to get a ring per enemy you should make a how to work with rings guide.
     
  6. SonicVaan

    SonicVaan I'm a cyberpunk with a taste for guns Member

    Joined:
    Sep 12, 2008
    Messages:
    456
    Location:
    Germany, Cologne
    No, usually, this is a simple task of Sonic 1 ASM hacking. You should learn it by yourself, but Qjimbo was nice and told you how. It
     
    Last edited by a moderator: Sep 28, 2008
  7. shobiz

    shobiz Well-Known Member Member

    Joined:
    Aug 11, 2007
    Messages:
    198
    Location:
    Karachi, Pakistan
    Just a small correction - for a short branch the exact limit is 129 bytes forward/126 bytes back from the instruction start address, and for a word branch (as well as pc-relative jsr and jmps) it's 32769 bytes forward and 32766 bytes back.
     
Thread Status:
Not open for further replies.