Class: NADOLTokenisedFile

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

Overview

file packed by the NADOL EDITOR application. format is a series of unnumbered lines, where each line has the following format:

<Length>     (8-bit: including length byte, line no, contents, zero>
<Tokens and/orCharacters>
<Zero byte>  ($00, to mark the end of the S-C Asm source line)

each byte in the line is interpreted as follows: $00 - end of line marker $01 - $64 - NADOL tokens $65-$70 - ??? unknown $71 - $7f - 1 to F spaces $80-$FF - ASCII character with high bit set

Constant Summary collapse

NADOL_EDITOR_TOKENS =
[
	"?",		#00 (so we can use token as an index in to this array)
	"READ(",	#01
	"FREE(",	#02
	"NOT(",	#03
	"LENGTH(",	#04
	"PDL(",	#05
	"SIZEOF(",	#06
	"LSCRN(",	#07
	"HSCRN(",	#08
	"CHECK(",	#09
	"MAKE(",	#0a
	"SCREEN(",	#0b
	"HEXPACK ",#0c
	"PROCEDURE ",#0d
	"ENDPROC",	#0e
	"FUNCTION ",#0f
	"ENDFUNC",	#10
	"IF ",	#11
	"ELSE",	#12
	"ENDIF",	#13
	"WHILE ",	#14
	"ENDWHILE",#15
	"DEFINE ",	#16
	"RESULT=",	#17
	"PRINT",	#18
	"PRINTHEX",#19
	"PRINTBYTE",#1a
	"LABEL ",	#1b
	"GOTO ",	#1c
	"INVERSE",	#1d
	"NORMAL",	#1e
	"FLASH",	#1f
	"CASE ",	#20
	"GOTOXY(",	#21
	"CLEAR",	#22
	"NEW",	#23
	"HOME",	#24
	"CLREOL",	#25
	"CLREOP",	#26
	"PRBLOCK(",#27
	"STOP",	#28
	"COPY(",	#29
	"FILL(",	#2a
	"MASK(",	#2b
	"RSECT(",	#2c
	"WSECT(",	#2d
	"RBLOCK(",	#2e
	"WBLOCK(",	#2f
	"WTRACK(",	#30
	"WSYNC(",	#31
	"RECAL(",	#32
	"DISPLAY(",#33
	"RTRACK(",	#34
	"RSYNC(",	#35
	"BEEP(",	#36
	"DISASM(",	#37
	"TEXT",	#38
	"FORMAT(",	#39
	"SETFORMAT(",#3a
	"WORKDRIVE ",#3b
	"INIT ",	#3c
	"LOAD ",	#3d
	"SAVE ",	#3e
	"CATALOG",	#3f
	"DELETE ",	#40
	"RENAME ",	#41
	"PACK ",	#42
	"CONVERT(",#43
	"INPUT(",	#44
	"LORES",	#45
	"PLOT(",	#46
	"HLINE(",	#47
	"VLINE(",	#48
	"COLOR=",	#49
	"FIND(",	#4a
	"HIRES",	#4b
	"HCOLOR=",	#4c
	"HPLOT",	#4d
	"CALL(",	#4e
	"PR#",	#4f
	"IN#",	#50
	"FILTER(",	#51
	"LIST",	#52
	"RUN",	#53
	"AUXMOVE(",#54
	"LCMOVE(",	#55
	"DELAY(",	#56
	"INTEGER",	#57
	"BYTE",	#58
	" AND ",	#59
	" OR ",	#5a
	" MOD ",	#5b
	" XOR ",	#5c
	" WITH ",	#5d
	" TO ",	#5e
	" AT ",	#5f
	"TAB(",	#60
	"ENDCASE",	#61
	"MON:",	#62
	"EDIT",	#63
	"SAVE@"	#64
]

Instance Attribute Summary

Attributes inherited from NADOLFile

#contents, #filename

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from NADOLFile

#hex_dump, #initialize

Constructor Details

This class inherits a constructor from NADOLFile

Class Method Details

.can_be_nadol_tokenised_file?(buffer) ⇒ Boolean

check whether a given series of bytes can be a valid NADOL tokenised file heuristics are:

  • bytes

Returns:

  • (Boolean)


168
169
170
171
172
173
174
175
176
177
178
179
180
# File 'lib/NADOLFile.rb', line 168

def  NADOLTokenisedFile.can_be_nadol_tokenised_file?(buffer)
	r=true
	i=0
	while i<buffer.length
		line_length=buffer[i]
		if buffer[i+line_length-1]!=0 then
			r=false
			break
		end
		i+=line_length
	end
	r
end

Instance Method Details

#file_extensionObject



185
186
187
# File 'lib/NADOLFile.rb', line 185

def file_extension
	".nad"
end

#to_sObject



182
183
184
# File 'lib/NADOLFile.rb', line 182

def to_s
	NADOLTokenisedFile.buffer_as_tokenised_file(@contents)
end