Users browsing this thread: 1 Guest(s)
Giving Everyone the Same Desperation Attack

#7
Posts: 48
Threads: 7
Thanks Received: 0
Thanks Given: 0
Joined: Dec 2017
Reputation: 0
Status
None
Here is my attempt. The key word being "attempt". This wasn't tested. Wink

So, instead of LDA $3EE4,X at C2/15F1, you could JSR elsewhere in C2 (or JSL in another bank) and either plug in this additive subroutine:


Code:
DA  --  --  PHX          ;Put X into the stack, just in case that value is useful later in the code
9C  va  r1  STZ  var1    ;Store zero into var1
A2  00  --  LDX  #$00    ;Clear X

beginning_of_loop:
E0  08  --  CPX  #$08    ;Compare X with #$08
B0  0F  --  BCS  end     ;If X is greater or equal to #$08 (or is the battle entity an enemy?), skip to the end
BD  34  13  LDA  $1334,X ;Load into the accumulator the character current status #1
89  C2  --  BIT  #$C2    ;Bitwise AND between the accumulator and C2 (Does the character has status Death, Zombie or Petrify?)
F0  08  --  BEQ  adding_desperation_chance  ;If the character has none of these statuses, skip the addition part
A9  55  --  LDA  #$55    ;Load 1/3 of #$FF into the accumulator
6D  va  r1  ADC  var1    ;Add var1 to the accumulator
8D  va  r1  STA  var1    ;Store the accumulator into var1

adding_desperation_chance:
E8  --  --  INX        
E8  --  --  INX         ;Increase X by 2 in order to target the next battle entity current status #1
80  E9  --  BRA  beginning_of_loop

end:
FA  --  --  PLX         ;Pull stacked value back into X        
60  --  --  RTS         ;Return (user RTL if you changed bank)


Or this substractive subroutine:


Code:
8E  va  r1  STX  var1    ;Store X into var1, because we will need that value to check whether the character is the attacker
DA  --  --  PHX          ;Push X into the stack
A9  FF  --  LDA  #$FF    ;Load #$FF in the accumulator
8D  va  r2  STA  var2    ;Store #$FF into var2
A2  00  --  LDX  #$00    ;Clear X

beginning_of_loop:
E0  08  --  CPX  #$08    ;Compare X with #$08
B0  19  --  BCS  end     ;If X is greater or equal to #$08 (or is the battle entity an enemy?), skip to the end;
BD  34  13  LDA  $1334,X ;Load into the accumulator the character current status #1
89  C2  --  BIT  #$C2    ;Bitwise AND between the accumulator and C2 (Does the character has status Death, Zombie or Petrify?)
D0  0E  --  BNE  reducing_desperation_chance ;If the character has any of these statuses, skip the substraction part
EC  va  r1  CPX  var1    ;Compare X with var1
F0  09  --  BEQ  skip_reducing_desperation_chance ;If the current character is the attacker, skip the substraction part
38  --  --  SEC          ;Set the carry flag, in preparation of the substraction
AD  va  r2  LDA  var2    ;Load var2 into the accumulator
E9  55  --  SBC  #$55    ;Substract 1/3 of #$FF from the accumulator
8D  va  r2  STA  var2    ;Store the accumulator back into var2

reducing_desperation_chance:
E8  --  --  INX        
E8  --  --  INX          ;Increase X by 2 in order to target the next battle entity current status #1
80  E3  --  BRA  beginning_of_loop

end:
FA  --  --  PLX          ;Pull stacked value back into X
60  --  --  RTS          ;return (Use RTL if you changed bank)

(I changed some things around while writing this reply. I hope I adjusted the branchings correctly Tongue).

Because I don't know which memory addresses are available at that point in the battle, hence the names var1 and var2. Replace them at your convenience.

After that, you will need to change C2/15FB for CMP var1 (or var2, depending of the method used). Because this opcode will be using 3 bytes instead of 2, you will need to move the rest of the code (getting rid of one EA at the end). Make sure the branchings are recalculated accordingly.

EDIT: I forgot that this subroutine makes C2/15F4 and C2/15F6 useless, giving you space for CMP var1/2 without having to move everything around.
  Find
Quote  



Messages In This Thread
RE: Giving Everyone the Same Desperation Attack - by NPCnextdoor - 07-21-2018, 03:45 PM

Forum Jump:

Users browsing this thread: 1 Guest(s)


Theme by Madsiur2017Custom Graphics by JamesWhite