If you select a PRG file using the Pi's browser then it will mount it into a virtual D64 so fast loaders can be used.

Note: FB64 will still use SD2IEC style loading directlyfrom the Pi's file system.
This commit is contained in:
Stephen White 2019-12-28 15:27:28 +11:00
parent 67c82503e6
commit 1ca78e3383
4 changed files with 57 additions and 0 deletions

View file

@ -182,6 +182,9 @@ bool DiskCaddy::Insert(const FILINFO* fileInfo, bool readOnly)
case DiskImage::T64:
success = InsertT64(fileInfo, (unsigned char*)DiskImage::readBuffer, bytesRead, readOnly);
break;
case DiskImage::PRG:
success = InsertPRG(fileInfo, (unsigned char*)DiskImage::readBuffer, bytesRead, readOnly);
break;
default:
success = false;
break;
@ -289,6 +292,20 @@ bool DiskCaddy::InsertT64(const FILINFO* fileInfo, unsigned char* diskImageData,
return false;
}
bool DiskCaddy::InsertPRG(const FILINFO* fileInfo, unsigned char* diskImageData, unsigned size, bool readOnly)
{
DiskImage* diskImage = new DiskImage();
if (diskImage->OpenPRG(fileInfo, diskImageData, size))
{
diskImage->SetReadOnly(readOnly);
disks.push_back(diskImage);
selectedIndex = disks.size() - 1;
return true;
}
delete diskImage;
return false;
}
void DiskCaddy::Display()
{
unsigned numberOfImages = GetNumberOfImages();

View file

@ -107,6 +107,7 @@ private:
bool InsertNBZ(const FILINFO* fileInfo, unsigned char* diskImageData, unsigned size, bool readOnly);
bool InsertD81(const FILINFO* fileInfo, unsigned char* diskImageData, unsigned size, bool readOnly);
bool InsertT64(const FILINFO* fileInfo, unsigned char* diskImageData, unsigned size, bool readOnly);
bool InsertPRG(const FILINFO* fileInfo, unsigned char* diskImageData, unsigned size, bool readOnly);
void ShowSelectedImage(u32 index);

View file

@ -176,6 +176,7 @@ void DiskImage::Close()
memset(tracks, 0x55, sizeof(tracks));
break;
default:
memset(tracks, 0x55, sizeof(tracks));
break;
}
memset(trackLengths, 0, sizeof(trackLengths));
@ -1295,6 +1296,40 @@ void DiskImage::CloseT64()
attachedImageSize = 0;
}
bool DiskImage::OpenPRG(const FILINFO* fileInfo, unsigned char* diskImage, unsigned size)
{
bool success = false;
Close();
this->fileInfo = fileInfo;
attachedImageSize = size;
unsigned char* newDiskImage = (unsigned char*)malloc(READBUFFER_SIZE);
if (newDiskImage)
{
unsigned length = DiskImage::CreateNewDiskInRAM(fileInfo->fname, "00", newDiskImage);
if (length)
{
bool addFileSuccess = AddFileToRAMD64(newDiskImage, fileInfo->fname, diskImage, size);
if (addFileSuccess && OpenD64(fileInfo, newDiskImage, length))
{
success = true;
DEBUG_LOG("Success\r\n");
diskType = PRG;
}
}
free(newDiskImage);
}
return success;
}
bool DiskImage::GetDecodedSector(u32 track, u32 sector, u8* buffer)
{
if (track > 0)
@ -1327,6 +1362,8 @@ DiskImage::DiskType DiskImage::GetDiskImageTypeViaExtention(const char* diskImag
return LST;
else if (toupper((char)ext[1]) == 'D' && ext[2] == '8' && ext[3] == '1')
return D81;
else if (toupper((char)ext[1]) == 'P' && toupper((char)ext[2]) == 'R' && toupper((char)ext[3]) == 'G')
return PRG;
}
return NONE;
}

View file

@ -63,6 +63,7 @@ public:
D71,
D81,
T64,
PRG,
RAW
};
@ -77,6 +78,7 @@ public:
bool OpenD71(const FILINFO* fileInfo, unsigned char* diskImage, unsigned size);
bool OpenD81(const FILINFO* fileInfo, unsigned char* diskImage, unsigned size);
bool OpenT64(const FILINFO* fileInfo, unsigned char* diskImage, unsigned size);
bool OpenPRG(const FILINFO* fileInfo, unsigned char* diskImage, unsigned size);
void Close();