Glitch City Laboratories Archives

Glitch City Laboratories closed on 1 September 2020 (announcement). This is an archived copy of a thread from Glitch City Laboratories Forums.

You can join Glitch City Research Institute to ask questions or discuss current developments.

You may also download the archive of this forum in .tar.gz, .sql.gz, or .sqlite.gz formats.

Generation I Glitch Discussion

PKMN R/B - ACE: How to Exec code from ram? - Page 1

PKMN R/B - ACE: How to Exec code from ram?

Posted by: Klohver
Date: 2017-04-12 10:37:04
Hi, I am new to the pokemon glitching scene, I have been playing pkm r/b since it first came out, and started glitching for the past few years. I am familiar with the item underflow, trainer fly, and other glitches. What really interests me is arbitrary code execution. My plan is to, using 8F to bootstrap my game on console, and be able to write a code similar to the one where TheZZAZZGlitch used pokemon r/b/y to load super mario, pokemon crystal, etc, but have it execute things back into the same cartridge, for example: code it to reset the game, then I can start a new game in pokemon r/b with that code running so when I start the new game, I will have a certain setup right off the bat. For instance: having item 8F right from pallet town, having items, badges, 151 pokemon, being able to item underflow, or even possibly creating some sort of GUI or entry into the start menu that can be accessed to edit memory addresses that are out of reach of the item underflow glitch, all from the get go. I haven't seen anyone do this yet so I'm hoping there is someone out there who could direct me on how to accomplish this. I get the gyst of how to bootstrap, but I am not familiar with the ASM code so I have no idea how to start this project? Any and all help will be super appreciated  ;D

Re: PKMN R/B - ACE: How to Exec code from ram?

Posted by: jfb1337
Date: 2017-04-12 13:02:12
If this is your first time using ACE, I'd recommend first try out some of the small scripts in the main thread, such as getting any item or any pokémon, and try to understand how they work. The dissasembly might help with understanding too.

Then you could start trying to make your own scripts, whenever you think of something that might be useful, using the Big Hex List and ISSOtm's compiler to help.

If you're unsure of anything, try it in an emulator first - especially for things that might have a chance to crash and corrupt the save file and/or things that take a long time to set up.

If your main goal is cartswapping, you can try a basic cartswap script at this point, that would soft reset into the swapped cart without any additional custom code.

Once you feel you have enough experience with ACE, you can start something more ambitious, like Offgao's memory editor, which I  programmed into my game using a slightly modified version of ZZAZZ's route 1 bike method - It's a GUI memory editor.

Then, it should be possible to write a program that allows a cartswap into another game, then copy the memory editor + any other set up you want (like putting an 8F in the bag, bootstrap in your party, etc) into the save file before jumping into the initialisation routine. 

In theory it should be possible to patch up the initialisation script, like ZZAZZ for super mario, and skip over the part that clears HRAM, allowing custom code to be injected into the title screen, which would also give you control over starting a new save file as well as just continuing - which would allow you to do the stuff you want such as having access to 8F and the GUI memeditor from the start.

Re: PKMN R/B - ACE: How to Exec code from ram?

Posted by: ISSOtm
Date: 2017-04-13 04:45:52
What you need first, and it is essential, is solid knowledge of assembly.
The Game Boy's processor is similar to the z80, so I recommend reading ASM in 28 Days (a Day in this tutorial is simply a lesson, not a full day :P) to learn the z80 assembly. The tutorial is for TI 8X+ calculators, so there are some things there that don't matter for Game Boy stuff, but read it all, it'll make you practice.

Once you have good knowledge of z80 assembly, read the Pan Docs to get the basics of the GB's internals.

And then get familiar with Gen I's engine, and you can start coding !

Re: PKMN R/B - ACE: How to Exec code from ram?

Posted by: TheSixthItem
Date: 2017-06-19 09:42:38

What you need first, and it is essential, is solid knowledge of assembly.
The Game Boy's processor is similar to the z80, so I recommend reading ASM in 28 Days (a Day in this tutorial is simply a lesson, not a full day :P) to learn the z80 assembly. The tutorial is for TI 8X+ calculators, so there are some things there that don't matter for Game Boy stuff, but read it all, it'll make you practice.

Once you have good knowledge of z80 assembly, read the Pan Docs to get the basics of the GB's internals.

And then get familiar with Gen I's engine, and you can start coding !

The link's broken :(

Re: PKMN R/B - ACE: How to Exec code from ram?

Posted by: ISSOtm
Date: 2017-06-20 05:11:48
Not anymore.