GoombaYoshi

by djief

Game: SMW

Description: Puts Goombas in Yoshi's mouth

!spriteNum		=	$0F
!swallowTimer	=	$FF

;===================================================================================
LDA $100	; \ only run in gamemode 14
	EOR #$14	; |
	ORA $9D		; | and when the game isn't paused
	BEQ +		; |
	RTL		; |
+	
	LDA $187A
	BEQ ret


	LDY $18DF			; load Yoshi's slot (+1)
	BEQ ret				; if 0, no Yoshi, so return
	DEY						; now Y = Yoshi's slot

  yoshifound:
	LDA $160E,y
	CMP #$FF
	BNE ret
	LDA $1594,y
	BNE ret
	LDX 11	; finds a free sprite slot, doesn't spawn anything if no slot
  loop:
        LDA $14C8,x	
	BEQ found				
	DEX
	BPL loop
  ret:
	RTL
	
 found:	
	LDA #!spriteNum 	: STA $009E,x		; spawns the item in yoshi's mouth
	LDA #$07        	: STA $14C8,x
	TXA					: STA $160E,y
	LDA #!swallowTimer	: STA $18AC
	
	if !spriteNum == $80				; Tells the game yoshi has a key in mouth
		LDA #$01
		STA $191C
	endif

	
	JSL $07F7D2


	
	RTL
back to listings