Files
RomWBW/Source/Images/d_bp/u15/CLEANDIR.MAC
b1ackmai1er 78f65522b7 Dev (#108)
* added hack to handle tunes

* quiet clean

* added chmod for execution

* suppress warnings

* Multi-boot fixes

* the windows build somehow thinks that these filesystems are cpm3.

* credit and primitive instructions

* Update sd.asm

Cosmetic fix.

* make compile shut up about conditionals

* Add bin2asm for linus and update build to process font files under linix

* fixed quoted double quote bug, added tests

* added tests

* added bin2asm for font file source creation

* Revert linux bin2asm font stuff

* added rule for font source generation

* build fonts

* added directory mapping cache.  if the same directory is being hit
as last run, we don't need to rebuild the map.  will likely break if
you are running more than one at a time, in that the cache will be
ineffective.  also, if the directory contents change, this will also break.

* removed strip.  breaks osx

* added directory tag so . isn't matched all over the place

* added real cache validation

* fixed build

* this file is copied from optdsk.lib or optcmd.lib

* install to ../HBIOS

* prerequisite verbosity

* diff soft failure and casefn speedup

* added lzsa

* added lzsa

* removed strip. breaks on osx

* added clobber

* added code to handle multiple platform rom builds with rom size override

* added align and 0x55 hex syntax

* default to hd64180

* added N8 capability

* added SBC_std.rom to default build

* added support for binary diff

* diff fixes

* clean, identical build.  font source generator emitted .align.  this does not match the windows build

* Upgrade NZCOM to latest

* Misc. Cleanup

* fixed expression parser bug : ~(1|2) returned 0xfe

* added diff build option

* Update Makefile

Makefile enhancement to better handle ncurses library from Bob Dunlop.

* Update sd.asm

Back out hack for uz80as now that Curt fixed it.

* Misc. Cleanup

* UNA Catchup

UNA support was lacking some of the more recent behavior changes.  This corrects most of it.

* Add github action for building RomWBW

* Bump Pre-release Version

* Update build.yml

Added "make clean" which will remove temporary files without removing final binary outputs.

* Update Makefile

Build all ROM variants by default in Linux/Mac build.

* Update Makefile

* Update Makefile

* Update Makefile

* Update Makefile

* Update Makefile

* Update Makefile

* Update Makefile

* Update Makefile

* Update Makefile

* Update for GitHub Build

Case issue in TASM includes showing up in GitHub build.  This should correct that.

* Added an gitignore files to exclude generated files

* Removed Tunes/clean.cmd and Tunes/ReadMe.txt - as make clean removes them

* Build.sh: marked as executable

chmod +x Build.sh

* Fix to HBIOS/build.sh

When adding files to rom disk, if files were missing, it would error out.

It appears the intent is to skip non-existing files.

Updated to log out correctly for missing files - and continue operation.

* Update Microsoft NASCOM BASIC.docx

Nascom manual, text version by Jan S (full name unknown)

* Fix issue with Apps/Tune not making

If dest directory does not exist, fails to make Apps

* Create ReadMe.txt

* Update Makefile

* Update Build.sh

* Make .gitignores for Tools/unix more specific

* cpmtools Update

Updated cpmtools applications (Windows only).  Removed hack in diskdefs that is no longer required.

* HBIOS Proxy Temp Stack Enhancement

Reuse the bounce buffer area as the temporary stack space required briefly in HBX_INVOKE when transitioning banks.  Increases size of temporary stack space to 64 bytes.

* Update ReadMe.txt

* HBIOS - clean up TMPSTK

* Update hbios.asm

Minor cosmetic changes.

* Build Process Updates

Minor udpates to build process to improve consistency between Windows and Mac/Linux builds.

* Update hbios.asm

Add improved interrupt protection to HBIOS PEEK, POKE, and BNKCPY functions.

* hbios - wrap hbx_bnkcpy

* hbios - adjust hbx_peek hbx_poke guards

* Update hbios.asm

Adjusted used of DI/EI for PEEK and POKE to regain a bit of INTSTK space.  Added code so that HB_INVBNK can be used as a flag indicating if HBIOS is active, $FF is inactive, anything else means active.

* Add HBIOS MuTex

* Initial Nascom basic ecb-vdu graphics

set and reset for 80x25b screen with 256 character mod

* Finalize Pre-release 34

Final support for FreeRTOS

* Update nascom.asm

Optimization, cleanup, tabs and white spaces

* IDE & PPIDE Cleanup

* Clean up

Make version include files common.

* Update Makefile

* Update Makefile

* Build Test

* Build Test

* Build Fixes

* Update nascom.asm

Cleanup

* Update nascom.asm

Optimization

* hbios - temp stack tweak

* Update hbios.asm

Comments on HBX_BUF usage.

* Update nascom.asm

Optimization

* Update nascom.asm

Setup ECB-VDU build option, remove debug code

* Update nascom.asm

Set default build. update initialization

* Update nascom.asm

Make CLS clear vdu screen

* Update nascom.asm

Fixup top screen line not showing

* Add SC131 Support

Also cleaned up some ReadMe files.

* HBIOS SCZ180 - remove mutex special files

* HBIOS SCZ180 - adjust mutex comment

* Misc. Cleanup

Includes some minor improvements to contents in some disk images.

* Delete FAT.COM

Changing case of FAT.COM extension to lowercase.

* Create FAT.com

Completing change of case in extension of FAT.com.

* Update Makefile

Remove ROM variants that just have the HBIOS MUTEX enabled.  Users can easily enable this in a custom build.

* Cleanup

Removed hack from Images Makefile.  Fixed use of DEFSERCFG in various places.

* GitHub CI Updates

Adds automation of build and release assets upon release.

* Prerelease 36

General cleanup

* Build Script Cleanups

* Config File Cleanups

* Update RomWBW Architecture

General refresh for v2.9.2

* Update vdu.asm

Removed a hack in VDU driver that has existed for 8 years.  :-)

