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

J glitch item - Page 1

J glitch item

Posted by: likebeingawesome
Date: 2017-07-09 13:32:07
I was wondering if I could get more information on this item. Including why it exists between your items and the area with random items when performing item underflow. As well as what it does and why it sells for 414925 pokedollars in sI shops.

Re: J glitch item

Posted by: TheZZAZZGlitch
Date: 2017-07-09 17:12:07
'j.' is a glitch item with hex ID 00.
You get to see it a lot during item underflow, simply because 0 is a popular number and it occurs many times throughout the game's memory. Which is what item underflow really is - viewing the memory beyond inventory data as items.

This item happens to execute code from $01D1, which is in the middle of map header pointers. This garbage code (which isn't really game code, but the game has to interpret it somehow) eventually causes a jump to $BE42, in the middle of SRAM.
It could be potentially used for arbitrary code execution, although only theoretically, since there's no easy way to control data at $BE42 without cheating or resorting to another form of arbitrary code execution.

j.'s sell price of 414925 is completely accidental.
The game keeps a table of all item prices. This table only has 96 entries. Item 0 is actually interpreted as item 256, so the game tries to grab the 256th entry of this list, and ends up reading past the table.
Just so happens, item names are located there, and the game reads the last 3 bytes of "X ACCURACY(end marker)" (0x82, 0x98, 0x50) as an item price.

So, the item's buy price is 829850.
The sell price is dynamically calculated by the game to be the half of the buy price.
829850 divided by 2 is - you guessed it - 414925.

Re: J glitch item

Posted by: likebeingawesome
Date: 2017-07-09 17:16:44
Thanks for telling me this is really cool