Research & Development Got a well-founded knack with ROM hacking? Love reverse-engineering the Pokémon games? Or perhaps you love your assembly language. This is the spot for polling and gathering your ideas, and then implementing them! Share your hypothesis, get ideas from others, and collaborate to create!

TrollandToad.com
Reply
 
Thread Tools
  #1001    
Old April 15th, 2017 (6:16 PM).
kelario27's Avatar
kelario27 kelario27 is offline
  • Crystal Tier
 
Join Date: Jun 2011
Location: Alaska
Age: 17
Gender: Male
Nature: Serious
Posts: 156
Okay, so I'm still a noob at this, but I think I understand better now how memory works. So for some things, I've decided to brute force my way through the hack with a hex editor.

Just to play around and reverse engineer things a bit, I tried the old fashioned method of opening up scripts with PKSV, then opening the ROM in the hex editor and going to the offsets it mentioned. Except...PKSV uses seven digits for "offsets", when there are only six digits for offsets in the ROM.

I don't really know what in particular to ask about this. Is there some way to translate between the two numbers? Does PKSV lie?

So just as I typed that entire paragraph, I realized that PKSV starts everything with 0x8 and then the offset number.

Posting this anyway in case anyone else was wondering.
__________________
Reply With Quote

Relevant Advertising!

  #1002    
