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

some questions of a starting glitch-er... - Page 1

some questions of a starting glitch-er...

Posted by: natanelho
Date: 2017-07-18 08:59:12
I am new to this forum (first post yay) but I read things here for a long time. I understand what 8f does- executing code starting from number of pokemons in party, then most of the time a setup of specific pokemons redirects it to inventory…
I learned recently assembly for 8051, 8085 (and others) and I want to execute some code in pokemon… I just want to know where can I find :
1. a compiler or a tool that can convert assembly code to hex,
2. any documentation of all the asm instructions I can use with 8f- I mean, I learned asm for a few processors and most of them have different instruction lists even if it is small…
3. a list of all ram/save addresses and what they represent to know for sure I dont mess up what I shouldn't and to know what I should manipulate to if I want to get what I want in the game itself… and maybe where it is safe to write
4. how to test code before executing it on pokemon- I mean it's a lot of hassle and I don't want to go through all that and get a little bug in the code…

also a few questions- is there an unused part of the save where I can place code or maybe backup some of my save or data and the game doesn't touch or modify it?

EDIT:is there an easy way with an emulator to force the program counter to a location I say? any painless way?

and if you can, a list of where are subroutines in memory and how to use them- things like "encounter with a wild pokemon" or "… with a legendary"… I assume they exist right?

tl;dr Im new to pokemon glitching but not to programming, help!

Re: some questions of a starting glitch-er...

Posted by: Flandre Scarlet
Date: 2017-07-18 10:16:44
For number 3 use a RAM/ROM Map http://datacrystal.romhacking.net/wiki/Pok%C3%A9mon_Red/Blue:RAM_map http://datacrystal.romhacking.net/wiki/Pok%C3%A9mon_Red_and_Blue:ROM_map

Additionally the Pokered Disassembly can be useful to you https://github.com/pret/pokered

I can't help you with the other questions but there are other people here who can help you.

Re: some questions of a starting glitch-er...

Posted by: Krys3000
Date: 2017-07-18 11:05:05
Hello,

Here are other useful ressources:
- The v3 of ISSOtm's GBZ80 to Items https://issotm.github.io/gbz80toitems3/ can convert opcodes to item lists. If you really need a code to hex conversion, you can use the v2 of this tool available on PRAMA Initiative, but in French: http://prama-initiative.com/8F/
- A list of GBZ80 opcodes: http://pastraiser.com/cpu/gameboy/gameboy_opcodes.html
- A summary on how to use them: http://www.devrs.com/gb/files/opcodes.html

Re: some questions of a starting glitch-er...

Posted by: natanelho
Date: 2017-07-18 13:16:50
added to my first post: is there an easy way with an emulator to force the program counter to a location I say? any painless way?


For number 3 use a RAM/ROM Map http://datacrystal.romhacking.net/wiki/Pok%C3%A9mon_Red/Blue:RAM_map http://datacrystal.romhacking.net/wiki/Pok%C3%A9mon_Red_and_Blue:ROM_map

Additionally the Pokered Disassembly can be useful to you https://github.com/pret/pokered

I can't help you with the other questions but there are other people here who can help you.

the ram/rom maps are great! I think I saw them before, when I was researching it, I dont understand half of whats written there- and I cant find what I want like where is the code for x… and about the disassembly- I dont understand where everything starts, where is the code….yeah Im new to this and I didnt really used to get non complete info


Hello,

Here are other useful ressources:
- The v3 of ISSOtm's GBZ80 to Items https://issotm.github.io/gbz80toitems3/ can convert opcodes to item lists. If you really need a code to hex conversion, you can use the v2 of this tool available on PRAMA Initiative, but in French: http://prama-initiative.com/8F/
- A list of GBZ80 opcodes: http://pastraiser.com/cpu/gameboy/gameboy_opcodes.html
- A summary on how to use them: http://www.devrs.com/gb/files/opcodes.html


thanks for the opcode->item list converter, from there I can use the big list to convert item->hex, so its good I guess… thanks… will probably make a tool that will do both item lists and hex… I need hex because I would like to write lots of code and that will require hex to do it easier… and I dont speak french so it will be a hell to use your other suggestion
I think I dont understand the GBZ80 opcode list but I guess I will use the summary… by the way does the summary include  every single possible instruction that exists? or only the most used ones?

Re: some questions of a starting glitch-er...

