Load a file, using cc65, into RAM or VERA

Tutorials and help articles.

(Posts require approval. See pinned post.)
Forum rules
Post guides, tutorials, and other instructional content here.

This topic area requires approval, so please be patient while we review content to make sure it fits the expectations for this topic area.

Tech support questions should be asked in Hardware or Software support.
Post Reply
rje
Posts: 1263
Joined: Mon Apr 27, 2020 10:00 pm
Location: Dallas Area

Load a file, using cc65, into RAM or VERA

Post 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...

Greg King
Posts: 162
Joined: Wed Jul 08, 2020 1:14 pm

Load a file, using cc65, into RAM or VERA

Post by Greg King »


0 is LOAD, 1 is VERIFY, 2 and 3 are VERA.

CX16UserSteveC
Posts: 37
Joined: Thu Jul 23, 2020 4:29 pm

Load a file, using cc65, into RAM or VERA

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

Post Reply