Old April 16th, 2017 (5:14 AM).
mbcn10ww's Avatar
mbcn10ww mbcn10ww is offline
     
    Join Date: Oct 2016
    Location: Brazil
    Gender: Male
    Nature: Lonely
    Posts: 366
    Quote:
    Originally Posted by kelario27 View Post
    Okay, so I'm still a noob at this, but I think I understand better now how memory works. So for some things, I've decided to brute force my way through the hack with a hex editor.

    Just to play around and reverse engineer things a bit, I tried the old fashioned method of opening up scripts with PKSV, then opening the ROM in the hex editor and going to the offsets it mentioned. Except...PKSV uses seven digits for "offsets", when there are only six digits for offsets in the ROM.

    I don't really know what in particular to ask about this. Is there some way to translate between the two numbers? Does PKSV lie?

    So just as I typed that entire paragraph, I realized that PKSV starts everything with 0x8 and then the offset number.

    Posting this anyway in case anyone else was wondering.
    First, it's the wrong place to ask for help.
    Second, the 0x8 (0x9 too, for expanded Roms) is only to tell the system "It's a ROM offset!", if it begins with 0x2 it's a RAM offset.
    __________________
    My Works:
    [Fire Red] Adding New Trainer Sprites
    [Fire Red] My Version of HMs Type Check
    [Fire Red] Touched's Mega Evolution System (PATCH)
    Reply With Quote
      #1003    
    Old April 17th, 2017 (11:14 PM).
    Shiny Quagsire's Avatar
    Shiny Quagsire Shiny Quagsire is offline
    I'm Still Alive, Elsewhere
       
      Join Date: May 2009
      Location: Hoenn Safari Zone
      Age: 19
      Gender: Male
      Nature: Jolly
      Posts: 700
      Quote:
      Originally Posted by kelario27 View Post
      Okay, so I'm still a noob at this, but I think I understand better now how memory works. So for some things, I've decided to brute force my way through the hack with a hex editor.

      Just to play around and reverse engineer things a bit, I tried the old fashioned method of opening up scripts with PKSV, then opening the ROM in the hex editor and going to the offsets it mentioned. Except...PKSV uses seven digits for "offsets", when there are only six digits for offsets in the ROM.

      I don't really know what in particular to ask about this. Is there some way to translate between the two numbers? Does PKSV lie?

      So just as I typed that entire paragraph, I realized that PKSV starts everything with 0x8 and then the offset number.

      Posting this anyway in case anyone else was wondering.
      This is a GBA memory mapping thing, http://problemkaputt.de/gbatek.htm#gbamemorymap
      __________________



      Reply With Quote
        #1004    
      Old April 20th, 2017 (6:50 PM). Edited April 24th, 2017 by mbcn10ww.
      mbcn10ww's Avatar
      mbcn10ww mbcn10ww is offline
         
        Join Date: Oct 2016
        Location: Brazil
        Gender: Male
        Nature: Lonely
        Posts: 366


        Change the pointer at 0x13009C to D1 08 13 08

        After choosing the player gender the gameplay will start without naming the player and the rival, then you will be able to use static names in-game.

        Note: If you don't have used some ASM to set the player/rival names the game will freeze.
        __________________
        My Works:
        [Fire Red] Adding New Trainer Sprites
        [Fire Red] My Version of HMs Type Check
        [Fire Red] Touched's Mega Evolution System (PATCH)
        Reply With Quote
          #1005    
        Old April 24th, 2017 (8:05 AM).
        AtecainCorp.'s Avatar
        AtecainCorp. AtecainCorp. is offline
        Rejishan awake...
           
          Join Date: Jun 2008
          Location: Takoabe Town (Region Thonsu)
          Age: 24
          Gender: Male
          Nature: Hardy
          Posts: 1,250
          Quote:
          Originally Posted by lsmash View Post
          Would you mind telling me how you fixed the music that plays after you captured a pokemon?
          I made the same feature (though differently: I didn't need to replace the bytes at x15A68), which is almost flawless, if not for the music: it plays the captured pokemon jingle, then the receive exp jingle.
          You can check it here: http://pokemonhackersonline.com/showthread.php?t=14839-FR-Pokemons-receive-EXP-after-capturing
          Is any chance for repoin this for Ruby? I have troubles with my own researches.
          __________________
          - My new Project comming Soon
          Reply With Quote
            #1006    
          Old April 25th, 2017 (1:07 AM).
          Squeetz's Avatar
          Squeetz Squeetz is offline
          Music hacker
          • Gold Tier
           
          Join Date: Jun 2013
          Location: Norway
          Age: 20
          Gender: Male
          Nature: Quiet
          Posts: 230
          It's often been asked how the Hidden Items work, and what flags they use.
          I was curious myself, so I did some digging. (FR)

          The routine responsible for handling the flag check/set and item give is at 0x6D17A.
          The subroutine that converts the Hidden ID to the flag to check/set here is located at 0xCC45E.
          It adds 0x3E8 to the Hidden ID, which is then the flag to be checked/set.
          This means that hidden ID 0x0 equates to flag 0x3E8, 0x1 equates to 0x3E9, and so on, until you reach ID 0xFF, which is flag 0x4E7.
          __________________
          Reply With Quote
            #1007    
          Old April 28th, 2017 (11:18 AM).
          DarkPsychic's Avatar
          DarkPsychic DarkPsychic is offline
             
            Join Date: Jul 2012
            Location: CO
            Gender: Male
            Nature: Timid
            Posts: 133
            Hello all,
            I made a way to have random wild battles which also randomize not only the Pokemon but the level as well.
            I got the idea and the know how from a thread called " PokeMart as debug input ".

            Anyway here is the XSE script.
            Code:
            Code:
            //wildbattle2hex
            00 B6 | ?? ??  | ?? 00   | ?? ?? |  B7 03 | 
             cmd  | pkid   | lvl      |  item  |             
             4100 | 4101 | 4102    | 4103  |  4104  |
            Hand to put B7 03 place of(25 39 01 27) wich means dowildbattle followed by '03' return.
            Also to get the address of vars 0x4000+ you need to take the pointer stored at 0x3005008 and add 0x1000 to it.
            To get var 0x4100 you would add 0x1200 to the pointer at 0x3005008.
            //
            
            #dynamic 0xD00000
            
            #org @start
            random 0x64
            compare 0x800D 0x8
            if 0x2 goto @snippet1
            random 0x64
            copyvar 0x4000 0x800D
            setvar 0x4100 0xB600
            copyvar 0x4101 0x4000
            random 0xFF
            copyvar 0x4102 0x800D
            setvar 0x4103 0x0000
            setvar 0x4104 0x03B7
            setvar 0x5006 0x1
            setvar 0x800D 0x0
            call @snippet2
            setvar 0x5006 0x0
            release
            end
            
            #org @snippet1
            release
            end
            
            #org @snippet2
            writebytetooffset 0x4 0x20370D0
            copybyte 0x20370D1 0x3005008
            copybyte 0x20370D2 0x3005009
            copybyte 0x20370D3 0x300500A
            copybyte 0x20370D8 0x20370D2
            copybyte 0x20370D9 0x20370D3
            addvar 0x8011 0x12
            copybyte 0x20370D2 0x20370D8
            copybyte 0x20370D3 0x20370D9
            copybyte 0x20370D4 0x300500B
            writebytetooffset 0x3 0x20370D5
            writebytetooffset 0xFF 0x20370D6
            writebytetooffset 0x0 0x20370D7
            call 0x20370D0
            return
            At the moment it still uses the default vars from the debug input thread.
            But I will make a different version that uses the safe vars hack.
            Just in case.

            To use this,
            Simply compile and place on green script tile then set the tiles var to 0x5006 and the value to 0.
            The default script is made so you have an 8% chance of a wildbattle to happen.

            What this does:
            It takes a script command and writes it in hex into vars 0x4100 - 0x4104.
            Then it changes the certain values to the random number (PokemonID and Level),
            after that it sets up vars 0x800D - 0x8012 and then calls the 0x800D to execute the code at 0x4100-0x4105.
            Then returns.

            Hope it can help someone out there.
            Reply With Quote
              #1008    
            Old May 4th, 2017 (4:06 AM).
            kleenexfeu kleenexfeu is offline
               
              Join Date: Aug 2013
              Gender: Male
              Posts: 219
              Quote:
              Originally Posted by Artemis64 View Post
              To do the same in Emerald, place 0xFC at 0x6DC48 and 0x6DC4E.
              To elaborate for the people who don't understand what this is about, it is setting the limiters for the maximum number of EVs a Pokémon can have per stat. Because only four EVs translate into a single stat point, having 255 EVs per stat is pointless, as the last three EVs do not make any difference.
              In addition to that, you can also change the total of EV each pokémon can get:
              Spoiler:
              Code:
              .equ New_Limit_Ev_Cap, Max_ev_per_stat @ can't go beyond 255*6 obviously
              .equ EV_by_stats_cap, Max_ev_per_poke @ can't go beyond 255 without rewriting a ton of routine, it's the original value
              
              @@ moving the EV cap per poke
              .org 0x6DC2A, 0xFF
              ldr r0, New_Limit_Ev_Cap
              add r0, #1
              
              @@ EV by stats cap
              .org 0x6DC48, 0xFF
              cmp r0, #EV_by_stats_cap
              ble 0x6DC58
              mov r0, r1
              add r0, #EV_by_stats_cap
              
              @@ moving the EV cap per poke
              .org 0x6DC88, 0xFF
              New_Limit_Ev_Cap:
              .word Max_EV_per_poke-1
              __________________
              Links for my work:
              Dynamic Emerald Attack ROMbase
              Arceus and Giratina Forms

              Touched's Emerald IDB + Battle stuff (probably outdated)
              Touched's Emerald IDB 6.8 + Battle stuff (probably outdated)
              Reply With Quote
                #1009    
              Old May 10th, 2017 (6:56 AM).
              Mariow2's Avatar
              Mariow2 Mariow2 is offline
                 
                Join Date: Feb 2017
                Location: Wales, UK
                Gender: Male
                Nature: Calm
                Posts: 82
                Quote:
                Originally Posted by Aryan 10 View Post
                Expanded Pokemon In Advance Map


                Take the total number of pokemon.

                Change it to hex and reverse it.



                For Advance Map 1.92
                Go to D027C

                For Advance Map 1.95
                Go to 77DD5

                and change
                Code:
                9C 01
                to your reverse hex number of Pokemon.

                And it's done.
                So how do you hack advance map?
                __________________
                A Pokemon that is discriminated!
                Support squirtle and make it everyone's favourite. Maybe it could be added to the Pokémon Orphanage.

                Name: Lilley
                Adopt one yourself! @Pokémon Orphanage
                Reply With Quote
                  #1010    
                Old May 10th, 2017 (7:03 PM).
                BluRose BluRose is offline
                blu rass
                   
                  Join Date: Apr 2014
                  Location: hyakkoku city
                  Age: 16
                  Gender: Male
                  Nature: Timid
                  Posts: 702
                  Quote:
                  Originally Posted by Mariow2 View Post
                  So how do you hack advance map?
                  you open it in a hex editor
                  __________________
                  am i cool yet
                  Reply With Quote
                    #1011    
                  Old May 11th, 2017 (6:59 AM).
                  Squeetz's Avatar
                  Squeetz Squeetz is offline
                  Music hacker
                  • Gold Tier
                   
                  Join Date: Jun 2013
                  Location: Norway
                  Age: 20
                  Gender: Male
                  Nature: Quiet
                  Posts: 230
                  In Firered at 0x15FD0C there's a table of pointers for the vars 0x8000-0x8014.
                  You can easily repoint this and add your own entries. I added 12 new ones (0x8015-0x8020) and using them all in a script worked perfectly.
                  So instead of writing to your static addresses with 'writebytetooffset', you could just set a var.
                  __________________
                  Reply With Quote
                    #1012    
                  Old May 15th, 2017 (3:08 PM).
                  Wesley FG's Avatar
                  Wesley FG Wesley FG is offline
                  Pokémon Kalos Advance !! Gba Hack
                     
                    Join Date: Oct 2008
                    Location: Brazil
                    Gender: Male
                    Nature: Modest
                    Posts: 338
                    This is one Information About Catch areas in Pokédex FR

                    Probably you have problem making you hack with it

                    Existe one table that control it
                    Table Located at 463580 have this format

                    [TT][XX][YY][00]

                    TT = Shape of the catch area (varies from 00 - 06) the img explain better

                    XX = X-coordinate of the area on the worldmap in the pokedex
                    YY = Y-coordinate of the area on the worldmap in the pokedex
                    00 = Padding

                    00463580 = FILLER
                    00463584 = PALLET TOWN
                    00463588 = VIRIDIAN CITY
                    0046358c = PEWTER CITY
                    00463590 = CERULEAN CITY
                    00463594 = LAVENDER TOWN
                    00463598 = VERMILION CITY
                    0046359c = CELADON CITY
                    004635a0 = FUCHSIA CITY
                    004635a4 = CINNABAR ISLAND
                    004635a8 = INDIGO PLATEAU
                    004635ac = SAFFRON CITY
                    004635bc = ROUTE 4
                    004635d4 = ROUTE 10
                    004635b0 = ROUTE 1
                    004635b4 = ROUTE 2
                    004635b8 = ROUTE 3
                    004635bc = ROUTE 4
                    004635c0 = ROUTE 5
                    004635c4 = ROUTE 6
                    004635c8 = ROUTE 7
                    004635cc = ROUTE 8
                    004635d0 = ROUTE 9
                    004635d4 = ROUTE 10
                    004635d8 = ROUTE 11
                    004635dc = ROUTE 12
                    004635e0 = ROUTE 13
                    004635e4 = ROUTE 14
                    004635e8 = ROUTE 15
                    004635ec = ROUTE 16
                    004635f0 = ROUTE 17
                    004635f4 = ROUTE 18
                    004635f8 = ROUTE 19
                    004635fc = ROUTE 20
                    00463600 = ROUTE 21
                    00463604 = ROUTE 22
                    00463608 = ROUTE 23
                    0046360c = ROUTE 24
                    00463610 = ROUTE 25
                    00463614 = VIRIDIAN FOREST
                    0046361c = MT. MOON
                    00463598 = S.S. ANNE (SAME OFFSET OF VERMILLION)
                    004635ac = UNDERGROUND PATH (SAME OFFSET OF SAFRON)
                    004635ac = UNDERGROUND PATH ( SAME OFFSET OF SAFRON)
                    00463618 = DIGLETT'S CAVE
                    0046363c = VICTORY ROAD
                    0046359c = ROCKET HIDEOUT (SAME OFFSET OF CELADON)
                    004635ac = SILPH CO. (SAME OFFSET OF SAFRON)
                    00463638 = POKéMON MANSION
                    00463630 = SAFARI ZONE
                    0046363c = POKéMON LEAGUE (SAME OFFSET VICTORY ROAD)
                    00463624 = ROCK TUNNEL
                    00463634 = SEAFOAM ISLANDS
                    0046362c = POKéMON TOWER
                    00463620 = CERULEAN CAVE
                    00463628 = POWER PLANT

                    Need search for the rest of Island Maps
                    Credit : sfc.pokefans.net/lesson.php?id=20
                    for the base of my search
                    __________________
                    Kalos Demake Soon!!
                    Reply With Quote
                      #1013    
                    Old June 8th, 2017 (5:53 AM).
                    Panda Face Panda Face is offline
                       
                      Join Date: Jan 2017
                      Gender: Female
                      Posts: 101
                      How to change the Latias and Latios event after chose red and blue?
                      __________________

                      Pokemon The Strongest Pure White v4.0
                      Community Link: https://www.pokecommunity.com/showthread.php?p=9569056#post9569056
                      Download Link: https://pan.baidu.com/s/1skXIUkP
                      Download Password: 3txt
                      Introduction:
                      There is a very high mountain, it exists too many unknown animals and plants. That mountain always happen the different natural damage such as T-storm, Tornado, Typhoon, Tsunami, Eruption, Blizzard, Earthquake, Forest fire blast and etc. None of people can be brave to climb this mountain. Nowdays, a boy wants to try it, he says he can completely to climb it by himself, he wants to show each region's girl, he is a most brave boy, he expects these girls like him, because these girls skin is bright snow white, he is very very like these girls, so he wants to be a friend with these girls at least. Then the story will begin at here...
                      Reply With Quote
                        #1014    
                      Old June 9th, 2017 (3:10 AM).
                      BobbyTom BobbyTom is offline
                         
                        Join Date: Sep 2015
                        Gender: Male
                        Posts: 4
                        Changing the experience gain formula (Emerald)

                        ** The purpose of this research isn't to learn the EXP calculation formula. We already know that. The purpose is to give offsets we can use to easily change the formula.

                        The exact point where the game yanks a Pokemon's experience yield is here:
                        Code:
                        0804A4A4 LDRB            R2, [R0,#pokemon_base.exp_yield]
                        At which point one of the following calculations occur:
                        Code:
                        if ( v0 )
                                {
                                  v8 = (unsigned int)(battle_participants[unk_202420D].level
                                                    * pokemon_basestats[battle_participants[unk_202420D].species].exp_yield
                                                    / 7 << 16) >> 17;
                                  v9 = v8 / v4;
                                  *v1 = v9;
                                  if ( !(v9 << 16) )
                                    *v1 = 1;
                                  word_20243CC[27] = v8 / v0;
                                  if ( !(v8 / v0 << 16) )
                                    word_20243CC[27] = 1;
                                }
                        else
                                {
                                  v10 = (battle_participants[unk_202420D].level
                                       * pokemon_basestats[battle_participants[unk_202420D].species].exp_yield
                                       / 7 & 0xFFFF)
                                      / v4;
                                  *v1 = v10;
                                  if ( !(v10 << 16) )
                                    *v1 = 1;
                                  word_20243CC[27] = 0;
                                }
                        Basically:
                        Code:
                        (exp_yield * level / 7) & 0xFFFF
                        Is always calculated, and then split according to how many Pokemon participated in the battle. This is that calculation in full:
                        Code:
                        ROM:0804A4A4 42 7A                                   LDRB            R2, [R0,#pokemon_base.exp_yield]
                        ROM:0804A4A6 2A 31                                   ADDS            R1, #0x2A @ '*'
                        ROM:0804A4A8 08 78                                   LDRB            R0, [R1]
                        ROM:0804A4AA 50 43                                   MULS            R0, R2
                        ROM:0804A4AC 07 21                                   MOVS            R1, #7
                        ROM:0804A4AE 9D F2 47 F8                             BL              __divsi3
                        ROM:0804A4B2 00 04                                   LSLS            R0, R0, #0x10
                        ROM:0804A4B4 01 0C                                   LSRS            R1, R0, #0x10
                        You can modify these opcodes however you like.
                        Before these opcodes:
                        • R0 is pokemon_base, the struct with all the information about the species of Pokemon we just KO'd.
                        • R1 contains knowledge about the specific Pokemon we battled, such as its level (offset 0x2A).
                        After these opcodes:
                        • R1 must contain the total EXP to split between the battling Pokemon.
                        Me, I just wanted to cancel EXP growth. So instead of the first opcode I zeroed out R2, and the result is that you always gain 1 EXP. Because of those checks in the psuedo-code - if the game detects that you're about to gain 0 EXP it changes it to 1 EXP. You can change that code as well if you want, it's right here:
                        Code:
                        ROM:0804A4C8 00 04                                   LSLS            R0, R0, #0x10
                        ROM:0804A4CA 00 28                                   CMP             R0, #0
                        ROM:0804A4CC 01 D1                                   BNE             loc_804A4D2
                        ROM:0804A4CE 01 20                                   MOVS            R0, #1
                        ROM:0804A4D0 08 80                                   STRH            R0, [R1]
                        ....and here:
                        Code:
                        ROM:0804A4DE 00 04                                   LSLS            R0, R0, #0x10
                        ROM:0804A4E0 00 28                                   CMP             R0, #0
                        ROM:0804A4E2 18 D1                                   BNE             loc_804A516
                        ROM:0804A4E4 01 20                                   MOVS            R0, #1
                        ROM:0804A4E6 28 80                                   STRH            R0, [R5]
                        ROM:0804A4E8 15 E0                                   B               loc_804A516
                        Reply With Quote
                          #1015    
                        Old June 9th, 2017 (7:53 AM).
                        DizzyEgg's Avatar
                        DizzyEgg DizzyEgg is offline
                           
                          Join Date: Feb 2014
                          Location: Poland
                          Age: 20
                          Gender: Male
                          Nature: Quiet
                          Posts: 714
                          Quote:
                          Originally Posted by BobbyTom View Post
                          snip
                          Pretty nice, but it's already known. See https://github.com/KDSKardabox/Pokemon-Emerald-Battle-Engine-Upgrade/blob/master/src/bscommands_updated.c#L3229
                          Reply With Quote
                            #1016    
                          Old June 9th, 2017 (9:24 AM).
                          BobbyTom BobbyTom is offline
                             
                            Join Date: Sep 2015
                            Gender: Male
                            Posts: 4
                            Quote:
                            Originally Posted by DizzyEgg View Post
                            Is that someone's attempt to recreate the source code? That's pretty rad. I guess the upshot in my post is that you can make changes directly to the engine. Even if you used a compiler you'd still need to know the offsets in the ROM.
                            Reply With Quote
                              #1017    
                            Old June 9th, 2017 (10:06 AM).
                            DizzyEgg's Avatar
                            DizzyEgg DizzyEgg is offline
                               
                              Join Date: Feb 2014
                              Location: Poland
                              Age: 20
                              Gender: Male
                              Nature: Quiet
                              Posts: 714
                              Quote:
                              Originally Posted by BobbyTom View Post
                              Is that someone's attempt to recreate the source code? That's pretty rad. I guess the upshot in my post is that you can make changes directly to the engine. Even if you used a compiler you'd still need to know the offsets in the ROM.
                              Nah, recreating the source code is another thing.
                              I linked you to the github of my and one other guy project. We basically rewrote a huge part of the original battle engine in C and added stuff in later generations. For more info, see my signature.
                              __________________
                              Support Pokeruby!

                              My works:
                              Battle Engine Upgrade
                              Pokemon Expansion
                              Items/TMs/Tutors Expansion
                              Various Features(Evo Methods, BW Repel, Levels Above 100, Trainers with EV, Nature Colored Stats)

                              Emerald Features:
                              Form Changes (KDS)
                              Reply With Quote
                                #1018    
                              Old June 9th, 2017 (1:14 PM).
                              BobbyTom BobbyTom is offline
                                 
                                Join Date: Sep 2015
                                Gender: Male
                                Posts: 4
                                Changing global wild encounter levels (Emerald)

                                ** Again, something I did for my own uses. Instead of changing the wild encounter tables for each route, you can make sweeping changes to all wild encounters by changing the code that uses those tables.

                                This is what the flow for generating wild encounters looks like (call order):
                                ROM:080B5288 walking_func
                                ROM:080B4F4C choose_wild_pokemon_encounter
                                ROM:080B4C74 choose_encounter_level

                                The first function performs some check for every step (or turn) the player takes. If the player's tile is encounter-eligible it enters the second function, which eventually calls the third function, "choose_encounter_level" which does just that. Let's look at some pseudo-code:

                                Code:
                                int __fastcall choose_encounter_level(int encounter_table)
                                {
                                  int encounter_table_loc; // [email protected]
                                  unsigned int v2; // [email protected]
                                  int level_min; // [email protected]
                                  unsigned int level_max; // [email protected]
                                  int rand; // [email protected]
                                  int v6; // [email protected]
                                  int v7; // [email protected]
                                
                                  encounter_table_loc = encounter_table;
                                  v2 = *(_BYTE *)(encounter_table + 1);
                                  if ( v2 < *(_BYTE *)encounter_table_loc )
                                  {
                                    level_min = *(_BYTE *)(encounter_table_loc + 1);
                                    level_max = *(_BYTE *)encounter_table_loc;
                                  }
                                  else
                                  {
                                    level_min = *(_BYTE *)encounter_table_loc;
                                    level_max = v2;
                                  }
                                  rand = (unsigned __int16)rng() % (signed int)((level_max - level_min + 1) & 0xFF) & 0xFF;
                                  if ( !pokemon_getattr(0x20244EC, 6, v6) )
                                  {
                                    v7 = (unsigned __int8)sub_806B6D8(0x20244EC);
                                    if ( v7 == 55 || v7 == 72 || v7 == 46 )
                                    {
                                      if ( !(rng() & 1) )
                                        return level_max;
                                      if ( rand )
                                        rand = (rand - 1) & 0xFF;
                                    }
                                  }
                                  return (level_min + rand) & 0xFF;
                                }
                                Only some of the stuff here I found important, mostly the computation for "rand". It's worth clarifying that "level_min" etc. are encounter-specific, and come straight out of the encounter tables. Here are the relevant opcodes:

                                Computing "rand"
                                Code:
                                ROM:080B4C8A F4 1B                                   SUBS            R4, R6, R7
                                ROM:080B4C8C 01 34                                   ADDS            R4, #1
                                ROM:080B4C8E 24 06                                   LSLS            R4, R4, #0x18
                                ROM:080B4C90 24 0E                                   LSRS            R4, R4, #0x18
                                ROM:080B4C92 BA F7 9B FC                             BL              rng
                                ROM:080B4C96 00 04                                   LSLS            R0, R0, #0x10
                                ROM:080B4C98 00 0C                                   LSRS            R0, R0, #0x10
                                ROM:080B4C9A 21 1C                                   MOVS            R1, R4
                                ROM:080B4C9C 32 F2 D8 FC                             BL              __modsi3
                                ROM:080B4CA0 00 06                                   LSLS            R0, R0, #0x18
                                ROM:080B4CA2 04 0E                                   LSRS            R4, R0, #0x18
                                On entering:
                                • R6 is level_min
                                • R7 is level_max
                                On leaving:
                                • R4 is "rand"

                                Returning "rand" as the encounter level
                                Code:
                                ROM:080B4CEA 38 19                                   ADDS            R0, R7, R4
                                ROM:080B4CEC 00 06                                   LSLS            R0, R0, #0x18
                                ROM:080B4CEE 00 0E                                   LSRS            R0, R0, #0x18
                                • R4 and R7 keep their values from the "rand" computation - "rand" and "level_min" respectively.
                                Use cases

                                So, what now? Well, say you wanted to make encounters a bit scarier - it's as easy as adding to R4 or R7. In my own experiments I replaced the useless left-shift/right-shift opcodes near the "rand" computation with something more useful:

                                Code:
                                ROM:080B4C8A                 SUBS            R4, R6, R7
                                ROM:080B4C8C                 ADDS            R4, #1
                                ROM:080B4C8E                 LDR             R5, =0x3005D8C
                                ROM:080B4C90                 LDR             R5, [R5,#4]
                                ROM:080B4C92                 BL              rng
                                ROM:080B4C96                 LDRB            R5, [R5,#0x14]
                                ROM:080B4C98                 NOP
                                ROM:080B4C9A                 MOVS            R1, R4
                                ROM:080B4C9C                 BL              __modsi3
                                ROM:080B4CA0                 LSRS            R5, R5, #3
                                ROM:080B4CA2                 ADDS            R4, R0, R5
                                Since R5 was unused, I borrowed it to add to "rand" the message frame value! You know, the value in the options that decides what pretty frame your menus have (I prefer the pink one with the bows!). Based on this research:
                                showthread.php?p=8615361#post8615361

                                The value's behind pointer 0x3005D90, offset 0x14. The reason I counted from 0x3005D8c is convenience - it's used a bit later at 080B4D50:
                                Code:
                                ROM:080B4D50 dword_80B4D50   DCD 0x3005D8C
                                Reply With Quote
                                  #1019    
                                Old June 13th, 2017 (5:32 PM).
                                frezgle frezgle is offline
                                   
                                  Join Date: Dec 2014
                                  Gender: Female
                                  Posts: 12
                                  Quote:
                                  Originally Posted by MWisBest View Post
                                  HM Flash Lightens Entire Screen [EM]

                                  I got a little irked trying to train in the Victory Road basement by the Flash HM not clearing the entire screen. I'm playing the game on my phone, which has an AMOLED display. AMOLED displays are very susceptible to burn-in, so to avoid getting a nice big dark circle in the middle of my screen...

                                  I modified the Flash brightness table to make it work like FR/LG and light up the entire screen:

                                  At 0x54FE66, change 48 to C8.

                                  This is kind of cheap because it makes navigating Granite Cave and Victory Road easier than intended, but whatever.
                                  Would just like to point out that doing this causes a softlock in the Dewford Gym if you defeat Brawly after defeating all of his trainers.
                                  Reply With Quote
                                    #1020    
                                  Old June 13th, 2017 (6:53 PM).
                                  NewDenverCity's Avatar
                                  NewDenverCity NewDenverCity is offline
                                     
                                    Join Date: Apr 2014
                                    Location: Antarctica
                                    Gender: Male
                                    Nature: Calm
                                    Posts: 329
                                    I just happened to stumble on this

                                    Writing C0 46 C0 46 to 0x03DF40 will allow the Weedle in the Old Man's tutorial to be female or genderless. Obviously this is only for FR but hey something similar should be out there for Emerald.

                                    Also at 0x07F88C, there is a
                                    Code:
                                    mov r1, #0xD
                                    which is where it loads Weedle's species, so you can change that to whatever you want with hooks or whatever.
                                    Reply With Quote
                                      #1021    
                                    Old June 14th, 2017 (8:07 AM).
                                    Criminon's Avatar
                                    Criminon Criminon is offline
                                    Pokemon: Aqua Blue
                                       
                                      Join Date: Aug 2012
                                      Gender: Male
                                      Posts: 243
                                      Quote:
                                      Originally Posted by Criminon View Post
                                      This stuff should help anyone wanting to check their party's hp.
                                      0x20242DA is the address stored in RAM for the 1st pokemon in your party's HP.
                                      0x20242DC is the max HP.
                                      0x20242D4 is the status ailment a pokemon is currently suffering. (00 being nothing)

                                      Using comparefarbytetobyte 0x20242DA 0xnumber you want to check
                                      you can easily check a pokemon's hp.

                                      using comparefarbytetobyte 0x20242DC 0xnumber you want to check
                                      you can easily see if a pokemon has enough hp for something.

                                      using writebytetooffset 0xstatus 0x20242D4
                                      you can easily edit the status effecting them.

                                      For the rest of your party, take these offsets and add 0x64 to them.
                                      It's crazy how much stuff I've written that I have completely forgot. Here's to remembering your own findings.
                                      __________________
                                      FC: 3582 - 9598 - 9978. Add me!
                                      Reply With Quote
                                        #1022    
                                      Old June 15th, 2017 (1:50 AM). Edited July 8th, 2017 by ghoulslash.
                                      ghoulslash's Avatar
                                      ghoulslash ghoulslash is offline
                                         
                                        Join Date: Mar 2016
                                        Gender: Male
                                        Posts: 63
                                        I did a little investigation into trainerbattle 0x9:

                                        Rather than nop-ing out of the Oak's text function, you can just change the reserved byte from 0x3 to 0x0 to prevent Oak's text from appearing during battle. So you could re-use trainerbattle 0x9 and still have a battle that uses the text. It would look like:
                                        Code:
                                        trainerbattle 0x9 0x(trianer_ID) 0x0 @win @lose      //Oak's text does NOT appear
                                        trainerbattle 0x9 0x(trainer_ID) 0x3 @win @lose     //Oak's text appears

                                        EDIT: setting the reserved byte to 0x0 instead of 0x3 removes the functionality allowing you to continue with a script even if you white out. I made an assembly routine to toggle the text on and off while keeping this functionality in this post, though.

                                        Additionally, trainerbattle 0x9 writes 0x0 or 0x1 to variable 0x800D (lastresult) depending on if you won or lost the battle, respectively. This allows you to branch to separate scripts depending on the result of your trainer battle
                                        Reply With Quote
                                          #1023    
                                        Old June 28th, 2017 (3:06 PM).
                                        Derlo's Avatar
                                        Derlo Derlo is offline
                                        Working on Essence of light...
                                           
                                          Join Date: Aug 2007
                                          Posts: 131
                                          Quote:
                                          Originally Posted by ghoulslash View Post
                                          I did a little investigation into trainerbattle 0x9:

                                          Rather than nop-ing out of the Oak's text function, you can just change the reserved byte from 0x3 to 0x0 to prevent Oak's text from appearing during battle. So you could re-use trainerbattle 0x9 and still have a battle that uses the text. It would look like:
                                          Code:
                                          trainerbattle 0x9 0x(trianer_ID) 0x0 @win @lose      //Oak's text does NOT appear
                                          trainerbattle 0x9 0x(trainer_ID) 0x3 @win @lose     //Oak's text appears
                                          Additionally, trainerbattle 0x9 writes 0x0 or 0x1 to variable 0x800D (lastresult) depending on if you won or lost the battle, respectively. This allows you to branch to separate scripts depending on the result of your trainer battle
                                          well, I tried this, but don't work!
                                          Doing what Knizz did, I get fix a bug in GBA emulator for android. when the OAK's battle start, the emu freezes.
                                          __________________



                                          Pokémon
                                          Essence of Light

                                          Comming Soon...
                                          Reply With Quote
                                            #1024    
                                          Old June 29th, 2017 (5:09 PM).
                                          ghoulslash's Avatar
                                          ghoulslash ghoulslash is offline
                                             
                                            Join Date: Mar 2016
                                            Gender: Male
                                            Posts: 63
                                            Quote:
                                            Originally Posted by Derlo View Post
                                            well, I tried this, but don't work!
                                            Doing what Knizz did, I get fix a bug in GBA emulator for android. when the OAK's battle start, the emu freezes.
                                            I've never tried using knizz's method, so perhaps it's an either-or situation. Try restoring the bytes that you nop-ed out of and see if that works.
                                            Reply With Quote
                                              #1025    
                                            Old June 29th, 2017 (6:56 PM).
                                            AkameTheBulbasaur's Avatar
                                            AkameTheBulbasaur AkameTheBulbasaur is offline
                                            Akame Marukawa of Iyotono
                                               
                                              Join Date: May 2013
                                              Location: A place :D
                                              Age: 20
                                              Gender: Male
                                              Nature: Gentle
                                              Posts: 326
                                              There was a conflict between JPAN's set trainer levels hack and Doesntknowhowtoplay's trainer EVs hack. I may have found a way to fix it so that one can have both in their hack at the same time.

                                              I posted it in Doesnt's original thread here, but I thought I'd link it here too so more people could see it, because it may be something useful for a lot of people's hacks if it works for everyone the way it worked for me.

                                              I haven't tested it on a clean ROM yet, but I think it should still work there too.
                                              __________________
                                              "The human sacrificed himself, to save the Pokemon. I pitted them against each other, but not until they set aside their differences did I see the true power they all share deep inside. I see now that the circumstances of one's birth are irrelevant; it is what you do with the gift of life that determines who you are." -Mewtwo
                                              Reply With Quote
                                              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 12:40 AM.