ROM and deviceID cleanups

start implementing a-z
This commit is contained in:
penfold42 2018-07-31 09:41:50 +10:00
parent b001959483
commit b809e3e70b
2 changed files with 77 additions and 86 deletions

View file

@ -386,8 +386,7 @@ FileBrowser::FileBrowser(DiskCaddy* diskCaddy, ROMs* roms, u8* deviceID, bool di
, roms(roms) , roms(roms)
, deviceID(deviceID) , deviceID(deviceID)
, displayPNGIcons(displayPNGIcons) , displayPNGIcons(displayPNGIcons)
, buttonChangedDevice(false) , buttonChangedROMDevice(false)
, buttonSelectROM(false)
, screenMain(screenMain) , screenMain(screenMain)
, screenLCD(screenLCD) , screenLCD(screenLCD)
, scrollHighlightRate(scrollHighlightRate) , scrollHighlightRate(scrollHighlightRate)
@ -823,54 +822,51 @@ void FileBrowser::UpdateInputFolders()
Keyboard* keyboard = Keyboard::Instance(); Keyboard* keyboard = Keyboard::Instance();
InputMappings* inputMappings = InputMappings::Instance(); InputMappings* inputMappings = InputMappings::Instance();
buttonChangedROMDevice = false;
if (IEC_Bus::GetInputButtonHeld(4)) if (IEC_Bus::GetInputButtonHeld(4))
{ {
if (inputMappings->BrowseSelect()) if (inputMappings->BrowseSelect())
{ {
GlobalSetDeviceID(8); SelectROMOrDevice(7); // == device 8
ShowDeviceAndROM(); buttonChangedROMDevice = true;
buttonChangedDevice = true;
} }
else if (inputMappings->BrowseUp()) else if (inputMappings->BrowseUp())
{ {
GlobalSetDeviceID(9); SelectROMOrDevice(8); // == device 9
ShowDeviceAndROM(); buttonChangedROMDevice = true;
buttonChangedDevice = true;
} }
else if (inputMappings->BrowseDown()) else if (inputMappings->BrowseDown())
{ {
GlobalSetDeviceID(10); SelectROMOrDevice(9); // == device 10
ShowDeviceAndROM(); buttonChangedROMDevice = true;
buttonChangedDevice = true;
} }
else if (inputMappings->BrowseBack()) else if (inputMappings->BrowseBack())
{ {
GlobalSetDeviceID(11); SelectROMOrDevice(10); // == device 11
ShowDeviceAndROM(); buttonChangedROMDevice = true;
buttonChangedDevice = true;
} }
} }
else if (IEC_Bus::GetInputButtonHeld(0)) else if (IEC_Bus::GetInputButtonHeld(0))
{ {
if (inputMappings->BrowseUp()) if (inputMappings->BrowseUp())
{ {
SelectROM(0); SelectROMOrDevice(0);
buttonSelectROM = true; buttonChangedROMDevice = true;
} }
else if (inputMappings->BrowseDown()) else if (inputMappings->BrowseDown())
{ {
SelectROM(1); SelectROMOrDevice(1);
buttonSelectROM = true; buttonChangedROMDevice = true;
} }
else if (inputMappings->BrowseBack()) else if (inputMappings->BrowseBack())
{ {
SelectROM(2); SelectROMOrDevice(2);
buttonSelectROM = true; buttonChangedROMDevice = true;
} }
else if (inputMappings->BrowseInsert()) else if (inputMappings->BrowseInsert())
{ {
SelectROM(3); SelectROMOrDevice(3);
buttonSelectROM = true; buttonChangedROMDevice = true;
} }
} }
else else
@ -880,13 +876,7 @@ void FileBrowser::UpdateInputFolders()
//u32 numberOfEntriesMinus1 = folder.entries.size() - 1; //u32 numberOfEntriesMinus1 = folder.entries.size() - 1;
bool dirty = false; bool dirty = false;
if (inputMappings->BrowseSelect()) if (inputMappings->BrowseSelect() && !buttonChangedROMDevice )
{
if (buttonSelectROM)
{
buttonSelectROM = false;
}
else
{ {
FileBrowser::BrowsableList::Entry* current = folder.current; FileBrowser::BrowsableList::Entry* current = folder.current;
if (current) if (current)
@ -934,7 +924,6 @@ void FileBrowser::UpdateInputFolders()
} }
} }
} }
}
else if (inputMappings->BrowseDone()) else if (inputMappings->BrowseDone())
{ {
selectionsMade = FillCaddyWithSelections(); selectionsMade = FillCaddyWithSelections();
@ -954,13 +943,7 @@ void FileBrowser::UpdateInputFolders()
ClearSelections(); ClearSelections();
dirty = true; dirty = true;
} }
else if (inputMappings->BrowseInsert()) else if (inputMappings->BrowseInsert() && !buttonChangedROMDevice )
{
if (buttonChangedDevice)
{
buttonChangedDevice = false;
}
else
{ {
FileBrowser::BrowsableList::Entry* current = folder.current; FileBrowser::BrowsableList::Entry* current = folder.current;
if (current) if (current)
@ -968,7 +951,6 @@ void FileBrowser::UpdateInputFolders()
dirty = AddToCaddy(current); dirty = AddToCaddy(current);
} }
} }
}
else if (inputMappings->BrowseNewD64()) else if (inputMappings->BrowseNewD64())
{ {
char newFileName[64]; char newFileName[64];
@ -997,6 +979,7 @@ void FileBrowser::UpdateInputFolders()
} }
else else
{ {
// check for number keys for ROM and Drive Number changes
unsigned keySetIndex; unsigned keySetIndex;
for (keySetIndex = 0; keySetIndex < 11; ++keySetIndex) for (keySetIndex = 0; keySetIndex < 11; ++keySetIndex)
{ {
@ -1004,15 +987,16 @@ void FileBrowser::UpdateInputFolders()
if (keyboard->KeyPressed(FileBrowser::SwapKeys[keySetIndexBase]) if (keyboard->KeyPressed(FileBrowser::SwapKeys[keySetIndexBase])
|| keyboard->KeyPressed(FileBrowser::SwapKeys[keySetIndexBase + 1]) || keyboard->KeyPressed(FileBrowser::SwapKeys[keySetIndexBase + 1])
|| keyboard->KeyPressed(FileBrowser::SwapKeys[keySetIndexBase + 2])) || keyboard->KeyPressed(FileBrowser::SwapKeys[keySetIndexBase + 2]))
{ SelectROMOrDevice(keySetIndex);
if (SelectROM(keySetIndex))
{
} }
else if ( (keySetIndex >= 7) && (keySetIndex <= 10 ) )
// check for keys a-z
if ( keyboard->KeyAnyHeld() && !keyboard->KeyEitherAlt() )
for (unsigned i=KEY_A; i<=KEY_Z; i++)
{ {
GlobalSetDeviceID( keySetIndex+1 ); if (keyboard->KeyPressed( i ))
ShowDeviceAndROM(); {
} char ascKey = i-KEY_A+'A';
} }
} }
@ -1033,7 +1017,9 @@ void FileBrowser::UpdateInputFolders()
} }
} }
bool FileBrowser::SelectROM(u32 index) bool FileBrowser::SelectROMOrDevice(u32 index)
// 0-6 select ROM image
// 7-10 change deviceID to 8-11
{ {
if ((index < ROMs::MAX_ROMS) && (roms->ROMValid[index])) if ((index < ROMs::MAX_ROMS) && (roms->ROMValid[index]))
{ {
@ -1043,6 +1029,12 @@ bool FileBrowser::SelectROM(u32 index)
ShowDeviceAndROM(); ShowDeviceAndROM();
return true; return true;
} }
else if ( (index >= 7) && (index <= 10 ) )
{
GlobalSetDeviceID( index+1 );
ShowDeviceAndROM();
return true;
}
return false; return false;
} }

View file

@ -217,7 +217,7 @@ private:
bool CheckForPNG(const char* filename, FILINFO& filIcon); bool CheckForPNG(const char* filename, FILINFO& filIcon);
void DisplayPNG(); void DisplayPNG();
bool SelectROM(u32 index); bool SelectROMOrDevice(u32 index);
enum State enum State
{ {
@ -232,8 +232,7 @@ private:
ROMs* roms; ROMs* roms;
u8* deviceID; u8* deviceID;
bool displayPNGIcons; bool displayPNGIcons;
bool buttonChangedDevice; bool buttonChangedROMDevice;
bool buttonSelectROM;
BrowsableList caddySelections; BrowsableList caddySelections;