Jump to content

Pokémon Red and Blue: Difference between revisions

m
→‎Glitch items: Changed tildes for range to en dashes
m (→‎Names: Another grammar nitpick)
m (→‎Glitch items: Changed tildes for range to en dashes)
Line 35:
* [[Safari Ball (glitch item)|Safari Ball]] (ID 8) exists as an item, even though it is never supposed to appear in the player's inventory. Again, throwing a ball in a Safari Zone battle actually "uses" this item.
* [[Pokédex (glitch item)|Pokédex]] (ID 9) exists as an item, even though it is never supposed to appear in the player's inventory. It is functional, but not actually "used" when the player accesses the Pokédex from the Start menu.
* Items with ID 21~2821–28 have the names of the Gym Badges, from "BoulderBadge" to "EarthBadge". Those names are used to display a list of all badges when the player talks to Cerulean City's badge describer.
** Furthermore, the first two of those, [[BoulderBadge (glitch item)|BoulderBadge]] and [[CascadeBadge (glitch item)|CascadeBadge]], are also "used" in a Safari Zone battle when throwing some bait or throwing a rock, respectively. Those glitch items are also functional in normal wild battles.
** The rest of those items are designed to be unusable anywhere, just like some valid items that are supposed to be checked rather than directly used from the menu (e.g. the [[bp:Helix Fossil|Helix Fossil]]), or exist just to be sold (i.e. the [[bp:Nugget|Nugget]]).
Line 42:
* [[Coin]] (ID 59) is an unusable glitch item.
 
In addition, all items with IDs greater or equal to 196 are considered HMs or TMs, and are handled in a special way. This means that the items with ID 251~255251–255 are named TM51~TM55TM51–TM55, and act as TMs. They actually teach exactly the same moves as HM01~HM05HM01–HM05, to exactly the same Pokémon, because even though the valid HM items have IDs before the TM items, for all other purposes, the HM moves come after the TM moves in the game's internal data. However, since TM51~TM55TM51–TM55 are considered as TMs rather than HMs, they are not key items (i.e. their quantities are displayed in the inventory, and they can be tossed or sold), and are consumed when used. ([[Cancel (Generation I 0xFF glitch item)|TM55]] has some further quirks because it has ID 255, which is also used as the terminator of item lists. Most notably, its name is rendered as "Cancel" in the inventory, and while on-screen it hides the items below it, although it can still be used, tossed, or sold because in those cases the game uses the item count byte to determine whether the player chose the Cancel button.)
 
Apart from the above glitch items, other glitch items have IDs outside of the valid range, i.e. either 0 or 84~19584–195. They take data from mostly unrelated memory regions, as detailed below.
 
=== Names ===
Line 60:
With the exception of TMs and HMs, when an item is used from the menu, the game finds the ''effect pointer'' of said item, and jumps there. Each effect pointer is 2-byte long, and they are stored in a contiguous table<ref>[https://github.com/pret/pokered/blob/fbbade2becdbbbaad787ec4ad957b8b5253498c0/engine/items/item_effects.asm#L18 The table of effect pointers]</ref>. Some valid items, such as all kinds of balls, share the same effect pointer, and the code there will determine exactly which one of them is being used by checking the item ID, which is stored at $CF91.
 
When finding the address of the effect pointer, the game computes (item ID - 1) * 2 to find out the byte offset first, and makes an assumption that this calculation does not underflow or overflow the byte. This assumption is sound for valid non-TM, non-HM items, but not for glitch items with ID 0 or 129~195129–195. This has the effect of "wrapping" the item ID to the 1~1281–128 range by adding or subtracting 128, for the purpose of finding the effect pointer only. As a result, the glitch items with ID 129~195129–195 have the same effect pointers, and thus similar effects, as the corresponding items with ID 1~671–67. The effects may not be completely the same because they may check the exact item ID, or the Rival's effect (see below) may happen.
 
As for glitch items with ID 84~12884–128, their effect pointers are actually the code of the function ItemUseBall<ref>[https://github.com/pret/pokered/blob/fbbade2becdbbbaad787ec4ad957b8b5253498c0/engine/items/item_effects.asm#L104 The function ItemUseBall], which appears just below the effect pointer table</ref>, split into 2-byte words and interpreted as pointers. Some of those 2-byte words are actually pointers: They are the operand of a 3-byte instruction, such as <code>ld a, ($xxyy)</code>, <code>ld hl, $xxyy</code>, or <code>jp z, $xxyy</code>. This is why the aforementioned [[ItemDex/RB:093|8F]] and [[ItemDex/RB:106|-gm]] always jump to the party count and the Safari Ball count respectively, even on various European versions of the game where the RAM layout is slightly different, as well as why [[ItemDex/RB:099|ws m]] in Red and Blue always print the "box is full" message.
 
Other glitch items' effect pointers consist of two separate bytes with usually different meanings in assembly. For example, the effect pointer of [[ItemDex/RB:089|4F]] is $FA65, which comes from two assembly instructions <code>jp nz, $658B</code> and <code>ld a, ($D05A)</code>, encoded as the byte sequence "C2 8B '''65 FA''' 5A D0", and the middle two bytes decoded as a 2-byte pointer in little-endian. This address happens to be in the Echo RAM, and "echos" the WRAM address $DA65, leading to another relatively popular ACE exploit.
Cookies help us deliver our services. By using our services, you agree to our use of cookies.