Register

Add functions to Basic Casio programs

Topics on released projects. Only the author of a program should start a topic on it.
Member
User avatar
Posts: 33
Joined: Sat Apr 07, 2012 10:08 am
Location: France

Add functions to Basic Casio programs

Postby Purobaz » Mon May 14, 2012 7:56 pm

Hi all,

I've already begun this discussion with SimonLothar about "how to add functions to Basic Casio programs", but he advises me to publish informations. So here it is :D
In fact I prefer, most of the time, to talk about technical informations in private, because it's easier for me to understand it (I'm french).


Since several months and thanks to the work of PierrotLL, I've worked on Basic programs in order to add new functions, it's PRGM2.
PRGM2 starts a timer, and launches a Casio Basic program.
The timer checks the value of 'F' variable. If it's non-null, the timer calls the function corresponding to the 'F' value. It allows to use fast functions in a basic program.
PRGM2_fx => here (sorry only in french on Planete-Casio)
PRGM2_prizm => here (on Cemetech)

Then I've managed to read List, Mat and Str from the main memory. I haven't released a new version yet, but it enables new and easier functions as sprites, tilesets and texts.


However I discovered today, syscalls 0x0CB0 : int PRGM_Send( short*opcode, char**program, TBCDvalue result[2] );

According to SimLo's (very helpful) documentation, this syscall can be used to redirect the PRGM-commands.
But I don't know how to redirect the command on my own function.

SimLo answered me :
That would require an OS mod. In the early days I modded by flash writing. Now I would rather mod a backed up image-file and write the modded OS back to the calculator. You would need fxRemote do achieve this. Alas, OS modding usually raises discussions. I have been occupied with other tasks recently and did not ask the admin yet, whether he would mind to publish fxRemote here. At present the only source is I know is
http://prizmwiki.omnimaga.org/wiki/F...60GII_tutorial.
But fxRemote is only the tool to move an OS image to and from the calculator.
The mod itself requires some additional tasks. You have to find some empty space in the OS image. This could be sector 0x80220000 (64k). You need an SDK which is able to link the code to the address 0x80220000 (the CASIO SDK can do this). In sector 0x80220000 the extended functions would reside. The you have to inject a jump-to-0x8022000 at the syscall-address, you want to redirect. Then you have to adjust the OS checksum. I know this is a lot even for a start.

Member
User avatar
Posts: 33
Joined: Sat Apr 07, 2012 10:08 am
Location: France

Postby Purobaz » Mon May 14, 2012 8:00 pm

I want to go this way, but I've a first question :
Can we locate the extended function in main memory ?

I think it isn't possible, but I don't know why.

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

Postby SimonLothar » Tue May 15, 2012 6:27 am

Purobaz wrote:Can we locate the extended function in main memory?
No. The BASIC-extension would have to reside at a fixed memory location. Objects in the main memory can be subject to shifts automatically done by the system. You cannot control that.
I'll be back!

Member
User avatar
Posts: 33
Joined: Sat Apr 07, 2012 10:08 am
Location: France

Postby Purobaz » Tue May 15, 2012 7:25 am

If I have understood correctly, I have to :
- write my own function in sector 0x80220000, thanks to fxRemote
- inject a jump-to-0x8022000 at the syscall-address

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

Postby SimonLothar » Tue May 15, 2012 10:51 am

Purobaz wrote:If I have understood correctly, I have to :
- write my own function in sector 0x80220000, thanks to fxRemote
Yes.

Purobaz wrote:- inject a jump-to-0x8022000 at the syscall-address
to-0x80220000 (my typo). Mind the alignment of the syscall-address. A 4-aligned address has a different POOL-offset than a merely 2-aligned one.

And adjust the OS-checksum.
I'll be back!

Member
User avatar
Posts: 33
Joined: Sat Apr 07, 2012 10:08 am
Location: France

Postby Purobaz » Tue May 15, 2012 5:35 pm

I think this solution is a bit difficult for users.

Can I store the function in the RAM thanks to malloc, and then inject a jump at the syscall-address.
Of course I will inject a new jump when the addin is executed.

I don't really understand what OS-checksum is ?

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

Postby SimonLothar » Tue May 15, 2012 6:49 pm

Purobaz wrote:I think this solution is a bit difficult for users.
Yes, I agree. It is not easy. But the user has to change his OS in any case (at least when changing the syscall and adjusting the checksum). Hence fxRemote or a similar tool is needed anyhow.

Purobaz wrote:Can I store the function in the RAM thanks to malloc, and then inject a jump at the syscall-address.
Of course I will inject a new jump when the addin is executed.
The address returned by malloc is not predictable. The compilers usually use far jumps (jsr, jmp), which are not relocatable after linking, t. i. the start-address must be known when you compile and link your binary (early-binding). There exists some unused onchip-memory (0xA5600200 to 0xA5603A97) on the fx9860G/GII-models. This can be used as fixed RAM (if your extension remains small enough; BTW: make sure, that your extension never touches the data outside of this range). I think the GII-2-CPU has a different onchip-RAM-address. If you are developing on machines with 512k RAM you could possibly use the upper 256k-half as fixed RAM (only while developing). I recommend that the final version should reside in the flash (0x80220000).

Purobaz wrote:I don't really understand what OS-checksum is ?

On fx9860-OSes 1.xx it is the sum of the bytes in the address-ranges
0x80010000 to 0x8022FFFF
and
0x80260000 to 0x8026FFF7
it is stored as int at 0x8026FFF8

On fx9860-OSes 2.xx it is the sum of the bytes in the address-range
0x80010000 to 0x8024FFF7
it is stored as int at 0x8024FFF8

If the checksum is not correct, the OS will automatically enter the "OS update" mode! Have fxRemote and a valid backup ready!
I'll be back!

Member
User avatar
Posts: 33
Joined: Sat Apr 07, 2012 10:08 am
Location: France

Postby Purobaz » Tue May 15, 2012 7:48 pm

There exists some unused onchip-memory (0xA5600200 to 0xA5603A97) on the fx9860G/GII-models. This can be used as fixed RAM (if your extension remains small enough; BTW: make sure, that your extension never touches the data outside of this range).

I will try to do this at first. How can I store a function at this adress. Is fxRemote the only way ?

I think the GII-2-CPU has a different onchip-RAM-address. If you are developing on machines with 512k RAM you could possibly use the upper 256k-half as fixed RAM (only while developing). I recommend that the final version should reside in the flash (0x80220000).

Of course if my tests are successful.

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

Postby SimonLothar » Tue May 15, 2012 8:07 pm

Purobaz wrote:How can I store a function at this adress. Is fxRemote the only way ?
Why, it is onchip-RAM. You can use memcpy.
I'll be back!

Member
User avatar
Posts: 33
Joined: Sat Apr 07, 2012 10:08 am
Location: France

Postby Purobaz » Tue May 15, 2012 9:12 pm

Yes, but where can I get the compiled code ?

Another question :
I can't redirect on this adress, only in changing opcode with syscall 0x0CB0 : int PRGM_Send( short*opcode, char**program, TBCDvalue result[2] ) ?

Next

Return to Released Projects

Who is online

Users browsing this forum: No registered users and 75 guests