Posted by: ISSOtm
Date: 2017-07-18 14:08:46
Heya ! I'm the guy who wrote GBZ80 to Items.

The only real way of doing ASM -> hex is to use a bit of compiler, since .gb/.gbc files are just hex dumps of the ROM.
The way I do it when I need some quick and dirty stuff is using BGB's code editor, or the Big HEX List when items are also needed. (When developing 8F codes, it's not considered good practice to force the user to have invalid items, but invalid quantities are fine)

BGB has the "Run" menu, which I often use with "Call cursor" (allows calling a function easily). It also has "jump to cursor", "step" (single-step instruction), "run to next line" (single-step except if it's a call, which is entirely run), etc. It's AWESOME.

If you want to get into 8F/ws m, it's a good idea to be in touch with GB programming. I recomment Avivace's Awesome-GBDev list, which has some very good tutorials on how to program for the GB. This will help you learning the GBz80's assembly, which is very similar to the z80's, btw)
It also links to RGBDS, which is in my opinion the best platform to compile GBz80 assembly.


The "8F compatibility" list doesn't exist, but I can either suggest going the automatic way with GBz80 to Items (I recommend v3 'cause it's simpler to use, but I also have an English version of v2 lying around somewhere), or you can use the Big HEX List (link in the sidebar under "References")


To get the comprehensive list of RAM addresses, check out Datacrystal (link extracted from Flandre Scarlet's post). For the FULL list, go check out Pokéred (again, from Flandre Scarlet's), and more specifically the wram.asm file


My workflow for testing the code :
1. Write it (I use Notepad++ with a custom language on Windows, and gedit with a custom language on Linux)
2. Compile it with RGBDS or the Big HEX List, I use the latter out of old habit but you might prefer the first
3. Extract the hex
4. Paste it into your inventory with BGB
5. Save state
6. Run, maybe trace execution to check if all goes fine (#BGBsDebuggerIsMyWai)
7. If needed, load state, refine code, retry
8. Use GBz80 to Items to compile code into items
9. Publish (Using Firefox, this is totally not a product placement)


Okay, that was a huge post. But hopefully it will explain everything you need to know - oh right, I forgot : pokered is made to be compiled with RGBDS. Just so you know, that's the RGBDS syntax.

PS : I really recommend you read a tutorial on GB Dev, because that will explain how the Game Boy works, which imo is essential to understanding some things when toying with 8F/ws m.

Re: some questions of a starting glitch-er...

Posted by: natanelho
Date: 2017-07-22 05:46:08

Heya ! I'm the guy who wrote GBZ80 to Items.

The only real way of doing ASM -> hex is to use a bit of compiler, since .gb/.gbc files are just hex dumps of the ROM.
The way I do it when I need some quick and dirty stuff is using BGB's code editor, or the Big HEX List when items are also needed. (When developing 8F codes, it's not considered good practice to force the user to have invalid items, but invalid quantities are fine)

BGB has the "Run" menu, which I often use with "Call cursor" (allows calling a function easily). It also has "jump to cursor", "step" (single-step instruction), "run to next line" (single-step except if it's a call, which is entirely run), etc. It's AWESOME.

If you want to get into 8F/ws m, it's a good idea to be in touch with GB programming. I recomment Avivace's Awesome-GBDev list, which has some very good tutorials on how to program for the GB. This will help you learning the GBz80's assembly, which is very similar to the z80's, btw)
It also links to RGBDS, which is in my opinion the best platform to compile GBz80 assembly.


The "8F compatibility" list doesn't exist, but I can either suggest going the automatic way with GBz80 to Items (I recommend v3 'cause it's simpler to use, but I also have an English version of v2 lying around somewhere), or you can use the Big HEX List (link in the sidebar under "References")


To get the comprehensive list of RAM addresses, check out Datacrystal (link extracted from Flandre Scarlet's post). For the FULL list, go check out Pokéred (again, from Flandre Scarlet's), and more specifically the wram.asm file


