My first add-in for this calculator: Description and
Download zip with add-in and source code files, etc. or
http://www.cemetech.net/scripts/countdown.php?/prizm/programs/Lock.zip&path=archives


Much of the code was possible due to help and examples from the brilliant gbl08ma and many other Cemetechians who posted on this forums before and/or PMed me with help recently: Programmer Nerd, AHelper, KermMartian, flyingfisch, Ashbad, JosJuice and many more.

Icons were done by me based on JosJuice's guidance.

Lock add-in is minimalistic and very Casio OS looking interface to power off and subsequently unlock your Prizm/Casio FX-CG. It locks the calculator using Casio's built-in User Name password as registered under System manager (i.e. MAIN MENU/[MENU]->System/[G]->Next page/[F6]->User Name/[F2]). Even if User Name setup is deleted from the System manager, the latest available password (if ever registered) will still work. This also means no additional setup or files in main or storage memory are needed to store your password, i.e. resetting main and storage memories without wiping add-ins will not effect the add-in. Even deleting User password won't effect the add-in: only user name and org will show in red then. Provided a password was ever registered in System manager the add-in will request it to unlock the calculator and to allow return to the main menu via [MENU] key or alternatively the calculator will power down on any other entries. Tested successfully on Casio FX-CG20 (OS 02.00.0200). On the emulator everything besides powering down works. Have fun and contribute any improvements you may have.

I include the source code below (adapted to compile under Windows without libc errors):

Code:

#include <fxcg/display.h>
#include <fxcg/keyboard.h>

char buf[8];
char* pwd = '\0';
int k;
int o;
int v = 1;
/* CODE BY SIMON LOTHAR, AVAILABLE ON "fx_calculators_SuperH_based.chm" version 16 */
// the function assumes, that the RAM-pointer to GetkeyToMainFunctionReturnFlag is loaded
// immediately by a "Move Immediate Data"-instruction
unsigned int SetGetkeyToMainFunctionReturnFlag( unsigned int enabled ) {
int addr, addr2;
// get the pointer to the syscall table
        addr = *(unsigned char*)0x80020071;     // get displacement
        addr++;
        addr *= 4;
        addr += 0x80020070;
        addr = *(unsigned int*)addr;
        if ( addr < (int)0x80020070 ) return 0x101;
        if ( addr >= (int)0x81000000 ) return 0x102;
// get the pointer to syscall 1E99
        addr += 0x1E99*4;
        if ( addr < (int)0x80020070 ) return 0x103;
        if ( addr >= (int)0x81000000 ) return 0x104;

        addr = *(unsigned int*)addr;
        if ( addr < (int)0x80020070 ) return 0x105;
        if ( addr >= (int)0x81000000 ) return 0x106;

        switch ( *(unsigned char*)addr ){
                case 0xD0 : // MOV.L @( disp, PC), Rn (REJ09B0317-0400 Rev. 4.00 May 15, 2006 page 216)
                case 0xD1 :
                case 0xD2 :
                case 0xD3 :
                case 0xD4 :
                case 0xD5 :
                case 0xD6 :
                case 0xD7 :
                case 0xD8 :
                        addr2 = *(unsigned char*)( addr + 1 );  // get displacement
                        addr2++;
                        addr2 *= 4;
                        addr2 += addr;
                        addr2 &= ~3;

                        if ( addr2 < (int)0x80020070 ) return 0x107;
                        if ( addr2 >= (int)0x81000000 ) return 0x108;

                        addr = *(unsigned int*)addr2;
                        if ( ( addr & 0xFF000000 ) != 0x88000000 ) return 0x109;

// finally perform the desired operation and set the flag:
                        if ( enabled ) *(unsigned char*)addr = 0;
                        else *(unsigned char*)addr = 3;

                        break;

                default : addr = 0x100;
}
return addr;
}