* Fix CONSOLE Constant

Rename CIODEV_CONSOLE constant to CIO_CONSOLE because it is a unit code, not a device type code.

Retabify TastyBasic.

* Minor Bug Fixes

- Disk assignment edge case
- CP/M 3 accidental fall thru
- Cosmetic updates

* Update util.z80

* Documentation Cleanup

* Documentation Update

* Documentation Update

* Documentation Updates

* Documentation Updates

* Create Common.inc

* Documentation Updates

* Documentation Updates

* doc - a few random fixes

* Documentation Cleanup

* Fix IM 0 Build Error in ACIA

* Documentation Updates

* Documentation Cleanup

* Remove OSLDR

The OSLDR application was badly broken and almost impossible to fix with new expanded OS support.

* Bug Fixes

- Init RAM disk at boot under CP/M 3
- Fix ACR activation in TUNE

* FD Motor Timeout

- Made FDC motor timeout smaller and more consistent across different speed CPUs
- Added "boot" messaging to RTC

* Cleanup

* Cleanup

- Fix SuperZAP to work under NZCOM and ZPM3
- Finalize standard config files

* Minor Changes

- Slight change to ZAP configuration
- Added ZSDOS.ZRL to NZCOM image

* ZDE Upgrade

- Upgraded ZDE 1.6 -> 1.6a

* Config File Tuning

* Pre-release for Testing

* cfg - mutex consistent config language

* Bump to Version 3.0

* Update SD Card How-To

Thanks David!

* update ReadMe.md

