;================================================================
; [intro.inc] -- Intro sequence for Cute Angela
;
; Okay! This file started out nicely (as always), but has ended
; up looking like as all hell has broken loose and been partying
; like maniacs kicking those poor bits 'n bytes >:(
;
; ..but it works, though!
;================================================================

SEQ_INTRO_KA
    lda introSIKA_again
    cmp #$01
    beq SIKA_OK_AGAIN
    rts

SIKA_OK_AGAIN

    jsr INIT_VIDEO_03
    lda #$80
    sta $2100                   ; screen off, no brightness

    LOAD_PAL BG_PAL
    LOAD_BLOCK2VRAM FONT2_TILES,$2000,$1800
    wai
    wai

    jsr SIKA_drawBorder         ; draw window border

    stz $2121                   ; change colour index #0 to pure black
    lda #$00
    sta $2122
    sta $2122

    lda #$02
    sta $212c                   ; disable all, but bg#2.

    GOTOXY 1,3
    PRINTS "DO YOU CARE FOR THE INTRO?"
    GOTOXY 2,3
    PRINTS " IT IS QUITE INFORMATIVE. "
    GOTOXY 5,14
    PRINTS "YAY!"
    GOTOXY 6,14
    PRINTS "NAY!"

    FADE_IN
    GOTOXY 6,11
    PRINTS "st"

    ldx #$01
    stx a_word                  ; the ping manager
    stz a_byte
    inc a_byte                  ; selection pointer
    lda #$ff
    sta a_byte2                 ; selection time countdown


SI_KA_loop
    wai
    wai
    dec a_byte2
    lda a_byte2
    cmp #$00
    bne SI_KA_continue
    jmp SI_KA_decided
SI_KA_continue
    lda joy1+1
    and #$08                    ; is the up key pressed?
    beq SI_KA_notUp             ; nope! let's branch

    ldx a_word
    cpx #$00
    beq SI_KA_noDing
;   lda #V1SFX_DING_A_LING_LOW
;   sta V1SFX
;   jsr AUDIO_PLAY_V1SFX
    ldx #$00
    stx a_word
SI_KA_noDing

    stz a_byte

    GOTOXY 5,11
    PRINTS "st"
    GOTOXY 6,11
    PRINTS "  "

    jmp SI_KA_notDown
SI_KA_notUp
    lda joy1+1
    and #$04                    ; key down then?
    beq SI_KA_notDown           ; nay!

    ldx a_word
    cpx #$01
    beq SI_KA_noPing
;   lda #V1SFX_PING_LOW
;   sta V1SFX
;   jsr AUDIO_PLAY_V1SFX
    ldx #$01
    stx a_word
SI_KA_noPing
    lda #$01
    sta a_byte

    GOTOXY 5,11
    PRINTS "  "
    GOTOXY 6,11
    PRINTS "st"

SI_KA_notDown
    lda joy1+1
    and #$10                    ; check start button
    beq SI_KA_chkX
    jmp SI_KA_decided
SI_KA_chkX
    lda joy1
    and #$40                    ; check x button
    beq SI_KA_chkA
    jmp SI_KA_decided
SI_KA_chkA
    lda joy1
    and #$80                    ; check "a" button
    beq SI_KA_chkB
    jmp SI_KA_decided
SI_KA_chkB
    lda joy1+1
    and #$80                    ; check b button
    beq SI_KA_chkY
    jmp SI_KA_decided
SI_KA_chkY
    lda joy1+1
    and #$40                    ; check y button
    beq SI_KA_loopyEnd
    jmp SI_KA_decided
SI_KA_loopyEnd
    jmp SI_KA_loop

SI_KA_decided
    lda #V0SFX_DEEP_THUMP
    sta V0SFX
    jsr AUDIO_PLAY_V0SFX

    lda a_byte
    cmp #$01
    beq SI_KA_noIntro
    FADE_OUT
    jsr SPLSC_CLR
    jsr SEQ_INTRO
    rts

;----------------------------------

SI_KA_noIntro
    ldx #$3f
    jsr theWayOfTheWAI

    GOTOXY 10,3
    PRINTS "WORD FROM THE HIGHER UPS.."
    GOTOXY 11,3
    PRINTS "    DO WE REALLY CARE?    "
    GOTOXY 14,14
    PRINTS "YUP!"
    GOTOXY 15,14
    PRINTS "MEH!"

    GOTOXY 15,11
    PRINTS "st"

    ldx #$01
    stx a_word                  ; the ping manager
    stz a_byte
    inc a_byte                  ; selection pointer
    lda #$ff
    sta a_byte2                 ; selection time countdown

SI_KA2_loop
    wai
    wai
    dec a_byte2
    lda a_byte2
    cmp #$00
    bne SI_KA2_continue
    jmp SI_KA2_decided
SI_KA2_continue
    lda joy1+1
    and #$08                    ; is the up key pressed?
    beq SI_KA2_notUp            ; nope! let's branch

    ldx a_word
    cpx #$00
    beq SI_KA2_noDing
;   lda #V1SFX_DING_A_LING_LOW
;   sta V1SFX
;   jsr AUDIO_PLAY_V1SFX
    ldx #$00
    stx a_word
SI_KA2_noDing

    stz a_byte

    GOTOXY 14,11
    PRINTS "st"
    GOTOXY 15,11
    PRINTS "  "

    jmp SI_KA2_notDown
SI_KA2_notUp
    lda joy1+1
    and #$04                    ; key down then?
    beq SI_KA2_notDown          ; nay!

    ldx a_word
    cpx #$01
    beq SI_KA2_noPing
;   lda #V1SFX_PING_LOW
;   sta V1SFX
;   jsr AUDIO_PLAY_V1SFX
    ldx #$01
    stx a_word
SI_KA2_noPing
    lda #$01
    sta a_byte

    GOTOXY 14,11
    PRINTS "  "
    GOTOXY 15,11
    PRINTS "st"

SI_KA2_notDown
    lda joy1+1
    and #$10                    ; check start button
    beq SI_KA2_chkX
    jmp SI_KA2_decided
SI_KA2_chkX
    lda joy1
    and #$40                    ; check x button
    beq SI_KA2_chkA
    jmp SI_KA2_decided
SI_KA2_chkA
    lda joy1
    and #$80                    ; check "a" button
    beq SI_KA2_chkB
    jmp SI_KA2_decided
SI_KA2_chkB
    lda joy1+1
    and #$80                    ; check b button
    beq SI_KA2_chkY
    jmp SI_KA2_decided
SI_KA2_chkY
    lda joy1+1
    and #$40                    ; check y button
    beq SI_KA2_loopyEnd
    jmp SI_KA2_decided
SI_KA2_loopyEnd
    jmp SI_KA2_loop

SI_KA2_decided
    lda #V0SFX_DEEP_THUMP
    sta V0SFX
    jsr AUDIO_PLAY_V0SFX

    lda a_byte
    cmp #$01
    beq SI_KA_noProfessor
    FADE_OUT
    jsr SPLSC_CLR
    jsr SEQ_PROFESSOR
    jmp SI_KA_noProfessorNoFO

