plasmo wrote:
Thanks for the DPB description.
I have not made as much progress as I've hoped. I start off wanting the disk format to be compatible with existing CP/M-80 and DOS/65 format so I can transfer CPM65's files across. That approach ran into problem with SYS being 512 and I don't know how to accommodate that in disk parameter header. I also don't know how to work with directory mask (DIRMSK) parameter. The first byte of Block Allocation Table appears to be a mask of some sort, I also not sure whether it needs to modified or not.
SYS is a L/M/H value of the reserved logical sectors (i.e. 256 bytes) at the beginning of a disc. These sectors are not counted by BDOS, i.e. first usable sector on a disc is always $000000. If your system needs 512 sectors a 512 bytes, SYS = $000200, if it's 512 sectors a 256 bytes, SYS = $000100.
DIRMSK marks the directory blocks in BAT permanently as occupied, thus preventing BDOS using them for file storage. It is actually the first byte of the BAT and just copied into it before BAT is rebuild, e.g. after a disc change.
plasmo wrote:
My latest attempt is to preserve the original disk parameter header of your BIOS and use just one drive, the original drive F is now drive A; Floppy disks are removed. I also preserved the original memory allocation for CCP, BDOS, and BIOS which are $D800, $DC00, and $E400, respectively. I only have 1K RAM from $E400 to $E7FF, so I put DMA, DIRBF, and SCSIBUF starting from $D000, which will cause problem if a big program is loading in CPM65, but I'll figure that out later. However, it still is not working. By "not working", I meant it did print the CPM65 sign-on message embedded in BOOT routine and access the CF disk briefly but it didn't display a CPM prompt.
You should place DIRBF and SCSIBUF above BIOS to prevent programs accidentially overwriting those. DMA can be placed where you want data loaded or saved by BDOS, e.g. to load file (see CCP)
Code:
LDFIL1 JSR SETDMA ;SET DMA=TPA
LDFIL5 LDX #RDSEQ ;READ A SECTOR
JSR BDOS
BCS LDFIL4
INC DMAV+1 ;INC DMA PAGE
BNE LDFIL5 ;branch allways
LDFIL4 CMP #EOF ;WAS IT A EOF?
BNE LDFIL2
LDFIL6 JSR RESDMA ;RESET DMA
CLC
RTS
plasmo wrote:
I have a few questions:
1. 6502's carry flag is used to signal whether a routine has executed successfully or not. The CONST, CONIN, and CONOUT routines are ROM calls so I do not know the protocol for indicating data is available in CONST or whether carry flag needs to be cleared for CONIN and CONOUT.
2. CP/M-80 has a BIOS routine for DMA. I did not see that in CPM65 list of BIOS. So is DMAV set somehow and I can use DMAV for disk operation?
3. The CP/M-80 track and sector seem to be replaced with 3-byte SECS. I'm guessing SECS is like sector, SECS+1 is like track, and SECS+2 is like head. If sectors and tracks are power of 2, it may be as simple as a shift right one bit of the entire 3-byte SECS and the resulting values become the Logical Block Address?
4. at the end of the BIOS BOOT routine, there is a JSR to BDOS with regX set to $E, followed by JSR to BDOS with regX set to 0. What does JSR to BDOS with X=$E do?
1. Carry set indeed signals an error condition in BDOS and also BIOS calls. It never needs to be reset. However, I was a bit inconsequential. Some calls, where errors are impossible by design, do not report a valid Carry, e.g. CONST, CONIN, CONOUT. I definetily have to write some documentation...
2. Right, BDOS does not handle DMA. The DMA is a fixed vector in page $00 (DMAV = $FE). CCP uses it and all user programs which need disc I/O
3. Right SECS/SECS+1/SECS+2 is a 24 bit LBA with fixed sector size of 256 bytes. So yes, the BIOS has to translate is in real disc parameters. The calculation of SECS is handled in BDOS and uses the DPH.
4. BDOS_$0E logs in the current drive defined in DEFDRV. It sets the DPH-values and resets some flags. BDOS_$00 is a warm boot resetting some BDOS vectors and parameters and calling the CCP
Regarding your BIOS code, this is where most changes have to be made, because this is the interface layer to your specific system. I suggest to replace my code by as many of your system monitor functions as possible. CONST, CONIN,CONOUT,LIST should be easy. For the disc ops, there is more to do
SELDSK sets DRIVE and selects the correct DPH
READ reads the 256 byte block defined in SECS to the memory location defined in DMAV ($00FE). So here the translation from logical sectors to physical sectors, tracks, side etc. has to be made including a blocking/deblocking for sector sizes other than 256 bytes.
WRITE same for writing a sector
SELDSK, READ and WRITE set carry if an error occurs
It seems you got it mostly right already
I will be travelling for the next 2 weeks, so I might be a little slow to react
Dietrich