]> git.sur5r.net Git - cc65/commitdiff
Loading and saving memory areas on cbm platforms
authormrintsch <mrintsch@b7a2c559-68d2-44c3-8de9-860c34a00d81>
Tue, 13 Mar 2001 22:48:19 +0000 (22:48 +0000)
committermrintsch <mrintsch@b7a2c559-68d2-44c3-8de9-860c34a00d81>
Tue, 13 Mar 2001 22:48:19 +0000 (22:48 +0000)
git-svn-id: svn://svn.cc65.org/cc65/trunk@625 b7a2c559-68d2-44c3-8de9-860c34a00d81

include/cbm.h
libsrc/cbm/Makefile
libsrc/cbm/c_load.s
libsrc/cbm/c_save.s [new file with mode: 0644]
libsrc/cbm/c_setlfs.s
libsrc/cbm/c_setnam.s
libsrc/cbm/cbm_load.c [new file with mode: 0644]
libsrc/cbm/cbm_save.c [new file with mode: 0644]

index 0fb618d2a59de3e6e24f80928ffb682c049fa103..bc787241f4510b931f75e28c749bbfd76326177a 100644 (file)
 
 
 
+/* 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
 
index 5a3e258c5495e642393d83051d90eb874f38c8c4..410ab112d38b8439cbd7575827380ac03ce0135a 100644 (file)
 %.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)
 
index 16aec28df191689530132fb3c3e6ac94af8fb946..14b92917c19a87d69896f30283b738c1822144f5 100644 (file)
@@ -1,18 +1,18 @@
 ;
 ; 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
@@ -23,4 +23,3 @@ _cbm_load:
        rts
 @Ok:   txa
        rts
-
diff --git a/libsrc/cbm/c_save.s b/libsrc/cbm/c_save.s
new file mode 100644 (file)
index 0000000..901d1cd
--- /dev/null
@@ -0,0 +1,28 @@
+;
+; 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
index a8bc6f841826de05df605af26e5e23547bdd8185..315a4fc5082ba951e84844a32c76cf3ca2d900b8 100644 (file)
@@ -1,18 +1,18 @@
 ;
 ; 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
index ed597139c6cf8525bb1bef93b300e75506a0e043..f3d571d28e8a200033c84757dd092c0fc79c0a39 100644 (file)
@@ -1,15 +1,15 @@
 ;
 ; 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
diff --git a/libsrc/cbm/cbm_load.c b/libsrc/cbm/cbm_load.c
new file mode 100644 (file)
index 0000000..8dbd5b2
--- /dev/null
@@ -0,0 +1,20 @@
+/*
+ * 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);
+}
diff --git a/libsrc/cbm/cbm_save.c b/libsrc/cbm/cbm_save.c
new file mode 100644 (file)
index 0000000..7f756e7
--- /dev/null
@@ -0,0 +1,18 @@
+/*
+ * 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);
+}