+/* 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 __fastcall__ cbm_k_load (unsigned char flag, unsigned addr);
+unsigned __fastcall__ cbm_k_save(unsigned int start, unsigned int end);
+
+/* BASIC-like functions */
+unsigned int cbm_load(const char* name, char device, unsigned int addr);
+unsigned int cbm_save(const char* name, char device,
+ unsigned int start, unsigned int end);
+
+
/* End of cbm.h */
#endif
%.o: %.s
@$(AS) -g -o $@ $(AFLAGS) $<
-C_OBJS =
+C_OBJS = cbm_load.o cbm_save.o
S_OBJS = ctype.o getenv.o gotoxy.o gotox.o gotoy.o where.o\
clock.o chline.o cvline.o cclear.o revers.o\
c_readst.o c_close.o c_open.o c_ckout.o c_clrch.o c_bsout.o\
c_basin.o c_clall.o c_iobase.o c_setnam.o c_setlfs.o c_acptr.o\
c_ciout.o c_untlk.o c_unlsn.o c_listen.o c_talk.o c_load.o\
- oserror.o
+ c_save.o oserror.o
all: $(C_OBJS) $(S_OBJS)
;
; Ullrich von Bassewitz, 03.06.1999
;
-; unsigned __fastcall__ cbm_load (unsigned char flag, unsigned addr);
+; unsigned __fastcall__ cbm_k_load (unsigned char flag, unsigned addr);
;
.include "cbm.inc"
- .export _cbm_load
+ .export _cbm_k_load
.import popa
.importzp ptr1
-_cbm_load:
+_cbm_k_load:
sta ptr1
- stx ptr1+1
+ stx ptr1+1
jsr popa ; get flag
ldx ptr1
ldy ptr1+1
rts
@Ok: txa
rts
-
--- /dev/null
+;
+; Marc 'BlackJack' Rintsch, 11.06.1999
+;
+; unsigned __fastcall__ cbm_k_save(unsigned int start, unsigned int end);
+;
+
+ .include "cbm.inc"
+
+ .export _cbm_k_save
+ .import popax
+ .importzp ptr1, tmp1
+
+_cbm_k_save:
+ sta tmp1 ; store end address
+ stx tmp1+1
+ jsr popax ; pop start address
+ sta ptr1
+ stx ptr1+1
+ lda #ptr1
+ ldx tmp1
+ ldy tmp1+1
+ jsr SAVE
+ ldx #0
+ bcc @Ok
+ inx
+ rts
+@Ok: txa
+ rts
;
; Ullrich von Bassewitz, 03.06.1999
;
-; void __fastcall__ cbm_setlfs (unsigned char LFN,
-; unsigned char DEV,
-; unsigned char SA);
+; void __fastcall__ cbm_k_setlfs (unsigned char LFN,
+; unsigned char DEV,
+; unsigned char SA);
;
.include "cbm.inc"
- .export _cbm_setlfs
+ .export _cbm_k_setlfs
.import popa
.importzp tmp1
-_cbm_setlfs:
+_cbm_k_setlfs:
sta tmp1 ; Save SA
jsr popa ; Get DEV
tax
;
; Ullrich von Bassewitz, 03.06.1999
;
-; void __fastcall__ cbm_setnam (const char* Name);
+; void __fastcall__ cbm_k_setnam (const char* Name);
;
.include "cbm.inc"
- .export _cbm_setnam
+ .export _cbm_k_setnam
.importzp ptr1
-_cbm_setnam:
+_cbm_k_setnam:
sta ptr1 ; Store pointer to file name
stx ptr1+1
ldy #$FF
--- /dev/null
+/*
+ * Marc 'BlackJack' Rintsch, 06.03.2001
+ *
+ * unsigned int cbm_load(const char* name, char device, unsigned int addr);
+ */
+
+#include <cbm.h>
+
+/* loads file "name" from given device to given address or to the load address
+ * of the file if addr is 0
+ */
+unsigned int cbm_load(const char* name, char device, unsigned int addr)
+{
+ /* 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) ? 1 : 0));
+ cbm_k_setnam(name);
+ return cbm_k_load(0, addr);
+}
--- /dev/null
+/*
+ * Marc 'BlackJack' Rintsch, 11.03.2001
+ *
+ * unsigned int cbm_save(const char* name,
+ * char device,
+ * unsigned int start,
+ * unsigned int end);
+ */
+
+#include <cbm.h>
+
+unsigned int cbm_save(const char* name, char device,
+ unsigned int start, unsigned int end)
+{
+ cbm_k_setlfs(0, device, 0);
+ cbm_k_setnam(name);
+ return cbm_k_save(start, end);
+}