SI_KA_noProfessorNoFO
    jsr SPLSC_CLR
    rts


;----------------------------------


SI_KA_noProfessor
    ldx #$3f
    jsr theWayOfTheWAI

    GOTOXY 19,2
    PRINTS "   BUT DO YOU REALLY CARE   "
    GOTOXY 20,2
    PRINTS "ABOUT REVISITING THIS SCREEN"
    GOTOXY 21,2
    PRINTS "NEXT TIME WHEN GAME IS OVER?"

    GOTOXY 24,14
    PRINTS "/*"
    GOTOXY 25,14
    PRINTS "**`"

    GOTOXY 24,11
    PRINTS "st"

    ldx #$01
    stx a_word                  ; the ping manager
    stz a_byte                  ; selection pointer
    lda #$ff
    sta a_byte2                 ; selection time countdown

SI_KA3_loop
    wai
    wai
    dec a_byte2
    lda a_byte2
    cmp #$00
    bne SI_KA3_continue
    jmp SI_KA3_decided
SI_KA3_continue
    lda joy1+1
    and #$08                    ; is the up key pressed?
    beq SI_KA3_notUp            ; nope! let's branch

    ldx a_word
    cpx #$00
    beq SI_KA3_noDing
;   lda #V1SFX_DING_A_LING_LOW
;   sta V1SFX
;   jsr AUDIO_PLAY_V1SFX
    ldx #$0000
    stx a_word
SI_KA3_noDing

    stz a_byte

    GOTOXY 24,11
    PRINTS "st"
    GOTOXY 25,11
    PRINTS "  "

    jmp SI_KA3_notDown
SI_KA3_notUp
    lda joy1+1
    and #$04                    ; key down then?
    beq SI_KA3_notDown          ; nay!

    ldx a_word
    cpx #$01
    beq SI_KA3_noPing
;   lda #V1SFX_PING_LOW
;   sta V1SFX
;   jsr AUDIO_PLAY_V1SFX
    ldx #$01
    stx a_word
SI_KA3_noPing
    lda #$01
    sta a_byte

    GOTOXY 24,11
    PRINTS "  "
    GOTOXY 25,11
    PRINTS "st"

SI_KA3_notDown
    lda joy1+1
    and #$10                    ; check start button
    beq SI_KA3_chkX
    jmp SI_KA3_decided
SI_KA3_chkX
    lda joy1
    and #$40                    ; check x button
    beq SI_KA3_chkA
    jmp SI_KA3_decided
SI_KA3_chkA
    lda joy1
    and #$80                    ; check "a" button
    beq SI_KA3_chkB
    jmp SI_KA3_decided
SI_KA3_chkB
    lda joy1+1
    and #$80                    ; check b button
    beq SI_KA3_chkY
    jmp SI_KA3_decided
SI_KA3_chkY
    lda joy1+1
    and #$40                    ; check y button
    beq SI_KA3_loopyEnd
    jmp SI_KA3_decided
SI_KA3_loopyEnd
    jmp SI_KA3_loop

SI_KA3_decided
    lda #V0SFX_DEEP_THUMP
    sta V0SFX
    jsr AUDIO_PLAY_V0SFX

    lda a_byte
    cmp #$00
    beq SI_KA_DaCapo
    stz introSIKA_again
    jmp SI_KA_noDaCapo

SI_KA_DaCapo
    lda #$01
    sta introSIKA_again
SI_KA_noDaCapo
    FADE_OUT
    jsr SPLSC_CLR
    rts


;================================


SIKA_drawBorder
.ENDASM
    GOTOXY 15,11
    PRINTS "v|nnnnnn@w"
    GOTOXY 16,11
    PRINTS "zqqqqqqqq{"
    GOTOXY 17,11
    PRINTS "lqqqqqqqqm"
    GOTOXY 18,11
    PRINTS "jqqqqqqqqk"
    GOTOXY 19,11
    PRINTS "x}ooooooiy"
.ASM

    GOTOXY 0,0
    PRINTS "v|nnnnnnnnnnnnnnnnnnnnnnnnnnnn@w"
    GOTOXY 1,0
    PRINTS "zuuuuuuuuuuuuuuuuuuuuuuuuuuuuuu{"

    GOTOXY 2,0
    jsr SIKA_dB_drFrm
    GOTOXY 3,0
    jsr SIKA_dB_drFrm
    GOTOXY 4,0
    jsr SIKA_dB_drFrm
    GOTOXY 5,0
    jsr SIKA_dB_drFrm
    GOTOXY 6,0
    jsr SIKA_dB_drFrm
    GOTOXY 7,0
    jsr SIKA_dB_drFrm
    GOTOXY 8,0
    jsr SIKA_dB_drFrm
    GOTOXY 9,0
    jsr SIKA_dB_drFrm
    GOTOXY 10,0
    jsr SIKA_dB_drFrm
    GOTOXY 11,0
    jsr SIKA_dB_drFrm
    GOTOXY 12,0
    jsr SIKA_dB_drFrm
    GOTOXY 13,0
    jsr SIKA_dB_drFrm
    GOTOXY 14,0
    jsr SIKA_dB_drFrm
    GOTOXY 15,0
    jsr SIKA_dB_drFrm
    GOTOXY 16,0
    jsr SIKA_dB_drFrm
    GOTOXY 17,0
    jsr SIKA_dB_drFrm
    GOTOXY 18,0
    jsr SIKA_dB_drFrm
    GOTOXY 19,0
    jsr SIKA_dB_drFrm
    GOTOXY 20,0
    jsr SIKA_dB_drFrm
    GOTOXY 21,0
    jsr SIKA_dB_drFrm
    GOTOXY 22,0
    jsr SIKA_dB_drFrm
    GOTOXY 23,0
    jsr SIKA_dB_drFrm
    GOTOXY 24,0
    jsr SIKA_dB_drFrm

    GOTOXY 25,0
    PRINTS "juuuuuuuuuuuuuuuuuuuuuuuuuuuuuuk"
    GOTOXY 26,0
    PRINTS "x}ooooooooooooooooooooooooooooiy"

    rts

SIKA_dB_drFrm
    PRINTS "luuuuuuuuuuuuuuuuuuuuuuuuuuuuuum"
    rts


;================================


SEQ_PROFESSOR
    jsr INIT_VIDEO_04
    lda #$80
    sta $2100                   ; screen off, no brightness

    lda #$63                    ; 16x16 spr. size, chr data at $6000
    sta $2101                   ; set oam size register

    jsr SEQ_setUpUsTheSprites
    jsr SEQ_hideSprites

    ldx #$0000
    stx MAPX
    stx MAPY                    ; reset bg#1 map x,y location

    lda #SONG_RUD21
    sta MUSIC
    jsr AUDIO_PLAY_SONG

    ldx #$64
    jsr theWayOfTheWAI

    LOAD_PAL INTRO_BG_MAN_PAL
    wai
    LOAD_BLOCK2VRAM INTRO_BG_MAN_MAP,$0000,$2000
    wai
    wai
    LOAD_BLOCK2VRAM INTRO_BG_MAN_GFX,$2000,$6000
    wai
    wai
    LOAD_BLOCK2VRAM INTRO_SPRFONT,$6000,$2000    ; 16x16 size
    wai
    wai

    jsr SEQ_hideSprites

