Page 1 of 1
Load a file, using cc65, into RAM or VERA
Posted: Thu Apr 15, 2021 7:50 pm
by rje
So you're using cc65 and want to load a file, whether into system RAM or VERA.
Here's how.
cbm_k_setnam("petfont.bin");
cbm_k_setlfs(0,8,0);
//
// A word about cbm_k_load( destination, address )
//
// The address value of cbm_k_load() gets you 16 bits. Of course,
// VERA's addressing space is larger. So you DO have to properly
// set the FIRST parameter to cbm_k_load():
// 0 points to X16's RAM.
// 1 points to VERA $00000.
// 2 points to VERA $10000.
//
cbm_k_load(2, 0xf800); // replace these with your target address...
Load a file, using cc65, into RAM or VERA
Posted: Fri Apr 16, 2021 12:47 am
by Greg King
0 is LOAD, 1 is VERIFY, 2 and 3 are VERA.
Load a file, using cc65, into RAM or VERA
Posted: Sun Apr 25, 2021 4:07 am
by CX16UserSteveC
Data in the 6502 microprocessor RAM can also be loaded and saved via the following cc65 function calls which are declared in cbm.h:
unsigned int __fastcall__ cbm_load (const char* name, unsigned char device, void* data);
/* Loads file "name", from given device, to given address -- or, to the load
** address of the file if "data" is the null pointer (like load"name",8,1
** in BASIC).
** Returns number of bytes that were loaded if loading was successful;
** otherwise 0, "_oserror" contains an error-code, then (see table above).
*/
unsigned char __fastcall__ cbm_save (const char* name, unsigned char device,
const void* addr, unsigned int size);
/* Saves "size" bytes, starting at "addr", to a file.
** Returns 0 if saving was successful, otherwise an error-code (see table
** above).
*/
Here are some example invocations:
r=cbm_save("bitminer.dat",8,&minerData,sizeof(minerData));
bytesLoaded=cbm_load("bitminer.dat",8,&minerDataLoadBuffer);