1 ; This is a utility program to delete all data on a disk drive.
2 ; The deletion is done by filling all directory sectors with 0E5h.
4 ; The program can be used, to init a RAM disk after cold start.
6 ; Copyright (C) 2010 Leo C.
8 ; This program is free software: you can redistribute it and/or modify
9 ; it under the terms of the GNU General Public License as published by
10 ; the Free Software Foundation, either version 3 of the License, or
11 ; (at your option) any later version.
13 ; This program is distributed in the hope that it will be useful,
14 ; but WITHOUT ANY WARRANTY; without even the implied warranty of
15 ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 ; GNU General Public License for more details.
18 ; You should have received a copy of the GNU General Public License
19 ; along with this program. If not, see <http://www.gnu.org/licenses/>.
27 biosofs equ -3 ;offset
29 wbootf equ biosofs+3*1 ;warm boot function
30 homef equ biosofs+3*8 ;disk home function
31 seldskf equ biosofs+3*9 ;select disk function
32 settrkf equ biosofs+3*10 ;set track function
33 setsecf equ biosofs+3*11 ;set sector function
34 setdmaf equ biosofs+3*12 ;set dma function
35 readf equ biosofs+3*13 ;read disk function
36 writef equ biosofs+3*14 ;write disk function
37 sectranf equ biosofs+3*16 ;sector translate
60 usage: db 'Usage: WIPE [Options] d:',cr,lf
61 db 'Delete all files on drive d: in all user areas.',cr,lf
64 db ' -Y Don''t ask for confirmation.',cr,lf
68 minvch: db '?:' ;filled in
71 db 'Can not select drive '
72 mnodrch:db '?:' ;filled in
74 mnowipe:db 'Nothing done.'
77 db 'Delete all files in all user areas on drive '
92 ; Get next character from commandline
113 ; Setup command line. (Terminate with 0)
117 ld e,(hl) ; get number of characters on command line
130 jp z,pusage ; empty command line
132 jp nz,pcmdarg ; no option, parse agrument
138 jp z,pusage ; no argument
140 ld b,'?' ; get argument (disk drive)
141 cp ' ' ; non printable char?
155 ; Fill buffer with E5
168 ; Print messages on console
170 pusage: ld de,usage ; address of usage text
184 ; Ask for confirmation.
190 ld c,pstring ; CP/M command for print
196 ld c,pstring ; CP/M command for print
198 ld a,(conlin) ; first char
204 ld c,pstring ; CP/M command for print
207 ; Return to CCP (no warmboot).
213 ; Call BIOS functions
239 ld c,1 ;write type = dir
256 pop hl ; Get return address;
257 ld (ccpret),hl ; and save it for later
258 ld sp,stack ; Setup local stack.
261 ld a,(drive) ; Was a drive specified?
263 jp z,pusage ; If not, print message and return.
264 cp 'A' ; valid drive letter?
269 ld a,(optyes) ; Was 'Y' option given?
271 call z,confirm ; If no, ask for confirmation.
273 ; Command is ok and confirmed, check drive
275 ld a,(drive) ; Select the requested drive.
276 sub 'A' ; Use the BIOS function for this,
277 ld c,a ; as BDOS would initialize the drive
278 call bseldsk ; and try to read the (broken) directory.
283 ld a,(cdisk) ; Reselect current disk drive.
287 jp pnodrive ; Msg, and return to CCP.
289 ; Drive exists. Get disk parameter
291 ld a,(hl) ; sector translation table
301 ld d,(hl) ; de = dpb of selected drive
303 ld hl,13 ; ofset to # of reserved tracks
305 ld c,(hl) ; Start track
307 ld b,(hl) ; bc = track
309 push bc ; save for later
311 ; Compute number of sectors to fill.
315 ld a,(hl) ; get drm (# of dir entries - 1)
319 ld a,(hl) ; Each sector holds 4 dir entries
332 ld c,a ; c = # of sectors ((drm+1+3)/4)
334 ; Get sectors per track.
336 ld a,(de) ; b = sectors per track
347 pop de ; d = spt, e = nsec
364 pop de ;d = spt, e = nsec
370 cp d ;if sector >= spt then change tracks
378 ; All directory sectors filled.
381 jp 0 ; Boot (reinits disks)
383 progend:ds (($+255) and 0ff00h)-$ ; Fill rest of page with zero
389 ; vim:set ts=8 noet nowrap