Merge branch 'master' of https://github.com/86Box/86Box
This commit is contained in:
@@ -199,7 +199,7 @@ HarddiskDialog::on_comboBoxFormat_currentIndexChanged(int index)
|
||||
* than a tenth of a percent change in size.
|
||||
*/
|
||||
static void
|
||||
adjust_86box_geometry_for_vhd(MVHDGeom *_86box_geometry, MVHDGeom *vhd_geometry)
|
||||
adjust_86box_geometry_for_vhd(_86BoxGeom *_86box_geometry, MVHDGeom *vhd_geometry)
|
||||
{
|
||||
if (_86box_geometry->cyl <= 65535) {
|
||||
vhd_geometry->cyl = _86box_geometry->cyl;
|
||||
@@ -226,10 +226,10 @@ adjust_86box_geometry_for_vhd(MVHDGeom *_86box_geometry, MVHDGeom *vhd_geometry)
|
||||
}
|
||||
|
||||
static HarddiskDialog *callbackPtr = nullptr;
|
||||
static MVHDGeom
|
||||
create_drive_vhd_fixed(const QString &fileName, HarddiskDialog *p, uint16_t cyl, uint8_t heads, uint8_t spt)
|
||||
static _86BoxGeom
|
||||
create_drive_vhd_fixed(const QString &fileName, HarddiskDialog *p, uint32_t cyl, uint32_t heads, uint32_t spt)
|
||||
{
|
||||
MVHDGeom _86box_geometry = {
|
||||
_86BoxGeom _86box_geometry = {
|
||||
.cyl = cyl,
|
||||
.heads = heads,
|
||||
.spt = spt
|
||||
@@ -256,10 +256,10 @@ create_drive_vhd_fixed(const QString &fileName, HarddiskDialog *p, uint16_t cyl,
|
||||
return _86box_geometry;
|
||||
}
|
||||
|
||||
static MVHDGeom
|
||||
create_drive_vhd_dynamic(const QString &fileName, uint16_t cyl, uint8_t heads, uint8_t spt, int blocksize)
|
||||
static _86BoxGeom
|
||||
create_drive_vhd_dynamic(const QString &fileName, uint32_t cyl, uint32_t heads, uint32_t spt, int blocksize)
|
||||
{
|
||||
MVHDGeom _86box_geometry = {
|
||||
_86BoxGeom _86box_geometry = {
|
||||
.cyl = cyl,
|
||||
.heads = heads,
|
||||
.spt = spt
|
||||
@@ -287,7 +287,7 @@ create_drive_vhd_dynamic(const QString &fileName, uint16_t cyl, uint8_t heads, u
|
||||
return _86box_geometry;
|
||||
}
|
||||
|
||||
static MVHDGeom
|
||||
static _86BoxGeom
|
||||
create_drive_vhd_diff(const QString &fileName, const QString &parentFileName, int blocksize)
|
||||
{
|
||||
int vhd_error = 0;
|
||||
@@ -301,23 +301,29 @@ create_drive_vhd_diff(const QString &fileName, const QString &parentFileName, in
|
||||
|
||||
MVHDMeta *vhd = mvhd_create_ex(options, &vhd_error);
|
||||
MVHDGeom vhd_geometry;
|
||||
_86BoxGeom _86box_geometry;
|
||||
if (vhd == NULL) {
|
||||
vhd_geometry.cyl = 0;
|
||||
vhd_geometry.heads = 0;
|
||||
vhd_geometry.spt = 0;
|
||||
_86box_geometry.cyl = 0;
|
||||
_86box_geometry.heads = 0;
|
||||
_86box_geometry.spt = 0;
|
||||
} else {
|
||||
vhd_geometry = mvhd_get_geometry(vhd);
|
||||
|
||||
if (vhd_geometry.spt > 63) {
|
||||
vhd_geometry.cyl = mvhd_calc_size_sectors(&vhd_geometry) / (16 * 63);
|
||||
vhd_geometry.heads = 16;
|
||||
vhd_geometry.spt = 63;
|
||||
_86box_geometry.cyl = mvhd_calc_size_sectors(&vhd_geometry) / (16 * 63);
|
||||
_86box_geometry.heads = 16;
|
||||
_86box_geometry.spt = 63;
|
||||
} else {
|
||||
_86box_geometry.cyl = vhd_geometry.cyl;
|
||||
_86box_geometry.heads = vhd_geometry.heads;
|
||||
_86box_geometry.spt = vhd_geometry.spt;
|
||||
}
|
||||
|
||||
|
||||
mvhd_close(vhd);
|
||||
}
|
||||
|
||||
return vhd_geometry;
|
||||
return _86box_geometry;
|
||||
}
|
||||
|
||||
void
|
||||
@@ -409,7 +415,7 @@ HarddiskDialog::onCreateNewFile()
|
||||
} else if (img_format >= IMG_FMT_VHD_FIXED) { /* VHD file */
|
||||
file.close();
|
||||
|
||||
MVHDGeom _86box_geometry {};
|
||||
_86BoxGeom _86box_geometry {};
|
||||
int block_size = ui->comboBoxBlockSize->currentIndex() == 0 ? MVHD_BLOCK_LARGE : MVHD_BLOCK_SMALL;
|
||||
switch (img_format) {
|
||||
case IMG_FMT_VHD_FIXED:
|
||||
@@ -493,10 +499,14 @@ HarddiskDialog::onCreateNewFile()
|
||||
}
|
||||
|
||||
static void
|
||||
adjust_vhd_geometry_for_86box(MVHDGeom *vhd_geometry)
|
||||
adjust_vhd_geometry_for_86box(MVHDGeom *vhd_geometry, _86BoxGeom *_86box_geometry)
|
||||
{
|
||||
if (vhd_geometry->spt <= 63)
|
||||
if (vhd_geometry->spt <= 63) {
|
||||
_86box_geometry->cyl = vhd_geometry->cyl;
|
||||
_86box_geometry->heads = vhd_geometry->heads;
|
||||
_86box_geometry->spt = vhd_geometry->spt;
|
||||
return;
|
||||
}
|
||||
|
||||
int desired_sectors = vhd_geometry->cyl * vhd_geometry->heads * vhd_geometry->spt;
|
||||
if (desired_sectors > 267321600)
|
||||
@@ -506,9 +516,9 @@ adjust_vhd_geometry_for_86box(MVHDGeom *vhd_geometry)
|
||||
if (remainder > 0)
|
||||
desired_sectors -= remainder;
|
||||
|
||||
vhd_geometry->cyl = desired_sectors / (16 * 63);
|
||||
vhd_geometry->heads = 16;
|
||||
vhd_geometry->spt = 63;
|
||||
_86box_geometry->cyl = desired_sectors / (16 * 63);
|
||||
_86box_geometry->heads = 16;
|
||||
_86box_geometry->spt = 63;
|
||||
}
|
||||
|
||||
void
|
||||
@@ -603,10 +613,11 @@ HarddiskDialog::onExistingFileSelected(const QString &fileName, bool precheck)
|
||||
}
|
||||
|
||||
MVHDGeom vhd_geom = mvhd_get_geometry(vhd);
|
||||
adjust_vhd_geometry_for_86box(&vhd_geom);
|
||||
cylinders = vhd_geom.cyl;
|
||||
heads = vhd_geom.heads;
|
||||
sectors = vhd_geom.spt;
|
||||
_86BoxGeom _86box_geom;
|
||||
adjust_vhd_geometry_for_86box(&vhd_geom, &_86box_geom);
|
||||
cylinders = _86box_geom.cyl;
|
||||
heads = _86box_geom.heads;
|
||||
sectors = _86box_geom.spt;
|
||||
size = static_cast<uint64_t>(cylinders * heads * sectors * 512);
|
||||
mvhd_close(vhd);
|
||||
} else {
|
||||
|
||||
@@ -64,4 +64,10 @@ private:
|
||||
void recalcSelection();
|
||||
};
|
||||
|
||||
typedef struct _86BoxGeom {
|
||||
uint32_t cyl;
|
||||
uint32_t heads;
|
||||
uint32_t spt;
|
||||
} _86BoxGeom;
|
||||
|
||||
#endif // QT_HARDDISKDIALOG_HPP
|
||||
|
||||
Reference in New Issue
Block a user