Jump to content



Photo
* * * * * 1 votes

Power Graphic 2 Development Thread


  • Please log in to reply
26 replies to this topic

#1 flyingfisch

flyingfisch

    Casio Maniac

  • Deputy
  • PipPipPipPipPipPipPipPip
  • 1891 posts
  • Gender:Male
  • Location:OH,USA
  • Interests:Aviation, Skiing, Programming, Mountain Biking.

  • Calculators:
    fx-9860GII
    fx-CG10 PRIZM

Posted 21 December 2012 - 03:00 PM

I'm making this thread for things that would be useful for C developers with Power Graphic 2 calcs.

To start with, mylib (by hayzel) will work unmodified.

Also, Casimo posted in that thread how to make monochrome lib work for the Power Graphic 2 series. I am quoting it here for easy reference:

To get MonochromeLib working, replace

static int SysCallCode[] = {0xD201422B,0x60F20000,0x80010070};
static int (*SysCall)( int R4, int R5, int R6, int R7, int FNo ) = (void*)&SysCallCode;
char* ML_vram_adress()
{
return (char*)((*SysCall)(0, 0, 0, 0, 309));
}

by

typedef char*(*sc_cpv)(void);
const unsigned int sc0135[] = { 0xD201D002, 0x422B0009, 0x80010070, 0x0135 };
#define ML_vram_adress (*(sc_cpv)sc0135)



If anyone knows what other libs work/how to modify them so they will work, please be sure to post it here :)
  • Casimo likes this

#2 Casimo

Casimo

    Casio Overlord

  • Members
  • PipPipPipPipPipPipPip
  • 641 posts
  • Gender:Not Telling

Posted 21 December 2012 - 03:32 PM

At http://prizm.cemetec...ess_PRGM_GetKey is an IsKeyDown-alternative function.
Just add this on top of your code and your game is compitable to the new calculators :clap:!
#define __KEYBIOS_H__
#include "fxlib.h"
#define KEY_CHAR_0 71
#define KEY_CHAR_1 72
#define KEY_CHAR_2 62
#define KEY_CHAR_3 52
#define KEY_CHAR_4 73
#define KEY_CHAR_5 63
#define KEY_CHAR_6 53
#define KEY_CHAR_7 74
#define KEY_CHAR_8 64
#define KEY_CHAR_9 54
#define KEY_CHAR_DP 61
#define KEY_CHAR_EXP 51
#define KEY_CHAR_PMINUS 41
#define KEY_CHAR_PLUS 42
#define KEY_CHAR_MINUS 32
#define KEY_CHAR_MULT 43
#define KEY_CHAR_DIV 33
#define KEY_CHAR_FRAC 75
#define KEY_CHAR_LPAR 55
#define KEY_CHAR_RPAR 45
#define KEY_CHAR_COMMA 35
#define KEY_CHAR_STORE 25
#define KEY_CHAR_LOG 66
#define KEY_CHAR_LN 56
#define KEY_CHAR_SIN 46
#define KEY_CHAR_COS 36
#define KEY_CHAR_TAN 26
#define KEY_CHAR_SQUARE 67
#define KEY_CHAR_POW 57
#define KEY_CTRL_EXE 31
#define KEY_CTRL_DEL 44
#define KEY_CTRL_AC 32
#define KEY_CTRL_FD 65
#define KEY_CTRL_EXIT 47
#define KEY_CTRL_SHIFT 78
#define KEY_CTRL_ALPHA 77
#define KEY_CTRL_OPTN 68
#define KEY_CTRL_VARS 58
#define KEY_CTRL_UP 28
#define KEY_CTRL_DOWN 37
#define KEY_CTRL_LEFT 38
#define KEY_CTRL_RIGHT 27
#define KEY_CTRL_F1 79
#define KEY_CTRL_F2 69
#define KEY_CTRL_F3 59
#define KEY_CTRL_F4 49
#define KEY_CTRL_F5 39
#define KEY_CTRL_F6 29
#define KEY_CTRL_MENU 48
#ifndef OS2Change
#define OS2Change
#ifndef OS2Change_GetOS2
#define OS2Change_GetOS2
typedef int(*sc_i2cp2sip)(char*, char*, short int*, short int*);
const unsigned int sc0015[] = { 0xD201D002, 0x422B0009, 0x80010070, 0x0015 };
#define GlibGetOSVersionInfo (*(sc_i2cp2sip)sc0015)
int OSVersionAsInt(void)
{
unsigned char mainversion;
unsigned char minorversion;
unsigned short release;
unsigned short build;
GlibGetOSVersionInfo( &mainversion, &minorversion, &release, &build );
return ( ( mainversion << 24 ) & 0xFF000000 ) | ( ( minorversion << 16 ) & 0x00FF0000 ) | ( release & 0x0000FFFF );
}
#define isOS2 (OSVersionAsInt() >= 0x02020000)
#define OS2(x,y) ((OSVersionAsInt() >= 0x02020000)?y:x)
#endif
#ifndef OS2Change_Keyboard
#define OS2Change_Keyboard
void delay(void)
{
char i;
for (i=0; i<5; i++){};
}
unsigned char CheckKeyRow(unsigned char code)
{
unsigned char result=0;
short*PORTB_CTRL=(void*)0xA4000102;
short*PORTM_CTRL=(void*)0xA4000118;
char*PORTB=(void*)0xA4000122;
char*PORTM=(void*)0xA4000138;
char*PORTA=(void*)0xA4000120;
short smask;
char cmask;
unsigned char column, row;
column = code>>4;
row = code &0x0F;
smask = 0x0003 << (( row %8)*2);
cmask = ~( 1 << ( row %8) );
if(row <8)
{
  *PORTB_CTRL = 0xAAAA ^ smask;
  *PORTM_CTRL = (*PORTM_CTRL & 0xFF00 ) | 0x00AA;
  delay();
  *PORTB = cmask;
  *PORTM = (*PORTM & 0xF0 ) | 0x0F;
}
else
{
  *PORTB_CTRL = 0xAAAA;
  *PORTM_CTRL = ((*PORTM_CTRL & 0xFF00 ) | 0x00AA)  ^ smask;
  delay();
  *PORTB = 0xFF;
  *PORTM = (*PORTM & 0xF0 ) | cmask;
}

delay();
result = (~(*PORTA))>>column & 1;
delay();
*PORTB_CTRL = 0xAAAA;
*PORTM_CTRL = (*PORTM_CTRL & 0xFF00 ) | 0x00AA;
delay();
*PORTB_CTRL = 0x5555;
*PORTM_CTRL = (*PORTM_CTRL & 0xFF00 ) | 0x0055;
delay();

return result;
}

