1
0
mirror of https://github.com/cc65/cc65.git synced 2024-09-28 10:55:43 +00:00

Changed the parameters of cbm_load and cbm_save to a more "C-like" way.

The API should be stable now.


git-svn-id: svn://svn.cc65.org/cc65/trunk@1018 b7a2c559-68d2-44c3-8de9-860c34a00d81
This commit is contained in:
mrintsch 2001-10-10 20:35:07 +00:00
parent 88dfee5642
commit babcf84f17
4 changed files with 41 additions and 24 deletions

View File

@ -83,13 +83,19 @@
#define CH_INS 148
#define CH_ESC 95
/* constants to use with cbm_open() for opening a file for reading or
* writing without the need to append ",r" or ",w" to the filename.
*
* e.g.: cbm_open(2, 8, CBM_READ, "data,s");
*/
#define CBM_READ 0
#define CBM_WRITE 1
/* Kernel level functions */
void __fastcall__ cbm_k_setlfs (unsigned char LFN, unsigned char DEV,
unsigned char SA);
void __fastcall__ cbm_k_setnam (const char* Name);
unsigned char __fastcall__ cbm_k_load(unsigned char flag, unsigned addr);
unsigned int __fastcall__ cbm_k_load(unsigned char flag, unsigned addr);
unsigned char __fastcall__ cbm_k_save(unsigned int start, unsigned int end);
unsigned char __fastcall__ cbm_k_open (void);
void __fastcall__ cbm_k_close (unsigned char FN);
@ -110,17 +116,18 @@ void __fastcall__ cbm_k_clrch (void);
unsigned char cbm_load(const char* name, unsigned char device,
unsigned int addr);
unsigned int cbm_load(const char* name, unsigned char device,
const char* data);
/* Loads file "name" from given device to given address or to the load
* address of the file if addr is 0 (like load"name",8,1 in BASIC)
* Returns 0 if loading was successful otherwise an errorcode (see table
* below).
* address of the file if "data" is the null pointer (like load"name",8,1
* in BASIC).
* Returns number of bytes that where loaded if loading was successful
* otherwise 0. "_oserror" contains an errorcode then (see table below).
*/
unsigned char cbm_save(const char* name, unsigned char device,
unsigned int start, unsigned int end);
/* Saves a memory area from start to end-1 to a file.
unsigned char* data, unsigned int size);
/* Saves "size" bytes starting at "data" to a file.
* Returns 0 if saving was successful, otherwise an errorcode (see table
* below).
*/

View File

@ -1,12 +1,13 @@
;
; Ullrich von Bassewitz, 03.06.1999
;
; unsigned char __fastcall__ cbm_k_load (unsigned char flag, unsigned addr);
; unsigned int __fastcall__ cbm_k_load (unsigned char flag, unsigned addr);
;
.include "cbm.inc"
.export _cbm_k_load
.import __oserror
.import popa
.importzp ptr1
@ -17,7 +18,14 @@ _cbm_k_load:
ldx ptr1
ldy ptr1+1
jsr LOAD
bcs @NotOk
lda #0
@NotOk: rts
bcc @Ok
sta __oserror
ldx ptr1
ldy ptr1+1
@Ok: txa
pha
tya
tax
pla
rts

View File

@ -1,21 +1,22 @@
/*
* Marc 'BlackJack' Rintsch, 06.03.2001
*
* unsigned char cbm_load(const char* name, char device, unsigned int addr);
* unsigned int cbm_load(const char* name,
* unsigned char device,
* const unsigned char* data);
*/
#include <cbm.h>
#include <errno.h>
/* loads file "name" from given device to given address or to the load address
* of the file if addr is 0
* of the file if "data" is 0
*/
unsigned char cbm_load(const char* name, unsigned char device,
unsigned int addr)
unsigned int cbm_load(const char* name, unsigned char device,
const char* data)
{
/* LFN is set to 0 but it's not needed for loading.
* (BASIC V2 sets it to the value of the SA for LOAD) */
cbm_k_setlfs(0, device, addr == 0);
cbm_k_setlfs(0, device, data == 0);
cbm_k_setnam(name);
return _oserror = cbm_k_load(0, addr);
return (cbm_k_load(0, (unsigned int)data) - (unsigned int)data);
}

View File

@ -3,8 +3,8 @@
*
* unsigned char cbm_save(const char* name,
* char device,
* unsigned int start,
* unsigned int end);
* unsigned char* data,
* unsigned int size);
*/
#include <cbm.h>
@ -13,9 +13,10 @@
/* saves a memory area from start to end-1 to a file.
*/
unsigned char cbm_save(const char* name, unsigned char device,
unsigned int start, unsigned int end)
unsigned char* data, unsigned int size)
{
cbm_k_setlfs(0, device, 0);
cbm_k_setnam(name);
return _oserror = cbm_k_save(start, end);
return _oserror =
cbm_k_save((unsigned int)data, ((unsigned int)data) + size);
}