• Our software update is now concluded. You will need to reset your password to log in. In order to do this, you will have to click "Log in" in the top right corner and then "Forgot your password?".
  • Welcome to PokéCommunity! Register now and join one of the best fan communities on the 'net to talk Pokémon and more! We are not affiliated with The Pokémon Company or Nintendo.

Code: ASM Resource Thread

Froosty

The_Learner
535
Posts
9
Years
  • I just wanted to one thing,
    most commonly in many post is this thread I have seen "Battle script" and "hold effect byte"
    I am almost new to these terms in hacking so can someone simply explain about it to me,
    .
    .
    I studied the item editor and found that "hold effect byte" is simply the value dealing with the effect if the item is held.... but what are those effect and where they exist in table (pointer) and simply how can I know which effect byte works as what???
    .
    .
    sorry I am new to these so asking a lot of question to know about it!
    .
    .
    and also if anyone would like to pls tell me about "battle scripts".
    .
    thanks in advance.
    ~sorry noob here! :P
     

    Lance32497

    LanceKoijer of Pokemon_Addicts
    792
    Posts
    9
    Years
  • I don't know if anyone's been working on this lately, but I've been itching to share this.

    FireRed lacks a system that uses a Region Dex order seperate from the National Dex. If you were to have a Region Dex and a National Dex, your National Dex would look unprofessional. What I'm putting here is my work towards a Region Dex system for FireRed. I would like to stress however that it is both unoptimized and unfinished, but I really wanted to release this.

    The current routines
    Spoiler:


    Send me a PM if you're interested in fixing up what's left.

    There is a ".dexarea" in Correct numbering routine that doesn't have any value. I tried inserting .dexarea .word 0x8a90000 at the bottom of the code but it doesn't work. Any idea?
     
    50
    Posts
    9
    Years
    • Seen Jan 18, 2017
    Black Sludge Implementation:

    -> Insert at x1BE18: 00 49 08 47 XX+1 XX XX 08 00 00

    -> Routine at XXXXXX:
    Spoiler:


    -> Battle Script at GGGGGG:
    Spoiler:


    (OPTIONAL) Update the Leftovers message to latest Generation (used for positive Black Sludge too):
    -> At 1C0F4: HH HH HH 08 (In reverse hex)

    -> Battle Script at HHHHHH:
    Spoiler:



    when the team to another pokemon type is not poison life instead of down is reset
     
    50
    Posts
    9
    Years
    • Seen Jan 18, 2017
    Has anyone else tried this EV-Reducing Berries ?

    I keep trying it but to no avail I just can't seem to get it to work.

    I assemble the routine and place it at 0x7900B0, then edit the given script to;
    XSEscript:
    Code:
    #dynamic 0x740000
    '----Main----
    #org @start
    special 0x9F                             ///Choose Pokemon from Party & store it on var 0x8004
    waitstate
    bufferpartypokemon 0x0 0x8004
    setvar 0x800D 0x1A                  ///EV-stat 0x1A = HP
    setvar 0x8000 0xA                    ///EV-stat amount to subtract 0xA = 10
    callasm 0x87900B1                   ///EV-Reducing Berries ASM(pointer + 1)
    compare 0x800D 0xFF             ///Compare last result to 255
    if 0x1 goto @snippetFail
    buffernumber 0x1 0x800F
    msgbox @stringDecrese 0x6 
    removeitem 0x99 0x1               ///Item 0x99 = Pomeg Berry
    release
    end
    
    '---------------
    #org @snippetFail
    msgbox @stringFail 0x6
    release
    end
    
    '---------
    ' Strings
    '---------
    #org @stringDecrese
    = [buffer1] lost [buffer2]\nHP EVs!
    
    #org @stringFail
    = It would have no effect!


    Is there something I'm doing wrong or is there a better way to do this?

    I'm merely trying to recreate the Pomeg Berry from Emerald in Fire Red...
    Not to mention EV-Reducing Berries are rather useful when EV training...

    Also since I'm here I was wondering what gltiches from the first gen could be simulated with asm in Fire Red?

    Would like to make a working MissingNo that will check the players name and base its form off of the characters in the certain spots like in Blue and Red. Would be cool to have the item duplication glitch as well but one step at a time...

    The reason I ask is because I'm trying to make a Glitch/Error Version...
    Keeping their sporadic nature but making them contained and fun to play with...
    GlitchQuests are rather fun when they work and do some crazy stuffs>_< hahaha.

    Anyway thanks for the time and any advice given...

    What I did was put the script to a ow and if it works, I failed you can in a berry, besides that resets me every time I talk to the guy, and also I freeze if I do not have the necessary berries nor if I have evs is reset
     

    AkameTheBulbasaur

    Akame Marukawa of Iyotono
    409
    Posts
    10
    Years
  • I was wondering if it would be possible to update the Everstone to have its Gen Six breeding effect?

    To review, the Gen Six Everstone:
    •Has a 100% chance to pass down the nature of the parent holding it.
    •If both parents are holding the Everstone, the Nature passed down will be randomly chosen from the two parents (if they both have the same nature this is unnoticeable.)
     
    794
    Posts
    10
    Years
  • I was wondering if it would be possible to update the Everstone to have its Gen Six breeding effect?

    To review, the Gen Six Everstone:
    •Has a 100% chance to pass down the nature of the parent holding it.
    •If both parents are holding the Everstone, the Nature passed down will be randomly chosen from the two parents (if they both have the same nature this is unnoticeable.)

    Wouldn't be hard. Take a look at that function in Emerald: 08070084. Apparently they already inherit nature if poke is female or Ditto, but only with 50% chance.
     

    MrDollSteak

    Formerly known as 11bayerf1
    858
    Posts
    15
    Years
  • I was wondering if it would be possible to update the Everstone to have its Gen Six breeding effect?

    To review, the Gen Six Everstone:
    •Has a 100% chance to pass down the nature of the parent holding it.
    •If both parents are holding the Everstone, the Nature passed down will be randomly chosen from the two parents (if they both have the same nature this is unnoticeable.)

    I believe FBI has code for that somewhere? Though that might just be for Fire Red. Should be easy enough to port.
     

    AkameTheBulbasaur

    Akame Marukawa of Iyotono
    409
    Posts
    10
    Years
  • I believe FBI has code for that somewhere? Though that might just be for Fire Red. Should be easy enough to port.

    I know he has a Destiny Knot port, but I've yet to see an Everstone one. I'll check though because it might have slipped under my radar.

    Also I should have probably specified that I'm using Fire Red already (although Emerald ports probably wouldn't be too hard, hopefully, since they already have that function in the game, albeit slightly different).

    EDIT: I can't seem to find it. :(
     
    Last edited:

    Lance32497

    LanceKoijer of Pokemon_Addicts
    792
    Posts
    9
    Years
  • Wow, you took that well. I was expecting you to be a little annoyed at me for practically butchering through most of your suggestions. I like people who understand. Here's something you'll enjoy :)


    Introducing ASM to your Bank scripts


    Bank scripts are normally very simple. There's a variable which holds the amount of money you have, normally holding $65, 535. Or if the scripter who wrote the script is good like I am, it'd become 999, 999, 999. Anyways, bragging aside, I made two routines to help improve your banking experience :P



    Adding Interest into your variable


    Before you can insert this, you need to have the Minute Routines Framework inserted.

    This is very specific to the bank variable you're using. I'll show you the routine first. There's some orange text for you to look at again. The first orange text is how often to add interest, 0x1 is every minute and 0x3b would be every hour. The second orange text is the amount you need to subtract from 0x4100 to reach your variable. Note, you bank variable should be in the range of 0x4011 - 0x40FF. If it's not you're using an unsafe variable and should change it to something.

    After you've fixed the orange text to match your bank script compile and insert into free space.

    Spoiler:


    After you've inserted this routine, append a pointer to it to the Minute Routine Framework table.

    Usage:

    No usage. Interest is added on a minute basis to your variable of choice (which should be deposited value).



    Battle Money Straight into a variable


    So this one is kind of specific, but I kinda felt like helping someone out so I did it. All it does is, intercept the money being given to the bag, and adds it to a given variable instead. It's toggled by flag 0x250.

    How to insert:

    Look at the orange text. Similar to the first routine, you will need to change the amount subtracted to match your variable (remember you're subtracting two hex numbers). Once you've fixed it, you can go ahead and compile the routine into free space (write down the place you compiled it to).

    Spoiler:


    Now navigate to 0x259EC and insert the following byte changes:
    Code:
     00 49 08 47 XX XX XX 08
    Where XX XX XX is the reverse hex pointer to where you inserted this routine +1.

    Usage:

    Flag 0x250 must be set for the routine to be toggled on, else money will be put in the player's bag as normal.

    Hello. Glad I'd implemented it on my hack there are two problems and one question though.
    My problem is upon defeating a trainer, the money that is supposed to be decreased by 10% is decreased by 100%. Upon setting flag 250, the every money that I get from a training is sent directly to the Var I had specified on the routine, and the playtime in trainer card stops at 00:59.

    And one question, how to deposit the saved money?
     

    Blah

    Free supporter
    1,924
    Posts
    11
    Years
  • Hello. Glad I'd implemented it on my hack there are two problems and one question though.
    My problem is upon defeating a trainer, the money that is supposed to be decreased by 10% is decreased by 100%. Upon setting flag 250, the every money that I get from a training is sent directly to the Var I had specified on the routine, and the playtime in trainer card stops at 00:59.

    And one question, how to deposit the saved money?

    Hello. As I'm aware, reading through the second routine, it basically stores all the money that would go to the player into the bank var instead, if a flag is set. To change the functionality there, you will have to edit the routine a little bit.

    The first routine seems to just increment a variable based on the play time. It requires some other playtime fetching routine be installed already, make sure you've got all of that set up. If you have further problems feel free to ask in the ASM help thread.
     

    Lance32497

    LanceKoijer of Pokemon_Addicts
    792
    Posts
    9
    Years
  • Hello. As I'm aware, reading through the second routine, it basically stores all the money that would go to the player into the bank var instead, if a flag is set. To change the functionality there, you will have to edit the routine a little bit.

    The first routine seems to just increment a variable based on the play time. It requires some other playtime fetching routine be installed already, make sure you've got all of that set up. If you have further problems feel free to ask in the ASM help thread.

    the only problem left to me is the time stops upong setting flag and I don't know how to deposit the saved money. Anyway thanks for the reply.
     

    Blah

    Free supporter
    1,924
    Posts
    11
    Years
  • the only problem left to me is the time stops upong setting flag and I don't know how to deposit the saved money. Anyway thanks for the reply.

    The money is in the bank variable. You deposit money by adding to that variable, and withdraw with a givemoney script and subtracting from the variable.

    I cannot know the cause of your time being frozen, but it seems like an insertion error, because from a glance I cannot see any errors here. Remember to end your table with 0xFFs, stupid I know, but this is kind of from a stupid time. :)
     

    Froosty

    The_Learner
    535
    Posts
    9
    Years
  • All the codes are now on github and the auto-insertion is completed via armips.
    https://github.com/jiangzhengwenjz/Double_wild_battle

    Old post:
    Spoiler:

    I read your codes on guthub
    And it says about 64 bit pc but what if one has 32 bit computer??
     

    jiangzhengwenjzw

    now working on katam
    181
    Posts
    11
    Years
    • Seen today
    By basic asm do you mean compiling the asm codes and then writing the codes from .bin file to game pr writing asm codes???

    The hooks and byte changes are in "insert.s", and the global symbols used are the pointer to the routines. The routines should be compiled at free space absolutely. Another issue is the battle script cmd header file, and you should change the path according to the location of the compiler.
    Otherwise you can create a python script by using FBI's or others' template, I guess it can work, lol.
     

    Lance32497

    LanceKoijer of Pokemon_Addicts
    792
    Posts
    9
    Years
  • Dunno if this will help you, but

    Multiple Characters

    Despite gender being binary in the games, there is actually an entire byte set aside for it in the second saveblock. You can change this byte with a simple ASM routine, e.g.

    Spoiler:

    Set it to zero for male and one for female. Use another byte for another for another character

    Note, this will break the script checkgender command! In order to restore it, you should first call checkgender, copy the value it returns in 0x800D to another unused var. Then set the gender using the above. Then you can restore it properly.

    Lastly, apply this hook (untested):

    Spoiler:
    You'll need to customise that table at the bottom. Each character you want must have its own 6 byte entry, even if you don't plan on using all the frames. The example entry above is a duplicate male character. Just change the bytes to the overworld sprites of your new character (the same in advance map when chooses a sprite for an NPC). Keep in mind you'll need running frames for the target character.

    This probably will only refresh when you change map, so use the next hack.

    Instant NPC sprite switch

    This is related to the last hack, but can be more useful for a less permanent change. It can also work on other NPCs. Callasm as usual with the NPC person number in 0x8000 (same ID you use with applymovement - and 0xFF for the player) and the target sprite (the sprite index you'd use in advance map) in 0x8001.

    Code untested.

    Spoiler:
    It would be cool if someone could test these and write example scripts. I am too lazy.

    Hello Touched, I have teste the codes already. The hook is not working properly, instead of walking sprites, it shows Surfing sprites.
    And the NPC Change, overworlds other than the player are not changing when the ASM is called. There's amn issue also in changing the sprite of player, the color is not loaded properly.
     
    457
    Posts
    10
    Years
    • Seen Apr 9, 2024

    Pre-battle Mugshot Hack in BPEE

    I don't hack Emerald but my friend jirachiwishmaker requested the code, so I will share it.
    This is a port of Jambo51's codes in this thread to Emerald Version
    If you still don't know what it is, please take a look at this picture:
    7-8_zpsiwx42jwk.png

    1. Make these byte changes:
    Code:
    0x147C6A - 00 00 00 00 (disable the palette mixing)
    0xB13FD - 78 (for safety's sake)
    0x5C8F90 - CD 6A 0F 73 51 7B 93 7F D5 7F FF 7F (filling the palette...)
    0x5C8F70 - CD 6A 0F 73 51 7B 93 7F D5 7F FF 7F
    0x5C8F50 - CD 6A 0F 73 51 7B 93 7F D5 7F FF 7F

    2. Insert these 3 ASM codes in free space and change bytes accordingly:
    insert 00 48 00 47 AA AA AA 08 at 0xB0F44, in which AA AA AA 08 is the pointer to the following routine (thumb mode +1)
    Code:
    .thumb
    .align 2
    ldrb r2, [r4, #7]
    cmp r2, #0
    beq normal
    ldr r0, =0x80B0F5D
    bx r0
    
    normal:
    ldrh r2, [r4]
    lsl r0, r2, #2
    add r0, r0, r2
    lsl r0, r0, #3
    add r0, r0, r1
    ldr r1, =0x80B0F4F
    bx r1

    insert 00 48 00 47 BB BB BB 08 at 0xB5E78, BB BB BB 08 = pointer to the following code (thumb mode +1)
    Code:
    .thumb
    .align 2
    cmp r4, #0x47
    beq normal
    cmp r4, #0x48
    beq normal
    ldr r0, =0x2038BCA
    ldrh r0, [r0]
    lsl r5, r0, #2
    add r5, r0, r5
    lsl r0, r5, #3
    ldr r5, =0x806E4C4
    ldr r5, [r5]
    add r0, r0, r5
    ldrb r4, [r0, #3]
    
    normal: 
    add r5, r1, #0
    add r6, r2, #0
    mov r9, r3
    ldr r7, [sp, #0x34]
    ldr r0, =0x80B5E81
    bx r0

    insert 01 49 08 47 00 00 CC CC CC 08 at 0x147C42, CC CC CC 08 = pointer to the following code (thumb mode +1)
    change 0x8FFFFFF to the palette table in your ROM and it can have 255 custom palettes.
    The table's structure is [pointer1][pointer2]........................
    Every pointer will point to a 16-color uncompressed palette (32 bytes)
    Code:
    .thumb
    main:
     ldr r1, ramoffset
     ldrh r1, [r1, #0x0]
     lsl r0, r1, #0x2
     add r0, r0, r1
     lsl r1, r0, #0x3
     ldr r0, trainertable
     ldr r0, [r0, #0x0]
     add r1, r0, r1
     ldrb r1, [r1, #0x1]
     cmp r1, #0x1f
     beq oldway
     cmp r1, #0x26
     beq oldway
     ldr r1, ramoffset
     ldrb r1, [r1, #0x7]
     sub r1, #0x1
     lsl r1, r1, #0x2
     ldr r0, table2
     add r1, r1, r0
     ldr r0, [r1, #0x0]
     b back
    oldway: ldr r1, table
     mov r2, r8
     mov r3, #0x26
     ldrh r0, [r2, r3]
     lsl r0, r0, #0x2
     add r0, r0, r1
     ldr r0, [r0, #0x0]
    back: ldr r1, return
     bx r1
    
    .align 2
    ramoffset: .word 0x02038BCA
    trainertable: .word 0x0806E4C4
    table:  .word 0x085C8FDC
    table2:  .word 0x08FFFFFF
    return:  .word 0x08147C51

    To activate it in a script, you can use this format:
    Code:
    trainerbattle 0(type, you can change it to fit your script) 0x50(your chosen trainer's ID) [b]0x0100[/b] @pointertomsg1 @pointertomsg2
    0x0100 means the first palette in your custom table at 0x8FFFFFF, and 0x0200 means the second, ...... 0xff00 means the 255th palette.

    Some sample palettes in the original game: (If you don't change the tiles and tileset, please build your palette in this format using APE)
    Code:
    D5 18 CE 39 52 4A D6 5A 5A 6B 17 5C 59 64 9B 6C DD 74 1F 7D CD 6A 0F 73 51 7B 93 7F D5 7F FF 7F
    Code:
    D5 18 CE 39 52 4A D6 5A 5A 6B 41 07 A4 13 C6 1B E9 27 EF 3F FC 45 3E 4E 7F 56 BF 5E FF 66 FC 45
    Give credit to Jambo51 (for the routines for BPRE) and jirachiwishmaker (for finding some offsets) if you use this hack. I only adjusted the routines so that it will be compatible with Emerald's RAM structure and fixed a small glitch in Jambo51's code1. So no credit needed for me, if you don't want to make your credit list long.

    It doesn't change Elite Four and Champion classes. What I mean is... if I set 0x100, 0x200, or any value, it doesn't go to the specific value but it goes to 0x100 instead.
     
    Back
    Top