SECTION "SRA2", ROM0[$A000]

_SRA2Checksum:
    ds 1

_SRA2Ident:
    db 2
include "engine/utils.asm"
include "engine/text.asm"
include "engine/menu.asm"
include "engine/overworld.asm"
include "engine/dma_hijacking.asm"
include "engine/ram_script.asm"

include "engine/gameover.asm"

_Start:
    ld de, NewRoute25TextPointers
    ld hl, $D36B ;wMapTextPtr
    ld a, e
    ldi [hl], a
    ld a, d
    ld [hl], a
    ret

NewRoute25TextPointers:
    dw CrashText
    dw CrashText
    dw LoadMisfortuneText
    dw CrashText
    dw CrashText
    dw CrashText
    dw CrashText
    dw CrashText
    dw CrashText
    dw CrashText
    dw CrashText

CrashText:
    db $08 ;TX_ASM
    xor a
    call SwitchToSRAX_NoPreserve
    rst $38

LoadMisfortuneText:
    
    ;db $41, $72, $65, $20, $79, $6F, $75, $20, $72, $65, $61 ; initial glitch textbox
    ;db $64, $79, $20, $74, $6F, $20, $70, $6C, $61, $79, $3F ; stuff. actually ascii 
    ; "Are you ready to play?"

    db $08 ;TX_ASM

    xor a
    ldh [$FFD7], a ;hTilesetType

    jr .skipEffect	; for quick debug entry

    ld a, $77
    ld [wPartyCount], a
    ld a, b_AnimateHealingMachine
    call $3E7E ;BankSwitchCommon
    call AnimateHealingMachine

.skipEffect
    call LoadMisfortuneGraphics
    call DisableLCD ; yea i know youd normally do this before loading the graphics but im doing it after for extra glitch points

    xor a
    ldh [$FFBA], a    ;H_AUTOBGTRANSFERENABLED
    ld [wUpdateSpritesEnabled], a

    	;ld hl, wOAMBuffer	; not necessary
    	;ld bc, 8*5*4
    	;call FillMemory

    call CutToBlack

    call EnableLCD
    ld c, $77
    call DelayFrames

    ; set stack pointer to empty?
    
    
    			;jp LoadMisfortune

		;LoadMisfortune:
    
    ld a, [wOnSGB]
    and a
    jr z, .noColor
    ld b, $08 ;SET_PAL_GENERIC
    call RunPaletteCommand ; if i can figure out how id like to make this a dmg style green palette
.noColor
    	;call PlaySong_M1
    ld a, $FF
    call PlaySound
    call PlaySong_M3
    ld sp, wStack
    jp M_OverworldInit

CutToBlack:
    ld a, $80
    ld hl, $9C00
    ld bc, $9E34 - $9C00
    call FillMemory
    xor a
    ldh [$FFB0], a
    ret

