AltairZ80: IBC MCC: Clean up HDC.

This commit is contained in:
Howard M. Harte 2023-06-18 16:12:30 -07:00
parent a7dc7567c5
commit 3acc69fbd2

View file

@ -49,7 +49,8 @@
#define IBC_HDC_MAX_DRIVES 4 /* Maximum number of drives supported */ #define IBC_HDC_MAX_DRIVES 4 /* Maximum number of drives supported */
#define IBC_HDC_MAX_SECLEN 256 /* Maximum of 256 bytes per sector */ #define IBC_HDC_MAX_SECLEN 256 /* Maximum of 256 bytes per sector */
#define IBC_HDC_FORMAT_FILL_BYTE 0xe5 /* Real controller uses 0, but we #define IBC_HDC_FORMAT_FILL_BYTE 0xe5 /* Real controller uses 0, but we
choose 0xe5 so the disk shows up as blank under CP/M. */ choose 0xe5 so the disk shows
up as blank under CP/M. */
#define IBC_HDC_MAX_CYLS 1024 #define IBC_HDC_MAX_CYLS 1024
#define IBC_HDC_MAX_HEADS 16 #define IBC_HDC_MAX_HEADS 16
#define IBC_HDC_MAX_SPT 256 #define IBC_HDC_MAX_SPT 256
@ -67,6 +68,7 @@
#define TF_TRKH 7 #define TF_TRKH 7
#define TF_FIFO 8 #define TF_FIFO 8
#define IBC_HDC_STATUS_BUSY (1 << 4)
#define IBC_HDC_STATUS_ERROR (1 << 0) #define IBC_HDC_STATUS_ERROR (1 << 0)
#define IBC_HDC_ERROR_ID_NOT_FOUND (1 << 4) #define IBC_HDC_ERROR_ID_NOT_FOUND (1 << 4)
@ -536,7 +538,7 @@ static t_stat IBC_HDC_doCommand(void)
IBC_HDC_DRIVE_INFO* pDrive = &ibc_hdc_info->drive[ibc_hdc_info->sel_drive]; IBC_HDC_DRIVE_INFO* pDrive = &ibc_hdc_info->drive[ibc_hdc_info->sel_drive];
uint8 cmd = ibc_hdc_info->taskfile[TF_CMD] & IBC_HDC_CMD_MASK; uint8 cmd = ibc_hdc_info->taskfile[TF_CMD] & IBC_HDC_CMD_MASK;
pDrive->cur_cyl = ibc_hdc_info->taskfile[TF_TRKH] << 8; pDrive->cur_cyl = (uint16)ibc_hdc_info->taskfile[TF_TRKH] << 8;
pDrive->cur_cyl |= ibc_hdc_info->taskfile[TF_TRKL]; pDrive->cur_cyl |= ibc_hdc_info->taskfile[TF_TRKL];
pDrive->xfr_nsects = ibc_hdc_info->taskfile[TF_NSEC]; pDrive->xfr_nsects = ibc_hdc_info->taskfile[TF_NSEC];
pDrive->cur_head = ibc_hdc_info->taskfile[TF_HEAD]; pDrive->cur_head = ibc_hdc_info->taskfile[TF_HEAD];
@ -569,7 +571,7 @@ static t_stat IBC_HDC_doCommand(void)
if (IBC_HDC_Validate_CHSN(pDrive) != SCPE_OK) break; if (IBC_HDC_Validate_CHSN(pDrive) != SCPE_OK) break;
/* Calculate file offset */ /* Calculate file offset */
file_offset = (pDrive->cur_cyl * pDrive->nheads * pDrive->nsectors); /* Full cylinders */ file_offset = (pDrive->cur_cyl * pDrive->nheads * pDrive->nsectors); /* Full cylinders */
file_offset += (pDrive->cur_head * pDrive->nsectors); /* Add full heads */ file_offset += (pDrive->cur_head * pDrive->nsectors); /* Add full heads */
file_offset += (pDrive->cur_sect); /* Add sectors for current request */ file_offset += (pDrive->cur_sect); /* Add sectors for current request */
file_offset *= pDrive->sectsize; /* Convert #sectors to byte offset */ file_offset *= pDrive->sectsize; /* Convert #sectors to byte offset */