lorom

;Enemy hit explosion, concept asm by Black Falcon

;when Samus's projectiles hit an enemy, they usually dissappear unspectacular :<
;this patch draws explosions at the moment the projectile hits an enemy, like in Fusion or Zero Mission
;list of possible values for explosions at the very bottom of this page:
;http://jathys.zophar.net/supermetroid/kejardon/RandomRoutines.txt

;this is just a proof of concept, so there are a few things missing:
; - check for enemy vulnerability
;   ie don't draw explosions if enemy
;   is unvulnerable to that specific weapon
; - individual sound effects for each projectile
;   (that'd take more space than it'd make sense... >_> )
; - the normal beam explosion (with specific beam color)
; - what about Bombs !?

; you may use and modify this code without the need to give credit

;values for explosion types
!missile = #$0003
!super = #$001D
!charge = #$000C


;DONT TOUCH THE ONES BELOW FOR ANY REASON!

!boom = $B4BC26
!prox = $0B64,y
!proy = $0B78,y
!projectiles = $0C18,y

org $A09CBD	;hijack special gfx enemies (pirates, bosses, etc)

JSR SPECIAL

;org $A0A1E3	ignore both....
;org $A0A1D8



org $A0A1EF	;hijack normal enemy

JSR NORMAL

org $A0F7E0
SPECIAL:		;because the hijacks overwrote different things
	LDX $0E54
	BRA SKIP

NORMAL:
	LDA $18A6
SKIP:
	PHA			;push stuff
	PHX
	PHY
	LDA !prox	;y is already given before the hijack
	STA $12		;X position
	LDA !proy
	STA $14		;Y position
	STZ $18		;clear an unknown glitchy-if-positive byte o_O? (palette?)

	LDA !projectiles
	AND #$0F00
	CMP #$0100
	BEQ MISSILE

	CMP #$0200
	BEQ SUPER

	LDA !projectiles ;I think there are possibilities to save space here...
	AND #$0010
	CMP #$0010
	BEQ CHARGE
	LDA !projectiles
	AND #$000F
	ASL a
	TAX
	LDA BEAMS,x		;example value is #$000C (small yellow smoke, you'll recognize it)
					;so you have to choose your explosion type
					;(link to possible values at the top)
	BRA BOOM

BEAMS:
DW $000C	;POWER
DW $000C	;WAVE
DW $000C	;ICE
DW $000C	;WAVE + ICE
	
DW $000C	;Spazer
DW $000C	;Spazer + Wave
DW $000C	;Spazer + Ice
DW $000C	;Spazer + wave + ice	
	
DW $000C	;plasma	
DW $000C	;plasma + wave 
DW $000C	;plasma + ice
DW $000c	;plasma + wave + ice

MISSILE:
	LDA !missile	;small explosion (standard missile)
	BRA BOOM

SUPER:
	LDA !super	;large explosion atm (normal super missile)
	BRA BOOM

CHARGE:
	LDA !charge	
BOOM:

	STA $16		;type
	JSL !boom	;Draw an explosion
	
	LDA $0B64,y
	STA $12
;second explosion, uncomment if you want, copy/paste to get as much
;additional explosions as you want (not projectile specific, will always be displayed)

;	LDA #$000C	
;	STA $16
;	JSL !boom  

	LDA #$0007	;value for screw attack killing an enemy
	JSL $8090AD	;Play sound
LEAVE:
	PLY
	PLX
	PLA
	RTS


