org &4000:limit &a400:nolist

jp letters
jp funky_off

.sy     defl 190
.hmax   defl 16
.count          defb 0
.ic1            defb 0
.ic2            defb 0
.itab           defb 20,28,14,10,10,14,28
.intblock       defs 9

.letters
call &bd19
call &bd19
xor a
ld (count),a
ld (ic1),a
ld (ic2),a
ld (botmode+1),a
ld a,&c9
ld (disable_flash),a

ld hl,intblock
ld de,funky
ld b,%10000001
ld c,0
call &bce0

ld hl,intblock
call &bcf2

ld de,&c850               ;B
ld hl,pics
call draw_letter

ld de,&c858               ;I
ld hl,pics+&80
call draw_letter

ld de,&c860               ;G
ld hl,pics+&100
call draw_letter

ld de,&c870               ;D
ld hl,pics+&180
call draw_letter

ld de,&c878               ;I
ld hl,pics+&80
call draw_letter

ld de,&c880               ;S
ld hl,pics+&200
call draw_letter

ld de,&c888               ;C
ld hl,pics+&280
call draw_letter

ld de,&c898               ;1
ld hl,pics+&300
call draw_letter

xor a
ld (disable_flash),a
inc a
ld (botmode+1),a

ret

.funky_off
ld hl,intblock
jp &bce6

.draw_letter
ld c,hmax
.loop1
push de
push bc

ld a,c
add sy-hmax
ld b,a
ld c,&ff

.loop2
push de
push hl

ldi
ldi
ldi
ldi
ldi
ldi
ldi
ldi

pop hl
pop de
call down_line

djnz loop2

call &bd19
call &bd19
call &bd19
call &bd19
call &bd19

ld de,8
add hl,de

pop bc
pop de
call down_line
dec c
jr nz,loop1

ex hl,de
ld b,sy-hmax
ld d,0
.er_loop
push hl

ld (hl),d
inc hl
ld (hl),d
inc hl
ld (hl),d
inc hl
ld (hl),d
inc hl
ld (hl),d
inc hl
ld (hl),d
inc hl
ld (hl),d
inc hl
ld (hl),d

pop hl
call &bc26
djnz er_loop

ret

.down_line
ld a,d
add 8
ld d,a
ret nc
push hl
ex hl,de
ld de,&c050
add hl,de
ex hl,de
pop hl
ret

.funky
ld hl,count
inc (hl)
ld a,(hl)
cp 6
jr nz,fi_1
xor a
.fi_1
ld (hl),a
push af

.botmode
ld a,0
call &bd1c

pop af
cp 1
ret nz

xor a
call &bd1c

.disable_flash
nop

di
ld hl,ic1
inc (hl)
res 3,(hl)
ld a,(hl)
inc l
ld (hl),a

ld de,&1b8c                   ;D controls overall height of flashy bit
ld bc,&7f01

ld h,30
.loop3
out (c),e
dec h
jr nz,loop3

.loop
ld hl,ic2
inc (hl)
res 3,(hl)
ld a,(hl)
add itab mod 256
ld l,a
ld h,itab/256
ld a,(hl)
or 64

out (c),e
out (c),e

out (c),c
out (c),a

ld h,8                    ;H controls width of bars
.w_loop
out (c),e
dec h
jr nz,w_loop

dec d
jr nz,loop

out (c),c                 ;Set pen back to red (6)
ld a,76
out (c),a

exx
out (c),c
exx
ld a,1
call &bd1c

ei
ret

list
.pics
;Pics are 2x2 chars in mode 0
;Stored in the order BIGDSC1
