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.

Programming/Scripting/Development/Web Design

[Utility] 8F Helper - gbz80aid - Page 1

[Utility] 8F Helper - gbz80aid

Posted by: Cryo
Date: 2016-12-10 21:57:42
Heya guys,

After a good bit of going back-and-forth to the Wiki (and later back-and-forth to a text file) in order to look up values for the 8F glitch, I decided to write a program in C using lookup tables that could directly parse gbz80 assembly and machine code, then output the results to the console pretty quickly (~12 milliseconds) in a variety of outputs.

You can check it out over at its Github page, 8F Helper.

As an example of its output, I took the assembly instructions for the perpetually resetting save file by Wacko and converted them to 8F items with the utility.

test.asm:

ld l,$6E
ld (hl),$36
ld a,$D3
ld ($D36F),a
inc b
ld c,$1c
ld h,$78
ld l,$48 ; 1c:7848: SaveSAVtoSRAM
ld b,c
call $35d6 ; BankSwitch
jp nc,$1f49 ; SoftReset


Command and output:

root@gbdev:~# gbz80aid -o gen1 -f test_code.asm

Item            Quantity
========================
X Accuracy      x110
Max Revive      x54
Lemonade        x211
TM34            x111
TM11            x4
Awakening      x28
Carbos          x120
X Accuracy      x72
X Attack        x205
TM14            x53
TM10            x73
Old Amber      xAny


Hope it can be of use! ;D

Re: [Utility] 8F Helper - gbz80aid

Posted by: ISSOtm
Date: 2016-12-11 05:28:02
Sure it'll be useful ! (And kudos for running this on Linux :D)

That reminds me of my old JavaScript "compiler", and I'd like to suggest some features that came to my mind as I was developing it.

- A -w option that would enable warnings (such as invalid items, using key items with a non-one quantity, two stacks of the same item…).
- Turn the gen2 option into gen2i to make room for the next option.
- Add a gen2b that outputs box names for more recent Gen II ACE exploits.
- More label support.
- Different syntax ? There are multiple syntax used out there.

Which compiler do you use ?

I have some knowledge about C and GBz80, so I forked your repository and did some edits.

Re: [Utility] 8F Helper - gbz80aid

Posted by: Stackout
Date: 2016-12-11 08:42:47
Nice work :)

Re: [Utility] 8F Helper - gbz80aid

Posted by: Cryo
Date: 2016-12-11 22:10:59

- A -w option that would enable warnings (such as invalid items, using key items with a non-one quantity, two stacks of the same item…).
- Turn the gen2 option into gen2i to make room for the next option.
- Add a gen2b that outputs box names for more recent Gen II ACE exploits.
- More label support.
- Different syntax ? There are multiple syntax used out there.


Thanks for the feedback! I'll start experimenting with the label support and warnings, and I'll start doing research into Gen II ACE exploits.

And yeah, the pointer operations are pretty hacky; I'll work on standardizing the code and sticking with one style. :D


Which compiler do you use ?

I have some knowledge about C and GBz80, so I forked your repository and did some edits.


Oh awesome! As for my go-to compiler, I use gcc almost exclusively, but I use Visual Studio's cl.exe compiler on very rare occasions.

Re: [Utility] 8F Helper - gbz80aid

Posted by: ISSOtm
Date: 2016-12-12 09:37:42
The edits are sitting on my PC as I'm writing stuff in gedit. I dunno which command you use to compile, so here's mine :

gcc gbz80aid.c -o gbz80aid -std=c99


Progression thus far :
Added bounds checking on options using arguments (-f and -o).
Added comments when I needed them.
Added a -v (version) argument, prints light version info.
Added support for brackets instead of parentheses.
Replaced some "malloc"s by some local strings.
Adding a -ofs option of asm format.

Re: [Utility] 8F Helper - gbz80aid

Posted by: ISSOtm
Date: 2016-12-14 08:39:37
I've sent a pull request, but I'm working on implementing some more features and cleaning stuff up.

Re: [Utility] 8F Helper - gbz80aid

Posted by: Cryo
Date: 2016-12-14 11:54:00

I've sent a pull request, but I'm working on implementing some more features and cleaning stuff up.


Oh awesome! I've merged the pull request with the changes in the master repo, which contains support for multiple labels, some error handling, and more efficient/standardized code than my initial master commit. ;D

As for my compilation command, I usually just use:
gcc -o gbz80aid gbz80aid.c