unsigned char KeyDown(unsigned char keycode)
{
unsigned short key[8];
const unsigned short* keyboardregister = (unsigned short*)0xA44B0000;
if(isOS2)
{
  unsigned char row = keycode%10;
  memcpy(key, keyboardregister, sizeof(unsigned short) << 3);
 
  return (0 != (key[row >> 1] & 1 << keycode / 10 - 1 + ((row & 1) << 3)));
}
else
{
  return CheckKeyRow((keycode % 10) + ((keycode / 10 - 1) << 4));
}
}
unsigned char GetKeyMod(unsigned int *key)
{
unsigned char x, ret;

ret = GetKey(key);

for(x = 0; x < 80; x++)
{
  if(KeyDown(x))
  {
   *key = x;
   break;
  }
}
return ret;
}
#define IsKeyDown(x) KeyDown(x)
#define IsKeyUp(x) !KeyDown(x)
#define GetKey(x) GetKeyMod(x)
#endif
#endif

http://prizm.cemetec...php/Change_freq works, too.
To have a battery-indicator for the new series, look here:
int GetMainBatteryVoltagePointer()
{
unsigned int ea;
unsigned int j;
ea = *(unsigned int*)0x8001007C;
ea = ea + 0x049C*4;
ea = *(unsigned int*)(ea);
while (*(unsigned short*)(ea) != 0xE464)
{
ea = ea + 2;
};
ea = ea + 2;
j = *(unsigned char*)(ea + 1);
j = 4*j;
j = (ea + j + 4) & 0xFFFFFFFC;
return *(unsigned int*)(j);
}
int GetBatteryStatus( int battery, int*firstlevel, int*secondlevel )
{
int (*iGBS)( int ) = 0; // declare an int function pointer
int*battconfig = (int*)0x80000334;
iGBS = (int(*)(int))GetMainBatteryVoltagePointer();
*firstlevel = 0x2AA;
*secondlevel = 0x288;
if (iGBS!=0) return (*iGBS)( battery );
else return 0;
}