;-----

    lda #$0f
    sta $2100                   ; screen on, full brightness

    jsr SEQ_introMosaicIn

    ldx #$40
    jsr theWayOfTheWAI

    stz.w a_word
    jsr SEQ_writeTextProfessor

    ldx #$7f
    jsr theWayOfTheWAI
    jsr SEQ_hideSprites
    ldx #$30
    jsr theWayOfTheWAI

    ldx #$01
    stx a_word
    jsr SEQ_writeTextProfessor

    ldx #$7f
    jsr theWayOfTheWAI
    jsr SEQ_hideSprites
    ldx #$30
    jsr theWayOfTheWAI

    ldx #$02
    stx a_word
    jsr SEQ_writeTextProfessor

    ldx #$7f
    jsr theWayOfTheWAI
    jsr SEQ_hideSprites
    ldx #$30
    jsr theWayOfTheWAI

    ldx #$03
    stx a_word
    jsr SEQ_writeTextProfessor

    ldx #$7f
    jsr theWayOfTheWAI
    jsr SEQ_hideSprites
    ldx #$30
    jsr theWayOfTheWAI

    ldx #$04
    stx a_word
    jsr SEQ_writeTextProfessor

    ldx #$7f
    jsr theWayOfTheWAI
    jsr SEQ_hideSprites
    ldx #$30
    jsr theWayOfTheWAI

    ; =======
    ; SEQPROFFEN
    ; =======

    jsr SEQ_introMosaicOut
    lda #$80
    sta $2100                   ; screen off, no brightness

    lda #SONG_ASCHE
    sta MUSIC
    jsr AUDIO_PLAY_SONG

    LOAD_PAL SEQ_PROFESSOR_PICPAL
    wai
    LOAD_BLOCK2VRAM SEQ_PROFESSOR_PICMAP,$0000,$2000
    wai
    wai
    LOAD_BLOCK2VRAM SEQ_PROFESSOR_PIC,$2000,$6000
    wai
    wai

    lda #$0f
    sta $2100                   ; screen on, full brightness
    jsr SEQ_introMosaicIn

    ldx #$40
    jsr theWayOfTheWAI

    ldx #$05
    stx a_word
    jsr SEQ_writeTextProfessor

    ldx #$7f
    jsr theWayOfTheWAI
    jsr SEQ_hideSprites
    ldx #$30
    jsr theWayOfTheWAI

    ldx #$06
    stx a_word
    jsr SEQ_writeTextProfessor

    ldx #$7f
    jsr theWayOfTheWAI
    jsr SEQ_hideSprites
    ldx #$30
    jsr theWayOfTheWAI

    ldx #$07
    stx a_word
    jsr SEQ_writeTextProfessor

    ldx #$ff
    jsr theWayOfTheWAI
    jsr SEQ_hideSprites
    ldx #$30
    jsr theWayOfTheWAI

    FADE_OUT

    lda #NO_SONG
    sta MUSIC
    jsr AUDIO_PLAY_SONG

    ldx #$7f
    jsr theWayOfTheWAI

;-----

    rts


;================================


SEQ_INTRO
    jsr INIT_VIDEO_04
    lda #$80
    sta $2100                   ; screen off, no brightness

    lda #$63                    ; 16x16 spr. size, chr data at $6000
    sta $2101                   ; set oam size register

    jsr SEQ_setUpUsTheSprites
    jsr SEQ_hideSprites

    ldx #$0000
    stx MAPX
    stx MAPY                    ; reset bg#1 map x,y location

    ldx #$32
    jsr theWayOfTheWAI

    lda #SONG_UNSQUAD
    sta MUSIC
    jsr AUDIO_PLAY_SONG

    ldx #$32
    jsr theWayOfTheWAI


    LOAD_PAL INTRO_BG_PLA_PAL
    wai
    LOAD_BLOCK2VRAM INTRO_BG_PLA_MAP,$0000,$2000
    wai
    wai
    LOAD_BLOCK2VRAM INTRO_BG_PLA_GFX,$2000,$6000
    wai
    wai
    LOAD_BLOCK2VRAM INTRO_SPRFONT,$6000,$2000    ; 16x16 size
    wai
    wai

    jsr SEQ_introRollCamera
    jsr SEQ_hideSprites

    rts


;=================================

; hide all of ze sprites

SEQ_hideSprites
    lda #$ff
    sta SPRBUF2
    sta SPRBUF2+1
    sta SPRBUF2+2
    sta SPRBUF2+3
    sta SPRBUF2+4
    sta SPRBUF2+5
    sta SPRBUF2+6
    sta SPRBUF2+7

    rts


;=================================


