Welcome, Guest. Please login or register.

Author Topic: Minimig Floppy Emu Bugfix???  (Read 789 times)

Description:

0 Members and 1 Guest are viewing this topic.

Offline TobiFlexTopic starter

  • Jr. Member
  • **
  • Join Date: Jan 2006
  • Posts: 53
Minimig Floppy Emu Bugfix???
« on: November 14, 2007, 11:05:24 PM »
I'm not sure but I think there is a Bug in the Pic-Source "main.c".
The FIFO length with KS1.3 is 0x1CBE and with KS2.0 is 0x1A9E. If you change the ReadTrack funktion of main.c you can handle both.
I use the DE1 Board for the Test. But the speed of the PIC in a original Minimig and the SPIHOST on the DE1 Board are different.
Thats why: can somebody test this code with a PIC?

Viele Grüße
TobiFlex


Code: [Select]


/*read a track from disk*/
void ReadTrack(struct adfTYPE *drive)
{
unsigned char sector_cnt,sector,c1,c2;

/*search track*/
putchar((drive->track/100)+48);
putchar(((drive->track/10)%10)+48);
putchar((drive->track%10)+48);

/*check if we are accessing new track or first track*/
if((drive->track!=drive->trackprev) || (drive->track==0))
{/*track step or track 0, start at beginning of track*/
drive->trackprev=drive->track;

sector=0;
file.cluster=drive->cache[drive->track];
file.sec=drive->track*11;
}
else if(drive->clusteroffset!=0)
{/*same track, start at next sector in track*/
sector=drive->sectoroffset;
file.cluster=drive->clusteroffset;
file.sec=(drive->track*11)+sector;
}
else
{/*???? --> start at beginning of track*/
sector=0;
file.cluster=drive->cache[drive->track];
file.sec=drive->track*11;
}

drive->clusteroffset=0;

sector_cnt=11;
do
{
/*read sector*/
SSPCON1=0x30;
FileRead2(&file);
SSPCON1=0x31;

/*we are now going to access FPGA*/
EnableFpga();

/*check if FPGA is still asking for data*/
c1=SPI(0);
c2=SPI(0);

/*send sector if fpga is still asking for data*/
if(c1&0x02)
{
SectorToFpga(sector,drive->track);
putchar('.');
}

/*we are done accessing FPGA*/
DisableFpga();

/*point to next sector*/
if(++sector>=11)
{
sector=0;
file.cluster=drive->cache[drive->track];
file.sec=drive->track*11;
}
else
{
SSPCON1=0x30;
FileNextSector2(&file);
SSPCON1=0x31;
}

/*remember second cluster of this track read, skip last sector*/
/*if(drive->clusteroffset==0 && sector!=10)*/
if(drive->clusteroffset==0)
{
drive->sectoroffset=sector;
drive->clusteroffset=file.cluster;
}

/*if track done, exit*/
if(!(c1&0x02))
break;
}
while(--sector_cnt);

putchar('O');
putchar('K');
putchar(0x0d);

/*fill floppy FIFO KS2.0=0x1A9E  KS1.3=0x1CBE */
while(c1&0x02)
{
EnableFpga();
c1=SPI(0xaa);
c2=SPI(0xaa);
if(c1&0x02)
{
SPI(0xaa);
SPI(0xaa);
}
DisableFpga();
}
}