Add the drive types dropdown, plus config fragments. Change the TPI settings to

floats (because 40-track 3.5" uses a TPI of 67.5...).
This commit is contained in:
dg
2023-05-08 23:04:52 +00:00
parent 5adfa95a85
commit 099d7969ca
17 changed files with 303 additions and 106 deletions

View File

@@ -44,7 +44,7 @@ message ConfigProto
optional RangeProto tracks = 6;
optional RangeProto heads = 7;
optional int32 tpi = 16 [ (help) = "TPI of image; if 0, use TPI of drive" ];
optional float tpi = 16 [ (help) = "TPI of image; if 0, use TPI of drive" ];
optional FilesystemProto filesystem = 17;

View File

@@ -32,7 +32,7 @@ message DriveProto
];
optional int32 head_width = 10
[ default = 1, (help) = "Width of the head (in tracks)" ];
optional int32 tpi = 11 [ default = 96, (help) = "TPI of drive" ];
optional float tpi = 11 [ default = 96, (help) = "TPI of drive" ];
optional double rotational_period_ms = 12
[ default = 0, (help) = "Rotational period of the drive in milliseconds (0 to autodetect)"];

View File

@@ -12,6 +12,15 @@ ConfigProto config = []()
return config;
}();
static double toFloat(const std::string& value)
{
size_t idx;
float f = std::stof(value, &idx);
if (value[idx] != '\0')
Error() << fmt::format("invalid number '{}'", value);
return f;
}
static double toDouble(const std::string& value)
{
size_t idx;
@@ -120,6 +129,10 @@ void setProtoFieldFromString(ProtoField& protoField, const std::string& value)
const auto* reflection = message->GetReflection();
switch (field->type())
{
case google::protobuf::FieldDescriptor::TYPE_FLOAT:
reflection->SetFloat(message, field, toFloat(value));
break;
case google::protobuf::FieldDescriptor::TYPE_DOUBLE:
reflection->SetDouble(message, field, toDouble(value));
break;

View File

@@ -21,6 +21,7 @@ extern std::map<std::string, const google::protobuf::FieldDescriptor*>
extern ConfigProto parseConfigBytes(const std::string_view& bytes);
extern ConfigProto config;
extern const std::map<std::string, const ConfigProto*> formats;
#endif

View File

@@ -1,5 +1,7 @@
ifneq ($(shell $(WX_CONFIG) --version),)
include src/gui/drivetypes/build.mk
FLUXENGINE_GUI_SRCS = \
src/gui/browserpanel.cc \
src/gui/customstatusbar.cc \
@@ -40,6 +42,7 @@ $(call use-pkgconfig, $(FLUXENGINE_GUI_BIN), $(FLUXENGINE_GUI_OBJS), fmt)
$(call use-library, $(FLUXENGINE_GUI_BIN), $(FLUXENGINE_GUI_OBJS), LIBARCH)
$(call use-library, $(FLUXENGINE_GUI_BIN), $(FLUXENGINE_GUI_OBJS), LIBFLUXENGINE)
$(call use-library, $(FLUXENGINE_GUI_BIN), $(FLUXENGINE_GUI_OBJS), LIBFORMATS)
$(call use-library, $(FLUXENGINE_GUI_BIN), $(FLUXENGINE_GUI_OBJS), LIBDRIVETYPES)
$(call use-library, $(FLUXENGINE_GUI_BIN), $(FLUXENGINE_GUI_OBJS), LIBUSBP)
$(call use-library, $(FLUXENGINE_GUI_BIN), $(FLUXENGINE_GUI_OBJS), PROTO)
$(call use-library, $(FLUXENGINE_GUI_BIN), $(FLUXENGINE_GUI_OBJS), FATFS)

View File

@@ -0,0 +1,6 @@
comment: '3.5" 40 track 67.5tpi'
drive {
tpi: 67.5
}

View File

@@ -0,0 +1,6 @@
comment: '3.5" 80 track 135tpi'
drive {
tpi: 135
}

View File

@@ -0,0 +1,6 @@
comment: '5.25" 40 track 48tpi'
drive {
tpi: 48
}

View File

@@ -0,0 +1,6 @@
comment: '5.25" 80 track 96tpi'
drive {
tpi: 96
}

View File

@@ -0,0 +1,6 @@
comment: '8" 38 track 32tpi'
drive {
tpi: 32
}

View File

@@ -0,0 +1,6 @@
comment: '8" 77 track 48tpi'
drive {
tpi: 48
}

View File

@@ -0,0 +1,31 @@
DRIVETYPES = \
35_80 \
35_40 \
525_80 \
525_40 \
8_77 \
8_38 \
apple2 \
$(OBJDIR)/src/gui/drivetypes/drivetype_%.o: $(OBJDIR)/src/gui/drivetypes/drivetype_%.cc
$(OBJDIR)/src/gui/drivetypes/drivetype_%.cc: $(OBJDIR)/protoencode_ConfigProto.exe src/gui/drivetypes/%.textpb
@mkdir -p $(dir $@)
@echo PROTOENCODE $*
@$^ $@ drivetypes_$*_pb
$(OBJDIR)/src/gui/drivetypes/table.cc: scripts/mktable.sh src/gui/drivetypes/build.mk \
$(patsubst %,src/gui/drivetypes/%.textpb,$(DRIVETYPES))
@mkdir -p $(dir $@)
@echo MKTABLE $@
@scripts/mktable.sh drivetypes $(DRIVETYPES) > $@
LIBDRIVETYPES_SRCS = \
$(patsubst %, $(OBJDIR)/src/gui/drivetypes/drivetype_%.cc, $(DRIVETYPES)) \
$(OBJDIR)/src/gui/drivetypes/table.cc
LIBDRIVETYPES_OBJS = $(patsubst %.cc, %.o, $(LIBDRIVETYPES_SRCS))
.PRECIOUS: $(LIBDRIVETYPES_SRCS)
LIBDRIVETYPES_LIB = $(OBJDIR)/libgui/drivetypes.a
LIBDRIVETYPES_LDFLAGS = $(LIBDRIVETYPES_LIB)
$(LIBDRIVETYPES_LIB): $(LIBDRIVETYPES_OBJS)

View File

@@ -3,6 +3,7 @@
#include <wx/wx.h>
class ConfigProto;
class ExecEvent;
class DiskFlux;
class TrackFlux;
@@ -13,6 +14,8 @@ extern void runOnUiThread(std::function<void()> callback);
extern void runOnWorkerThread(std::function<void()> callback);
extern bool isWorkerThread();
extern const std::map<std::string, const ConfigProto*> drivetypes;
wxDECLARE_EVENT(UPDATE_STATE_EVENT, wxCommandEvent);
template <typename R>

View File

@@ -20,12 +20,10 @@
#include ".obj/extras/fluxfile.h"
#include ".obj/extras/imagefile.h"
extern const std::map<std::string, const ConfigProto*> formats;
#define CONFIG_SELECTEDSOURCE "SelectedSource"
#define CONFIG_DEVICE "Device"
#define CONFIG_DRIVE "Drive"
#define CONFIG_FORTYTRACK "FortyTrack"
#define CONFIG_DRIVETYPE "DriveType"
#define CONFIG_HIGHDENSITY "HighDensity"
#define CONFIG_FORMAT "Format"
#define CONFIG_FORMATOPTIONS "FormatOptions"
@@ -76,7 +74,7 @@ public:
for (const auto& it : formats)
{
auto config = std::make_unique<ConfigProto>();
*config = *it.second;
*config = *it.second;
if (config->is_extension())
continue;
@@ -194,27 +192,6 @@ public:
FlagGroup::applyOption(e.second);
}
/* Merge in any custom config. */
for (auto setting : split(_extraConfiguration, '\n'))
{
setting = trimWhitespace(setting);
if (setting.size() == 0)
continue;
if (setting[0] == '#')
continue;
auto equals = setting.find('=');
if (equals != std::string::npos)
{
auto key = setting.substr(0, equals);
auto value = setting.substr(equals + 1);
setProtoByString(&config, key, value);
}
else
FlagGroup::parseConfigFile(setting, formats);
}
/* Locate the device, if any. */
auto serial = _selectedDevice;
@@ -232,9 +209,7 @@ public:
case SELECTEDSOURCE_REAL:
{
config.mutable_drive()->set_high_density(_selectedHighDensity);
if (_selectedFortyTrack)
FlagGroup::parseConfigFile("40track_drive", formats);
config.MergeFrom(*_selectedDriveType);
std::string filename = _selectedDrive ? "drive:1" : "drive:0";
FluxSink::updateConfigForFilename(
@@ -263,6 +238,27 @@ public:
break;
}
}
/* Merge in any custom config. */
for (auto setting : split(_extraConfiguration, '\n'))
{
setting = trimWhitespace(setting);
if (setting.size() == 0)
continue;
if (setting[0] == '#')
continue;
auto equals = setting.find('=');
if (equals != std::string::npos)
{
auto key = setting.substr(0, equals);
auto value = setting.substr(equals + 1);
setProtoByString(&config, key, value);
}
else
FlagGroup::parseConfigFile(setting, formats);
}
}
const wxBitmap GetBitmap() override
@@ -298,9 +294,13 @@ private:
_config.Read(CONFIG_HIGHDENSITY, &s);
_selectedHighDensity = wxAtoi(s);
s = "0";
_config.Read(CONFIG_FORTYTRACK, &s);
_selectedFortyTrack = wxAtoi(s);
s = "";
_config.Read(CONFIG_DRIVETYPE, &s);
auto it = drivetypes.find(s.ToStdString());
if (it != drivetypes.end())
_selectedDriveType = it->second;
else
_selectedDriveType = drivetypes.begin()->second;
/* Flux image block. */
@@ -372,8 +372,11 @@ private:
_config.Write(CONFIG_DRIVE, wxString(std::to_string(_selectedDrive)));
_config.Write(
CONFIG_HIGHDENSITY, wxString(std::to_string(_selectedHighDensity)));
_config.Write(
CONFIG_FORTYTRACK, wxString(std::to_string(_selectedFortyTrack)));
for (auto it : drivetypes)
{
if (_selectedDriveType == it.second)
_config.Write(CONFIG_DRIVETYPE, wxString(it.first));
}
/* Flux image block. */
@@ -442,13 +445,24 @@ private:
OnControlsChanged(e);
});
panel->fortyTrackDriveToggle->SetValue(_selectedFortyTrack);
panel->fortyTrackDriveToggle->Bind(
wxEVT_COMMAND_CHECKBOX_CLICKED,
int i = 0;
for (auto& driveConfig : drivetypes)
{
panel->driveTypeChoice->Append(
driveConfig.second->comment());
if (driveConfig.second == _selectedDriveType)
panel->driveTypeChoice->SetSelection(i);
i++;
}
panel->driveTypeChoice->Bind(wxEVT_CHOICE,
[=](wxCommandEvent& e)
{
_selectedFortyTrack =
panel->fortyTrackDriveToggle->GetValue();
auto it = drivetypes.begin();
std::advance(
it, panel->driveTypeChoice->GetSelection());
_selectedDriveType = it->second;
OnControlsChanged(e);
});
@@ -679,7 +693,7 @@ private:
int _selectedSource;
std::string _selectedDevice;
int _selectedDrive;
bool _selectedFortyTrack;
const ConfigProto* _selectedDriveType;
bool _selectedHighDensity;
std::string _selectedFluxfilename;
std::string _selectedImagefilename;

View File

@@ -1,5 +1,5 @@
///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version 3.10.1-1fa5400)
// C++ code generated with wxFormBuilder (version 3.10.1-234-gd93c9fc0-dirty)
// http://www.wxformbuilder.org/
//
// PLEASE DO *NOT* EDIT THIS FILE!
@@ -1040,8 +1040,23 @@ HardwareSourcePanelGen::HardwareSourcePanelGen( wxWindow* parent, wxWindowID id,
bSizer3->Add( highDensityToggle, 0, wxALL|wxEXPAND, 5 );
fortyTrackDriveToggle = new wxCheckBox( this, wxID_ANY, wxT("I'm using a 40-track drive"), wxDefaultPosition, wxDefaultSize, 0 );
bSizer3->Add( fortyTrackDriveToggle, 0, wxALL, 5 );
wxFlexGridSizer* fgSizer14;
fgSizer14 = new wxFlexGridSizer( 0, 2, 0, 0 );
fgSizer14->AddGrowableCol( 1 );
fgSizer14->SetFlexibleDirection( wxBOTH );
fgSizer14->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED );
m_staticText29 = new wxStaticText( this, wxID_ANY, wxT("Drive type:"), wxDefaultPosition, wxDefaultSize, 0 );
m_staticText29->Wrap( -1 );
fgSizer14->Add( m_staticText29, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 );
wxArrayString driveTypeChoiceChoices;
driveTypeChoice = new wxChoice( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, driveTypeChoiceChoices, 0 );
driveTypeChoice->SetSelection( 0 );
fgSizer14->Add( driveTypeChoice, 0, wxALL|wxEXPAND, 5 );
bSizer3->Add( fgSizer14, 1, wxEXPAND, 5 );
this->SetSizer( bSizer3 );

View File

@@ -6266,67 +6266,147 @@
</object>
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="flag">wxALL</property>
<property name="proportion">0</property>
<object class="wxCheckBox" expanded="1">
<property name="BottomDockable">1</property>
<property name="LeftDockable">1</property>
<property name="RightDockable">1</property>
<property name="TopDockable">1</property>
<property name="aui_layer"></property>
<property name="aui_name"></property>
<property name="aui_position"></property>
<property name="aui_row"></property>
<property name="best_size"></property>
<property name="bg"></property>
<property name="caption"></property>
<property name="caption_visible">1</property>
<property name="center_pane">0</property>
<property name="checked">0</property>
<property name="close_button">1</property>
<property name="context_help"></property>
<property name="context_menu">1</property>
<property name="default_pane">0</property>
<property name="dock">Dock</property>
<property name="dock_fixed">0</property>
<property name="docking">Left</property>
<property name="drag_accept_files">0</property>
<property name="enabled">1</property>
<property name="fg"></property>
<property name="floatable">1</property>
<property name="font"></property>
<property name="gripper">0</property>
<property name="hidden">0</property>
<property name="id">wxID_ANY</property>
<property name="label">I&apos;m using a 40-track drive</property>
<property name="max_size"></property>
<property name="maximize_button">0</property>
<property name="maximum_size"></property>
<property name="min_size"></property>
<property name="minimize_button">0</property>
<property name="flag">wxEXPAND</property>
<property name="proportion">1</property>
<object class="wxFlexGridSizer" expanded="1">
<property name="cols">2</property>
<property name="flexible_direction">wxBOTH</property>
<property name="growablecols">1</property>
<property name="growablerows"></property>
<property name="hgap">0</property>
<property name="minimum_size"></property>
<property name="moveable">1</property>
<property name="name">fortyTrackDriveToggle</property>
<property name="pane_border">1</property>
<property name="pane_position"></property>
<property name="pane_size"></property>
<property name="permission">public</property>
<property name="pin_button">1</property>
<property name="pos"></property>
<property name="resize">Resizable</property>
<property name="show">1</property>
<property name="size"></property>
<property name="style"></property>
<property name="subclass">; ; forward_declare</property>
<property name="toolbar_pane">0</property>
<property name="tooltip"></property>
<property name="validator_data_type"></property>
<property name="validator_style">wxFILTER_NONE</property>
<property name="validator_type">wxDefaultValidator</property>
<property name="validator_variable"></property>
<property name="window_extra_style"></property>
<property name="window_name"></property>
<property name="window_style"></property>
<property name="name">fgSizer14</property>
<property name="non_flexible_grow_mode">wxFLEX_GROWMODE_SPECIFIED</property>
<property name="permission">none</property>
<property name="rows">0</property>
<property name="vgap">0</property>
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="flag">wxALIGN_CENTER_VERTICAL|wxALL</property>
<property name="proportion">0</property>
<object class="wxStaticText" expanded="1">
<property name="BottomDockable">1</property>
<property name="LeftDockable">1</property>
<property name="RightDockable">1</property>
<property name="TopDockable">1</property>
<property name="aui_layer"></property>
<property name="aui_name"></property>
<property name="aui_position"></property>
<property name="aui_row"></property>
<property name="best_size"></property>
<property name="bg"></property>
<property name="caption"></property>
<property name="caption_visible">1</property>
<property name="center_pane">0</property>
<property name="close_button">1</property>
<property name="context_help"></property>
<property name="context_menu">1</property>
<property name="default_pane">0</property>
<property name="dock">Dock</property>
<property name="dock_fixed">0</property>
<property name="docking">Left</property>
<property name="drag_accept_files">0</property>
<property name="enabled">1</property>
<property name="fg"></property>
<property name="floatable">1</property>
<property name="font"></property>
<property name="gripper">0</property>
<property name="hidden">0</property>
<property name="id">wxID_ANY</property>
<property name="label">Drive type:</property>
<property name="markup">0</property>
<property name="max_size"></property>
<property name="maximize_button">0</property>
<property name="maximum_size"></property>
<property name="min_size"></property>
<property name="minimize_button">0</property>
<property name="minimum_size"></property>
<property name="moveable">1</property>
<property name="name">m_staticText29</property>
<property name="pane_border">1</property>
<property name="pane_position"></property>
<property name="pane_size"></property>
<property name="permission">protected</property>
<property name="pin_button">1</property>
<property name="pos"></property>
<property name="resize">Resizable</property>
<property name="show">1</property>
<property name="size"></property>
<property name="style"></property>
<property name="subclass">; ; forward_declare</property>
<property name="toolbar_pane">0</property>
<property name="tooltip"></property>
<property name="window_extra_style"></property>
<property name="window_name"></property>
<property name="window_style"></property>
<property name="wrap">-1</property>
</object>
</object>
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="flag">wxALL|wxEXPAND</property>
<property name="proportion">0</property>
<object class="wxChoice" expanded="1">
<property name="BottomDockable">1</property>
<property name="LeftDockable">1</property>
<property name="RightDockable">1</property>
<property name="TopDockable">1</property>
<property name="aui_layer"></property>
<property name="aui_name"></property>
<property name="aui_position"></property>
<property name="aui_row"></property>
<property name="best_size"></property>
<property name="bg"></property>
<property name="caption"></property>
<property name="caption_visible">1</property>
<property name="center_pane">0</property>
<property name="choices"></property>
<property name="close_button">1</property>
<property name="context_help"></property>
<property name="context_menu">1</property>
<property name="default_pane">0</property>
<property name="dock">Dock</property>
<property name="dock_fixed">0</property>
<property name="docking">Left</property>
<property name="drag_accept_files">0</property>
<property name="enabled">1</property>
<property name="fg"></property>
<property name="floatable">1</property>
<property name="font"></property>
<property name="gripper">0</property>
<property name="hidden">0</property>
<property name="id">wxID_ANY</property>
<property name="max_size"></property>
<property name="maximize_button">0</property>
<property name="maximum_size"></property>
<property name="min_size"></property>
<property name="minimize_button">0</property>
<property name="minimum_size"></property>
<property name="moveable">1</property>
<property name="name">driveTypeChoice</property>
<property name="pane_border">1</property>
<property name="pane_position"></property>
<property name="pane_size"></property>
<property name="permission">public</property>
<property name="pin_button">1</property>
<property name="pos"></property>
<property name="resize">Resizable</property>
<property name="selection">0</property>
<property name="show">1</property>
<property name="size"></property>
<property name="style"></property>
<property name="subclass">; ; forward_declare</property>
<property name="toolbar_pane">0</property>
<property name="tooltip"></property>
<property name="validator_data_type"></property>
<property name="validator_style">wxFILTER_NONE</property>
<property name="validator_type">wxDefaultValidator</property>
<property name="validator_variable"></property>
<property name="window_extra_style"></property>
<property name="window_name"></property>
<property name="window_style"></property>
</object>
</object>
</object>
</object>
</object>

View File

@@ -1,5 +1,5 @@
///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version 3.10.1-1fa5400)
// C++ code generated with wxFormBuilder (version 3.10.1-234-gd93c9fc0-dirty)
// http://www.wxformbuilder.org/
//
// PLEASE DO *NOT* EDIT THIS FILE!
@@ -496,11 +496,12 @@ class HardwareSourcePanelGen : public wxPanel
protected:
wxStaticText* m_staticText30;
wxStaticText* m_staticText29;
public:
wxStaticText* label;
wxCheckBox* highDensityToggle;
wxCheckBox* fortyTrackDriveToggle;
wxChoice* driveTypeChoice;
HardwareSourcePanelGen( wxWindow* parent, wxWindowID id = wxID_ANY, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( -1,-1 ), long style = wxTAB_TRAVERSAL, const wxString& name = wxEmptyString );