SEQ_introRollCamera
    lda #$0f
    sta $2100                   ; screen on, full brightness

    jsr SEQ_introMosaicIn

    ldx #$40
    jsr theWayOfTheWAI

    stz.w a_word
    jsr SEQ_writeText

    ldx #$7f
    jsr theWayOfTheWAI
    jsr SEQ_hideSprites
    ldx #$30
    jsr theWayOfTheWAI

    ldx #$01
    stx a_word
    jsr SEQ_writeText

    ldx #$7f
    jsr theWayOfTheWAI
    jsr SEQ_hideSprites
    ldx #$30
    jsr theWayOfTheWAI

    ldx #$02
    stx a_word
    jsr SEQ_writeText

    ldx #$7f
    jsr theWayOfTheWAI
    jsr SEQ_hideSprites
    ldx #$30
    jsr theWayOfTheWAI

    ldx #$03
    stx a_word
    jsr SEQ_writeText

    ldx #$7f
    jsr theWayOfTheWAI
    jsr SEQ_hideSprites
    ldx #$30
    jsr theWayOfTheWAI

    ldx #$04
    stx a_word
    jsr SEQ_writeText

    ldx #$7f
    jsr theWayOfTheWAI
    jsr SEQ_hideSprites
    ldx #$30
    jsr theWayOfTheWAI

    ldx #$05
    stx a_word
    jsr SEQ_writeText

    ldx #$7f
    jsr theWayOfTheWAI
    jsr SEQ_hideSprites
    ldx #$30
    jsr theWayOfTheWAI

    ldx #$06
    stx a_word
    jsr SEQ_writeText

    ldx #$7f
    jsr theWayOfTheWAI
    jsr SEQ_hideSprites
    ldx #$30
    jsr theWayOfTheWAI

    ldx #$07
    stx a_word
    jsr SEQ_writeText

    ldx #$7f
    jsr theWayOfTheWAI
    jsr SEQ_hideSprites
    ldx #$30
    jsr theWayOfTheWAI

    ; =======
    ; INTRODR
    ; =======

    jsr SEQ_introMosaicOut
    lda #$80
    sta $2100                   ; screen off, no brightness

    LOAD_PAL INTRO_BG_DR_PAL
    wai
    LOAD_BLOCK2VRAM INTRO_BG_DR_MAP,$0000,$2000
    wai
    wai
    LOAD_BLOCK2VRAM INTRO_BG_DR_GFX,$2000,$6000
    wai
    wai

    lda #$0f
    sta $2100                   ; screen on, full brightness
    jsr SEQ_introMosaicIn

    ldx #$40
    jsr theWayOfTheWAI

    ldx #$08
    stx a_word
    jsr SEQ_writeText

    ldx #$7f
    jsr theWayOfTheWAI
    jsr SEQ_hideSprites
    ldx #$30
    jsr theWayOfTheWAI

    ldx #$09
    stx a_word
    jsr SEQ_writeText

    ldx #$7f
    jsr theWayOfTheWAI
    jsr SEQ_hideSprites
    ldx #$30
    jsr theWayOfTheWAI

    ldx #$0a
    stx a_word
    jsr SEQ_writeText

    ldx #$7f
    jsr theWayOfTheWAI
    jsr SEQ_hideSprites
    ldx #$30
    jsr theWayOfTheWAI

    ldx #$0b
    stx a_word
    jsr SEQ_writeText

    ldx #$7f
    jsr theWayOfTheWAI
    jsr SEQ_hideSprites
    ldx #$30
    jsr theWayOfTheWAI

    ; ========
    ; INTROPNT
    ; ========

    jsr SEQ_introMosaicOut
    lda #$80
    sta $2100                   ; screen off, no brightness

    lda #SONG_MERRY
    sta MUSIC
    jsr AUDIO_PLAY_SONG

    LOAD_PAL INTRO_BG_PNT_PAL
    wai
    LOAD_BLOCK2VRAM INTRO_BG_PNT_MAP,$0000,$2000
    wai
    wai
    LOAD_BLOCK2VRAM INTRO_BG_PNT_GFX,$2000,$6000
    wai
    wai

    lda #$0f
    sta $2100                   ; screen on, full brightness
    jsr SEQ_introMosaicIn

    ldx #$40
    jsr theWayOfTheWAI

    ldx #$0c
    stx a_word
    jsr SEQ_writeText

    ldx #$7f
    jsr theWayOfTheWAI
    jsr SEQ_hideSprites
    ldx #$30
    jsr theWayOfTheWAI

    ; ========
    ; INTROTAN
    ; ========

    jsr SEQ_introMosaicOut
    lda #$80
    sta $2100                   ; screen off, no brightness

    lda #SONG_ASCHE
    sta MUSIC
    jsr AUDIO_PLAY_SONG

    LOAD_PAL INTRO_BG_TAN_PAL
    wai
    LOAD_BLOCK2VRAM INTRO_BG_TAN_MAP,$0000,$2000
    wai
    wai
    LOAD_BLOCK2VRAM INTRO_BG_TAN_GFX,$2000,$6000
    wai
    wai

    lda #$0f
    sta $2100                   ; screen on, full brightness
    jsr SEQ_introMosaicIn

    ldx #$40
    jsr theWayOfTheWAI

    ldx #$0d
    stx a_word
    jsr SEQ_writeText

    ldx #$7f
    jsr theWayOfTheWAI
    jsr SEQ_hideSprites
    ldx #$30
    jsr theWayOfTheWAI

    ldx #$0e
    stx a_word
    jsr SEQ_writeText

    ldx #$7f
    jsr theWayOfTheWAI
    jsr SEQ_hideSprites
    ldx #$30
    jsr theWayOfTheWAI

    ldx #$0f
    stx a_word
    jsr SEQ_writeText

    ldx #$7f
    jsr theWayOfTheWAI
    jsr SEQ_hideSprites
    ldx #$30
    jsr theWayOfTheWAI

    ldx #$10
    stx a_word
    jsr SEQ_writeText

    ldx #$7f
    jsr theWayOfTheWAI
    jsr SEQ_hideSprites
    ldx #$30
    jsr theWayOfTheWAI

    ldx #$11
    stx a_word
    jsr SEQ_writeText

    ldx #$7f
    jsr theWayOfTheWAI
    jsr SEQ_hideSprites
    ldx #$30
    jsr theWayOfTheWAI

    ; ========
    ; INTROTST
    ; ========

    jsr SEQ_introMosaicOut
    lda #$80
    sta $2100                   ; screen off, no brightness

    LOAD_PAL INTRO_BG_TST_PAL
    wai
    LOAD_BLOCK2VRAM INTRO_BG_TST_MAP,$0000,$2000
    wai
    wai
    LOAD_BLOCK2VRAM INTRO_BG_TST_GFX,$2000,$6000
    wai
    wai

    lda #$0f
    sta $2100                   ; screen on, full brightness
    jsr SEQ_introMosaicIn

    ldx #$40
    jsr theWayOfTheWAI

    ldx #$12
    stx a_word
    jsr SEQ_writeText

    ldx #$7f
    jsr theWayOfTheWAI
    jsr SEQ_hideSprites
    ldx #$30
    jsr theWayOfTheWAI

    ldx #$13
    stx a_word
    jsr SEQ_writeText

    ldx #$7f
    jsr theWayOfTheWAI
    jsr SEQ_hideSprites
    ldx #$30
    jsr theWayOfTheWAI

    ; -no picture-

    jsr SEQ_introMosaicOut
    lda #$80
    sta $2100                   ; screen off, no brightness

    lda #SONG_GOOP
    sta MUSIC
    jsr AUDIO_PLAY_SONG

    lda #%00011110
    sta $212c                   ; disable bg#1
    lda #$0f
    sta $2100                   ; screen on, full brightness

    ldx #$40
    jsr theWayOfTheWAI

    ldx #$14
    stx a_word
    jsr SEQ_writeText

    ldx #$7f
    jsr theWayOfTheWAI
    jsr SEQ_hideSprites
    ldx #$30
    jsr theWayOfTheWAI

    ldx #$15
    stx a_word
    jsr SEQ_writeText

    ldx #$7f
    jsr theWayOfTheWAI
    jsr SEQ_hideSprites
    ldx #$30
    jsr theWayOfTheWAI

    ; ========
    ; INTROMAN
    ; ========

    lda #$80
    sta $2100                   ; screen off, no brightness
    lda #%00011111
    sta $212c                   ; re-enable bg#1

    LOAD_PAL INTRO_BG_MAN_PAL
    wai
    LOAD_BLOCK2VRAM INTRO_BG_MAN_MAP,$0000,$2000
    wai
    wai
    LOAD_BLOCK2VRAM INTRO_BG_MAN_GFX,$2000,$6000
    wai
    wai

    lda #$0f
    sta $2100                   ; screen on, full brightness
    jsr SEQ_introMosaicIn

    ldx #$40
    jsr theWayOfTheWAI

    ldx #$16
    stx a_word
    jsr SEQ_writeText

    ldx #$7f
    jsr theWayOfTheWAI
    jsr SEQ_hideSprites
    ldx #$30
    jsr theWayOfTheWAI

    ldx #$17
    stx a_word
    jsr SEQ_writeText

    ldx #$7f
    jsr theWayOfTheWAI
    jsr SEQ_hideSprites
    ldx #$30
    jsr theWayOfTheWAI

    ldx #$18
    stx a_word
    jsr SEQ_writeText

    ldx #$7f
    jsr theWayOfTheWAI
    jsr SEQ_hideSprites
    ldx #$30
    jsr theWayOfTheWAI

    ; ========
    ; INTROGRL
    ; ========

    jsr SEQ_introMosaicOut
    lda #$80
    sta $2100                   ; screen off, no brightness

    LOAD_PAL INTRO_BG_GRL_PAL
    wai
    LOAD_BLOCK2VRAM INTRO_BG_GRL_MAP,$0000,$2000
    wai
    wai
    LOAD_BLOCK2VRAM INTRO_BG_GRL_GFX,$2000,$6000
    wai
    wai
    LOAD_BLOCK2VRAM INTRO_SPRHAI,$6000,$2000    ; 16x16 size
    wai
    wai

    lda #$0f
    sta $2100                   ; screen on, full brightness
    jsr SEQ_introMosaicIn

    ldx #$40
    jsr theWayOfTheWAI

    ldx #$68
    stx SPRBUF1+SX4
    ldx #$8a
    stx SPRBUF1+SY4
    ldx #$68
    stx SPRBUF1+SX15
    ldx #$88
    stx SPRBUF1+SX6
    ldx #$8a
    stx SPRBUF1+SY6
    ldx #$88
    stx SPRBUF1+SX17
    ldx #$9a
    stx SPRBUF1+SY15
    stx SPRBUF1+SY16
    stx SPRBUF1+SY17

    lda #$00
    sta CURFRAME4
    lda #$02
    sta CURFRAME5
    lda #$04
    sta CURFRAME6
    lda #$06
    sta CURFRAME15
    lda #$08
    sta CURFRAME16
    lda #$0a
    sta CURFRAME17
    lda #%11000000
    sta SPRBUF2+1
    lda #%00111111
    sta SPRBUF2+3
    lda #%11110000
    sta SPRBUF2+4

    ldx #$ff
    jsr theWayOfTheWAI
    jsr SEQ_hideSprites

