Skip to content

Instantly share code, notes, and snippets.

@HS39
Created November 17, 2018 01:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save HS39/fe38de694646d43adfc8354c2c5eb067 to your computer and use it in GitHub Desktop.
Save HS39/fe38de694646d43adfc8354c2c5eb067 to your computer and use it in GitHub Desktop.
import asm65816
import ASMRef
Magnet_No_PP_Text:
newline
"@{target} does not have any PP![03]"
eob
Magnet: {
REP (0x31)
PHD
TDC
ADC_i (0xFFE8)
TCD
LDX_a (0xA972) //Loads Current target to X register
LDA_x (0x0019) //Checks byte 0x19 of combatant table (current PP), loads value to Accumulator from X register
BNE_a (Magnet_1) //Branch if target currently has more than 0 PP
BText (Magnet_No_PP_Text)
BRA_a (Magnet_Return) //If not, branch to end
Magnet_1:
LDA_i (0x0004)
JSL (Rand_0_to_A1) //Random number 0-3
TAX
STX_d (0x16)
LDA_i (0x0004)
JSL (Rand_0_to_A1) //Random number 0-3
STA_d (0x02)
LDX_d (0x16)
TXA
CLC
ADC_d (0x02)
STA_d (0x02)
INC_d (0x02)
INC_d (0x02) //Increases number by 2
LDX_a (0xA972) //Loads Current target to X register
LDA_x (0x0019) //Checks byte 0x19 of combatant table (current PP), loads value to Accumulator from X register
CMP_d (0x02)
BCS_a (Magnet_2)
STA_d (0x02) //Capped by current PP
Magnet_2:
ASMLoadAddress0E (0xEF773F)
LDA_d (0x02)
STA_d (0x06)
STZ_d (0x08)
BPL_a (Magnet_3)
DEC_d (0x08)
Magnet_3:
LDA_d (0x06)
STA_d (0x12)
LDA_d (0x08)
STA_d (0x14)
JSL (0xC1DC66) //Displays text at 0xEF773F
LDX_d (0x02)
LDA_a (0xA972) //Loads Current target to Accumulator
JSL (Reduce_PP) //Reduces target's current PP
LDX_a (0xA970) //Loads Current user to X register
LDA_d (0x02)
CLC
ADC_x (0x0019) //Increases user's current PP
TAX
LDA_a (0xA970) //Loads Current user to Accumulator
JSL (Set_Rolling_PP)
Magnet_Return:
PLD
RTL
}
Magnet_All: {
REP (0x31)
LDX_a (0xA972) //Loads Current target to X register
LDA_x (0x000E) //Checks byte 0xE of combatant table (enemy), loads value to Accumulator from X register
AND_i (0x00FF)
BNE_a (Magnet_All_Jump) //Branch if enemy
LDX_a (0xA972) //Loads Current target to X register
LDA_x (0x0000)
CMP_i (0x0003)
BEQ_a (Magnet_All_Return) //Skips if not a PC
Magnet_All_Jump:
JSL (Magnet)
Magnet_All_Return:
RTL
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment