incsrc subroutinedefs_trasm.asm

dcb "INIT"
JSL SubHorizPos
TYA
STA $157C,x
STZ $0E85,x
RTL

dcb "MAIN"
PHB		
PHK		
PLB		
JSR SpriteCode	
PLB		
RTL	

Flip:
LDA $157C,x
EOR #$01
STA $157C,x
BRA Comebacknow

RETURN: 
RTS

Checkforprox:
JSR Proximity
STA $1763
BEQ Lalalacomeback3
INC $0E85,x
BRA Comebacknow

SpriteCode:
	LDA $14C8,x			
	CMP #$08			
	BNE RETURN
	LDA $9D				
	BNE RETURN			
	
	JSL SubOffScreenX0

	LDA $1588,x 
	AND #$03
	BNE Flip	
Comebacknow:

LDA $0E85,x
BEQ Checkforprox
; dropping
LDA #$20
STA $AA,x
STZ $B6,x
BRA UpdatedSpeed

Lalalacomeback3:
	LDY $157C,x	
	LDA xxxspd,y
	STA $B6,x	
UpdatedSpeed:
LDA $1588,x
AND #$04
BNE hitthefloor
JSR yomama
JSL $81801A
JSL $818022
JSL $819138
	JSL $818032			
	JSL $81A7DC
	BCC Nothinghappened
	LDA #$09
	STA $14C8,x
	LDA #$11
	STA $9E,x
	JSL $87F7D2
;	LDA #$02
;	STA $14C8,x
;	LDA #$D0
;	STA $AA,x
;	LDA #$08
;	STA $B6,x
;	JSL $81802A
	Nothinghappened:
RTS

hitthefloor:
JSR askuhduakhduahsdhjhdskjah
RTS

SPEEDXY: dcb $10,$F0
yyyys: dcb $F0,$F0
xxxspd: dcb $08,$F7
;====================================================================================================

PROPERTIES: dcb $CD,$8D
TILEMAP: dcb $80,$82
TILEMAP1234: dcb $84,$88

yomama:
	JSL GetDrawInfo 	
	
	LDA $157C,x
	STA $02			

	LDA $00			
	STA $0300,y		

	LDA $01			
	STA $0301,y		

LDA $0E85,x
BNE hhhuhuikkujk
	PHX
	LDA $13
	LSR
	LSR
	LSR
	AND #$01
	TAX
	LDA TILEMAP,x
	STA $0302,y

	LDX $02			
	LDA PROPERTIES,x
	ORA $64
	STA $0303,y		
	PLX	
BRA thisistheuplaoder
hhhuhuikkujk:
	PHX
	LDA $13
	LSR
	LSR
	LSR
	AND #$01
	TAX
	LDA TILEMAP1234,x
	STA $0302,y

	LDX $02			
	LDA PROPERTIES,x
	ORA $64
	STA $0303,y		
	PLX	


	
thisistheuplaoder:
;	INY			
;	INY			
;	INY			
;	INY			

	LDY #$02		
	LDA #$00		

	JSL $81B7B3		
	RTS	
;====================================================================================================
					
Proximity:		; If sprite is TOO close to Mario, return.
	LDA $14E0,x
	XBA
	LDA $E4,x
	REP #$20 ; Get sprite's X position.
	SEC
	SBC $94	; Subtract Mario's to get the difference range.
	SEP #$20
	PHA
	JSL SubHorizPos ; Determine sprite range.
	PLA
	EOR InvertAbility,y ; Apply inversion based on direction.
	CMP #$09 ; Range.
	BCS OutofRange
	LDA #$01
	RTS
OutofRange:
	LDA $E4,x
	CMP $94
	BNE RangeOut
	LDA #$01
	RTS
RangeOut:
	LDA #$00
	RTS
InvertAbility:
	dcb $FF,$00

askuhduakhduahsdhjhdskjah:
;	LDA $14
;	AND #$7F
;;	ORA $9D
;	BNE RETURN2
;	JSL $82A9DE
;	BMI RETURN2
;	PHX
;	TYX
	LDA #$01
	STA $14C8,x
	LDA #$11
	STA $9E,x
	JSL $87F7D2
;	TXY
;	PLX
;	LDA $E4,x
;	STA $00E4,y
;	LDA $14E0,x
;	STA $14E0,y
;	LDA $D8,x
;	STA $00D8,y
;	LDA $14D4,x
;	STA $14D4,y
;RETURN2:
	RTS 
