Author Topic: Compiling stuff for Prizm  (Read 74198 times)

0 Members and 1 Guest are viewing this topic.

Offline Kristaba

  • LV1 Newcomer (Next: 20)
  • *
  • Posts: 16
  • Rating: +5/-0
    • View Profile
Compiling stuff for Prizm
« on: February 15, 2011, 08:43:56 am »
Hey guys :)
I saw nobody here posted a real tutorial about how to build stuff for SH3 (and later for Prizm itself) :(

Simon Lothar and Andreas Bertheussen, two casio hacker, made some years ago a good reverse engineering of fx9860 calculator, and they wrote some tools
for, and some informations about how to use GCC to make G1A Addin :
http://sourceforge.net/apps/trac/fxsdk/wiki/UsingGCC

I advise you to subscribe and download the Kpit GNU tools (most recent and up-to-date) at http://www.kpitgnutools.com/index.php
They have a strange policy : they allow to download freely the code (because GCC is under GNU GPL license of course ::) ) but you need to subscribe to download the binaries, so I think it could be a good thing to distribute ourselves the binaries from their source in the future...

The link I give is about fx9860, so they are some thing to do before use this for the Prizm :
* In addin.ld change "rom  : o = 0x00300200" by "rom  : o = 0x00300000"
* crt.s need to be modified (we need to to do a reverse-engineering on the Prizm initilization code)
* a g3a wrapper

Edit :
Okay, so I disassembled Converter addin this morning (downloaded on casio.edu) to try to isolate the init stuff.
The complete disassembled sources (all conv.g3a), with only some labels to understand more the code (because 200 lines of assembly without any label to indicate constant values, loops and functions is really hard to read) is here http://pastebin.com/xT8XNAhH

I rewrote the code that seems to be the init stuff, and as I expected it's very similar to the fx9860 crt0.s written by SimLo and/or Andreas, but it seems call only _GLibAddinAplExecutionCheck after the ram is initialized, and immediately jump to _main...
So it's either the Prizm OS does a part of the initialization that was did by the addin code in fx9860 OS, or a part of the Converter code I thought it's the "_main" code is in fact init code.
Maybe Simon Lothar already isolate the init stuff, so, if you see this, please say what you think about that...
crt0.s : http://pastebin.com/ccE3NPhZ
my addin.ld : http://pastebin.com/YMrdDHWS

(and really sorry for my poor english ;D)
« Last Edit: February 16, 2011, 08:53:22 am by Kristaba »

Offline JosJuice

  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1344
  • Rating: +66/-14
    • View Profile
Re: Compiling stuff for Prizm
« Reply #1 on: February 15, 2011, 09:31:41 am »
Great! I can't really check this out now, since I don't have a Prizm yet... But it certainly does look nice. Is this mostly for assembly, or is it for C?

* In addin.ld change "rom  : o = 0x00300200" by "rom  : o = 0x00300000"
Shouldn't this be 0x00307000 on the Prizm?

Offline Kristaba

  • LV1 Newcomer (Next: 20)
  • *
  • Posts: 16
  • Rating: +5/-0
    • View Profile
Re: Compiling stuff for Prizm
« Reply #2 on: February 16, 2011, 09:10:52 am »
Great! I can't really check this out now, since I don't have a Prizm yet... But it certainly does look nice. Is this mostly for assembly, or is it for C?

* In addin.ld change "rom  : o = 0x00300200" by "rom  : o = 0x00300000"
Shouldn't this be 0x00307000 on the Prizm?

Yeah, I know the problem because I haven't my one yet too :/
It's a fully GCC so you can compile a lot of languages, mainly asm and C, but also C++ (with some change to remove the runtime), Ada, Fortan, etc...

And no, it seems Prizm set the MMU to 0x300000 as the first code address (Andreas wrote this in Casio Kingdom same days ago)

Edit 02/16/11 :
First post updated
« Last Edit: February 16, 2011, 09:11:26 am by Kristaba »

