2018-12-31 10:05:17 +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)
|
2019-08-31 11:26:23 +00:00
|
|
|
#if not defined(EXPERIMENTALZERO)
|
2018-12-31 10:05:17 +00:00
|
|
|
, screen(0)
|
2019-08-31 11:26:23 +00:00
|
|
|
#endif
|
2019-09-21 15:24:09 +00:00
|
|
|
, screenLCD(0)
|
2018-12-31 10:05:17 +00:00
|
|
|
{
|
|
|
|
}
|
2019-09-21 15:24:09 +00:00
|
|
|
void SetScreen(Screen* screen, ScreenBase* screenLCD)
|
|
|
|
{
|
|
|
|
#if not defined(EXPERIMENTALZERO)
|
|
|
|
this->screen = screen;
|
2019-08-31 11:26:23 +00:00
|
|
|
#endif
|
2019-09-21 15:24:09 +00:00
|
|
|
this->screenLCD = screenLCD;
|
|
|
|
}
|
2018-12-31 10:05:17 +00:00
|
|
|
|
|
|
|
bool Empty();
|
|
|
|
|
|
|
|
bool Insert(const FILINFO* fileInfo, bool readOnly);
|
|
|
|
|
|
|
|
DiskImage* GetCurrentDisk()
|
|
|
|
{
|
2019-09-21 15:24:09 +00:00
|
|
|
#if defined(EXPERIMENTALZERO)
|
|
|
|
Update();
|
|
|
|
#endif
|
2018-12-31 10:05:17 +00:00
|
|
|
if (selectedIndex < disks.size())
|
|
|
|
return &disks[selectedIndex];
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
DiskImage* NextDisk()
|
|
|
|
{
|
|
|
|
selectedIndex = (selectedIndex + 1) % (u32)disks.size();
|
2019-09-21 15:24:09 +00:00
|
|
|
auto ret = GetCurrentDisk();
|
2018-12-31 10:05:17 +00:00
|
|
|
return GetCurrentDisk();
|
|
|
|
}
|
|
|
|
|
|
|
|
DiskImage* PrevDisk()
|
|
|
|
{
|
2019-08-31 11:26:23 +00:00
|
|
|
if (selectedIndex == 0u)
|
|
|
|
selectedIndex += (u32)disks.size()-1;
|
|
|
|
else
|
|
|
|
--selectedIndex;
|
|
|
|
|
2018-12-31 10:05:17 +00:00
|
|
|
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);
|
|
|
|
bool InsertD81(const FILINFO* fileInfo, unsigned char* diskImageData, unsigned size, bool readOnly);
|
|
|
|
|
|
|
|
void ShowSelectedImage(u32 index);
|
|
|
|
|
|
|
|
std::vector<DiskImage> disks;
|
|
|
|
u32 selectedIndex;
|
|
|
|
u32 oldCaddyIndex;
|
2019-08-31 11:26:23 +00:00
|
|
|
#if not defined(EXPERIMENTALZERO)
|
2018-12-31 10:05:17 +00:00
|
|
|
ScreenBase* screen;
|
2019-08-31 11:26:23 +00:00
|
|
|
#endif
|
2019-09-21 15:24:09 +00:00
|
|
|
ScreenBase* screenLCD;
|
2018-12-31 10:05:17 +00:00
|
|
|
};
|
|
|
|
|
2018-05-20 04:53:34 +00:00
|
|
|
#endif
|