#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);
-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).
*/
;
; 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
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
/*
* 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);
}
*
* unsigned char cbm_save(const char* name,
* char device,
- * unsigned int start,
- * unsigned int end);
+ * unsigned char* data,
+ * unsigned int size);
*/
#include <cbm.h>
/* 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);
}