bible_documentations/_posts/software/file_format/2020-06-30-g3a.md

6.1 KiB

layout title permalink author
page G3A format documentation /software/format/g3a.html Yatis

G3A addin file format documentation

All this file is based on this page, written by Simon Lothar.
More explication will be delivered when I will have disassembled some syscalls used to check the addin file format.


G3A header (offset 0x000 to 0x020)

All file formats that are read or written by the calculator share a common header format.
This header is inverted (ex: 0x01 -> 0xfe) before being written and read, so a description of the inverted file data make more sense than the normal file data:

Offset Size (byte) Description
0x0000 8 File Identifier: "USBPower"
0x0008 1 File Type (see below)
0x0009 5 Control bytes: {0x00, 0x01, 0x00, 0x01, 0x00}
0x000E 1 Control byte: LSB of filesize + 0x41
0x000F 1 Control byte: 0x01
0x0010 4 Total file size as unsigned integer, big endian format
0x0014 1 Control byte: LSB of filesize + 0xB8
0x0015 1 Unknown purpose, appears insignificant
0x0016 2 Checksum of 8 words starting at offset 0x7100
0x0018 8 Unknown purpose, appears insignificant

offset 0x008:
Known file type:

  • 0x2C = Add-in
  • 0x49 = eAct
  • 0x7d = Picture Plot File

offset 0x00E
The LSB of filesize is stored at offset 0x013

offset 0x010
Total file size = (header size + subheader size + last hecksum) + add-in code size
Total file size = (0x7004) + addin code size

offset 0x014
The LSB of filesize is stored at offset 0x013

offset 0x016
Checked only by the CASIO fx-9860 SDK emulator.


G1A subheader (offset 0x0020 to 0x7000 + last 4 bytes)

Offset | Size (byte) | Description 0x0020 | 4 | Byte checksum: sum 0x00000000 to 0x0000001F and 0x00000024 to EOF minus 4 0x0024 | 2 | Control bytes: {0x01, 0x01} 0x0026 | 8 | Unknown; obviously insignificant, usually 0x00 0x002E | 4 | Add-in code size (without headers and checksums: filesize - 0x7004) 0x0032 | 14 | Unknown; obviously insignificant, usually 0x00 0x0040 | 16 | Programe title; zero terminated 0x0050 | 12 | Unknown; obviously insignificant, usually 0x00 0x005C | 4 | Total file size as unsigned integer, big endian format 0x0060 | 11 | Internal name, on the form "@APPNAME" (the name SHOULD be in upper case); filled up with zeros 0x006B | 24 | Language_1_label; (English) 0x0083 | 24 | Language_2_label; (Spanish) 0x009B | 24 | Language_3_label; (German) 0x00B3 | 24 | Language_4_label; (French) 0x00CB | 24 | Language_5_label; (Portuguese) 0x00E3 | 24 | Language_6_label; (Chinese) 0x00FB | 24 | Language_7_label; (reserved) 0x0113 | 24 | Language_8_label; (reserved) 0x012B | 1 | eAct strp flag. 01:can be used; 00:cannot be used; 0x012C | 4 | Control bytes: {0x00, 0x00, 0x00, 0x00} 0x0130 | 12 | Version "01.00.0000", 0x00, 0x00 0x013C | 14 | Stamp "2012.0903.1652 0x014A | 38 | All zeros 0x0170 | 36 | eAct strip label; (English) 0x0194 | 36 | eAct strip label; (Spanish) 0x01B8 | 36 | eAct strip label; (German) 0x01DC | 36 | eAct strip label; (French) 0x0200 | 36 | eAct strip label; (Chinese) 0x0224 | 36 | eAct strip label; (reserved) 0x0248 | 36 | eAct strip label; (reversed) 0x026C | 36 | eAct strip label; (reserved) 0x0290 | 0x300 | eAct icon; 3color-bitmap w64 x h24; the last pixel of every row is ignored 0x0590 | 0x92C | Unknown; obviously insignificant, usually 0x00 0x0EBC | 0x144 | G3A filename; f. i. "PictPlot.g3a" 0x1000 | 11776 | Selected icon image (w92 x h64, RGB565 -> (92 * 2) * 64 = 11776) 0x4000 | 11776 | Unselected icon image (w92 x h64, RGB565 -> (92 * 2) * 64 = 11776) 0x7000 | ... | Add-in code EOF | 4 | Copy of offset 0x0020: bytes checksum


Note (Simon Lothar):

Upon execution, the addin-code starting at file offset 0x7000 is virtually mapped to 0x00300000, and the OS jumps to address 0x00300000 (Addin code). The addin code should use 0x08100000 for its .bss and .data sections (static RAM). CASIOs SDK will automatically add initialization code that loads the .data section and performs various system calls.

G3A-startup; fx-CG20; OS1.04 syscall sys0017 App_RegisterAddins_ validates add-ins, when the MAIN MENU is built up.

  1. the checksums at 0x20 and at the end of the file are compared (0x8002D376; OS104).
  2. the byte at 0x24 is checked to be 1 (0x8002D386; OS104).

The byte at 0x0E is not checked. The byte at 0x14 is not checked. With OS 1.04, the complete 0x10 bytes starting at 0x00 are not heeded for.

When the addin is started, the following checks are done inside of 0x8002CB22 (OS104), called by syscall 0x0026 and 0x002C. 0x002C seems to check conv.g3a every time any addin is started. At first the actual filesize is compared to the filesize stored at file-offset 0x5C (0x8002CB94; OS104). Then it calculates and compares the checksum (0x8002CCBE; OS104).

Two address-ranges 0xFE240000 and 0xFE241000 are involved in addin-loading. They contain at least 63 int-values, which are initialized with zeros.

  • If an addin is considered to be OK the correspondig entry in table 0xFE240000 is 1.
  • If a checksum-mismatch or a filesize-mismatch is detected, the corressponding value in table 0xFE240000 will be 2. These memory-ranges are a bit peculiar.

The calculator freezes, if INSIGHT tries to display the memory-ranges. Theses addresses obviously are not used in the GII-2 series' OSes.