Users browsing this thread: 2 Guest(s)
Shock Ability

#13
Posts: 175
Threads: 11
Thanks Received: 10
Thanks Given: 8
Joined: May 2013
Reputation: 13
Status
Well-Fed
So I got bored and coded up an MP-costing Shock. Only needed 70 bytes of space, even! (And I'm going to look at getting it into even less free space, but it's functional and, I think, not too shabbily done so far.)

With this code:
  • Shock costs 50MP (set by a !define at the start of the code)
  • Shock's MP cost is adjusted by Gold Hairpin/Economizer.
  • Shock is disabled when current MP is below 50MP
  • Shock is disabled when muted
  • Shock is properly enabled when MP goes back above 50, and when unmuted
It's not super thoroughly tested yet, but I've run it through the obvious stuff. Let me know if you run into any problems with it. If you don't want it disabled on Mute, that's actually super easy -- just comment out the BCC line in dis_shock, and it'll bypass that check. If you don't want its cost adjusted by GH/Economizer, comment out the XBA/LDA/JSR lines at the end of shockMP.

Code:
hirom
; header

; Defines
!Freespace_1 = $c2A65A          ; 26 bytes, or 70 total
;!Freespace_2 = $c2xxxx         ; 27 bytes (if separate from above)
;!Freespace_3 = $c2xxxx         ; 17 bytes (if separate from above)
!Shock_ID = $1B
!Shock_MP = $32                 ; or 50d


;;; Flagging menu redraw on MP restore/loss
; These were all originally STA $3C08,Y (and one ,X).
; They now jump to new generic functions that update current MP,
; but also flag the attacker/target (as relevant) to have their
; menu updated for Shock's MP cost.
;
; Nothing needed to be done for Mute, as it already flagged the
; function appropriately, and Shock piggybacks on Magic/Lore/X-Magic
; for handling it.
org $C21365
           JSR flagSTAY
           
org $c21375
           JSR flagSTAY
           
org $c2137D
           JSR flagSTAY
           
org $c232E0
           JSR flagSTAX
           
org $c23CB4
           JSR flagSTAY
           
org $c23F47
           JSR flagSTAY

;;; Adding MP Cost to Shock
; Added a jump in the middle of the MP cost code; new code
; replicates the same check for Summon, then checks for Shock
; before jumping back to this codeblock as appropriate.
org $C24F14
           JMP shockMP : NOP

         
;;; Disabling Shock at less than 50MP
; Adjusts some table pointers, and then includes new code includes
; the space opened up by moving the tables to freespace.
;
; New code checks current MP against cost of Shock and disables
; (greys out) the command if MP is too low.
org $c252C6
           LDX #$0008
           CMP.l c2_table1,X   ; Moved table to free space because it's being expanded
           
org $c252D2
           JSR (c2_table2,X)   ; Moved table to free space because it's being expanded
           
org $c252E9                     ; Code fits into the place freed by the moved tables
dis_Shock:  REP #$20            ; Set 16-bit A
           LDA.w #!Shock_MP    ; LDA with $32/50d
           CMP $3C08,Y         ; Compare it to current MP and restore processor flags from stack
           SEP #$20            ; Set 8-bit A
           BCC c25314          ; If MP was over 50, carry is clear, so branch to Magic/Lore/X-Magic code to check for mute
           RTS                 ; Else, return with carry set, which will grey out Shock
           
    warnpc $c25300
           
org $c25314
c25314:                         ; Setting label for branch above


;;; New Code!
; This code (jumped to from MP cost function above) sets Shock's MP cost
; and adjusts it as necessary for Gold Hairpin/Economizer.
org !Freespace_1                ; (26 bytes)
shockMP:    CMP #$19            ; Is the command Summon? (Moved check to make space for JMP to new code)
           BNE .notSummon
           JMP $4F24           ; If it is, jump back to where it would have BRA'd in the earlier code
.notSummon CMP #!Shock_ID      ; Is it Shock?
           BEQ .shockMP        ; If it is, branch and set MP to deduct
           JMP $4F18
  .shockMP LDA #!Shock_MP
           XBA                 ; Put Shock's MP cost in the top of A
           LDA $3C45,X         ; Get relic byte 2 (Gold Hairpin/Economizer)
           JSR $5739           ; Adjust MP cost based on Gold Hairpin/Economizer
           JMP $4F54


; Moved/expanded tables (from the disable CMDs function)
;org !Freespace_2               ; (27 bytes)
c2_table1:  db $03, $0B, $07, $0C, $17, $02, $06, $00, !Shock_ID
c2_table2:  dw $5326, $5322, $531D, $5314, $5314, $5314, $5310, $5310, dis_Shock  


; Generic functions for flagging menu redraw on MP damage/restore (one for STA $3C08,Y, one for STA $3C08,X)
;org !Freespace_3               ; (17 bytes)
flagSTAY:   STA $3C08,Y         ; Stores updated current MP
           PHX : TYX
           INC $2F30,X
           PLX
           RTS
           
flagSTAX:   STA $3C08,X         ; Stores updated current MP
           INC $2F30,X         ; Flags actor/target (as relevant) to have menu updated
           RTS            


Current Project: FF6: Tensei | Discord ID: TristanGrayse
  Find