;   jsr SEQ_introMosaicOut
;   lda #$80
;   sta $2100                   ; screen off, no brightness
;   lda #$0f
;   sta $2106
    FADE_OUT

    lda #NO_SONG
    sta MUSIC
    jsr AUDIO_PLAY_SONG

    ldx #$7f
    jsr theWayOfTheWAI
    rts


;=================================


SEQ_introMosaicOut
     lda #$0f
     jsr SEQ_iMIl
     lda #$1f
     jsr SEQ_iMIl
     lda #$2f
     jsr SEQ_iMIl
     lda #$3f
     jsr SEQ_iMIl
     lda #$4f
     jsr SEQ_iMIl
     lda #$5f
     jsr SEQ_iMIl
     lda #$6f
     jsr SEQ_iMIl
     lda #$7f
     jsr SEQ_iMIl
     lda #$8f
     jsr SEQ_iMIl
     lda #$9f
     jsr SEQ_iMIl
     lda #$af
     jsr SEQ_iMIl
     lda #$bf
     jsr SEQ_iMIl
     lda #$cf
     jsr SEQ_iMIl
     lda #$df
     jsr SEQ_iMIl
     lda #$ef
     jsr SEQ_iMIl
     lda #$ff
     jsr SEQ_iMIl
     rts
SEQ_introMosaicIn
     lda #$ff
     jsr SEQ_iMIl
     lda #$ef
     jsr SEQ_iMIl
     lda #$df
     jsr SEQ_iMIl
     lda #$cf
     jsr SEQ_iMIl
     lda #$bf
     jsr SEQ_iMIl
     lda #$af
     jsr SEQ_iMIl
     lda #$9f
     jsr SEQ_iMIl
     lda #$8f
     jsr SEQ_iMIl
     lda #$7f
     jsr SEQ_iMIl
     lda #$6f
     jsr SEQ_iMIl
     lda #$5f
     jsr SEQ_iMIl
     lda #$4f
     jsr SEQ_iMIl
     lda #$3f
     jsr SEQ_iMIl
     lda #$2f
     jsr SEQ_iMIl
     lda #$1f
     jsr SEQ_iMIl
     lda #$0f
     jsr SEQ_iMIl
     rts

SEQ_iMIl
     sta $2106
     wai
     wai
     wai
     rts


;=================================

; How to follow the way of the WAI:
; 1) ldx <value>
; 2) jsr theWayOfTheWAI, baby!

theWayOfTheWAI
     wai
     dex
     cpx #$0000
     bne theWayOfTheWAI
     rts


;=================================


