The PokéCommunity Forums Fan Games ROM Hacking Research & Development
Development Changing Fire Red intro rival sprites/names and texts depending on players gender

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!

Reply
 
Thread Tools
  #1    
Old December 11th, 2011 (12:26 PM). Edited December 15th, 2011 by tinix.
tinix's Avatar
tinix tinix is offline
PearlShipper & C Programmer
     
    Join Date: Feb 2010
    Location: Bratislava, Slovakia
    Age: 20
    Gender: Male
    Posts: 86
    So lately I have been thinking aboout how to edit sprites of rival in the fire red intro depending on the gender of player. After a while of reaserch I managed to do it. Although I dont like a few things about that code it works and doesnt seem to cause any harm to the ROM. So here are the routines

    Branching routine to be inserted at 0x131248:
    Spoiler:

    Code:
    .align 2
    .thumb
    .thumb_func
    ; should go at 0x131248
    main:
       push {r4}
       ldr r4, .POINTER 
       bx r4
    .POINTER
       .word 0x08900001


    Actual code that modifies the behaivour:
    Spoiler:

    Code:
    .align 2
    .thumb
    .thumb_func
    .main:
       pop {r4}
       push {r3}
       ldr r3, .PLAYER_DATA
       ldr r3, [r3]
       ldrb r3, [r3, #0x8] 
       mov r1, #0x60
       mov r2, #0x40
       cmp r3,#0x0
       bne .girl
       pop {r3}
       push {r3}
       ldr r0, .IMAGE_1a
       ldr r3, .FUN1
       bl .jmp
       pop {r3}
       ldr r0, .IMAGE_1
       ldr r2, .RETURN
       bx r2
    .girl:
       pop {r3}
       push {r3}
       ldr r0, .IMAGE_2a
       ldr r3, .FUN1
       bl .jmp
       pop {r3}
       ldr r0, .IMAGE_2
       ldr r2, .RETURN
       bx r2
    .jmp:
       bx r3
    .align 2
    .PLAYER_DATA:
     .word 0x0300500C
    .IMAGE_1:
     .word 0x084623EC 
    .IMAGE_2:
        .word 0x08460F14  
    .IMAGE_1a:
     .word 0x084623AC 
    .IMAGE_2a:
        .word 0x08460ED4 
    .RETURN:
     .word 0x08131255
    .FUN1:
     .word 0x080703ED


    Next thing Im going to look into are names.
    Video:
    __________________
    Pokémon games I own:
    Pokémon Diamond
    Pokémon Platinum
    Pokémon Ranger: Shadows of Almia
    Pokémon HeartGold Version
    Reply With Quote

    Relevant Advertising!

      #2    
    Old December 15th, 2011 (4:49 AM). Edited December 15th, 2011 by Jambo51.
    Jambo51's Avatar
    Jambo51 Jambo51 is offline
    Glory To Arstotzka
       
      Join Date: Jun 2009
      Gender: Male
      Nature: Quiet
      Posts: 732
      Is this your first piece of ASM (or close to)?
      It could be written better, but very well done on getting it to work.

      Things which could definitely be improved:

      Spoiler:

      Code:
      ldr r4, .BOY
       ; These two were in dissasembly of original code, I didnt played with them 
      mov r1, #0x60
      mov r2, #0x40
      ;Comparision
      cmp r3,r4
      bne girl
      Should simply be:

      Code:
      mov r1, #0x60
      mov r2, #0x40
      cmp r3, #0x0
      bne girl


      The loading of 0x0 into r4 for comparison is wasteful, when you can simply compare r3 with 0 like I have above, this also nullifies the need for the push of r4 in the code. You only need to load something into the register to compare if the thing you want to compare with is unknown at compile time (the number is known in this case) or if the number you wish to compare is larger than 0xFF. Otherwise, simply use cmp rx, #0xZ to compare register x with byte Z.

      The way that bl (or blx as you call it) work with the gba games is annoying:
      The way to use it properly is this:

      Spoiler:

      Code:
      ldr r0, .IMAGE_1a
      bl wherever
      pop {r3}
      //rest of code
      ldr r0, .IMAGE_2a
      bl wherever
      pop {r3}
      //rest of code
      wherever: push {r3}
      ldr r3, .FUN1
      bx r3


      A pain? Yes. But it works.

      Hope this helps, and well done on finding and creating a solution for yourself!
      __________________
      Hey guys, please check out my recreations of the gen 1 and 2 music on my custom engine at my SoundCloud! - Here!
      Reply With Quote
        #3    
      Old December 15th, 2011 (6:06 AM).
      tinix's Avatar
      tinix tinix is offline
      PearlShipper & C Programmer
         
        Join Date: Feb 2010
        Location: Bratislava, Slovakia
        Age: 20
        Gender: Male
        Posts: 86
        Quote:
        Originally Posted by Jambo51 View Post
        Is this your first piece of ASM (or close to)?
        It could be written better, but very well done on getting it to work.

        Things which could definitely be improved:

        Spoiler:

        Code:
        ldr r4, .BOY
         ; These two were in dissasembly of original code, I didnt played with them 
        mov r1, #0x60
        mov r2, #0x40
        ;Comparision
        cmp r3,r4
        bne girl
        Should simply be:

        Code:
        mov r1, #0x60
        mov r2, #0x40
        cmp r3, #0x0
        bne girl


        The loading of 0x0 into r4 for comparison is wasteful, when you can simply compare r3 with 0 like I have above, this also nullifies the need for the push of r4 in the code. You only need to load something into the register to compare if the thing you want to compare with is unknown at compile time (the number is known in this case) or if the number you wish to compare is larger than 0xFF. Otherwise, simply use cmp rx, #0xZ to compare register x with byte Z.

        The way that bl (or blx as you call it) work with the gba games is annoying:
        The way to use it properly is this:

        Spoiler:

        Code:
        ldr r0, .IMAGE_1a
        bl wherever
        pop {r3}
        //rest of code
        ldr r0, .IMAGE_2a
        bl wherever
        pop {r3}
        //rest of code
        wherever: push {r3}
        ldr r3, .FUN1
        bx r3


        A pain? Yes. But it works.

        Hope this helps, and well done on finding and creating a solution for yourself!
        Thank you for pointing out these things. It is my first working ARM/THUMB ASM program/hack (played with x86 a bit) I will try to fix those things.
        __________________
        Pokémon games I own:
        Pokémon Diamond
        Pokémon Platinum
        Pokémon Ranger: Shadows of Almia
        Pokémon HeartGold Version
        Reply With Quote
          #4    
        Old December 15th, 2011 (6:11 AM).
        Darthatron's Avatar
        Darthatron Darthatron is offline
        巨大なトロール。
        • Silver Tier
         
        Join Date: Jan 2006
        Location: Melbourne, Australia
        Age: 25
        Gender: Male
        Nature: Modest
        Posts: 1,152
        Always nice to see new ASM hacks by new people. But maybe you should upload a video or something of it working.

        Also, I think once you've become a bit better with THUMB, you may be able to just rewrite the whole routine and make it WAY smaller. Maybe even fit in to the old routine and save a bunch of space. Good luck!!
        __________________
        あなた は しきしゃ です
        わたし は ばか です
        Reply With Quote
          #5    
        Old December 15th, 2011 (10:04 AM).
        tinix's Avatar
        tinix tinix is offline
        PearlShipper & C Programmer
           
          Join Date: Feb 2010
          Location: Bratislava, Slovakia
          Age: 20
          Gender: Male
          Posts: 86
          I modified the routine according to tips that jambo has given, and also I will soon post a video of it working.
          __________________
          Pokémon games I own:
          Pokémon Diamond
          Pokémon Platinum
          Pokémon Ranger: Shadows of Almia
          Pokémon HeartGold Version
          Reply With Quote
            #6    
          Old December 15th, 2011 (2:31 PM).
          The Author's Avatar
          The Author The Author is offline
          The Hero of Knothole Glade
             
            Join Date: Sep 2011
            Location: Knothole Glade
            Age: 19
            Gender: Male
            Nature: Quiet
            Posts: 381
            This is EXACTLY what I was looking for!
            This will help out a lot.
            THANK YOU. :cer_boogie:
            __________________
            The Disciple
            The Poet
            The Leader
            The Musician
            The Transcendentalist

            The Author
            The Philosopher
            The Architect
            The Psychologist
            The Artist
            Reply With Quote
              #7    
            Old December 15th, 2011 (4:10 PM).
            Diegoisawesome's Avatar
            Diegoisawesome Diegoisawesome is offline
            Oh god the bees
            • Silver Tier
             
            Join Date: Dec 2007
            Location: :noitacoL
            Age: 20
            Gender: Male
            Nature: Naive
            Posts: 1,032
            Hey, I already did this a while ago, for my own hack. Nice to see someone else do it, too.
            Although mine is more complete...
            __________________


            My other resources:
            My Website
            diegoisawesome's MEGA-HUGE XSE Scripting Tutorial
            diegoisawesome's Miscellaneous Finds
            The Ruins of Alph Puzzles
            Diego's Miscellaneous Patches
            GBA Intro Manager
            The Secret Sauce: Triple-Layer Tiles
            Reply With Quote
              #8    
            Old December 15th, 2011 (9:49 PM).
            tinix's Avatar
            tinix tinix is offline
            PearlShipper & C Programmer
               
              Join Date: Feb 2010
              Location: Bratislava, Slovakia
              Age: 20
              Gender: Male
              Posts: 86
              Quote:
              Originally Posted by diegoisawesome View Post
              Hey, I already did this a while ago, for my own hack. Nice to see someone else do it, too.
              Although mine is more complete...
              I plan to change names too, but I didnt lastly have time to look into it.
              __________________
              Pokémon games I own:
              Pokémon Diamond
              Pokémon Platinum
              Pokémon Ranger: Shadows of Almia
              Pokémon HeartGold Version
              Reply With Quote
              Reply
              Quick Reply

              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 7:09 AM.