Re: [Utility] 8F Helper - gbz80aid

Posted by: ISSOtm
Date: 2016-12-15 11:39:17
You never get any warnings when compiling ?
I got a ton when I ran this command, mostly about "for(int i = 0; …", which went away when I switched to C99 standard (-std=c99)

I added "-Wall -Wextra" and commited changes to remove almost all warnings.
I'm also getting ready to write a box name format for Gen II.

Re: [Utility] 8F Helper - gbz80aid

Posted by: Cryo
Date: 2016-12-16 17:57:49
Nah, no warnings from the compiler; I'm using GCC 6.2.1 on Kali 2016.2 Rolling. Same with GCC using MinGW on Windows.

It only complains about warnings whenever I enable all warnings during compilation, but it's otherwise quiet.

Re: [Utility] 8F Helper - gbz80aid

Posted by: Yeniaul
Date: 2016-12-16 20:22:35
…why are you running Kali for everyday use?

Re: [Utility] 8F Helper - gbz80aid

Posted by: Stackout
Date: 2016-12-17 05:57:17

…why are you running Kali for everyday use?


FTFY

Re: [Utility] 8F Helper - gbz80aid

Posted by: ISSOtm
Date: 2016-12-17 15:42:26
I have GCC 4.9, if I'm correct (I'm on my Windows right now, so no checking that 'cause I got stuff to do before I reboot).
That might explain.

Re: [Utility] 8F Helper - gbz80aid

Posted by: Cryo
Date: 2016-12-17 19:17:09

…why are you running Kali for everyday use?

Probably PTSD from taking the OSCP and OSCE.


…why are you running Kali for everyday use?


To spread holiday cheer. ;D


I have GCC 4.9, if I'm correct (I'm on my Windows right now, so no checking that 'cause I got stuff to do before I reboot).
That might explain.

Oh yeah, GCC 5 changed the default from 89 to 11. :P

Re: [Utility] 8F Helper - gbz80aid

Posted by: Cryo
Date: 2016-12-21 15:42:08
I apologize for the double post, but I just pushed a pretty big update to the repo that will, among other things, greatly help with determining the inputs for the recently-posted Full Control 8F RAM manipulation method.


Due to an oversight on my end, I had neglected to implement translation for the JP instruction and only supported the JR instruction; it now includes full support for both the JP and JR instructions, even when using custom offsets with the [tt]-ofs[/tt] flag.

The program now supports both the reading and printing of gbz80 ASM in a variety of formats, primarily the BGB formatfor example, the instructions [tt]ldi (hl),a[/tt] and [tt]ld (hl+),a[/tt] are treated as the same instruction and can be output in BGB format by specifying the [tt]-o bgb[/tt] flag.

Most notably, however, the program can now convert gbz80 ASM (and gbz80 machine code) into button presses for use with the Full Control 8F method. In this mode, each line of button presses represents a single byte written to memory, and even calculated the total number of button presses required (just for fun). You can specify this mode with the [tt]-o joy[/tt] flag.


As an example of the 8F Full Control button output, here's a snippet of the output when using the ASM code for credits warping on Super Mario Land 2 from TheZZAZZGlitch's recent ACE video.

SAMPLE OUTPUT:

C:\gbdev>gbz80aid.exe -o joy -f sml2_ace.asm

Joypad Values:

A
DOWN UP LEFT RIGHT B A A
RIGHT SELECT B B
START B A A
DOWN A DOWN DOWN
UP DOWN LEFT RIGHT START SELECT B A A
DOWN UP LEFT RIGHT START SELECT B A A
START B A A
UP LEFT RIGHT START A A
DOWN LEFT RIGHT RIGHT

[92 lines omitted]

LEFT B B
DOWN LEFT START SELECT B A A
LEFT B B
LEFT RIGHT START SELECT B B
DOWN UP RIGHT RIGHT
LEFT B B
DOWN UP B A A
DOWN UP LEFT LEFT
DOWN UP RIGHT RIGHT
START + SELECT

Total number of button presses: 506


If you're interested in testing it out, you can grab the Windows executable all zipped up here.

Re: [Utility] 8F Helper - gbz80aid

Posted by: Torchickens
Date: 2016-12-21 16:19:37
Very cool! It's funny these are button combinations like classic game cheats. What would the Konami code or Up-Down-Left-Right-A+Start give, lol?