Merge pull request #57 from penfold42/cleanup

Browser oled, add '<' for readonly files + cleanups
This commit is contained in:
Stephen White 2018-08-02 12:21:56 +10:00 committed by GitHub
commit 0d64664cc0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 35 additions and 33 deletions

View File

@ -88,8 +88,8 @@ void FileBrowser::BrowsableListView::RefreshLine(u32 entryIndex, u32 x, u32 y, b
RGBA BkColour = RGBA(0, 0, 0, 0xFF); //palette[VIC2_COLOUR_INDEX_BLUE]; RGBA BkColour = RGBA(0, 0, 0, 0xFF); //palette[VIC2_COLOUR_INDEX_BLUE];
u32 columnsMax = columns; u32 columnsMax = columns;
if (columnsMax > sizeof(buffer1)) if (columnsMax > sizeof(buffer1)-1)
columnsMax = sizeof(buffer1); columnsMax = sizeof(buffer1)-1;
if (entryIndex < list->entries.size()) if (entryIndex < list->entries.size())
{ {
@ -102,10 +102,17 @@ void FileBrowser::BrowsableListView::RefreshLine(u32 entryIndex, u32 x, u32 y, b
} }
else else
{ {
char ROstring[8] = { 0 };
if (entry->filImage.fattrib & AM_RDO)
strncpy (ROstring, "<", 8);
if (entry->caddyIndex != -1) if (entry->caddyIndex != -1)
snprintf(buffer2, 256, "%d>%s", entry->caddyIndex, entry->filImage.fname); snprintf(buffer2, 256, "%d>%s%s"
, entry->caddyIndex
, entry->filImage.fname
, ROstring
);
else else
snprintf(buffer2, 256, "%s", entry->filImage.fname); snprintf(buffer2, 256, "%s%s", entry->filImage.fname, ROstring);
} }
} }
else else
@ -150,7 +157,7 @@ void FileBrowser::BrowsableListView::RefreshLine(u32 entryIndex, u32 x, u32 y, b
} }
else else
{ {
memset(buffer1, ' ', 80); memset(buffer1, ' ', columnsMax);
screen->PrintText(false, x, y, buffer1, BkColour, BkColour); screen->PrintText(false, x, y, buffer1, BkColour, BkColour);
} }
} }
@ -196,10 +203,17 @@ void FileBrowser::BrowsableListView::RefreshHighlightScroll()
} }
else else
{ {
char ROstring[8] = { 0 };
if (entry->filImage.fattrib & AM_RDO)
strncpy (ROstring, "<", 8);
if (entry->caddyIndex != -1) if (entry->caddyIndex != -1)
snprintf(buffer2, 256, "%d>%s", entry->caddyIndex, entry->filImage.fname); snprintf(buffer2, 256, "%d>%s%s"
, entry->caddyIndex
, entry->filImage.fname
, ROstring
);
else else
snprintf(buffer2, 256, "%s", entry->filImage.fname); snprintf(buffer2, 256, "%s%s", entry->filImage.fname, ROstring);
} }
} }
else else
@ -514,7 +528,7 @@ void FileBrowser::FolderChanged()
void FileBrowser::DisplayRoot() void FileBrowser::DisplayRoot()
{ {
f_chdir("\\1541"); f_chdir("/1541");
FolderChanged(); FolderChanged();
} }

View File

