Class: ProDOSFile

Inherits:
DSKFile show all
Defined in:
lib/ProDOSFile.rb

Overview

ProDOS file

Constant Summary collapse

PRODOS_FILE_TYPES =

ProDOS file types from “Beneath Apple DOS pp 4-10 - 4-11)

{		
0x00=>"",      #"Typeless File"
 0x01=>"BAD",  #BAD blocks file
 0x02=>"PCD",  #Pascal CoDe file
 0x03=>"PTX",  #Pascal TeXt file
 0x04=>"TXT",  #ASCII text file
 0x05=>"PDA",  #Pascal DAta file
 0x06=>"BIN",  #BINary file
 0x07=>"CHR",  #CHaRacter font file
 0x08=>"PIC",  #PICture file
 0x09=>"BA3",  #Business BASIC (SOS) program file
 0x0A=>"DA3",  #Business BASIC (SOS) data file
 0x0B=>"WPD",  #Word Processor Document
 0x0F=>"DIR",  #subDIRectory file
 0x10=>"RPD",  #RPS data file
 0x11=>"RPI",  #RPS index file
 0x19=>"ADB",  #AppleWorks Database file
 0x1A=>"AWP",  #AppleWorks WordProcessing file
 0x1B=>"ASP",  #AppleWorks Spreadsheet file
 0x60=>"PRE",  #ProDOS preboot driver
 0x6B=>"NIO",  #PC Transporter BIOS and drivers
 0x6D=>"DVR",  #PC Transporter device drivers
 0x6F=>"HDV",  #MSDOS HardDisk Volume
 0xA0=>"WPF",  #WordPerfect document file
 0xA1=>"MAC",  #Macrofile
 0xA2=>"HLP",  #Help File
 0xA3=>"DAT",  #Data File
 0xA5=>"LEX",  #Spelling dictionary
 0xAC=>"ARC",  #General Purpose Archive file
 0xB0=>"SRC",  #ORCA/M & APW source file
 0xB1=>"OBJ",  #ORCA/M & APW object file
 0xB2=>"LIB",  #ORCA/M & APW library file
 0xB3=>"S16",  #ProDOS16 system file
 0xB4=>"RTL",  #ProDOS16 runtime library
 0xB5=>"EXE",  #APW shell command file
 0xB6=>"STR",  #ProDOS16 startup init file
 0xB7=>"TSF",  #ProDOS16 temporary init file
 0xB8=>"NDA",  #ProDOS16 new desk accessory
 0xB9=>"CDA",  #ProDOS16 classic desk accessory
 0xBA=>"TOL",  #ProDOS16 toolset file
 0xBB=>"DRV",  #ProDOS16 driver file
 0xBF=>"DOC",  #document file
 0xC0=>"PNT",  #//gs paint document
 0xC1=>"SCR",  #//gs screen file
 0xC8=>"FNT",  #Printer font file
 0xE0=>"LBR",  #Apple archive library file
 0xE2=>"ATI",  #Appletalk init file
 0xEF=>"PAS",  #ProDOS Pascal file
 0xF0=>"CMD",  #added command file
 0xF1=>"OVL",  #Overlay file
 0xF2=>"DBF",  #Database file
 0xF3=>"PAD",  #MouseWrite file
 0xF4=>"MCR",  #AE Pro macro file
 0xF5=>"ECP",  #ECP batch file
 0xF6=>"DSC",  #description file
 0xF7=>"TMP",  #temporary work file
 0xF8=>"RSX",  #linkable object module
 0xF9=>"IMG",  #ProDOS image file
 0xFA=>"INT",  #Integer BASIC program
 0xFB=>"IVR",  #Integer BASIC variables file
 0xFC=>"BAS",  #AppleSoft BASIC program
 0xFD=>"VAR",  #AppleSoft BASIC variables file
 0xFE=>"REL",  #ProDOS EDASM relocatable object module file
 0xFF=>"SYS",  #ProDOS8 system file}
}

Constants inherited from DSKFile

DSKFile::APPLESOFT_TOKENS

Instance Attribute Summary collapse

Attributes inherited from DSKFile

#contents, #filename

Instance Method Summary collapse

Methods inherited from DSKFile

#==, #buffer_as_applesoft_file, #can_be_picture?, #hex_dump, #length_in_sectors, #to_ascii

Constructor Details

#initialize(filename, contents, file_type, aux_type) ⇒ ProDOSFile

Returns a new instance of ProDOSFile.



10
11
12
13
14
15
16
17
# File 'lib/ProDOSFile.rb', line 10

def initialize(filename,contents,file_type,aux_type)
	raise "filename too long - #{filename}" unless filename.length<=15
	@filename=filename
	@contents=contents
	@file_type=PRODOS_FILE_TYPES[file_type]
	@file_type=sprintf('$%02X',file_type) if @file_type.nil?
	@aux_type=aux_type
end

Instance Attribute Details

#aux_typeObject

Returns the value of attribute aux_type.



8
9
10
# File 'lib/ProDOSFile.rb', line 8

def aux_type
  @aux_type
end

#file_typeObject

Returns the value of attribute file_type.



8
9
10
# File 'lib/ProDOSFile.rb', line 8

def file_type
  @file_type
end

Instance Method Details

#file_extensionObject

ProDOS8 system file}



84
85
86
# File 'lib/ProDOSFile.rb', line 84

def file_extension
	return "."+@file_type.downcase
end

#to_sObject



88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
# File 'lib/ProDOSFile.rb', line 88

def to_s
	case @file_type
	when "BAS" then
		#applesoft detokeniser routine expects the first two bytes to be length of buffer
		buffer_length=2+contents.length
		buffer=(buffer_length%0x100).chr+(buffer_length/0x100).chr+contents
		buffer_as_applesoft_file(buffer)
	when "AWP" then
		buffer_as_awp_file(contents)			
	else
		#strip of the high bits
		s=""
		@contents.each_byte{|b| s+=(b%0x80).chr.tr(0x0D.chr,"\n")}
		s
		end
end