Can now change device ID in browse mode with keyboard 8,9,0,- and F8..F11

Maximum rom images is now 7 (down from 8)
This commit is contained in:
penfold42 2018-07-21 13:07:14 +10:00
parent 1090e509a1
commit 709809281f
5 changed files with 32 additions and 19 deletions

View file

@ -35,9 +35,11 @@ extern "C"
#define PNG_WIDTH 320 #define PNG_WIDTH 320
#define PNG_HEIGHT 200 #define PNG_HEIGHT 200
extern void GlobalSetDeviceID(u8 id);
unsigned char FileBrowser::LSTBuffer[FileBrowser::LSTBuffer_size]; unsigned char FileBrowser::LSTBuffer[FileBrowser::LSTBuffer_size];
const unsigned FileBrowser::SwapKeys[30] = const unsigned FileBrowser::SwapKeys[33] =
{ {
KEY_F1, KEY_KP1, KEY_1, KEY_F1, KEY_KP1, KEY_1,
KEY_F2, KEY_KP2, KEY_2, KEY_F2, KEY_KP2, KEY_2,
@ -48,7 +50,8 @@ const unsigned FileBrowser::SwapKeys[30] =
KEY_F7, KEY_KP7, KEY_7, KEY_F7, KEY_KP7, KEY_7,
KEY_F8, KEY_KP8, KEY_8, KEY_F8, KEY_KP8, KEY_8,
KEY_F9, KEY_KP9, KEY_9, KEY_F9, KEY_KP9, KEY_9,
KEY_F10, KEY_KP0, KEY_0 KEY_F10, KEY_KP0, KEY_0,
KEY_F11, KEY_KPMINUS, KEY_MINUS
}; };
static const u32 palette[] = static const u32 palette[] =
@ -370,7 +373,7 @@ FileBrowser::BrowsableList::Entry* FileBrowser::BrowsableList::FindEntry(const c
return 0; return 0;
} }
FileBrowser::FileBrowser(DiskCaddy* diskCaddy, ROMs* roms, unsigned deviceID, bool displayPNGIcons, ScreenBase* screenMain, ScreenBase* screenLCD, float scrollHighlightRate) FileBrowser::FileBrowser(DiskCaddy* diskCaddy, ROMs* roms, u8* deviceID, bool displayPNGIcons, ScreenBase* screenMain, ScreenBase* screenLCD, float scrollHighlightRate)
: state(State_Folders) : state(State_Folders)
, diskCaddy(diskCaddy) , diskCaddy(diskCaddy)
, selectionsMade(false) , selectionsMade(false)
@ -895,18 +898,25 @@ void FileBrowser::UpdateInputFolders()
else else
{ {
unsigned keySetIndex; unsigned keySetIndex;
for (keySetIndex = 0; keySetIndex < ROMs::MAX_ROMS; ++keySetIndex) for (keySetIndex = 0; keySetIndex < 11; ++keySetIndex)
{ {
unsigned keySetIndexBase = keySetIndex * 3; unsigned keySetIndexBase = keySetIndex * 3;
if (keyboard->KeyPressed(FileBrowser::SwapKeys[keySetIndexBase]) || keyboard->KeyPressed(FileBrowser::SwapKeys[keySetIndexBase + 1]) || keyboard->KeyPressed(FileBrowser::SwapKeys[keySetIndexBase + 2])) if (keyboard->KeyPressed(FileBrowser::SwapKeys[keySetIndexBase])
|| keyboard->KeyPressed(FileBrowser::SwapKeys[keySetIndexBase + 1])
|| keyboard->KeyPressed(FileBrowser::SwapKeys[keySetIndexBase + 2]))
{ {
if (roms->ROMValid[keySetIndex]) if ( (keySetIndex < ROMs::MAX_ROMS) && (roms->ROMValid[keySetIndex]) )
{ {
roms->currentROMIndex = keySetIndex; roms->currentROMIndex = keySetIndex;
roms->lastManualSelectedROMIndex = keySetIndex; roms->lastManualSelectedROMIndex = keySetIndex;
DEBUG_LOG("Swap ROM %d %s\r\n", keySetIndex, roms->ROMNames[keySetIndex]); DEBUG_LOG("Swap ROM %d %s\r\n", keySetIndex, roms->ROMNames[keySetIndex]);
ShowDeviceAndROM(); ShowDeviceAndROM();
} }
else if ( (keySetIndex >= 7) && (keySetIndex <= 10 ) )
{
GlobalSetDeviceID( keySetIndex+1 );
ShowDeviceAndROM();
}
} }
} }
@ -1028,7 +1038,7 @@ void FileBrowser::ShowDeviceAndROM()
u32 x = 0; // 43 * 8 u32 x = 0; // 43 * 8
u32 y = screenMain->ScaleY(STATUS_BAR_POSITION_Y) - 20; u32 y = screenMain->ScaleY(STATUS_BAR_POSITION_Y) - 20;
snprintf(buffer, 256, "Device %d %s\r\n", deviceID, roms->ROMNames[roms->currentROMIndex]); snprintf(buffer, 256, "Device %2d %s\r\n", *deviceID, roms->ROMNames[roms->currentROMIndex]);
screenMain->PrintText(false, x, y, buffer, textColour, bgColour); screenMain->PrintText(false, x, y, buffer, textColour, bgColour);
} }

View file

