Register

How to find and display the Prizm's built-in MENU-icons

Learn how to program. Code snippets for creating sprites etc. Submit your own or use those of others.
Senior Member
User avatar
Posts: 603
Joined: Sat Sep 15, 2012 6:59 am
Location: Krautland ****
Calculators: Casio fx-7400GII, Casio fx-7400GII (SH4), Casio fx-9750 G II, Casio fx-9750 G II (SH4), Casio fx-9860G, Casio fx-9860 G SD, Casio fx-9860G Slim, Casio fx-9860 GII SD, Casio fx-9860 GII SD Power Graphic 2, Casio Classpad 330 plus, Casio fx-CG 20, Casio Classpad fx-cp400, Casio fx-CG 50

How to find and display the Prizm's built-in MENU-icons

Postby SimonLothar » Sat May 23, 2015 8:53 am

First find the address of syscall 0x001E, f. i. 80 01 02 04 (this is an example, not a real address).
Then find the address of syscall 0x1515, f. i. 80 05 07 08 (this is an example, not a real address).
Search the OS-range for these 8 bytes (in the example above search for: 80 01 02 04 80 05 07 08). The sequence should occur only once.
The four bytes immediately preceding these 8 bytes represent the address to the built-in table.
The built-in table consists of 5 pointers per built-in.
The 1st pointer is the address of the built-in's MCS-name.
The 2nd pointer is the address of the built-in's syscall. The syscalls should not be called without knowing the interface. The built-ins' syscall interfaces differ even in number of arguments!
The 5th pointer is the address of the built-in's icon (64 lines x 92 words (16 bit-color pixels) per line).

built_in_table:
.data.l pointer to ASCIIZ "@RUNMAT"
.data.l sys1a03_APP_RUNMAT
.data.l 0
.data.l pointer to some other bitmap, purpose unknown yet, size the same as the icon
.data.l BuiltInIconBitmap_RUNMAT
.data.l pointer to ASCIIZ "@STAT"
.data.l sys1ced_APP_STAT_
.data.l 0
.data.l pointer to some other bitmap, purpose unknown yet, size the same as the icon
.data.l BuiltInIconBitmapSTAT
.data.l pointer to ASCIIZ "@EACT"
.data.l sys0a83_APP_EACT_
.data.l h'100
.data.l pointer to some other bitmap, purpose unknown yet, size the same as the icon
.data.l BuiltInIconBitmap_EACT
.data.l pointer to ASCIIZ "@SSHEET"
.data.l sys1b0f_APP_SHEET_
.data.l 0
.data.l pointer to some other bitmap, purpose unknown yet, size the same as the icon
.data.l BuiltInIconBitmap_SSHEET
a. s. o.

F. i. BuiltInIconBitmap_RUNMAT is the pointer to the MENU-bitmap of the built-in RunMat.

-------------------
Some example code

