Development Diary: File System I/O API makes a comeback!

File System I/O API makes a comeback!
kveroneau(Game Creator)
April 5, 2017, 4:48 a.m.

Due to the sheer amount of effort and time required to create a full file system in pure 65c02, I have brought back the original File System I/O API, but in a more advanced and block device friendly way. The API is very similar to what it was when there was a simulated file system in Hacker's Edge, except in this update the File System I/O API goes through the new block storage device when writing, reading, and cataloging files on the disk. So, players will be-able to use hex editors on the block device to see all the RAW data which is stored therein. Furthermore, if a player wishes to write their own file system on top of the block device, they can. The block device API is still fully intact, and you can easily just read and write RAW blocks to and from the disk.

I made this choice of bringing back the original API, as development was getting really slow and complicated, as focusing most of my time on creating a file system driver is not very useful for players and the game by the end of the day. Now that a file system is available, I can now begin work on what matters more, getting the basic HackerOS up and running so that players can actually start playing what would be called a game.

I am also thinking of writing some hardcoded helpers, such as a CASE/SELECT routine in the form of a JMP table along with textual strings. This will be mainly used when building command shells, as a null-terminated command, along with a 16-bit address can be stored into a table. Then calling a special hardcoded API to obtain the JMP index in the table to JMP to. The API would take a null-terminated string as input, normally a command the player just entered, and then use the table to determine what address to return back for the code can JMP or JSR to. This should make getting the shell program up and running much much quicker. However, the shell program is mainly a tool to launch other binary programs, so technically just checking the string the player entered against the list of files in the file system should be enough to make a simple shell work.

I am aiming to have a simple shell and a couple basic programs up and running by or on this weekend.

For those curious about how the block device looks after using the File System I/O API, here is a hexdump of the block storage:

