]> git.unchartedbackwaters.co.uk Git - francis/winuae.git/commitdiff
Generate better partition HDF default geometry if size is >=1000M.
authorToni Wilen <twilen@winuae.net>
Sun, 8 Dec 2019 12:16:48 +0000 (14:16 +0200)
committerToni Wilen <twilen@winuae.net>
Sun, 8 Dec 2019 12:16:48 +0000 (14:16 +0200)
hardfile.cpp
include/filesys.h
od-win32/win32gui.cpp

index dcb6d64143b1d26ca294b6082068148313f062d7..46bf16f94f16bd6cf0a2a0c041c6266255b40daa 100644 (file)
@@ -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);
index 23d4295350adbb1c964794dd76452b95fb6c9728..728c0f8ba2f42f040bdd649a2bb27ea81f7106bd 100644 (file)
@@ -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);
 
index e53d96bb75caf83d075ec31e2b662fdea2f355a6..aac580666c6e0835a8fe226f2e90a0d7cf4ace47 100644 (file)
@@ -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, &current_hfdlg.ci.pcyls, &current_hfdlg.ci.pheads, &current_hfdlg.ci.psecs, false);
                        }
+                       if (defaults && !gotrdb) {
+                               gethdfgeometry(bsize, &current_hfdlg.ci);
+                               phys = false;
+                       }
                } else {
                        current_hfdlg.forcedcylinders = current_hfdlg.ci.pcyls;
                }