home *** CD-ROM | disk | FTP | other *** search
- ;remove.asm
- ;========================================
- ; Command: remove a RAM resident command
- ;========================================
- ; Last changed: 07March88
-
- zrimg = $0060 ; Shell's copy of REU command register
- z128 = $0061 ; Shell's copy of $DF02
- zrda = $0063 ; Shell's copy of $DF04
- zxfer = $0066 ; Shell's copy of $DF05
- poker = $0016 ; Zero page pointer
- index1 = $0024 ; Zero page pointer
- index2 = $0026 ; Zero page pointer
- int04 = $1704 ; Get 1st char of parameter .x
- int05 = $1705 ; Get next char after int04
- int0e = $170e ; Program terminate
- int21 = $1721 ; Function interrupt
- rflag = $1bf0 ; Bit 7=1 if ramdisk is in the 1750
- primm = $ff7d ; Print immediate
- chrout = $ffd2
- rdmax = $1bf1 ; Last address or page used by ramdisk
- rdadr = $1bf5 ; First address or page used by ramdisk
- rdbnk = $1bf3 ; Bank ramdisk starts in
- tx = $1bfe ; Bit 6=1 if ramdisk is enabled
- getcfg = $ff6b ; Convert bank to CR
-
- star = $0b00
- .wor star
- * = star
-
- jmp Remove
- dw Date
-
- Remove lda #13
- jsr chrout
- bit tx ; First make sure ramdisk is enabled
- bvs remove ; it is
- jsr primm
- .asc "RAM disk isn't installed.",13,0
- exit1 lda #1
- jmp int0e
-
- remove ldx #1 ; start with %1 and work up
- stx parm
- rm0 ldx parm
- jsr int04 ; confirm that parameter exists
- bcc rm1 ; ok. go on its there
- exit0 lda #0
- jmp int0e ; all done
-
- rm1 ldy #6 ; find %x in ramdisk
- jsr int21 ; 'zrda' points to file header if found
- php ; save found flag
- ldy #2 ; get ready for echo
- bcc rm2 ; name at $1b60 if found
- ldx parm ; otherwise echo parameter
- jsr int04
- gc jsr chrout
- iny
- jsr int05
- bcc gc
- bcs rm3
-
- rm2 lda $1b60,y ; echo filename
- beq rm3
- jsr chrout
- iny
- bne rm2
-
- rm3 lda #" " ; tab(16)
- jsr chrout
- iny
- cpy #18
- bne rm3
- plp ; was it found?
- bcc rm4 ; yes. remove it
- jsr primm
- .asc "Not found.",13,0
- rmnx inc parm
- jmp rm0
-
- rm4 jsr remit ; remove it
- bcc done
- jsr primm
- .asc "RAM disk corrupt. Can't remove",13,0
- exit4 lda #4
- jmp int0e
-
- done jsr primm
- .asc "Removed.",13,0
- jmp rmnx
-
-
- ;------------------------------------------------
- ; Subroutine: remove file at $1b60 from RAM disk
- ;------------------------------------------------
-
- ; SEC = error, CLC = file removed
-
- remit ldy #9 ; Save this file's starting address
- rmi0 lda zrimg,y ; This will be the destination of the move
- sta destn,y
- dey
- bpl rmi0
- ldy #7 ; bump to next file
- jsr int21 ; (adds current file's length to 'zrda')
- bcc rmi1 ; OK
- rmi3 rts ; Error, better quit
-
- rmi1 ldy #9
- rmi2 lda zrimg,y ; save source of move
- sta source,y
- dey
- bpl rmi2
- ldy #8 ; and get highest address to move
- jsr int21 ; 'zrda' points to end of RAM disk
- bcs rmi3 ; Error
- bit rflag ; In RAM or 1750?
- bmi in1750
- lda source+3 ; In RAM we need zero page
- sta index1
- lda source+4
- sta index1+1
- lda destn+3
- sta index2
- lda destn+4
- sta index2+1
- ldy #0
- lda rdbnk+1
- sta $ff00
- loop lda (index1),y
- sta (index2),y
- inc index1
- bne loop1
- inc index1+1
- loop1 inc index2
- bne loop2
- inc index2+1
- loop2 lda index1+1
- cmp rdmax+1
- bne loop
- lda index1
- cmp rdmax
- bne loop2
- sty $ff00
- clc
- rts
-
- in1750 lda #<$1600 ; Set 1 page buffer at $1600
- sta source+1
- sta destn+1
- lda #>$1600
- sta source+2
- sta destn+2
- lda #<256
- sta source+6
- sta destn+6
- lda #>256
- sta source+7
- sta destn+7
- lda #%10010000 ; Adjust control register for 128->REU
- sta destn
- clc ; Last address is this plus two
- lda zrda
- adc #2
- sta zrda
- bcc jjj
- inc zrda+1
- bne jjj
- inc zrda+2
- jjj jsr pgdn ; Move one page down
- bcs jjj ; Still more
- clc ; Else done
- rts
-
- pgdn 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
- sta destn+7
- lda temp
- sta source+6
- sta destn+6
- ora temp+1 ; Length=0?
- bne use256 ; No..go on
- clc
- rts
- use256 ldy #9 ; fetch page
- lda $d030
- pha
- and #%11111110
- sta $d030
- bit $df00 ; Clear flags
- l1 lda source,y ; Fetch page
- sta $df01,y
- dey
- bpl l1
- wait bit $df00 ; wait for completion
- bvc wait
- ldy #9
- l2 lda destn,y ; Store it back at lower address
- sta $df01,y
- dey
- bpl l2
- wait2 bit $df00 ; Wait for completion
- bvc wait2
- pla
- sta $d030
- clc
- lda source+3 ; Adjust source
- adc source+6
- sta source+3
- lda source+4
- adc source+7
- sta source+4
- bcc l3
- inc source+5
- l3 clc
- lda destn+3 ; Adjust destination
- adc destn+6
- sta destn+3
- lda destn+4
- adc destn+7
- sta destn+4
- bcc ll3
- inc destn+5
- ll3 sec ; Check if done
- lda zrda
- sbc source+3
- lda zrda+1
- sbc source+4
- lda zrda+2
- sbc source+5
- rts ; SEC=still more, CLC=done
-
- source *=*+10
- destn *=*+10
- temp *=*+2
- parm *=*+2
-
- .end
-