func_loaddata:

;OPEN FILE
ld de,$c800
ld c,$f
call $f37d

ld hl,($c810)
ld ($ca06),hl

;SET DISK TRANSFER ADDRESS
ld de,$ca80
ld c,$1a
call $f37d

func_loaddata_loop:

;READ FILE
ld de,$c800
ld c,$14
call $f37d

;COPY DATA BLOCK
ld hl,($ca06)
ld de,128
or a
sbc hl,de
jr c,func_loaddata_1

ld bc,128
jr func_loaddata_3

func_loaddata_1:
ld bc,($ca06)

func_loaddata_3:
ld a,b
or c
ret z

ld hl,$ca80
ld de,($ca00)
ldir

ld de,128
ld hl,($ca06)
or a
sbc hl,de
ld ($ca06),hl

ld hl,($ca04)
add hl,de
ld ($ca04),hl

ld de,($c810)
ex de,hl
or a
sbc hl,de
jr c,func_loaddata_exit

ld hl,($ca00)
ld de,128
add hl,de
ld ($ca00),hl

jr func_loaddata_loop

func_loaddata_exit:

ret