Offline DJ Omnimaga

  • Clacualters are teh gr33t
  • CoT Emeritus
  • LV15 Omnimagician (Next: --)
  • *
  • Posts: 55943
  • Rating: +3154/-232
  • CodeWalrus founder & retired Omnimaga founder
    • View Profile
    • Dream of Omnimaga Music
Re: Compiling stuff for Prizm
« Reply #3 on: February 16, 2011, 04:52:51 pm »
Hmm nice, hopefully this could be useful, since both calcs are similar processor-wise.

Offline SimonLothar

  • LV4 Regular (Next: 200)
  • ****
  • Posts: 129
  • Rating: +35/-1
    • View Profile
Re: Compiling stuff for Prizm
« Reply #4 on: March 04, 2011, 04:00:32 pm »
I attached the current version of insight (see directory projects\insight\insight.g3a). The source and the tools to build the g3a are included, too. Only one exception: the BIN-directory of the legacy CASIO fx-9860 SDK, which is needed, is not included.

EDIT:
New version: http://ourl.ca/9205/182330
version 1.01 removed.
« Last Edit: March 07, 2011, 11:47:05 am by SimonLothar »
I'll be back.

Offline DJ Omnimaga

  • Clacualters are teh gr33t
  • CoT Emeritus
  • LV15 Omnimagician (Next: --)
  • *
  • Posts: 55943
  • Rating: +3154/-232
  • CodeWalrus founder & retired Omnimaga founder
    • View Profile
    • Dream of Omnimaga Music
Re: Compiling stuff for Prizm
« Reply #5 on: March 06, 2011, 02:04:08 pm »
Nice, I just checked and I like it so far. :D

Offline SimonLothar

  • LV4 Regular (Next: 200)
  • ****
  • Posts: 129
  • Rating: +35/-1
    • View Profile
Re: Compiling stuff for Prizm
« Reply #6 on: March 07, 2011, 11:45:59 am »
Insight version 1.02:
RTC read and set; battery voltage; new syscalls; a new library fxCG_TOOLS.LIB; 256 color bitmap to fxCG icon converter; memory search; memory backup.

Outdated: update here http://ourl.ca/9205/187104
« Last Edit: March 20, 2011, 09:50:19 am by SimonLothar »
I'll be back.

Offline DJ Omnimaga

  • Clacualters are teh gr33t
  • CoT Emeritus
  • LV15 Omnimagician (Next: --)
  • *
  • Posts: 55943
  • Rating: +3154/-232
  • CodeWalrus founder & retired Omnimaga founder
    • View Profile
    • Dream of Omnimaga Music
Re: Compiling stuff for Prizm
« Reply #7 on: March 07, 2011, 03:35:27 pm »
Cool, thanks for the update. :D

Offline JonimusPrime

  • LV6 Super Member (Next: 500)
  • ******
  • Posts: 389
  • Rating: +25/-5
    • View Profile
    • Jonimoose.net
Re: Compiling stuff for Prizm
« Reply #8 on: March 10, 2011, 11:44:04 pm »
I actually have my own built toolchain I built based on GCC as I didn't want to register to dl the one from that KPIT site. It can be found at http://jonimoose.net/prizm/sh3-unknown-elf/ the two tars are identical one just used xz compression to be smaller.

"Always code as if the person who will maintain your code is a maniac serial killer that knows where you live" -Unknown

"If you've done something right no one will know that you've done anything at all" -Futurama

"Have a nice day, or not, the choice is yours." Tom Steiner

Offline DJ Omnimaga

  • Clacualters are teh gr33t
  • CoT Emeritus
  • LV15 Omnimagician (Next: --)
  • *
  • Posts: 55943
  • Rating: +3154/-232
  • CodeWalrus founder & retired Omnimaga founder
    • View Profile
    • Dream of Omnimaga Music
Re: Compiling stuff for Prizm
« Reply #9 on: March 10, 2011, 11:48:25 pm »
Cool to hear Jonimus. :D

Offline SimonLothar

  • LV4 Regular (Next: 200)
  • ****
  • Posts: 129
  • Rating: +35/-1
    • View Profile