SEQ_setUpUsTheSprites
     ldx #$23                   ; all of the following code are used to
     stx SPRBUF1+SX             ; set up the sprites location (x,y) on
     ldx #$8a                   ; screen. this is of course only done once
     stx SPRBUF1+SY             ; as the only stuff that'll get altered
                                ; is the "sframe"-byte of each sprite
     ldx #$34                   ; respectively.
     stx SPRBUF1+SX1
     ldx #$8a
     stx SPRBUF1+SY1

     ldx #$45
     stx SPRBUF1+SX2
     ldx #$8a
     stx SPRBUF1+SY2
     
     ldx #$56
     stx SPRBUF1+SX3
     ldx #$8a
     stx SPRBUF1+SY3

     ldx #$67
     stx SPRBUF1+SX4
     ldx #$8a
     stx SPRBUF1+SY4
     
     ldx #$78
     stx SPRBUF1+SX5
     ldx #$8a
     stx SPRBUF1+SY5

     ldx #$89
     stx SPRBUF1+SX6
     ldx #$8a
     stx SPRBUF1+SY6
     
     ldx #$9a
     stx SPRBUF1+SX7
     ldx #$8a
     stx SPRBUF1+SY7

     ldx #$AB
     stx SPRBUF1+SX8
     ldx #$8a
     stx SPRBUF1+SY8
     
     ldx #$BC
     stx SPRBUF1+SX9
     ldx #$8a
     stx SPRBUF1+SY9

     ldx #$CD
     stx SPRBUF1+SX10
     ldx #$8a
     stx SPRBUF1+SY10
     
     ldx #$23
     stx SPRBUF1+SX11
     ldx #$9b
     stx SPRBUF1+SY11

     ldx #$34
     stx SPRBUF1+SX12
     ldx #$9b
     stx SPRBUF1+SY12
     
     ldx #$45
     stx SPRBUF1+SX13
     ldx #$9b
     stx SPRBUF1+SY13

     ldx #$56
     stx SPRBUF1+SX14
     ldx #$9b
     stx SPRBUF1+SY14
     
     ldx #$67
     stx SPRBUF1+SX15
     ldx #$9b
     stx SPRBUF1+SY15

     ldx #$78
     stx SPRBUF1+SX16
     ldx #$9b
     stx SPRBUF1+SY16
     
     ldx #$89
     stx SPRBUF1+SX17
     ldx #$9b
     stx SPRBUF1+SY17

     ldx #$9a
     stx SPRBUF1+SX18
     ldx #$9b
     stx SPRBUF1+SY18

     ldx #$AB
     stx SPRBUF1+SX19
     ldx #$9b
     stx SPRBUF1+SY19
     
     ldx #$BC
     stx SPRBUF1+SX20
     ldx #$9b
     stx SPRBUF1+SY20

     ldx #$CD
     stx SPRBUF1+SX21
     ldx #$9b
     stx SPRBUF1+SY21

     ldx #$23
     stx SPRBUF1+SX22
     ldx #$AC
     stx SPRBUF1+SY22

     ldx #$34
     stx SPRBUF1+SX23
     ldx #$AC
     stx SPRBUF1+SY23
     
     ldx #$45
     stx SPRBUF1+SX24
     ldx #$AC
     stx SPRBUF1+SY24

     ldx #$56
     stx SPRBUF1+SX25
     ldx #$AC
     stx SPRBUF1+SY25
     
     ldx #$67
     stx SPRBUF1+SX26
     ldx #$AC
     stx SPRBUF1+SY26

     ldx #$78
     stx SPRBUF1+SX27
     ldx #$AC
     stx SPRBUF1+SY27
     
     ldx #$89
     stx SPRBUF1+SX28
     ldx #$AC
     stx SPRBUF1+SY28

     ldx #$9a
     stx SPRBUF1+SX29
     ldx #$AC
     stx SPRBUF1+SY29

     ldx #$AB
     stx SPRBUF1+SX30
     ldx #$AC
     stx SPRBUF1+SY30
     
     ldx #$BC
     stx SPRBUF1+SX31
     ldx #$AC
     stx SPRBUF1+SY31

     ;------

     ; just in case you didn't know.. you must
     ; not store values in the CURFRAME's until
     ; you're done with the other sprite vars!
     ; if you do so, the result will be erronous.

     ; here's the complete offset table for the
     ; sprites in `./gfx/sprfont/sprfont.pic'.
     ;---
     ; $00-$0e = a-h, $20-$2e = i-p
     ; $40-$4e = q-x, $60-$6a = yz!.?,
     ;-
     ; nb! there's no '?'. it's actually used for space [$68].
     lda #$00
     sta SPRBUF1+SPRIORITY
     sta SPRBUF1+SPRIORITY1
     sta SPRBUF1+SPRIORITY2
     sta SPRBUF1+SPRIORITY3
     sta SPRBUF1+SPRIORITY4
     sta SPRBUF1+SPRIORITY5
     sta SPRBUF1+SPRIORITY6
     sta SPRBUF1+SPRIORITY7
     sta SPRBUF1+SPRIORITY8
     sta SPRBUF1+SPRIORITY9
     sta SPRBUF1+SPRIORITY10
     sta SPRBUF1+SPRIORITY11
     sta SPRBUF1+SPRIORITY12
     sta SPRBUF1+SPRIORITY13
     sta SPRBUF1+SPRIORITY14
     sta SPRBUF1+SPRIORITY15
     sta SPRBUF1+SPRIORITY16
     sta SPRBUF1+SPRIORITY17
     sta SPRBUF1+SPRIORITY18
     sta SPRBUF1+SPRIORITY19
     sta SPRBUF1+SPRIORITY20
     sta SPRBUF1+SPRIORITY21
     sta SPRBUF1+SPRIORITY22
     sta SPRBUF1+SPRIORITY23
     sta SPRBUF1+SPRIORITY24
     sta SPRBUF1+SPRIORITY25
     sta SPRBUF1+SPRIORITY26
     sta SPRBUF1+SPRIORITY27
     sta SPRBUF1+SPRIORITY28
     sta SPRBUF1+SPRIORITY29
     sta SPRBUF1+SPRIORITY30
     sta SPRBUF1+SPRIORITY31

     rts


;================================


; this routine outputs sequencial text to the screen.
; the input -must- be 32 bytes. the text gets outputted
; like this:
; xxxxxxxxxxx
; xxxxxxxxxxx
; xxxxxxxxxx
;
; select a textstring to be written to screen by storing
; a certain number in `a_word'.  e.g: "ldx #$0a ; stx a_word"

SEQ_writeText
     ldy #$0000

     jsr SEQ_wT_txtLoop
     sta CURFRAME
     jsr SEQ_wT_txtLoop
     sta CURFRAME1
     jsr SEQ_wT_txtLoop
     sta CURFRAME2
     jsr SEQ_wT_txtLoop
     sta CURFRAME3
     jsr SEQ_wT_txtLoop
     sta CURFRAME4
     jsr SEQ_wT_txtLoop
     sta CURFRAME5
     jsr SEQ_wT_txtLoop
     sta CURFRAME6
     jsr SEQ_wT_txtLoop
     sta CURFRAME7
     jsr SEQ_wT_txtLoop
     sta CURFRAME8
     jsr SEQ_wT_txtLoop
     sta CURFRAME9
     jsr SEQ_wT_txtLoop
     sta CURFRAME10
     jsr SEQ_wT_txtLoop
     sta CURFRAME11
     jsr SEQ_wT_txtLoop
     sta CURFRAME12
     jsr SEQ_wT_txtLoop
     sta CURFRAME13
     jsr SEQ_wT_txtLoop
     sta CURFRAME14
     jsr SEQ_wT_txtLoop
     sta CURFRAME15
     jsr SEQ_wT_txtLoop
     sta CURFRAME16
     jsr SEQ_wT_txtLoop
     sta CURFRAME17
     jsr SEQ_wT_txtLoop
     sta CURFRAME18
     jsr SEQ_wT_txtLoop
     sta CURFRAME19
     jsr SEQ_wT_txtLoop
     sta CURFRAME20
     jsr SEQ_wT_txtLoop
     sta CURFRAME21
     jsr SEQ_wT_txtLoop
     sta CURFRAME22
     jsr SEQ_wT_txtLoop
     sta CURFRAME23
     jsr SEQ_wT_txtLoop
     sta CURFRAME24
     jsr SEQ_wT_txtLoop
     sta CURFRAME25
     jsr SEQ_wT_txtLoop
     sta CURFRAME26
     jsr SEQ_wT_txtLoop
     sta CURFRAME27
     jsr SEQ_wT_txtLoop
     sta CURFRAME28
     jsr SEQ_wT_txtLoop
     sta CURFRAME29
     jsr SEQ_wT_txtLoop
     sta CURFRAME30
     jsr SEQ_wT_txtLoop
     sta CURFRAME31

     lda #$06
     sta a_byte2
     jsr SEQ_wT_setFontPal

     jsr SEQ_wT_uncover

     dec a_byte2
     jsr SEQ_wT_setFontPal
     dec a_byte2
     jsr SEQ_wT_setFontPal
     dec a_byte2
     jsr SEQ_wT_setFontPal
     dec a_byte2
     jsr SEQ_wT_setFontPal
     dec a_byte2
     jsr SEQ_wT_setFontPal
     dec a_byte2
     jsr SEQ_wT_setFontPal

     rts

