lib/file_systems/TrsDos.rb in ripxplore-0.0.1 vs lib/file_systems/TrsDos.rb in ripxplore-0.0.2
- old
+ new
@@ -5,11 +5,12 @@
$:.include?(File.dirname(__FILE__+"\\..")) || $:.include?(File.expand_path(File.dirname(__FILE__+"\\..")))
require 'FileSystem'
#TRSDOS (and compatables, e.g. LDOS, NEWDOS)
-#Reference - http://www.classic-computers.org.nz/system-80/software-manuals/manuals-NewDOS-80_v2.0_manual.pdf pages 99-101
+#Reference - http://www.fileden.com/files/2008/7/6/1990698/manuals-NewDOS-80_v2.0_manual.pdf pages 99-101
+#(previous location - http://www.classic-computers.org.nz/system-80/software-manuals/manuals-NewDOS-80_v2.0_manual.pdf )
#sectors 2-9 of the directory track (17) contain File Primary Directory Entries, which are 32 bytes made up of:
# byte $00:
# bit 7 : 0 = FPDE, 1 = FXDE
# bit 6 : 1 means a SYSTEM file
# bit 5 : undefined
@@ -64,13 +65,13 @@
#for now, only SSSD images are supported
def self.sectors_per_granule(file_system_image)
5
end
+#all TRS-80 disks seem to start with the same bytes
is_valid_file_system_if lambda {
- file_system_image.image_format.instance_of?(Trs80Jv1Dsk)
-}
+ file_system_image.get_sector(0,0)[0,3]==[0x00,0xFE,0x11].pack("CCC") }
FDE_SIZE=0x20
def self.files(file_system_image)
files=FileContainer.new
@@ -86,11 +87,11 @@
#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("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
@@ -100,13 +101,15 @@
# 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
+ #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)