Users browsing this thread: 3 Guest(s)
Final Requests for Help
04-06-2021, 07:24 AM
Here's some code I wrote years ago for expanding Throwable items. You can use this to give items an effect when thrown.
Code:
; Generic non-magic Skean function
; Compares item ID to a table of IDs, then uses a jump table to jump to
; mini-functions to perform for that specific item ID
hirom
;header
!freespace = $C265A0
; The safe and sane version - no infinite loops if no match
org $C22ADC
C22ADC: LDA $01,S ; Item ID
PHX ; Preserve X
LDX #$0006 ; Check four entries: 0, 2 ,4, 6
.loop CMP.l table,X ; Compare with table of item IDs
BEQ .jump ; If match, jump
DEX #2 ; Next item
BPL .loop ; Loop and check next table entry
BRA .end ; If no matches, no action
.jump JSR (jumptable,X) ; If match, perform associated function
.end PLX
print pc
; The unsafe version - assumes a match, saves 4 bytes
; Better make sure there's a matching Item ID table entry for each throwable
;org $C22ADC
;C22ADC: LDA $01,S
; PHX
; LDX #$0006
;.loop DEX #2
; CMP.l throwables,X
; BNE .loop
;.dostuff JSR (jumptable,X)
;.end PLX
; NOP #4
;print pc
org !freespace
reset bytes
table:
print "inviz edge:", pc
dw $00AE ; Inviz Edge
print "shadow edge:", pc
dw $00AF ; Shadow Edge
print "smoke bomb:", pc
dw $00FC ; Smoke Bomb
dw $0043 ; Tack Star
jumptable:
dw inviz_Edge
dw shadow_Edge
dw smoke_Bomb
dw magic_Shuriken
inviz_Edge:
LDA #$10
TSB $11AA ; Set Clear in status attack byte 1
RTS
shadow_Edge:
LDA #$04
TSB $11AB ; Set Image in status attack byte 2
RTS
smoke_Bomb:
LDA #$96 ; Special effect $4B (doubled to serve as index)
STA $11A9 ; Set Smoke Bomb in Special Effect
LDA #$01
STA $B5 ; Set command to Item for animation purposes, and so the Can't Run check works
RTS
magic_Shuriken:
LDA #$02
TRB $B2 ; Clear no critical and ignore True Knight
LDA #$0E ; Special Effect $07 (doubled)
STA $11A9 ; Set MP Crits
RTS
print bytes
« Next Oldest | Next Newest »
Users browsing this thread: 3 Guest(s)