func_savedata:

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

func_savedata_loop:

;SET DISK TRANSFER ADDRESS
ld de,($ca00)
ld c,$1a
call $f37d

;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_savedata_closefile

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

jr func_savedata_loop

func_savedata_closefile:

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

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


ret

