;@xkas
header
lorom

!freeram = $60 		;dont edit this snn or everything will break

org $009C67	;layer 3 menu frozen until set free by $60
JML asdf1

org $00941E
db $80,$01
db $00
db $80

org $298000
asdf1:
	LDA !freeram
	BEQ argh
	LDA $15
	ORA $17
	AND #$80
	BEQ argh

	LDA #$15
	STA $1DFC
	JML $009CA3

argh:
	JML $009C6C

LDA #$FE		;Alcaro's a Genius
org $009DAB		;
SBC #$58		;Elminiates garbage on file selection screen
org $009D96		;
LDY #$01		;

org $009CAD	;enable title screen hdma
rep 3 : NOP

org $009C82	;stop title screen movement and looping
db $EA,$A9,$00


org $00941E	;disable circle fade in
	INC $0100
	LDA #$01
	STA $1DF5
rolf:
	JSL $7F8000
	LDA #$EC
	JMP $9440

org $009ABD	;see above
	JSR rolf


org $009EBA	;repoint arrow tilemap
db $A5,$30	
org $009EC1
db $A6,$30	

org $009AD0
NOP #3		;disable blinking


;/NEW LAYER 3 MENU

org $05B722
;     -       -       .       .       .       M       A       R       I       O               A               E       M       P       T       Y   
db $51,$EA,$00,$1F,$24,$38,$24,$38,$24,$38,$76,$31,$71,$31,$74,$31,$82,$30,$83,$30,$FC,$38,$71,$31,$FC,$38,$73,$31,$76,$31,$6F,$31,$2F,$31,$72,$31
db $52,$2A,$00,$1F,$24,$38,$24,$38,$24,$38,$76,$31,$71,$31,$74,$31,$82,$30,$83,$30,$FC,$38,$2C,$31,$FC,$38,$73,$31,$76,$31,$6F,$31,$2F,$31,$72,$31
db $52,$6A,$00,$1F,$24,$38,$24,$38,$24,$38,$76,$31,$71,$31,$74,$31,$82,$30,$83,$30,$FC,$38,$2D,$31,$FC,$38,$73,$31,$76,$31,$6F,$31,$2F,$31,$72,$31

org $809D3A
JML stuff

org $A98019	;freespace
db "STAR"
dw StuffEnd-stuff-$01
dw StuffEnd-stuff-$01^$FFFF

stuff:
STZ $05
CPX #$CB
BEQ FileSelectCode
BRA EraseFileSelectCode

FileSelectCode:
LDX #$00
REP #$10
LDY.w #$0000
-
LDA FileSelectStimStart,x
PHX : TYX
STA $7F837D,x
PLX : INX : INY
CPY.w #FileSelectStimEnd-#FileSelectStimStart+#$0001
BNE -
JML $809D53

EraseFileSelectCode:
LDX #$00
REP #$10
LDY.w #$0000
-
LDA EraseFileSelectStimStart,x
PHX : TYX
STA $7F837D,x
PLX : INX : INY
CPY.w #EraseFileSelectStimEnd-#EraseFileSelectStimStart+#$0001
BNE -
JML $809D53

FileSelectStimStart:
;incbin fileselect.stim
incbin fileselect3.stim
FileSelectStimEnd:

EraseFileSelectStimStart:
;incbin erasefileselect.stim
incbin erasefileselect3.stim
EraseFileSelectStimEnd:

OneTwoPlayerStim:
;incbin 12player.stim
incbin 12player3.stim



;pasted from overworld exanimation
Boost0701:
;The original patch overflowed vblank, which generated some quite bad garbage. To fix this, I tried to optimize some other routines.
;Sadly, this was the only optimizable spot I found, and it wasn't enough. I had to split the uploads to two frames.
;But some extra VRAM time never hurts... (note: affects levels too)
LDA $0701
AND #$1F
ORA #$20
STA $2132

REP #$20
LDA $0701
LSR #2
SEP #$20;putting this SEP as soon as possible should save three more cycles...
LSR #3
AND #$1F
ORA #$40
STA $2132

LDA $0702
LSR #2
;I don't need AND #$1F here unless the top bit here is set, and it isn't.
ORA #$80
STA $2132
JML $00AE64


StuffEnd:

org $00AE47
JML Boost0701

org $0084E2
dl OneTwoPlayerStim

;this part restores some kind of fuckup on leod's side; it is not useful whenever this one is ported to a clean rom
;(though it does no harm either)
org $05B93B
db $00,$06,$40,$06