int MainBatteryPercentage( void )
{
int firstlevel, secondlevel;
int i;
if ( IsEmulator() ){
i = 100;
firstlevel = 70;
secondlevel = 65;
}
else i = GetBatteryStatus( 1, &firstlevel, &secondlevel );
	
if (firstlevel > 0 ) return ( 200*i )/(firstlevel*3);
else return 0;
}

And hereyou can download the new revolutionfx (it's a modificated version of 0.3).

Edited by Casimo, 22 January 2013 - 10:51 AM.

  • Casimo likes this

#3 Anonymouse

Anonymouse

    Casio Addict

  • Members
  • PipPipPip
  • 58 posts
  • Gender:Male

  • Calculators:
    CASIO Graph 75

Posted 27 December 2012 - 12:00 AM

This isn't for those with an SH-4 processor, right?

#4 flyingfisch

flyingfisch

    Casio Maniac

  • Deputy
  • PipPipPipPipPipPipPipPip
  • 1891 posts
  • Gender:Male
  • Location:OH,USA
  • Interests:Aviation, Skiing, Programming, Mountain Biking.

  • Calculators:
    fx-9860GII
    fx-CG10 PRIZM

Posted 27 December 2012 - 01:25 AM

This isn't for those with an SH-4 processor, right?


It is for calcs with the sh4a processor. ;)

#5 Casimo

Casimo

    Casio Overlord

  • Members
  • PipPipPipPipPipPipPip
  • 641 posts
  • Gender:Not Telling

Posted 27 December 2012 - 07:44 AM

It's for both calculators.

Edited by Casimo, 31 December 2012 - 10:25 AM.


#6 Dark Storm

Dark Storm

    Newbie

  • Members
  • Pip
  • 3 posts

  • Calculators:
    fx-9750GII (modded),

Posted 03 January 2013 - 01:19 PM

Great !
This new has succefully been shared on Planet-Casio :)
But when I tryed to include these codes in my project, I've got an Illegal token "0x02020000" error...
Have you ever seen this problem ?
Thank you for your work, and your help ! :)

I'm french, so excuse me if my english is not perfect...

Edited by Dark Storm, 03 January 2013 - 01:20 PM.


#7 Casimo

Casimo

    Casio Overlord

  • Members
  • PipPipPipPipPipPipPip
  • 641 posts
  • Gender:Not Telling

Posted 03 January 2013 - 03:27 PM

I changed the first part (the 'Just add this on top of your code and your game is compitable to the new calculators' - part). Is it better now?

#8 flyingfisch

flyingfisch

    Casio Maniac

  • Deputy
  • PipPipPipPipPipPipPipPip
  • 1891 posts
  • Gender:Male
  • Location:OH,USA
  • Interests:Aviation, Skiing, Programming, Mountain Biking.

  • Calculators:
    fx-9860GII
    fx-CG10 PRIZM

Posted 03 January 2013 - 03:40 PM

Hello Dark Storm and welcome to UCF! You should introduce yourself.

#9 Dark Storm

Dark Storm

    Newbie

  • Members
  • Pip
  • 3 posts

  • Calculators:
    fx-9750GII (modded),

Posted 04 January 2013 - 10:51 AM

Thank you so much Casimo !
It work now :D

#10 louloux

louloux

    Casio Fan

  • Members
  • PipPip
  • 32 posts
  • Gender:Male

  • Calculators:
    Graph 85 SD
    Graph 35+
    fx-92

Posted 04 January 2013 - 10:55 AM

Thanks a lot ! I adapted some of my add-ins ;)

#11 Casimo

Casimo

    Casio Overlord

  • Members
  • PipPipPipPipPipPipPip
  • 641 posts
  • Gender:Not Telling

Posted 04 January 2013 - 11:10 AM

Update: I've just seen that it is not possible to use KeyDown and GetKey at the same time, because the keycodes are changed: If you have the SH4, GetKey still returns the "old" values, but the keycodes have got the "new" numbers.
For example:

#define KEY_CHAR_0 OS2(0x30,71)
GetKey(&key);
-> if the key '0' was pressed:
if(key == KEY_CHAR_0) is the same as
if(key == 71), but the correct code is 0x30, so the function doesn't return True :(

Does someone have got an idea how to fix that bug?

#12 Anonymouse

