How to load and save binary data on the C128 and Plus/4
Thanks to BASIC 7.0’s powerful commands we can load and save arbitrary sections of memory to disk using BLOAD and BSAVE.
This was useful for dealing with machine code as well as raw image data. Both commands work on the C128 and Plus/4, but sadly the C64 was lacking in this area.
BLOAD and BSAVE work much like DLOAD and DSAVE with the addition that you can specify a section of memory – like this:
// save contents of the 40 column display BSAVE "FILENAME", P1024 TO P2023 // save the contents of hi-res graphics and colour separately BSAVE "IMAGE", P8192 TO P16181 BSAVE "COLOURS", P7168 TO P8167 // save graphics and colour information together BSAVE "FULL IMAGE", P7168 TO P16181
BLOAD doesn’t need additional parameters and will load a file back into memory where it originally resided – just like the standard LOAD “FILE”,8,1 (with the 1 at the end). You can however provide the starting memory and make the file load somewhere else instead:
// load file to a different place in memory BLOAD "FILENAME", P10000