Skip to content

Commit

Permalink
drop path storage
Browse files Browse the repository at this point in the history
  • Loading branch information
jkotlinski committed Apr 22, 2023
1 parent ece5ced commit aeb29a4
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions forth/block.fs
Original file line number Diff line number Diff line change
Expand Up @@ -3,25 +3,24 @@
create bbi 0 , 0 c, \ buffer block id's
create dirty 0 , 0 c,
create curr-buf 0 c,
create path 'b' c, 3 allot

: >addr ( buf -- addr )
$400 * $c000 + ;

: >path ( blk -- )
#10 /mod #10 /mod
4 1 do '0' + path i + c! loop ;
'b' here c! #10 /mod #10 /mod
4 1 do '0' + here i + c! loop ;

: save-buf ( buf -- )
dup dirty + c@ 0= if drop exit then
0 over dirty + c!
dup bbi + c@ >path >addr dup $400 +
path 4 saveb ;
here 4 saveb ;

This comment has been minimized.

Copy link
@ekipan

ekipan Apr 22, 2023

Contributor

Do you need to scratch first?

This comment has been minimized.

Copy link
@jkotlinski

jkotlinski Apr 22, 2023

Author Owner

Yes, I missed that. This is where things starts to get real slow: First the drive head moves from track 18 to track X and back, to scratch the file. Then from track 18 to track X and back again, to save the file.

This comment has been minimized.

Copy link
@ekipan

ekipan Apr 22, 2023

Contributor

So perhaps doing direct sectors could be faster after all?

This comment has been minimized.

Copy link
@jkotlinski

jkotlinski Apr 22, 2023

Author Owner

I don't know :-) I did not measure that.

This comment has been minimized.

Copy link
@jkotlinski

jkotlinski Apr 23, 2023

Author Owner

Testing quickly with SuperForth64, block-based access does feel faster than PRG-file-based access, probably just because it does not need to seek back and forth between data block and BAM.

This comment has been minimized.

Copy link
@jkotlinski

jkotlinski Apr 23, 2023

Author Owner

Maybe it could be worth testing REL-based files? To have one random-access file named "BLOCKS".


: >buf ( blk -- buf ) 3 mod ;

: load-blk ( blk -- )
dup >path >buf >addr >r path 4
dup >path >buf >addr >r here 4
r@ loadb 0= if r@ $400 erase then

This comment has been minimized.

Copy link
@ekipan

ekipan Apr 22, 2023

Contributor

The standard seems to assume the block numbers map to physical locations on disk, so this filename virtual mapping I came up with does introduce the problem of inventing data for files that don't exist yet. In my block wordset I did bl fill for easier editing instead of erase here, probably the standard doesn't specify.

This comment has been minimized.

Copy link
@jkotlinski

jkotlinski Apr 22, 2023

Author Owner

OK! I chose to set it to all zeroes, because that is what an empty C64 disk contains.

This comment has been minimized.

Copy link
@ekipan

ekipan Apr 22, 2023

Contributor

I'm not sure what's the best choice. I should probably change my editor so it's robust against binary data instead.

r> drop ;

Expand Down

0 comments on commit aeb29a4

Please sign in to comment.