SEQ_wT_txtLoop
;    lda TXT_INTRO_00, y
;    iny
;    rts
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     ldx a_word
     cpx #$00
     beq wT_00
     cpx #$01
     beq wT_01
     cpx #$02
     beq wT_02
     cpx #$03
     beq wT_03
     cpx #$04
     beq wT_04
     cpx #$05
     beq wT_05
     cpx #$06
     beq wT_06

     jmp wT_check2               ; had to split this horrific cpx-monster-
                                 ; routine (tm) due to 8-bit BEQ limitation.
wT_00
     phb
     lda #:TXT_INTRO_00
     pha
     plb
     lda TXT_INTRO_00, y
     plb
     jmp wT_ff
wT_01
     phb
     lda #:TXT_INTRO_01
     pha
     plb
     lda TXT_INTRO_01, y
     plb
     jmp wT_ff
wT_02
     phb
     lda #:TXT_INTRO_02
     pha
     plb
     lda TXT_INTRO_02, y
     plb
     jmp wT_ff
wT_03
     phb
     lda #:TXT_INTRO_03
     pha
     plb
     lda TXT_INTRO_03, y
     plb
     jmp wT_ff
wT_04
     phb
     lda #:TXT_INTRO_04
     pha
     plb
     lda TXT_INTRO_04, y
     plb
     jmp wT_ff
wT_05
     phb
     lda #:TXT_INTRO_05
     pha
     plb
     lda TXT_INTRO_05, y
     plb
     jmp wT_ff
wT_06
     phb
     lda #:TXT_INTRO_06
     pha
     plb
     lda TXT_INTRO_06, y
     plb
     jmp wT_ff

wT_check2
     cpx #$07
     beq wT_07
     cpx #$08
     beq wT_08
     cpx #$09
     beq wT_09
     cpx #$0a
     beq wT_0a
     cpx #$0b
     beq wT_0b
     cpx #$0c
     beq wT_0c

     jmp wT_check3

wT_07
     phb
     lda #:TXT_INTRO_07
     pha
     plb
     lda TXT_INTRO_07, y
     plb
     jmp wT_ff
wT_08
     phb
     lda #:TXT_INTRO_08
     pha
     plb
     lda TXT_INTRO_08, y
     plb
     jmp wT_ff
wT_09
     phb
     lda #:TXT_INTRO_09
     pha
     plb
     lda TXT_INTRO_09, y
     plb
     jmp wT_ff
wT_0a
     phb
     lda #:TXT_INTRO_10
     pha
     plb
     lda TXT_INTRO_10, y
     plb
     jmp wT_ff
wT_0b
     phb
     lda #:TXT_INTRO_11
     pha
     plb
     lda TXT_INTRO_11, y
     plb
     jmp wT_ff
wT_0c
     phb
     lda #:TXT_INTRO_12
     pha
     plb
     lda TXT_INTRO_12, y
     plb
     jmp wT_ff


wT_check3
     cpx #$0d
     beq wT_0d
     cpx #$0e
     beq wT_0e
     cpx #$0f
     beq wT_0f
     cpx #$10
     beq wT_10
     cpx #$11
     beq wT_11
     cpx #$12
     beq wT_12
     cpx #$13
     beq wT_13
     cpx #$14
     beq wT_14
     cpx #$15
     beq wT_15
     cpx #$16
     beq wT_16

     jmp wT_check4

wT_0d
     phb
     lda #:TXT_INTRO_13
     pha
     plb
     lda TXT_INTRO_13, y
     plb
     jmp wT_ff
wT_0e
     phb
     lda #:TXT_INTRO_14
     pha
     plb
     lda TXT_INTRO_14, y
     plb
     jmp wT_ff
wT_0f
     phb
     lda #:TXT_INTRO_15
     pha
     plb
     lda TXT_INTRO_15, y
     plb
     jmp wT_ff
wT_10
     phb
     lda #:TXT_INTRO_16
     pha
     plb
     lda TXT_INTRO_16, y
     plb
     jmp wT_ff
wT_11
     phb
     lda #:TXT_INTRO_17
     pha
     plb
     lda TXT_INTRO_17, y
     plb
     jmp wT_ff
wT_12
     phb
     lda #:TXT_INTRO_18
     pha
     plb
     lda TXT_INTRO_18, y
     plb
     jmp wT_ff
wT_13
     phb
     lda #:TXT_INTRO_19
     pha
     plb
     lda TXT_INTRO_19, y
     plb
     jmp wT_ff
wT_14
     phb
     lda #:TXT_INTRO_20
     pha
     plb
     lda TXT_INTRO_20, y
     plb
     jmp wT_ff
wT_15
     phb
     lda #:TXT_INTRO_21
     pha
     plb
     lda TXT_INTRO_21, y
     plb
     jmp wT_ff
wT_16
     phb
     lda #:TXT_INTRO_22
     pha
     plb
     lda TXT_INTRO_22, y
     plb
     jmp wT_ff


wT_check4
     cpx #$17
     beq wT_17
     cpx #$18
     beq wT_18
     cpx #$19
     beq wT_19

wT_17
     phb
     lda #:TXT_INTRO_23
     pha
     plb
     lda TXT_INTRO_23, y
     plb
     jmp wT_ff
wT_18
     phb
     lda #:TXT_INTRO_24
     pha
     plb
     lda TXT_INTRO_24, y
     plb
     jmp wT_ff
wT_19
     phb
     lda #:TXT_INTRO_25
     pha
     plb
     lda TXT_INTRO_25, y
     plb

wT_ff
     iny
     rts
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

;=================================================

SEQ_writeTextProfessor
     ldy #$0000

     jsr SEQ_wTP_txtLoop
     sta CURFRAME
     jsr SEQ_wTP_txtLoop
     sta CURFRAME1
     jsr SEQ_wTP_txtLoop
     sta CURFRAME2
     jsr SEQ_wTP_txtLoop
     sta CURFRAME3
     jsr SEQ_wTP_txtLoop
     sta CURFRAME4
     jsr SEQ_wTP_txtLoop
     sta CURFRAME5
     jsr SEQ_wTP_txtLoop
     sta CURFRAME6
     jsr SEQ_wTP_txtLoop
     sta CURFRAME7
     jsr SEQ_wTP_txtLoop
     sta CURFRAME8
     jsr SEQ_wTP_txtLoop
     sta CURFRAME9
     jsr SEQ_wTP_txtLoop
     sta CURFRAME10
     jsr SEQ_wTP_txtLoop
     sta CURFRAME11
     jsr SEQ_wTP_txtLoop
     sta CURFRAME12
     jsr SEQ_wTP_txtLoop
     sta CURFRAME13
     jsr SEQ_wTP_txtLoop
     sta CURFRAME14
     jsr SEQ_wTP_txtLoop
     sta CURFRAME15
     jsr SEQ_wTP_txtLoop
     sta CURFRAME16
     jsr SEQ_wTP_txtLoop
     sta CURFRAME17
     jsr SEQ_wTP_txtLoop
     sta CURFRAME18
     jsr SEQ_wTP_txtLoop
     sta CURFRAME19
     jsr SEQ_wTP_txtLoop
     sta CURFRAME20
     jsr SEQ_wTP_txtLoop
     sta CURFRAME21
     jsr SEQ_wTP_txtLoop
     sta CURFRAME22
     jsr SEQ_wTP_txtLoop
     sta CURFRAME23
     jsr SEQ_wTP_txtLoop
     sta CURFRAME24
     jsr SEQ_wTP_txtLoop
     sta CURFRAME25
     jsr SEQ_wTP_txtLoop
     sta CURFRAME26
     jsr SEQ_wTP_txtLoop
     sta CURFRAME27
     jsr SEQ_wTP_txtLoop
     sta CURFRAME28
     jsr SEQ_wTP_txtLoop
     sta CURFRAME29
     jsr SEQ_wTP_txtLoop
     sta CURFRAME30
     jsr SEQ_wTP_txtLoop
     sta CURFRAME31

     lda #$06
     sta a_byte2
     jsr SEQ_wT_setFontPal

     jsr SEQ_wT_uncover

     dec a_byte2
     jsr SEQ_wT_setFontPal
     dec a_byte2
     jsr SEQ_wT_setFontPal
     dec a_byte2
     jsr SEQ_wT_setFontPal
     dec a_byte2
     jsr SEQ_wT_setFontPal
     dec a_byte2
     jsr SEQ_wT_setFontPal
     dec a_byte2
     jsr SEQ_wT_setFontPal

     rts

