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

Create a debug menu

I learned about windows and list menus today, and I've written a short-ish tutorial on how to add a debug menu to pokeemerald using the same hooks Game Freak used for their own debug menu in order to try and help others in turn. BBcode depresses me, so I've hosted it as a gist.

If you're a better C programmer than me or more familiar with the pokeemerald codebase, I'd like to know about any ways in which I can do what I'm doing more efficiently. In particular, having three different lists which need to be kept in sync strikes me as odd; I considered writing a macro, but then I remembered how C's macro system works and decided not doing that sounded way more fun.
 
Thanks a lot for the tutorial! I'm still in the process of understanding it completely, but for now I've just added your code as it is, and I'm facing this error:

Code:
`Debug_ShowMainMenu' referenced in section `.text' of src/field_control_avatar.o: defined in discarded section `.text' of src/debug.o
make: *** [Makefile:204: pokeemerald.elf] Error 1

Do you have any idea why that would be happening?
 
You need to add src/debug.o to the linker script. It looks like I forgot to mention that, possibly because I replaced it with one that didn't include filenames individually by name. (Presumably eventually someone will fork pokeemerald to make it more suited to ROM hacking, and you won't have to do this anymore.)

1. Open ld_script.txt.
2. Find the line src/start_menu.o(.text);; add a new line after it that says src/debug.o(.text);.
3. Find the line src/start_menu.o(.rodata);; add a new line after it that says src/debug.o(.rodata);.
 
You need to add src/debug.o to the linker script. It looks like I forgot to mention that, possibly because I replaced it with one that didn't include filenames individually by name. (Presumably eventually someone will fork pokeemerald to make it more suited to ROM hacking, and you won't have to do this anymore.)

1. Open ld_script.txt.
2. Find the line src/start_menu.o(.text);; add a new line after it that says src/debug.o(.text);.
3. Find the line src/start_menu.o(.rodata);; add a new line after it that says src/debug.o(.rodata);.

Thanks a lot! That worked ?????? There's only a minor problem where unless I open the Start Menu once the palette for the border is garbled, but I don't think that should be an issue and instead I'll work on actually adding debug options to this

[PokeCommunity.com] Create a debug menu
 
Last edited:
Thanks a lot! That worked ������ There's only a minor problem where unless I open the Start Menu once the palette for the border is garbled, but I don't think that should be an issue and instead I'll work on actually adding debug options to this

[PokeCommunity.com] Create a debug menu

I was able to fix this by looking at start_menu.c and map_popup_menu.c: the issue seems to have been caused by 1) the game not loading the gfx/palettes for the border and 2) the map popup obscuring the debug window since it's on the left

[PokeCommunity.com] Create a debug menu


To fix the problem, add the Map Popup Header

Code:
#include "map_name_popup.h"

to the top, then add these lines

Code:
HideMapNamePopUpWindow();
sub_81973A4();

Above the lines indicated by // create window.

The function sub_81973A4(); doesn't seem to have been renamed, but this is what it looks like, in case anyone was wondering:

Code:
void sub_81973A4(void)
{
    LoadMessageBoxGfx(0, DLG_WINDOW_BASE_TILE_NUM, DLG_WINDOW_PALETTE_NUM * 0x10);
    LoadUserWindowBorderGfx(0, STD_WINDOW_BASE_TILE_NUM, STD_WINDOW_PALETTE_NUM * 0x10);
}

I spent an obscene amount of time trying to figure this out, but I intend to make a general purpose debug menu at some point that romhackers can use for easy testing.
 
how to you make a build without the debug menu once you implement it? I tried just plain make, added an else clause to debug in the makefile that sets the flags to 0 if no param is sent. each time the compiler just either said "nothing to do for 'rom'", or it copied cached data from pokeemerald.elf. I even tried deleting the elf file, but the code constrained under the debug flags is still functional in game. I'm nowhere near anything worth putting out yet, but I thought I would see if my code worked without the debug functions or if I had botched something. glad I caught it now rather than later, but I still have no idea how to fix it.
 
added an else clause to debug in the makefile that sets the flags to 0 if no param is sent

I don't have a repo set up to check, but this isn't necessary and is probably the source of the problem you're having. #if DEBUG isn't checking whether DEBUG is equal to 1 - it's checking whether it's set at all. Setting DEBUG to 0 is still setting it, so your debug code is always compiled.
 
Is there a way to implement this for pokefirered?

I imported all of the code to the same files and was able to get it to compile after some tweaking, but the debug menu won't open. The start menu just opens like normal.
 
Back
Top