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

## Arbitrary Code Execution Discussion

### Game crashes when using 8F - Page 1

Previous Page

- 1

Next Page

#### Game crashes when using 8F

Posted by: Blendy
Date: 2020-02-01 17:27:15
Im using this setup:
Pokemon Red (English)
Party pokemon:
Kanghaskan
223 HP Pidgey
Parasect
Onix
Tentacool
Arbok
And code:
8f
Lemonade x25
TM34 x39
TM11 x1
Burn Heal x1
I used https://eldred.fr/gbz80toitems3/ to convert the asm code to items, (im new to gbz80 coding) my original code was:
ld A, 25
ld ($D327), A
And I was trying to convert the amount of Burn heals to 25
Any clue on why that happens?
Edit: I changed TM11 x1 to TM11 x201 to add ret at the end of the asm code, like this:
ld A, 25
ld ($D327), A
ret
Edit2: As I used $D322 (default in converter) to write the data i added an item at the top of the bag so it starts executing at the 3rd item(lemonade not tm34)

#### Re: Game crashes when using 8F

Posted by: Parzival
Date: 2020-02-01 17:54:14
Are you using 3DS VC?

#### Re: Game crashes when using 8F

Posted by: Blendy
Date: 2020-02-01 18:11:45
No, im in vba link 1.8 (i can transfer the sav to 3dsvc if necessary)

#### Re: Game crashes when using 8F

Posted by: Parzival
Date: 2020-02-02 10:27:01

> No, im in vba link 1.8 (i can transfer the sav to 3dsvc if necessary)

VBA is very bad for people doing anything outside casual play, as the codebase is way less accurate than other emulators. I'd suggest BGB if you want a debugger, or Sameboy if you like RetroArch.

#### Re: Game crashes when using 8F

Posted by: Blendy
Date: 2020-02-02 10:56:02
Oh ok and is there any Code diference between european english ver and non-european english?

#### Re: Game crashes when using 8F

Posted by: Parzival
Date: 2020-02-02 12:41:16

> Oh ok and is there any Code diference between european english ver and non-european english?

Not that I can tell.

#### Re: Game crashes when using 8F

Posted by: iTNZ
Date: 2020-02-02 12:43:58
A 223 pidgey? you mean 233?

#### Re: Game crashes when using 8F

Posted by: Parzival
Date: 2020-02-02 12:52:38

> A 223 pidgey? you mean 233?

I… damn how did i miss that, yeah that might do it

#### Re: Game crashes when using 8F

Posted by: Torchickens
Date: 2020-02-02 13:26:11
Hi :) hope this may help (your suspicions about item 3 are correct). ^^ I've marked what to change in blue.

> Im using this setup:
> Pokemon Red (English)
> Party pokemon: > Looks OK according to this 6 Pokémon setup
> Kanghaskan
> 223 HP Pidgey > Replace with 233 HP as iTNZ pointed out (if not typo)
> Parasect
> Onix
> Tentacool
> Arbok
> And code:
> 8f
> [Have any item 2 here]
> Lemonade x25
> TM34 x41 Unfortunately the reorganisation meant I changed x39 to x41, as the Burn Heal quantity stack is now at item 6 quantity. Hope that's OK, if you want it at item 5 quantity can try to rewrite the code
> TM11 x1 The game is going to run the x1 as a ld bc,xxyy; which is convenient here as Burn Heal x1 is not run as code; the values are loaded for xx and yy. However (see addition of TM01 item)
> Burn Heal x1
> TM01 x(any) Ret (C9) is normally needed to end the code. After the end of the code (can be after a quantity or item, you'll need a x201 or TM01). We normally add a ret (C9 byte), because the game doesn't know where the end of the code is, so it will execute item 7 quantity, 8, and so on and when it encounters code like Cancels (0xFF) that is one way the game can freeze (the full story is more complex but unless you change "sp" rets can reliably mark the end for you). The code otherwise should change item 6 quantity to 25.
> I think this code may need the Lemonade x25 stacks and below to begin at item 3. This is where most codes which use the 'D322' or 'to item 3' setup will start, except for codes that read other quantities as a feature etc. The code unmodified (but beginning at item 3 except 8F should stay at item 1) reads: ld a,19 ld (D327),a ld bc, 010c. > it's now ld a,19 ld (D329),a ld bc,010c ret

#### Re: Game crashes when using 8F

Posted by: Blendy
Date: 2020-02-02 13:34:48
Ow 233 ………
And if i add +2 items after 8f wouldn't It just start at the 2nd item i add? Because 8f is first and 2nd (any) item id third???
And yes i added ret.
Ty all
Edit: Yaaaaaay It works! Now I can start learning z80 being able to test! :D

#### Re: Game crashes when using 8F

Posted by: Torchickens
Date: 2020-02-02 13:48:42

> Ow 233 ………
> And if i add +2 items after 8f wouldn't It just start at the 2nd item i add? Because 8f is first and 2nd (any) item id third???
> And yes i added ret.
> Ty all

In that case there would be a change of +2 only if 8F is item 1 (1+2>3), however if you had it at say item 2, it would be (2+1>3); because technically only item 3 and below's content matter for the code (other than for the stack you use 8F itself). In other words, here the item 3 is the absolute item 3 (not dependent on relatively where you are on the list). Physically you still need 8F at item 1, item 2, or somewhere outside of (in this case, items 3-7) to use the item. However, you could also have say items 3-7 contain the code and the rest of the inventory be anything (except for one slot to have 8F).
Pleasure to help. Happy it worked! ^^
Previous Page

- 1

Next Page