Class: Trs80LevelIIBasic
- Inherits:
-
NativeFileType
- Object
- NativeFileType
- Trs80LevelIIBasic
- Defined in:
- lib/native_file_types/trs80/Trs80LevelIIBasic.rb
Constant Summary collapse
- SINGLE_BYTE_TOKENS =
{ 0x80=>'END', 0x81=>'FOR', 0x82=>'RESET', 0x83=>'SET', 0x84=>'CLS', 0x85=>'CMD', 0x86=>'RANDOM', 0x87=>'NEXT', 0x88=>'DATA', 0x89=>'INPUT', 0x8A=>'DIM', 0x8B=>'READ', 0x8C=>'LET', 0x8D=>'GOTO', 0x8E=>'RUN', 0x8F=>'IF', 0x90=>'RESTORE', 0x91=>'GOSUB', 0x92=>'RETURN', 0x93=>'REM', 0x94=>'STOP', 0x95=>'ELSE', 0x96=>'TRON', 0x97=>'TROFF', 0x98=>'DEFSTR', 0x99=>'DEFINT', 0x9A=>'DEFSNG', 0x9B=>'DEFDBL', 0x9C=>'LINE', 0x9D=>'EDIT', 0x9E=>'ERROR', 0x9F=>'RESUME', 0xA0=>'OUT', 0xA1=>'ON', 0xA2=>'OPEN', 0xA3=>'FIELD', 0xA4=>'GET', 0xA5=>'PUT', 0xA6=>'CLOSE', 0xA7=>'LOAD', 0xA8=>'MERGE', 0xA9=>'NAME', 0xAA=>'KILL', 0xAB=>'LSET', 0xAC=>'RSET', 0xAD=>'SAVE', 0xAE=>'SYSTEM', 0xAF=>'LPRINT', 0xB0=>'DEF', 0xB1=>'POKE', 0xB2=>'PRINT', 0xB3=>'CONT', 0xB4=>'LIST', 0xB5=>'LLIST', 0xB6=>'DELETE', 0xB7=>'AUTO', 0xB8=>'CLEAR', 0xB9=>'CLOAD', 0xBA=>'CSAVE', 0xBB=>'NEW', 0xBC=>'TAB(', 0xBD=>'TO', 0xBE=>'FN', 0xBF=>'USING', 0xC0=>'VARPTR', 0xC1=>'USR', 0xC2=>'ERL', 0xC3=>'ERR', 0xC4=>'STRING$', 0xC5=>'INSTR', 0xC6=>'POINT', 0xC7=>'TIME$', 0xC8=>'MEM', 0xC9=>'INKEY$', 0xCA=>'THEN', 0xCB=>'NOT', 0xCC=>'STEP', 0xCD=>'+', 0xCE=>'-', 0xCF=>'*', 0xD0=>'/', 0xD1=>'[', 0xD2=>'AND', 0xD3=>'OR', 0xD4=>'>', 0xD5=>'=', 0xD6=>'<', 0xD7=>'SGN', 0xD8=>'INT', 0xD9=>'ABS', 0xDA=>'FRE', 0xDB=>'INP', 0xDC=>'POS', 0xDD=>'SQR', 0xDE=>'RND', 0xDF=>'LOG', 0xE0=>'EXP', 0xE1=>'COS', 0xE2=>'SIN', 0xE3=>'TAN', 0xE4=>'ATN', 0xE5=>'PEEK', 0xE6=>'CVI', 0xE7=>'CVS', 0xE8=>'CVD', 0xE9=>'EOF', 0xEA=>'LOC', 0xEB=>'LOF', 0xEC=>'MKI$', 0xED=>'MKS$', 0xEE=>'MKD$', 0xEF=>'CINT', 0xF0=>'CSNG', 0xF1=>'CDBL', 0xF2=>'FIX', 0xF3=>'LEN', 0xF4=>'STR$', 0xF5=>'VAL', 0xF6=>'ASC', 0xF7=>'CHR$', 0xF8=>'LEFT$', 0xF9=>'RIGHT$', 0xFA=>'MID$', 0xFB=>"'", }
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
-
#matching_score ⇒ Object
make sure if we match, we override CMD.
- #to_listing ⇒ Object
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
.file_system_file_types ⇒ Object
6 7 8 9 10 |
# File 'lib/native_file_types/trs80/Trs80LevelIIBasic.rb', line 6 def self.file_system_file_types { TrsDos=>:any } end |
Instance Method Details
#matching_score ⇒ Object
make sure if we match, we override CMD
25 26 27 |
# File 'lib/native_file_types/trs80/Trs80LevelIIBasic.rb', line 25 def matching_score Trs80Cmd.matching_score+1 end |
#to_listing ⇒ Object
157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 |
# File 'lib/native_file_types/trs80/Trs80LevelIIBasic.rb', line 157 def to_listing s="" p=1 while(p<contents.length-2) && !((contents[p]==0) && (contents[p+1]==0)) p+=2 #skip the 2 byte pointer to the start of next line line_number=contents[p]+(contents[p+1]<<8) p+=2 s+= "#{line_number} " in_quotes=false in_remark=false while(p<contents.length) && (contents[p]!=0) c=contents[p] p+=1 in_quotes=!in_quotes if (c.chr=='"') if (in_quotes or in_remark or (c<0x80)) then s+=(c%0x80).chr else token=SINGLE_BYTE_TOKENS[c] s+=(token.nil?) ? sprintf("[%02X]",c):token in_remark=true if (c==0x93) end end s+="\n" p+=1 end s end |