SuperH-based fx calculators
fx legacy: Expressions

Expressions are used in RUN-MAT processing.
The 20 entries of the Graph Func memory (MCS-directory "main", items "1".."20") are expressions.
The current expression of the equation solver is stored in MCS-directory "main", item "EQU_SOLV".


0x0645: int CalculateExpression( char**expression, char*c, TBCDvalue*value, int mode );

expression is a string (no typo: its a pointer to a pointer), which consists of valid characters like '0'..'9', '.', 'A'..'Z' and valid opcodes.
F. i. the opcode 0x81 belongs to sin, the opcode 0x89 belongs to +. A full list can be obtained with 0x07FC, but not every opcode in this list can be used in expression.
The meaning of c is unknown, yet. It is set to 0x31 by some OS functions, which call 0x0645.
mode must be set to 1.
The function heeds for several setup-entries.
F. i. if expression is sin X (t. i. \x81\x58), the result depends on setup-entry 0x13.


0x07FC: int OpcodeToStr( unsigned short opcode, unsigned char *string );
Returns a displaystring in string according to opcode.

0x08F7: void DisplayMBString2( int P1, unsigned char*buffer, int P3, int xpos, int zero, int x, int y, int pos_to_clear, int P9, int P10 );
buffer: MB-buffer to display
P3: x-offset into buffer

0x08DC: int EditValue( int mode, short key, int row, TBCDvalue*value, char*pretext );

Set mode=0 and key=0x7545.
row defines the row, where the value editor will occur on the display.
*value is the start-value and the return-value after edit.
*pretext is the text displayed in front of the edit-field.

With mode=1, key is used as first input key. Maybe any valid opcode. *value is not used.

returns 0 on EXE
returns -1 on QUIT
returns -2 on EXIT

Hint: although the SHIFT CATALOG key sequence displays the opcode selection list, the selected opcode is not inserted into the edit buffer.


0x08DB: int EditExpression( int mode, short key, int row, TBCDvalue*value, char*editbuffer, short editbufferlen, char*pretext, int mode2 );

If mode == 0{
//    key is checked to be RIGHT, AC, EXIT or QUIT
//    key is checked according to mode2:
    switch ( ( mode2 >> 1 ) & 0x03 ){
        case 0 : allows key to be 0..9 only
        case 1 : allows key to be most keys
        case 2 : allows key to be most keys
        case 3 : do not care for key
//    the editbuffer will be initialized (
    memset( editbuffer, 0, editbufferlen + 1 ) )

The first four parameters and the return values are the same as with 0x8DC.
editbuffer is the expression edit buffer.
editbufferlen seems to be editbuffer-size (usually 0xFF).
pretext is the same as with 0x8DC.

With bit 0 of mode2 set, the edit line is centered and the visible edit range is limited to 12 characters.
The edit field scrolls when the cursor hits the bounds.

With bit 1 and bit 2 of mode2 both not set, the editor allows positive integer input, only (a hint of sagarvaze).

With bit 1 and bit 2 of mode2 both set, SHIFT CATALOG works as expected.

With bit 2 of mode2 set, the content of editbuffer is used as initial edit expression,
else editbuffer is preset with value.

The return-values are the same as with 0x8DC.

0x0AE8: int CatalogDialog( void );
Returns opcode on EXE.
Returns 0 on EXIT.

0x0DAB: void StoreExpressionToGraphFuncMemory( int funo, int unknown, unsigned char *expression );
Stores expression to the Graph Func memory function with the number funo. unknown is set to zero by the OS function editor. Its meaning is unknown yet. funo is not checked for the range 1..20. expression is not checked.


(01.06.2012 13:31:51)