Repository navigation
Combat System
Combat is not a simple bump-attack. First observed via live play (Beaten Dying Moon
emulator) and then traced in the disassembly and confirmed dynamically with scripted
breakpoint hooks on combat2.state, the actual sequence is:
- Walk up to stand adjacent to one or more monsters.
- Press the direction toward the monster you want to target — this doesn't move you (you're
already adjacent) or attack yet, it selects that monster. The selection is shown as
blinking corner markers on the monster's tile - the actual sprite behind this (VRAM
OBJ tiles
$2c/$2e, one corner graphic reused 4x via sprite flip, alternating between the two tile IDs for the blink) is isolated in the Sprite Glossary "UI overlay / cursor sprites". If multiple monsters are adjacent, pressing a different direction re-selects a different one. - Press A to actually execute the attack on the currently-selected target.
So targeting takes a direction press and a separate A press — simply walking into a monster's tile does not attack by itself. Every attack executed this way lands; there is no accuracy/miss chance anywhere in the game. This was confirmed on both sides of combat:
Two nested state machines, both dispatched through RST_00 jump tables (the "second jump
trampoline", see below):
-
$c125is the main state (24-entry table at$3360inbank_000.asm). State6= "adjacent target selection active" (Call_000_3bae); state12= "execute attack/pickup" (Jump_001_5a59_ConfirmAttackOrPickup, bank 1). - Inside state 6,
Call_000_3bc6reads the newly-pressed button ($c512) and jumps toCall_000_3c4f_TrySelectDirection(a direction),Jump_000_3c7f_ConfirmAttack(A), orJump_000_3c85_CancelTargeting(B). -
Call_000_3c4f_TrySelectDirectionchecks, for the pressed direction, whether a monster (Call_001_57db/Call_000_2f28, a monster-slot scan) or a ground item (Call_000_35ef) is actually there — only then is that direction accepted as the new target (jr_000_3c72, sets$c126=1). This is the exact "pressing a direction selects the monster" behavior, with a real adjacency check — not just a cosmetic move. -
Jump_000_3c7f_ConfirmAttack(A pressed) just sets$c126=3; the outer dispatch inCall_000_3bae(a secondRST_00table at$3bbe, indexed by$c126) resolves that toJump_000_3c38_ConfirmAttack, which sets$c125=12— the real attack state. -
Jump_001_5a59_ConfirmAttackOrPickup(state 12) branches on$c524: bit 7 set means the target is a ground item (jumps into the pickup code,Jump_001_4f3d); otherwise$c524is the monster participant ID (<2= nothing valid selected,>=2= monster slot + 2). For a real attack,$c523is forced to$01(player is the attacker) andCall_001_5c00runs the shared damage formula.
Verified dynamically: a hook on $5a59 fired exactly on the A press with $c523=1,
$c524=2 (monster slot 0), immediately followed by Call_001_5c47/Call_001_5c75, with
the monster's HP struct field (offset $06) dropping by the expected damage in the same
step. Still open: how the game transitions into $c125=6 in the first place (presumably
automatic on detecting an adjacent monster/item after a movement step — not yet traced).
Partial answer (live gearboy-mcp session): observed $c125 flip straight to 6 as the
direct result of a movement attempt whose destination cell was monster-occupied - the
move didn't commit (player stayed put) but target-selection opened immediately in the same
input, already aiming at that monster. So the trigger isn't a separate post-move adjacency
scan; it looks like the same occupancy check that blocks the move (see
Dungeon Mechanics "Movement collision, partially traced") also opens
targeting when the blocking occupant is a monster, in one step. Not yet confirmed from the
disassembly, but consistent with every observation so far.
A monster gets a free attack if a menu is opened while adjacent to it. Confirmed live: opening the Camp/item-use menu while standing next to a live monster (HP 7/10 going in) cost 3 HP by the time the menu closed, with no attack animation or combat state visible - the adjacent monster's turn still resolves while the player is menu-bound. Don't assume menus are a free, consequence-free pause if something is standing next to you.
-
Monster → player damage is a deterministic per-monster-type table lookup
(
Call_001_518a-style lookups), not a random roll. -
Player → monster damage (
Call_001_5c47/Call_001_5c75, bank 1) is the same kind of deterministic table/arithmetic lookup, confirmed by watching the monster's HP field drop by a varying-but-formulaic amount on every single attempt across two independent live fights (never a "nothing happened, it dodged" turn).
Effective attack/defense values used in combat are computed on the fly:
- Effective attack =
wPlayerAttack+ two equipment bonus bytes (clamped to 99 in BCD) - Effective defense =
wPlayerDefense+ two equipment bonus bytes (clamped to 99 in BCD)
The equipment bonus bytes come from equipped swords/shields — see Item System for the exact bonus table.
Damage itself is integer arithmetic on attack vs. defense, scaled by a
direction/facing-derived factor ($c539 and $1f), with a minimum damage of 1 if
attack × 2 ≤ defense. Observed damage values across two test fights: 2, 2, 3, 4, 1, 2 —
confirming this is a real formula, not the fixed "always exactly 2" that an earlier,
smaller sample had suggested.
Fire ($03) is a separate, much higher-damage source outside this formula - confirmed
live at 12 damage in one hit (vs. the 1-4 range above), one-shotting a 6 HP Tarantula.
See Item System $03 for the full targeting mechanism (own free-moving
cursor, not the adjacent-select combat uses).
Melee damage can also spike much higher than the earlier 1-4 sample suggested once
equipment is in play: with a Sword +1 equipped (effective attack 5, see
Item System $18), one plain melee hit dealt 7 damage, one-shotting a
fresh 7 HP Minotaur (gearboy-mcp session). Consistent with the formula being genuinely
attack-vs-defense-sensitive rather than a small fixed range - the +1 from the sword was
enough to roughly double the damage ceiling seen so far against this particular monster's
defense.
A monster adjacent during a $c100-level transient state (not just the item-menu case
above) can land a lethal free hit. Confirmed live: after a quest was already fully
complete (3/3), a Crab adjacent to the player during a $c100=2 transient (entered via a
wall-bump clear, see Dungeon Mechanics "$c125=0") dropped HP from 2
straight to 0, triggering a normal Game Over - the HP-reaches-0 trigger itself is the
already-documented one in
Player Death and Game Over, nothing new there, but it
confirms these adjacency-based free hits are a real death risk, not just chip damage, at
low HP.
Cave Noire doesn't have a classic random number generator (no LFSR, no rDIV read anywhere
relevant). Instead, it reuses a harmless side effect of the game loop as a "good enough"
randomness source:
-
RST_00is a second jump-table trampoline (likeRST_28, which doeshl += a, butRST_00is a jump-table instead): the index comes froma, and the 2-bytes-per-entry table lives directly in the byte stream right after therst RST_00opcode — which is why it looks like garbage code to a naive disassembler until you realize it's data. - Every monster struct (16 bytes, base
$c5c0 + 16×slot) has a 2-3 bit state/direction field at offset$0f. This field is used (masked withand $03/and $07, thenrst RST_00) as an index into a 4-entry jump table pointing at the four cardinal movement functions. - The actual "randomness": this field gets incremented every time it is not that monster's turn in the per-turn dispatch loop. Since the game loop steps through multiple monster types per turn, this counter increments at a cadence the player can't predict — its low bits behave like a dice roll even though it's just a dumb running counter.
This also answers the "hit chance" question definitively: there isn't one. Whether a monster can attack at all is purely positional (aligned with the player on row/column, adjacent), and this pseudo-random counter only determines whether/where it moves instead.
Not previously documented at all beyond the cure item's name. Confirmed live (gearboy-mcp
session, Tarantula fight): after taking melee damage from a Tarantula, the character sheet's
condition line (たいちょう, normally OK) read たいちょう「どく」("condition: Poison")
instead. While poisoned, HP ticked down by 1 per turn even with no monster adjacent and
no further combat - confirmed across two separate idle turns (5→4→ [interrupted by an item
use, see below] and losing HP again on the very next plain turn after that). Dokukeshi
($02) cures it immediately - the condition line read OK again the turn after using it, and
HP stopped draining. Not yet confirmed which monster classes can inflict it (only tested
against Tarantula, class 3) or whether the drain amount/duration varies.
wPlayerLucky ($c123) does not affect hit chance or combat accuracy at all. All of
its uses are in the item-effect dispatcher:
-
Healing:
new HP = min(current HP + Lucky, max HP)for one potion-like item effect. Reconfirmed live (gearboy-mcp session):wPlayerLucky=4, used Kaifuku ($01) at 3 HP, result exactly 7 HP (3+4, below the 10 HP max so the clamp didn't engage). -
A second item type: heals by
Lucky + 1. -
Random event timer (
$c515): for most item effects,$c515is set from the LCG pseudo-random source ($c011/$c012,state = state×9 + $0929 mod $11d7), with the range of the result scaled byLucky / 2— e.g. a trap fuse duration or buff duration. - Status screen: Lucky is also just displayed as a stat number, no computation there.
So: higher Lucky means better healing items and wider random-duration ranges for certain item effects — not a better chance to hit or be hit.