Cite as
pret/pokered
Original
https://github.com/pret/pokered
Pinned
pret/pokered @ af519899719f0754965776faac0e836a3b906e6d
Accessed
2026-10-20
Licence
none stated (no LICENSE file; GitHub reports no license)
Credit
The pret community, about 78 GitHub contributors (2026-10-20), led in commit count by kanzure, dannye, Rangi42, iimarckus and yenatch. See https://github.com/pret/pokered/graphs/contributors. The labels and comments quoted in claims (e.g. "bug: should be EFFECTIVE (10)") are theirs.
Notes
Builds the English (UE) Pokémon Red and Blue ROMs (README, roms.sha1: Red ea9bcae6…, Blue d7037c83…), not the Japanese Red/Green. Line numbers in claims refer to the pinned commit.

Cited on

Claims (116)

A ×¼ hit no longer truncates to a miss: 2 damage through two ½ rows gives ⌊2 × 5 / 10⌋ = 1, then ⌊1 × 5 / 10⌋ = 0, raised to 1.engine/battle/core.asm L5162–5176Code
Crystal's table adds Steel and Dark and changes four Red/Blue matchups: Poison→Bug ×2 → ×1, Bug→Poison ×2 → ×½, Ghost→Psychic ×0 → ×2, and Ice→Fire ×1 → ×½.data/types/type_matchups.asm L1–85constants/battle_constants.asm L61–65Code
Crystal's random-number routine is Red and Blue's generator, adding the divider register (with carry) to one byte and subtracting it (with borrow) from a second, but it returns the second where Red and Blue's returns the first; pret's comment says the divider counts at 16,384 Hz.engine/math/random.asm L1–13home/random.asm L1–12Code
Computed, for a Bulbasaur (catch rate 45) with max HP 100 and no status in a Poké Ball: at full HP it is caught about 6.0% of the time in Red and Blue, 6.25% in Crystal, and 6.25% in Emerald; at 1 HP, 18.0%, 17.6%, and 19.8%. Here the three formulas land close together, though they roll twice in Red and Blue, once in Crystal, and up to four times in Emerald.engine/items/item_effects.asm L185–199engine/items/item_effects.asm L241–316data/pokemon/base_stats/bulbasaur.asm L7Code
Gold and Silver's escape formula is Red and Blue's, ⌊32P/(⌊E/4⌋mod256)⌋ plus 30 for each earlier attempt against a random byte, with a held Smoke Ball that always escapes; Crystal adds two battle types, Celebi's and Suicune's, that block escape.engine/battle/core.asm L1496–1612Code
The sound engine runs once a frame from the vertical blank handler. On the four music channels a note lasts ⌊((ℓ⋅smod256)⋅T+f)mod65536/256⌋ frames, where ℓ is its length in 16ths, s the channel's note speed, T the song's 16-bit tempo, and f the channel's leftover fraction, which the low byte carries to the next note: the product ℓ⋅s keeps only its low byte, and the sum only 16 bits. The sound-effect channels use the sound-effect tempo for T instead, and the last of them, the noise channel's, a fixed $0100.home/vblank.asm L59–72audio/engine_1.asm L39–47audio/engine_1.asm L690–737audio/engine_1.asm L1290–1302constants/audio_constants.asm L21–30Code
Channel 3 plays one of six 32-step waveforms, numbered 0 to 5. A song command picks one with its low nibble, and on each note the engine stops the wave channel, copies the 16 bytes into wave RAM, and starts it again.audio/wave_samples.asm L3–16audio/engine_1.asm L343–355audio/engine_1.asm L906–944Code
Every wild Pokémon of a species starts with the same catch rate, its species' (45 for a Bulbasaur): when the battle loads the Pokémon it copies the species' catch-rate byte, and the ball's catch-rate test reads that copy. In the Safari Zone, bait halves the copy and a rock doubles it, up to 255.engine/battle/core.asm L6107–6118ram/wram.asm L1200–1201data/pokemon/base_stats/bulbasaur.asm L7engine/items/item_effects.asm L298–303engine/items/item_effects.asm L1432–1455Code
Every ball but the Master Ball starts with a random first number whose range the ball sets: 0 to 255 for a Poké Ball, 0 to 200 for a Great Ball, and 0 to 150 for an Ultra or Safari Ball. The game draws a random byte and draws again while it is above the ball's limit. A Master Ball draws the byte too but ignores it, and catches without this or any later test.engine/items/item_effects.asm L177–214engine/items/item_effects.asm L318–319Code
A sleeping or frozen Pokémon is easiest to catch, then a burned, paralyzed, or poisoned one. The ball subtracts 25 from its first number for sleep or freeze, 12 for any other status, and nothing without one, and a first number below that amount catches at once: sleep alone catches on 25 of a Poké Ball's 256 first numbers (9.8%) and on 25 of an Ultra Ball's 151 (16.6%) (computed). Otherwise the throw fails when the first number less that amount is above the catch rate, and goes on to the HP test when it isn't.engine/items/item_effects.asm L216–239constants/battle_constants.asm L67–73engine/items/item_effects.asm L298–303Code
The lower the Pokémon's HP, the likelier a throw that passes the catch-rate test (the first number, less the status amount, at most the catch rate) is to catch, and a Great Ball's second test is easier than any other ball's. The ball computes T=⌊⌊255M/F⌋/max⁡(⌊H/4⌋,1)⌋ from the Pokémon's max HP M and current HP H, with F 8 for a Great Ball and 12 for every other ball, each division rounding down. A T over 255 catches; otherwise a second random byte catches when it is at most T. At full HP the second test so passes about a third of the time (about half with a Great Ball), and from roughly a third of max HP down (half with a Great Ball) it always passes (computed).engine/items/item_effects.asm L241–316Code
A Poké Ball catches a Bulbasaur (catch rate 45) with no status and max HP 100 about 6.0% of the time at full HP and 18.0% at 1 HP (computed, counting every value of each random byte as equally likely). Without a status, a throw's chance is min⁡(C+1,N)N⋅min⁡(T+1,256)256: the share of first numbers at most the catch rate C, out of N, 256 for a Poké Ball, 201 for a Great Ball, and 151 for an Ultra or Safari Ball, times the share of second bytes at most T=⌊⌊255M/F⌋/max⁡(⌊H/4⌋,1)⌋, for max HP M, current HP H, and a ball factor F of 8 for a Great Ball and 12 for any other.engine/items/item_effects.asm L185–214engine/items/item_effects.asm L298–316data/pokemon/base_stats/bulbasaur.asm L7engine/items/item_effects.asm L268–281engine/items/item_effects.asm L241–266Code
At full HP a Great Ball can catch more often than an Ultra Ball (computed): against a Bulbasaur (catch rate 45) with max HP 100 and no status, the Great Ball catches about 11.4% of the time and the Ultra Ball about 10.2%. A throw rolls two random numbers from 0 to 255, and on both a low roll is the one that catches. With no status, the first roll must be at or below the species' catch rate, its base-stats byte, which loading the opposing Pokémon copies in; the Great Ball rerolls any first roll above 200 and the Ultra Ball any above 150, so the Ultra Ball's first roll passes at least as often. The second roll must be at or below a target of max HP × 255, divided by 8 for the Great Ball or 12 for the Ultra Ball, then by a quarter of current HP (at least 1); a target above 255 catches with no second roll. The Great Ball's smaller divisor gives it the larger target, and with no status and a catch rate of 200 or more both first rolls always pass, so there the Great Ball never catches less often.data/pokemon/base_stats.asm L1–3data/pokemon/base_stats/bulbasaur.asm L1–7engine/battle/core.asm L5992–5999home/pokemon.asm L401–409ram/wram.asm L1522–1535engine/battle/core.asm L6107–6118ram/wram.asm L1200–1201engine/items/item_effects.asm L185–214engine/items/item_effects.asm L225–227engine/items/item_effects.asm L241–287engine/items/item_effects.asm L300–316Code
A failed throw's shakes depend only on the ball and on the Pokémon's catch rate, HP, and status, so every failed throw of one ball at a Pokémon in the same state shows the same count: no random number feeds it (computed). The game computes Y=⌊100C/B⌋ from the catch rate C, with B 255 for a Poké Ball, 200 for a Great Ball, and 150 for any other, then Z=⌊min⁡(T,255)⋅Y/255⌋ from the HP test's result T, plus 10 for sleep or freeze or 5 for another status. A Z under 10 misses ("You missed the POKéMON!"), under 30 shows one shake ("Darn! The POKéMON broke free!"), under 70 two ("Aww! It appeared to be caught!"), and 70 or more three ("Shoot! It was so close too!"). The code's branch for a Y over 255, which would show three, never runs: Y is at most 170 (computed).engine/items/item_effects.asm L284–303engine/items/item_effects.asm L321–362engine/items/item_effects.asm L363–412engine/items/item_effects.asm L439–455engine/items/item_effects.asm L587–607data/text/text_6.asm L9–27constants/charmap.asm L16Code
A ball thrown at a ghost is dodged ("It dodged the thrown BALL! This POKéMON can't be caught!"): at any wild Pokémon in Pokémon Tower while the Silph Scope isn't in the bag, and at the Marowak on the tower's 6F even with it. A ball thrown in the old man's battle always catches, and that Pokémon isn't added to the player's party, nor is a ball taken from the bag. The ghost tests and the old man's catch both come before any random number is drawn.engine/items/item_effects.asm L149–175engine/battle/core.asm L3309–3324home/map_objects.asm L61–64constants/pokemon_constants.asm L209engine/items/item_effects.asm L439–443data/text/text_6.asm L1–6engine/items/item_effects.asm L512–516engine/items/item_effects.asm L568–579Code
Yellow's catch formula is Red and Blue's: every range, status value, ball factor, shake divisor, and shake threshold quoted here is the same in both. The cases around it differ. Yellow adds the Pikachu battle in Pallet Town at the start of the game, which shows Professor Oak on the player's side: a ball there takes the old man's branch and catches outright, and, as in the old man's battle, the full-party-and-box refusal is skipped and the Pokémon isn't given to the player. In the old man's battle itself, the throw catches outright unless a story flag for the first catch training is set, in which case it skips the catch and takes the three-shake result, $63, the value a failed throw's shake count of 70 or more gets. After every catch it gives the player, Yellow also sets Pikachu's mood.engine/items/item_effects.asm L185–414Code
A Master Ball catches every wild Pokémon but the ghosts, which dodge it as they dodge every ball, unless the party and the current PC box are both full, when no ball can be thrown: after the ghost tests, it skips the catch-rate, status, and HP tests, so neither status nor HP matters. A random byte is drawn before the ball is identified and never used.engine/items/item_effects.asm L149–175engine/items/item_effects.asm L185–195engine/items/item_effects.asm L318–319engine/items/item_effects.asm L115–125constants/pokemon_data_constants.asm L58–60Code
A badly poisoned Pokémon is as easy to catch as a poisoned one. Toxic sets the same poison bit in the status byte as other poisoning moves, plus a separate badly-poisoned flag, and the ball's status tests read only the status byte, so it subtracts 12 from the first number and adds 5 to the shake count, as for any status but sleep or freeze.engine/battle/effects.asm L119–137constants/battle_constants.asm L67–73constants/battle_constants.asm L107–109engine/items/item_effects.asm L224–230engine/items/item_effects.asm L380–386Code
A ball can be thrown only in battle; outside one, Oak says "This isn't the time to use that!". With six Pokémon in the party and 20 in the current PC box, a ball can't be thrown ("The POKéMON BOX is full! Can't use that item!"), except in the old man's battle. Thrown at a trainer's Pokémon, the ball is blocked ("The trainer blocked the BALL!", then "Don't be a thief!") and used up.engine/items/item_effects.asm L106–125constants/pokemon_data_constants.asm L58–60engine/items/item_effects.asm L2274–2311engine/items/item_effects.asm L2321–2351data/text/text_6.asm L190–231Code
Outside the old man's battle, a caught Pokémon ("All right! … was caught!") joins the party with the HP and status it had when the ball hit, or goes to the current PC box when the party is full, with "… was transferred to BILL's PC!" once the player has met Bill and "someone's PC!" before. A species not yet owned is first registered in the Pokédex and its entry shown ("New POKéDEX data will be added for …!").engine/items/item_effects.asm L457–567engine/items/item_effects.asm L499–509engine/items/item_effects.asm L608–630engine/pokemon/add_mon.asm L109–162data/text/text_6.asm L29–57constants/charmap.asm L16engine/items/item_effects.asm L521–539Code
A Pokémon that is transformed when caught is caught as a Ditto at its level, whatever its species: the catch code assumes only a Ditto can be transformed, which a comment in the disassembly calls a bug, since a wild Pokémon could copy Transform with Mirror Move.engine/items/item_effects.asm L471–479engine/items/item_effects.asm L492–499engine/items/item_effects.asm L510–513engine/battle/core.asm L5996–5997Code
A Great Ball costs ¥600 and an Ultra Ball ¥1200, three and six times a Poké Ball's ¥200. The Master, Ultra, Great, Poké, and Safari Balls are all thrown through the same code. The price list gives the Safari Ball ¥1000 and the Master Ball 0.engine/items/item_effects.asm L18–27data/items/prices.asm L1–10Code
A POKé BALL costs ¥200, a GREAT BALL ¥600, and an ULTRA BALL ¥1,200, and the NUGGET is the most expensive item at ¥10,000. A mart charges each of the 83 items a price from one table of 3-byte decimal prices, and each of the 50 TMs a price from a second table that keeps one digit per TM, in thousands (¥1,000 to ¥5,000). A purchase costs the price times the quantity, up to 99 at a time, and a sale pays half of that. Key items and HMs can't be sold, and an HM has no price of its own. Eight items that aren't key items have a price of 0, so they sell for nothing: the MASTER BALL, MOON STONE, EXP.ALL, PP UP, ETHER, MAX ETHER, ELIXER, and MAX ELIXER. The first table goes on past the items with 14 elevator floors, each priced 0.data/items/prices.asm L1–101data/items/tm_prices.asm L1–54data/items/key_items.asm L1–86data/items/names.asm L1–101constants/item_constants.asm L8–115constants/item_constants.asm L119–211home/names.asm L56–68home/item_price.asm L1–38engine/items/tm_prices.asm L1–22engine/battle/misc.asm L85–102home/list_menu.asm L259–285engine/events/pokemart.asm L70–186home/inventory.asm L1–10Code
Red and Blue have 14 mart clerks: one each in Viridian City, Pewter City, Cerulean City, Vermilion City, Lavender Town, Fuchsia City, Cinnabar Island, Saffron City, and Indigo Plateau, and five in the Celadon Dept. Store, two on 2F, one on 4F, and two on 5F, 94 listings in all. A clerk's list runs from 4 items (Viridian City's) to 9. Viridian City's clerk sells only once Oak's Parcel has been delivered. A clerk's text starts with the mart marker, then the number of items, the items, and $FF; the game copies that list into the buy menu, which prices each item from the price table. Two more lists in the same file, a BICYCLE alone and GREAT BALL, HYPER POTION, SUPER POTION, FULL HEAL, and REVIVE, belong to no map's text.data/items/marts.asm L1–50macros/scripts/text.asm L193–201home/text_script.asm L68–78home/text_script.asm L141–171engine/events/pokemart.asm L139–150scripts/PewterMart.asm L9scripts/CeruleanMart.asm L6scripts/VermilionMart.asm L6scripts/LavenderMart.asm L6scripts/CeladonMart2F.asm L6–7scripts/CeladonMart4F.asm L6scripts/CeladonMart5F.asm L8–9scripts/FuchsiaMart.asm L6scripts/CinnabarMart.asm L6scripts/SaffronMart.asm L6scripts/IndigoPlateauLobby.asm L22scripts/ViridianMart.asm L8–76data/maps/objects/CeladonMart2F.asm L19–20data/maps/objects/CeladonMart5F.asm L21–22text/CeladonMart1F.asm L1–4data/maps/names.asm L2–11Code
Poké Balls lying on 44 maps hold 104 items, one each, which the player takes by talking to the ball: 27 hold TMs, 9 a RARE CANDY, 2 an ULTRA BALL, and 1 a POKé BALL (in Viridian Forest), and none a GREAT BALL or a MASTER BALL. All but two lie there from the start: Rocket Hideout B4F's SILPH SCOPE appears once Giovanni is beaten there, and its LIFT KEY once a Rocket is beaten and talked to again. A ball is a map object marked as an item, with the item's number, and its text is the pick-up routine. That routine gives 1 of the item and hides the ball, only if the ball is one of the map's objects that can be hidden, as every one of the 104 is; with a full bag it says so and the ball stays.macros/scripts/maps.asm L16–31home/overworld.asm L2199–2230home/overworld_text.asm L28–31engine/events/pick_up_item.asm L1–45data/maps/objects/CeruleanCave1F.asm L23–25data/maps/objects/CeruleanCave2F.asm L20–22data/maps/objects/CeruleanCaveB1F.asm L16–17data/maps/objects/MtMoon1F.asm L37–42data/maps/objects/MtMoonB2F.asm L31–32data/maps/objects/PokemonMansion1F.asm L23–24data/maps/objects/PokemonMansion2F.asm L20data/maps/objects/PokemonMansion3F.asm L21–22data/maps/objects/PokemonMansionB1F.asm L22–27data/maps/objects/PokemonTower3F.asm L20data/maps/objects/PokemonTower4F.asm L22–24data/maps/objects/PokemonTower5F.asm L24data/maps/objects/PokemonTower6F.asm L21–22data/maps/objects/PowerPlant.asm L37–41data/maps/objects/RocketHideoutB1F.asm L28–29data/maps/objects/RocketHideoutB2F.asm L22–25data/maps/objects/RocketHideoutB3F.asm L19–20data/maps/objects/RocketHideoutB4F.asm L27–31data/maps/objects/Route12.asm L35–36data/maps/objects/Route15.asm L37data/maps/objects/Route2.asm L21–22data/maps/objects/Route24.asm L26data/maps/objects/Route25.asm L32data/maps/objects/Route4.asm L22data/maps/objects/Route9.asm L31data/maps/objects/SSAnne1FRooms.asm L37data/maps/objects/SSAnne2FRooms.asm L41–44data/maps/objects/SSAnneB1FRooms.asm L40–42data/maps/objects/SafariZoneCenter.asm L23data/maps/objects/SafariZoneEast.asm L23–26data/maps/objects/SafariZoneNorth.asm L27–28data/maps/objects/SafariZoneWest.asm L27–30data/maps/objects/SilphCo10F.asm L26–28data/maps/objects/SilphCo3F.asm L28data/maps/objects/SilphCo4F.asm L29–31data/maps/objects/SilphCo5F.asm L34–36data/maps/objects/SilphCo6F.asm L34–35data/maps/objects/SilphCo7F.asm L38–39data/maps/objects/VictoryRoad1F.asm L23–24data/maps/objects/VictoryRoad2F.asm L37–40data/maps/objects/VictoryRoad3F.asm L29–30data/maps/objects/ViridianForest.asm L35–37data/maps/objects/ViridianGym.asm L34data/maps/objects/WardensHouse.asm L19scripts/CeruleanCave1F.asm L6–8scripts/CeruleanCave2F.asm L6–8scripts/CeruleanCaveB1F.asm L19–20scripts/MtMoon1F.asm L25–30scripts/MtMoonB2F.asm L167–168scripts/PokemonMansion1F.asm L67–68scripts/PokemonMansion2F.asm L63scripts/PokemonMansion3F.asm L90–91scripts/PokemonMansionB1F.asm L66–71scripts/PokemonTower3F.asm L21scripts/PokemonTower4F.asm L21–23scripts/PokemonTower5F.asm L59scripts/PokemonTower6F.asm L104–105scripts/PowerPlant.asm L27–31scripts/RocketHideoutB1F.asm L47–48scripts/RocketHideoutB2F.asm L276–279scripts/RocketHideoutB3F.asm L132–133scripts/RocketHideoutB4F.asm L82–86scripts/Route12.asm L74–75scripts/Route15.asm L28scripts/Route2.asm L6–7scripts/Route24.asm L89scripts/Route25.asm L55scripts/Route4.asm L20scripts/Route9.asm L27scripts/SSAnne1FRooms.asm L27scripts/SSAnne2FRooms.asm L26–29scripts/SSAnneB1FRooms.asm L26–28scripts/SafariZoneCenter.asm L6scripts/SafariZoneEast.asm L6–9scripts/SafariZoneNorth.asm L6–7scripts/SafariZoneWest.asm L6–9scripts/SilphCo10F.asm L48–50scripts/SilphCo3F.asm L64scripts/SilphCo4F.asm L101–103scripts/SilphCo5F.asm L81–83scripts/SilphCo6F.asm L53–54scripts/SilphCo7F.asm L277–278scripts/VictoryRoad1F.asm L46–47scripts/VictoryRoad2F.asm L79–82scripts/VictoryRoad3F.asm L84–85scripts/ViridianForest.asm L22–24scripts/ViridianGym.asm L182scripts/WardensHouse.asm L7data/maps/toggleable_objects.asm L81–393scripts/RocketHideoutB4F.asm L54–64scripts/RocketHideoutB4F.asm L188–197data/maps/objects/BluesHouse.asm L17–18Code
Red and Blue hide 54 items on 39 maps, each found once: among them 4 ULTRA BALLs and 2 GREAT BALLs, and no POKé BALL or MASTER BALL. Two stand apart: a NUGGET in the Safari Zone Gate, which a disassembly comment marks inaccessible, and a MAX ELIXER on map $6F, which the disassembly names unused and whose header entry is Lance's room's. Each hidden item is an entry in its map's hidden-event list that calls the hidden-item routine with the item's number; the routine finds the tile's place in a second list of hidden-item tiles, gives 1 of the item unless that place's found flag is set, and then sets it. With a full bag it says so and the item stays.data/events/hidden_events.asm L107–112data/events/hidden_events.asm L41–94data/events/hidden_events.asm L346–598data/events/hidden_item_coords.asm L1–63engine/events/hidden_items.asm L1–45constants/map_constants.asm L185data/maps/map_header_pointers.asm L115Code
The Game Corner prize room trades coins at three counters, and no prize is a ball or any item but a TM. The right counter offers TM23, TM15, and TM50 for 3,300, 5,500, and 7,700 coins in both versions. The left and middle counters offer Pokémon, which differ by version: in Red, ABRA (level 9) for 180 coins, CLEFAIRY (8) for 500, NIDORINA (17) for 1,200, DRATINI (18) for 2,800, SCYTHER (25) for 5,500, and PORYGON (26) for 9,999; in Blue, ABRA (6) for 120, CLEFAIRY (12) for 750, NIDORINO (17) for 1,200, PINSIR (20) for 2,500, DRATINI (24) for 4,600, and PORYGON (18) for 6,500. A TM goes in the bag; a Pokémon is given at the level its version's list sets.data/events/prizes.asm L1–67data/events/prize_mon_levels.asm L1–19data/maps/objects/GameCornerPrizeRoom.asm L13–15scripts/GameCornerPrizeRoom.asm L7–22home/text_script.asm L68–84engine/events/prize_menu.asm L64–71engine/events/prize_menu.asm L204–225engine/events/prize_menu.asm L283–296Makefile L109–110Code
Three vending machines on the Celadon Dept. Store roof sell FRESH WATER for ¥200, SODA POP for ¥300, and LEMONADE for ¥350, one at a time. They check only that the player has ¥200, whatever the drink: a player with less than a drink's price still gets it, and is left with ¥0 (computed from the subtraction, which sets money that would go below zero to zero). A drink comes from its own price list, not the mart price table.data/items/vending_prices.asm L1–10data/maps/objects/CeladonMartRoof.asm L12–14scripts/CeladonMartRoof.asm L213–215scripts/CeladonMartRoof.asm L252–253home/text_script.asm L68–83engine/events/vending_machine.asm L36–72engine/events/vending_machine.asm L87–90engine/events/vending_machine.asm L114–130home/money.asm L1–7engine/math/bcd.asm L196–218Code
Besides the marts, the Poké Balls on maps, the hidden items, the prize counters, and the vending machines, 45 gifts put an item in the bag or the PC: 20 TMs, all 5 HMs, and 20 other items. The only balls among them are the 5 POKé BALLs Prof. Oak gives and the MASTER BALL from the president of Silph Co. on 11F. Each gift is a script whose condition is in its row: the three from Prof. Oak's aides count the species owned against 10, 30, or 50, and a new game starts with a POTION in the PC.home/give.asm L1–16engine/movie/oak_speech/oak_speech.asm L42engine/movie/oak_speech/oak_speech.asm L53–58scripts/OaksLab.asm L965–976scripts/OaksLab.asm L984–989scripts/OaksLab.asm L1022–1026scripts/Route1.asm L14–17scripts/ViridianMart.asm L48–60scripts/BluesHouse.asm L27–41scripts/ViridianCity.asm L235–241scripts/Route2Gate.asm L9–16engine/events/oaks_aide.asm L1–24scripts/Route11Gate2F.asm L19–26scripts/Route15Gate2F.asm L9–16scripts/PewterGym.asm L45–52scripts/MtMoonB2F.asm L239–250scripts/MtMoonB2F.asm L142–150scripts/MtMoonB2F.asm L267–278scripts/Museum1F.asm L191–197scripts/CeruleanGym.asm L45–52scripts/CeruleanCity.asm L305–309scripts/Route24.asm L107–115scripts/BillsHouse.asm L163–169scripts/VermilionGym.asm L64–71scripts/SSAnneCaptainsRoom.asm L18–27scripts/PokemonFanClub.asm L4–12scripts/PokemonFanClub.asm L98–113scripts/BikeShop.asm L10–29scripts/VermilionOldRodHouse.asm L10–20scripts/CeladonCity.asm L45–51scripts/CeladonDiner.asm L30–36scripts/CeladonMart3F.asm L25–31scripts/CeladonMartRoof.asm L84–85scripts/CeladonMartRoof.asm L114–121scripts/CeladonMartRoof.asm L86–87scripts/CeladonMartRoof.asm L101–108scripts/CeladonMartRoof.asm L88–95scripts/CeladonGym.asm L45–52scripts/MrFujisHouse.asm L71–77scripts/Route12Gate2F.asm L11–17scripts/Route12SuperRodHouse.asm L10–20scripts/Route16FlyHouse.asm L10–17scripts/FuchsiaGoodRodHouse.asm L10–20scripts/FuchsiaGym.asm L47–54scripts/SafariZoneSecretHouse.asm L9–15scripts/WardensHouse.asm L32–43scripts/MrPsychicsHouse.asm L9–15scripts/SilphCo2F.asm L116–122scripts/SilphCo11F.asm L293–304scripts/SaffronGym.asm L45–52scripts/CopycatsHouse2F.asm L14–28scripts/CinnabarLabMetronomeRoom.asm L13–19scripts/CinnabarGym.asm L145–152scripts/ViridianGym.asm L137–144Code
POKé BALLs sell in Viridian City (once Oak's Parcel is delivered), Pewter City, Cerulean City, and Vermilion City; GREAT BALLs in Lavender Town, the Celadon Dept. Store (2F, left clerk), Fuchsia City, Cinnabar Island, Saffron City, and Indigo Plateau; and ULTRA BALLs in Fuchsia City, Cinnabar Island, and Indigo Plateau. No mart sells a MASTER BALL or a SAFARI BALL.data/items/marts.asm L4–50Code
The president of Silph Co. on 11F is the only source of a MASTER BALL: he gives one, once. No mart sells one, no Poké Ball on a map or hidden item holds one, the prize counters and the vending machines offer none, and no other script gives one. In the disassembly's debug build of Blue, a separate ROM, the debug menu's DEBUG choice starts a new game with 99.scripts/SilphCo11F.asm L293–304engine/debug/debug_party.asm L34–160engine/debug/debug_menu.asm L1–70engine/overworld/special_warps.asm L10–13Makefile L109–111Code
In the Safari Zone the wild Pokémon never attacks. Every battle in the Safari Zone's four areas is a Safari battle, whose menu offers BALL×, BAIT, THROW ROCK, and RUN in place of the usual commands. After each of the player's actions that doesn't end the battle, the Pokémon either flees or the menu comes back; no move is ever chosen for either side.engine/battle/init_battle_variables.asm L30–36constants/map_constants.asm L355–359data/text_boxes.asm L72–74engine/battle/core.asm L158–173engine/battle/core.asm L203–207Code
Bait makes a Pokémon harder to catch and a rock easier. Bait halves its catch rate, rounded down, and a rock doubles it, up to 255; each throw works on the rate the last one left, so a Chansey's 30 becomes 15 after bait and 60 after a rock. Halving has no floor: six baits take a catch rate of 45 to 0 (computed), and with no status a rate of 0 still passes the catch-rate test, in which the ball's first random number, less the status amount, must not be above the catch rate, when that first number is 0. When the angry count runs out, the rate returns to the species' own value, undoing every bait and rock before it. When the eating count runs out, the rate stays where the bait left it, and bait thrown at an angry Pokémon clears the angry count without resetting the rate, as a rock thrown at an eating one clears the eating count.engine/items/item_effects.asm L1433–1465engine/battle/safari_zone.asm L1–28engine/items/item_effects.asm L298–303data/pokemon/base_stats/chansey.asm L7data/text/text_6.asm L84–91ram/wram.asm L479–480Code
Bait makes the Pokémon eat and a rock makes it angry, each for 1 to 5 more turns, and each ends the other: bait clears the angry count and a rock the eating count. The turns added are a random byte's low three bits, redrawn until under 5, plus 1, and a count stops at 255. After each of the player's actions that doesn't end the battle, the game prints "Wild CHANSEY is eating!" (with the Pokémon's name) and takes a turn off the eating count; when the Pokémon isn't eating, it prints "Wild CHANSEY is angry!" and takes one off the angry count, and with neither count it prints nothing.engine/items/item_effects.asm L1433–1481engine/battle/safari_zone.asm L1–36engine/battle/core.asm L174–181ram/wram.asm L479–480data/text/text_2.asm L1329–1341Code
A Safari Pokémon flees more often the faster it is, much less often while eating, and more often while angry: at a speed of 50 it flees about 39% of the time (100 in 256), 9.8% while eating, and 78% while angry (computed). After each of the player's actions that doesn't end the battle, it flees ("Wild CHANSEY ran!") when a random byte is below a threshold b, so with chance b/256. b starts at twice its speed (the speed's low byte, all of any speed under 256), and a low byte of 128 or more makes it flee at once. While it is eating, b is divided by 4, rounded down; while it is angry, b is doubled, up to 255. The count is taken off before the roll, so bait that adds n eating turns lowers the chance on n−1 of them (computed).engine/battle/core.asm L181–207engine/battle/core.asm L254–270data/text/text_2.asm L832–837engine/battle/safari_zone.asm L1–14Code
A Safari Ball catches exactly as an Ultra Ball does: its first roll is redrawn until it is at most 150, its HP check uses a ball factor of 12, and a missed throw counts its shakes against 150. Each throw takes one of the Safari Balls the gate hands out instead of a ball from the bag.engine/items/item_effects.asm L130–137engine/items/item_effects.asm L185–214engine/items/item_effects.asm L252–258engine/items/item_effects.asm L335–349engine/items/item_effects.asm L576–579constants/battle_constants.asm L48–50engine/battle/core.asm L2163–2165scripts/SafariZoneGate.asm L186–187Code
A Safari Zone encounter ends in one of four ways: a catch; the Pokémon fleeing; the player choosing RUN, which in the Safari Zone always gets away ("Got away safely!"); or a missed throw with the last Safari Ball, after which the PA announces "Ding-dong! You are out of SAFARI BALLs!" and the battle ends before the flee check.engine/battle/core.asm L168–181engine/battle/core.asm L2270–2295engine/battle/core.asm L1496–1501engine/battle/core.asm L1602–1611data/text/text_2.asm L947–948data/text/text_2.asm L825–830engine/battle/core.asm L203–207Code
A Safari Game costs ¥500 and gives 30 Safari Balls and a step counter that starts at 502, shown out of 500. Each step takes one off, and a step that finds the counter at 0 ends the game ("PA: Ding-dong! Time's up!"); running out of Safari Balls ends it as soon as the player is back on the map. Either way the PA says "Your SAFARI GAME is over!" and the player is sent back to the gate.scripts/SafariZoneGate.asm L158–191text/SafariZoneGate.asm L6–7engine/overworld/player_state.asm L251–252home/overworld.asm L53–56home/overworld.asm L307–312engine/events/hidden_events/safari_game.asm L1–80data/text/text_2.asm L310–318engine/overworld/player_state.asm L219–235Code
Pokémon Red and Blue keep one copy of the game in battery-backed cartridge RAM (the player's name, the main data, the map's sprites, the party, the current PC box, and one byte for tile animations), followed by a check byte that is the complement of the 8-bit sum of all those bytes.ram/sram.asm L12–24engine/menus/save.asm L290–310engine/menus/save.asm L237–240Code
When Pokémon Red and Blue load, they recompute the save's one check byte over all the saved game data before copying each of three parts (the first check is tried twice before giving up), and on a mismatch print "The file data is destroyed!", wait 100 frames, and set the save status to 1, which the main menu treats as no save file. The failure path doesn't write to the save: the check turns cartridge RAM off before it returns, so before the message prints, and the path's one store is the status byte, in work RAM.engine/menus/save.asm L1–57data/text/text_3.asm L1–3engine/menus/main_menu.asm L32–34engine/menus/save.asm L93–99engine/menus/save.asm L114–120engine/menus/save.asm L132–141constants/hardware.inc L816ram/wram.asm L1382Code
A wild Pokémon enters battle at full HP with no status. Its max HP is ⌊2(B+D)L/100⌋+L+10, capped at 999, where B is its species' base HP, L its level, and D its HP DV, with no stat-experience bonus. A DV is a hidden value from 0 to 15 that each Pokémon has for each stat. A wild Pokémon's attack, defense, speed, and special DVs are the four 4-bit halves of two random bytes drawn when the battle loads it, and its HP DV takes the lowest bit of each: 8 from attack, 4 from defense, 2 from speed, and 1 from special. A level 5 Bulbasaur (base HP 45) so has 19 to 21 max HP (computed). A trainer's Pokémon gets fixed DVs and keeps its party HP and status instead, and a transformed one keeps the DVs it had before transforming.engine/battle/core.asm L6000–6027engine/battle/core.asm L6029–6043engine/battle/core.asm L6543–6548home/move_mon.asm L49–71home/move_mon.asm L109–153home/move_mon.asm L154–227constants/battle_constants.asm L75data/pokemon/base_stats/bulbasaur.asm L3–4engine/battle/core.asm L6044–6059Code
The game's name text uses one byte a character: capitals A to Z from $80, lowercase a to z from $A0, digits 0 to 9 from $F6, and $7F for a space; é is $BA, and $BB to $BF and $E4 and $E5 each hold an apostrophe with a letter ('d, 'l, 's, 't, 'v, 'r, 'm). A name ends at $50.constants/charmap.asm L90–93constants/charmap.asm L63constants/charmap.asm L12constants/charmap.asm L126constants/charmap.asm L153–154constants/charmap.asm L165constants/charmap.asm L187Code
The game numbers 27 types, of which 15 have their own name: NORMAL to GHOST as 0 to 8, and FIRE to DRAGON as 20 to 26. Type 6 is named BIRD, and numbers 9 to 19 all point at NORMAL's name.data/types/names.asm L1–24constants/type_constants.asm L11–20Code
The 165 moves, by move number, each with its name, effect number, power, type, accuracy (a byte out of 255), and PP. 99 have a power above 1, up to EXPLOSION's 170; nine have a power of 1 (among them GUILLOTINE, SEISMIC TOSS, and DRAGON RAGE), and 57 have none. 78 of the moves are NORMAL. The lowest accuracy is 76 in 255, about 30%, for GUILLOTINE, HORN DRILL, and FISSURE; 104 moves have 255. PP runs from 5 to 40 in steps of 5.data/moves/moves.asm L1–14data/moves/names.asm L1–4macros/data.asm L3Code
The game numbers its species 1 to 190 in an internal order that starts with RHYDON, KANGASKHAN, and NIDORAN♂, not the Pokédex's. 151 of the numbers are Pokémon, each with its Pokédex number in a second table, and the other 39 are named MISSINGNO. and have Pokédex number 0.data/pokemon/names.asm L1–4data/pokemon/dex_order.asm L1–4Code
The 151 Pokémon's base data, in Pokédex order: five base stats, two types (89 Pokémon have one type, listed twice), catch rate, base experience, the moves it knows at level 1, and its growth rate. The five base stats add up to between 175 (CATERPIE and WEEDLE) and 590 (MEWTWO); MEW and DRAGONITE come next at 500. 80 Pokémon grow at the medium-fast rate, 40 medium-slow, 26 slow, and 5 fast; no Pokémon uses the other two of the six rates. Catch rate runs from 3 (ARTICUNO, ZAPDOS, MOLTRES, and MEWTWO) to 255 (fifteen Pokémon), and base HP from 10 (DIGLETT) to 250 (CHANSEY).data/pokemon/base_stats/bulbasaur.asm L1–22data/pokemon/mew.asm L13–14constants/pokemon_data_constants.asm L86–92Code
The 50 TMs and 5 HMs, each the move it teaches, in the order of the TM/HM bits in a Pokémon's base data: TM01 to TM50, then HM01 to HM05.data/moves/tmhm_moves.asm L3–13constants/item_constants.asm L124–137constants/item_constants.asm L150–158macros/data.asm L17–28data/pokemon/base_stats/bulbasaur.asm L11–15Code
The type chart is a list of 82 matchups, each an attacking type, a defending type, and a multiplier: 38 of 2, 38 of 0.5, and 6 of 0. GHOST against PSYCHIC is listed as 0, POISON against BUG and BUG against POISON as 2 each way, and ICE against FIRE isn't listed.data/types/type_matchups.asm L1–4data/types/type_matchups.asm L78data/types/type_matchups.asm L48data/types/type_matchups.asm L70Code
The 97 items numbered $01 to $61, by item number, each with its name and its mart price, stored as six decimal digits in three bytes. 45 have a price above 0, the highest the NUGGET's 10,000; the last 14 are named as floors (B2F to 11F and B4F), each priced 0.data/items/names.asm L1–4data/items/prices.asm L1–4macros/data.asm L10–14data/items/key_items.asm L1–4Code
The 16 mart lists, in the order they're stored: each a $FE byte, the text command (TX_SCRIPT_MART) that the game's text routine sends to the mart dialogue, then a count and that many item numbers, from 1 item (a BICYCLE alone, in a list pret marks unreferenced) to 9. The second clerk on Celadon Dept. Store 2F sells nine TMs, item numbers $C9 and up; the item table has no row for them, so those cells show the raw item numbers.data/items/marts.asm L1–50macros/scripts/text.asm L194–201constants/item_constants.asm L150–161macros/scripts/text.asm L193home/text_script.asm L78Code
The six growth rates, each a formula in the level n, (a/b)n³ + cn² + dn − e, from four bytes: medium fast is n³; slightly fast (3/4)n³ + 10n² − 30; slightly slow (3/4)n³ + 20n² − 70; medium slow (6/5)n³ − 15n² + 100n − 140; fast (4/5)n³; and slow (5/4)n³.data/growth_rates.asm L1–21Code
Red and Blue have 57 lists of wild Pokémon, 570 rows in all: 55 for grass and cave floors, one map each, and two for water, one shared by Routes 19 and 20 and one for Route 21. Each list holds its encounter rate and ten slots, each a level and a species. Grass rates run from 8 (Viridian Forest) to 30 (the Safari Zone); both water lists are all Tentacool, at rate 5. The versions differ in 175 rows across 34 lists, always in the species, and in one row the level too: Pokémon Mansion B1F's slot 8 holds a level-42 Weezing in Red and a level-38 Magmar in Blue. A slot's chance is the same on every list. The species' names are as the game prints them.data/wild/maps/Route1.asm L1–16data/wild/maps/Route2.asm L1–25data/wild/maps/Route3.asm L1–16data/wild/maps/Route4.asm L1–27data/wild/maps/Route5.asm L1–30data/wild/maps/Route6.asm L1–30data/wild/maps/Route7.asm L1–29data/wild/maps/Route8.asm L1–29data/wild/maps/Route9.asm L1–27data/wild/maps/Route10.asm L1–27data/wild/maps/Route11.asm L1–27data/wild/maps/Route12.asm L1–30data/wild/maps/Route13.asm L1–30data/wild/maps/Route14.asm L1–28data/wild/maps/Route15.asm L1–28data/wild/maps/Route16.asm L1–16data/wild/maps/Route17.asm L1–16data/wild/maps/Route18.asm L1–16data/wild/maps/SeaRoutes.asm L1–16data/wild/maps/Route21.asm L1–26data/wild/maps/Route22.asm L1–29data/wild/maps/Route23.asm L1–26data/wild/maps/Route24.asm L1–27data/wild/maps/Route25.asm L1–30data/wild/maps/ViridianForest.asm L1–28data/wild/maps/MtMoon1F.asm L1–16data/wild/maps/MtMoonB1F.asm L1–16data/wild/maps/MtMoonB2F.asm L1–16data/wild/maps/RockTunnel1F.asm L1–16data/wild/maps/PowerPlant.asm L1–22data/wild/maps/VictoryRoad1F.asm L1–16data/wild/maps/PokemonTower1F.asm L1–6data/wild/maps/PokemonTower2F.asm L1–6data/wild/maps/PokemonTower3F.asm L1–16data/wild/maps/PokemonTower4F.asm L1–16data/wild/maps/PokemonTower5F.asm L1–16data/wild/maps/PokemonTower6F.asm L1–16data/wild/maps/PokemonTower7F.asm L1–16data/wild/maps/SeafoamIslandsB1F.asm L1–30data/wild/maps/SeafoamIslandsB2F.asm L1–29data/wild/maps/SeafoamIslandsB3F.asm L1–29data/wild/maps/SeafoamIslandsB4F.asm L1–29data/wild/maps/PokemonMansion1F.asm L1–30data/wild/maps/SeafoamIslands1F.asm L1–29data/wild/maps/VictoryRoad2F.asm L1–16data/wild/maps/DiglettsCave.asm L1–16data/wild/maps/VictoryRoad3F.asm L1–16data/wild/maps/PokemonMansion2F.asm L1–30data/wild/maps/PokemonMansion3F.asm L1–30data/wild/maps/PokemonMansionB1F.asm L1–30data/wild/maps/SafariZoneEast.asm L1–30data/wild/maps/SafariZoneNorth.asm L1–27data/wild/maps/SafariZoneWest.asm L1–27data/wild/maps/SafariZoneCenter.asm L1–29data/wild/maps/CeruleanCave2F.asm L1–16data/wild/maps/CeruleanCaveB1F.asm L1–21data/wild/maps/CeruleanCave1F.asm L1–21data/wild/maps/RockTunnelB1F.asm L1–16engine/overworld/wild_mons.asm L1–31data/wild/grass_water.asm L254–263data/wild/grass_water.asm L33–34Code
The Good Rod's list has two entries, a level-10 Goldeen and a level-10 Poliwag, on every map.data/wild/good_rod.asm L1–5Code
In caves, Pokémon Tower, the Power Plant, and Pokémon Mansion every step off water can start a wild battle; on routes, in Viridian Forest, and in the Safari Zone only a step in grass or on water can. A turn rolls as a step does: pressing a direction other than the last one walked, from standing, first turns the player in place, and the same check runs on the tile the player stands on, before any step. The tile decides: the tileset's grass tile rolls against the map's grass rate and a water tile ($14) against its water rate. Any other tile rolls against the grass rate on an indoor map, by map number, unless the map uses the forest tileset, as Viridian Forest and the four Safari Zone areas do; outdoors it doesn't roll. Only the overworld, forest, and plateau tilesets have a grass tile.engine/battle/wild_encounters.asm L26–47data/tilesets/tileset_headers.asm L1–36constants/map_constants.asm L66–69data/maps/headers/ViridianForest.asm L1data/maps/headers/MtMoon1F.asm L1data/maps/headers/MtMoonB1F.asm L1data/maps/headers/MtMoonB2F.asm L1data/maps/headers/RockTunnel1F.asm L1data/maps/headers/PowerPlant.asm L1data/maps/headers/VictoryRoad1F.asm L1data/maps/headers/PokemonTower3F.asm L1data/maps/headers/PokemonTower4F.asm L1data/maps/headers/PokemonTower5F.asm L1data/maps/headers/PokemonTower6F.asm L1data/maps/headers/PokemonTower7F.asm L1data/maps/headers/SeafoamIslandsB1F.asm L1data/maps/headers/SeafoamIslandsB2F.asm L1data/maps/headers/SeafoamIslandsB3F.asm L1data/maps/headers/SeafoamIslandsB4F.asm L1data/maps/headers/PokemonMansion1F.asm L1data/maps/headers/SeafoamIslands1F.asm L1data/maps/headers/VictoryRoad2F.asm L1data/maps/headers/DiglettsCave.asm L1data/maps/headers/VictoryRoad3F.asm L1data/maps/headers/PokemonMansion2F.asm L1data/maps/headers/PokemonMansion3F.asm L1data/maps/headers/PokemonMansionB1F.asm L1data/maps/headers/SafariZoneEast.asm L1data/maps/headers/SafariZoneNorth.asm L1data/maps/headers/SafariZoneWest.asm L1data/maps/headers/SafariZoneCenter.asm L1data/maps/headers/CeruleanCave2F.asm L1data/maps/headers/CeruleanCaveB1F.asm L1data/maps/headers/CeruleanCave1F.asm L1data/maps/headers/RockTunnelB1F.asm L1home/overworld.asm L132–145home/overworld.asm L179–234Code
On a shore half-block whose water lies only at its bottom right, such as Cinnabar Island's east coast (by the comment), a step rolls at the water rate but meets a Pokémon from the grass list. The rate comes from the half-block's bottom-right tile and the list from its bottom-left tile: the water list only when that tile is water ($14) as well, the grass list otherwise.engine/battle/wild_encounters.asm L63–73Code
Surfing on open water meets only Tentacool, of levels 5 to 40, on Routes 19, 20, and 21: theirs are the only water lists. Every other map loads a water rate of 0, which no random byte is below, the water in Seafoam Islands and Cerulean Cave included; the water tile is $14 in every tileset that has water (by the comment). A left-shore half-block rolls at the water rate but draws from the grass list.engine/overworld/wild_mons.asm L24–28engine/battle/wild_encounters.asm L34–37engine/battle/wild_encounters.asm L48–53Code
The slot byte picks slot 0 for 0–50, 1 for 51–101, 2 for 102–140, 3 for 141–165, 4 for 166–190, 5 for 191–215, 6 for 216–228, 7 for 229–241, 8 for 242–252, and 9 for 253–255. The slot table holds each slot's running total of chances less 1, and the byte takes the first slot whose entry it doesn't pass; the step then reads that slot's level and species from the list.data/wild/probabilities.asm L1–9data/wild/probabilities.asm L17–26engine/battle/wild_encounters.asm L54–62engine/battle/wild_encounters.asm L74–80Code
Some steps can't start a wild battle wherever they are: the two after a battle, a step while a character's scripted movement runs, a ledge jump, a step out of a door, a step that ends on a door or warp tile, and a step past the map's edge. A turn in place runs the same check and the same limits hold for it, but a turn doesn't count the post-battle cooldown down, since only a finished step does: during the cooldown a turn neither rolls nor shortens it. Those steps and turns also leave a Repel's count alone.engine/battle/wild_encounters.asm L1–18engine/battle/core.asm L6661–6664Code
A Repel lasts 100 steps, a Super Repel 200, and a Max Repel 250, counted on every step, and every turn in place, that the encounter check runs on, in towns and on paths as well as in grass. Using one outside battle sets the count, replacing what was left. On the step or turn the count reaches 0 the game prints "REPEL's effect wore off." and meets nothing.engine/items/item_effects.asm L1532–1541engine/items/item_effects.asm L1622–1628engine/battle/wild_encounters.asm L19–25engine/battle/wild_encounters.asm L90–99data/text/text_4.asm L20–23Code
While a Repel lasts, a wild Pokémon below the level of the first Pokémon in the party is turned away, and one at that level or above still appears, so battles come less often. The rate roll and the slot pick run first and are unchanged: a Repel alters neither how often they turn up a Pokémon nor which one, and a slot below the leader's level then ends the step with no battle. The first Pokémon's level counts even if it has fainted.engine/battle/wild_encounters.asm L81–89Code
The Old Rod always gets a bite, and it is always a level-5 Magikarp.engine/items/item_effects.asm L1826–1831Code
Wherever a rod works, a Good Rod cast gets a bite one time in three, a Goldeen or a Poliwag equally (counting each random byte as equally likely and each draw as independent). An odd byte ends the cast with no bite; an even byte bites when its next two bits make 0 or 1, picking that entry, and draws again otherwise, so 64 of the 192 values that end a cast bite.engine/items/item_effects.asm L1833–1857Code
The Super Rod's lists give 33 maps two to four entries each, 109 rows in all, the same in both versions; on any other map it finds nothing. Ten lists are shared among those maps, and every entry is level 15 except Cerulean Cave's and Route 23's four at level 23, Celadon City's and Route 10's Poliwhirl and Fuchsia City's Seaking at 23, and a level-5 Tentacool on Routes 12, 13, 17, and 18. Its only Dratini are in the Safari Zone.data/wild/super_rod.asm L1–101Code
A Super Rod cast bites half the time on a map whose list has four entries, 3 times in 7 with three, and once in 3 with two, every entry equally likely (counting each random byte as equally likely and each draw as independent). An odd byte ends the cast with no bite; an even byte's next two bits pick an entry, and a number past the map's list draws again.engine/items/item_effects.asm L2855–2898engine/items/item_effects.asm L1861–1865Code
A rod works only outside battle, facing water or a shore (at Vermilion Dock, water only), and not while surfing. A bite starts its battle at once, without the step's checks, so neither the cooldown after a battle nor a Repel stops a hooked Pokémon.engine/items/item_effects.asm L1891–1916engine/items/item_effects.asm L2826–2851engine/items/item_effects.asm L1866–1877home/overworld.asm L64–66engine/battle/core.asm L6642–6651Code
Red and Blue's type chart has 82 non-neutral (attacker, defender, multiplier) rows over 15 types, ended by -1; unlisted pairs are neutral.data/types/type_matchups.asm L1–85constants/type_constants.asm L1–28Code
Multipliers are integers scaled by 10 (20 for “super effective”, 05 for “not very effective”, and 00 for no effect); the table never uses 10 (effective) or 15 (more effective).constants/battle_constants.asm L60–65Code
The type-adjustment routine applies STAB before any type row: damage+⌊damage/2⌋ when the move's type matches either attacker type.engine/battle/core.asm L5101–5125Code
In table order, each type chart row matching the move's type and either defender type sets damage to ⌊damage×value/10⌋; 0 marks a miss.engine/battle/core.asm L5127–5185Code
Under two ½ rows (×¼), 2 or 3 damage truncates to 0 and the move misses; 4 damage gives 1.engine/battle/core.asm L5150–5176constants/battle_constants.asm L64data/types/type_matchups.asm L14data/types/type_matchups.asm L30Code
Truncating after each row can cost a hit that nets ×1 damage when its ½ row comes first: Ice against Water/Flying takes 3 to ⌊3 × 5 / 10⌋ = 1, then ⌊1 × 20 / 10⌋ = 2, not 3.data/types/type_matchups.asm L33–36engine/battle/core.asm L5150–5170constants/battle_constants.asm L61–64Code
The Red/Blue type chart gives Ghost-type moves no effect on Psychic types.data/types/type_matchups.asm L78Code
In Red and Blue, a Saffron Gym trainer's after-battle line, “Psychic #MON fear only ghosts and bugs!”, contradicts the game's own type chart, under which Ghost-type moves have no effect on Psychic types.text/SaffronGym.asm L135–139Code
Each matching row overwrites one damage-multiplier byte, so the text follows the last row: above 10 is “super effective”, below 10 “not very effective”, and a miss reads “doesn't affect” only at 0.engine/battle/core.asm L5147–5153engine/battle/display_effectiveness.asm L1–10engine/battle/core.asm L3718–3733engine/battle/core.asm L3218–3229Code
An Ice move against a Water/Flying Pokémon nets ×1 damage, a ½ row and then a 2× row, yet prints “It's super effective!”, since the message reads only the last matching row's value, 20, and compares it with 10.data/types/type_matchups.asm L33–36engine/battle/core.asm L5147–5153constants/battle_constants.asm L61–63engine/battle/display_effectiveness.asm L1–8data/text/text_2.asm L1319–1321Code
Earthquake against a Rock/Flying Pokémon does 0 damage and prints that the attack missed, not “It doesn't affect”: the Ground-against-Flying row (×0) zeroes the damage and makes the move miss, but the message reads the last matching row's value, Ground against Rock's ×2, and only a 0 there picks “doesn't affect”.data/moves/moves.asm L102data/types/type_matchups.asm L9data/types/type_matchups.asm L55constants/battle_constants.asm L61–65engine/battle/core.asm L5150–5176engine/battle/core.asm L3218–3221engine/battle/core.asm L3725–3733data/text/text_2.asm L1122–1140Code
Moves on the set-damage list (Sonic Boom, Seismic Toss, Dragon Rage, Night Shade, Psywave, and Super Fang) jump to the hit test, skipping the base-damage routine and the type-adjustment routine, the only damage routine that reads the type chart.engine/battle/core.asm L3134–3139data/battle/set_damage_effects.asm L1–6data/moves/moves.asm L62Code
The trainer AI's type-effectiveness lookup stops at the first row matching either defender type, ignoring dual-type products.engine/battle/core.asm L5187–5223engine/battle/trainer_ai.asm L207–216Code
The type constants still define a Bird type ($06), with a name string, but no type chart row names it.constants/type_constants.asm L11data/types/names.asm L40Code
Type picks the stats: Fire, Water, Grass, Electric, Psychic, Ice, and Dragon (the first special type upward) use Special on both sides; the rest use Attack against Defense.engine/battle/core.asm L4040–4042constants/type_constants.asm L19–26Code
In Red and Blue, a damaging move runs the critical-hit test, the base formula, the type adjustment (STAB, then type rows), the random factor, and then the hit test (accuracy).engine/battle/core.asm L3140–3150engine/battle/core.asm L5531–5543Code
The base-damage routine computes ⌊⌊(⌊2×Level/5⌋+2)×Power×Attack/Defense⌋/50⌋, caps it at 997, and adds 2, so the type step receives 2–999. For a move with the explode effect it halves Defense first (to at least 1).engine/battle/core.asm L4299–4318engine/battle/core.asm L4343–4459engine/battle/core.asm L4030–4034constants/battle_constants.asm L53–54Code
The damage-randomizing routine multiplies damage by a random byte, 217–255, and integer-divides by 255, leaving 0 or 1 damage untouched.engine/battle/core.asm L5420–5454macros/data.asm L3Code
The critical-hit test makes a hit critical when a random byte is below a threshold set by the attacker's base Speed S: ⌊S/2⌋ for most moves, and min⁡(255,8⌊S/2⌋) for Karate Chop, Razor Leaf, Crabhammer, and Slash.engine/battle/core.asm L4478–4544data/battle/critical_hit_moves.asm L1–6Code
Without Focus Energy, a Pokémon with base Speed 115, such as Persian, lands a critical hit on 57 of 256 rolls with most moves and on 255 of 256 with Slash.data/pokemon/base_stats/persian.asm L3–4engine/battle/core.asm L4489–4539data/battle/critical_hit_moves.asm L1–6Code
Focus Energy cuts the critical-hit chance to about a quarter instead of raising it: for most moves the threshold becomes ⌊S/8⌋ in 256, where S is the attacker's base Speed, against ⌊S/2⌋ without it, because the code halves a value it should double; a comment in pret's disassembly marks this as a bug.engine/battle/core.asm L4489–4524Code
A critical hit doubles the attacker's level in the damage formula and ignores stat stages, Reflect, and Light Screen: the player's Pokémon's attacking or defending stat comes from its party data, and the opponent's is recomputed from its base stat, level, and DVs, without stat experience, or read from its party data in a link battle.engine/battle/core.asm L4044–4072engine/battle/core.asm L4074–4099engine/battle/core.asm L4131–4136engine/battle/core.asm L4162–4216engine/battle/core.asm L4244–4249engine/battle/core.asm L4258–4295home/move_mon.asm L54–71engine/battle/core.asm L6382–6443Code
Red and Blue store a move's accuracy as a byte, ⌊255p/100⌋ for p percent, so 100% is 255 and 85% is 216.data/moves/moves.asm L1–8macros/data.asm L3Code
The hit test lands a move when a random byte is below its accuracy byte, so even a 100% move misses 1 time in 256.engine/battle/core.asm L5321–5327Code
The hit-chance routine multiplies the accuracy byte by the attacker's accuracy-stage ratio and then by the defender's evasion-stage ratio, read in reverse; it truncates after each step, keeps at least 1, and caps the result at 255.engine/battle/core.asm L5348–5418data/battle/stat_modifiers.asm L1–15Code
Swift returns from the hit test before any check, so it never misses, even against a Pokémon in the air from Fly or underground from Dig; other moves always miss such a target, and X Accuracy skips only the roll.engine/battle/core.asm L5247–5261engine/battle/core.asm L5287–5290Code
Doubleslap, Comet Punch, Fury Attack, Pin Missile, Spike Cannon, Barrage, and Fury Swipes hit 2 or 3 times with probability 3/8 each, and 4 or 5 times with 1/8 each; Double Kick, Bonemerang, and Twineedle always hit twice.engine/battle/effects.asm L944–966data/moves/moves.asm L16–17data/moves/moves.asm L37data/moves/moves.asm L44–55data/moves/moves.asm L144data/moves/moves.asm L153data/moves/moves.asm L167–168Code
A multi-hit move runs the critical test, the damage formula, and the accuracy roll once; every later hit repeats the first hit's damage, and a first hit that misses ends the move.engine/battle/core.asm L3140–3159engine/battle/core.asm L3218–3237data/battle/always_happen_effects.asm L1–7engine/battle/core.asm L3246–3253engine/battle/core.asm L4678–4695Code
Twineedle hits twice because its branch stores the value of a poison side-effect constant, which is 2, as the hit count, along with making it the move's effect.engine/battle/effects.asm L962–969constants/move_effect_constants.asm L9Code
The random-number update routine adds the hardware divider register to one byte with carry and subtracts it from a second byte with borrow; the VBlank handler calls it every frame, and the routine games call to get a random number returns the first byte.engine/math/random.asm L1–13home/random.asm L1–8home/vblank.asm L37Code
The battle random routine calls the ordinary random routine outside link battles; in a link battle both Game Boys read the first 9 bytes of a shared 10-byte list in turn, and after the ninth read those 9 are each replaced by 5x+1mod256; the tenth byte is never read.engine/battle/core.asm L6543–6599constants/serial_constants.asm L19Code
A step, or a turn in place, that can meet a wild Pokémon finds one when a random byte is below the map's encounter rate, out of 256: Route 1's grass rate is 25, so a step in its grass finds one 25 times in 256.engine/battle/wild_encounters.asm L26–53data/wild/maps/Route1.asm L1–2Code
A second random byte, which the generator updates along with the first, then picks one of the map's 10 slots, which have 51, 51, 39, 25, 25, 25, 13, 13, 11, and 3 chances in 256.engine/battle/wild_encounters.asm L54–62data/wild/probabilities.asm L11–28Code
After any battle, including one that ends in a blackout, the first two steps once the map reloads can't start a wild battle and the third can (computed). Every battle's end sets a cooldown flag; the map then reloads (after a blackout, at the place the warp sends the player), and a map load with the flag set sets a counter of 3. Each step not taken under scripted movement counts it down while the flag is set, clearing the flag when it reaches 0, and a wild battle can't start while it is above 0. A step's countdown runs before that step's encounter check.engine/battle/end_of_battle.asm L46–70home/overworld.asm L341–358home/overworld.asm L756–770engine/menus/main_menu.asm L327–341home/overworld.asm L6–17home/overworld.asm L291–320home/overworld.asm L321–340home/overworld.asm L362–371engine/battle/core.asm L6642–6645engine/battle/core.asm L6653–6664engine/battle/core.asm L6676engine/battle/core.asm L6693engine/battle/core.asm L6733–6735engine/battle/core.asm L6763–6764Code
In a wild battle, the run routine lets the player escape when their Pokémon's Speed P is at least the foe's E; otherwise it computes Q=⌊32P/(⌊E/4⌋mod256)⌋, adds 30 for each earlier attempt, and escapes when a random byte is at most the result, or at once when the result passes 255.engine/battle/core.asm L1496–1578Code
Quick Attack moves first and Counter last unless both sides chose the same one; otherwise the Pokémon with higher Speed moves first, and a tie goes either way with probability 1/2.engine/battle/core.asm L370–412macros/data.asm L3Code
Of the 165 moves in the move table, Struggle included, 104 are listed at 100% accuracy and 61 below it; the lowest are the three one-hit KO moves at 30%.data/moves/moves.asm L11–178data/moves/moves.asm L25Code
Bulbasaur and Squirtle start with Tackle, 35 power at 95% accuracy, and Charmander with Scratch, 40 power at 100%: the starter arrives at level 5 with the moves its base data lists, plus learned moves up to its level, and none of the three learns one before level 7.scripts/OaksLab.asm L927–931engine/pokemon/add_mon.asm L173–193engine/pokemon/evos_moves.asm L409–415data/pokemon/base_stats/bulbasaur.asm L13data/pokemon/base_stats/squirtle.asm L13data/pokemon/base_stats/charmander.asm L13data/pokemon/evos_moves.asm L1753–1758data/pokemon/evos_moves.asm L1985–1990data/pokemon/evos_moves.asm L1998–2003data/moves/moves.asm L23data/moves/moves.asm L46Code
Four 120-power moves trade accuracy for power against a 95-power, 100%-accurate move of the same type: Thunder (70%) against Thunderbolt, Blizzard (90%) against Ice Beam, Fire Blast (85%) against Flamethrower, and Hydro Pump (80%) against Surf. Sing, Hypnosis, Sleep Powder, Lovely Kiss, and Spore put the target to sleep at 55%, 60%, 75%, 75%, and 100%, and Guillotine, Horn Drill, and Fissure knock out in one hit at 30%.data/moves/moves.asm L98–103data/moves/moves.asm L66–72data/moves/moves.asm L139data/moves/moves.asm L38–47data/moves/moves.asm L25data/moves/moves.asm L76data/moves/moves.asm L60data/moves/moves.asm L92data/moves/moves.asm L108data/moves/moves.asm L155–160Code
Sand-Attack and Smokescreen (100%), Kinesis (80%), and Flash (70%) lower the target's accuracy by one stage; Double Team and Minimize (100%) raise the user's evasion by one stage.data/moves/moves.asm L41data/moves/moves.asm L117–121data/moves/moves.asm L147data/moves/moves.asm L161constants/move_effect_constants.asm L17–30ram/wram.asm L568–574engine/battle/effects.asm L351–377engine/battle/effects.asm L539–598Code
Outside link battles, an enemy's stat-lowering effect first fails when a random byte is below 64, 1 time in 4; the player's moves skip that roll. A move whose main effect lowers a stat, such as Sand-Attack or Smokescreen, then faces the normal accuracy test, while a damaging move's side effect instead takes hold only on a byte below 85, 85 times in 256.engine/battle/effects.asm L539–571macros/data.asm L3constants/move_effect_constants.asm L25–78data/moves/moves.asm L158Code
Pidgey learns Sand-Attack at level 5, and a wild or trainer Pokémon knows the moves its learnset gives up to its level; so the level-5 Pidgey on Route 1 (the last of its 10 grass slots, 3 encounters in 256) and on Route 2 (the fifth slot, 25 in 256), and the rival's level-9 Pidgey on Route 22, can use it.data/pokemon/evos_moves.asm L596–601engine/battle/core.asm L6083–6102engine/pokemon/evos_moves.asm L409–472data/wild/maps/Route1.asm L1–12data/wild/maps/Route2.asm L1–7data/wild/probabilities.asm L21–26data/trainers/parties.asm L487–494engine/battle/read_trainer_party.asm L64–78engine/pokemon/add_mon.asm L190–193Code
Yellow keeps Red and Blue's critical-hit test line for line, so the attacker's base Speed still sets the chance, ⌊S/2⌋ in 256 for most moves and 8 times that for the high-critical ones, and Focus Energy still cuts it to a quarter.engine/battle/core.asm L4478–4546Code
Yellow keeps Red and Blue's hit test and its accuracy scaling unchanged, so a move still hits when a random byte is below its scaled accuracy byte, and even a 100% move misses 1 time in 256.engine/battle/core.asm L5228–5419Code
Yellow's type chart file is byte-for-byte Red and Blue's, the same 82 rows over 15 types, with Ghost still no effect on Psychic.data/types/type_matchups.asm L1–85Code
Yellow keeps Red and Blue's routine that adjusts damage for the move's type, so STAB is still damage+⌊damage/2⌋ before the type rows.engine/battle/core.asm L5075–5191Code
Yellow keeps Red and Blue's damage calculation and its random factor unchanged, so base damage is still capped at 997 plus 2 and scaled by a random 217–255 over 255.engine/battle/core.asm L4299–4466Code
Yellow keeps Red and Blue's two-to-five-hit effect, 2 or 3 hits at 3/8 each and 4 or 5 at 1/8, and its damage loop, in which every hit after the first repeats it without a new damage calculation or accuracy test.engine/battle/effects.asm L925–970engine/battle/core.asm L3246–3253Code
Yellow's wild encounter check tests the bottom-left tile of the player's half-block where Red and Blue test the bottom-right, so “left shore” half-blocks, such as Cinnabar Island's east coast, no longer load grass encounters; the rest of the routine is unchanged.engine/battle/wild_encounters.asm L27–37engine/battle/wild_encounters.asm L64–72Code
Yellow keeps Red and Blue's escape formula, ⌊32P/(⌊E/4⌋mod256)⌋ plus 30 for each earlier attempt against a random byte, and adds one battle type that always escapes.engine/battle/core.asm L1496–1612Code
Yellow keeps Red and Blue's turn order: Quick Attack goes first and Counter last unless both sides chose the same one; otherwise the higher Speed goes first, and a tie goes to the player when a random byte is below 128, half the time (the Game Boy clocking a link battle inverts the roll so both sides agree).engine/battle/core.asm L371–412Code