\ The Rest is Silence 03Sep83map************************************************************* ************************************************************* *** *** *** Please direct all questions, comments, and *** *** miscellaneous personal abuse to: *** *** *** *** Henry Laxen or Michael Perry *** *** 1259 Cornell Avenue 1125 Bancroft Way *** *** Berkeley, California Berkeley, California *** *** 94706 94702 *** *** *** *** (415) 525-8582 (415) 644-3421 *** *** *** ************************************************************* ************************************************************* \ Load Screen for BIOS disk interface 08Oct83mapVOCABULARY DIRECT ONLY FORTH ALSO DIRECT ALSO DEFINITIONS 1 6 +THRU \ variables 28Sep83map2 CONSTANT #DRIVES VARIABLE DRIVE VARIABLE TRACK VARIABLE RECORD : /DRIVE create #drives 2* allot does> drive @ 2* + ; /DRIVE REC/TRK /DRIVE TRK/DRV /DRIVE REC/DRV /DRIVE BLK/DRV /DRIVE DPH : XLT (S -- translation-table-address ) DPH @ @ ; \ BIOS calls 08Oct83map: HOME (S -- ) 0 8 BIOS DROP ; : SETTRK (S track -- ) 10 BIOS DROP ; : SETSEC (S sector -- ) 11 BIOS DROP ; : SETDMA (S address -- ) 12 BIOS DROP ; : READ (S -- error ) 0 13 BIOS DISK-ERROR ! ; : WRITE (S -- error ) 0 14 BIOS DISK-ERROR ! ; LABEL INDIRECT E DCR 0 D MVI 1 LHLD D DAD D DAD D DAD PCHL CODE SELDSK (S drive -- DPH ) H POP B PUSH L C MOV H B MOV 9 E MVI INDIRECT CALL B POP HPUSH JMP C; \ translation 08Oct83mapLABEL INDIR D PUSH 45 D LXI 1 LHLD D DAD D POP PCHL CODE TRANS (S rec1 table -- rec2 ) D POP H POP B PUSH L C MOV H B MOV INDIR CALL B POP HPUSH JMP C; DEFER TRANSLATE (S record1 table -- record2 ) ' TRANS IS TRANSLATE \ ' DROP IS TRANSLATE \ DPB decoding 08Oct83map: DECODE (S DPH -- ) DUP DPH ! 10 + @ ( DPB ) LENGTH REC/TRK ! 1+ COUNT ( BLM ) 1+ ( rec/group ) SWAP 1+ LENGTH 1+ ( group/drv ) ROT * ( rec/drv in file area ) SWAP 6 + @ ( res. tracks ) REC/TRK @ * + REC/DRV ! REC/DRV @ REC/TRK @ / TRK/DRV ! REC/DRV @ REC/BLK / BLK/DRV ! ; : SET-DRV (S drive -- ) DUP SELDSK DUP 0= ABORT" Bad Drive" SWAP DRIVE ! DECODE ; 4 C@ SET-DRV ( default to current drive ) \ set record 08Oct83map: SET-RECORD (S record -- ) DUP RECORD ! XLT TRANSLATE SETSEC ; : SET-TRACK (S track -- ) DUP TRACK ! SETTRK ; : ACCESS (S record# -- ) REC/TRK @ /MOD DUP TRK/DRV @ >= ABORT" Out of range" SET-TRACK SET-RECORD ; : +RECORD (S -- ) RECORD @ 1+ DUP REC/TRK @ = IF DROP 0 TRACK @ 1+ DUP TRK/DRV @ = IF DROP 0 DRIVE @ 1+ SET-DRV THEN SET-TRACK THEN SET-RECORD ; \ read write 12Oct83map: BLOCK-READ (S address block# -- ) REC/BLK * ACCESS REC/BLK 0 DO DUP SET-DMA B/REC + READ +RECORD LOOP DROP ; : BLOCK-WRITE (S address block# -- ) REC/BLK * ACCESS REC/BLK 0 DO DUP SET-DMA B/REC + WRITE +RECORD LOOP DROP ; : DIRECT-IO (S -- ) SAVE-BUFFERS ['] BLOCK-READ IS READ-BLOCK ['] BLOCK-WRITE IS WRITE-BLOCK ; \ Load Screen for BIOS disk interface 08Oct83mapDIRECT contains the direct bios track and sector disk i/o routines. \ variables 28Sep83mapChange #DRIVES for your system. DRIVE current drive. TRACK current track. RECORD current 'sector'. /DRIVE defining word for arrays of drive parameters. "per drive" REC/TRK records per track. TRK/DRV tracks per drive. REC/DRV records per drive. BLK/DRV blocks per drive. DPH address of the Disk Parameter Header for this drive. XLT address of the 'sector' translation table for this drive. \ BIOS calls 12Oct83mapHOME recalibrate disk head. SETTRK set logical track. SETSEC set logical 'sector'. SETDMA set data address. READ perform read. WRITE perform write. INDIRECT subroutine for SELDSK. SELDSK select drive, leave address of DPH. \ translation 12Oct83mapINDIR subroutine for TRANS. TRANS translate record number using given table. TRANSLATE is an execution vector. Set it to TRANS for CP/M skewing. Set it to DROP for no skewing. \ DPB decoding 12Oct83mapDECODE uses the DPH to find the DPB ( Disk Parameter Block ) and initializes all /drive variables accordingly. SET-DRV select drive, and decode its DPB. Address 4 contains the currently logged in drive, in CP/M-80. \ set record 12Oct83mapSET-RECORD set record number for next read or write. SET-TRACK set track number for next read or write. ACCESS set record and track numbers for next read or write. +RECORD advance record and track numbers for next read or write \ read write 12Oct83mapBLOCK-READ read a block. BLOCK-WRITE write a block. DIRECT-IO set BLOCK to use direct track and sector I/O.