Register

Finding bitmaps to use with WriteGraph

Discuss issues related to the Casio Prizm 3rd party development
Senior Member
Posts: 141
Joined: Wed May 16, 2012 2:50 pm
Location: Portugal
Calculators: Casio fx-CG20

Finding bitmaps to use with WriteGraph

Postby gbl08ma » Fri Nov 08, 2013 12:23 pm

I understand more or less how the Bdisp_WriteGraphVRAM syscall works. I see it needs a struct with a pointer to the bitmap to display.
I read somewhere this is how the OS displays the icons, for example on the menu and on the file browsers.

What I'm looking for is a syscall that does the same as GetFKeyPtr, but for file icons (those used in the file browser). I believe such a thing should exist (unless the positions of the bitmaps in memory don't change with the OS version, and the OS has them hardcoded?). The syscall should be able to get the pointer to the icons in memory, which I can then display with WriteGraph.

Can someone help?

Senior Member
User avatar
Posts: 605
Joined: Sat Sep 15, 2012 6:59 am
Location: Krautland ****
Calculators: Casio fx-7400GII, Casio fx-7400GII (SH4), Casio fx-9750GII, Casio fx-9750GII (SH4), Casio fx-9860G, Casio fx-9860G SD, Casio fx-9860G Slim, Casio fx-9860GII SD, Casio fx-9860GII SD Power Graphic 2, Casio Classpad 330 plus, Casio fx-CG20, Casio fx-CG50, Casio Classpad fx-CP400

Re: Finding bitmaps to use with WriteGraph

Postby SimonLothar » Sun Nov 10, 2013 6:17 pm

There exists a built-in-table:

if ( osversion( OS103_Prizm ) ) ea = 0x806751E8;
else if ( osversion( OS104_Prizm ) ) ea = 0x8067AA6C;
else if ( osversion( OS200_Prizm ) ) ea = 0x806A5F08;

This table consists of five Dwords for every built-in.
The 1st Dword is a pointer, which points to the built-in's name, f. i. "@RUNMAT".
The 2nd Dword is a pointer, which points to the built-in's start-code (some syscall).
The 3rd Dword's bits seem to be some flags.
The 4th Dword is a pointer, which points to the built-in's main menu icon (unselected).
The 5th Dword is a pointer, which points to the built-in's main menu icon (selected).

Alas, there seems to be no syscall to grab the pointer to the built-in-table or to display a specific built-in's icon.
I'll be back!

Senior Member
Posts: 141
Joined: Wed May 16, 2012 2:50 pm
Location: Portugal
Calculators: Casio fx-CG20

Re: Finding bitmaps to use with WriteGraph

Postby gbl08ma » Sun Nov 10, 2013 6:34 pm

Thanks! That's some interesting information on the bitmaps used for the built-in applications on the Main Menu. It also gives insight as how built-in apps are represented in the menu, and how they are called (I would say they are represented just like add-ins, except that on add-ins the 2nd Dword points to some add-in loader code, and the 5th Dword possibly points to the icon's location in the g3a file).

I don't find it too amusing that there is no fixed position for the icons, or a syscall to get the table start. My understanding is that code that runs in the "main" application stack (i.e. the main menu, and possibly things such as screen capture and the catalog) doesn't use syscalls. So at OS compile time the compiler and linker take care of pointing the code to the right memory addresses where that data is.

However, what I was really looking for is a way to display the bitmaps found in the file browser, that is, the ones that are shown to the left of each file:
Image

I need these so that I can display them in my Utilities add-in. I could do it by carefully copying and adding them as sprites on my add-in, but that would increase the file size a lot.

EDIT: another thing I don't think anyone has looked into yet, is the font used on the main menu entries. That font is definitely not the font used on PrintMini. It doesn't appear to contain all the special characters the other fonts contain - when Chinese is the selected language, the PrintMini font is used instead of it (because PrintMini supports the Chinese characters).

