Skip to content

Instantly share code, notes, and snippets.

@dr-carlos

dr-carlos/main.c Secret

Last active October 5, 2021 09:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dr-carlos/12aeef1a47a4f5908d2983d356cd25b1 to your computer and use it in GitHub Desktop.
Save dr-carlos/12aeef1a47a4f5908d2983d356cd25b1 to your computer and use it in GitHub Desktop.
Casio fx-CG50 Lock Extension
#include <fxcg/keyboard.h>
#include <fxcg/system.h>
#include <fxcg/display.h>
#include <fxcg/app.h>
#include <string.h>
static void getString(int n, char *buffer, int x, int y) {
// Set first character to \0, also represented as "" (empty string)
buffer[0] = '\0';
int start = 0;
int cursor = 0;
int col = 0x04;
int row = 0x09;
unsigned short key;
while (1) {
// GetKey(&key);
Bdisp_PutDisp_DD();
GetKeyWait_OS(&col, &row, 0, 0, 1, &key);
if (key == KEY_CTRL_EXIT || key == KEY_CTRL_EXE) {
break;
}
if (key && key < 30000) {
cursor = EditMBStringChar((unsigned char*)buffer, n, cursor, key);
if (cursor == 1)
DisplayMBString((unsigned char*)"*", start, cursor, x, y);
else if (cursor == 2)
DisplayMBString((unsigned char*)"**", start, cursor, x, y);
else if (cursor == 3)
DisplayMBString((unsigned char*)"***", start, cursor, x, y);
else if (cursor == 4)
DisplayMBString((unsigned char*)"****", start, cursor, x, y);
else if (cursor == 5)
DisplayMBString((unsigned char*)"*****", start, cursor, x, y);
else
DisplayMBString((unsigned char*)"******", start, cursor, x, y);
} else {
int keycode = (int)key;
EditMBStringCtrl((unsigned char*)buffer, n, &start, &cursor, &keycode, x, y);
}
}
}
void timerHandler(void) {
Keyboard_PutKeycode(0x04, 0x09, 0);
}
void main(void) {
Bdisp_EnableColor(0);
Bkey_SetAllFlags(0x80);
char buf[1024];
while (1) {
// Clear screen
Bdisp_AllClr_VRAM();
// Disable menu return
SetGetkeyToMainFunctionReturnFlag(0);
// Turn off
PowerOff(1);
// When on, print "Enter password: "
PrintXY(1, 1, " Enter password:", 0, 0);
// Search through user info
char* flagpointer = (char*) 0x80BE0000;
int counter = 0;
while (*flagpointer == 0x0F) {
flagpointer = flagpointer + 0x40;
counter++;
}
// Set password from latest info
char* password;
if (!counter) {
continue;
} else {
flagpointer = flagpointer - 0x40;
if(*(flagpointer+0x2C) != '\0') {
password = (flagpointer+0x2C);
} else {
continue;
}
}
// Get password entered
getString(1024, buf, 1, 2);
// If correct password
// if (strcmp(buf, password) == 0) {
int key;
// Start timer to run MENU
Timer_Install(6, (void*)&timerHandler, 1);
Timer_Start(6);
// Run getkey
GetKey(&key);
// Stop timer
Timer_Deinstall(6);
// }
}
return;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment