Pokémon 3rd Generation/Pokémon FireRed and LeafGreen/ROM map

From Data Crystal
Jump to navigation Jump to search

Chip tiny.png The following article is a ROM map for Pokémon 3rd Generation/Pokémon FireRed and LeafGreen.

General pointers

Offset Pointer Comment
08000128 082350AC Pointer to graphic table, which contains pointers to front pokemon images.
0800012C 0823654C Pointer to graphic table, which contains pointers to back pokemon images.
08000130 0823730C Pointer to palette table, which contains pointers to normal palettes for pokemon images.
08000134 082380CC Pointer to palette table, which contains pointers to shiny palettes for pokemon images.

Hex address to wild Pokemon

NOTE: This hacking I test in EUROPE (Spanish) version games.

Go to 3C438C address corresponding to Route 101 at the beginning of the game.

Then, in these address change the wild pokemon code, with the hex pokemon code that you like appear.

Hex address to Poke Market in first town

NOTE: This hacking I test in EUROPE (Spanish) version games.

Go to 16A30C address showing the codes first town.

Then you can change the code of first item that they sell you, to other code, for example a MasterBall (code 0100).

Copy array from a RAM address to another

  • arguments:
    • r0 = copy_destination
    • r1 = copy_source
    • r2 = number_of_bytes_to_copy
08008DD0 B570     push    r4-r6,r14                               ;
08008DD2 1C04     mov     r4,r0                                   ;r4 = copy_destination
08008DD4 1C0E     mov     r6,r1                                   ;r6 = copy_source
08008DD6 0612     lsl     r2,r2,18h                               ;
08008DD8 0E15     lsr     r5,r2,18h                               ;r5 = number_of_bytes_to_copy; max length is 255
08008DDA 2300     mov     r3,0h                                   ;current_byte = 0
08008DDC 1C28     mov     r0,r5                                   ;r0 = number_of_bytes_to_copy
08008DDE 4283     cmp     r3,r0                                   ;
08008DE0 D209     bcs     Lxx_8008DF6h                            ;if(number_of_bytes_to_copy == 0), exit this function
08008DE2 1C02     mov     r2,r0                                   ;r2 = number_of_bytes_to_copy
08008DE4 18E1     add     r1,r4,r3                                ;r1 = copy_destination + current_byte
08008DE6 18F0     add     r0,r6,r3                                ;r0 = copy_source + current_byte
08008DE8 7800     ldrb    r0,[r0]                                 ;load byte to copy
08008DEA 7008     strb    r0,[r1]                                 ;store copied byte in destination
08008DEC 1C58     add     r0,r3,1                                 ;
08008DEE 0400     lsl     r0,r0,10h                               ;
08008DF0 0C03     lsr     r3,r0,10h                               ;current_byte++
08008DF2 4293     cmp     r3,r2                                   ;
08008DF4 D3F6     bcc     Lxx_8008DE4h                            ;loop until the number_of_bytes_to_copy have been copied
08008DF6 1960     add     r0,r4,r5                                ;r0 = copy_destination + number_of_bytes_to_copy
08008DF8 BC70     pop     r4-r6                                   ;
08008DFA BC02     pop     r1                                      ;
08008DFC 4708     bx      r1                                      ;

Pokémon in Old Man Tutorial

In US 1.1, 0x7F8A0 contains the Pokémon ID, 0x7F8A2 the level, the instructions at 0x7F8B4 sets the battle type to OLD_MAN_TUTORIAL. If you try to set the Pokémon ID to a genderless Pokémon, you will softlock unless you change the check done on r0 ≠ 0 and the bne at 0x3DF54 after the call of func_3F7A0.

Check if Pokémon is male, female, or genderless

  • 0x3F7A0 - Retrieves Pokémon gender ratio, checks if always male, always female or genderless, then checks pid to determine if male or female
  • arguments:
    • r0 = pokemon_id
    • r1 = pid
  • returns:
    • r0 = 0x0 if male; 0xFE if female; 0xFF if genderless
0803F7A0 B500     push    r14                                     ;
0803F7A2 1C0B     mov     r3,r1                                   ;r3 = pokemon_pid
0803F7A4 0400     lsl     r0,r0,10h                               ;
0803F7A6 0C02     lsr     r2,r0,10h                               ;r2 = pokemon_id
0803F7A8 490C     ldr     r1,=Lxx_82547F4h                        ;r1 = pointer_to_pokemon_data
0803F7AA 00D0     lsl     r0,r2,3h                                ;
0803F7AC 1A80     sub     r0,r0,r2                                ;
0803F7AE 0080     lsl     r0,r0,2h                                ;r0 = pokemon_id × 28
0803F7B0 1840     add     r0,r0,r1                                ;r0 = pointer_to_pokemon_datum
0803F7B2 7C00     ldrb    r0,[r0,10h]                             ;r0 = pokemon_gender_ratio
0803F7B4 2800     cmp     r0,0h                                   ;
0803F7B6 D014     beq     Lxx_803F7E2h                            ;if (pokemon_always_male), exit this function
0803F7B8 2800     cmp     r0,0h                                   ;
0803F7BA DB03     blt     Lxx_803F7C4h                            ;
0803F7BC 28FF     cmp     r0,0FFh                                 ;
0803F7BE DC01     bgt     Lxx_803F7C4h                            ;
0803F7C0 28FE     cmp     r0,0FEh                                 ;
0803F7C2 DA0E     bge     Lxx_803F7E2h                            ;if (pokemon_always_female || pokemon_is_genderless), exit this function
0803F7C4 00D0     lsl     r0,r2,3h                                ;
0803F7C6 1A80     sub     r0,r0,r2                                ;
0803F7C8 0080     lsl     r0,r0,2h                                ;r0 = pokemon_id × 28
0803F7CA 1840     add     r0,r0,r1                                ;r0 = pointer_to_pokemon_datum
0803F7CC 7C01     ldrb    r1,[r0,10h]                             ;r1 = pokemon_gender_ratio
0803F7CE 20FF     mov     r0,0FFh                                 ;
0803F7D0 4018     and     r0,r3                                   ;r0 = 0xFF & pokemon_pid
0803F7D2 4281     cmp     r1,r0                                   ;
0803F7D4 D804     bhi     Lxx_803F7E0h                            ;if (pokemon_is_female), r0 = 0xFE, and exit this function
0803F7D6 2000     mov     r0,0h                                   ;else r0 = 0
0803F7D8 E003     b       Lxx_803F7E2h                            ;exit this function
0803F7DA 0000     lsl     r0,r0,0h                                ;
0803F7DC 082547F4                                                 ;(pointer_to_pokemon_data)
0803F7E0 20FE     mov     r0,0FEh                                 ;r0 = 0xFE
0803F7E2 BC02     pop     r1                                      ;
0803F7E4 4708     bx      r1                                      ;

Rival name selection

081303B2 0600     lsl     r0,r0,18h                               ;
081303B4 1604     asr     r4,r0,18h                               ;r4 = cursor_position
081303B6 2C00     cmp     r4,0h                                   ;
081303B8 D022     beq     Lxx_8130400h                            ;to Name Entry screen
081303BA 2C00     cmp     r4,0h                                   ;
081303BC DD30     ble     Lxx_8130420h                            ;Player didn't validate a choice yet; exit this function
081303BE 2C04     cmp     r4,4h                                   ;There's only 5 option in the Rival name selection
081303C0 DC2E     bgt     Lxx_8130420h                            ;Invalid menu ID I suppose ? Does the same thin as not having selected a choice; exit this function
081303C2 2005     mov     r0,5h                                   ;r0 = 5
081303C4 F741FF8C bl      Lxx_80722E0h                            ;
081303C8 7EA8     ldrb    r0,[r5,1Ah]                             ;
081303CA 2101     mov     r1,1h                                   ;r1 = 1
081303CC F7DFF8C0 bl      Lxx_810F550h                            ;
081303D0 7EA8     ldrb    r0,[r5,1Ah]                             ;
081303D2 F6D3FD3D bl      Lxx_8003E50h                            ;
081303D6 4808     ldr     r0,=Lxx_203B108h                        ;
081303D8 6800     ldr     r0,[r0]                                 ;
081303DA 7C00     ldrb    r0,[r0,10h]                             ;
081303DC 1E61     sub     r1,r4,1                                 ;
081303DE 0609     lsl     r1,r1,18h                               ;
081303E0 0E09     lsr     r1,r1,18h                               ;
081303E2 F001F9F3 bl      Lxx_81317CCh                            ;call Fixed Rival name subroutine
081303E6 2001     mov     r0,1h                                   ;
081303E8 83E8     strh    r0,[r5,1Eh]                             ;
081303EA 1C38     mov     r0,r7                                   ;
081303EC 3808     sub     r0,8h                                   ;
081303EE 1830     add     r0,r6,r0                                ;
081303F0 4902     ldr     r1,=Lxx_81304DDh                        ;
081303F2 E014     b       Lxx_813041Eh                            ;exit this function
081303F4 5098     str     r0,[r3,r2]                              ;
081303F6 0300     lsl     r0,r0,0Ch                               ;
081303F8 B108     ????                                            ;
081303FA 0203     lsl     r3,r0,8h                                ;
081303FC 04DD     lsl     r5,r3,13h                               ;
081303FE 0813     lsr     r3,r2,20h                               ;
08130400 2005     mov     r0,5h                                   ;r0 = 5
08130402 F741FF6D bl      Lxx_80722E0h                            ;
08130406 2001     mov     r0,1h                                   ;
08130408 4240     neg     r0,r0                                   ;r0 = -1
0813040A 9400     str     r4,[sp]                                 ;
0813040C 2100     mov     r1,0h                                   ;
0813040E 2200     mov     r2,0h                                   ;
08130410 2310     mov     r3,10h                                  ;
08130412 F740F8C3 bl      Lxx_807059Ch                            ;
08130416 1C38     mov     r0,r7                                   ;
08130418 3808     sub     r0,8h                                   ;
0813041A 1830     add     r0,r6,r0                                ;
0813041C 4902     ldr     r1,=Lxx_813042Dh                        ;Prolly call to Name Entry screen
0813041E 6001     str     r1,[r0]                                 ;
08130420 B001     add     sp,4h                                   ;
08130422 BCF0     pop     r4-r7                                   ;
08130424 BC01     pop     r0                                      ;
08130426 4700     bx      r0                                      ;

Fixed Rival name subroutine

Call to 0x1317CC at address 0x1303B2 in US 1.1