func_loaddatatovram:

ld hl,($ca00)
call func_prep_write_vram

;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_loaddatatovram_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_loaddatatovram_1

ld b,128
jr func_loaddatatovram_3

func_loaddatatovram_1:
ld a,($ca06)
ld b,a

func_loaddatatovram_3:
ld a,b
or a
ret z

ld hl,$ca80
ld a,(7)
ld c,a

func_loaddatatovram_loop2:
outi
jr nz,func_loaddatatovram_loop2

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_loaddatatovram_exit

jr func_loaddatatovram_loop

func_loaddatatovram_exit:

ret

