Press N to crete a new .d64 image

Still need to implement finding the highest existing numbered filename
This commit is contained in:
penfold42 2018-07-19 23:49:08 +10:00
parent 9d10bcb3ef
commit 53de164fbe
7 changed files with 52 additions and 5 deletions

View File

@ -32,6 +32,9 @@ extern "C"
#include "rpi-gpio.h"
}
#include "iec_commands.h"
extern IEC_Commands m_IEC_Commands;
#define PNG_WIDTH 320
#define PNG_HEIGHT 200
@ -892,6 +895,14 @@ void FileBrowser::UpdateInputFolders()
dirty = AddToCaddy(current);
}
}
else if (inputMappings->BrowseNewD64())
{
char newFileName[64];
int num = folder.FindNextAutoName("testfile");
snprintf(newFileName, 64, "testfile%03d.d64", num);
m_IEC_Commands.CreateD64(newFileName, "42");
FolderChanged();
}
else
{
unsigned keySetIndex;
@ -1241,3 +1252,21 @@ void FileBrowser::AutoSelectImage(const char* image)
selectionsMade = FillCaddyWithSelections();
}
}
int FileBrowser::BrowsableList::FindNextAutoName(const char* basename)
{
int index;
int len = (int)entries.size();
int baselen = strlen(basename);
int lastNumber = 0;
for (index = 0; index < len; ++index)
{
Entry* entry = &entries[index];
if (!(entry->filImage.fattrib & AM_DIR) && strncasecmp(basename, entry->filImage.fname, baselen) == 0)
{
lastNumber = 55;
}
}
return lastNumber+1;
}

View File

@ -151,6 +151,7 @@ public:
};
Entry* FindEntry(const char* name);
int FindNextAutoName(const char* basename);
void RefreshViews();
void RefreshViewsHighlightScroll();

View File

@ -170,6 +170,8 @@ bool InputMappings::CheckKeyboardBrowseMode()
// SetKeyboardFlag(PAGEUP_LCD_FLAG);
//else if (keyboard->KeyHeld(KEY_END))
// SetKeyboardFlag(PAGEDOWN_LCD_FLAG);
else if (keyboard->KeyHeld(KEY_N))
SetKeyboardFlag(NEWD64_FLAG);
else
{
unsigned index;

View File

@ -28,14 +28,17 @@
#define UP_FLAG (1 << 4)
#define PAGEUP_FLAG (1 << 5)
#define DOWN_FLAG (1 << 6)
#define PAGEDOWN_FLAG (1 << 7)
#define PAGEDOWN_FLAG (1 << 7)
#define SPACE_FLAG (1 << 8)
#define BACK_FLAG (1 << 9)
#define INSERT_FLAG (1 << 10)
#define NUMBER_FLAG (1 << 11)
#define PAGEDOWN_LCD_FLAG (1 << 12)
#define PAGEUP_LCD_FLAG (1 << 13)
#define PAGEDOWN_LCD_FLAG (1 << 12)
#define PAGEUP_LCD_FLAG (1 << 13)
#define NEWD64_FLAG (1 << 14)
// dont exceed 32!!
class InputMappings : public Singleton<InputMappings>
{
@ -137,6 +140,11 @@ public:
return KeyboardFlag(INSERT_FLAG)/* | UartFlag(INSERT_FLAG)*/ | ButtonFlag(INSERT_FLAG);
}
inline bool BrowseNewD64()
{
return KeyboardFlag(NEWD64_FLAG);
}
// Used by the 2 cores so need to be volatile
//volatile static unsigned directDiskSwapRequest;
static unsigned directDiskSwapRequest;

View File

@ -344,5 +344,9 @@ public:
{
return (keyStatus[0] | keyStatus[1]);
}
inline bool KeyLeftAlt()
{
return (modifier & 1<<2);
}
};
#endif

View File

@ -78,6 +78,9 @@ public:
const char* GetNameOfImageSelected() const { return selectedImageName; }
const FILINFO* GetImageSelected() const { return &filInfoSelectedImage; }
void SetStarFileName(const char* fileName) { starFileName = fileName; }
int CreateD64(char* filenameNew, char* ID);
protected:
enum ATNSequence
{
@ -128,7 +131,6 @@ protected:
void CloseAllChannels();
void SendError();
int CreateD64(char* filenameNew, char* ID);
bool Enter(DIR& dir, FILINFO& filInfo);
bool FindFirst(DIR& dir, const char* matchstr, FILINFO& filInfo);

View File

@ -793,7 +793,7 @@ void emulator()
deviceID = m_IEC_Commands.GetDeviceId();
fileBrowser->SetDeviceID(deviceID);
fileBrowser->ShowDeviceAndROM();
SetVIAsDeviceID(deviceID); // Let the emilated VIA know
SetVIAsDeviceID(deviceID); // Let the emulated VIA know
break;
default:
break;
@ -1361,3 +1361,4 @@ extern "C"
#endif
}
}