2018-05-20 04:53:34 +00:00
|
|
|
// Pi1541 - A Commodore 1541 disk drive emulator
|
|
|
|
// Copyright(C) 2018 Stephen White
|
|
|
|
//
|
|
|
|
// This file is part of Pi1541.
|
|
|
|
//
|
|
|
|
// Pi1541 is free software : you can redistribute it and/or modify
|
|
|
|
// it under the terms of the GNU General Public License as published by
|
|
|
|
// the Free Software Foundation, either version 3 of the License, or
|
|
|
|
// (at your option) any later version.
|
|
|
|
//
|
|
|
|
// Pi1541 is distributed in the hope that it will be useful,
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
// GNU General Public License for more details.
|
|
|
|
//
|
|
|
|
// You should have received a copy of the GNU General Public License
|
|
|
|
// along with Pi1541. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
|
|
|
#ifndef DISKCADDY_H
|
|
|
|
#define DISKCADDY_H
|
|
|
|
|
|
|
|
#include <vector>
|
|
|
|
#include "DiskImage.h"
|
|
|
|
#include "Screen.h"
|
|
|
|
|
|
|
|
class DiskCaddy
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
DiskCaddy()
|
|
|
|
: selectedIndex(0)
|
|
|
|
, screen(0)
|
2018-06-03 08:11:58 +00:00
|
|
|
, screenLCD(0)
|
2018-05-20 04:53:34 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2018-06-03 08:11:58 +00:00
|
|
|
void SetScreen(Screen* screen, ScreenBase* screenLCD) { this->screen = screen; this->screenLCD = screenLCD; }
|
2018-05-20 04:53:34 +00:00
|
|
|
|
2018-06-12 09:17:00 +00:00
|
|
|
bool Empty();
|
2018-05-20 04:53:34 +00:00
|
|
|
|
|
|
|
bool Insert(const FILINFO* fileInfo, bool readOnly);
|
|
|
|
|
|
|
|
DiskImage* GetCurrentDisk()
|
|
|
|
{
|
|
|
|
if (selectedIndex < disks.size())
|
|
|
|
return &disks[selectedIndex];
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
DiskImage* NextDisk()
|
|
|
|
{
|
|
|
|
selectedIndex = (selectedIndex + 1) % (u32)disks.size();
|
|
|
|
return GetCurrentDisk();
|
|
|
|
}
|
|
|
|
|
|
|
|
DiskImage* PrevDisk()
|
|
|
|
{
|
|
|
|
selectedIndex = (selectedIndex - 1) % (u32)disks.size();
|
|
|
|
return GetCurrentDisk();
|
|
|
|
}
|
|
|
|
|
|
|
|
u32 GetNumberOfImages() const { return disks.size(); }
|
|
|
|
u32 GetSelectedIndex() const { return selectedIndex; }
|
|
|
|
|
|
|
|
DiskImage* GetImage(unsigned index) { return &disks[index]; }
|
|
|
|
DiskImage* SelectImage(unsigned index)
|
|
|
|
{
|
|
|
|
if (selectedIndex != index && index < disks.size())
|
|
|
|
{
|
|
|
|
selectedIndex = index;
|
|
|
|
return GetCurrentDisk();
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
DiskImage* SelectFirstImage()
|
|
|
|
{
|
|
|
|
if (disks.size())
|
|
|
|
{
|
|
|
|
selectedIndex = 0;
|
|
|
|
return GetCurrentDisk();
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
void Display();
|
|
|
|
bool Update();
|
|
|
|
|
|
|
|
private:
|
|
|
|
bool InsertD64(const FILINFO* fileInfo, unsigned char* diskImageData, unsigned size, bool readOnly);
|
|
|
|
bool InsertG64(const FILINFO* fileInfo, unsigned char* diskImageData, unsigned size, bool readOnly);
|
|
|
|
bool InsertNIB(const FILINFO* fileInfo, unsigned char* diskImageData, unsigned size, bool readOnly);
|
|
|
|
bool InsertNBZ(const FILINFO* fileInfo, unsigned char* diskImageData, unsigned size, bool readOnly);
|
|
|
|
|
|
|
|
void ShowSelectedImage(u32 index);
|
|
|
|
|
|
|
|
std::vector<DiskImage> disks;
|
|
|
|
u32 selectedIndex;
|
|
|
|
u32 oldCaddyIndex;
|
|
|
|
|
|
|
|
Screen* screen;
|
2018-06-03 08:11:58 +00:00
|
|
|
ScreenBase* screenLCD;
|
2018-05-20 04:53:34 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|