0xabad1dea

infosec sorceress

READ GLORY IN THE THUNDER, WORLD'S #1 SOURCE FOR TRAUMATIZED TEENS WITH TOO MUCH RESPONSIBILITY https://www.wattpad.com/story/343286820-glory-in-the-thunder


rgmechex
@rgmechex

You're probably familiar with the hidden items that are scattered throughout the various Pokemon games. There seems to be nothing on the ground, but if you press the A button, you'll find a (generally pretty good) item.

Collecting a hidden item in Celadon City A lot of these items are kinda obvious like this one, but some aren't so easy to find.

To make these items not completely impossible to search for, each game has a dowsing machine--or at least in the generation 1 games, the ItemFinder. If you use the item while a hidden item is on screen, it will tell you there's something nearby.

Due to a bug (well, six of them), a handful of hidden items can be collected infinitely many times. These include nuggets and rare candies--what a score! The only caveat is that this was only possible in the original releases of Pokemon Red and Green in Japan.


The games have a big list of all of the invisible object triggers in each room. This includes hidden items, but also things like the buttons in the trash cans in Vermillion Gym, the PCs in the Pokemon Centers, etc. Each object has an X and Y coordinate associated with it, which is the tile that has to be inspected by the player in order to process it.

Then there's another separate list of just the hidden items. It lists all 54 hidden items: what map they are on, and their X and Y coordinates within the map. This list is used specifically by the ItemFinder. When you use it, it scans through the list, comparing the map IDs with the currently loaded map ID. If it matches, and the coordinates are 'nearby', and that item hasn't been collected already, then the ItemFinder will go off.

Using the ItemFinder to locate a hidden item in a bush This thing was clunky to use though, so it may be more efficient to just comb the entire map mashing the A button.

This list is also used when you collect a hidden item. Hidden items don't have explicitly defined IDs, their ID is calculated on the fly by determining where they appear in this list. The coordinates of the object trigger you interacted with is compared with each hidden item coordinates. Once a match is found, the index of the matching element is used to set a single bit in a set of bit flags to mark that that particular hidden item has been found.

It's important that these two lists have matching coordinates for each hidden item, or else things would break.

Yeah. Five of the hidden items have non-matching coordinates, and there's a 55th hidden item that just isn't in the list at all. Oops.

MapInvisible Object LocationHidden Item LocationItem
Cerulean Cave 1F$0B, $0E$0B, $0FRare Candy
Cerulean Cave B1F$03, $1B$16, $1DUltra Ball
Copycat's House$06, $00$01, $00Nugget
Pokemon Mansion B1F$09, $01-Rare Candy
Rocket Hideout B3F$11, $1B$17, $16Nugget
Route 13$0D, $10$08, $30Calcium
The coordinates are stored in (Y, X) order.

The invisible object location is where the item actually is and where you can pick it up. Then the game calculates the hidden item's ID so it can mark that you've collected this item. Since all of these items' coordinates aren't present in the second list, they all end up with the same ID of 255.

The fact that they all end up sharing the same ID results in some weird intertwined behavior: if you collect one of these hidden items, you can't collect any of the others. When you grab one, it marks hidden item ID 255 as collected, so you can't collect any hidden item with ID 255 again.

Also, there were only supposed to be 54 hidden items. The game actually has memory allocated for 112 hidden items (14 bytes times 8 bits), so it can keep track of the states of 112 hidden items. Unfortunately, since the hidden item ID here ends up being 255, it indexes this table out of bounds. The bit that ends up being set when collecting any of these items is the highest bit of the fossil identifier.

When you give a fossil to the scientist on Cinnabar Island, this byte holds the ID of the fossil item so the game knows which Pokemon to give you. The possible values are $1F for Old Amber, $2A for Helix Fossil, and $2B for Dome Fossil. Each of these IDs have the highest bit as a zero. This means that the hidden item 255 collected flag can be reset by giving the scientist any fossil. This makes all six hidden items reappear; even the one you just collected!

