endlos99 / xdt99

xdt99: TMS 99xx Cross-Development Tools
http://endlos99.github.io/xdt99
GNU General Public License v3.0
52 stars 8 forks source link

xdm99.py miscalculates sectors for double-density images #10

Closed christopherkobayashi closed 8 years ago

christopherkobayashi commented 8 years ago

Hello,

Small bug that affects double-density images -- it multiplies the sector-per-track by the density specified in the VID. This is okay for single-density images (where density = 1) but tries to set the number of sectors per track to 36 (18 * 2) for double-density images, which is wrong.

One-line patch to address this below.

Thanks ...

diff --git a/xdm99.py b/xdm99.py
index 7c8ca62..d1b0f5e 100755
--- a/xdm99.py
+++ b/xdm99.py
@@ -138,7 +138,7 @@ class Disk:
     def checkGeometry(self):
         """check geometry against sector count"""
         if (self.totalSectors !=
-                self.sides * self.density * self.tracksPerSide * self.sectorsPerTrack):
+                self.sides * self.tracksPerSide * self.sectorsPerTrack):
             self.warn("Sector count does not match disk geometry", "geom")
         if self.totalSectors % 8 != 0:
             self.warn("Sector count is not multiple of 8", "geom")
christopherkobayashi commented 8 years ago

Found one more bug, converting from DSDD40T to DSSD80T. Use this diff instead, please.

diff --git a/xdm99.py b/xdm99.py
index 7c8ca62..48c4823 100755
--- a/xdm99.py
+++ b/xdm99.py
@@ -138,7 +138,7 @@ class Disk:
     def checkGeometry(self):
         """check geometry against sector count"""
         if (self.totalSectors !=
-                self.sides * self.density * self.tracksPerSide * self.sectorsPerTrack):
+                self.sides * self.tracksPerSide * self.sectorsPerTrack):
             self.warn("Sector count does not match disk geometry", "geom")
         if self.totalSectors % 8 != 0:
             self.warn("Sector count is not multiple of 8", "geom")
@@ -362,8 +362,11 @@ class Disk:
         self.sides = sides or self.sides
         self.density = density or self.density
         self.tracksPerSide = tracks or self.tracksPerSide
+       self.sectorsPerTrack = self.density * 9
         self.image = (
-            self.image[:0x11] +
+           self.image[:0x0C] +
+           chr(self.sectorsPerTrack) +
+            self.image[0x0D:0x11] +
             "%c%c%c" % (chr(self.tracksPerSide), chr(self.sides),
                         chr(self.density)) +
             self.image[0x14:]
endlos99 commented 8 years ago

Thanks for the pull-request; has been merged.