@ -1100,9 +1100,6 @@ void IEC_Commands::New(void)
{ {
FILINFO filInfo; FILINFO filInfo;
if(!(strstr(filenameNew, ".d64") || strstr(filenameNew, ".D64")))
strcat(filenameNew, ".d64");
int ret = CreateD64(filenameNew, ID, true); int ret = CreateD64(filenameNew, ID, true);
if (ret==0) if (ret==0)

View File

@ -635,17 +635,12 @@ static void PlaySoundDMA()
write32(DMA0_BASE + DMA_CS, DMA_ACTIVE); write32(DMA0_BASE + DMA_CS, DMA_ACTIVE);
} }
static void SetVIAsDeviceID(u8 id)
{
pi1541.VIA[0].GetPortB()->SetInput(VIAPORTPINS_DEVSEL0, id & 1);
pi1541.VIA[0].GetPortB()->SetInput(VIAPORTPINS_DEVSEL1, id & 2);
}
void GlobalSetDeviceID(u8 id) void GlobalSetDeviceID(u8 id)
{ {
deviceID = id; deviceID = id;
m_IEC_Commands.SetDeviceId(id); m_IEC_Commands.SetDeviceId(id);
SetVIAsDeviceID(id); pi1541.VIA[0].GetPortB()->SetInput(VIAPORTPINS_DEVSEL0, id & 1);
pi1541.VIA[0].GetPortB()->SetInput(VIAPORTPINS_DEVSEL1, id & 2);
} }
void CheckAutoMountImage(EXIT_TYPE reset_reason , FileBrowser* fileBrowser) void CheckAutoMountImage(EXIT_TYPE reset_reason , FileBrowser* fileBrowser)
@ -736,17 +731,14 @@ void emulator()
CheckAutoMountImage(EXIT_UNKNOWN, fileBrowser); CheckAutoMountImage(EXIT_UNKNOWN, fileBrowser);
break; break;
case IEC_Commands::NONE: case IEC_Commands::NONE:
{ fileBrowser->Update();
fileBrowser->Update();
// Check selections made via FileBrowser // Check selections made via FileBrowser
if (fileBrowser->SelectionsMade()) if (fileBrowser->SelectionsMade())
emulating = BeginEmulating(fileBrowser, fileBrowser->LastSelectionName()); emulating = BeginEmulating(fileBrowser, fileBrowser->LastSelectionName());
}
break; break;
case IEC_Commands::IMAGE_SELECTED: case IEC_Commands::IMAGE_SELECTED:
{ // Check selections made via IEC commands (like fb64)
// Check selections made via FileBrowser
fileBrowserSelectedName = m_IEC_Commands.GetNameOfImageSelected(); fileBrowserSelectedName = m_IEC_Commands.GetNameOfImageSelected();
@ -768,8 +760,10 @@ void emulator()
DEBUG_LOG("IEC mounting %s\r\n", filInfoSelected->fname); DEBUG_LOG("IEC mounting %s\r\n", filInfoSelected->fname);
bool readOnly = (filInfoSelected->fattrib & AM_RDO) != 0; bool readOnly = (filInfoSelected->fattrib & AM_RDO) != 0;
if (diskCaddy.Insert(filInfoSelected, readOnly)) emulating = BeginEmulating(fileBrowser, filInfoSelected->fname); if (diskCaddy.Insert(filInfoSelected, readOnly))
else fileBrowserSelectedName = 0; emulating = BeginEmulating(fileBrowser, filInfoSelected->fname);
else
fileBrowserSelectedName = 0;
} }
else else
{ {
@ -780,8 +774,7 @@ void emulator()
m_IEC_Commands.Reset(); m_IEC_Commands.Reset();
selectedViaIECCommands = true; selectedViaIECCommands = true;
} break;
break;
case IEC_Commands::DIR_PUSHED: case IEC_Commands::DIR_PUSHED:
fileBrowser->FolderChanged(); fileBrowser->FolderChanged();
break; break;
@ -798,7 +791,6 @@ void emulator()
case IEC_Commands::DEVICEID_CHANGED: case IEC_Commands::DEVICEID_CHANGED:
GlobalSetDeviceID( m_IEC_Commands.GetDeviceId() ); GlobalSetDeviceID( m_IEC_Commands.GetDeviceId() );
fileBrowser->ShowDeviceAndROM(); fileBrowser->ShowDeviceAndROM();
SetVIAsDeviceID(deviceID); // Let the emulated VIA know
break; break;
default: default:
break; break;
@ -1346,10 +1338,9 @@ extern "C"
f_chdir("/1541"); f_chdir("/1541");
m_IEC_Commands.SetDeviceId(deviceID);
m_IEC_Commands.SetStarFileName(options.GetStarFileName()); m_IEC_Commands.SetStarFileName(options.GetStarFileName());
SetVIAsDeviceID(deviceID); GlobalSetDeviceID(deviceID);
pi1541.drive.SetVIA(&pi1541.VIA[1]); pi1541.drive.SetVIA(&pi1541.VIA[1]);
pi1541.VIA[0].GetPortB()->SetPortOut(0, IEC_Bus::PortB_OnPortOut); pi1541.VIA[0].GetPortB()->SetPortOut(0, IEC_Bus::PortB_OnPortOut);