formats.py 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167
  1. # greaseweazle/codec/formats.py
  2. #
  3. # Written & released by Keir Fraser <keir.xen@gmail.com>
  4. #
  5. # This is free and unencumbered software released into the public domain.
  6. # See the file COPYING for more details, or visit <http://unlicense.org>.
  7. from greaseweazle.tools import util
  8. class Format:
  9. adf_compatible = False
  10. img_compatible = False
  11. default_trackset = 'c=0-79:h=0-1'
  12. max_trackset = 'c=0-81:h=0-1'
  13. def __init__(self):
  14. self.default_tracks = util.TrackSet(self.default_trackset)
  15. self.max_tracks = util.TrackSet(self.max_trackset)
  16. self.decode_track = self.fmt.decode_track
  17. class Format_Amiga_AmigaDOS_DD(Format):
  18. adf_compatible = True
  19. def __init__(self):
  20. import greaseweazle.codec.amiga.amigados as m
  21. self.fmt = m.AmigaDOS_DD
  22. self.default_revs = m.default_revs
  23. super().__init__()
  24. class Format_Amiga_AmigaDOS_HD(Format):
  25. adf_compatible = True
  26. def __init__(self):
  27. import greaseweazle.codec.amiga.amigados as m
  28. self.fmt = m.AmigaDOS_HD
  29. self.default_revs = m.default_revs
  30. super().__init__()
  31. class Format_IBM_180(Format):
  32. img_compatible = True
  33. default_trackset = 'c=0-39:h=0'
  34. max_trackset = 'c=0-41:h=0'
  35. def __init__(self):
  36. import greaseweazle.codec.ibm.mfm as m
  37. self.fmt = m.IBM_MFM_720
  38. self.default_revs = m.default_revs
  39. super().__init__()
  40. class Format_IBM_360(Format):
  41. img_compatible = True
  42. default_trackset = 'c=0-39:h=0-1'
  43. max_trackset = 'c=0-41:h=0-1'
  44. def __init__(self):
  45. import greaseweazle.codec.ibm.mfm as m
  46. self.fmt = m.IBM_MFM_720
  47. self.default_revs = m.default_revs
  48. super().__init__()
  49. class Format_IBM_720(Format):
  50. img_compatible = True
  51. def __init__(self):
  52. import greaseweazle.codec.ibm.mfm as m
  53. self.fmt = m.IBM_MFM_720
  54. self.default_revs = m.default_revs
  55. super().__init__()
  56. class Format_IBM_800(Format):
  57. img_compatible = True
  58. def __init__(self):
  59. import greaseweazle.codec.ibm.mfm as m
  60. self.fmt = m.IBM_MFM_800
  61. self.default_revs = m.default_revs
  62. super().__init__()
  63. class Format_IBM_1440(Format):
  64. img_compatible = True
  65. def __init__(self):
  66. import greaseweazle.codec.ibm.mfm as m
  67. self.fmt = m.IBM_MFM_1440
  68. self.default_revs = m.default_revs
  69. super().__init__()
  70. class Format_IBM_1200(Format):
  71. img_compatible = True
  72. def __init__(self):
  73. import greaseweazle.codec.ibm.mfm as m
  74. self.fmt = m.IBM_MFM_1200
  75. self.default_revs = m.default_revs
  76. super().__init__()
  77. class Format_AtariST_360(Format):
  78. img_compatible = True
  79. default_trackset = 'c=0-79:h=0'
  80. max_trackset = 'c=0-81:h=0'
  81. def __init__(self):
  82. import greaseweazle.codec.ibm.mfm as m
  83. self.fmt = m.AtariST_SS_9SPT
  84. self.default_revs = m.default_revs
  85. super().__init__()
  86. class Format_AtariST_400(Format):
  87. img_compatible = True
  88. default_trackset = 'c=0-79:h=0'
  89. max_trackset = 'c=0-81:h=0'
  90. def __init__(self):
  91. import greaseweazle.codec.ibm.mfm as m
  92. self.fmt = m.AtariST_10SPT
  93. self.default_revs = m.default_revs
  94. super().__init__()
  95. class Format_AtariST_440(Format):
  96. img_compatible = True
  97. default_trackset = 'c=0-79:h=0'
  98. max_trackset = 'c=0-81:h=0'
  99. def __init__(self):
  100. import greaseweazle.codec.ibm.mfm as m
  101. self.fmt = m.AtariST_11SPT
  102. self.default_revs = m.default_revs
  103. super().__init__()
  104. class Format_AtariST_720(Format):
  105. img_compatible = True
  106. def __init__(self):
  107. import greaseweazle.codec.ibm.mfm as m
  108. self.fmt = m.AtariST_DS_9SPT
  109. self.default_revs = m.default_revs
  110. super().__init__()
  111. class Format_AtariST_800(Format):
  112. img_compatible = True
  113. def __init__(self):
  114. import greaseweazle.codec.ibm.mfm as m
  115. self.fmt = m.AtariST_10SPT
  116. self.default_revs = m.default_revs
  117. super().__init__()
  118. class Format_AtariST_880(Format):
  119. img_compatible = True
  120. def __init__(self):
  121. import greaseweazle.codec.ibm.mfm as m
  122. self.fmt = m.AtariST_11SPT
  123. self.default_revs = m.default_revs
  124. super().__init__()
  125. formats = {
  126. 'amiga.amigados': Format_Amiga_AmigaDOS_DD,
  127. 'amiga.amigados_hd': Format_Amiga_AmigaDOS_HD,
  128. 'ibm.180': Format_IBM_180,
  129. 'ibm.360': Format_IBM_360,
  130. 'ibm.720': Format_IBM_720,
  131. 'ibm.1200': Format_IBM_1200,
  132. 'ibm.1440': Format_IBM_1440,
  133. 'atarist.360': Format_AtariST_360,
  134. 'atarist.400': Format_AtariST_400,
  135. 'atarist.440': Format_AtariST_440,
  136. 'atarist.720': Format_AtariST_720,
  137. 'atarist.800': Format_AtariST_800,
  138. 'atarist.880': Format_AtariST_880,
  139. 'commodore.1581': Format_IBM_800,
  140. }
  141. def print_formats(f = None):
  142. s = ''
  143. for k, v in sorted(formats.items()):
  144. if not f or f(k, v):
  145. if s:
  146. s += '\n'
  147. s += ' ' + k
  148. return s