Talking to the scientist on Cinnabar Island You can have the Pokemon revived, or just donate the fossil for science and the hidden items will come back.

The ItemFinder only uses the second list to detect items. Since the errant hidden items always end up with an ID of 255, the broken hidden items in this list will never be marked as collected. This also means the the ItemFinder will detect hidden items that are not even collectible.

Map showing where the hidden item is in red, and where the ItemFinder thinks the item is in green The red tile denotes where the invisible object is, and the green tile denotes where the hidden item is supposedly located.

For example here in the Rocket Hideout, the hidden item is directly to the right of the visible TM10 item. However, the ItemFinder will produce a false positive for a tile on the right side of the bottom room. This will go off even after collecting the hidden Nugget.

The ItemFinder incorrectly locating a fake hidden item False positive! Maybe this is more accurate to how dowsing machines work in real life.

The hidden item in the Pokemon Mansion is the only one that is just outright missing from the second list, so the ItemFinder will not react to anything on this map.

Map showing where the hidden item is in red The ItemFinder won't help you here.

There's also one on Route 13.

Map showing where the hidden item is in red, and where the ItemFinder thinks the item is in green I feel like putting the item in the fenced off area would have been a better idea anyway.

There's two in Cerulean Cave, one on the main floor, and one on the lower level.

Map showing where the hidden item is in red, and where the ItemFinder thinks the item is in green This one is just off by one tile, frustrating!

The one on the lower level has ItemFinder coordinates that are so far off the bottom of the map that you can't even get close enough for the ItemFinder to react to it at all.

Map showing where the hidden item is in red, and where the ItemFinder thinks the item is in green It's plausible that these errant coordinates are just from an older revision, and they weren't updated when the hidden item was moved. But this one is way out of bounds on this map.

I also learned that Cerulean Cave is completely different in the Japanese releases of Red and Green. The international releases of Red and Blue use a different layout, and the Japanese release of Blue also uses this different layout. Then Pokemon Yellow uses a third layout. I do like that all three layouts still have all the ladders in the same coordinates so that the warping locations didn't have to be updated. Also, the hidden item locations for the original and second versions of the cave are identical as well.

And then there's one in the Copycat's bedroom.

Map showing where the hidden item is in red, and where the ItemFinder thinks the item is in green, and where the updated location of the hidden item is in blue I feel bad snooping around in this girl's room.

This one was all sorts of messed up. The hidden item is in Copycat's bed, but the ItemFinder coordinates are directly on top of her PC, which you can interact with already. Additionally, the ItemFinder doesn't even go off at all for this one due to another bug.

; $1D:4084 - Determine if near hidden item
LD A, [playerYPos]
CALL Sub5Clamp0
CP D
JR NC, loop ; skip if item above top of screen
LD A, [playerYPos]
ADD #4
CP D
JR C, loop ; skip if item below bottom of screen
LD A, [playerXPos]
CALL Sub5Clamp0
CP E
JR NC, loop ; skip if item off screen to the left
LD A, [playerXPos]
ADD #5
CP E
JR C, loop ; skip if item off screen to the right
SCF
RET

Equivalent code can be found in the Gen 1 Pokemon disassembly here. Note that the disassembly is for the international releases, so the misaligned hidden items are fixed here.

This is the code that checks if the player is "near" the hidden item. You have to be within 5 tiles horizontally and 4 tiles vertically for the ItemFinder to go off (basically, the tile it is hidden in must be on screen).

However, due to the logic used, they had to clamp the position of the top and left corner of the screen to zero, to prevent it from overflowing back to 255. The result of this is that hidden items with X or Y coordinates of 0 will never be detected by the ItemFinder. Therefore, the original coordinates (both at the PC and in the bed) were invalid, and the Nugget had to be moved to her desk instead.

It was probably for the best that the item was moved out of her bed anyway! This is a kid's game!


You can support Retro Game Mechanics Explained on Patreon here! Any and all support is greatly appreciated!


You must log in to comment.