static void S(char buffer[8]){
    v = 0;
    int start = 0; // Used for scrolling left and right
   int cursor = 0; // Cursor position
    buffer[0] = '\0'; // This sets the first character to \0, also represented by "", an empty string
    DisplayMBString((unsigned char*)buffer, start, cursor, 2, 6); // Last two parameters are X,Y coords (not in pixels)
    PrintXY(10,6,"  ]", 0, 0);
    while(1){
        GetKey(&k); // Blocking is GOOD.  This gets standard keys processed and, possibly, powers down the CPU while waiting
      if (k == KEY_CTRL_F6) {
         F(1, 0x018E);//'
         F(2, 0x018F);//"
         F(3, 0x0190);//~
         F(6, 0);
         o = 1;
      } else if(k == KEY_CTRL_F1 && o == 1) {
         k = 39;//'
      } else if(k == KEY_CTRL_F2 && o == 1) {
         k = KEY_CHAR_DQUATE;
      } else if(k == KEY_CTRL_F3 && o == 1) {
         k = 126;//~
      } else if(k == KEY_CTRL_EXE){// Ok
          int i;
         i = strcmp(buffer,pwd);
         if (i == 0) {//Match
            PrintXY(2,6,"  ********]", 0, 0);
            SetGetkeyToMainFunctionReturnFlag(1); //Enable menu return
            M("  Complete!","  Press [MENU]", "  to unlock");
         } else {
            M("","   Mismatch", "");
         }
        }else if(k == KEY_CTRL_EXIT){// Aborted
         SetSetupSetting((unsigned int)0x14, 0x84);
         S(buf);
      }
        if(k && k < 30000) {
         cursor = EditMBStringChar((unsigned char*)buffer, 8, cursor, k);
            DisplayMBString((unsigned char*)buffer, start, cursor, 2, 6);
      }else{
            EditMBStringCtrl((unsigned char*)buffer, 8, &start, &cursor, &k, 2, 6);
        }
       PrintXY(10,6,"  ]", 0, 0);
   }
   return;
}

void M(char* m1, char* m2, char* m3) {
   Cursor_SetFlashOff();
   DisplayStatusArea();
   MsgBoxPush(4);
   PrintCXY(31, 15, (const char*) " Turn OFF:any key ", 0, -1, 0xFFFF, 0x001F, 1, 0);
   PrintXY(7,3,m1, 0, 0);
   PrintXY(6,4,m2, 0, 0);
   PrintXY(7,5,m3, 0, 0);
   GetKey(&k);
   MsgBoxPop();
   v = 1;
   main();
}

void main() {
   Bkey_SetAllFlags(0x80);
   DefineStatusAreaFlags(3, SAF_BATTERY | SAF_ALPHA_SHIFT, 0, 0);
   int c;
   char* usr;
   char* org;
   char* flagpointer = (char*)0x80BE0000;
   while(*flagpointer == 0x0F) {
      if(*(flagpointer+0x2C) != '\0') {
         pwd = (flagpointer+0x2C);
         usr = (flagpointer+0x18);
         org = (flagpointer+0x04);
         c = 0;
      }
      else {//use previous info in red if User Name deleted 
         c = 4;
      }
      flagpointer = flagpointer + 0x40;
   }
   if(pwd == '\0') {
      SetSetupSetting((unsigned int)0x14, 0);
      DisplayStatusArea();
      Bdisp_EnableColor(1);
      SetBackGround(7);
      PrintXY(1,1,"  In System Manager", 0x20, 1);
      PrintXY(1,2,"  go Next Page [F6]", 0x20, 0);
      PrintXY(1,3,"  then User Name [F2].", 0x20, 0);
      PrintXY(1,4,"  Edit with [F1] and", 0x20, 0);
      PrintXY(1,5,"  register with [EXE],", 0x20, 0);
      PrintXY(1,6,"  then [F1] and [EXIT]", 0x20, 0);
      PrintXY(1,7,"  to complete.", 0x20, 0);
      while (1) {
         GetKey(&k);
         APP_SYSTEM();
      }
   } else {
      SetGetkeyToMainFunctionReturnFlag(0); //Disable menu return   
      SetSetupSetting((unsigned int)0x14, 0x84);
      DisplayStatusArea();
      int iresult;
      if (o == 0) {
         F(6, 0x018D);
      }else{
         F(1, 0x018E);//'
         F(2, 0x018F);//"
         F(3, 0x0190);//~
      }
      PrintXY_2(0,-1,1,2018,1);//PrintXY(1,1,"  User Name", 0x20, 1);
      PrintXY(1,2,"  [", 0, 0);
      locate_OS(2,2);
      PrintLine2(0, 1, usr, 0, -1, 20, c, 7);
      PrintXY(21,2,"  ]", 0, 0);
      PrintXY_2(0,-1,3,2019,1);//PrintXY(1,3,"  Organization", 0x20, 1);
      PrintXY(1,4,"  [", 0, 0);
      locate_OS(2,4);
      PrintLine2(0, 1, org, 0, -1, 20, c, 7);
      PrintXY(21,4,"  ]", 0, 0);
      PrintXY_2(0,-1,5,2020,1);//PrintXY(1,5,"  Password", 0x20, 1);
      PrintXY(1,6,"  [", 0, 0);
      if (v == 1) {
         v = 0;
         PowerOff(1);
      }
      S(buf);
   }
}
void F(int iF, int iD) {
      int iresult;
      GetFKeyPtr(iD, &iresult);
      FKey_Display(iF-1, (int*)iresult);
}

