I didn’t publicize the C version of my Atari 8 bit library when I released it, except in a small-ish community. The current version is 1.21. The C version of the library includes some things the Action! version does not. The C version has the following features:
Text windowing
Window gadgets
Menu controls
FujiNet bindings
FujiNet Base64 and Hash bindings
APE Time support
The library can be downloaded from my GitHub site where the Action! version of the library is also hosted. Another Atari enthusiast also converted the library to Pascal, and added a few functions. The Pascal code is hosted on the GitHub page as well.
Rather than post any of it here, I’ll point you at the GitHub page for all versions of the library.
I’ve been working on a project where I need to store bytes and integers in a file and read them back in later. The bytes were easy enough, the integers were easy too, once I found the best way. I’m only talking about words consisting of two bytes.
The first method I tried was using fprintf() and fscanf(). While this works, fscanf() needs to know how many bytes to read or a terminator. This is also wasteful, as the number is saved in ASCII form. So, a 5 digit number which takes 2 bytes of memory, ends up as 5 bytes plus a terminator once saved with fprintf().
The next method I tried was calculating the high (most significant) and low (least significant) bytes, then storing them as individual bytes using fputc(). This worked well using fgetc() to retrieve the values. The method was efficient storage wise, but came at the cost of mathmatical operations on the save and read.
The last method I tried, which turns out to be the best, is using fwrite() and fread(). In the past I primarily related these to writing and reading arrays of bytes, such as character strings, or numeric arrays. It was perhaps some knowledge I lost over the years, and just re-learned. I discovered using this method its easy to store and retrieve an integer in the storage efficient 2 byte form.
I wrote a small program to set a byte and integer, display them in various forms, write them to file, then read them back into new variables, and finally display them back in the same forms. This is done on the Atari 8 bit using CC65. Compilation instructions are in the header notes.