header
lorom

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

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

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





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 $00AE47
autoclean JML Boost0701

org $0084E2
dl OneTwoPlayerStim

;tweak this whenever the stripes are edited
org $009D55 : LDA #$8C
org $009DAB : SBC $AA
org $009D96 : LDY #$01

org $809D3A
autoclean JML stuff

org $809B7B
autoclean JML ultrastuff

freecode

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

FileSelectCode:
STZ $0DDE
LDX #$00
REP #$10
LDY.w #$0000
-
LDA FileSelectStimStart,x
PHX : TYX
STA $7F837D,x
PLX : INX : INY
CPY.w #FileSelectStimEnd-FileSelectStimStart+$0001
BNE -
LDA #$32
STA $AA
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 -
SEP #$10
JML $809DB4


ultrastuff:
LDA $05
LDX #$00
LDA #$0A
STA $AA
REP #$10
LDY.w #$0000
-
LDA UltraStimStart,x
PHX : TYX
STA $7F837D,x
PLX : INX : INY
CPY.w #UltraStimEnd-UltraStimStart+$0001
BNE -
SEP #$10
LDA #$16
JML $809D57

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

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

UltraStimStart:
incbin ultra.stim
UltraStimEnd:

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

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

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

argh:
	JML $009C6C



;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