File format of .85G files ========================= Compiled by David Brodbeck (gull@cyberspace.com) Corrections by Magnus Hagander (mha@algonet.se) Type codes compiled by Per Finander (pfimdt93@hvdc.hv.se) The .85G files are groups of TI-85 variables. They are also the general part of all .85x files (see README.TXT for further information about this). An 85G file can contain any number of variables, as long as their total size does not exceed 64Kb. The format of the .85G file is ------------------------------ Header - 37h bytes Entry1 Entry2 .. EntryX Checksum - 2 bytes The header has the following format ----------------------------------- Offset Length Comments ====== ====== ======== 00h 08h Signature. Must be "**TI85**" 08h 03h End-Of-File marker and further signature, must be 1Ah 0Ch 00h 0Bh 2Ah Comment. This is a space- or null-padded string. It may _NOT_ contain any of the special characters on the TI-85. All normal characters are allowed, though. 35h 02h Word: Number of bytes from [next byte to EOF]-2. This variable is used to calculate the checksum of the file. Read this word. Then calculate the checksum on the n words that follows, where n is the value you just read. After that, append the checksum. Each entry has the following format ----------------------------------- Offset Length Comments ====== ====== ======== +00h 02h Word: Bytes from next byte to end of name This can be used for "fast-skipping" of the variable when seeking through the file. The word pointed to by this value is the size of the variable, and therefor the whole thing can be skipped faster. +02h 02h Word: Data length +04h 01h Byte: Type code (see table below) +05h 01h Byte: Name length +06h *h Name (plain data, no terminating null or padding spaces) *+00h 02h Word: Data length *+02h xxx Data The typecodes available are: ---------------------------- 00 Real 01 Cplx 02 Vectr 03 Vectr complex 04 List 05 List complex 06 Matrx 07 Matrx complex 08 Const 09 Const complex 0A Equ 0B Range 0C Strng 0D-10 GDB 11 Pict 12 Prgm 13 Range 14 ? 15-1B Range The checksum is calculated the following way -------------------------------------------- Sum up all the words between 37h and (filesize-2), and the value with FFFFh, and there you are. A little Pascal code snippet to show the basic idea (programmers in other languages should probably understand it too): var checksum:Word;f:file;i:Integer;b:Byte; begin seek(f,$37); checksum:=0; for i:=1 to filepos(f)-$39 do begin blockread(f,b,1); checksum:=checksum+b; end; blockwrite(f,checksum,2); end; You could also read the word at address 35h to determine how much to compute the checksum on, if you don't want to use the files size.