Anonymouse

    Casio Addict

  • Members
  • PipPipPip
  • 58 posts
  • Gender:Male

  • Calculators:
    CASIO Graph 75

Posted 04 January 2013 - 12:36 PM

Update: I've just seen that it is not possible to use KeyDown and GetKey at the same time, because the keycodes are changed: If you have the SH4, GetKey still returns the "old" values, but the keycodes have got the "new" numbers.
For example:

#define KEY_CHAR_0 OS2(0x30,71)
GetKey(&key);
-> if the key '0' was pressed:
if(key == KEY_CHAR_0) is the same as
if(key == 71), but the correct code is 0x30, so the function doesn't return True :(

Does someone have got an idea how to fix that bug?

This is a big PiTA, but you could write a custom GetKey replacement that will either:
A) Loop through all the keys with KeyDown (probably not a good idea)
B) Use GetKey then convert the keycodes.

Then the question is how to actually give it the name GetKey: to my knowledge you'll have to replace the standard library.

#13 Casimo

Casimo

    Casio Overlord

  • Members
  • PipPipPipPipPipPipPip
  • 641 posts
  • Gender:Not Telling

Posted 05 January 2013 - 01:31 PM

Converting the codes would be too hard. I changed the post above.
Now I loop through all keys after GetKey was called. I think that's the easiest way.

#14 supercalcfan

supercalcfan

    Newbie

  • Members
  • Pip
  • 4 posts

Posted 04 February 2013 - 04:22 AM

I am VERY new to C and calculators, but I have been trying to port CalcCity to the new SH4 model (for personal use only of course).

It now runs but sometimes crashes. Is there any debug I can use on the calcuator itself? It runs fine in the emulator!

Also, what do I need to do with the modified revolutionFX files? How does it replace revolution.h etc?

Thanks!

EDIT: And what do I need to know about Epsilion when replacing it with RevolutionFX? (This could be a source of my crashes?)

Edited by supercalcfan, 04 February 2013 - 04:25 AM.


#15 Casimo

Casimo

    Casio Overlord

  • Members
  • PipPipPipPipPipPipPip
  • 641 posts
  • Gender:Not Telling

Posted 04 February 2013 - 02:36 PM

If this (step-by-step guide) doesn't work just give me the source.


EDIT:

Hello supercalcfan and welcome to UCF! You should introduce yourself.

Edited by Casimo, 04 February 2013 - 07:17 PM.


#16 supercalcfan

supercalcfan

    Newbie

  • Members
  • Pip
  • 4 posts

Posted 04 February 2013 - 11:17 PM

Thanks, I will try and figure this out myself for the time being, your page looks like it has the answers I need! Now to check on the results. ;)

I keep getting an error on this line:

GlibGetOSVersionInfo( &mainversion, &minorversion, &release, &build );

...which messes stuff up along the way, what's happening? (keep in mind I am very new to C)

Edited by supercalcfan, 05 February 2013 - 12:22 AM.


#17 Casimo

Casimo

    Casio Overlord

  • Members
  • PipPipPipPipPipPipPip
  • 641 posts
  • Gender:Not Telling

Posted 05 February 2013 - 02:40 PM

Could you post the error message?

#18 supercalcfan

supercalcfan

    Newbie

  • Members
  • Pip
  • 4 posts

Posted 05 February 2013 - 09:46 PM

Sorry, I forgot to include that. Here is the message.

C:\Users\Shirley\Desktop\Calc\CityNEW\revolution.c(56) : C1016 (W) Argument mismatch

I only get that with the modified revolution library. It also causes a lot of other errors further down.


