$:.unshift(File.dirname(__FILE__)) unless $:.include?(File.dirname(__FILE__)) || $:.include?(File.expand_path(File.dirname(__FILE__))) $:.unshift(File.dirname(__FILE__+"\\..")) unless $:.include?(File.dirname(__FILE__+"\\..")) || $:.include?(File.expand_path(File.dirname(__FILE__+"\\.."))) require 'ImageFormat' #A2 DSK with "physical" ordering class A2Dsk < ImageFormat def A2Dsk.possible_extensions ['.dsk','.do','.po'] end def A2Dsk.host_system Apple2 end #to be overriden in each subclass with a table showing what order logical sectors are stored def A2Dsk.interleave nil end def sectors_in_track(track_no) (0..0x0f).collect end def track_count file_bytes.length/4096 end def get_sector(track,sector) return nil if self.class.interleave.nil? return nil unless sector.between?(0,0x0F) physical_sector=self.class.interleave[sector] start_byte=track*16*256+physical_sector*256 file_bytes[start_byte,256] end end class A2DskPhysicalOrder < A2Dsk def A2DskPhysicalOrder.interleave [0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09,0x0A,0x0B,0x0C,0x0D,0x0E,0x0F] end end class A2DskDosOrder < A2Dsk def A2DskDosOrder.interleave [0x00,0x0E,0x0D,0x0C,0x0B,0x0A,0x09,0x08,0x07,0x06,0x05,0x04,0x03,0x02,0x01,0x0F] end end # == Author # Jonno Downes (jonno@jamtronix.com) # # == Copyright # Copyright (c) 2007 Jonno Downes (jonno@jamtronix.com) # #Permission is hereby granted, free of charge, to any person obtaining #a copy of this software and associated documentation files (the #"Software"), to deal in the Software without restriction, including #without limitation the rights to use, copy, modify, merge, publish, #distribute, sublicense, and/or sell copies of the Software, and to #permit persons to whom the Software is furnished to do so, subject to #the following conditions: # The above copyright notice and this permission notice shall be # included in all copies or substantial portions of the Software. # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.