Remove some odd `\`.

* Update ReadMe.txt

* Update ReadMe.md

* Update Generated Doc Files

* Improve XModem Startup

- Extended startup timeout for XM.COM so that it doesn't timeout so quickly while host is selecing a file to send.
- Updated SD Card How-To from David Reese.

* XModem Timing Refinements

* TMS Driver Z180 Improvements

- TMS driver udpated to insert Z180 I/O waitstates internally so other code can run at full speed.
- Updated How-To documents from David.
- Fixed TUNE app to properly restore Z180 I/O waitstates after manipulating them.

* CLRDIR and ZDE updates

- CLRDIR has been updated by Max Scane for CP/M 3 compatibility.
- A minor issue in the preconfigured ZDE VT100 terminal escape sequences was corrected.

* Fix Auto CRT Console Switch on CP/M 3

* Handle lack of RTC better

DSRTC driver now correctly returns an error if there is no RTC present.

* Minor RTC Updates

* Finalize v3.0.1

Cleanup release for v3.0

* New ROMLDR and INTRTC driver

- Refactored romldr.asm
- Added new periodic timer based RTC driver

* CP/M 3 Date Hack

- Hack to allow INTRTC to increment time without destroying the date

* Update romldr.asm

Work around minor Linux build inconsistency

* Update Apps for New Version

* Revert "Update Apps for New Version"

This reverts commit ad80432252.

* Revert "Update romldr.asm"

This reverts commit 4a9825cd57.

* Revert "CP/M 3 Date Hack"

This reverts commit 153b494e61.

* Revert "New ROMLDR and INTRTC driver"

This reverts commit d9bed4563e.

* Start v3.1 Development

* Update FDISK80.COM

Updated FDISK80 to allow reserving up to 256 slices.

* Update sd.asm

For Z180 CSIO, ensure that xmit is finished, before asserting CS for next transaction.

* Add RC2014 UART, Improve SD protocol fix

- RC2014 and related platforms will autodetect a UART at 0xA0 and 0xA8
- Ensure that CS fully brackets all SD I/O

* ROMLDR Improvements

.com files can now be started from CP/M and size of .com files has been reduced so they always fit.

* Update commit.yml

Run commit build in all branches

* Update commit.yml

Run commit build for master and dev branches

* Improved clock driver auto-detect/fallback

* SIO driver now CTC aware

The SIO driver can now use a CTC (if available) to provide much more flexible baud rate programming.

* CTC driver fine tuning

* Update xmdm125.asm

Fixed a small issue in core XM125 code that caused a file write error message to not be displayed when it should be.

* CF Card compatibility improvement

Older CF Cards did not reset IDE registers to defaults values when reset.  Implemented a work around.

* Update ACIA detection

ACIA should no longer be detected if there is also a UART module in the system.

* Handle CTC anomaly

Small update to accommodate CTC behavior that occurs when the CTC trigger is more than half the CTC clock.

* Update acia.asm

Updated ACIA detection to use primary ACIA port instead of phantom port.

* Update acia.asm

Fix bug in ACIA detection.

Thanks Alan!

* MacOS Build Improvement

Build script updated to improve compatibility with MacOS.

Credit to Fredrik Axtelius for this.

* HBIOS Makefile - use env vars for target

Allow build ROM targets to be restricted to just one platform thru use of ENV vars:

ROM_PLATFORM - if defined to a known platform, only this platform is build - defaults to std config
ROM_CONFIG - sets the desired platform config - defaults to std

if the above ENVs are not defined, builds all ROMs

* Added some more gitignores

* Whitespace changes (crlf)

* HBIOS: Force the assembly to fail for vdu drivers if function table count is not correct

* Whitespace: trailing whitespaces

* makefile: updated some make scripts to use  when calling subdir makefiles

* linux build: update to Build.sh fix for some platforms

The initialization of the Rom dat file used the pipe (|) operator to build an initial empty file.

But the pipe operator | may sometimes return a non-zero exit code for some linux platforms, if the
the streams are closed before dd has fully processed the stream.

This issue occured on a travis linux ubuntu image.

Solution was to change to redirection.

* Bump version

* Enhance CTC periodic timer

Add ability to use TIMER mode in CTC driver to generate priodic interrupts.

* HBIOS: Added support for sound drivers

New sound driver support with initial support for the SN76489 chip

New build configuration entry:
* SN76489ENABLE

Ports are currently locked in with:
* SN76489_PORT_LEFT       .EQU    $FC     ; PORTS FOR ACCESSING THE SN76489 CHIP (LEFT)
* SN76489_PORT_RIGHT      .EQU    $F8     ; PORTS FOR ACCESSING THE SN76489 CHIP (LEFT)

* Miscellaneous Cleanup

No functional changes.

Co-authored-by: curt mayer <curt@zen-room.org>
Co-authored-by: Wayne Warthen <wwarthen@gmail.com>
Co-authored-by: ed <linux@maidavale.org>
Co-authored-by: Dean Netherton <dnetherton@dius.com.au>
Co-authored-by: ed <ed@maidavale.org>
Co-authored-by: Phillip Stevens <phillip.stevens@gmail.com>
Co-authored-by: Dean Netherton <dean.netherton@gmail.com>
2020-04-24 06:17:22 +08:00

857 lines
15 KiB
Plaintext
Raw Blame History

This file contains invisible Unicode characters
This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
;
; Program: CLEANDIR
; Derivation: SAP 3.8 (see following history for authors)
; Derivation By: Richard Conn
; Version: 1.1
; Date: 28 November 1984
; Previous Versions: 1.0 (20 June 84)
;
; bug fix ;841201 Peter T Lyman
; Version 1.1P
;
; Search for ';841201' to locate the code
;
; CLEANDIR can and does wipe out the operating system
; (also known as a crash) whenever the maximum size of
; the directory (DRM) exceeds the available memory....
;
; Maybe that is a good feature, since you at least don't
; hurt the disk...
;
; However on my hard disk I have two platters with
; DRM equal to 2048.... In this case CLEANDIR crashes...
;
; The fix that I have added (I did this with an early version
; of SAP) gives you a choice.... If DRM is greater than
; the space available betwwen BUF and BDOS, you are given
; a choice with proceeding if the actual number of directory
; entries is less than or equal to the space available....
; If not you ABORT.....
;
; The down side risk of this modification is that if you
; proceed ("Y") when the actual number of files exceeds
; the space available, you lose all the directories entries
; which don't fit in the available space....
;
; With out the fix the system crashes and you cannot clean the
; directory... With the fix you can clean the directory, but
; you can lose files if you don't pay attention....
;
vers equ 11
z3env equ 0f400h
;
; SYSLIB and Z3LIB References
;
ext z3init,z3log
ext eprint,cout
ext codend
ext phlfdc ;841201
;
; Environment Definition
;
if z3env ne 0
;
; External ZCPR3 Environment Descriptor
;
jmp start
db 'Z3ENV' ;This is a ZCPR3 Utility
db 1 ;External Environment Descriptor
z3eadr:
dw z3env
start:
lhld z3eadr ;pt to ZCPR3 environment
;
else
;
; Internal ZCPR3 Environment Descriptor
;
MACLIB Z3BASE.LIB
MACLIB SYSENV.LIB
z3eadr:
jmp start
SYSENV
start:
lxi h,z3eadr ;pt to ZCPR3 environment
endif
;
; Start of Program -- Initialize ZCPR3 Environment
;
call z3init ;initialize the ZCPR3 Environment
; v3.8 SORT AND PACK CP/M DISK DIRECTORY - 10/16/83
;
; THIS PROGRAM READS THE DISK DIRECTORY TRACKS, SORTS THEM ALPHABETICALLY
; THEN REPLACES THEM ON THE DISK. ALL UNUSED OR ERASED AREAS ON THE DIR-
; ECTORY TRACK ARE REFORMATTED WITH CONTINUOUS 'E5' CHARACTERS. (THIS
; ERASES PREVIOUS FILE NAMES WHICH HAVE BEEN DEACTIVATED.) SORTING THE
; DIRECTORY IN THIS MANNER OFFERS MANY ADVANTAGES. SOME OF THEM ARE:
;
; 1) ALLOWS 'DIR' TO SHOW AN ALPHABETIZED LISTING
; 2) ELIMINATES POTENTIAL PROBLEMS WITH "UNERASE" PROGRAMS
; 3) SPEEDS UP ACCESS VIA 'SD' AND OTHER SPECIAL PROGRAMS
; 4) ASSISTS ON WORKING DIRECTLY ON THE DISK WITH 'DUU', ETC.
; 5) REMOVES FILES FROM THE DISK SOMEBODY ELSE COULD RECOVER
;
; - Notes by Irv Hoff W6FFC
;
; 1977 Written by L. E. Hughes. Modified extensively since by Bruce
; Ratoff, Keith Petersen, James Prest, Ron Fowler, Frank Gaude,
; Irv Hoff and likely others.
;
; 10/16/83 Now using a Shell-Metzner sort which speeds the sorting time
; considerably, especially on large directories. (SFK)
;
; 07/27/83 Shows an error flag for MP/M and CP/M+ both. Rewrites dir-
; tory even if previously sorted, to insure erased programs at
; v3.7 end of directory are properly cleared.
; - Irv Hoff
;
TRUE EQU 0FFH
FALSE EQU 0
;
BDOS EQU 5
CR EQU 0DH
DPBLEN EQU 15 ;SIZE OF CP/M2 DISK PARAMETER BLOCK
FCB EQU 5CH
FCB2 EQU 6CH
GETDSK EQU 25 ;BDOS "GET DISK #" FUNCTION
LF EQU 0AH
SELDRV EQU 14 ;SELECT DRIVE
;.....
;
;
; OBTAIN BIOS VECTORS
;
VECTRS:
JMP GETVEC
;
DS 53 ;ROOM FOR JUMP VECTORS
;
WBOOT EQU VECTRS+3 ;DO NOT CHANGE THESE EQUATES
CSTS EQU VECTRS+6
CI EQU VECTRS+9
CO EQU VECTRS+12
LO EQU VECTRS+15
PO EQU VECTRS+18
RI EQU VECTRS+21
HOME EQU VECTRS+24
SELDSK EQU VECTRS+27
SETTRK EQU VECTRS+30
SETSEC EQU VECTRS+33
SETDMA EQU VECTRS+36
READ EQU VECTRS+39
WRITE EQU VECTRS+42
LSTS EQU VECTRS+45 ;ONLY IN CP/M2
SECTRN EQU VECTRS+48 ;ONLY IN CP/M2
;
; GET BIOS VECTORS
;
GETVEC:
LXI D,WBOOT
LHLD 1
MVI B,53
CALL MOVE
;
; PROGRAM STARTS HERE
;
LXI H,0
DAD SP ;GET ADDRESS OF CP/M STACK
SHLD STACK ;STORE IT SO WE CAN GO BACK TO IT
CALL CODEND ;DETERMINE FREE SPACE
LXI D,80H ;ALLOW 80H BYTES FOR STACK
SHLD BUF ;SET BUFFER ADDRESS
SPHL ;SET TOP OF STACK
lda bdos+2 ;fetch bdos page ;841201
dcr a ; less one ;
lhld buf ;fetch buf pntr ;
sub h ;available space for dir ;
mvi h,0 ; ;
mov l,a ;number of pages available ;
dad h ;x2->number of sectors ;
dad h ;x2 ;
dad h ;x2->number of directory ;
; entries which will fit ;
shld maxdir ;save for later ;
XRA A ;SET NO REVERSE OF USER AREAS
STA REVERSE
CALL EPRINT ;PRINT MSG:
DB 'CLEANDIR, Version '
DB (vers/10)+'0','.',(vers mod 10)+'0','P' ;841201
DB 0
LDA FCB+1 ;CHECK FOR HELP REQUEST
CPI '/' ;ANY OPTION MEANS HELP
JZ HELP
CPI 'D' ;SELECT DESCENDING ORDER?
JZ DESC
LDA FCB2+1 ;CHECK FOR OPTION CHAR
CPI 'D' ;DESCENDING ORDER OF USER AREAS?
JNZ SAP
DESC:
MVI A,0FFH ;ENABLE REVERSE
STA REVERSE
JMP SAP
;
; PRINT HELP MESSAGE
;
HELP:
CALL EPRINT
DB CR,LF,'Syntax:'
DB CR,LF,' CLEANDIR dir: o'
DB CR,LF,'Options:'
DB CR,LF,' D - sort in Descending Order (users and files)'
DB CR,LF,'Note:'
DB CR,LF,' Only disk ref is used in dir: form'
DB 0
JMP EXIT1
;
; MAIN PROGRAM ROUTINE
;
SAP:
CALL SETUP
call ckdrsz ;check available memory space ;841201
CALL RDDIR
CALL CLEAN
CALL SORT
CALL PACK
CALL WRDIR
CALL EPRINT
DB 'Done',0
JMP EXIT
ckdrsz: lhld drm ;fetch max dir size ;841201
xchg ; ;
lhld maxdir ;fetch memory available for dir ;
call hlmde ;subtract ;
rnc ;return if room ;
call eprint ;else... ;
db lf,lf,lf,lf,lf,lf ;
db cr,lf,'Your maximum directory size is ',0 ;
lhld drm ;print max dir size ;
inx h ; ;
call phlfdc ; ;
call eprint ; ;
db ' directory entries.',0 ;
call eprint ; ;
db cr,lf,'your memory can only handle ',0 ;
lhld maxdir ;print space available ;
call phlfdc ; ;
call eprint ; ;
db ' directory entries.' ;
db cr,lf,lf,'IF.....your directory DOES NOT exceed ',0;
lhld maxdir ; ;
call phlfdc ; ;
call eprint ; ;
db ' directory entries,' ;
db cr,lf,' (Directory entries NOT Files)';
db cr,lf,' you may enter "Y" to proceed,' ;
db cr,lf,lf,'ELSE...any other key ABORTS.' ;
db cr,lf,lf,lf,lf,lf,lf,lf,lf,'..............> ',7,0;
ck1: mvi c,6 ;get input ;
mvi e,-1 ; ;
call bdos ; ;
cpi 0 ; ;
jz ck1 ; ;
ani 5fh ; ;
cpi 'Y' ; ;
jnz exit1 ; ;
lhld maxdir ; ;
shld drm ; ;
ret ; ;
; ;
hlmde: mov a,h ; ;
cmp d ; ;
rnz ; ;
mov a,l ; ;
cmp e ; ;
ret ; ;
;
; SUBROUTINES
;
;
CLEAN:
LXI H,0 ;I = 0
;
CLNLOP:
SHLD I
CALL INDEX ;HL = BUF + 16 * I
MOV A,M ;JUMP IF THIS IS A DELETED FILE
CPI 0E5H
JZ FILLE5
LXI D,12
DAD D ;HL = HL + 12
MOV A,M ;CHECK EXTENT FIELD
ORA A
JNZ CLBUMP ;SKIP IF NOT EXTENT ZERO
INX H ;POINT TO RECORD COUNT FIELD
INX H
MOV A,M ;GET S2 BYTE (EXTENDED RC)
ANI 0FH ; FOR CPM2, 0 FOR CPM1
MOV E,A
INX H
MOV A,M ;CHECK RECORD COUNT FIELD
ORA E
JNZ CLBUMP ;JUMP IF NON-ZERO
LHLD I ;CLEAR ALL 32 BYTES OF
CALL INDEX ; DIRECTORY ENTRY TO E5
INX H
MOV A,M ;GET FIRST CHAR OF FILENAME
DCX H ; WARD CHRISTENSONS CAT PGMS
CPI '-' ; HAVE DISKNAME OF ZERO LENGTH
JZ CLBUMP ; THAT START WITH '-', DON'T DELETE
CPI ' ' ; DISCAT USES DISKNAME OF ZERO LENGTH
JZ CLBUMP ; THAT STARTS WITH ' ', DON'T DELETE
;
FILLE5:
MVI C,32 ;NUMBER OF BYTES TO CLEAR
;
FILLOP:
MVI M,0E5H ;MAKE IT ALL E5'S
INX H
DCR C
JNZ FILLOP
;
CLBUMP:
LHLD DRM ;GET COUNT OF FILENAMES
INX H
XCHG
LHLD I ;OUR CURRENT COUNT
INX H
PUSH H
CALL SUBDE ;SUBTRACT
POP H
JC CLNLOP ;LOOP TILL ALL CLEANED
RET
;
DODIR:
STA WRFLAG
LHLD SYSTRK
CALL DOTRAK ;SET THE TRACK
LXI H,0
SHLD SECTOR
LHLD DRM ;NUMBER OF DIR ENTRIES
INX H ;RELATIVE TO 1
CALL ROTRHL ;DIVIDE BY 4
CALL ROTRHL ; TO GET SECTOR COUNT
SHLD DIRCNT
LHLD BUF
SHLD ADDR ;FOR DMA ADDRESS
;
DIRLOP:
LHLD SECTOR ;GET SECTORS PER TRACK
INX H
XCHG
LHLD SPT ;CURRENT SECTOR
CALL SUBDE ; SECTOR - SPT
XCHG
JNC NOTROV
;
; TRACK OVERFLOW, BUMP TO NEXT
;
LHLD TRACK
INX H
CALL DOTRAK
LXI H,1 ;REWIND SECTOR NUMBER
;
NOTROV:
CALL DOSEC ;SET CURRENT SECTOR
LHLD ADDR
MOV B,H ;SET UP DMA ADDRESS
MOV C,L
CALL SETDMA
LDA WRFLAG ;TIME TO FIGURE OUT
ORA A ; IF WE ARE READING
JNZ DWRT ; OR WRITING
;
;
; READ
;
CALL READ
ORA A ;TEST FLAGS ON READ
JNZ RERROR ;NZ=ERROR
JMP MORE ;GOOD READ, GO DO MORE
;
; TRACK AND SECTOR UPDATE ROUTINES
;
DOTRAK:
SHLD TRACK
MOV B,H
MOV C,L
CALL SETTRK
RET
DOSEC:
SHLD SECTOR
MOV B,H
MOV C,L
LHLD SECTBL
XCHG
DCX B
CALL SECTRN
MOV B,H
MOV C,L
CALL SETSEC
RET
;
; WRITE
;
DWRT:
MVI C,1 ;FOR CPM/2 DEBLOCKING BIOS'S
CALL WRITE
ORA A ;TEST FLAGS ON WRITE
JNZ WERROR ;NZ=BAD DIRECTORY WRITE
JMP MORE
;
; Exit Program
;
EXIT:
LDA NOBOOT ;SEE IF BOOT IS NEEDED
ORA A
JNZ EXIT1 ;FLAG IS SET IF ALREADY ALPHABETIZED
JMP 0000H ;A REWRITTEN DIRECTORY NEEDS A WARM BOOT
;
EXIT1:
LHLD STACK ;GET ADDRESS OF ORIGINAL CP/M STACK
SPHL ;RESET STACK ADDRESS
RET
;
INDEX:
DAD H
DAD H
DAD H
DAD H
DAD H
XCHG
LHLD BUF ;GET ADDRESS OF BUF
XCHG
DAD D
RET
;
; GOOD READ OR WRITE
;
MORE:
LHLD ADDR ;BUMP DMA ADRS FOR NEXT PASS
LXI D,80H
DAD D
SHLD ADDR
LHLD DIRCNT ;COUNTDOWN ENTRIES
DCX H
SHLD DIRCNT
MOV A,H ;TEST FOR ZERO LEFT
ORA L
JNZ DIRLOP ;LOOP TILL ZERO
;
;
; DIRECTORY I/O DONE, RESET DMA ADDRESS
;
LXI B,80H
CALL SETDMA
RET
;
; MOVE UTILITY SUBROUTINE
;
MOVE:
MOV A,M
STAX D
INX H
INX D
DCR B
JNZ MOVE
RET
;
; PACK DIRECTORY
;
PACK:
LXI H,0 ;I = 0
;
PACK1:
SHLD I
CALL INDEX ;HL = BUF + 16 * I
LXI D,9
DAD D ;HL = HL + 9
MOV A,M ;JUMP IF FILETYPE NOT 'X$$'
SUI '0' ; WHERE 0.LE.X.LE.9
JC PACK2
CPI 10
JNC PACK2
STA J
INX H
MOV A,M
CPI '$'
JNZ PACK2
INX H
MOV A,M
CPI '$'
JNZ PACK2
INX H ;SET EXTENT NUMBER TO X
LDA J
MOV M,A
DCX H ;SET FILETYPE TO '$$$'
MVI M,'$'
DCX H
MVI M,'$'
DCX H
MVI M,'$'
;
PACK2:
LHLD I ;I = I + 1
INX H
XCHG
LHLD DRM
INX H
XCHG
PUSH H
CALL SUBDE
POP H ;LOOP UNTIL I > DRM
JC PACK1
RET
;
; READ AND WRITE DIRECTORY ROUTINES
;
RDDIR:
CALL EPRINT
DB ' --> Reading, ',0
XRA A
STA NOBOOT ;ZERO THE FLAG
JMP DODIR ;ZERO THE WRITE FLAG FOR NOW
;
; COME HERE IF WE GET A READ ERROR
;
RERROR:
CALL EPRINT ;PRINT:
DB ' READ ERROR - No Change Made',0
JMP EXIT
;
; DIVIDE HL BY 2
;
ROTRHL:
ORA A ;CLEAR CARRY
MOV A,H
RAR
MOV H,A
MOV A,L
RAR
MOV L,A
RET
;
; SETUP FOR SELECTING DRIVE AND LOADING DISK PARM BLOCK
;
SETUP:
LXI D,FCB
CALL Z3LOG ;LOG INTO DISK SPECIFIED BY USER
MVI C,GETDSK ;OTHERWISE GET CURRENT DEFAULT DRIVE
CALL BDOS ;SO QUERY 'BDOS' FOR DRIVE
MOV C,A ;PREP FOR OBTAINING DPB
CALL EPRINT
DB CR,LF,' Disk ',0
MOV A,C ;GET DISK NUMBER
ADI 'A' ;CONVERT TO ASCII
CALL COUT
CALL SELDSK
;
; GET CP/M 2.2 DPB DATA
;
MOV E,M
INX H
MOV D,M
INX H
XCHG
SHLD SECTBL
XCHG
LXI D,8 ;OFFSET TO DPB WITHIN HEADER
DAD D ;RETURNED BY SELDSK IN CPM2
MOV A,M ;GET ADRS OF DPB
INX H
MOV H,M
MOV L,A
LXI D,DPB ;POINT TO DEST: OUR DPB
MVI B,DPBLEN
CALL MOVE
RET
;
; SORT THE DIRECTORY
;
SORT:
CALL EPRINT
DB 'Sorting (',0
LDA REVERSE ;INDICATE ASC OR DSC
ORA A ;0=ASC
JZ SORTASC
CALL EPRINT
DB 'Descending',0
JMP SORTDO
SORTASC:
CALL EPRINT
DB 'Ascending',0
;
; SHELL-METZNER SORT
;
SORTDO:
CALL EPRINT
DB ' Order), ',0
LHLD I
SHLD SNUMRECW
LHLD BUF
SHLD SSTADR
PUSH H ; AND SAVE IT
LXI H,32
SHLD SRECLEN
PUSH H ; AND SAVE IT
;
; NOW DIVIDE # OF FIELDS BY 2
;
DIVIDE:
LHLD SNUMRECW ;GET VALUE
CALL ROTRHL
SHLD SNUMRECW ;SAVE RESULT
MOV A,L ;IF SNUMRECW<>0
ORA H ; THEN
JNZ NOTDONE ; NOT DONE
;
; ALL FIELDS SORTED
;
POP B ;CLEAN UP STACK
POP D
RET
;
NOTDONE:
XCHG
LHLD I
MOV A,L
SUB E
MOV L,A
MOV A,H
SBB D
MOV H,A
SHLD SRECLEN
LXI H,1
SHLD SSORTV1
SHLD SSTADR
DCR L
POP B
PUSH B
NDONE1:
DAD D
DCX B
MOV A,B
ORA C
JNZ NDONE1
SHLD SSORTV2
XCHG
POP B
POP H
PUSH H
PUSH B
NDONE2:
SHLD SSORTV4
SHLD SSORTV3
XCHG
DAD D
XCHG
COMPARE:
POP B
PUSH B
COMPAR1:
LDAX D
ANI 7FH
PUSH B
MOV C,A
MOV A,M
ANI 7FH
MOV B,A
MOV A,C
SUB B
POP B
JNZ NOTEQU
INX H
INX D
DCX B
MOV A,B
ORA C
JNZ COMPAR1
JMP NOSWITCH
;
; THE CONDITION AT NOTEQU: HAS TO
; BE CHANGED FOR DESCENDING SORT -- IF REVERSE=0, JNC TO NOSWITCH, ELSE
; JC TO NOSWITCH
;
NOTEQU:
PUSH PSW ;SAVE CONDITION
LDAX D ;GET (DE)
CPI 0E5H ;IF ERASED, SELECT ASCENDING
JZ ASCENDING
MOV A,M ;GET (HL)
CPI 0E5H ;IF ERASED, SELECT ASCENDING
JZ ASCENDING
LDA REVERSE ;DESCENDING SORT?
ORA A ;0=NO
JZ ASCENDING
POP PSW ;GET CONDITION FOR DESCENDING SORT
JC NOSWITCH
JMP SWITCH
ASCENDING:
POP PSW ;GET CONDITION FOR ASCENDING SORT
JNC NOSWITCH
SWITCH:
PUSH B
MOV B,M
LDAX D
MOV M,A
MOV A,B
STAX D
INX H
INX D
POP B
DCX B
MOV A,B
ORA C
JNZ SWITCH
LHLD SNUMRECW
MOV A,H
CMA
MOV D,A
MOV A,L
CMA
MOV E,A
LHLD SSORTV1
DAD D
JNC NOSWITCH
INX H
SHLD SSORTV1
LHLD SSORTV3
XCHG
LHLD SSORTV2
MOV A,E
SUB L
MOV L,A
MOV A,D
SBB H
MOV H,A
SHLD SSORTV3
JMP COMPARE
;
NOSWITCH:
LHLD SSTADR
INX H
SHLD SSTADR
SHLD SSORTV1
XCHG
LHLD SRECLEN
MOV A,L
SUB E
MOV A,H
SBB D
JC DIVIDE
LHLD SSORTV4
POP D
PUSH D
DAD D
XCHG
LHLD SSORTV2
XCHG
JMP NDONE2
;
; UTILITY SUBTRACTION SUBROUTINE...
; HL=HL-DE
;
SUBDE:
MOV A,L
SUB E
MOV L,A
MOV A,H
SBB D
MOV H,A
RET
;.....
;
;
WRDIR:
CALL EPRINT
DB 'Writing, ',0
MVI A,1
JMP DODIR
;
; COME HERE IF WE GET A WRITE ERROR
;
WERROR:
CALL EPRINT ;PRINT:
DB ' WRITE ERROR - Directory Left in UNKNOWN Condition',0
JMP EXIT
;
; DATA AREA
;
ADDR:
DS 2
BUF:
DS 2
DIRCNT:
DS 2
I:
DS 2
J:
DS 2
MAPPTR:
DS 2
maxdir:
ds 2 ;841201
NOBOOT:
DS 1
NOSWAP:
DS 1
REVERSE:
DS 1
SECTBL:
DS 2
SECTOR:
DS 2
TRACK:
DS 2
WRFLAG:
DS 1
SRECLEN:
DS 2
SSTADR:
DS 2
SSORTV1:
DS 2
SSORTV2:
DS 2
SSORTV3:
DS 2
SSORTV4:
DS 2
SNUMRECW:
DS 2
;
; DISK PARAMETER BLOCK:
;
DPB:
SPT:
DS 2
BSH:
DS 1
BLM:
DS 1
EXM:
DS 1
DSM:
DS 2
DRM:
DS 2
AL0:
DS 1
AL1:
DS 1
CKS:
DS 2
SYSTRK:
DS 2
;
STACK:
DS 2 ;SPACE FOR OLD STACK ADDRESS
;
END
;