Re: Compiling stuff for Prizm
« Reply #10 on: March 20, 2011, 09:45:40 am »
Insight version 1.03:
a little display demo: moving and bouncing objects; a HTMLHELP-file with some information concerning syscalls of fx-9860- and fx-CG-systems (to be continued).

EDIT: ah, yes. @cfxm: and a new pair of my cute icons, which everyone loves. ;D

EDIT(2011-04-03):
Updated: http://ourl.ca/9205/193577
version 1.03 removed
« Last Edit: April 03, 2011, 11:05:35 am by SimonLothar »
I'll be back.

Offline fxdev

  • LV4 Regular (Next: 200)
  • ****
  • Posts: 177
  • Rating: +34/-6
    • View Profile
Re: Compiling stuff for Prizm
« Reply #11 on: March 20, 2011, 10:18:07 am »
I totally like the display routine! :w00t:

Offline DJ Omnimaga

  • Clacualters are teh gr33t
  • CoT Emeritus
  • LV15 Omnimagician (Next: --)
  • *
  • Posts: 55943
  • Rating: +3154/-232
  • CodeWalrus founder & retired Omnimaga founder
    • View Profile
    • Dream of Omnimaga Music
Re: Compiling stuff for Prizm
« Reply #12 on: March 21, 2011, 01:24:45 am »
For a bit I thought the display thing was separate from Insight and I couldn't find the file, so I had to sign up on Casio site to download the 9860G SDK and stuff, but then I realized it was part of Insight. X.x

Anyway this looks nice. I'm glad to see more showcases of SH3 ASM programs.

EDIT: Here's a screenshot (well... sort-of). Don't use Internets Exploder to ruin it.
« Last Edit: March 21, 2011, 01:43:28 am by DJ_O »

Offline SimonLothar

  • LV4 Regular (Next: 200)
  • ****
  • Posts: 129
  • Rating: +35/-1
    • View Profile
Re: Compiling stuff for Prizm
« Reply #13 on: March 21, 2011, 10:58:50 am »
I totally like the display routine!
So? Then if you like it crowded, try this...

@DJ_O: it is C, not assembler!

Code: [Select]
static unsigned int lastrandom=0x12345678;
unsigned short random( int seed = 0 ){
    if (seed) lastrandom=seed;
    lastrandom = ( 0x41C64E6D*lastrandom ) + 0x3039;
    return ( lastrandom >> 16 );
}

#define NSHAPES 100

