Class: SCAsmFile

Inherits:
DOSFile show all
Defined in:
lib/DOSFile.rb

Constant Summary

Constants inherited from DSKFile

DSKFile::APPLESOFT_TOKENS

Instance Attribute Summary

Attributes inherited from DOSFile

#contents, #filename, #locked

Attributes inherited from DSKFile

#contents, #filename

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from DOSFile

#catalog_filename, catalog_filename, #initialize

Methods inherited from DSKFile

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

Constructor Details

This class inherits a constructor from DOSFile

Class Method Details

.can_be_scasm_file?(buffer) ⇒ Boolean

Returns:

  • (Boolean)


365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
# File 'lib/DOSFile.rb', line 365

def SCAsmFile.can_be_scasm_file?(buffer)
	if buffer.length<2 then
		return false
	end
	length=buffer[0]+buffer[1]*256
	index=2
	s=""
	while (index<length)
		line_length=buffer[index]
		line_no=buffer[index+1]+buffer[index+2]*256
		index+=3 #skip over the "line number" field
		#S-C Assembler lines always ends with a 0x00 
		if ( buffer[index+line_length-4] != 0x00 )
			return false
		end
		buffer[index..index+line_length-3].each_byte do |b|
				if b>0xc0 then
					return false
				end
		end
		index+= (line_length-3).abs
	end
	return true
end

Instance Method Details

#file_extensionObject



361
362
363
# File 'lib/DOSFile.rb', line 361

def file_extension
	".asm"
end

#file_typeObject



348
349
350
# File 'lib/DOSFile.rb', line 348

def file_type
	"I"
end

#file_type_byteObject



352
353
354
# File 'lib/DOSFile.rb', line 352

def file_type_byte
	0x01
end

#to_sObject

display file with all tokens expanded



357
358
359
# File 'lib/DOSFile.rb', line 357

def to_s
	SCAsmFile.buffer_as_scasm_file(@contents)
end