Class: CocoBasic
- Inherits:
-
NativeFileType
- Object
- NativeFileType
- CocoBasic
- Defined in:
- lib/native_file_types/coco/CocoBasic.rb
Constant Summary collapse
- FUNCTION_TOKENS =
[ # 00 - 0f '!', '!', '!', '!', '!', '!', '!', '!', '!', '!', '!', '!', '!', '!', '!', '!', # 10 - 1f '!', '!', '!', '!', '!', '!', '!', '!', '!', '!', '!', '!', '!', '!', '!', '!', # 20 - 2f '!', '!', '!', '!', '!', '!', '!', '!', '!', '!', '!', '!', '!', '!', '!', '!', # 30 - 3f '!', '!', '!', '!', '!', '!', '!', '!', '!', '!', '!', '!', '!', '!', '!', '!', # 40 - 4f '!', '!', '!', '!', '!', '!', '!', '!', '!', '!', '!', '!', '!', '!', '!', '!', # 50 - 5f '!', '!', '!', '!', '!', '!', '!', '!', '!', '!', '!', '!', '!', '!', '!', '!', # 60 - 6f '!', '!', '!', '!', '!', '!', '!', '!', '!', '!', '!', '!', '!', '!', '!', '!', # 70 - 7f '!', '!', '!', '!', '!', '!', '!', '!', '!', '!', '!', '!', '!', '!', '!', '!', # 80 - 8f 'SGN', 'INT', 'ABS', 'USR', 'RND', 'SIN', 'PEEK', 'LEN', 'STR$', 'VAL', 'ASC', 'CHR$', 'EOF', 'JOYSTK', 'LEFT$', 'RIGHT$', # 90 - 9f 'MID$', 'POINT', 'INKEY$', 'MEM', 'ATN', 'COS', 'TAN', 'EXP', 'FIX', 'LOG', 'POS', 'SQR', 'HEX$', 'VARPTR', 'INSTR$', 'TIMER', # a0 - af 'PPOINT', 'STRING$', 'CVN', 'FREE', 'LOC', 'LOF', 'MKN$', 'AS', "'", 'LPEEK', 'BUTTON', 'HPOINT', 'ERNO', 'ERLIN', '!', '!', # b0 - bf '!', '!', '!', '!', '!', '!', '!', '!', '!', '!', '!', '!', '!', '!', '!', '!', # c0 - cf '!', '!', '!', '!', '!', '!', '!', '!', '!', '!', '!', '!', '!', '!', '!', '!', # d0 - df '!', '!', '!', '!', '!', '!', '!', '!', '!', '!', '!', '!', '!', '!', '!', '!', # e0 - ef '!', '!', '!', '!', '!', '!', '!', '!', '!', '!', '!', '!', '!', '!', '!', '!', # f0 - ff '!', '!', '!', '!', '!', '!', '!', '!', '!', '!', '!', '!', '!', '!', '!', '!', ]
- COMMAND_TOKENS =
[ # 00 - 0f '!', '!', '!', '!', '!', '!', '!', '!', '!', '!', '!', '!', '!', '!', '!', '!', # 10 - 1f '!', '!', '!', '!', '!', '!', '!', '!', '!', '!', '!', '!', '!', '!', '!', '!', # 20 - 2f '!', '!', '!', '!', '!', '!', '!', '!', '!', '!', '!', '!', '!', '!', '!', '!', # 30 - 3f '!', '!', '!', '!', '!', '!', '!', '!', '!', '!', '!', '!', '!', '!', '!', '!', # 40 - 4f '!', '!', '!', '!', '!', '!', '!', '!', '!', '!', '!', '!', '!', '!', '!', '!', # 50 - 5f '!', '!', '!', '!', '!', '!', '!', '!', '!', '!', '!', '!', '!', '!', '!', '!', # 60 - 6f '!', '!', '!', '!', '!', '!', '!', '!', '!', '!', '!', '!', '!', '!', '!', '!', # 70 - 7f '!', '!', '!', '!', '!', '!', '!', '!', '!', '!', '!', '!', '!', '!', '!', '!', # 80 - 8f 'FOR', 'GO', 'REM', "'", 'ELSE', 'IF', 'DATA', 'PRINT', 'ON', 'INPUT', 'END', 'NEXT', 'DIM', 'READ', 'RUN', 'RESTORE', # 90 - 9f 'RETURN', 'STOP', 'POKE', 'CONT', 'LIST', 'CLEAR', 'NEW', 'CLOAD', 'CSAVE', 'OPEN', 'CLOSE', 'LLIST', 'SET', 'RESET', 'CLS', 'MOTOR', # a0 - af 'SOUND', 'AUDIO', 'EXEC', 'SKIPF', 'TAB(', 'TO', 'SUB', 'THEN', 'NOT', 'STEP', 'OFF', '+', '-', '*', '/', '^', # b0 - bf 'AND', 'OR', '>', '=', '<', 'DEL', 'EDIT', 'TRON', 'TROFF', 'DEF', 'LET', 'LINE', 'PCLS', 'PSET', 'PRESET', 'SCREEN', # c0 - cf 'PCLEAR', 'COLOR', 'CIRCLE', 'PAINT', 'GET', 'PUT', 'DRAW', 'PCOPY', 'PMODE', 'PLAY', 'DLOAD', 'RENUM', 'FN', 'USING', 'DIR', 'DRIVE', # d0 - df 'FIELD', 'FILES', 'KILL', 'LOAD', 'LSET', 'MERGE', 'RENAME', 'RSET', 'SAVE', 'WRITE', 'VERIFY', 'UNLOAD', 'DSKINI', 'BACKUP', 'COPY', 'DSKI$', # e0 - ef 'DSKO$', 'DOS', 'WIDTH', 'PALETTE', 'HSCREEN', 'LPOKE', 'HCLS', 'HCOLOR', 'HPAINT', 'HCIRCLE', 'HLINE', 'HGET', 'HPUT', 'HBUFF', 'HPRINT', 'ERR', # f0 - ff 'BRK', 'LOCATE', 'HSTAT', 'HSET', 'HRESET', 'HDRAW', 'CMP', 'RGB', 'ATTR', '!', '!', '!', '!', '!', '!', '!', ]
Instance Attribute Summary
Attributes inherited from NativeFileType
#aux_code, #contents, #file_system_image, #file_type, #filename, #meta_data
Class Method Summary collapse
-
.file_system_file_types ⇒ Object
BASIC files have a filetype of 0 aux_code determines whether file is tokenised or ASCII.
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
.file_system_file_types ⇒ Object
BASIC files have a filetype of 0 aux_code determines whether file is tokenised or ASCII
8 9 10 11 12 |
# File 'lib/native_file_types/coco/CocoBasic.rb', line 8 def self.file_system_file_types { RsDos=>0 } end |
Instance Method Details
#to_listing ⇒ Object
146 147 148 149 150 151 152 153 154 155 156 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 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 |
# File 'lib/native_file_types/coco/CocoBasic.rb', line 146 def to_listing return contents if aux_code==0xFF #Aux Code is "ASCII FLAG" s="" p=0 if contents[p] == 0xff then p+=1 file_size = contents[p]<<8 p+=1 file_size += contents[p] p+=1 # raise "Binary CoCo BASIC file format inconsistant (file size record was = $#{"%X" % file_size}, real file size=$#{"%X" % (contents.length-3)}" if file_size != (contents.length-3) end value = contents[p]<<8 p+=1 value += contents[p] p+=1 while (p<contents.length-2) && (value != 0) line_number = contents[p]<<8 p+=1 line_number += contents[p] p+=1 s+= "#{line_number} " character = contents[p] p+=1 while (p<contents.length-1) && (character != 0) if character == 0xff then character = contents[p] p+=1 s+=FUNCTION_TOKENS[character] elsif character >= 0x80 s+=COMMAND_TOKENS[character] elsif character == 0x3a && (contents[p] == 0x83 || contents[p] == 0x84 ) #When colon-apostrophe is encountered, the colon is dropped. */ #When colon-ELSE is encountered, the colon is dropped. */ else s+=(character % 0x80).chr end character = contents[p] p+=1 end s+="\n" value = contents[p]<<8 p+=1 value += contents[p] unless contents[p].nil? p+=1 end s end |