Cite as
Herringway/ebsrc
Original
https://github.com/Herringway/ebsrc
Pinned
Herringway/ebsrc @ 68aec5c39e67f3ef4f0be138ee58c1ba0cc33d62
Accessed
2026-10-21
Licence
none stated (no LICENSE file)
Credit
Herringway and the project's contributors, who disassembled the Super Famicom game into ca65 source, one routine per file, and named its routines, structures, and constants. Every label and comment quoted in earthbound claims comes from this repo.
Notes
Builds the US retail EarthBound (the default target, assembled with -D USA), the 1995-03-27 US localization prototype, and Mother 2 (-D JPN) from one source tree with .IF branches; claims read the US branches. Not rebuilt here. The HP meter table quoted in earthbound/rolling-hp sits at $C3:FB1F in the atlas's US ROM (earthbound-snes-rom) with the source's bytes.

Cited on

Claims (10)

In EarthBound (US release), damage to a party member sets a target HP, and the HP shown counts toward it over time: each call moves one party slot (picked by the frame counter's low two bits) by 1.125, 1.094, or 1.0625 HP by the text speed setting. Healing rolls at 6.25 HP per update when a fastest flag or the flip-out mode is set; damage rolls at 6.25 only in the flip-out mode. A character falls only when that rolling HP reaches 0. When the last enemy falls, each meter still rolling down stops where it is, so mortal damage that hasn't finished rolling doesn't knock anyone out. Enemies and guest characters take damage at once.src/battle/set_hp.asm L23–64src/misc/hp_pp_roller.asm L12–22src/misc/hp_pp_roller.asm L64–80src/misc/hp_pp_roller.asm L109–127src/data/hp_meter_speeds.asm L2–5src/intro/file_select_menu_loop.asm L665–678src/battle/check_dead_players.asm L43–63src/battle/main_battle_routine.asm L3051–3058src/misc/reset_hppp_rolling.asm L37–50Code
In EarthBound (US release), a battle the party can't lose is won without being fought. The check fails if the enemies struck first, or if there are more enemies than able party members among the four main characters (unconscious, diamondized, paralyzed, nauseous, poisoned, sunstroked, cold, mushroomized, and possessed ones don't count). In an even start, the four's lowest Speed must be at least every enemy's Speed, and twice their lowest Offense at least each enemy's HP plus Defense. When the party struck first, it sorts the able members by Offense and the enemies by HP, both highest first, and plays one round in that order: each member makes one attack of 2 × Offense − Defense on the current enemy, moving on to the next enemy only when one falls (any surplus damage is lost), and the party wins if every enemy falls.src/battle/instant_win_check.asm L17–21src/battle/instant_win_check.asm L46–59src/battle/instant_win_check.asm L130–137src/battle/instant_win_check.asm L183–206src/battle/instant_win_check.asm L383–427src/battle/init_overworld.asm L16–23Code
In EarthBound (US release), a battle starts when an enemy on the map touches the party, and the two's facings decide who strikes first. With the direction from the enemy to the party rounded to one of eight: the party strikes first when the enemy isn't moving toward the party (within 45°) and the leader isn't facing away from the enemy; the enemies strike first when the enemy is moving toward the party and the leader faces away; otherwise neither does. A standing enemy always gives the party the first strike.src/unknown/C0/C0D19B.asm L17–32src/unknown/C0/C0D19B.asm L49–99Code
In EarthBound (US release), an enemy on the map turns and runs from the party when its group's run-away event flag holds the value the group names (its run_away_flag_state byte), or when the levels of the party's main characters (not guests) summed are more than 10 times the enemy's level; more than 8 times for 3 enemies in 4, and more than 6 times for 1 in 2, by a random byte each enemy gets when it spawns.src/unknown/C0/C0C524.asm L24–47src/unknown/C0/C0C524.asm L49–105src/unknown/C0/C0C615.asm L2–11src/overworld/spawn_enemies_from_group.asm L412–414Code
In EarthBound (US release), a bash is a "SMAAAASH!!" with a chance of about the attacker's Guts in 500, with a party member's Guts counted as at least 25 (about 1 in 20). It is rolled after the miss check and before the dodge, so it can't be dodged, and deals 4 × Offense − Defense with no random spread.src/battle/actions/bash.asm L7–17src/battle/smaaaash.asm L10–26include/config.asm L66src/battle/smaaaash.asm L59–67src/battle/success_500.asm L8–13Code
In EarthBound (US release), a bash first misses at the attacker's miss rate in 16: for a party member its weapon's, or 1 with no weapon, plus 8 while crying or nauseous; for an enemy its own. Then the target dodges with a chance of about (2 × target's Speed − attacker's Speed) in 500, never when that is 0 or less, nor while the target is paralyzed, asleep, immobilized, or solidified.src/battle/miss_calc.asm L40–56src/battle/miss_calc.asm L72–98src/battle/determine_dodge.asm L34–47Code
In EarthBound (US release), a bash deals 2 × the attacker's Offense − the target's Defense, moved up or down by up to 25%, and at least 1. The spread draws two random bytes and keeps the one nearer 128; its distance d from 128 moves the damage by d/512 of it, down when the byte is under 128 and up when over, so small changes are the most common.src/battle/actions/level_2_attack.asm L7–30src/battle/25_percent_variance.asm L11–93Code
In EarthBound (US release), every conscious combatant's initiative is rolled at the start of each turn: its Speed moved up or down by up to 50% (the 25% spread's method without the final halving), at least 1. Then the conscious combatant yet to act with the highest initiative goes next, ties going to the later slot.src/battle/main_battle_routine.asm L1127–1142src/battle/50_percent_variance.asm L66–76src/battle/main_battle_routine.asm L2126–2138Code
In EarthBound (US release), running away never works against a boss. Otherwise it works on the first turn of a battle the party started with the first strike, or when no enemy can act; else it works with a chance of about (10 × the turn number + the fastest party member's Speed − the fastest able enemy's Speed) in 100, and never when that is below 0.src/battle/main_battle_routine.asm L1276–1300src/battle/main_battle_routine.asm L1950–1969src/battle/main_battle_routine.asm L1999–2003src/battle/main_battle_routine.asm L2019–2068src/battle/main_battle_routine.asm L1112–1116Code
EarthBound (US release) keeps EarthBound Beginnings' order of a plain attack, with the "SMAAAASH!!" rolled before the dodge so it can't be dodged, but changes the numbers: the chance comes from the attacker's Guts alone (about Guts in 500) instead of Fight against Fight; the SMAAAASH deals 4 × Offense − Defense instead of the full Offense; a normal hit deals 2 × Offense − Defense instead of Offense − Defense ÷ 2; and the dodge comes from Speed instead of Fight.src/battle/actions/bash.asm L11–17src/battle/smaaaash.asm L10–24src/battle/smaaaash.asm L60–65src/battle/actions/level_2_attack.asm L8–12src/battle/determine_dodge.asm L34–39Code