00000000  80 16 4b 45 52 4e 45 4c  2e 53 59 53 00 4b 45 52  |..KERNEL.SYS.KER|
00000010  4e 45 4c 2e 4e 45 57 00  a9 f0 8d 8b ff a9 08 8d  |NEL.NEW.........|
00000020  81 ff a9 02 8d 80 ff a9  01 8d 82 ff a9 0d 8d 80  |................|
00000030  ff a9 02 8d 82 ff 4c 00  f0 00 00 00 00 00 00 00  |......L.........|
00000040  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
*
00000100  03 f7 07 00 00 4b 45 52  4e 45 4c 2e 53 59 53 00  |.....KERNEL.SYS.|
00000110  00 02 02 77 69 6f 61 70  69 2e 69 6e 63 00 00 00  |...wioapi.inc...|
00000120  04 02 f8 6b 65 72 6e 65  6c 2e 69 6e 63 00 00 06  |...kernel.inc...|
00000130  01 d8 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
00000140  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
*
00000200  a9 25 8d d4 ff a9 2c 8d  d5 ff a9 fe 85 71 a9 00  |.%....,......q..|
00000210  85 70 a9 32 85 f0 a9 f1  85 f1 a0 00 b1 f0 f0 0a  |.p.2............|
00000220  91 70 c8 a9 f0 91 70 c8  80 f2 a9 13 85 f0 a0 00  |.p....p.........|
00000230  3f 00 fe a9 00 8d d4 ff  00 a9 61 85 80 a5 f1 85  |?.........a.....|
00000240  81 a9 f2 20 e6 f0 a0 61  ad 86 ff d0 3a 20 f7 f0  |... ...a....: ..|
00000250  a9 f2 8d 01 f2 3f 00 f2  a9 6c 85 80 a9 f3 20 e6  |.....?...l.... .|
00000260  f0 a0 6c ad 86 ff d0 1f  20 f7 f0 a9 f3 8d 01 f3  |..l..... .......|
00000270  3f 00 f3 a0 ff a9 00 85  fa a9 08 85 fb a9 00 20  |?.............. |
00000280  d2 f0 a9 02 85 f1 00 20  00 f1 80 e7 08 48 b1 f0  |....... .....H..|
00000290  c9 00 f0 06 8d d0 ff c8  d0 f4 68 28 60 08 48 ad  |..........h(`.H.|
000002a0  e0 ff 91 f0 c9 0a f0 03  c8 d0 f4 a9 00 91 f0 68  |...............h|
000002b0  28 60 48 5a a0 00 b1 fa  85 ff b1 fc c5 ff d0 0c  |(`HZ............|
000002c0  c8 a9 00 c5 ff d0 ef 85  ff 7a 68 60 a9 01 85 ff  |.........zh`....|
000002d0  d0 f7 91 fa 88 d0 fb 91  fa 60 b1 fa 91 fc 88 d0  |.........`......|
000002e0  f9 b1 fa 91 fc 60 48 a9  03 8d 82 ff 9c 83 ff 9c  |.....`H.........|
000002f0  85 ff 68 8d 84 ff 60 20  8c f0 a0 3e 20 8c f0 60  |..h...` ...> ..`|
00000300  a9 1f 8d d4 ff 20 8c f0  a0 4f 20 8c f0 a9 20 8d  |..... ...O ... .|
00000310  d4 ff 60 48 61 63 6b 65  72 4b 65 72 6e 65 6c 20  |..`HackerKernel |
00000320  76 30 2e 32 20 24 52 65  76 3a 20 31 36 33 20 24  |v0.2 $Rev: 163 $|
00000330  0a 00 8c f0 9d f0 b2 f0  d2 f0 da f0 00 00 20 64  |.............. d|
00000340  72 69 76 65 72 20 6c 6f  61 64 65 64 2e 0a 00 20  |river loaded... |
00000350  66 61 69 6c 65 64 20 74  6f 20 6c 6f 61 64 2e 0a  |failed to load..|
00000360  00 46 49 4c 45 49 4f 2e  53 59 53 00 4e 45 54 44  |.FILEIO.SYS.NETD|
00000370  52 56 2e 53 59 53 00 00  00 00 00 00 00 00 00 00  |RV.SYS..........|
00000380  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
*
00000400  3b 20 44 65 63 6c 61 72  65 20 76 61 72 69 61 62  |; Declare variab|
00000410  6c 65 73 28 6d 61 6b 65  73 20 63 6f 64 65 20 65  |les(makes code e|
00000420  61 73 69 65 72 20 74 6f  20 72 65 61 64 29 0d 0a  |asier to read)..|
00000430  64 65 66 20 6e 70 61 67  65 20 24 66 66 37 30 0d  |def npage $ff70.|
00000440  0a 64 65 66 20 6e 63 6f  6e 6e 20 24 66 66 37 31  |.def nconn $ff71|
00000450  0d 0a 64 65 66 20 6e 63  62 31 20 24 66 66 37 32  |..def ncb1 $ff72|
00000460  0d 0a 64 65 66 20 6e 63  62 32 20 24 66 66 37 33  |..def ncb2 $ff73|
00000470  0d 0a 64 65 66 20 6e 70  6f 72 74 20 24 66 66 37  |..def nport $ff7|
00000480  34 0d 0a 64 65 66 20 6e  63 6e 74 6c 20 24 66 66  |4..def ncntl $ff|
00000490  37 35 0d 0a 64 65 66 20  6e 69 70 31 20 24 66 66  |75..def nip1 $ff|
000004a0  37 36 0d 0a 64 65 66 20  6e 69 70 32 20 24 66 66  |76..def nip2 $ff|
000004b0  37 37 0d 0a 64 65 66 20  6e 63 6f 6d 6d 20 24 66  |77..def ncomm $f|
000004c0  66 37 38 0d 0a 64 65 66  20 66 64 65 76 20 24 66  |f78..def fdev $f|
000004d0  66 38 61 0d 0a 64 65 66  20 66 6d 70 61 67 65 20  |f8a..def fmpage |
000004e0  24 66 66 38 62 0d 0a 64  65 66 20 66 62 6c 6b 31  |$ff8b..def fblk1|
000004f0  20 24 66 66 38 63 0d 0a  64 65 66 20 66 62 6c 6b  | $ff8c..def fblk|
00000500  32 20 24 66 66 38 64 0d  0a 64 65 66 20 66 63 6e  |2 $ff8d..def fcn|
00000510  74 6c 20 24 66 66 38 65  0d 0a 64 65 66 20 70 6f  |tl $ff8e..def po|
00000520  75 74 20 24 66 66 64 30  0d 0a 64 65 66 20 70 6f  |ut $ffd0..def po|
00000530  72 64 20 24 66 66 64 31  0d 0a 64 65 66 20 70 68  |rd $ffd1..def ph|
00000540  65 78 20 24 66 66 64 32  0d 0a 64 65 66 20 70 63  |ex $ffd2..def pc|
00000550  73 69 20 24 66 66 64 33  0d 0a 64 65 66 20 70 63  |si $ffd3..def pc|
00000560  66 67 20 24 66 66 64 34  0d 0a 64 65 66 20 70 63  |fg $ffd4..def pc|
00000570  62 67 20 24 66 66 64 35  0d 0a 64 65 66 20 70 72  |bg $ffd5..def pr|
00000580  6f 77 20 24 66 66 64 36  0d 0a 64 65 66 20 70 63  |ow $ffd6..def pc|
00000590  6f 6c 20 24 66 66 64 37  0d 0a 64 65 66 20 6d 63  |ol $ffd7..def mc|
000005a0  62 31 20 24 66 66 64 62  0d 0a 64 65 66 20 6d 63  |b1 $ffdb..def mc|
000005b0  62 31 20 24 66 66 64 63  0d 0a 64 65 66 20 6d 62  |b1 $ffdc..def mb|
000005c0  70 20 24 66 66 64 64 0d  0a 64 65 66 20 6d 72 6f  |p $ffdd..def mro|
000005d0  77 20 24 66 66 64 65 0d  0a 64 65 66 20 6d 63 6f  |w $ffde..def mco|
000005e0  6c 20 24 66 66 64 66 0d  0a 64 65 66 20 69 6e 70  |l $ffdf..def inp|
000005f0  20 24 66 66 65 30 0d 0a  00 00 00 00 00 00 00 00  | $ffe0..........|
00000600  3b 20 4b 65 72 6e 65 6c  20 41 50 49 20 69 6e 63  |; Kernel API inc|
00000610  6c 75 64 65 20 66 69 6c  65 2e 0d 0a 64 65 66 20  |lude file...def |
00000620  25 70 72 69 6e 74 20 28  24 66 65 30 30 29 0d 0a  |%print ($fe00)..|
00000630  64 65 66 20 25 69 6e 70  75 74 20 28 24 66 65 30  |def %input ($fe0|
00000640  32 29 0d 0a 64 65 66 20  25 73 74 72 63 6d 70 20  |2)..def %strcmp |
00000650  28 24 66 65 30 34 29 0d  0a 64 65 66 20 25 6d 65  |($fe04)..def %me|
00000660  6d 63 6c 72 20 28 24 66  65 30 36 29 0d 0a 64 65  |mclr ($fe06)..de|
00000670  66 20 25 6d 65 6d 63 70  79 20 28 24 66 65 30 38  |f %memcpy ($fe08|
00000680  29 0d 0a 64 65 66 20 25  66 69 6e 69 74 20 28 24  |)..def %finit ($|
00000690  66 65 32 30 29 0d 0a 64  65 66 20 25 66 63 6f 75  |fe20)..def %fcou|
000006a0  6e 74 20 28 24 66 65 32  32 29 0d 0a 64 65 66 20  |nt ($fe22)..def |
000006b0  25 66 65 78 69 73 74 73  20 28 24 66 65 32 34 29  |%fexists ($fe24)|
000006c0  0d 0a 64 65 66 20 25 70  72 69 6e 74 69 70 20 28  |..def %printip (|
000006d0  24 66 65 34 30 29 0d 0a  00 00 00 00 00 00 00 00  |$fe40)..........|
000006e0  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|