/* CODE FROM libc/string.c */

int strcmp(const char *s1, const char *s2) {
   while (*s1 != 0 && *s2 != 0) {
      if (*s1 != *s2)
         break;
      s1++;
      s2++;
   }
   return *s1 - *s2;
}


To install the add-in you can follow the sticky post the following way:
Step 1: unzip Lock.g3a from Archives
KermMartian wrote:
...
Step 2: Plug your Prizm into your computer with a MiniUSB cable. On the Prizm's screen, a menu will pop up; press F1 to make your Prizm look like a flash drive to your computer.

Step 3: Copy all the .g3* files into your calculator, which will appear as a Removable Drive in My Computer (if you're on Windows) or in the Finder (if you're using a Mac). Any .g3a files should go in the root (main folder) of the drive...
Happy New Year to All!

Please kindly test and leave your comments on my new version of the Lock add-in:

Download here from Archive.

The interface is more distinctive of successful and unsuccessful password entry by displaying Main Menu or powering down screens respectively.

Main Menu icons are also more in-line with the OS now - see below icon ("L" Alpha Code one, not the "M" one) selected and unselected:


Also I reworked the addin for when no User info has ever been registered.

I hope you will find the Lock Add-In useful and I look forward to receiving your comments.
Yeah, that's looks pretty good ! I like the graphics in the OS style ! With the "festivities" (don't know if that's the good word, I mean with thé new year and Christmas you keep moving a lot these days, at least in my case) I cannot try it immediatly but in the next week, I'll have my calc around and will try it, that's looks to be a great work ! Smile
Stay around for more from me Wink.
Thanks, Nemhardy. I'm looking forward to your feedback. Please remember that you need to make sure first that a User Name is setup in the OS native System Manager. (Especially if you also test the first version of my add-in as it had APP_SYSTEM call to take you to System Manager if you had no info under User Name - I have removed this call in the updated version to avoid confusing users who would not immediately see how to restart the add-in after a call to a built-in app).

Also if you could confirm what firmware version you are on please - I noticed differences even between emulator and real calculator with the same firmware versions - it was only noticeable if the number of icons in the MAIN MENU was not divisible by 4 but I managed to take care of it. I don't know if more will be needed for the previous versions of the firmware.
Hi All,

Just to let you know that the updated version is now available in the archive www.cemetech.net/scripts/countdown.php?/prizm/programs/Lock.zip&path=archive
Depending on your feedback and my abilty to sort out my compiler issues I will build a version with a watch (and possibly stopwatch/timer) and extra power management features (and possibly replacing CONV.G3A add-in while keeping Conversion functionality in Run-Mat).

I am really looking forward to all your feedback.
Functionality wise I now cannot decide if to minimize this add-in to current functionality but eliminating the unnecessary popup messages like Complete, Mismatch and press Menu key as I am very confident one could achieve this and go into main menu or runmatrix or any other Main Menu app or even in case of no password set up straight to User Name Edit settings in system manager straight from the add-in or...
keep intermediary popups and add extra functionality already available in other add-ins like watch/timers and power management (the latest made look very OS like).

