;
;               *************************************
;               **                                 **
;               **         Welcome to HULK         **
;               **                                 **
;               **   ~CASSY~ buster to the world   **
;               **                                 **
;               ** (C) Copyright December 1988 HLF **
;               **                                 **
;               **     Version 2.5 source code     **
;               **                                 **
;               *************************************
;
;

.hulk           org &a000
                limit &ffff

.km_wait_key    defl &bb18
.txt_output     defl &bb5a
.txt_place_csr  defl &bb8a
.txt_remove_csr defl &bb8d
.txt_set_paper  defl &bb96
.txt_set_pen    defl &bb90
.scr_set_mode   defl &bc0e
.scr_set_ink    defl &bc32
.scr_set_bord   defl &bc38
.scr_setflash   defl &bc3e
.cas_out_open   defl &bc8c
.cas_out_close  defl &bc8f
.cas_out_direct defl &bc98
.kl_init_back   defl &bcce
.mc_startprog   defl &bd16

.decode         ld hl,&417f
                ld (hl),&8f
                ld hl,&41cc
                ld (hl),&b3
                ld hl,&422c
                ld (hl),&f9
                ld a,1
                call scr_set_mode
                ld a,&c3
                ld (&be00),a
                ld hl,hulk1
                ld (&be01),hl
                jp &4005

.hulk1          ld hl,hulk2
                ld c,0
                call mc_startprog

.hulk2          ld a,1
                call scr_set_mode
                xor a
                ld (flag),a
                ld bc,0
                call scr_set_ink
                ld a,1
                ld bc,&1818
                call scr_set_ink
                ld a,2
                ld bc,&d0d
                call scr_set_ink
                ld a,3
                ld bc,&1a
                call scr_set_ink
                ld bc,0
                call scr_set_bord
                ld hl,&f0f
                call scr_setflash

                ld a,2
                call txt_set_paper

.start          ld hl,copyright
                call print
                xor a
                call txt_set_paper

.search         ld hl,searching
                call print
                ld bc,&500
                ld ix,&ac00

.search1        ld a,(ix+0)
                cp &c4
                jr nz,search2
                ld a,(ix+1)
                cp &14
                jr nz,search2
                ld a,(ix+2)
                cp &ac
                jr nz,search2
                ld hl,found
                call print
                call printix
                ld a,13 
                call txt_output
                ld a,10
                call txt_output
                call txt_output
                ld a,1
                ld (flag),a       
                ld (ix+1),&00
                ld (ix+2),&be

.search2        inc ix
                dec bc
                ld a,b
                or c
                jr nz,search1

                ld hl,searchfin
                call print
                ld a,(flag)
                or a
                jr nz,skip

                ld hl,nofound
                call print
                call km_wait_key
                rst 0

.skip           ld hl,loading
                call print
                ld hl,hulk4
                ld de,&be00
                ld bc,hulk6-hulk4
                ldir
                call km_wait_key
                jp &ac00

.printix        push ix
                pop hl
                ld de,4096
                call pix
                ld de,256
                call pix
                ld de,16
                call pix
                ld de,1

.pix            xor a

.pix2           and a
                inc a
                sbc hl,de
                jr nc,pix2
                add hl,de
                dec a
                push hl
                ld e,a
                ld d,0
                ld hl,table
                add hl,de
                ld a,(hl)
                call txt_output
                pop hl
                ret

.print          ld a,(hl)
                push hl
                call txt_set_pen
                pop hl
                inc hl

.ploop          ld a,(hl)
                or a
                ret z
                call txt_output
                inc hl
                jr ploop

.hulk4          ld hl,&be08
                ld c,0     
                call mc_startprog

.hulk5          ld c,7
                ld hl,&a900
                ld de,&40
                call kl_init_back
                ld hl,&be32
                ld b,12
                ld de,&c000
                call cas_out_open
                ld hl,&40
                ld de,&a46f
                ld bc,0
                ld a,2
                call cas_out_direct
                call cas_out_close

.key            jp &ac14

.name           text"HULKFILE.BIN"

.hulk6

.copyright      defb 1
                text "  ~HULK~ - THE ALL IN ONE CASSY BUSTER  "
                text "     (C)Copyright December 1988 HLF     "
                defb 31,1,25
                rmem 40,32
                defb 31,1,5,0

.searching      defb 1
                text "Searching..."
                defb 13,10,10,0

.found          defb 3
                text "CALL found at &"
                defb 0

.searchfin      defb 1
                text "Search complete."
                defb 13,10,10,10,10,0

.nofound        defb 3
                text "*** No CALL's found.Press a key. ***"
                defb 0

.loading        defb 2
                text "The game will now load and a backup will"
                text "be written to disk as ~HULKFILE.BIN~.You"
                text "can hack this easily.Have a nice day !"
                defb 13,10,10,15,1
                text "             Press a key..."
                defb 0

.table          text "0123456789ABCDEF"
.flag           defb 0
