From 16fded6d0cc4a8a9aa4235e6a07a693db4cbcbda Mon Sep 17 00:00:00 2001 From: mrintsch Date: Tue, 13 Mar 2001 22:48:19 +0000 Subject: [PATCH] Loading and saving memory areas on cbm platforms git-svn-id: svn://svn.cc65.org/cc65/trunk@625 b7a2c559-68d2-44c3-8de9-860c34a00d81 --- include/cbm.h | 13 +++++++++++++ libsrc/cbm/Makefile | 4 ++-- libsrc/cbm/c_load.s | 9 ++++----- libsrc/cbm/c_save.s | 28 ++++++++++++++++++++++++++++ libsrc/cbm/c_setlfs.s | 10 +++++----- libsrc/cbm/c_setnam.s | 6 +++--- libsrc/cbm/cbm_load.c | 20 ++++++++++++++++++++ libsrc/cbm/cbm_save.c | 18 ++++++++++++++++++ 8 files changed, 93 insertions(+), 15 deletions(-) create mode 100644 libsrc/cbm/c_save.s create mode 100644 libsrc/cbm/cbm_load.c create mode 100644 libsrc/cbm/cbm_save.c diff --git a/include/cbm.h b/include/cbm.h index 0fb618d2a..bc787241f 100644 --- a/include/cbm.h +++ b/include/cbm.h @@ -94,6 +94,19 @@ +/* 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 diff --git a/libsrc/cbm/Makefile b/libsrc/cbm/Makefile index 5a3e258c5..410ab112d 100644 --- a/libsrc/cbm/Makefile +++ b/libsrc/cbm/Makefile @@ -11,14 +11,14 @@ %.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) diff --git a/libsrc/cbm/c_load.s b/libsrc/cbm/c_load.s index 16aec28df..14b92917c 100644 --- a/libsrc/cbm/c_load.s +++ b/libsrc/cbm/c_load.s @@ -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 index 000000000..901d1cd1a --- /dev/null +++ b/libsrc/cbm/c_save.s @@ -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 diff --git a/libsrc/cbm/c_setlfs.s b/libsrc/cbm/c_setlfs.s index a8bc6f841..315a4fc50 100644 --- a/libsrc/cbm/c_setlfs.s +++ b/libsrc/cbm/c_setlfs.s @@ -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 diff --git a/libsrc/cbm/c_setnam.s b/libsrc/cbm/c_setnam.s index ed597139c..f3d571d28 100644 --- a/libsrc/cbm/c_setnam.s +++ b/libsrc/cbm/c_setnam.s @@ -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 index 000000000..8dbd5b245 --- /dev/null +++ b/libsrc/cbm/cbm_load.c @@ -0,0 +1,20 @@ +/* + * Marc 'BlackJack' Rintsch, 06.03.2001 + * + * unsigned int cbm_load(const char* name, char device, unsigned int addr); + */ + +#include + +/* 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 index 000000000..7f756e766 --- /dev/null +++ b/libsrc/cbm/cbm_save.c @@ -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 + +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); +} -- 2.39.5