Skip to content

Instantly share code, notes, and snippets.

@charasyn
Created May 17, 2021 18:17
Show Gist options
  • Save charasyn/234168086c5e5bc86cdd31942f0a54bd to your computer and use it in GitHub Desktop.
Save charasyn/234168086c5e5bc86cdd31942f0a54bd to your computer and use it in GitHub Desktop.
// This patch is public domain, "as-is" with no warranty
// See https://unlicense.org/
// Author: cooprocks123e, 2021-05-17
import asm65816
// Patch battle routine to avoid killing players
// with displayed HP of 0 when it is rolling up
ROM[0xc2bb74] = {
LDX_d(0x02) // 74: Load character struct pointer into X
LDA_x(0x004b) // 76: Load PP from character struct
STA_y(0x9fc3) // 79: Store to battler struct PP
LDA_x(0x0045) // 7c: Load HP from character struct
STA_y(0x9fbd) // 7f: Store to battler struct HP
BNE(0x71) // 0xc2bbf5-0xc2bb84 // 82: Branch forward to UNKNOWN4 if HP is not zero
LDA_x(0x0047) // 84: Load target HP from character struct
BNE(0x6c) // 0xc2bbf5-0xc2bb89 // 87: Branch forward to UNKNOWN4 if target HP is not zero
BRA(0x02) // 0xc2bb8d-0xc2bb8b // 89: Branch past NOPs (avoid wasting cycles)
NOP() // 8b: \ NOP padding
NOP() // 8c: /
// PC should now be 0xc2bb8d
// UNKNOWN4 = 0xc2bbf5
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment