DEV Community


Doing the Port Myself

mich_cook profile image mich ・2 min read

Part of the catalog software that I mentioned in my previous post will take a disk image, validate it, and get a listing of the files on the disk as well as a few other details (disk name, blocks free).

As I also mentioned previously, there's already software out there that does this called c1541 that's part of the VICE emulator. It was done and seemed that it would be easy to use (it's easy to use on a local machine), but this meant that I would need to use google run. Not that I mind that, but it meant building docker a container to have google, well, run.

Starting to get my docker VM running, it ALSO reported that it was out of space (it would appear that 10GB allocations of fixed disks isn't a very good idea). So instead of going through the whole process like I did last time, I went a different direction that I had planned to do later regardless: port c1541 to JavaScript myself. I looked to see if there was anything that already existed and nothing really hit the mark that I needed.

Loading a file is pretty easy in node.js. I just used fs.readFileSync since I really didn't need async and there wasn't much point in wrapping everything else in a promise. From there it was just jumping around the buffer.

I found two different sources that had almost identical information about the bytes of a .d64 file that appeared to both copy from roughtly the same place. It was fun to see that tripod is still around. I remember them from many years ago.

Using these sources, I was able to navigate a bit around the file buffer to get the parts that I needed. It was so simple since you can seek a node.js buffer just like it's an array. So disk[0x16500] gives me the byte at 0x16500. Pretty spiffy!

I'll probably write more about the actual code soon, but in the meantime you can take a look at the github project and/or play with the npm package.

Discussion (0)

Editor guide