EDIT 2: could the 3rd dword flags be related to the presence of the app in the menu and in eActivity? Could the 4th dword be a pointer to the eActivity strip icon?
The OS has an app, that eActivity calls "Notes", which is only available as an eActivity strip. I think the internal name of the app is @TEXT. It would be interesting to know if the OS offers the possibility for add-ins to only be available as eActivity strips.

A version of INSIGHT that has the strip part enabled would be useful. I learned a lot about how the strip mechanism works by making my own, less powerful, debug add-ins strip-enabled. I should have notes about it somewhere, in case anyone is interested...

Senior Member
User avatar
Posts: 605
Joined: Sat Sep 15, 2012 6:59 am
Location: Krautland ****
Calculators: Casio fx-7400GII, Casio fx-7400GII (SH4), Casio fx-9750GII, Casio fx-9750GII (SH4), Casio fx-9860G, Casio fx-9860G SD, Casio fx-9860G Slim, Casio fx-9860GII SD, Casio fx-9860GII SD Power Graphic 2, Casio Classpad 330 plus, Casio fx-CG20, Casio fx-CG50, Casio Classpad fx-CP400

Re: Finding bitmaps to use with WriteGraph

Postby SimonLothar » Tue Nov 12, 2013 7:24 pm

This are the icons I found up to now

Image

Dimensions 0x12 * 0x18; 16 bit color

Starting at 0x80450850 with OS 2.00 (just if you want to do some experiments).

I think syscall 0x0c2c maps between extension and bitmap.
Though, I still have to unravel the interface.
I'll be back!

Senior Member
Posts: 141
Joined: Wed May 16, 2012 2:50 pm
Location: Portugal
Calculators: Casio fx-CG20

Re: Finding bitmaps to use with WriteGraph

Postby gbl08ma » Tue Nov 12, 2013 7:41 pm

That's very good, thanks!
As you said, the icons are 18*24 (0x12*0x18), just like the glyphs used with PrintXY. From what I remember there are no more file icons, so don't waste your time looking for any more.
In case anyone's wondering, from left to right we have: folder; *.g1m/.g2m/.g3m; *.g1e/*.g2e/*.g3e; *.g3p; *.g3b; *.bmp; *.txt; *.csv; unsupported file; and some junk?

I'm curious about that junk, is it just the result of you wanting to see if there was an icon at that location, or is it actually registered in some table as an icon? If the latter is true, then it may be some icon not yet converted from the fx9860G, which means it shows junk because it's still saved as 1 bit-per-pixel.

Senior Member
Posts: 141
Joined: Wed May 16, 2012 2:50 pm
Location: Portugal
Calculators: Casio fx-CG20

Re: Finding bitmaps to use with WriteGraph

Postby gbl08ma » Fri Nov 15, 2013 7:05 pm

Did you manage to discover any new information on the 0x0c2c syscall interface? I tried calling it with a few possible combos of parameters, but of course all I always got was a system error with 0x00000001 as the target.

Senior Member
User avatar
Posts: 605
Joined: Sat Sep 15, 2012 6:59 am
Location: Krautland ****
Calculators: Casio fx-7400GII, Casio fx-7400GII (SH4), Casio fx-9750GII, Casio fx-9750GII (SH4), Casio fx-9860G, Casio fx-9860G SD, Casio fx-9860G Slim, Casio fx-9860GII SD, Casio fx-9860GII SD Power Graphic 2, Casio Classpad 330 plus, Casio fx-CG20, Casio fx-CG50, Casio Classpad fx-CP400

Re: Finding bitmaps to use with WriteGraph

Postby SimonLothar » Sat Nov 16, 2013 10:10 am

gbl08ma wrote:Did you manage to discover any new information on the 0x0c2c syscall interface?
Yes.
This is what I found:
syscall 0x0C2C : int SMEM_MapIconToExt( unsigned char*filename, unsigned short*foldername, unsigned int*msgno, unsigned short*iconbuffer );
Maps an icon to a filename.
filename(input): filename of the file, the icon of which has to be retrieved
foldername(input): if foldername (unsigned short array; FONTCHARACTER) is empty, the filename is analyzed to retrieve an appropriate icon. Otherwise the folder-icon is returned.
msgno(output): a pointer which is used to return the message-number, which designates the filetype, f. i. 0x66F: "eActivity File" (see LocalizeMessage).
iconbuffer(output): pointer to a buffer to receive an 0x12 x 0x18; 16bit-color-icon (0x1B0 short numbers). This buffer must be provided by the caller.

