On Mon, Aug 15, 2022 at 1:47 PM B 9 <[email protected]> wrote: > > Is there a manual where the .CO file format is defined? I presume there's > a header I'll have to skip to get to my data, but what is its format? Also, > how can I render a .CO file harmless if a user accidentally tries to load > it. For example, can I set the reserved load location to be 0000 so it'll > write to ROM? > >
https://bitchin100.com/wiki/index.php?title=Low_Level_Filesystem_Access#CO_File_Format As to making the CO file safe... I don't know you'd have to experiment. I think you'd have to find a RET instruction in memory for your platform and set the EXEC address there. In fact if you don't CLEAR before load or launch the CO it will fail no matter what, error BEEP and show the Load, Length and EXE address. > If you want to create a binary file, you need to create a CO file by >> saving a range of memory to a CO file. To create the initial contents you >> would POKE your bytes into a reserved region of memory. >> > > That would be the simplest way, but I'm trying to avoid duplicating the > file in memory. Has anybody ever tried first creating a .DO file of the > correct size in BASIC and then twiddling the RAM Directory's attribute byte > so that it is a binary file? > You cannot do that. The BA, DO and CO regions are separate contiguous blocks. You'd have to move the file bytes if you changed its type. Which is a whole thing. Take a look at the link above for the general file system structure. > Once I have the file's address, I could just poke directly into it and > save the copy. Right? Or am I missing something? (For example, after > creating a file, does the Ram Directory get updated? I already noticed that > I need to use CLEAR at the start of my program since the file pointers are > stale after doing an EDIT in BASIC.) > > To create a CO file: First, CLEAR space at some location. Of it it's small you could poke your contents into some known safe region like the ALTLCD buffer. This is a small buffer that maintain a copy of the screen contents while TELCOM is in operation. After you have a safe area, you can poke your data to it. Then you can SAVE it as a file. This command is different on different BASICs. As to having one program run on M100, T200 and NEC... be advised that is tricky if it's even possible. Their BASICs are different, and there ROMs are different and their RAM offsets are different. In particular the SAVE/LOAD commands are different between NEC and Tandy. -- John.
