Jump to content

Load a file, using cc65, into RAM or VERA


rje
 Share

Recommended Posts

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...
Edited by rje
  • Thanks 1
Link to comment
Share on other sites

  • 2 weeks later...

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);

Edited by CX16UserSteveC
Clarified alternate way to save and load RAM data which seems to be simpler..
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...

Important Information

Please review our Terms of Use