returns 1, if a fileicon is returned, otherwise 0 (foldericon).
I'll be back!

Senior Member
Posts: 141
Joined: Wed May 16, 2012 2:50 pm
Location: Portugal
Calculators: Casio fx-CG20

Re: Finding bitmaps to use with WriteGraph

Postby gbl08ma » Sat Nov 16, 2013 1:33 pm

Thanks! It seems to work fine, also, the filename doesn't need to be an actual file on the disk which is good for my purposes (since I can't use over 60 KB of RAM just to store icons for, say, a list with 200 files, I will just prefetch each icon and store it in an known memory location, then have my own functions do the linking, using pointers instead of buffers).
The thing to show the localized name for the file type works fine.

However, I don't know how to write the bitmap it returns in the iconbuffer, to VRAM. I tried using Bdisp_WriteGraphVRAM with a pointer to iconbuffer as the bitmap, and using colormode 2 (full color). But all I get in the screen is garbage. In what format does WriteGraph expect the bitmap to be? Or is this not the correct syscall to print these icons? Should I just develop my own sprite printing function that takes unsigned shorts?

EDIT: funnily enough, my own custom function prints the bitmaps fine. Oh well, I guess I will just use it, as it is probably faster than WriteGraph, and doesn't need as many strange parameters/structs.

Senior Member
User avatar
Posts: 605
Joined: Sat Sep 15, 2012 6:59 am
Location: Krautland ****
Calculators: Casio fx-7400GII, Casio fx-7400GII (SH4), Casio fx-9750GII, Casio fx-9750GII (SH4), Casio fx-9860G, Casio fx-9860G SD, Casio fx-9860G Slim, Casio fx-9860GII SD, Casio fx-9860GII SD Power Graphic 2, Casio Classpad 330 plus, Casio fx-CG20, Casio fx-CG50, Casio Classpad fx-CP400

Re: Finding bitmaps to use with WriteGraph

Postby SimonLothar » Sat Nov 16, 2013 1:38 pm

This is, what I do

i = SMEM_MapIconToExt( "XYZ.G3A", "\x000\x000", &msgno, iconbuffer );

Graph.x = 12;
Graph.y = 40;
Graph.xofs = 0;
Graph.yofs = 0;
Graph.width = 0x12;
Graph.height = 0x18;
Graph.colormode = 0x02;
Graph.zero4 = 0x00;
Graph.P20_1 = 0x20;
Graph.P20_2 = 0x20;
Graph.bitmap = (int)iconbuffer;
Graph.color_idx1 = 0x00;
Graph.color_idx2 = 0x05;
Graph.color_idx3 = 0x01;
Graph.P20_3 = 0x01;
Graph.writemodify = 0x01;
Graph.writekind = 0x00;
Graph.zero6 = 0x00;
Graph.one2 = 0x00;
Graph.transparency = 0;
Bdisp_WriteGraphVRAM( &Graph );
I'll be back!

Senior Member
Posts: 141
Joined: Wed May 16, 2012 2:50 pm
Location: Portugal
Calculators: Casio fx-CG20

Re: Finding bitmaps to use with WriteGraph

Postby gbl08ma » Sat Nov 16, 2013 1:43 pm

Oh well, I guess I was missing the part where one turns it into a (int). I will take that into account next time, thanks.
Anyway, I'm now using this function instead: https://github.com/gbl08ma/utilities/bl ... r.cpp#L226

It doesn't need as many parameters, and even supports setting a maskcolor that will not be drawn, making it perfect for the job.

Next

Return to Casio Prizm SDK

Who is online

Users browsing this forum: No registered users and 17 guests