Quote  
[-] The following 4 users say Thank You to GrayShadows for this post:
  • madsiur (06-01-2018), Robo Jesus (05-20-2019), Turbotastic (06-01-2018), Warrax (06-01-2018)



Messages In This Thread
Shock Ability - by Lightning - 05-22-2018, 01:48 AM
RE: Shock Ability - by madsiur - 05-22-2018, 02:34 AM
RE: Shock Ability - by Lightning - 05-22-2018, 11:16 AM
RE: Shock Ability - by ShadowDreamer - 05-23-2018, 12:48 AM
RE: Shock Ability - by Turbotastic - 05-25-2018, 06:18 PM
RE: Shock Ability - by Tenkarider - 05-24-2018, 11:41 AM
RE: Shock Ability - by GrayShadows - 05-26-2018, 11:15 AM
RE: Shock Ability - by Turbotastic - 05-27-2018, 04:19 PM
RE: Shock Ability - by Lightning - 05-27-2018, 04:33 PM
RE: Shock Ability - by madsiur - 05-27-2018, 05:43 PM
RE: Shock Ability - by Lightning - 05-27-2018, 10:52 PM
RE: Shock Ability - by madsiur - 05-28-2018, 01:33 AM
RE: Shock Ability - by GrayShadows - 05-31-2018, 07:32 PM
RE: Shock Ability - by Lightning - 05-31-2018, 08:46 PM
RE: Shock Ability - by GrayShadows - 06-01-2018, 10:33 AM
RE: Shock Ability - by Lightning - 06-01-2018, 01:51 PM
RE: Shock Ability - by Warrax - 06-01-2018, 03:37 PM
RE: Shock Ability - by GrayShadows - 06-01-2018, 04:26 PM
RE: Shock Ability - by Lightning - 06-01-2018, 10:26 PM
RE: Shock Ability - by Turbotastic - 06-02-2018, 09:21 AM
RE: Shock Ability - by Lightning - 06-02-2018, 10:15 AM
RE: Shock Ability - by dn - 06-02-2018, 01:53 PM
RE: Shock Ability - by Turbotastic - 06-02-2018, 07:21 PM
RE: Shock Ability - by Lightning - 06-02-2018, 08:35 PM
RE: Shock Ability - by GrayShadows - 06-05-2018, 09:38 PM
RE: Shock Ability - by Lightning - 06-05-2018, 10:38 PM
RE: Shock Ability - by Lightning - 07-10-2018, 06:37 PM
RE: Shock Ability - by Lightning - 09-06-2018, 12:28 AM
RE: Shock Ability - by Gi Nattak - 07-10-2018, 07:35 PM
RE: Shock Ability - by Lightning - 07-10-2018, 11:05 PM
RE: Shock Ability - by Lightning - 07-19-2018, 03:52 PM
RE: Shock Ability - by GrayShadows - 07-20-2018, 12:53 AM
RE: Shock Ability - by Warrax - 07-20-2018, 01:24 AM
RE: Shock Ability - by PowerPanda - 07-20-2018, 12:19 PM
RE: Shock Ability - by GrayShadows - 07-20-2018, 12:26 PM
RE: Shock Ability - by Lightning - 07-20-2018, 05:44 PM
RE: Shock Ability - by Warrax - 07-20-2018, 05:56 PM
RE: Shock Ability - by Lightning - 07-20-2018, 05:58 PM
RE: Shock Ability - by PowerPanda - 09-10-2018, 10:53 AM
RE: Shock Ability - by Lightning - 09-10-2018, 01:01 PM
RE: Shock Ability - by PowerPanda - 09-10-2018, 01:37 PM
RE: Shock Ability - by Lightning - 09-10-2018, 01:42 PM
RE: Shock Ability - by PowerPanda - 09-10-2018, 02:13 PM
RE: Shock Ability - by Lightning - 09-10-2018, 03:20 PM
RE: Shock Ability - by PowerPanda - 09-10-2018, 04:22 PM
RE: Shock Ability - by Lightning - 09-10-2018, 06:44 PM
RE: Shock Ability - by PowerPanda - 09-10-2018, 07:46 PM
RE: Shock Ability - by Lightning - 09-10-2018, 09:03 PM
RE: Shock Ability - by madsiur - 09-10-2018, 09:31 PM
RE: Shock Ability - by Lightning - 09-10-2018, 09:41 PM
RE: Shock Ability - by PowerPanda - 09-10-2018, 10:35 PM
RE: Shock Ability - by Subtraction - 09-11-2018, 02:16 AM
RE: Shock Ability - by Lightning - 09-11-2018, 03:57 AM
RE: Shock Ability - by Warrax - 09-11-2018, 08:39 AM
RE: Shock Ability - by madsiur - 09-11-2018, 10:52 AM
RE: Shock Ability - by PowerPanda - 09-11-2018, 09:15 AM
RE: Shock Ability - by Lightning - 09-11-2018, 03:47 PM
RE: Shock Ability - by PowerPanda - 09-11-2018, 06:28 PM
RE: Shock Ability - by Lightning - 09-11-2018, 06:47 PM

Forum Jump:

Users browsing this thread: 2 Guest(s)


Theme by Madsiur2017Custom Graphics by JamesWhite