//
int MoveOne( TBdispFillArea a[], TShapeProps sp[], int idx ){
int vy1, vy2, j, k;
int xoverlap, yoverlap, overlap;
int xd, yd;
a[idx].x1 += sp[idx].dx;
if ( a[idx].x1 >= 384 - sp[idx].wx){
sp[idx].dx = -sp[idx].dx;
a[idx].x1 += sp[idx].dx;
sp[idx].dx = -1;  // cold wall
return 0;
}
if ( a[idx].x1 <= 1){
sp[idx].dx = -sp[idx].dx;
a[idx].x1 += sp[idx].dx;
sp[idx].dx = 3; // hot wall
return 0;
}
for (j=0;j<NSHAPES;j++){
overlap = 0;
if ( j != idx ){
xd = a[idx].x1 - a[j].x1;
yd = a[idx].y1 - a[j].y1;
if ( xd * xd + yd * yd < 100 ) overlap = 1;
if ( overlap ) break;
}
}
if ( overlap ){
sp[idx].dx = -sp[idx].dx;
a[idx].x1 += sp[idx].dx;
k = sp[idx].dx;
sp[idx].dx = sp[j].dx;
sp[j].dx = -k;
return 0;
}

a[idx].y1 += sp[idx].dy;
if ( a[idx].y1 >= 216 - sp[idx].wy){
sp[idx].dy = -sp[idx].dy;
a[idx].y1 += sp[idx].dy;
return 0;
}
if ( a[idx].y1 <= 1){
sp[idx].dy = -sp[idx].dy;
a[idx].y1 += sp[idx].dy;
return 0;
}
for (j=0;j<NSHAPES;j++){
overlap = 0;
if ( j != idx ){
xd = a[idx].x1 - a[j].x1;
yd = a[idx].y1 - a[j].y1;
if ( xd * xd + yd * yd < 100 ) overlap = 1;
if ( overlap ) break;
}
}
if ( overlap ){
sp[idx].dy = -sp[idx].dy;
a[idx].y1 += sp[idx].dy;
k = sp[idx].dy;
sp[idx].dy = sp[j].dy;
sp[j].dy = -k;
return 0;
}

k = 0;
if (sp[idx].dy<0) k -= sp[idx].dy; else k += sp[idx].dy;
if (sp[idx].dx<0) k -= sp[idx].dx; else k += sp[idx].dx;
switch (k){
case 2 : sp[idx].color = 0x001F ; break;
case 3 : sp[idx].color = 0x03FF ; break;
case 4 : sp[idx].color = 0x07E0 ; break;
case 5 : sp[idx].color = 0xFFC0 ; break;
case 6 : sp[idx].color = 0xF800 ; break;
}

a[idx].mode = 0;
Bdisp_AreaClr( &sp[idx].saved, 1, -1 );
a[idx].mode = 1;

a[idx].x2 = a[idx].x1 + sp[idx].wx;
a[idx].y2 = a[idx].y1 + sp[idx].wy;
Bdisp_AreaClr( &a[idx], 1, sp[idx].color );
memcpy( &sp[idx].saved, &a[idx], sizeof( TBdispFillArea ) );

/*
vy1 = a[idx].y1 - sp[idx].wy / 2;
vy2 = a[idx].y2 + sp[idx].wy / 2;
if ( vy1 < 0 ) vy1 = 0;
if ( vy2 > 215 ) vy2 = 215;
Bdisp_PutDisp_DD_stripe( vy1, vy2 );
*/
return 1;

}

#define V 1

void F7_Handler(){
TBdispFillArea ar[NSHAPES];
TShapeProps mp[NSHAPES];
int ticks, i, iwork;
ticks = RTC_GetTicks();
random( ticks );
while (!RTC_Elapsed_ms( ticks, 100 ));

for ( i=0;i<NSHAPES;i++){
ar[i]. mode = 1;
memset( &mp[i], 0, sizeof( TShapeProps ) );
mp[i].wx = 10;
mp[i].wy = 10;
ar[i].x1 = 11 * ((i >> 2)+1);
mp[i].color = random();
ar[i].y1 = 10 + 11 * ( i & 0x3 );

iwork = random();
iwork = ( 3 * iwork ) / 0x10000 + 1;
if ( random() & 0x8000 ) iwork = -iwork;
mp[i].dx = iwork;
iwork = random();
iwork = ( 3 * iwork ) / 0x10000 + 1;
if ( random() & 0x8000 ) iwork = -iwork;
mp[i].dy = iwork;

ar[i].x2 = ar[i].x1 + mp[i].wx;
ar[i].y2 = ar[i].y1 + mp[i].wy;
}
while ( !(*(unsigned short*)0xA44B0000) ){
for (i=0;i<NSHAPES;i++){
MoveOne( ar, mp, i );
}
   Bdisp_PutDisp_DD();
}
}

Attachment removed. Actual version included here:
http://ourl.ca/9205/218371
« Last Edit: June 11, 2011, 10:46:49 am by SimonLothar »
I'll be back.

Offline DJ Omnimaga

  • Clacualters are teh gr33t
  • CoT Emeritus
  • LV15 Omnimagician (Next: --)
  • *
  • Posts: 55943
  • Rating: +3154/-232
  • CodeWalrus founder & retired Omnimaga founder
    • View Profile
    • Dream of Omnimaga Music
Re: Compiling stuff for Prizm
« Reply #14 on: March 21, 2011, 02:12:26 pm »
Yeah sorry I meant SH3 C and ASM. I am aware that this is C. I tend to just say ASM sometimes when it comes to calculator hacking, having been used to a platform with no decent C capabilities for years (the TI-83 Plus series). ASM here would be in reference to Qwerty.55 and z80man, although they use hexadecimal rather than SH3 mnemonics.