//int MenuOption;
#include <pspdebug.h>
#include <pspctrl.h>
#include "xy.h"
#include "menu.h"
//#include "numbers.h"
#include <string.h>
int MenuOption;

int sa; int sb; int sc; int sd;

int xposition; 
int yposition;


            

void sn(const char *save, char *char_to_save) // Save number. Used for put a number on the fx buffer.
{
     printf("%s", save);
     strcpy(char_to_save, save);
}
void strcat_strings()
{
     strcpy(final_text, fa);
     strcat(final_text, fb);
     strcat(final_text, fc);
     strcat(final_text, fd);
     }
void Encrypt_Numbers(int max, int condition)
{
     int i = 0;
     while(i < max)
     {
             final_text[i] = final_text[i] + 20;
             i++;
             if(i == condition)
             continue;
             }
     //printf("%s |", final_text);
}
void Read_final_Password()
{
     SceCtrlData pad;
     sceCtrlReadBufferPositive(&pad, 1);
     
     if((strcmp(final_text, pinti) == 0) && (ReadFileReturn("password.txt") < 0))
     PintiAgree();
     
     if(pad.Buttons & PSP_CTRL_RTRIGGER)
     {
                    printf("\nLoading recovery !");
     if(ReadPassword("password.txt", final_text, 5) != -1)
     {
                                     sceKernelLoadExec(RecoveryRoot, NULL);
                                     
                                     }
                                     }
     
     
     
     if(ReadPassword("password.txt", final_text, 5) != -1)
     {
                                     printf("\nCorrect password!, going to XMB...");
                                     sceKernelDelayThread(500000);
                                     sceKernelExitGame();
                                     }
     
     
     else
     {
         //printf("\nFalse password!. Shutdown PSP manually please.");
         scePowerUnlock(0);
         scePowerRequestSuspend();
         scePowerLock(0);
         printf("\nPress O to return to main menu.");
         
         PassWord(1);
         }
         }
void SelectOption(int *MenuOption, int *sa, int *sb, int *sc, int *sd)
{
     yposition = y;
     
     //pspDebugScreenSetY(yposition);
     if(MenuOption == 1)
     {
                   xposition = ax; 
                   pspDebugScreenSetXY(xposition, yposition);
                   pspDebugScreenSetTextColor(0xFFFFF1);
                   if(sa == 0)
                   { sn("0", fa); }
                   if(sa == 1)
                  { sn("1", fa);} // sn...
                   if(sa == 2)
                  { sn("2", fa);}
                   if(sa == 3)
                  { sn("3", fa);}
                   if(sa == 4)
                  { sn("4", fa);}
                   if(sa == 5)
                  { sn("5", fa);}
                   if(sa == 6)
                  { sn("6", fa);}
                   if(sa == 7)
                  { sn("7", fa);}
                   if(sa == 8)
                  { sn("8", fa);}
                   if(sa == 9)
                  { sn("9", fa);}
                  pspDebugScreenSetTextColor(0x111FFF);
                 // printf("\n %s, ", fa);
                 // sap(bx, "0"); sap(cx, "0"); sap(dx, "0");
                   }
     if(MenuOption == 2)
     {
                   
                   xposition = bx; //yposition = y;
                   pspDebugScreenSetXY(xposition, yposition);
                   pspDebugScreenSetTextColor(0xFFFFF1);
                   if(sb == 0)
                  { sn("0", fb);}
                   if(sb == 1)
                  { sn("1", fb);}
                   if(sb == 2)
                  { sn("2", fb);}
                   if(sb == 3)
                  { sn("3", fb);}
                   if(sb == 4)
                  { sn("4", fb);}
                   if(sb == 5)
                  { sn("5", fb);}
                   if(sb == 6)
                 {  sn("6", fb);}
                   if(sb == 7)
                 {  sn("7", fb);}
                   if(sb == 8)
                  { sn("8", fb);}
                   if(sb == 9)
                  { sn("9", fb);}
                  pspDebugScreenSetTextColor(0x111FFF);
                 // printf("%s, ", fb);
                   }
     if(MenuOption == 3)
     {
                   xposition = cx; //yposition = y;
                   pspDebugScreenSetXY(xposition, yposition);
                   pspDebugScreenSetTextColor(0xFFFFF1);
                   if(sc == 0)
                  { sn("0", fc);}
                   if(sc == 1)
                   {sn("1", fc);}
                   if(sc == 2)
                  { sn("2", fc);}
                   if(sc == 3)
                  { sn("3", fc);}
                   if(sc == 4)
                  { sn("4", fc);}
                   if(sc == 5)
                  { sn("5", fc);}
                   if(sc == 6)
                  { sn("6", fc);}
                   if(sc == 7)
                  { sn("7", fc);}
                   if(sc == 8)
                  { sn("8", fc);}
                   if(sc == 9)
                  { sn("9", fc);}
                  pspDebugScreenSetTextColor(0x111FFF);
                 // printf("%s, ", fc);
                   }
     if(MenuOption == 4)
     {
                   xposition = dx; //yposition = y;
                   pspDebugScreenSetXY(xposition, yposition);
                   pspDebugScreenSetTextColor(0xFFFFF1);
                   if(sd == 0)
                   {sn("0", fd);}
                   if(sd == 1)
                  { sn("1", fd);}
                   if(sd == 2)
                  { sn("2", fd);}
                   if(sd == 3)
                  { sn("3", fd);}
                   if(sd == 4)
                   {sn("4", fd);}
                   if(sd == 5)
                  {sn("5", fd);}
                   if(sd == 6)
                   {sn("6", fd);}
                   if(sd == 7)
                  { sn("7", fd);}
                   if(sd == 8)
                  { sn("8", fd);}
                   if(sd == 9)
                  { sn("9", fd);}
                  pspDebugScreenSetTextColor(0x111FFF);
                  //printf("%s, ", fd);
                   }
                   
                   }
                   
