Jump to content

Load a file, using cc65, into RAM or VERA


Recommended Posts

So you're using cc65 and want to load a file, whether into system RAM or VERA.
Here's how.


//   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:



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.

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.


  • Create New...

Important Information

Please review our Terms of Use