SuperH-based fx calculators
fx-CG20, keyboard

Some keyboard aspects are similar to those of the legacy systems.

The matrixcode ↔ key relationship is the same as on the fx-9860G standard.

The numbering of the PCB-contacts is different.

OSUPD: OS update contact (3).
DIAG: Diagnostic Mode contact (1).

syscall 0x0111 : void Bkey_ClrAllFlags( void );
Clears all bits of the short-value at 0xFD80161A.
Bit 0x0020: see 0x8013FF2C
Bit 0x0040: see 0x8024CF3C
Bit 0x0080: see 0x80249570
Bit 0x0200: see 0x8014BAB2 (f. i. used to flag the OverwriteConfimation-Dialog(0x0D91))
Bit 0x1000: see 0x8013FBDA
Bit 0x8000: is set during showing a battery-low-status message (f. i. syscall 0x1E75).

The FKey_mapping (0x0129/0x012B) is bypassed, if any of 0xFD80161A's bits are set.

syscall 0x0112 : void Bkey_SetFlag( short flagpattern );
Sets all bits corresponding to flagpattern of the short-value at 0xFD80161A. For a detailed description of known bits see 0x0111.

syscall 0x0113 : void Bkey_ClrFlag( short flagpattern );
Clears all bits corresponding to flagpattern of the short-value at 0xFD80161A. For a detailed description of known bits see 0x0111.

syscall 0x0114 : int Bkey_AllFlagsAreZero2( void );
Queries the short-value at 0xFD80161A for beeing zero. For a detailed description of known bits see 0x0111.

syscall 0x0115 : short Bkey_GetAllFlags( void );
Returns the short-value at 0xFD80161A.  For a detailed description of known bits see 0x0111.

syscall 0x0129: void FKey_mapping2( int P1 );
The function is only needed, if an add-in-prototype is run from RAM. See the source of INSIGHT.
The function claims some kind of internal handle, which is a limited ressource. It is not clear yet, if or how the handle is released properly. Under normal circumstances 0x0129 shouldn't be invoked.
syscall 0x012B: void FKey_mapping1( int P1, void*P2 );
The function is only needed, if an add-in is run from RAM.
See the source of INSIGHT.
if
P2 is null, the short at 8804D712 is set to 0xFFFF.
if
P1 is between 0 and 289 and P2 is null, 0x8804D710 is stored to a pointer-array starting at 0x88091280. The index of the item is P1*4.
if
P1 is between 0 and 289 and P2 is not null, P2 is stored to a pointer-array starting at 0x88091280. The index of the item is P1*4.
Under normal circumstances 0x012B shouldn't be invoked. There is no need to remap the function-key-codes.
 
syscall 0xD39: int KeyBoard_PRGM_GetKey( TBCDvalue*result );

0xD39 is the PRGM-GetKey function and calls 0x12BF with KEYWAIT_HALTOFF_TIMEROFF, t. i. non-blocking.
result is a pointer to a 12 byte buffer. The buffer receives the matrixcode as BCD-value.
In case of the slim the matrixcode is automatically converted to the standard type's code! Hence the function is calctype-independent.
The function decrements the row-number by 1 to prevent the occurence of the invalid BCD-digit "A". F. i. the key F1 yields 79, whereas syscall 0x0247 would return (0x07;0x0A) in this case.

Exception:
in case of the "AC/on"-key BCD-error 1 is returned, t. i. exponent==0xF00 and first nibble of the mantissa==1.

If no key is available, the function returns a BCD-value 0 in result*.

The function's int-return-value is 0 in case of the "AC/on"-key, else 1.

To yield the same function result as PRGM-GETKEY one could use this:

int PRGM_GetKey(){
unsigned char buffer[12];
        KBD_PRGM_GetKey( buffer );
        return ( buffer[1] & 0x0F ) * 10 + ( ( buffer[2]  & 0xF0 )  >> 4 );
}

syscall 0x0EA0 : short Bkey_GetAllFlags( void );
Returns the short-value at 0xFD80161C.

Bit 0x0001 is involved, when the OPTN-key inside of GetKey() is hit [0x80159350].
Bit 0x0002 is involved, when the VARS-key inside of GetKey() is hit [0x8015936A].
Bit 0x0004 is involved, when the PRGM-key inside of GetKey() is hit [0x80159384].
Bit 0x0010 is involved, when the CLIP-key inside of GetKey() is hit [0x8015939E].
Bit 0x0020 is checked inside of GetKey() at [0x801595BE].
Bit 0x0040 is checked inside of GetKey() at [0x80159680].
Bit 0x0080 is involved, when the CATALOG-key inside of GetKey() is hit [0x80159318].
With bit 0x0080 set, the catalog-function (Shift 4) is disabled.

