Class: Badline::Storage::DiskImage

Inherits:
Object
  • Object
show all
Defined in:
lib/badline/storage/disk_image.rb

Direct Known Subclasses

D64Image, D81Image

Constant Summary collapse

SECTOR_SIZE =
256
ENTRY_SIZE =
32
ENTRIES_PER_SECTOR =
8
FILETYPE_PRG =
0x02
NAME_PADDING =
0xa0

Instance Method Summary collapse

Constructor Details

#initialize(path) ⇒ DiskImage

Returns a new instance of DiskImage.



12
13
14
# File 'lib/badline/storage/disk_image.rb', line 12

def initialize(path)
  @bytes = File.binread(path).bytes
end

Instance Method Details

#read_file(name) ⇒ Object



16
17
18
19
20
# File 'lib/badline/storage/disk_image.rb', line 16

def read_file(name)
  pattern = Storage.matcher(name)
  entry = entries.find { |e| pattern.match?(e[:name]) }
  read_chain(entry[:track], entry[:sector]) if entry
end