From: Toni Wilen Date: Sun, 8 Dec 2019 12:16:48 +0000 (+0200) Subject: Generate better partition HDF default geometry if size is >=1000M. X-Git-Tag: 4300~17 X-Git-Url: https://git.unchartedbackwaters.co.uk/w/?a=commitdiff_plain;h=98b933a62394f299591e597773408c276d7ce54c;p=francis%2Fwinuae.git Generate better partition HDF default geometry if size is >=1000M. --- diff --git a/hardfile.cpp b/hardfile.cpp index dcb6d641..46bf16f9 100644 --- a/hardfile.cpp +++ b/hardfile.cpp @@ -270,21 +270,38 @@ void getchsgeometry_hdf (struct hardfiledata *hfd, uae_u64 size, int *pcyl, int getchsgeometry2 (size, pcyl, phead, psectorspertrack, size <= minsize ? 1 : 2); } +// partition hdf default +void gethdfgeometry(uae_u64 size, struct uaedev_config_info *ci) +{ + int head = 1; + int sectorspertrack = 32; + if (size >= 1048576000) { // >=1000M + head = 16; + while ((size / 512) / ((uae_u64)head * sectorspertrack) >= 32768 && sectorspertrack < 32768) { + sectorspertrack *= 2; + } + } + ci->surfaces = head; + ci->sectors = sectorspertrack; + ci->reserved = 2; + ci->blocksize = 512; +} + void getchspgeometry (uae_u64 total, int *pcyl, int *phead, int *psectorspertrack, bool idegeometry) { uae_u64 blocks = total / 512; - if (blocks > 16515072) { - /* >8G, CHS=16383/16/63 */ - *pcyl = 16383; - *phead = 16; - *psectorspertrack = 63; - return; - } if (idegeometry) { *phead = 16; *psectorspertrack = 63; *pcyl = blocks / ((*psectorspertrack) * (*phead)); + if (blocks > 16515072) { + /* >8G, CHS=16383/16/63 */ + *pcyl = 16383; + *phead = 16; + *psectorspertrack = 63; + return; + } return; } getchsgeometry (total, pcyl, phead, psectorspertrack); diff --git a/include/filesys.h b/include/filesys.h index 23d42953..728c0f8b 100644 --- a/include/filesys.h +++ b/include/filesys.h @@ -155,9 +155,11 @@ extern void hdf_close_target (struct hardfiledata *hfd); extern int hdf_read_target (struct hardfiledata *hfd, void *buffer, uae_u64 offset, int len); extern int hdf_write_target (struct hardfiledata *hfd, void *buffer, uae_u64 offset, int len); extern int hdf_resize_target (struct hardfiledata *hfd, uae_u64 newsize); + extern void getchsgeometry (uae_u64 size, int *pcyl, int *phead, int *psectorspertrack); extern void getchsgeometry_hdf (struct hardfiledata *hfd, uae_u64 size, int *pcyl, int *phead, int *psectorspertrack); extern void getchspgeometry (uae_u64 total, int *pcyl, int *phead, int *psectorspertrack, bool idegeometry); +extern void gethdfgeometry(uae_u64 size, struct uaedev_config_info*); void add_cpuboard_unit(int unit, struct uaedev_config_info *uci, struct romconfig *rc); diff --git a/od-win32/win32gui.cpp b/od-win32/win32gui.cpp index e53d96bb..aac58066 100644 --- a/od-win32/win32gui.cpp +++ b/od-win32/win32gui.cpp @@ -14060,6 +14060,7 @@ static void updatehdfinfo (HWND hDlg, bool force, bool defaults) bsize = 0; if (force) { bool open = false; + bool gotrdb = false; int blocksize = 512; struct hardfiledata hfd; memset (id, 0, sizeof id); @@ -14076,6 +14077,7 @@ static void updatehdfinfo (HWND hDlg, bool force, bool defaults) current_hfdlg.size = hfd.virtsize; if (!memcmp (id, "RDSK", 4) || !memcmp (id, "CDSK", 4)) { blocksize = (id[16] << 24) | (id[17] << 16) | (id[18] << 8) | (id[19] << 0); + gotrdb = true; break; } } @@ -14102,6 +14104,10 @@ static void updatehdfinfo (HWND hDlg, bool force, bool defaults) } else { getchspgeometry (bsize, ¤t_hfdlg.ci.pcyls, ¤t_hfdlg.ci.pheads, ¤t_hfdlg.ci.psecs, false); } + if (defaults && !gotrdb) { + gethdfgeometry(bsize, ¤t_hfdlg.ci); + phys = false; + } } else { current_hfdlg.forcedcylinders = current_hfdlg.ci.pcyls; }