finish implementing disk and hard disk insertion

This commit is contained in:
Jorj Bauer 2020-12-28 15:55:02 -05:00
parent 991c5fefd7
commit 9f530fa2b5
2 changed files with 33 additions and 51 deletions

View File

@ -551,6 +551,19 @@ uint16_t BIOS::PaddlesScreenHandler(bool needsRedraw, bool performAction)
return BIOS_PADDLES; return BIOS_PADDLES;
} }
static void insertDisk(int forWhat, const char *path,
const char *fileName)
{
// drawIt is false b/c we don't want to draw it immediately -- that
// would draw over the bios screen
if (forWhat == ACT_DISK1 || forWhat == ACT_DISK2) {
((AppleVM *)g_vm)->insertDisk(forWhat == ACT_DISK1 ? 0 : 1, staticPathConcat(path, fileName), false);
} else {
// must be a hard drive
((AppleVM *)g_vm)->insertHD(forWhat == ACT_HD1 ? 0 : 1, staticPathConcat(path, fileName));
}
}
uint16_t BIOS::SelectFileScreenHandler(bool needsRedraw, bool performAction) uint16_t BIOS::SelectFileScreenHandler(bool needsRedraw, bool performAction)
{ {
if (selectedMenuItem < 0) if (selectedMenuItem < 0)
@ -558,24 +571,23 @@ uint16_t BIOS::SelectFileScreenHandler(bool needsRedraw, bool performAction)
selectedMenuItem %= BIOS_MAXFILES + 2; selectedMenuItem %= BIOS_MAXFILES + 2;
static bool localRedraw = true; static bool localRedraw = true;
static int8_t sel = 0;
static int8_t page = 0; static int8_t page = 0;
static uint16_t fileCount = 0; static uint16_t fileCount = 0;
if (needsRedraw || localRedraw) { if (needsRedraw || localRedraw) {
fileCount = DrawDiskNames(page, sel, fileFilter); fileCount = DrawDiskNames(page, selectedMenuItem, fileFilter);
localRedraw = false; localRedraw = false;
} }
if (performAction) { if (performAction) {
if (sel == 0) { if (selectedMenuItem == 0) {
page--; page--;
if (page < 0) page = 0; if (page < 0) page = 0;
// else sel = BIOS_MAXFILES + 1; // else sel = BIOS_MAXFILES + 1;
localRedraw = true; localRedraw = true;
} }
else if (sel == BIOS_MAXFILES+1) { else if (selectedMenuItem == BIOS_MAXFILES+1) {
if (fileCount == BIOS_MAXFILES) { // don't let them select if (fileCount == BIOS_MAXFILES) { // don't let them select
// 'Next' if there were no // 'Next' if there were no
// files in the list or if the // files in the list or if the
@ -584,20 +596,22 @@ uint16_t BIOS::SelectFileScreenHandler(bool needsRedraw, bool performAction)
//sel = 0; //sel = 0;
localRedraw = true; localRedraw = true;
} }
} else if (strcmp(fileDirectory[sel-1], "../") == 0) { } else if (strcmp(fileDirectory[selectedMenuItem-1], "../") == 0) {
// Go up a directory (strip a directory name from rootPath) // Go up a directory (strip a directory name from rootPath)
stripDirectory(); stripDirectory();
page = 0; page = 0;
//sel = 0; //sel = 0;
localRedraw = true; localRedraw = true;
} else if (fileDirectory[sel-1][strlen(fileDirectory[sel-1])-1] == '/') { } else if (fileDirectory[selectedMenuItem-1][strlen(fileDirectory[selectedMenuItem-1])-1] == '/') {
// Descend in to the directory. FIXME: file path length? // Descend in to the directory. FIXME: file path length?
strcat(rootPath, fileDirectory[sel-1]); strcat(rootPath, fileDirectory[selectedMenuItem-1]);
sel = 0; selectedMenuItem = 0;
page = 0; page = 0;
localRedraw = true; localRedraw = true;
} else { } else {
selectedFile = sel - 1; selectedFile = selectedMenuItem - 1;
insertDisk(fileSelectionFor, rootPath, fileDirectory[selectedFile]);
g_display->flush(); g_display->flush();
return BIOS_DISKS; return BIOS_DISKS;
} }
@ -1093,45 +1107,3 @@ uint16_t BIOS::GatherFilenames(uint8_t pageOffset, const char *filter)
} }
} }
#if 0
***
switch (fileSelectionFor) {
case ACT_DISK1:
if (SelectDiskImage("dsk,.po,nib,woz")) {
((AppleVM *)g_vm)->insertDisk(0, staticPathConcat(rootPath, fileDirectory[selectedFile]), false);
return BIOS_DONE;
...
case ACT_DISK2:
if (SelectDiskImage("dsk,.po,nib,woz")) {
((AppleVM *)g_vm)->insertDisk(1, staticPathConcat(rootPath, fileDirectory[selectedFile]), false);
return BIOS_DONE;
...
case ACT_HD1:
***
if (SelectDiskImage("img")) {
((AppleVM *)g_vm)->insertHD(0, staticPathConcat(rootPath, fileDirectory[selectedFile]));
return BIOS_DONE;
}
case ACT_HD2:
***
if (SelectDiskImage("img")) {
((AppleVM *)g_vm)->insertHD(1, staticPathConcat(rootPath, fileDirectory[selectedFile]));
return BIOS_DONE;
}
...
/*
int8_t sel = 0;
int8_t page = 0;
uint16_t fileCount = 0;
while (1) {
fileCount = DrawDiskNames(page, sel, filter);
*/
#endif

View File

@ -327,6 +327,16 @@ void loop()
if (wasBios) { if (wasBios) {
// bios has just exited // bios has just exited
writePrefs(); writePrefs();
// if we turned off debugMode, make sure to clear the debugMsg
if (g_debugMode == D_NONE) {
g_display->debugMsg("");
}
// Force the display to redraw
g_display->redraw(); // Redraw the UI
((AppleDisplay*)(g_vm->vmdisplay))->modeChange(); // force a full re-draw and blit
wasBios = false; wasBios = false;
} }
} }