For the new calculator casio graph 85, Fa-124 use a binary format named g1r instead of the cat format. This format can save many record in one file and support all casio kind of data. G1r files are ended by .g1r
In this format, programs are stored in the raw format, inside a bloc of metadata with a fix size. Those metadata contain the name of the program and if the program use bas operations or not. Programs and metadata can be extracted from a g1r file with a regular expression (here in python with the re module):
g1r_file = open(filename, 'r') # Regular expression: data_pattern = re.compile(''' (PROGRAM) # kind of data (only programs with this regexp) [\x00]{12} # Separator [\x01] # one 0x01 (separator) system # The 'system' string [\x00]{2} # Separator ([^\x00]{1,8}) # name of the program [\x00]{0,7} # 0x00 to complete the name [\x01] # mark of the end of the name [\x00]{2} # Separator .{2} # two characters (?) [\x00]{11} # Separation (\x00|\x01) # Base (0x01) or not (0x00) (.*[^\x00]) # all characters, ended by a non 0x00 characters: raw data without the 0xFF end character [\x00]{2} # end of the record ''', re.VERBOSE) # extract data from the file data_list = data_pattern.findall(g1r_file.read()) g1r_file.close() for record in data_list: # record = ('DATA TYPE', 'FILE NAME', 'BASE', 'RAW DATA') data_type = record[0] data_name = record[1] if record[2] == '\x01': use_base = True else: use_base = False raw_data = record[3] + '\x0d\xff' #adding the raw end character
The extraction of a picture from a g1r file is done in two steps.
This may be done with a regular expression, here in python, with the re module:
# Make the regular expression picture_pattern = re.compile(''' (PICTURE[ ][1-6]) # data name [\x00]{10} # Separator [\x01] # one 0x01 character main # The 'main' string [\x00]{4} # Separator (PICT[1-6]) # name (#2) [\x00]{3} # Separator [\x07][\x00]{2} [\x08][\x00]{4} (.{1024}) # Sheet1 (.{1024}) # Sheet2 ''', re.VERBOSE | re.DOTALL) g1r_file = open(filename, 'r') picture_list = picture_pattern.findall(g1r_file.read()) g1r_file.close() for record in picture_list: # record = ('DATA NAME #1', 'DATA NAME #2', 'SHEET1', 'SHEET2') data_name = 'Picture' + record[0][-1] sheet1 = record[2] sheet2 = record[3]
You get the picture under the form of two sheet, each one code a color.
Each sheet is 1024 byte long. 16 following byte represent a row, where each bit represents one pixel: if the value of the bit is 1, the value of the pixel is the color of the sheet. Bit are sorted in row from the left to the right ; row are sorted from the top to the bottom.