Skip to content

Commit

Permalink
enhancement: populate more fields in Hardfile dialog (fixes #1578)
Browse files Browse the repository at this point in the history
  • Loading branch information
midwan committed Jan 9, 2025
1 parent 87ba6cf commit 2eca3a4
Show file tree
Hide file tree
Showing 5 changed files with 193 additions and 38 deletions.
3 changes: 2 additions & 1 deletion src/cfgfile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7621,7 +7621,8 @@ static void parse_hardfile_spec (struct uae_prefs *p, const TCHAR *spec)
const std::string x2 = parameter.substr(pos + 1, parameter.length());
#ifdef FILESYS
default_hfdlg(&current_hfdlg, false);
updatehdfinfo(true, false, false);
std::string txt1, txt2;
updatehdfinfo(true, false, false, txt1, txt2);

current_hfdlg.ci.type = UAEDEV_HDF;
_tcscpy(current_hfdlg.ci.devname, x1.c_str());
Expand Down
2 changes: 1 addition & 1 deletion src/include/options.h
Original file line number Diff line number Diff line change
Expand Up @@ -1277,7 +1277,7 @@ extern void hardfile_testrdb(struct hfdlg_vals* hdf);
extern void default_tapedlg(struct tapedlg_vals* f);
extern void default_fsvdlg(struct fsvdlg_vals* f);
extern void default_hfdlg(struct hfdlg_vals* f, bool rdb);
extern void updatehdfinfo(bool force, bool defaults, bool realdrive);
extern void updatehdfinfo(bool force, bool defaults, bool realdrive, std::string& txtHdfInfo, std::string& txtHdfInfo2);

#ifdef AMIBERRY
struct amiberry_customised_layout
Expand Down
57 changes: 54 additions & 3 deletions src/osdep/amiberry_gui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1461,10 +1461,12 @@ void default_rdb_hfdlg(struct hfdlg_vals* f, const TCHAR* filename)
hardfile_testrdb(f);
}

void updatehdfinfo(bool force, bool defaults, bool realdrive)
void updatehdfinfo(bool force, bool defaults, bool realdrive, std::string& txtHdfInfo, std::string& txtHdfInfo2)
{
uae_u8 id[512] = { 0 };
uae_u32 i;
uae_u8 id[512] = { };
uae_u32 blocks, cyls, i;
TCHAR tmp[200], tmp2[200];
TCHAR idtmp[17];
bool phys = is_hdf_rdb();

uae_u64 bsize = 0;
Expand Down Expand Up @@ -1528,6 +1530,55 @@ void updatehdfinfo(bool force, bool defaults, bool realdrive)
if (current_hfdlg.ci.unit_feature_level == HD_LEVEL_ATA_1 && bsize >= 4 * static_cast<uae_u64>(0x40000000))
current_hfdlg.ci.unit_feature_level = HD_LEVEL_ATA_2;
}

cyls = phys ? current_hfdlg.ci.pcyls : current_hfdlg.forcedcylinders;
int heads = phys ? current_hfdlg.ci.pheads : current_hfdlg.ci.surfaces;
int secs = phys ? current_hfdlg.ci.psecs : current_hfdlg.ci.sectors;
if (!cyls && current_hfdlg.ci.blocksize && secs && heads) {
cyls = (uae_u32)(bsize / ((uae_u64)current_hfdlg.ci.blocksize * secs * heads));
}
blocks = cyls * (secs * heads);
if (!blocks && current_hfdlg.ci.blocksize)
blocks = (uae_u32)(bsize / current_hfdlg.ci.blocksize);
if (current_hfdlg.ci.max_lba)
blocks = (uae_u32)current_hfdlg.ci.max_lba;

for (i = 0; i < sizeof (idtmp) / sizeof (TCHAR) - 1; i++) {
TCHAR c = id[i];
if (c < 32 || c > 126)
c = '.';
idtmp[i] = c;
idtmp[i + 1] = 0;
}

tmp[0] = 0;
if (bsize) {
_sntprintf (tmp2, sizeof tmp2, _T(" %s [%02X%02X%02X%02X %02X%02X%02X%02X %02X%02X%02X%02X %02X%02X%02X%02X]"), idtmp,
id[0], id[1], id[2], id[3], id[4], id[5], id[6], id[7],
id[8], id[9], id[10], id[11], id[12], id[13], id[14], id[15]);
if (!blocks) {
_sntprintf (tmp, sizeof tmp, _T("%uMB"), (unsigned int)(bsize / (1024 * 1024)));
} else if (blocks && !cyls) {
_sntprintf (tmp, sizeof tmp, _T("%u blocks, %.1fMB"),
blocks,
(double)bsize / (1024.0 * 1024.0));
} else {
_sntprintf (tmp, sizeof tmp, _T("%u/%u/%u, %u/%u blocks, %.1fMB/%.1fMB"),
cyls, heads, secs,
blocks, (int)(bsize / current_hfdlg.ci.blocksize),
(double)blocks * 1.0 * current_hfdlg.ci.blocksize / (1024.0 * 1024.0),
(double)bsize / (1024.0 * 1024.0));
if ((uae_u64)cyls * heads * secs > bsize / current_hfdlg.ci.blocksize) {
_tcscat (tmp2, _T(" [Geometry larger than drive!]"));
} else if (cyls > 65535) {
_tcscat (tmp2, _T(" [Too many cyls]"));
}
}
if (txtHdfInfo.empty() && txtHdfInfo2.empty()) {
txtHdfInfo = std::string(tmp);
txtHdfInfo2 = std::string(tmp2);
}
}
}

void new_filesys(int entry)
Expand Down
6 changes: 4 additions & 2 deletions src/osdep/gui/EditFilesysHardDrive.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,8 @@ class FilesysHardDriveActionListener : public gcn::ActionListener
current_hfdlg.ci.controller_type_unit = posn / HD_CONTROLLER_NEXT_UNIT;
current_hfdlg.forcedcylinders = 0;
current_hfdlg.ci.cyls = current_hfdlg.ci.highcyl = current_hfdlg.ci.sectors = current_hfdlg.ci.surfaces = 0;
updatehdfinfo(true, true, true);
std::string txt1, txt2;
updatehdfinfo(true, true, true, txt1, txt2);
inithdcontroller(current_hfdlg.ci.controller_type, current_hfdlg.ci.controller_type_unit, UAEDEV_HDF, current_hfdlg.ci.rootdir[0] != 0);
setharddrive();
}
Expand Down Expand Up @@ -596,7 +597,8 @@ bool EditFilesysHardDrive(const int unit_no)
fileSelected = false;
}

updatehdfinfo(true, false, true);
std::string txt1, txt2;
updatehdfinfo(true, false, true, txt1, txt2);

// Prepare the screen once
uae_gui->logic();
Expand Down
Loading

0 comments on commit 2eca3a4

Please sign in to comment.