Class: ScAsm

Inherits:
IntegerBASIC show all
Defined in:
lib/native_file_types/apple2/ScAsm.rb

Overview

require ‘IntegerBASIC’

Instance Attribute Summary

Attributes inherited from NativeFileType

#aux_code, #contents, #file_system_image, #file_type, #filename, #meta_data

Instance Method Summary collapse

Methods inherited from IntegerBASIC

file_system_file_types

Methods inherited from NativeFileType

#<=>, #==, all_native_file_types, best_fit, code_for_tests, compatability_score, #data_without_header, file_type_matches?, #full_filename, #header_length, #initialize, is_valid_file_if, #load_address, load_address, matching_score, native_file_types_possible_on_file_system, non_matching_score, #to_hex_dump, #to_info_dump, #type_description

Methods included from SubclassTracking

extended

Constructor Details

This class inherits a constructor from NativeFileType

Instance Method Details

#to_listingObject



53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
# File 'lib/native_file_types/apple2/ScAsm.rb', line 53

def to_listing
    length=contents[0]+contents[1]*256
		index=2
		s=""
		while (index<length)
			line_length=contents[index]
			line_no=contents[index+1]+contents[index+2]*256
			s+=sprintf("%d ",line_no)
			index+=3 #skip over the "line number" field
			end_of_line=index+line_length-4
			while(index<end_of_line)
				b=contents[index]
				if (b==0xC0) then
					repeat_count=contents[index+1]
					repeat_char=(contents[index+2]).chr
					s+=repeat_char*repeat_count
					index+=3
				elsif(b>=0x80) then
					s+=" "*(b-0x80)
					index+=1
				else
					s+=b.chr
					index+=1
				end
			end
			index+=1 #skip over end-of-line marker
			s+="\n"
		end
		s
end