********************************************************* * CSAVEB * Save ASCII text in memory to tape as a BASIC program. * * This program is relocatable, except that it assumes * its data buffer to start at $4000, and its end-buffer * pointer to be at $3100 and $3101, as per COMM4. Note * that this end-buffer pointer points one byte past the * last byte to be saved; it does not point at the last * byte itself. * * By default (entry point=$3000), the starting address * of the data to save is $4000. The last byte saved * is determined by the end-buffer pointer as described * above. * * The alternative (entry point=$3002) is that the * starting address is found at run-time, at $3102 * and $3103. The last byte saved is determined by the * end-buffer pointer as described above. * * It maps out ROMs when reading the data to write onto * tape, allowing for programs up to almost 48K (if the * saved data starts at address $4000). * * 20-Aug-99 310am WJY - initial version * 2-Sep-99 930pm WJY - write gaps between data blocks * 2-Sep-99 1000pm WJY - write a gap before the EOF block * 4-Sep-99 1130pm WJY - swap out ROMs to allow 48K files * 5-Sep-99 105am WJY - show count of written data blocks * 12-Sep-99 10pm WJY - improved block counter * 12-Sep-99 1030pm WJY - allow alternate data address ********************************************************** noopt include "coco.asm" * COMM4 leftover data buffer equ $4000 ; buffer of ASCII data last equ $3100 ; last address filled + 1 * These are considered as external to the program, * so references to them should not be relative. * Data needed with the special entry point ($3002) spdata equ $3102 ; address of the data to save * buffer location for the block of data to write blkbuf equ $3200 ; .. $32FF - data block to write org $3000 start bra normal start2 bra specl fcb $99,$09,$12,$10,$30 ; revision date & time fcc "CSAVEB V0.7" normal ldx #buffer ; default addresses == buffer stx spdata specl orcc #IRQ|FIRQ ; disable interrupts clr numwrt,pc ; no blocks written yet lda #$30 sta ACTIND-2 * write the name block leax namblk,pc stx CBUFAD ldd #(NAMBLK<<8)+15 ; NAMBLK:BLKLEN=15 std BLKTYP ; and BLKLEN jsr [WRTLDR] jsr [BLKOUT] ; write the name block bsr count ; increment block counter * write the data blocks ldx spdata stx blksrc,pc ; initialize data pointer dloop ldd last ; figure out the length subd blksrc,pc bls endblk ; no data left? tsta beq length ldb #255 ; block length = max length lda #DATBLK std BLKTYP ; and BLKLEN ldx blksrc,pc ; copy data from source ldy #blkbuf ; ... into the block buffer sty CBUFAD ; re-init buffer address sta SAMTYP+1 ; map out ROM, map in upper 32K RAM copy lda ,x+ sta ,y+ decb bne copy stx