I feel the first option is better and would allow to replace Conversion add-in described earlier with the second I'm not sure how it would be perceived and if using it instead of CONV.g3a would be possible.

Please leave your feedback what developments on this you would want.

Kind regards,

A~nka
My development went more along the first option root described here however i managed to incorporate some of the power management functions and battery meter without diviating from native os look. Even added reset options in case my redesigning back plate requires this etc and kept it compact enough to replace conversion add in without loss of its functionality but now started thinking of having it configurable to run custom scripts which i plan to share with g-clock add in... So currently it has option to automatically go to main menu or launching any of the integrated in os apps (not add-ins yet) or making changes to auto power time out or one off resets. Giving it more functionality may take me over the limit I decided to enforce for making it a conversion add in replacement but I think i could try to squeeze in a script execution option to kick in upon unlock, but any editing of the script will have to be done outside of this lock add-in - so I'm planning to have my other g-clock addin to handle such editing in its setting to be saved to main memory or if this is too difficult to have it as a shared file editable on a pc before exporting to the storage memory...

Any other ideas are most welcome
Hi All,

I uploaded a newer version which was completed 7 months ago to the archive https://www.cemetech.net/scripts/countdown.php?/prizm/programs/Lock.zip&location=archive.

As you will see from the readme it has the following now:

Code:

|Provided a password was ever registered in System manager
|
|==>the add-in will lock and power down the calculator.
   |
   |==>The add-in then request this password on turning the calculator
      |
      |== >If the matching password is entered
      |   |
      |   |==>the MAIN MENU is returned (now WITHOUT extra pop-ups and subsequent presses of [MENU])
      |   or
      |   |==>or a bult-in main menu APP of your choice is launched
      |
      |==>If the calulator is left idle beyond the backlight duration setting the add-in will power off the calculator.

* your choice of where your are taken upon unlock will be remembered by the add-in until you  change it (by [Up]/[Down] buttons).

* If no password was ever registered the add-in will launch System manager instead and navigate you to the where you need to do user setup - please REMEMBER YOUR PASSWORD!

Code:

Add-in now also has functionality to:
* show your battery voltage (via [Up]/[Down] selection or [Menu] shortcut);
* reset the calculator (via [Up]/[Down] selection - useful for anyone who disabled the reset button at back of the calculator);
* setup auto power off for any amount of minutes interval between 1 and 120 minutes. ([Shift]then [Menu] to setup then [Up]/[Down] to increase/decrease)
* replace Conversion add-in - just rename this add-in to Conv.g3a and it will enable the same in RunMat (i.e. [Optn] then [F6] in RunMat will have Convert above [F1])
* other small improvements (Unadmissable characters filter, USB protection)


I was able to reduce the add-in file size by 52 bytes now with some improvements to the code so if someone wishes to suggest some extra functionality they would like to have in the above add-in please leave your ideas here. Please keep in mind the functionality exciting already in the other 2 add-ins by me G-CLOCK (digital watch and launcher) and G-PLUS (time display in status bar of almost all built in apps) and how those add-ins can launch this lock add-in (or any other add-in or app). Thanks for your feedback
The only functionality I could not fit in the size limit of the addin to be able to act as conversion addin before was customisable backlight timeout duration - but i do not consider it critical enough for now and it was involving pressing shift-menu twice for that setup - what are your opinions on perhaps addin ability to setup running of other addins or at least of my G-CLOCK watch or something else...
  
Register to Join the Conversation
Have your own thoughts to add to this or any other topic? Want to ask a question, offer a suggestion, share your own programs and projects, upload a file to the file archives, get help with calculator and computer programming, or simply chat with like-minded coders and tech and calculator enthusiasts via the site-wide AJAX SAX widget? Registration for a free Cemetech account only takes a minute.

» Go to Registration page
Page 1 of 1
» All times are GMT - 5 Hours
 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

 

Advertisement