Tools, Tutorials & Resources Various tools to help you develop your hacks can be found here.

TrollandToad.com
Reply
 
Thread Tools
  #1    
Old July 28th, 2017 (5:35 AM).
Bladecraft's Avatar
Bladecraft Bladecraft is online now
It's written "Bladecraft" on my forehead.
     
    Join Date: Feb 2017
    Gender: Male
    Nature: Calm
    Posts: 69
    Introduction
    Eyyyrybody!!
    Lately I have been creating a sidequest for my rom hack. In this sidequest you are helping the Professor research a cave, and therefore you must catch and show him every Pokemon that appears in the cave.

    He tells you which Pokemon he wants you to show him, you go and catch it, then, when talking to him again, the Pokemon menu opens and you show him the Pokemon.

    Since I had a difficult [and tilting] time overcoming this problem, I decided to create this Resource/Tutorial thread to improve the information we have about rom hacking and now everyone can use this.

    Example
    Here's a gif demonstrating the final result:

    Spoiler:

    How It's Done
    Alright, I'm going to take you step by step about how to do this.
    I'm going to assume that you already know how to insert an ASM routine into your game and how to use it.

    In case you don't, I learned how to using this thread by HackMew:
    https://www.pokecommunity.com/showthread.php?t=117917

    Simply go to the "Having Fun With ASM" section and finish his tutorial first, as it is very comfortable and beginner friendly.

    The ASM Routine
    The base ASM routine that we're using is this routine written by kleenexfeu, so credits to him.
    However, his routine is is incorrect though, so we have the extremely talented and handsome BreadCrumbs to rewrite and fix it for us.

    Here is the post that kleenexfeu made for this routine - I feel obliged to put it in because he's the original author:
    https://www.pokecommunity.com/showpost.php?p=8925169&postcount=724

    Here is the original routine by kleenexfeu in case you're lazy to check the post:
    Spoiler:
    .thumb

    Start:
    push {r0-r7, lr}
    ldr r6, var8005
    ldr r0, party_amount
    ldrb r4, [r0]
    cmp r4, #0x0
    beq End
    ldrh r3, [r6]
    cmp r3, #0x0
    beq End
    Check:
    add r0, #3
    mov r1, #0x64
    ldr r7, var8004
    ldrb r6, [r7]
    mul r1, r6
    add r0, r0, r1
    push {r0-r7}
    mov r1, #0xB
    ldr r2, decrypt_poke
    bl Jump
    mov r9, r0
    pop {r0-r7}
    cmp r9, r3
    bne NoSuccess
    mov r6, #1
    b Success
    NoSuccess:
    mov r6, #0
    Success:
    ldr r7, var8005
    strh r6, [r7]

    End:
    pop {r0-r7, pc}
    Jump:
    mov pc, r2

    .align 2
    party_amount: .word 0x020244E9
    var8004: .word 0x020275D8 + (0x8004*2)
    var8005: .word 0x020275D8 + (0x8005*2)
    decrypt_poke: .word 0x0806A519

    And here is the modified routine by BreadCrumbs
    Spoiler:
    .thumb

    Start:
    push {r0-r7, lr}
    ldr r6, var8005
    ldr r0, party_amount
    ldrb r4, [r0]
    cmp r4, #0x0
    beq End
    ldrh r3, [r6]
    cmp r3, #0x0
    beq End
    Check:
    ldr r0, party_player
    mov r1, #0x64
    ldr r7, var8004
    ldrb r6, [r7]
    mul r1, r6
    add r0, r0, r1
    push {r0-r7}
    mov r1, #0xB
    ldr r2, decrypt_poke
    bl Jump
    mov r9, r0
    pop {r0-r7}
    cmp r9, r3
    bne NoSuccess
    mov r6, #1
    b Success
    NoSuccess:
    mov r6, #0
    Success:
    ldr r7, var8005
    strh r6, [r7]

    End:
    pop {r0-r7, pc}
    Jump:
    mov pc, r2

    .align 2
    party_amount: .word 0x020244E9
    var8004: .word 0x020275D8 + (0x8004*2)
    var8005: .word 0x020275D8 + (0x8005*2)
    decrypt_poke: .word 0x0806A519
    party_player: .word 0x020244EC

    How To Use The Routine
    Alright so the routine works like so. First, you set the variable 8005 to the hex ID of the Pokemon you want to be shown. So if I want the player to show a Tochic, my first line is "setvar 0x8005 0x118"

    Afterwards, call the special 0xA2, which opens the Pokemon menu.
    Put a waitstate so the game keeps waiting, and afterwards call the ASM routine using the line "callasm 0x08ROUTINE+1"

    If you've done all this, the variable 8005 is now set to 0x1 if the player picked the correct Pokemon, and 0x0 if he picked the wrong one.

    Example Scripts
    I'll assume that there's a sprite you want the player to talk to and show it the Pokemon.

    So here's the most basic script, this is ONLY the Pokemon Menu opening and the correct Pokemon has to be picked. If it's correct it will go to @yep and if it's incorrect it will continue to the msgbox stating it is incorrect.

    Spoiler:
    #org @start
    setvar 0x8005 0x118
    special 0xA2
    waitstate
    callasm 0x8E3CF81
    compare 0x8005 0x1
    if 0x1 goto @yep
    msgbox @nope 0x6
    release
    end

    Here's the biggest example I can show you - it's the sidequest script from my hack.
    You show 7 different Pokemon in a specific order, and the reward is included, too.
    This script is over 450 lines long though, so you can only use it if you have the will to read and understand it.

    Spoiler:
    #freespace 0xFF
    #dynamic 0x800000
    #org @start
    lockall
    faceplayer
    checkflag 0x206
    if 0x1 goto @questComplete
    checkflag 0x205
    if 0x1 goto @snoruntCatch
    checkflag 0x204
    if 0x1 goto @magimerCatch
    checkflag 0x203
    if 0x1 goto @tentacoolCatch
    checkflag 0x201
    if 0x1 goto @sphealCatch
    checkflag 0x200
    if 0x1 goto @golbatCatch
    checkflag 0x199
    if 0x1 goto @zubatCatch
    checkflag 0x198
    if 0x1 goto @questStart
    msgbox @1 0x5
    compare 0x800D 0x1
    if 0x1 call @setFlag1
    if 0x1 goto @questStart
    msgbox @2 0x4
    release
    end

    #org @questStart
    msgbox @3 0x4
    setflag 0x199
    release
    end

    #org @setFlag1
    setflag 0x198
    return

    #org @zubatCatch
    msgbox @4 0x5
    compare 0x800D 0x1
    if 0x1 goto @caughtZubat
    msgbox @5 0x4
    release
    end

    #org @caughtZubat
    setvar 0x8005 0x29
    special 0xA2
    waitstate
    callasm 0x08F3F2A1
    lockall
    compare 0x8005 0x1
    if 0x1 goto @zubatCatchYes
    msgbox @6 0x4
    release
    end

    #org @zubatCatchYes
    msgbox @7 0x4
    setflag 0x200
    release
    end

    #org @golbatCatch
    msgbox @14 0x5
    compare 0x800D 0x1
    if 0x1 goto @caughtGolbat
    msgbox @5 0x4
    release
    end

    #org @caughtGolbat
    setvar 0x8005 0x2A
    special 0xA2
    waitstate
    callasm 0x08F3F2A1
    lockall
    compare 0x8005 0x1
    if 0x1 goto @golbatCatchYes
    msgbox @8 0x4
    release
    end

    #org @golbatCatchYes
    msgbox @9 0x4
    setflag 0x201
    release
    end

    #org @sphealCatch
    msgbox @15 0x5
    compare 0x800D 0x1
    if 0x1 goto @caughtSpheal
    msgbox @5 0x4
    release
    end

    #org @caughtSpheal
    setvar 0x8005 0x155
    special 0xA2
    waitstate
    callasm 0x08F3F2A1
    lockall
    compare 0x8005 0x1
    if 0x1 goto @sphealCatchYes
    msgbox @10 0x4
    release
    end

    #org @sphealCatchYes
    msgbox @11 0x4
    setflag 0x203
    release
    end

    #org @tentacoolCatch
    msgbox @16 0x5
    compare 0x800D 0x1
    if 0x1 goto @caughtTentacool
    msgbox @5 0x4
    release
    end

    #org @caughtTentacool
    setvar 0x8005 0x48
    special 0xA2
    waitstate
    callasm 0x08F3F2A1
    lockall
    compare 0x8005 0x1
    if 0x1 goto @tentacoolCatchYes
    msgbox @12 0x4
    release
    end

    #org @tentacoolCatchYes
    msgbox @13 0x4
    setflag 0x204
    release
    end

    #org @magimerCatch
    msgbox @18 0x5
    compare 0x800D 0x1
    if 0x1 goto @caughtMagikarp
    msgbox @5 0x4
    release
    end

    #org @caughtMagikarp
    setvar 0x8005 0x81
    special 0xA2
    waitstate
    callasm 0x08F3F2A1
    lockall
    compare 0x8005 0x1
    if 0x1 goto @caughtWailmer
    msgbox @17 0x4
    release
    end

    #org @caughtWailmer
    msgbox @19 0x4
    closeonkeypress
    setvar 0x8005 0x139
    special 0xA2
    waitstate
    callasm 0x08F3F2A1
    lockall
    compare 0x8005 0x1
    if 0x1 goto @wailmerCatchYes
    msgbox @21 0x4
    release
    end

    #org @wailmerCatchYes
    msgbox @20 0x4
    setflag 0x205
    release
    end

    #org @snoruntCatch
    msgbox @22 0x5
    compare 0x800D 0x1
    if 0x1 goto @caughtSnorunt
    msgbox @5 0x4
    release
    end

    #org @caughtSnorunt
    setvar 0x8005 0x15A
    special 0xA2
    waitstate
    callasm 0x08F3F2A1
    lockall
    compare 0x8005 0x1
    if 0x1 goto @snoruntCatchYes
    msgbox @24 0x4
    release
    end

    #org @snoruntCatchYes
    msgbox @23 0x4
    setflag 0x206
    goto @questComplete

    #org @questComplete
    msgbox @25 0x4
    countpokemon
    compare 0x800D 0x6
    if 0x1 goto @tooManyPokemon
    giveitem 0x2D 0x1 MSG_OBTAIN
    msgbox @28 0x4
    compare 0x800D 0x0
    if 0x1 goto @bagIsFull
    compare 0x40EC 0x0
    if 0x1 call @giveTreecko
    compare 0x40EC 0x1
    if 0x1 call @giveTorchic
    compare 0x40EC 0x2
    if 0x1 call @giveMudkip
    msgbox @38 0x4
    fanfare 0x13E
    msgbox @39 0x4
    waitfanfare
    givemoney 0x4E20 0x00
    msgbox @40 0x4
    closeonkeypress
    compare playerfacing 0x1
    if 0x1 goto @up
    compare playerfacing 0x2
    if 0x1 goto @down
    compare playerfacing 0x3
    if 0x1 goto @right
    compare playerfacing 0x4
    if 0x1 goto @left

    #org @up
    applymovement 0x3 @birchMove1
    waitmovement 0x0
    sound 0x08
    applymovement 0x3 @birchMove3
    waitmovement 0x0
    hidesprite 0x3
    setflag 0x191
    release
    end

    #org @down
    applymovement 0x3 @birchMove2
    waitmovement 0x0
    sound 0x08
    applymovement 0x3 @birchMove3
    waitmovement 0x0
    hidesprite 0x3
    setflag 0x191
    release
    end

    #org @right
    applymovement 0x3 @birchMove1
    waitmovement 0x0
    sound 0x08
    applymovement 0x3 @birchMove3
    waitmovement 0x0
    hidesprite 0x3
    setflag 0x191
    release
    end

    #org @left
    applymovement 0x3 @birchMove1
    waitmovement 0x0
    sound 0x08
    applymovement 0x3 @birchMove3
    waitmovement 0x0
    hidesprite 0x3
    setflag 0x191
    release
    end

    #org @giveTreecko
    givepokemon 0x115 0x5 0x0 0x0 0x0 0x0
    fanfare 0x13E
    msgbox @29 0x4
    waitfanfare
    msgbox @35 0x5
    closeonkeypress
    compare 0x800D 0x1
    if 0x1 goto @nicknamePokemon
    msgbox @34 0x4
    return

    #org @giveMudkip
    givepokemon 0x11B 0x5 0x0 0x0 0x0 0x0
    fanfare 0x13E
    msgbox @31 0x4
    waitfanfare
    msgbox @37 0x5
    closeonkeypress
    compare 0x800D 0x1
    if 0x1 goto @nicknamePokemon
    msgbox @33 0x4
    return

    #org @giveTorchic
    givepokemon 0x118 0x5 0x0 0x0 0x0 0x0
    fanfare 0x13E
    msgbox @30 0x4
    waitfanfare
    msgbox @36 0x5
    closeonkeypress
    compare 0x800D 0x1
    if 0x1 goto @nicknamePokemon
    msgbox @32 0x4
    return

    #org @tooManyPokemon
    msgbox @26 0x4
    release
    end

    #org @bagIsFull
    msgbox @27 0x4
    release
    end

    #org @nicknamePokemon
    countpokemon
    subvar 0x800D 0x1
    copyvar 0x8004 0x800D
    call 0x82723DD
    return

    #org @40
    = [player]: PROFESSOR BIRCH[.]\nI don't know what to say[.]\lThis is much more than I expected.\pPROF BIRCH: This is only a kind\nthank you, [player].\lFor both the great person you are,\land also for helping me personally\lin my workplace.\pI have more ROUTES and places to\ngo and research.\lCome see me in my POKéMON LAB\lin LITTLEROOT if you would like me\lto evaluate your POKéDEX.\p[player]: I'll be sure to do that.\nGoodbye for you, PROFESSOR!\pPROF BIRCH: Goodbye, [player]!\nSee you soon!

    #org @39
    = [player] recieved 20,000[$]

    #org @38
    = One last thing from me to you,\n[player].\lBecause you helped further the\lresearch of POKéMON in our world,\lI'd like to give you some of the\lfunding that has been given to me\learlier.

    #org @37
    = Would you like to give a nickname\nto MUDKIP?

    #org @36
    = Would you like to give a nickname\nto TORCHIC?

    #org @35
    = Would you like to give a nickname\nto TREECKO?

    #org @34
    = Some time ago, when both BRENDAN\nand my MAY started their adventure\lI gave both of them POKéMON.\pMAY decided to take MUDKIP, while\nBRENDAN took TORCHIC.\pI had this TREECKO left, and I'd\nlike you to have it.\p[player]: Thank you very much!\nI appreciate these gifts.\pPROF BIRCH: You deserve it all,\n[player]. There's one more thing,\ltoo.

    #org @33
    = Some time ago, when both BRENDAN\nand my MAY started their adventure\lI gave both of them POKéMON.\pMAY decided to take TORCHIC, while\nBRENDAN took TREECKO.\pI had this MUDKIP left, and I'd\nlike you to have it.\p[player]: Thank you very much!\nI appreciate these gifts.\pPROF BIRCH: You deserve it all,\n[player]. There's one more thing,\ltoo.

    #org @32
    = Some time ago, when both BRENDAN\nand my MAY started their adventure\lI gave both of them POKéMON.\pMAY decided to take TREECKO, while\nBRENDAN took MUDKIP.\pI had this TORCHIC left, and I'd\nlike you to have it.\p[player]: Thank you very much!\nI appreciate these gifts.\pPROF BIRCH: You deserve it all,\n[player]. There's one more thing,\ltoo.

    #org @31
    = [player] recieved a MUDKIP!

    #org @30
    = [player] recieved a TORCHIC!

    #org @29
    = [player] recieved a TREECKO!

    #org @28
    = PROF BIRCH: This is a super rare\nitem[.] The SACRED ASH.\pI luckily managed to get my hands\non it. Now that I investigated it\land understood it's origins, I no\llonger have a use for it.\pIt revives every fainted POKéMON\nin your party to full HP.\pI assume a great trainer like you\nwill have a use for it.\pNow I'd like to give you a special\nPOKéMON.

    #org @27
    = [player]: PROFESSOR, hold up one\nmoment please. My bag is full.\llet me make room for what you're\labout to give me.

    #org @26
    = Your party is full[.]\nI want to give you a very special\lPOKéMON.\pPlease come back when your party\nisn't full.

    #org @25
    = PROF BIRCH: [player][.] For your\nreward[.] I got you three things.\pIt's both to thank you for helping\nme personally, and also for making\linformation on POKéMON more\laccessible for everyone.

    #org @24
    = [player], [player][.]\nThis isn't a SNORUNT for sure.\pIt's the last POKéMON that should\nbe here. Try finding that secret\lroom.

    #org @23
    = Incredible[.] This is truly amazing\nthat we've managed to do this.\pAlright, for your reward I got you\na few things, [player].

    #org @22
    = PROF BIRCH: Finally!\nDid you bring me a SNORUNT?

    #org @21
    = [player]: Actually, that's not a\nWAILMER. I made a mistake, sorry.\pPROF BIRCH: It's alright, [player].\nShow me a WAILMER as soon as it is\lpossible.

    #org @20
    = That, is a WAILMER!\nIncredible! They're very rare in\lthe wild, I'm pretty sure.\pWe'll soon be done, [player].\nThere's one final POKéMON that we\lneed to catch here.\pIt's name is SNORUNT. It evolves\ninto GLALIE.\pIt is very rare, and I assume it\ncan be found only in one place.\pA secret room perhaps?\nI'm convinced he is in this cave,\lthough.

    #org @19
    = Sweet. That's a MAGIKARP alright.\nNext up is WAILMER.

    #org @18
    = PROF BIRCH: Oh, [player]!\nYou're back already?\p[player]: That's right.\pPROF BIRCH: Let's start with your\nevaluation. First, MAGIKARP.\pHave you caught the MAGIKARP?

    #org @17
    = [player], my dear[.] This is not a\nMAGIKARP[.] I expected you to know\lwhat a MAGIKARP is[.]\pIt's an orange fish POKéMON[.] You\ncan find it very easily fishing.

    #org @16
    = PROF BIRCH: I'm still looking for\nthat TENTACOOL[.]\l[.]\l[.]\l[.]\l[.]\pOh my, did you find a TENTACOOL?

    #org @15
    = PROF BIRCH: [player]! My research\nis going well.\lDid you bring a SPHEAL here?

    #org @14
    = PROF BIRCH: Hey [player]!\nDid you bring a GOLBAT?

    #org @13
    = A TENTACOOL! I've actually seen\nplenty of these, but never done\lgood research on one.\lThanks for showing me this one.\pFor the next one I'll give you\ntwo POKéMON at a time.\pThe first one will be MAGIKARP.\nYou can find it easily using an\lOLD ROD or a GOOD ROD.\pThe second one will be WAILMER.\nIt is more rare than MAGIKARP.\lYou will need to use either a GOOD\lROD or a SUPER ROD to find it.\pGood luck!

    #org @12
    = Is this a TENTACOOL?\nI'm unsure, this doesn't match my\lresources[.]\pI don't think this is a TENTACOOL,\n[player]. Please bring a JELLYFISH\lPOKEMON.

    #org @11
    = Amazing! Then this is how a SPHEAL\nfeels like[.]\lIt's different than I expected[.]\pOh, I'm getting carried away, yes,\nthe research!\pThe next POKéMON on my list is the\nPOKéMON TENTACOOL.\pYou've probably seen plenty of\nTENTACOOL in your journey.\pI'll need to look at one carefully\nthough, so I don't get hurt.

    #org @10
    = Hahaha, [player][.]\nYou know just like me that this is\lno cute ball of SPHEAL.\pPlease come back when you get a\nSPHEAL, this is a serious research.

    #org @9
    = That GOLBAT sure does match the\npictures I've seen!\lThe mouth, teeth and everything!\pThank you very much for this.\nI'll be sure to reward you when\lwe're finished.\pThe next POKéMON here is SPHEAL.\nMy sources say it's a small ICE\lTYPE POKéMON, and it resembles a\lcute little ball.\pIf you catch one, let me see it.

    #org @8
    = [player][.] Are you joking?\nThat looks nothing like a GOLABT.\lCome back when you find one.

    #org @7
    = Excellent! That's definitely a\nZUBAT right here!\pAlright.\nThe next POKéMON I want you to\lshow me is a GOLBAT.\pIt's the evolved form of ZUBAT.\nYou can find it here, it's quite\lrare, though.

    #org @6
    = That's no ZUBAT, [player][.]\nLet me know if you get a ZUBAT.

    #org @5
    = It's alright, let me know if you\nget one.

    #org @4
    = PROF BIRCH: [player]!\nDid you catch a ZUBAT?

    #org @3
    = Awesome!\pSo, my research concludes of\ncatching every single POKéMON in\lthis cave.\pThe first one should be ZUBAT.\nIt is very common.\pPlease catch a ZUBAT and bring it\nhere so I can see it.

    #org @2
    = Oh[.] That's too bad[.]\nCome back if you would like to\lhelp out, I'd love it.

    #org @1
    = PROF BIRCH: [player]! You came to\nhelp me with my research?

    #org @birchMove1
    #raw 0x08
    #raw 0x08
    #raw 0x08
    #raw 0x08
    #raw 0x0A
    #raw 0x0A
    #raw 0x0A
    #raw 0xFE

    #org @birchMove2
    #raw 0x0A
    #raw 0x08
    #raw 0x08
    #raw 0x08
    #raw 0x08
    #raw 0x0A
    #raw 0x0A
    #raw 0xFE

    #org @birchMove3
    #raw 0x08
    #raw 0xFE
    Final Words

    So I explained only the basics in this one and gave a couple of examples. The thing to remember is to think and be original with the things that this routine can accomplish, as it is very flexible. Another rom hacker that I keep in touch is already making a daily quest using this routine, so you can go very far using this, you only need to think of the great idea.

    Big thanks to everyone that made this possible, the original author of the routine and others in the Discord channel by helping me out while I was struggling:
    kleenexfeu, Lunos, Ryusaki and BreadCrumbs
    __________________
    Rule #0: Always Make a Backup


    Team Obsidian is looking for talented & creative Rom Hackers, check us out here!


    Reply With Quote

    Relevant Advertising!

    Reply

    Quick Reply

    Join the conversation!

    Create an account to post a reply in this thread, participate in other discussions, and more!

    Create a PokéCommunity Account

    Sponsored Links
    Thread Tools

    Posting Rules
    You may not post new threads
    You may not post replies
    You may not post attachments
    You may not edit your posts

    BB code is On
    Smilies are On
    [IMG] code is On
    HTML code is Off

    Forum Jump


    All times are GMT -8. The time now is 5:29 PM.