Code: Select all
//
void F33_Handler(){
int ADR001E, ADR1515, pBuiltInTable, pIconBitmap;
int p, AppNo;
unsigned int key;
unsigned char hb[15];
TDispGraph Graph;

   Bdisp_AllClr_VRAM();
   
// find syscall addresses 0x001E and 0x1515
   p = *(int*)0x8002007C;
   ADR001E = *(int*)(p + 0x001E * 4);
   ADR1515 = *(int*)(p + 0x1515 * 4);
   
   // display to check
   locate( 1, 1 );
   LongToAscHex( ADR001E, hb, 8 );
   Print( hb );
   locate( 10, 1 );
   LongToAscHex( ADR1515, hb, 8 );
   Print( hb );

// find the buit-in table   
   pBuiltInTable = 0;
   p = 0x80020000;
   while ( p < 0x80B60000 ){
      if ( *(int*)p == ADR001E ){
         if ( *(int*)(p+4) == ADR1515 ){
            pBuiltInTable = *(int*)(p-4);
            break;
         }
      }
      p += 4;
   }
   
// find the bitmap pointer and display
   if ( pBuiltInTable ){
   // display to check
      locate( 1, 2 );
      LongToAscHex( pBuiltInTable, hb, 8 );
      Print( hb );
      
      Graph.xofs = 0;
      Graph.yofs = 0;
      Graph.width = 92;
      Graph.height = 64;
      Graph.colormode = 2;
      Graph.zero4 = 0x00;
      Graph.P20_1 = 0x20;
      Graph.P20_2 = 0x20;
      Graph.color_idx1 = 0x01;
      Graph.color_idx2 = 0x00;
      Graph.color_idx3 = 0xFF;
      Graph.P20_3 = 0x20;
      Graph.writemodify = 0x01;
      Graph.writekind = 0x01;
      Graph.zero6 = 0x00;
      Graph.one2 = 0x01;
      Graph.transparency = 0;
      
      AppNo = 0;  // RunMat
      pIconBitmap = *(int*)(pBuiltInTable+20*AppNo+4*4);
   // display to check
      locate( 1, 2 );
      LongToAscHex( pIconBitmap, hb, 8 );
      Print( hb );
      
      Graph.x = 10;
      Graph.y = 10;
      Graph.bitmap = pIconBitmap;
      Bdisp_WriteGraphVRAM( &Graph );
      
      AppNo = 1;  // Stat
      pIconBitmap = *(int*)(pBuiltInTable+20*AppNo+4*4);
      locate( 10, 2 );
      LongToAscHex( pIconBitmap, hb, 8 );
      Print( hb );
      
      Graph.x = 110;
      Graph.bitmap = pIconBitmap;
      Bdisp_WriteGraphVRAM( &Graph );
      
      AppNo = 2;  // EACT
      pIconBitmap = *(int*)(pBuiltInTable+20*AppNo+4*4);
      locate( 1, 3 );
      LongToAscHex( pIconBitmap, hb, 8 );
      Print( hb );
      
      Graph.x = 10;
      Graph.y = 100;
      Graph.bitmap = pIconBitmap;
      Bdisp_WriteGraphVRAM( &Graph );
      
      
      AppNo = 3;  // Sheet
      pIconBitmap = *(int*)(pBuiltInTable+20*AppNo+4*4);
      
      locate( 10, 3 );
      LongToAscHex( pIconBitmap, hb, 8 );
      Print( hb );
      
      Graph.x = 110;
      Graph.bitmap = pIconBitmap;
      Bdisp_WriteGraphVRAM( &Graph );
      
   }
   
   GetKey( &key );
}
I'll be back!

Senior Member
Posts: 112
Joined: Mon Mar 02, 2015 10:53 am
Calculators: Casio fx-CG 20

Re: How to find and display the Prizm's built-in MENU-icons

Postby AmazoNKA » Thu Apr 21, 2016 12:25 am

I assume it is for the first 16 icons (i.e. built-in ones) on the main menu only - or is there a way to find the other, not built-in icons too please? Or is the safest way to get them directly from the add-ins files themselves in the storage memory?

Determining the order in which all the add-ins appear on the main menu is tricky in itself - or is there a system call at least for that please - I posted similar question here https://www.cemetech.net/forum/viewtopic.php?t=11935 with some address reference listing order of add-ins if it helps but that appears to change with OS versions...

Also I was wondering what routine prints the main menu icons' titles - the font seems unique.

Many thanks in advance.

Senior Member
User avatar
Posts: 603
Joined: Sat Sep 15, 2012 6:59 am
Location: Krautland ****
Calculators: Casio fx-7400GII, Casio fx-7400GII (SH4), Casio fx-9750 G II, Casio fx-9750 G II (SH4), Casio fx-9860G, Casio fx-9860 G SD, Casio fx-9860G Slim, Casio fx-9860 GII SD, Casio fx-9860 GII SD Power Graphic 2, Casio Classpad 330 plus, Casio fx-CG 20, Casio Classpad fx-cp400, Casio fx-CG 50

Re: How to find and display the Prizm's built-in MENU-icons

Postby SimonLothar » Sat Apr 23, 2016 6:06 am