@ -165,7 +165,7 @@ public:
std::vector<BrowsableListView> views; std::vector<BrowsableListView> views;
}; };
FileBrowser(DiskCaddy* diskCaddy, ROMs* roms, unsigned deviceID, bool displayPNGIcons, ScreenBase* screenMain, ScreenBase* screenLCD, float scrollHighlightRate); FileBrowser(DiskCaddy* diskCaddy, ROMs* roms, u8* deviceID, bool displayPNGIcons, ScreenBase* screenMain, ScreenBase* screenLCD, float scrollHighlightRate);
void AutoSelectImage(const char* image); void AutoSelectImage(const char* image);
void DisplayRoot(); void DisplayRoot();
@ -187,8 +187,6 @@ public:
void ClearScreen(); void ClearScreen();
void SetDeviceID(u8 id) { deviceID = id; }
static const long int LSTBuffer_size = 1024 * 8; static const long int LSTBuffer_size = 1024 * 8;
static unsigned char LSTBuffer[]; static unsigned char LSTBuffer[];
@ -229,7 +227,7 @@ private:
bool selectionsMade; bool selectionsMade;
const char* lastSelectionName; const char* lastSelectionName;
ROMs* roms; ROMs* roms;
unsigned deviceID; u8* deviceID;
bool displayPNGIcons; bool displayPNGIcons;
BrowsableList caddySelections; BrowsableList caddySelections;

View file

@ -173,7 +173,7 @@ bool InputMappings::CheckKeyboardBrowseMode()
else else
{ {
unsigned index; unsigned index;
for (index = 0; index < 10; ++index) for (index = 0; index < 11; ++index)
{ {
unsigned keySetIndexBase = index * 3; unsigned keySetIndexBase = index * 3;
if (keyboard->KeyHeld(FileBrowser::SwapKeys[keySetIndexBase]) || keyboard->KeyHeld(FileBrowser::SwapKeys[keySetIndexBase + 1]) || keyboard->KeyHeld(FileBrowser::SwapKeys[keySetIndexBase + 2])) if (keyboard->KeyHeld(FileBrowser::SwapKeys[keySetIndexBase]) || keyboard->KeyHeld(FileBrowser::SwapKeys[keySetIndexBase + 1]) || keyboard->KeyHeld(FileBrowser::SwapKeys[keySetIndexBase + 2]))

View file

@ -34,7 +34,7 @@ public:
void ResetCurrentROMIndex(); void ResetCurrentROMIndex();
static const int ROM_SIZE = 16384; static const int ROM_SIZE = 16384;
static const int MAX_ROMS = 8; static const int MAX_ROMS = 7;
unsigned char ROMImages[MAX_ROMS][ROM_SIZE]; unsigned char ROMImages[MAX_ROMS][ROM_SIZE];
char ROMNames[MAX_ROMS][256]; char ROMNames[MAX_ROMS][256];

View file

@ -639,8 +639,15 @@ static void PlaySoundDMA()
static void SetVIAsDeviceID(u8 id) static void SetVIAsDeviceID(u8 id)
{ {
if (id & 1) pi1541.VIA[0].GetPortB()->SetInput(VIAPORTPINS_DEVSEL0, true); pi1541.VIA[0].GetPortB()->SetInput(VIAPORTPINS_DEVSEL0, id & 1);
if (id & 2) pi1541.VIA[0].GetPortB()->SetInput(VIAPORTPINS_DEVSEL1, true); pi1541.VIA[0].GetPortB()->SetInput(VIAPORTPINS_DEVSEL1, id & 2);
}
void GlobalSetDeviceID(u8 id)
{
deviceID = id;
m_IEC_Commands.SetDeviceId(id);
SetVIAsDeviceID(id);
} }
static void CheckAutoMountImage(EXIT_TYPE reset_reason , FileBrowser* fileBrowser) static void CheckAutoMountImage(EXIT_TYPE reset_reason , FileBrowser* fileBrowser)
@ -677,7 +684,7 @@ void emulator()
roms.lastManualSelectedROMIndex = 0; roms.lastManualSelectedROMIndex = 0;
diskCaddy.SetScreen(&screen, screenLCD); diskCaddy.SetScreen(&screen, screenLCD);
fileBrowser = new FileBrowser(&diskCaddy, &roms, deviceID, options.DisplayPNGIcons(), &screen, screenLCD, options.ScrollHighlightRate()); fileBrowser = new FileBrowser(&diskCaddy, &roms, &deviceID, options.DisplayPNGIcons(), &screen, screenLCD, options.ScrollHighlightRate());
fileBrowser->DisplayRoot(); fileBrowser->DisplayRoot();
pi1541.Initialise(); pi1541.Initialise();
@ -788,10 +795,8 @@ void emulator()
fileBrowser->FolderChanged(); fileBrowser->FolderChanged();
break; break;
case IEC_Commands::DEVICEID_CHANGED: case IEC_Commands::DEVICEID_CHANGED:
deviceID = m_IEC_Commands.GetDeviceId(); GlobalSetDeviceID( m_IEC_Commands.GetDeviceId() );
fileBrowser->SetDeviceID(deviceID);
fileBrowser->ShowDeviceAndROM(); fileBrowser->ShowDeviceAndROM();
SetVIAsDeviceID(deviceID); // Let the emilated VIA know
break; break;
default: default:
break; break;