• Just a reminder that providing specifics on, sharing links to, or naming websites where ROMs can be accessed is against the rules. If your post has any of this information it will be removed.
  • Ever thought it'd be cool to have your art, writing, or challenge runs featured on PokéCommunity? Click here for info - we'd love to spotlight your work!
  • Our weekly protagonist poll is now up! Vote for your favorite Conquest protagonist in the poll by clicking here.
  • 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
    10
    Years
    • Age 123
    • 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:

    [PokeCommunity.com] Heads-up Display


    [PokeCommunity.com] Heads-up Display


    [PokeCommunity.com] Heads-up Display


    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.
     
    you may also want to take that woman off the top of that building before she falls and breaks a bone or something

    I think the whole idea is SHE is the HUD.
     
    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:
    "image removed"

    Here is the HUD reflecting that change:
    "image removed"

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

    "image removed"
    "image removed"

    And the HUD shows my entire party's status ailments:
    "image removed"
     
    Last edited:
    That is really, really amazing! Great work. I look forward to it being completed!
     
    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.
     
    awesome, really freaking awesome
     
    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 ?
     
    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
     
    Or perhaps display an RTC in the corner of the screen, or even a repel step counter, either of which using a micro-sized font. Both of those would be useful to players.

    For RTC it might be neat to have it like the clocks in Animal Crossing, where it pops out if you idle for a few seconds.
     
    Maybe the HUD could serve as a mini-version of the bottom screen of a DS
     
    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