Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- *=$D804
- CastHEAL2:
- JSR Heal2Amount
- ; Store low byte
- PHA
- ; Store high byte
- TYA
- PHA
- LDA #$28
- JSR ChoosePartyMember
- ; $30 = high byte
- PLA
- STA $30
- ; A = low byte
- PLA
- BCS $D818
- JSR HealPartyMember_16bit
- LDA #$00
- RTS
- ; $99, $9A = Caster in RAM
- ; Returns Random(0 to WIS) + (Level * 2)
- *=$BF40
- HealAmount:
- LDY #$33 ; Level
- LDA ($99),Y
- ASL A ; * 2
- STA $30
- LDY #$0A ; WIS
- LDA ($99),Y
- JSR RNG
- CLC
- ADC $30
- RTS
- ; $99, $9A = Caster in RAM
- ; Returns Random(0 to WIS*2) + (Level*2)
- ; Banks 0 and 6
- *=$BF56
- Heal2Amount:
- ; $B8 = Random(0 to WIS * 2)
- LDY #$0A
- LDA ($99),Y
- ASL A
- JSR RNG
- ; Add Caster Level * 2
- LDY #$33
- LDA ($99),Y
- ASL A
- CLC
- ADC $B8
- ; X = low byte
- ADC #$64 ; Base heal amount
- TAX
- ; A = high byte
- LDA #$00
- ADC #$00
- ; But we need to return the low byte in A...
- TAY ; Y = high byte
- TXA ; A = low byte
- RTS
- ; A = Amount to heal (low byte)
- ; *NEW* 16-bit version: $30 = Amount to heal (high byte)
- ; ($99) = Pointer to character being healed
- ; ------------------------
- ; OLD CODE
- ; ------------------------
- *=$DAC0
- HealPartyMember:
- STA $30
- LDY #$2D ; Current HP (low byte)
- LDA ($99),Y
- CLC
- ADC $30
- STA $2D ; NEW_HP (low byte)
- INY ; Current HP (high byte)
- LDA ($99),Y
- ADC #$00
- STA $2E ; NEW_HP (high byte)
- ; ------------------------
- ; NEW CODE
- ; ------------------------
- *=$DAC0
- HealPartyMember:
- LDY #$00
- ;*=$DAC2
- ; A = low byte
- ; Y = high byte
- HealPartyMember_16bit:
- STY $30
- CLC
- LDY #$2D ; Current HP (low byte)
- ADC ($99),Y
- STA $2D
- INY ; Current HP (high byte)
- LDA ($99),Y
- ADC $30
- STA $2E
- ; Check if NEW_HP exceeds MAX_HP
- LDY #$37 ; Max HP (high byte)
- CMP ($99),Y
- BCC _not_exceeded
- BNE _set_max
- ; High byte of NEW_HP exceeds high byte of MAX_HP: check low byte
- LDA $2D
- DEY
- CMP ($99),Y
- BCC _not_exceeded
- _set_max:
- ; NEW_HP > MAX_HP, so we set NEW_HP = MAX_HP
- LDY #$36 ; Max HP (
- LDA ($99),Y
- STA $2D
- INY
- LDA ($99),Y
- STA $2E
- ; ------------------------
- ; OLD CODE
- ; 22 bytes
- ; ------------------------
- _not_exceeded:
- ; Calculate the amount healed with 16-bit subtraction NEW_HP - CUR_HP
- ; At the same time set CUR_HP = NEW_HP
- LDY #$2D
- LDA $2D ; NEW_HP low byte
- SEC
- SBC ($99),Y ; OLD_HP low byte
- STA $A0 ; Difference low byte
- LDA $2D ; Store NEW_HP low byte
- STA ($99),Y
- INY
- LDA $2E ; Store NEW_HP high byte
- STA ($99),Y
- LDA #$00 ; Doesn't bother with difference high byte...
- STA $A1
- ; ------------------------
- ; NEW CODE
- ; 22 bytes
- ; ------------------------
- _not_exceeded:
- LDY #$2D
- LAX $2D ; NEW_HP low byte
- SEC
- SBC ($99),Y ; OLD_HP low byte
- STA $A0 ; Difference low byte
- TXA
- STA ($99),Y ; Store NEW_HP low byte
- INY
- LAX $2E ; NEW_HP high byte
- SBC ($99),Y ; OLD_HP high byte
- STA $A1 ; Difference low byte
- TXA
- STA ($99),Y ; Store NEW_HP low byte
- ; ------------------------
- LDA _PPUMask ; Skip the dialogue if rendering is disabled
- BEQ _end
- LDA #$5A
- STA $30
- JMP CallTalkDialogue
- _end:
- RTS
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement