• 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.

Development: Heads-up Display

Touched

Resident ASMAGICIAN
625
Posts
9
Years
    • Age 122
    • Seen Feb 1, 2018
    Most games have a HUD, which allows players to check vital status information, such as health, money, etc. The Pokemon series has no need for this information, as it's all packed away in the start menu. However, with the mechanics of the game being altered, one could feasibly implement a hunger and thirst system, or a fatigue system. These mechanics would need a HUD of some sort in order to be properly implemented.

    Since the HUD is usually displayed on the map, and not on any menus, I sought the map rendering routine. I found it at 0805ABB0. This routine does some checks every frame to see if the camera has moved, and updates the appropriate area of the display if it has. However, for the purposes of this research, we have no interest in the body of this routine. We are only interested in the part that returns the function (the branch at 0805AC7E).

    Code:
    ROM:0805AC7E loc_805AC7E                             ; CODE XREF: ROM:0805AC52j
    ROM:0805AC7E                 LDR     R0, =0x3000E90
    ROM:0805AC80                 MOVS    R1, R7
    ROM:0805AC82                 MOV     R2, R8
    ROM:0805AC84                 BL      sub_805A5D4
    ROM:0805AC88                 LDR     R1, =0x300506C
    ROM:0805AC8A                 LDRH    R0, [R1]
    ROM:0805AC8C                 SUBS    R0, R0, R7
    ROM:0805AC8E                 STRH    R0, [R1]
    ROM:0805AC90                 LDR     R1, =0x3005068
    ROM:0805AC92                 LDRH    R0, [R1]
    ROM:0805AC94                 MOV     R2, R8
    ROM:0805AC96                 SUBS    R0, R0, R2
    ROM:0805AC98                 STRH    R0, [R1]
    ROM:0805AC9A                 POP     {R3}
    ROM:0805AC9C                 MOV     R8, R3
    ROM:0805AC9E                 POP     {R4-R7}
    ROM:0805ACA0                 POP     {R0}
    ROM:0805ACA2                 BX      R0

    So we'd like to inject a routine that loads our HUD after the map updates.

    From the looks of the code around the call to this function, this function is a void (doesn't return anything), therefore we can just use r1 without fear of overwriting anything.
    Code:
    ldr r1, =0xDEADBEEF
    bx r1

    Where 0xDEADBEEF is the offset of your new routine. This code then assembles to
    Code:
    01 49 08 47 EF BE AD DE

    That code is going to be 8 bytes. 4 bytes for both opcodes and another 4 for that symbol. So we can overwrite the instructions here: 0805AC9A. One problem - this isn't word aligned. So we need to align that symbol properly. Just pad it with 0s:
    Code:
    01 49 08 47 00 00 EF BE AD DE

    Now we can insert at 0805AC9A. Remember to replace the fake offset with your new routine. I chose 087FF000. Also remember to set the Thumb bit.

    Now we need to restore functionality to this routine, be adding the opcodes we overwrote. So here is a skeleton routine that you must insert at the offset you chose:

    Code:
    .thumb
    .align 2
    
    main:
    	bl main_func
    	pop {r3}
    	mov r8, r3
    	pop {r4-r7}
    	pop {r0}
    	bx r0
    
    main_func:
    	mov r0, r0 @nop
    	@ Render HUD here

    Now the next thing is we must be careful not to do too much in this function to prevent lag. So using this skeleton, I wrote some stuff to the OAM at a fixed pair of coordinates, on the highest priority, and got this:

    2hqe688.png


    2rqg8ev.png


    2vnqbkw.png


    So it works. Now I just have to work on loading custom graphics and whatever into the VRAM. Right now, overworlds will flicker, but this is just because I'm overwriting OBJ1 in the OAM. I'll update more when I have it.
     

    Danno

    Formerly Meowth, AKA InnerMobius
    1,224
    Posts
    17
    Years
  • This could prove to be very useful for my hack, thanks for the research, if used I'll surely give you credit!
     

    Touched

    Resident ASMAGICIAN
    625
    Posts
    9
    Years
    • Age 122
    • Seen Feb 1, 2018
    I've got an update. I wrote an example routine (very hurriedly, I might add, it's unoptimized and is very slow) that reads what status ailments your party has and displays it on the HUD.
    Spoiler:

    Screenshots:

    I caught a Pikachu, and my Bulbasaur was paralysed in the process:
    View attachment 73199

    Here is the HUD reflecting that change:
    View attachment 73200

    I then battled a Weedle with my Pikachu, and got poisoned:

    View attachment 73201
    View attachment 73203

    And the HUD shows my entire party's status ailments:
    View attachment 73202
     
    Last edited:
    10,078
    Posts
    15
    Years
    • UK
    • Seen Oct 17, 2023
    Looks pretty good so far! Do the images for PSN and PAR disappear if you interact with a person? Or do they interfere in anyway with textboxes?

    This has potential for a tonne of RPG-style features. Number of pokeballs? Event ticks? Capture the flags? Your idea is genius and a great stepping stone to some new, unique features among FR hacks.
     

    Le pug

    Creator of Pokémon: Discovery / Fat Kid
    870
    Posts
    10
    Years
  • Hunger and thirsty... systems my hack needs since youre stranded on an island. So it's possible to have it to where... you do this and maybe after 1000 steps you have like a battery life and it drains by 1 bar or so ?
     

    cscof

    pretty coolish guy
    52
    Posts
    10
    Years
  • It would be cool if the HUD would show if your party is doing well or not, as in the HUD would be green if all your pokes have full health/pp and no status ailments, yellow around half/ with status ailments, and red if you need to get to a pokecenter right away
     

    Chronosplit

    I play for keeps!
    492
    Posts
    13
    Years
    • Seen yesterday
    There is a reason why the offset is 0xDEADBEEF as in DEAD BEEF.
    She's secretly a Miltank! D:

    This could actually be a pretty cool update for the VS Seeker: display a bar after using it or a counter of how many steps are left until it's recharged. Or maybe even a little tiny compass/itemfinder in the corner.
     

    Danny0317

    Fluorite's back, brah
    1,067
    Posts
    10
    Years
    • Age 24
    • Seen Nov 19, 2023
    So while Touched is working hard to make this available, you guys are making jokes about old ladies and "DEADBEEF.."

    Really guys? Really?

    Anyways Touched, this is looking great. Perhpahs a world map icon would be good to? Just a suggestion :)
     

    Touched

    Resident ASMAGICIAN
    625
    Posts
    9
    Years
    • Age 122
    • Seen Feb 1, 2018
    I found the offset where you can inject the HUD for Emerald: 0808A24E

    That's the same routine as in the first post, so the procedure for injecting should identical.

    I'm gonna move this to a C build, since that's easier.
     
    Back
    Top