spinix-hive/pfth/sdutils.fth

59 lines
1.1 KiB
Forth
Raw Normal View History

: print_allocated_clusters
spi_fat1 @ spi_sectorsperfat @ 0 ?do
dup spi_buf spi_readblock drop
1+
512 0 do
spi_filesystem @ 2 =
if
spi_buf i + @ dup
if
j 128 * i 4 / + . . cr
else
drop
then
4
else
spi_buf i + w@ dup
if
j 256 * i 2 / + . . cr
else
drop
then
2
then
+loop
loop
drop
;
: create_file
32 word count 0 create-file
swap . . cr
;
: open_file
32 word count 0 open-file
swap . . cr
;
: _dump_file_info
." file_sector0 " file_sector0 ? cr
." file_sector " file_sector ? cr
." file_length " file_length ? cr
." file_position " file_position ? cr
." file_remaining " file_remaining ? cr
." file_dsector " file_dsector ? cr
." file_doffset " file_doffset ? cr
." file_dirty " file_dirty ? cr
." file_opened " file_opened ? cr
;
: dump_file_info
file_info_1 to file_info
." file_info_1" cr
_dump_file_info
file_info_2 to file_info
." file_info_2" cr
_dump_file_info
;