Class: TrsDos

Inherits:
FileSystem show all
Defined in:
lib/file_systems/TrsDos.rb

Overview

of the FDE.

Constant Summary collapse

FDE_SIZE =
0x20

Class Method Summary collapse

Methods inherited from FileSystem

all_file_systems, code_for_tests, compatability_score, is_valid_file_system_if, matching_score, non_matching_score

Methods included from SubclassTracking

extended

Class Method Details

.directory_trackObject

standard TRSDOS has directory on track 17



61
62
63
# File 'lib/file_systems/TrsDos.rb', line 61

def self.directory_track
  0x11
end

.files(file_system_image) ⇒ Object



76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
# File 'lib/file_systems/TrsDos.rb', line 76

def self.files(file_system_image)
  files=FileContainer.new
  granule_allocation_table=file_system_image.get_sector(directory_track,0)
  return files if granule_allocation_table.nil?
  file_system_image.volume_name=granule_allocation_table[0xd0,8].unpack("A*")
  (file_system_image.sectors_in_track(directory_track)-[0,1]).each do |sector_no|
    fde_sector=file_system_image.get_sector(directory_track,sector_no)
    (fde_sector.length/FDE_SIZE).times do |fde_number|
      fde=fde_sector[fde_number*FDE_SIZE,FDE_SIZE]
      attributes=fde[0x00]
      
      #for a valid FPDE, bit 7 is 0 and bite 4 is 1
      is_fpde  = ((attributes & 0b10010000)==(0b00010000))
      next if !is_fpde 
      eof_low=fde[0x03]
      filename_base=fde[0x05,8].unpack("A8")
      filename_extension=fde[0x0D,3].unpack("A3")
      filename="#{filename_base}/#{filename_extension}"
      contents=""
      eof_mid=fde[0x14]
      eof_high=fde[0x15]
      file_length=(eof_high<<16)+(eof_mid<<8)+eof_low
      if (eof_low>0) then
        file_length-=0x100
      end
# byte $16 - $1F : 5 pairs of extent elements, each pair made up of:
#     byte $00 : if $FF, then end of extent elements for this file. if $FE, then next byte contains the DEC for the first (or next) FXDE assigned to this file.
#                     any other value ($00-$FD) equals the number of the diskette's lump in which the area starts. 
#     byte $01  : bits 7-5 = number of granules (0-7) from the start of the lump to the start of the area
#                   : bits 4- 0 = number less one of contiguous granules assigned to this area.

      5.times do |extent_no|
        extent=fde[(extent_no*2)+0x16,2]
        break if extent[0]==0xFF
        #raise "FXDE's not implemented yet" if extent[0]==0xFE
        break if extent[0]==0xFE # "FXDE's not implemented yet"
        track_no=extent[0]
        granule_offset=extent[1]>>5
        number_of_granules=1+(extent[1] & 0b00011111)
        start_sector=granule_offset*sectors_per_granule(file_system_image)
        number_of_sectors=number_of_granules*sectors_per_granule(file_system_image)
        number_of_sectors.times {|i| contents<<file_system_image.get_sector(track_no,start_sector+i)}        
      end
      contents=contents[0,file_length]
      files<<NativeFileType.best_fit(file_system_image,filename,contents,filename_extension)      
    end
  end
  files
end

.host_systemObject



56
57
58
# File 'lib/file_systems/TrsDos.rb', line 56

def self.host_system
  Trs80
end

.sectors_per_granule(file_system_image) ⇒ Object

for now, only SSSD images are supported



66
67
68
# File 'lib/file_systems/TrsDos.rb', line 66

def self.sectors_per_granule(file_system_image)
  5
end