There exists a registered addin-table, the order of which corresponds with the main menu addin order.
First get the address returned by syscall 1e50 (this is the start of some VRAM cache or shadow VRAM). Add 0x28800. Then search for the first string which starts with "@". This should be the start of the addin-table, which consists of an eight byte addin-name (the name used in the main memory, t. i. preceeded by "@", f. i. "@CONV") and a four byte address, which is the pointer to the addin-header. This struct is repeated for each addin.
I did not find any syscall to get the address of the registered addin-table directly.
I'll be back!

Senior Member
Posts: 112
Joined: Mon Mar 02, 2015 10:53 am
Calculators: Casio fx-CG 20

Re: How to find and display the Prizm's built-in MENU-icons

Postby AmazoNKA » Sun Apr 24, 2016 1:02 am

Thank you so much for this - I will give it a try for sure.

Is it known how to print the titles of the icons the way they are printed on the main menu as well please?

Senior Member
Posts: 112
Joined: Mon Mar 02, 2015 10:53 am
Calculators: Casio fx-CG 20

Re: How to find and display the Prizm's built-in MENU-icons

Postby AmazoNKA » Fri Apr 29, 2016 7:58 am

Your suggestion works - thank you.
In my G-Clock add-in I used the following to count add-ins before
Code: Select all
typedef struct {
   unsigned short id, type;
   unsigned long fsize, dsize;
   unsigned int property;
   unsigned long address;
} file_type_t;
int g3a_count() {
   unsigned short filename[0x10A];
   unsigned short found[0x10A];
   file_type_t fileinfo;
   int findhandle;
   int ret;
   Bfile_StrToName_ncpy(filename,"\\\\fls0\\*.g3a", 0x10A);
   ret = Bfile_FindFirst_NON_SMEM((const char*)filename, &findhandle, (char*)found, &fileinfo);
   int totalsize = 1;
   while(!ret) {
      ++totalsize;
      ret = Bfile_FindNext_NON_SMEM(findhandle, (char*)found, (char*)&fileinfo);
   }
   Bfile_FindClose(findhandle);
   return totalsize;
}

but replacing with
Code: Select all
   unsigned int VRAM2;
   VRAM2 = getSecondaryVramAddress();
   VRAM2 += 0x28800;
   int z = 1;
   while (*(char*)VRAM2 != '@') {
      VRAM2++;
   }
   while (*(char*)VRAM2 == '@') {
      z++;
      VRAM2 += 12;
   }


I saw somewhere 1e50 and regular GetVRAMAddress listed as returning unsigned int I think which was the only way I could make 1e50 work, but it seems to me that regular GetVRAMAddress returns void* so I struggled for a while because of this confusion - I still need to understand how to fully use the new system call for example when looking up some pixels as the routines I used on regular VRAM don't work with what 1e50 returns but this is something else...

Also thank you so much for documenting how to add new system calls on a fly.

Thanks again and let me know if you have any idea about how icons' titles are printed please if you can.

Senior Member
User avatar
Posts: 603
Joined: Sat Sep 15, 2012 6:59 am
Location: Krautland ****
Calculators: Casio fx-7400GII, Casio fx-7400GII (SH4), Casio fx-9750 G II, Casio fx-9750 G II (SH4), Casio fx-9860G, Casio fx-9860 G SD, Casio fx-9860G Slim, Casio fx-9860 GII SD, Casio fx-9860 GII SD Power Graphic 2, Casio Classpad 330 plus, Casio fx-CG 20, Casio Classpad fx-cp400, Casio fx-CG 50

Re: How to find and display the Prizm's built-in MENU-icons

Postby SimonLothar » Sat Apr 30, 2016 8:29 am

AmazoNKA wrote:I saw somewhere 1e50 and regular GetVRAMAddress listed as returning unsigned int I think which was the only way I could make 1e50 work, but it seems to me that regular GetVRAMAddress returns void* so I struggled for a while because of this confusion - I still need to understand how to fully use the new system call for example when looking up some pixels as the routines I used on regular VRAM don't work with what 1e50 returns but this is something else...
1E50 as well as 01E6 return an address in r0. The difference is the alignment. 01E6 returns a 4-aligned address (usually A8000000). 1E50 may return an odd address. You can use an odd address only to access char or unsigned char, t. i. you have to typecast such an address as (char*) or (unsigned char*). Any other pointer typecast will lead to an error.