C:\Users\Shirley\Desktop\Calc\CityNEW\revolution.c(56) : C1016 (W) Argument mismatch
C:\Users\Shirley\Desktop\Calc\CityNEW\revolution.c(56) : C1016 (W) Argument mismatch
C:\Users\Shirley\Desktop\Calc\CityNEW\revolution.c(56) : C1016 (W) Argument mismatch
C:\Users\Shirley\Desktop\Calc\CityNEW\revolution.c(1820) : C1016 (W) Argument mismatch
C:\Users\Shirley\Desktop\Calc\CityNEW\revolution.c(1834) : C1016 (W) Argument mismatch
C:\Users\Shirley\Desktop\Calc\CityNEW\revolution.c(2777) : C2118 (E) Prototype mismatch "GetPixel"
C:\Users\Shirley\Desktop\Calc\CityNEW\revolution.c(2783) : C2118 (E) Prototype mismatch "PlotPixel"
C:\Users\Shirley\Desktop\Calc\CityNEW\revolution.c(2793) : C2118 (E) Prototype mismatch "DrawLine"
C:\Users\Shirley\Desktop\Calc\CityNEW\RTS.c(60) : C2114 (E) Multiple variable declarations
C:\Users\Shirley\Desktop\Calc\CityNEW\RTS.c(61) : C2135 (E) Multiple initialization
C:\Users\Shirley\Desktop\Calc\CityNEW\RTS.c(63) : C2136 (E) Type mismatch
C:\Users\Shirley\Desktop\Calc\CityNEW\RTS.c(69) : C1016 (W) Argument mismatch
C:\Users\Shirley\Desktop\Calc\CityNEW\RTS.c(69) : C1016 (W) Argument mismatch
C:\Users\Shirley\Desktop\Calc\CityNEW\RTS.c(69) : C1016 (W) Argument mismatch
C:\Users\Shirley\Desktop\Calc\CityNEW\RTS.c(69) : C1016 (W) Argument mismatch

Which I again only get with the modified lib - seems to stem from not properly recognizing the OS version in line 56 (my previous post)?

Using the stock Revolution I get no build errors but it crashes on my calculator. (But not in the debugger of the SDK...)

#19 Casimo

Casimo

    Casio Overlord

  • Members
  • PipPipPipPipPipPipPip
  • 641 posts
  • Gender:Not Telling

Posted 06 February 2013 - 05:56 AM

Have you included the header and the sourc file? You just need the .c file.

#20 scientifix

scientifix

    Casio Addict

  • Members
  • PipPipPip
  • 78 posts

  • Calculators:
    fx9860gII

Posted 08 February 2013 - 03:26 PM

Hi everybody,
Could you make a Symbolix v0.45 version for SH4 please ?
It would be very helpful !
Thank you !
scientifix

#21 Casimo

Casimo

    Casio Overlord

  • Members
  • PipPipPipPipPipPipPip
  • 641 posts
  • Gender:Not Telling

Posted 08 February 2013 - 03:28 PM

If there aren't any sources of symbolix there's no chance to do that because kucalc is a bit inactive, at the moment.

#22 scientifix

scientifix

    Casio Addict

  • Members
  • PipPipPip
  • 78 posts

  • Calculators:
    fx9860gII

Posted 08 February 2013 - 03:32 PM

Hi,
Could you ask him to create a SH4 verion of symbolix next time you see him ?
Thank you very much !
scientifix

#23 Casimo

Casimo

    Casio Overlord

  • Members
  • PipPipPipPipPipPipPip
  • 641 posts
  • Gender:Not Telling

Posted 08 February 2013 - 03:35 PM

I can't ask him - I don't know how :blind:.

His last visit: Aug 14 2012 09:46 PM
So this could take much time :closed:...

#24 MicroPro

MicroPro

    Casio Overlord

  • Deputy
  • PipPipPipPipPipPipPip
  • 640 posts
  • Gender:Male
  • Location:Iran

  • Calculators:
    Casio ClassPad 300

Posted 07 March 2013 - 06:26 PM

Did you PM him?

#25 Casimo

Casimo

    Casio Overlord

  • Members
  • PipPipPipPipPipPipPip
  • 641 posts
  • Gender:Not Telling

Posted 07 March 2013 - 06:38 PM

Yes, a month ago.

#26 flyingfisch

flyingfisch

    Casio Maniac

  • Deputy
  • PipPipPipPipPipPipPipPip
  • 1891 posts
  • Gender:Male
  • Location:OH,USA
  • Interests:Aviation, Skiing, Programming, Mountain Biking.

  • Calculators:
    fx-9860GII
    fx-CG10 PRIZM

Posted 07 March 2013 - 09:24 PM

I am afraid you won't be able to get the sources. In another thread (I can't find it just now), Kucalc said that he lost all the source code. :-\

EDIT: link: http://community.cas...em/page__st__40

#27 Casimo

Casimo

    Casio Overlord

  • Members
  • PipPipPipPipPipPipPip
  • 641 posts
  • Gender:Not Telling

Posted 08 March 2013 - 03:23 PM

The link he gave in his post is broken - I can't find the file.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users