finish abstracting file extension filter

This commit is contained in:
Jorj Bauer 2018-02-07 14:23:52 -05:00
parent f790b3d5ab
commit c2d5166272
2 changed files with 10 additions and 10 deletions

View File

@ -168,7 +168,7 @@ bool BIOS::runUntilDone()
if (((AppleVM *)g_vm)->DiskName(0)[0] != '\0') { if (((AppleVM *)g_vm)->DiskName(0)[0] != '\0') {
((AppleVM *)g_vm)->ejectDisk(0); ((AppleVM *)g_vm)->ejectDisk(0);
} else { } else {
if (SelectDiskImage()) { if (SelectDiskImage("dsk,.po,nib")) {
((AppleVM *)g_vm)->insertDisk(0, staticPathConcat(rootPath, fileDirectory[selectedFile]), false); ((AppleVM *)g_vm)->insertDisk(0, staticPathConcat(rootPath, fileDirectory[selectedFile]), false);
goto done; goto done;
} }
@ -178,7 +178,7 @@ bool BIOS::runUntilDone()
if (((AppleVM *)g_vm)->DiskName(1)[0] != '\0') { if (((AppleVM *)g_vm)->DiskName(1)[0] != '\0') {
((AppleVM *)g_vm)->ejectDisk(1); ((AppleVM *)g_vm)->ejectDisk(1);
} else { } else {
if (SelectDiskImage()) { if (SelectDiskImage("dsk,.po,nib")) {
((AppleVM *)g_vm)->insertDisk(1, staticPathConcat(rootPath, fileDirectory[selectedFile]), false); ((AppleVM *)g_vm)->insertDisk(1, staticPathConcat(rootPath, fileDirectory[selectedFile]), false);
goto done; goto done;
} }
@ -188,7 +188,7 @@ bool BIOS::runUntilDone()
if (((AppleVM *)g_vm)->HDName(0)[0] != '\0') { if (((AppleVM *)g_vm)->HDName(0)[0] != '\0') {
((AppleVM *)g_vm)->ejectHD(0); ((AppleVM *)g_vm)->ejectHD(0);
} else { } else {
if (SelectDiskImage()) { if (SelectDiskImage("img")) {
((AppleVM *)g_vm)->insertHD(0, staticPathConcat(rootPath, fileDirectory[selectedFile])); ((AppleVM *)g_vm)->insertHD(0, staticPathConcat(rootPath, fileDirectory[selectedFile]));
goto done; goto done;
} }
@ -198,7 +198,7 @@ bool BIOS::runUntilDone()
if (((AppleVM *)g_vm)->HDName(1)[0] != '\0') { if (((AppleVM *)g_vm)->HDName(1)[0] != '\0') {
((AppleVM *)g_vm)->ejectHD(1); ((AppleVM *)g_vm)->ejectHD(1);
} else { } else {
if (SelectDiskImage()) { if (SelectDiskImage("img")) {
((AppleVM *)g_vm)->insertHD(1, staticPathConcat(rootPath, fileDirectory[selectedFile])); ((AppleVM *)g_vm)->insertHD(1, staticPathConcat(rootPath, fileDirectory[selectedFile]));
goto done; goto done;
} }
@ -637,13 +637,13 @@ void BIOS::DrawMainMenu()
// return true if the user selects an image // return true if the user selects an image
// sets selectedFile (index; -1 = "nope") and fileDirectory[][] (names of up to BIOS_MAXFILES files) // sets selectedFile (index; -1 = "nope") and fileDirectory[][] (names of up to BIOS_MAXFILES files)
bool BIOS::SelectDiskImage() bool BIOS::SelectDiskImage(const char *filter)
{ {
int8_t sel = 0; int8_t sel = 0;
int8_t page = 0; int8_t page = 0;
while (1) { while (1) {
DrawDiskNames(page, sel); DrawDiskNames(page, sel, filter);
while (!g_keyboard->kbhit()) while (!g_keyboard->kbhit())
; ;
@ -709,9 +709,9 @@ void BIOS::stripDirectory()
} }
} }
void BIOS::DrawDiskNames(uint8_t page, int8_t selection) void BIOS::DrawDiskNames(uint8_t page, int8_t selection, const char *filter)
{ {
uint8_t fileCount = GatherFilenames(page, "dsk,.po,nib,img"); uint8_t fileCount = GatherFilenames(page, filter);
g_display->clrScr(); g_display->clrScr();
g_display->drawString(M_NORMAL, 0, 12, "BIOS Configuration - pick disk"); g_display->drawString(M_NORMAL, 0, 12, "BIOS Configuration - pick disk");

4
bios.h
View File

@ -35,8 +35,8 @@ class BIOS {
void WarmReset(); void WarmReset();
void ColdReboot(); void ColdReboot();
bool SelectDiskImage(); bool SelectDiskImage(const char *filter);
void DrawDiskNames(uint8_t page, int8_t selection); void DrawDiskNames(uint8_t page, int8_t selection, const char *filter);
uint8_t GatherFilenames(uint8_t pageOffset, const char *filter); uint8_t GatherFilenames(uint8_t pageOffset, const char *filter);
void stripDirectory(); void stripDirectory();