SEQ_wTP_txtLoop
;    lda TXT_INTRO_00, y
;    iny
;    rts
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     ldx a_word
     cpx #$00
     beq wTP_00
     cpx #$01
     beq wTP_01
     cpx #$02
     beq wTP_02
     cpx #$03
     beq wTP_03
     cpx #$04
     beq wTP_04
     cpx #$05
     beq wTP_05
     cpx #$06
     beq wTP_06
     cpx #$07
     beq wTP_07

wTP_00
     phb
     lda #:TXT_SEQPROFFEN_00
     pha
     plb
     lda TXT_SEQPROFFEN_00, y
     plb
     jmp wTP_ff
wTP_01
     phb
     lda #:TXT_SEQPROFFEN_01
     pha
     plb
     lda TXT_SEQPROFFEN_01, y
     plb
     jmp wTP_ff
wTP_02
     phb
     lda #:TXT_SEQPROFFEN_02
     pha
     plb
     lda TXT_SEQPROFFEN_02, y
     plb
     jmp wTP_ff
wTP_03
     phb
     lda #:TXT_SEQPROFFEN_03
     pha
     plb
     lda TXT_SEQPROFFEN_03, y
     plb
     jmp wTP_ff
wTP_04
     phb
     lda #:TXT_SEQPROFFEN_04
     pha
     plb
     lda TXT_SEQPROFFEN_04, y
     plb
     jmp wTP_ff
wTP_05
     phb
     lda #:TXT_SEQPROFFEN_05
     pha
     plb
     lda TXT_SEQPROFFEN_05, y
     plb
     jmp wTP_ff
wTP_06
     phb
     lda #:TXT_SEQPROFFEN_06
     pha
     plb
     lda TXT_SEQPROFFEN_06, y
     plb
     jmp wTP_ff
wTP_07
     phb
     lda #:TXT_SEQPROFFEN_007
     pha
     plb
     lda TXT_SEQPROFFEN_007, y
     plb
     jmp wTP_ff

wTP_ff
     iny
     rts
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


SEQ_wT_uncover
     ldy #$0000
     sty a_word
SEQ_wT_oneMoreTime
     lda #%11111100
     jsr SEQ_wT_uncDoIt
     lda #%11110000
     jsr SEQ_wT_uncDoIt
     lda #%11000000
     jsr SEQ_wT_uncDoIt
     lda #%00000000
     jsr SEQ_wT_uncDoIt

     ldy a_word
     iny
     sty a_word
     cpy #$08
     bmi SEQ_wT_oneMoreTime

     rts                        ; /* SEQ_wT_uncover */

SEQ_wT_uncDoIt
     wai
     wai

     ldy a_word
     cpy #$00
     beq SEQ_wT_DoIt00
     cpy #$01
     beq SEQ_wT_DoIt01
     cpy #$02
     beq SEQ_wT_DoIt02
     cpy #$03
     beq SEQ_wT_DoIt03
     cpy #$04
     beq SEQ_wT_DoIt04
     cpy #$05
     beq SEQ_wT_DoIt05
     cpy #$06
     beq SEQ_wT_DoIt06

SEQ_wT_DoIt07
     sta SPRBUF2+7
     jmp SEQ_wT_DoItFF
SEQ_wT_DoIt06
     sta SPRBUF2+6
     jmp SEQ_wT_DoItFF
SEQ_wT_DoIt05
     sta SPRBUF2+5
     jmp SEQ_wT_DoItFF
SEQ_wT_DoIt04
     sta SPRBUF2+4
     jmp SEQ_wT_DoItFF
SEQ_wT_DoIt03
     sta SPRBUF2+3
     jmp SEQ_wT_DoItFF
SEQ_wT_DoIt02
     sta SPRBUF2+2
     jmp SEQ_wT_DoItFF
SEQ_wT_DoIt01
     sta SPRBUF2+1
     jmp SEQ_wT_DoItFF
SEQ_wT_DoIt00
     sta SPRBUF2

SEQ_wT_DoItFF
     rts


;=================================

; this isn't a particularly nice routine, but it does its job!
; and that's what it's all about in the end, right? ;-)

SEQ_wT_setFontPal
     ldx #$0100
     ldy #$0000

     lda #$80
     sta $2121

     lda a_byte2
     cmp #$06
     beq SEQ_wT_sfp_loop_06
     cmp #$05
     beq SEQ_wT_sfp_loop_05
     cmp #$04
     beq SEQ_wT_sfp_loop_04
     cmp #$03
     beq SEQ_wT_sfp_loop_03
     cmp #$02
     beq SEQ_wT_sfp_loop_02
     cmp #$01
     beq SEQ_wT_sfp_loop_01
     bra SEQ_wT_sfp_loop_00


SEQ_wT_sfp_loop_06
     INTROTXT_LOAD_PAL SPRFPAL_06
     jmp SEQ_wT_sfp_ende

SEQ_wT_sfp_loop_05
     INTROTXT_LOAD_PAL SPRFPAL_05
     jmp SEQ_wT_sfp_ende

SEQ_wT_sfp_loop_04
     INTROTXT_LOAD_PAL SPRFPAL_04
     jmp SEQ_wT_sfp_ende

SEQ_wT_sfp_loop_03
     INTROTXT_LOAD_PAL SPRFPAL_03
     jmp SEQ_wT_sfp_ende

SEQ_wT_sfp_loop_02
     INTROTXT_LOAD_PAL SPRFPAL_02
     jmp SEQ_wT_sfp_ende

SEQ_wT_sfp_loop_01
     INTROTXT_LOAD_PAL SPRFPAL_01
     jmp SEQ_wT_sfp_ende

SEQ_wT_sfp_loop_00
     INTROTXT_LOAD_PAL SPRFPAL_00


SEQ_wT_sfp_ende
     ldx #$04
     jsr theWayOfTheWAI

     rts
