Disk magnet management moved from mmio.h to disk.c

This commit is contained in:
tudnai 2020-06-06 21:09:00 -07:00
parent bfc010901c
commit 23bc243a1b
3 changed files with 17 additions and 14 deletions

View File

@ -79,6 +79,18 @@ void disk_phase() {
}
void disk_phase_on( uint8_t currentMagnet ) {
disk.phase.magnet |= 1 << currentMagnet;
disk_phase();
}
void disk_phase_off( uint8_t currentMagnet ) {
disk.phase.magnet &= ~(1 << currentMagnet);
disk_phase();
}
uint8_t disk_read() {
dbgPrintf("io_DISK_READ (S%u)\n", 6);
disk.clk_last_access = m6502.clktime;

View File

@ -64,6 +64,8 @@ extern int diskAccelerator_speed;
//extern const unsigned long long clk_diskAcceleratorTimeout;
extern void disk_phase(void);
extern void disk_phase_on( uint8_t currentMagnet );
extern void disk_phase_off( uint8_t currentMagnet );
extern uint8_t disk_read(void);

View File

@ -549,8 +549,6 @@ INLINE uint8_t ioRead( uint16_t addr ) {
// if (outdev) fprintf(outdev, "ioRead:%04X\n", addr);
// printf("ioRead:%04X (PC:%04X)\n", addr, m6502.PC);
uint8_t currentMagnet = 0;
// TODO: This is for checking only, should be either removed or the entire ioRead should based on binary search, whatever is faster
if ( addr == io_KBD ) {
// clk_6502_per_frm_max = clk_6502_per_frm_max > 32768 ? clk_6502_per_frm_max - 32768 : 0; // ECO Mode!
@ -710,24 +708,15 @@ INLINE uint8_t ioRead( uint16_t addr ) {
case (uint8_t)io_DISK_PHASE1_OFF + SLOT6:
case (uint8_t)io_DISK_PHASE2_OFF + SLOT6:
case (uint8_t)io_DISK_PHASE3_OFF + SLOT6:
currentMagnet = (addr - io_DISK_PHASE0_OFF - SLOT6) / 2;
disk.phase.magnet &= ~(1 << currentMagnet);
// printf("io_DISK_PHASE%u_OFF (S%u, ps:%X) ", currentMagnet, 6, disk.phase.magnet);
disk_phase();
disk_phase_off( (addr - io_DISK_PHASE0_OFF - SLOT6) / 2 );
return 0;
case (uint8_t)io_DISK_PHASE0_ON + SLOT6:
case (uint8_t)io_DISK_PHASE1_ON + SLOT6:
case (uint8_t)io_DISK_PHASE2_ON + SLOT6:
case (uint8_t)io_DISK_PHASE3_ON + SLOT6: {
currentMagnet = (addr - io_DISK_PHASE0_ON - SLOT6) / 2;
disk.phase.magnet |= 1 << currentMagnet;
// printf("io_DISK_PHASE%u_ON (S%u, ps:%X) ", currentMagnet, 6, disk.phase.magnet);
disk_phase();
case (uint8_t)io_DISK_PHASE3_ON + SLOT6:
disk_phase_on( (addr - io_DISK_PHASE0_ON - SLOT6) / 2 );
return 0;
}
case (uint8_t)io_DISK_POWER_OFF + SLOT6:
dbgPrintf2("io_DISK_POWER_OFF (S%u)\n", 6);