Class: Applesoft
- Inherits:
-
NativeFileType
- Object
- NativeFileType
- Applesoft
- Defined in:
- lib/native_file_types/apple2/Applesoft.rb
Constant Summary collapse
- APPLESOFT_TOKENS =
[ "END","FOR","NEXT","DATA","INPUT","DEL","DIM","READ", "GR","TEXT","PR#","IN#","CALL","PLOT","HLIN","VLIN", "HGR2","HGR","HCOLOR=","HPLOT","DRAW","XDRAW","HTAB", "HOME","ROT=","SCALE=","SHLOAD","TRACE","NOTRACE", "NORMAL","INVERSE","FLASH","COLOR=","POP","VTAB", "HIMEM=","LOMEM=","ONERR","RESUME","RECALL","STORE", "SPEED=","LET","GOTO","RUN","IF","RESTORE","&","GOSUB", "RETURN","REM","STOP","ON","WAIT","LOAD","SAVE","DEF", "POKE","PRINT","CONT","LIST","CLEAR","GET","NEW", "TAB(","TO","FN","SPC(","THEN","AT","NOT","STEP","+", "-","*","/","^","AND","OR",">","=","<","SGN","INT", "ABS","USR","FRE","SCRN(","PDL","POS","SQR","RND", "LOG","EXP","COS","SIN","TAN","ATN","PEEK","LEN", "STR$","VAL","ASC","CHR$", "LEFT$","RIGHT$","MID$","?", "?","?","?","?","?","?","?","?","?","?","?","?","?","?","?","?","?","?","?","?" ]
Instance Attribute Summary
Attributes inherited from NativeFileType
#aux_code, #contents, #file_system_image, #file_type, #filename, #meta_data
Class Method Summary collapse
Instance Method Summary collapse
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
Constructor Details
This class inherits a constructor from NativeFileType
Class Method Details
Instance Method Details
#to_listing ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 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 83 84 85 86 87 88 |
# File 'lib/native_file_types/apple2/Applesoft.rb', line 29 def to_listing # Adapted from FID.C -- a utility to browse Apple II .DSK image files by Paul Schlyter ([email protected]) # #Applesoft file format: # <Length_of_file> (16-bit little endian) (only for Apple DOS files - these 2 bytes are not present in Applesoft file on ProDOS) # <Line> # ...... # <Line> # where <Line> is: # <Next addr> (16-bit little endian) # <Line no> (16-bit little endian: 0-65535) # <Tokens and/or characters> # <End-of-line marker: $00 > # if (file_system_image.file_system)==AppleDos then length=contents[0]+contents[1]*256 index=2 else length=contents.length index=0 end s="" while (index<length) index+=2 #skip over the "next address" field break if contents[index].nil? break if contents[index+1].nil? line_no=contents[index]+contents[index+1]*256 index+=2 #skip over the "line number" field s+=sprintf("%u",line_no) done_line=false last_char_space=false inside_quotes=true while (!done_line) b=contents[index] break if b.nil? inside_quotes=!inside_quotes if b==0x22 if b>=0x80 then if inside_quotes then if !last_char_space then s+=" " end s+=APPLESOFT_TOKENS[b-0x80]+" " last_char_space=true else s+=(b-0x80).chr #if we're inside quotes, bytes >80 are inverse text. but we'll just display them as normal text end else s+=b.chr last_char_space=false end index+=1 done_line=(index>=length)||(contents[index]==0) end s+="\n" index+=1 # skip over "end of line" marker end #s s end |