My workflow for testing the code :
1. Write it (I use Notepad++ with a custom language on Windows, and gedit with a custom language on Linux)
2. Compile it with RGBDS or the Big HEX List, I use the latter out of old habit but you might prefer the first
3. Extract the hex
4. Paste it into your inventory with BGB
5. Save state
6. Run, maybe trace execution to check if all goes fine (#BGBsDebuggerIsMyWai)
7. If needed, load state, refine code, retry
8. Use GBz80 to Items to compile code into items
9. Publish (Using Firefox, this is totally not a product placement)


Okay, that was a huge post. But hopefully it will explain everything you need to know - oh right, I forgot : pokered is made to be compiled with RGBDS. Just so you know, that's the RGBDS syntax.

PS : I really recommend you read a tutorial on GB Dev, because that will explain how the Game Boy works, which imo is essential to understanding some things when toying with 8F/ws m.

thanks for the awesome list! I spent a few days just looking in the list and reading… some cool projects and documentation…
can you please give me a link to a good gb asm dev guide? in the awesome list I found only 2, one is ASMschool which is not complete (lesson 10 onward is exactly what I need….) and that spanish guide with the translation.. the translation is terrible and I barely understand what he does there…

I also use notepad++ while on windows (and Im in windows 90% of the time) and it does its job with lang set to asm, but not perfectly or atleast as good as I would want it to be… can you please send me the custom language you talked about and a brief explaination on how to install it? that would be great…

I already installed RGBDS and BGB and BGB is pretty good… only complaint is it cant run at, like, 10 times the speed of a normal GB to fast forward the slow game pokemon is… or can it? I already ran a successful code (something as easy as changing the ammount of money I have) but I want more of course… its really annoying when BGB shows a few lines in one line when it interprets this line as an asm instruction.. is there a way to tell it to just show a hex list of memory? its pretty confusing when I want to write a code and it interprets the byte before where it starts as the first part of the instruction…

and thanks for making the item list! I know I can compile my code and copy paste the hex values but then I need to add a header, do stupid shit like that and then search my code in the gb file… if you could add a hex value representing the item next to the item, as it perfectly does with glitch items and the amount of each item on the right, I dont think it would hurt anybody…

also can you (or anybody else) share with me a few tips for how to make item lists include only non-glitch items? I already discovered one trick which is to use nop as a placeholder but it only works sometimes which is not really that much…

Re: some questions of a starting glitch-er...

Posted by: Charmy
Date: 2017-07-22 23:41:21
If you want to make BGB speedup a bunch, you can go to options, and find an option affecting the frame rate, just don't set it to above 999 or it'll most likely crash for some reason

Re: some questions of a starting glitch-er...

Posted by: ISSOtm
Date: 2017-07-23 03:41:13
Thing is, I actually never read a single GB tutorial. I actually started with programming on the TI 83+, which has the z80 processor. When I approached the GBz80, I understood it as a z80 stripped of a bunch of its instructions and with a few extra ones. Thus, I can't give you such a link. It will depend on what you need.

The custom language file is attached to this post. To install it :

BGB can't speed-up as much as, say, VBcrap, because it is less optimized. This is a consequence of better accuracy. It's a complicated topic. I got it speed up by 5x.

Now, there's just something I don't understand. What is wrong with the hex viewer panel ? The one under the code panel. This one shows raw bytes, so that's exactly what you need, yet you don't seem to notice it.
Also, if there is a byte that's misinterpreted in the code panel, note the address of the first byte of the code, hit Ctrl+G, type the address, and go. This will force BGB to interpret that byte as the first byte of an instruction. This doesn't work perfectly and may require some fiddling, but it's better than nothing.

You don't need to add a header. BGB will load even badly malformed ROMs (just telling you OH MY GOD WHAT THE FUCK in the middle of the loading), and if you just put the code at $0000 it will show up at the first address in the ROM. So lol.
I'll maybe add a raw hex output to GBz80 to Items, but currently nobody requests it (aside from you and someone else) and I'm already programming something else, so I don't have a lot of time. tl;dr : I'll maybe add it, but it's not on my priority list.

The placeholder used classically is "inc b", but then there are a couple others. When you need a "filler" byte, check which registers aren't locked-up, and use an instruction that trashes another one. rlca, scf, etc. Second possibility is to use 3-bytes instructions, mostly 16-bit loads. The sky number of instructions is the limit !

Re: some questions of a starting glitch-er...

Posted by: SatoMew
Date: 2017-07-31 09:35:53

I already installed RGBDS and BGB and BGB is pretty good… only complaint is it cant run at, like, 10 times the speed of a normal GB to fast forward the slow game pokemon is… or can it?


You can assign a key for the fast forward function. Open BGB's settings and tick "configure extra buttons" under the Joypad tab, then click the "configue keyboard" button. You'll find fast forward after clicking "Skip/clear" or "Skip/keep" (depends on what you want to do) twice.