        CASE ON         ; Enable case sensitivity for labels

        EXPORT	R0138_CPSEF_HiddenCodeLauncher  
        SEG 'main'
R0138_CPSEF_HiddenCodeLauncher  PROC
        LDA        $34            ; Backup value at offset $34 to stack
        PHA
        LDA        $32            ; Backup value at offset $32 to stack
        PHA
        PER        L0209B2+4      ; Offset of routine data following R0138_CPSEF_HiddenCodeLauncher code
        PLA
        STA        $32            ; Store offset of routine data at offset $32
        SEP        #$20
        LONGA OFF
        PHK                       ; Get program bank register
        PLA
        STA        $34            ; Store program bank register at offset $32
        STZ        $35            ; Store 0 at offset $34. Offset $32 now contains the 4 bytes address to routine data
        REP        #$20
        LONGA ON
        LDY        #$1a
        LDA        [$32],Y        ; Offset 26 in routine data
        TAY
        PLA
        STA        $32
        PLA
        STA        $34
        TDC
        TAX
        TYA
        TCD
        STX        $30
        PER        L0209B2+4
        PLA
        STA        $32
        SEP        #$20
        LONGA OFF
        PHK
        PLA
        STA        $34
        STZ        $35
        REP        #$20
        LONGA ON
        LDY        #$14
        LDA        #$00
        STA        [$32],Y        ; Offset 20 in routine data
        LDY        #$00
        LDA        [$32],Y        ; Offset 0 in routine data
        STA        $36
        INY
        INY
        LDA        [$32],Y        ; Offset 2 in routine data
        STA        $38
        LDY        #$16
        LDA        [$32],Y        ; Offset 22 in routine data
        STA        [$36]
        INC        $36
        INC        $36
        INY
        INY
        LDA        [$32],Y        ; Offset 24 in routine data
        STA        [$36]
        LDY        #$08
        PHD
        LDA        [$32],Y        ; Offset 8 in routine data
        PHA
        PER        L020939
        PLA
        INC        A
        STA        $36
        LDA        $34
        STA        $38
        LDY        #$04
        LDA        [$32],Y        ; Offset 4 in routine data
        STA        [$36]
        INC        $36
        INC        $36
        INY
        INY
        SEP        #$20
        LONGA OFF
        LDA        [$32],Y        ; Offset 6 in routine data
        STA        [$36]
        REP        #$20
        LONGA ON
        LDA        $30
        TCD
L020939 JSL        $ff0000
        PLY
        PLD
        STX        $3c
        STA        $3a
        CLC
        ADC        #$c8
        BCC        L02095E
        LDX        #$c6
        TXY
L02094D LDA        [$3a],Y
        STA        $40,X
        DEX
        DEX
        DEY
        DEY
        BPL        L02094D
        LDA        #$40
        STA        $3a
        STZ        $3c
L02095E LDY        #$12
L020961 LDA        [$32],Y        ; Offset 10 to 18 in routine data
        PHA
        DEY
        DEY
        CPY        #$0a
        BCS        L020961
        PER        L020985
        PLA
        INC        A
        STA        $36
        LDA        $34
        STA        $38
        LDA        $3a
        STA        [$36]
        LDY        #$02
        SEP        #$20
        LONGA OFF
        LDA        $3c
        STA        [$36],Y
        REP        #$20
        LONGA ON
L020985 JSL        $ff0000
        TSC
        CLC
        ADC        #$0a
        TCS
        PER        L0209B2
        PLA
        INC        A
        STA        $36
        LDA        $34
        STA        $38
        LDY        #$00
        LDA        [$32],Y        ; Offset 0 in routine data
        STA        [$36]
        INC        $36
        INC        $36
        INY
        INY
        SEP        #$20
        LONGA OFF
        LDA        [$32],Y        ; Offset 2 in routine data
        STA        [$36]
        REP        #$20
        LONGA ON
        LDA        $30
        TCD
L0209B2 JMP        $ff0000
        ENDP
        END