AmazoNKA wrote:Thanks again and let me know if you have any idea about how icons' titles are printed please if you can.
At present my Windows 10 machines deny to accept a CG20 as mass-storage device. Hence I cannot verify any assumptions. I am a bit short of time to see to that. The secret will be found around the DisplayMainMenu-syscall 1E6A.
I'll be back!

Senior Member
Posts: 112
Joined: Mon Mar 02, 2015 10:53 am
Calculators: Casio fx-CG 20

Re: How to find and display the Prizm's built-in MENU-icons

Postby AmazoNKA » Thu May 05, 2016 3:34 pm

Thanks for those explanations.

Regarding usb connection problems- a couple of times it helped me to reset the calculator and then connecting to pc restored itself. I hope it helps you.

Senior Member
User avatar
Posts: 603
Joined: Sat Sep 15, 2012 6:59 am
Location: Krautland ****
Calculators: Casio fx-7400GII, Casio fx-7400GII (SH4), Casio fx-9750 G II, Casio fx-9750 G II (SH4), Casio fx-9860G, Casio fx-9860 G SD, Casio fx-9860G Slim, Casio fx-9860 GII SD, Casio fx-9860 GII SD Power Graphic 2, Casio Classpad 330 plus, Casio fx-CG 20, Casio Classpad fx-cp400, Casio fx-CG 50

Re: How to find and display the Prizm's built-in MENU-icons

Postby SimonLothar » Thu May 05, 2016 4:28 pm

AmazoNKA wrote:Regarding usb connection problems- a couple of times it helped me to reset the calculator and then connecting to pc restored itself. I hope it helps you.

I used an USB-cable, which has been provided as accessory with some USB-charging device. Data-lines not connected. OMG.
Now I am operational again.

AmazoNKA wrote:Also I was wondering what routine prints the main menu icons' titles - the font seems unique.

First thing I found is syscall void*0x0D03( char Character, short*CharWidth ), which returns the address of the character's bitmap and the character's width in CharWidth.
If CharWidth is <=8, the Bitmap consists of 16 bytes, otherwise the bitmap consists of 16 words.
I'll be back!

Senior Member
User avatar
Posts: 603
Joined: Sat Sep 15, 2012 6:59 am
Location: Krautland ****
Calculators: Casio fx-7400GII, Casio fx-7400GII (SH4), Casio fx-9750 G II, Casio fx-9750 G II (SH4), Casio fx-9860G, Casio fx-9860 G SD, Casio fx-9860G Slim, Casio fx-9860 GII SD, Casio fx-9860 GII SD Power Graphic 2, Casio Classpad 330 plus, Casio fx-CG 20, Casio Classpad fx-cp400, Casio fx-CG 50

Re: How to find and display the Prizm's built-in MENU-icons

Postby SimonLothar » Thu May 05, 2016 5:54 pm

syscall void*0x0D06( unsigned short Character, unsigned short*CharWidth )
Supports some E5- and E6-multibyte characters, too.
I'll be back!

Senior Member
User avatar
Posts: 603
Joined: Sat Sep 15, 2012 6:59 am
Location: Krautland ****
Calculators: Casio fx-7400GII, Casio fx-7400GII (SH4), Casio fx-9750 G II, Casio fx-9750 G II (SH4), Casio fx-9860G, Casio fx-9860 G SD, Casio fx-9860G Slim, Casio fx-9860 GII SD, Casio fx-9860 GII SD Power Graphic 2, Casio Classpad 330 plus, Casio fx-CG 20, Casio Classpad fx-cp400, Casio fx-CG 50

Re: How to find and display the Prizm's built-in MENU-icons

Postby SimonLothar » Thu May 05, 2016 6:52 pm

Syscall 0D07 displays a MMGlyphBitmap obtained by 0D03 or 0D06:
MMGlyphPrint( int x, int y, void*glyphbitmap, 2, int charwidth, 0, 0, 0, 0, unsigned short color, 0, 0 );
I'll be back!

Next

Return to Tutorials & Code Snippets

Who is online

Users browsing this forum: No registered users and 2 guests