syscall 0x0EA1 : void Bkey_SetAllFlags( short flags );
Sets all bits of the short-value at 0xFD80161C to flags. For a detailed description of known bits see 0x0EA0.

syscall 0x0EA2 : void Bkey_SetFlag( short flagpattern );
Sets all bits corresponding to flagpattern of the short-value at 0xFD80161C. For a detailed description of known bits see 0x0EA0.

syscall 0x0EA3 : void Bkey_ClrAllFlags( void );
Clears all bits of the short-value at 0xFD80161C. For a detailed description of known bits see 0x0EA0.

syscall 0x0EA4 : void Bkey_ClrFlag( short flagpattern );
Clears all bits corresponding to flagpattern of the short-value at 0xFD80161C. For a detailed description of known bits see 0x0EA0.

syscall 0x0EAB : int GetKey( int*key );
GetKey transfers VRAM to DD, like in the legacy systems.

syscall 0x0EAE : void*Bkey_GetkeyTablePtr( void );
Returns the pointer to some keycode-table.

syscall 0x12bf : GetKeyWait_OS(int*column, int*row, int type_of_waiting, int timeout_period, int menu, unsigned short*keycode );

syscall 0x12C9 : int Keyboard_SpyMatrixCode(char*column, char*row)
Returns the current number of keycodes in the key-buffer.
Returns the next matrixcode available in column and row.
Does not remove the matrixcode from the buffers.

syscall 0x1A37 : unsigned char Keyboard_GetShiftStatus( void );
returns 0x01: shift status
returns 0x04: alpha status
returns 0x84: alpha lock status

syscall 0x1A38 : void Keyboard_ClrShiftStatus( void );

syscall 0x1E60 : void SpecialMatrixcodeProcessing( int*col, int*row );
Examples:

int row = 0xC, col = 4;  // DIAG - contact
   SetSetupSetting( 0x14, 0 );
   SpecialMatrixcodeProcessing( &col, &row );

calls the "OPTN/EXP/ACON"-diagnostic menu


int row = 0xC, col = 2;  // OSUP - contact
   SetSetupSetting( 0x14, 0 );
   SpecialMatrixcodeProcessing( &col, &row );

calls the OS update dialog


int row = 1, col = 1;  // ACon - key
   SetSetupSetting( 0x14, 1 );
   SpecialMatrixcodeProcessing( &col, &row );

switches the calculator off

The diagnostics dialog:
if this dialog is finished, a restart is performed (jump to 0xA0000000).
PATTERN: enters some semi-automated test!
FUNC: enters some semi-automated test! Very similar to PATTERN, except the keyboard check follows another scheme.
TEST: enters the MANUAL TEST
VERSION: displays some OS version related information
SERVICE: displays the calculators unique ID (8 byte at 0x8001FFD0).

MANUAL TEST:
LCD: LCD TEST dialog
KEY: the same keyboard test performed inside the FUNC sequence.
ROM: ROM-testing like in PATTERN and FUNC
RAM: RAM-testing like in PATTERN and FUNC
DETECT: does some battery tests. Creates the files voltag1.txt, voltag2.txt and voltage.txt, which contain the hex-value of the battery voltage.
TRANS: some tests for the communication channels
CURRENT: no recognizable effect.
OTHERS: some cash and battery tests

LCD TEST:
LCD COLOR SET: switches between 16bit and 3bit color depth (maybe interesting how the setting influences the other LCD options. Options marked blue are very much influenced)
LCD CHECK: enters the LCD CHECK dialog
SETTING MENU: enters the SETTING MENU
OHP LCD CHECK:
LIGHT TEST:
TFT AUTO: performs some LCD display options (switch with EXE)

LCD CHECK:
8-COLOR:
C-BAR:
C-GRAD:
CLEAR:
FRAME:
MESH:
R-MESH:
WB-GRAD:
DUMMY:

SETTING MENU:
FRAME FREQ SET:
BC SET:
BL PWMDIV SET:
BL EN2 SET:
BL PWMDUTY SET
Sample Picture: displays 6 sample pictures (switch with the FKeys)

(19.05.2012 21:24:41)