func_savedatafromvram:

ld hl,($ca00)
call func_prep_read_vram

;CREATE FILE
ld de,$c800
ld c,$16
call $f37d

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

func_savedatafromvram_loop:

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

func_savedatafromvram_loop2:
ini
jr nz,func_savedatafromvram_loop2

;WRITE FILE
ld de,$c800
ld c,$15
call $f37d

ld hl,($ca04)
ld de,128
add hl,de
ld ($ca04),hl
ld de,($ca02)
ex de,hl
or a
sbc hl,de
jr c,func_savedatafromvram_closefile

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

jr func_savedatafromvram_loop

func_savedatafromvram_closefile:

;SET LENGTH DATA
ld hl,($ca02)
ld ($c810),hl

;CLOSE FILE
ld de,$c800
ld c,$10
call $f37d


ret

