home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
CP/M
/
CPM_CDROM.iso
/
enterprs
/
c128
/
text
/
examples.arc
/
PUTRAM.A
< prev
next >
Wrap
Text File
|
1989-12-01
|
8KB
|
217 lines
; putram.asm
;====================================
; Command: Save RAM disk to floppy
;====================================
zrimg = $0060
z128 = $0061
zrda = $0063
zxfer = $0066
poker = $0016
index1 = $0024
index2 = $0026
fetvec = $02aa
fetch = $02a2
int04 = $1704
int05 = $1705
int09 = $1709
int0c = $170c
int0d = $170d
int0e = $170e
int13 = $1713
int21 = $1721
rflag = $1bf0
primm = $ff7d
chrout = $ffd2
chkout = $ffc9
clrchn = $ffcc
rdmax = $1bf1
rdadr = $1bf5
rdbnk = $1bf3
tx = $1bfe
getcfg = $ff6b
star = $0b00
.wor star
* = star
jmp Putram
dw Date
Putram bit tx ; Make sure RAM disk is there
bvs putram ; It is
jsr primm
.asc "RAM disk isn't installed.",13,0
lda #1
jmp int0e
putram jsr chkram ; Setup
ldx #1 ; Scratch the output file
jsr int13
ldx #1 ; filename is %1
lda #"p" ; save as PRG file
jsr int09
bcc opnok ; open went ok
dskerr jsr clrchn ; disk error. display ds$ and quit
jsr int0d
lda #2
jmp int0e ; all done
opnok jsr chkout ; get ready for output
bcs dskerr
lda #0 ; write a phony load address
jsr chrout
lda #$a0
jsr chrout
wrtlp jsr fetblk ; fetch RAM disk block
jsr wrtblk ; write it to disk
bcc wrtlp ; still more
lda #0
jsr chrout
lda #0
jsr chrout
jsr clrchn
jsr primm
.asc "RAM disk saved as ", 0
ldx #1
jsr int04
more jsr chrout
jsr int05
bcc more
lda #13
jsr chrout
lda #0
jmp int0e
;-------------------------------------
; Subroutine: Setup RAM disk for read
;-------------------------------------
; SEC = error, CLC = disk seems ok so far
chkram ldy #4 ; Initialize, seek to start of RAM disk
jsr int21
ldy #5 ; Move ahead to first name
jsr int21
bne cr0 ; Found one
jsr primm
.asc "RAM disk is empty. Why save it?",13,0
lda #1
jmp int0e
cr0 ldy #9 ; save REC image for move
rmi0 lda zrimg,y
sta source,y
dey
bpl rmi0
ldy #8 ; seek to end of RAM disk
jsr int21
bcc rmi1
rmi3 jsr primm
.asc "Error reading RAM disk.",13,0
lda #4
jmp int0e
rmi1 clc
lda zrda ; +2 to get true size
adc #2
sta zrda
bcc mri1
inc zrda+1
bne mri1
inc zrda+2
mri1 bit rflag ; in RAM or 1750?
bmi in1750
lda source+3 ; in RAM we need zero page
sta rdorg
lda source+4
sta rdorg+1
in1750 lda #<buf ; setup buffer address
sta source+1
lda #>buf
sta source+2
lda #<256
sta source+6
lda #>256
sta source+7
rts
fetblk sec ; if (end of disk)-source <256 then change xfer length
lda zrda ; to the difference
sbc source+3
sta temp
lda zrda+1
sbc source+4
sta temp+1
lda zrda+2
sbc source+5
ora temp+1
bne use256
sta source+7 ; change blocksize for last block
lda temp
sta source+6
use256 bit rflag
bpl nt1750
ldy #9 ; fetch page
lda $d030
pha
and #%11111110
sta $d030
l1 lda source,y
sta $df01,y
dey
bpl l1
wait bit $df00 ; wait for completion
bvc wait
pla
sta $d030
l4 inc source+4
bne l3
inc source+5
l3 rts
source .wor 0,0,0,0,0
temp .wor 0
nt1750 lda rdorg
sta index1
lda rdorg+1
sta index1+1
lda #<index1
sta fetvec
ldy #0
ntfl ldx rdbnk+1
jsr fetch
sta buf,y
iny
bne ntfl
inc rdorg+1
jmp l4
wrtblk ldy #0
lda source+7
bne doall
ldy source+6
beq none
doall sty max
ldy #0
wlp lda buf,y
jsr chrout
iny
cpy max
bne wlp
lda source+7
bne more1
none sec
.byt $24
more1 clc
rts
max .byt 0
rdorg * = *+2
buf * = *+256
.end