The following warnings occurred:
Warning [2] count(): Parameter must be an array or an object that implements Countable - Line: 895 - File: showthread.php PHP 7.3.33 (Linux)
File Line Function
/showthread.php 895 errorHandler->error




Users browsing this thread: 1 Guest(s)
Equipment Check Event Command

#1
Posts: 3,969
Threads: 279
Thanks Received: 236
Thanks Given: 57
Joined: Oct 2011
Reputation: 65
Status
Tissue-aware
Equipment Check Event Command
version 1.1
released on 04/28/2016
Apply to a FF3us
wiki entry
Download


Files

equipcheckEE.asm: For implementation in another bank than $C0
equipcheckC0.asm: For implementation in bank $C0

Apply with xkas 0.06
Command example: xkas equipcheckEE.asm romname.smc

Space used

$C0 implementation: 0xC1 bytes (bank $C0)
$XX implementation: 0x07 bytes (bank $C0), 0xBD bytes (bank $XX)

Description

This event command ($66) allows to check equipment on party member(s).

There are 5 parameters to the command:

Code:
Param A:
    0x00-0x0F: Check specific character (must be in party otherwise condition fail).
    0x10: Check if at least 1 character meet the condition (has the equipment).
    0x20: Check if party leader meet the condition (has the equipment).
    0x40: Check if all party members meet the condition (have the equipment).
    anything else: condition may fail or succeed. Use at your own risk.

Param B: Equipment piece to check (0x00 to 0xFF)

Param C, D, E: Offset EEDDCC where (CA/0000 + EEDDCC) is offset to jump to if condition is met.


Examples

66 0C C9 10 EF 02: If gogo has one hero ring (or more) equipped, jump to CC/EF10 otherwise continue.
66 40 C9 B8 48 00: If all party members have 1 hero ring (or more) equipped, jump to CA/48B8 otherwise continue.

Implementation ($C0)
Code:
;For implementation in bank $C0

hirom           ;do not touch
;header         ;uncomment if your ROM has a header

org $C09926     ;command 66 jump table entry.
DB $13, $D6     ;jump to C0/D613.

org $C0D613     ;Don't forget to change this if you need to relocate.
               ;following code require 0xC1 free bytes.
equipCheck:
LDA #$20        ;when comparing $1A to char battle order further down, this ensure
               ;we have at least one party leader, i.e. first comparison will always branch.
STA $1A
LDY $00         ;zero Y
TYX             ;zero X
STX $1C         ;zero $1C-$1D (temp variables)
mainLoop:
LDA $1850,Y     ;load character battle setup
AND #$07        ;isolate character's party bit
CMP $1A6D       ;compare with active party
BNE nextActor   ;branch if character is not in active party
INC $1D         ;increment party counter
LDA $EB         ;load first command parameter
CMP #$10
BCS notActor    ;branch if we are not checking a character
TYA
CMP $EB
BNE nextActor   ;branch if we don't have a character match
JSR getBlockOff ;get char equip block offset
loopEquip:
LDA $161F,X     ;get equipment
CMP $EC
BEQ goToOffset  ;if equip found, branch to jump to offset given in command params
INX
DEY
BNE loopEquip   ;loop for 6 equipment pieces
BRA exit
notActor:       ;if we are here first command param should be $10, $20 or $40
TYA
PHY             ;we are in a loop so we don't want to lose X and Y
PHX
JSR getBlockOff ;get char equip block offset
loopEquipB:
LDA $161F,X     ;get equipment
CMP $EC
BEQ incCounter  ;if equip found, increment equipment counter.
INX
DEY
BEQ endLoopB    ;branch if 6 equipment pieces are checked
BRA loopEquipB  ;otherwise check next equip piece
incCounter:
INC $1C
endLoopB:
PLX             ;restore X and Y
PLY
LDA $1850,Y     ;load character battle setup
AND #$18        ;isolate battle order
CMP $1A         ;compare to previous lowest battle order
BCS nextActor   ;branch if current char is "less leader" than the one we already have.
STA $1A         ;store battle order
STX $1E         ;store (temp) party leader
nextActor:
INX
INY
CPY #$0010
BNE mainLoop    ;loop for all 16 chars
LDA $EB
CMP #$10
BEQ partyChar   ;branch if we are checking for one party member
CMP #$40
BEQ allParty    ;branch if we are checking all party
CMP #$20
BEQ partyLead   ;branch if we are checking party leader
BRA exit        ;invalid command falls here

partyChar:
LDA $1C
CMP #$00
BNE goToOffset  ;branch if equip counter > 0
BRA exit

allParty:
LDA $1C
CMP #$00
BEQ exit        ;brand if equip counter == 0
CMP $1D         ;compare equip counter to number of party members
BEQ goToOffset  ;branch if number of same equipment == number of party members
               ;even if a char has twice the same relic equipped, only first one is counted
BRA exit

partyLead:
LDA $1E         ;load real party leader
JSR getBlockOff ;get equip block offset
loopEquipC:
LDA $161F,X     ;get equipment
CMP $EC
BEQ goToOffset  ;equipment piece found
INX
DEY
BNE loopEquipC  ;loop for 6 equipment pieces if needed

exit:           ;we are continuing after the event command
REP #$21        ;16-bit accum./memory + cary flag
LDA $E5
ADC #$0006
STA $E5
TDC
SEP #$20        ;8-bit accum./memory
ADC $E7
STA $E7
JMP $9A6D       ;event command "ending routine".

goToOffset:     ;we are jumping to offset specified in $ED-$EF
LDX $ED
STX $E5
LDA $EF
CLC
ADC #$CA
STA $E7
JMP $9A6D       ;event command "ending routine".

getBlockOff:
STA $4202       ;store character ID for multiplication
LDA #$25        ;size of character block
STA $4203       ;store block size for multiplication
NOP
NOP
LDX $4216       ;X <- index * 37
LDY #$0006      ;there's 6 slots
RTS
  Find
Quote  



Messages In This Thread
Equipment Check Event Command - by madsiur - 04-24-2016, 08:48 PM

Forum Jump:

Users browsing this thread: 1 Guest(s)


Theme by Madsiur2017Custom Graphics by JamesWhite