Advertisement
atm959

main.c(Tiny Chao Garden Save Fixer(NOT COMPLETE))

Jul 20th, 2018
340
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 2.34 KB | None | 0 0
  1. /*
  2.     Tiny Chao Garden Save Fixer
  3.     By atm959
  4. */
  5.  
  6. #include <nds.h>
  7. #include <stdio.h>
  8.  
  9. char fixedValue;    //The GBA header's fixed value is loaded to here
  10. char gameTitle[13]; //The GBA header's game title is loaded to here
  11. int pressed;        //The joypad state is loaded to here
  12. int i;              //Used for FOR loops
  13.  
  14. int main(void) {
  15.     defaultExceptionHandler(); //Setup the default exception handler
  16.    
  17.     consoleDemoInit(); //Init the text console
  18.  
  19.     //Name and instructions
  20.     iprintf("Tiny Chao Garden Save Fixer\nBy atm959\n\n");
  21.     iprintf("Insert Sonic Advance into Slot 2 and press A\n\n");
  22.    
  23.     //Wait for A button press
  24.     while(1) {
  25.         scanKeys();
  26.         pressed = keysDown();
  27.         if(pressed & KEY_A) break;
  28.         swiWaitForVBlank();
  29.     }
  30.  
  31.     fixedValue = *((u8 *)0x80000B2); //Load the fixed value
  32.  
  33.     //Load the title
  34.     for(i = 0; i < 12; i++){
  35.         gameTitle[i] = *((u8 *)0x80000A0 + i);
  36.     }
  37.     gameTitle[12] = '\0'; //Set the last character to the escape character
  38.  
  39.     iprintf("Game Title: %s\n\n", gameTitle); //Print the game title
  40.  
  41.     //Check if Sonic Advance is inserted
  42.     if((fixedValue != 0x96) || (strncmp(gameTitle, "SONICADVANCE", 12) != 0)){
  43.         consoleClear();
  44.         iprintf("Game Title: %s\n\n", gameTitle);
  45.         iprintf("Either a GBA game is not\n inserted, or the inserted GBA\n game is not Sonic Advance!\n\n");
  46.         iprintf("Insert Sonic Advance into Slot 2 and press A\n\n");
  47.  
  48.         //Loop until Sonic Advance is inserted
  49.         while((fixedValue != 0x96) || (strncmp(gameTitle, "SONICADVANCE", 12) != 0)){
  50.             scanKeys();
  51.             pressed = keysDown();
  52.  
  53.             if(pressed & KEY_A){
  54.                 fixedValue = *((u8 *)0x80000B2); //Load the fixed value
  55.  
  56.                 //Load the title
  57.                 for(i = 0; i < 12; i++){
  58.                     gameTitle[i] = *((u8 *)0x80000A0 + i);
  59.                 }
  60.                 gameTitle[12] = '\0'; //Set the last character to the escape character
  61.  
  62.                 //Check if Sonic Advance is inserted
  63.                 if((fixedValue != 0x96) || (strncmp(gameTitle, "SONICADVANCE", 12) != 0)){
  64.                     consoleClear();
  65.                     iprintf("Game Title: %s\n\n", gameTitle);
  66.                     iprintf("Either a GBA game is not\n inserted, or the inserted GBA\n game is not Sonic Advance!\n\n");
  67.                     iprintf("Insert Sonic Advance into Slot 2 and press A\n\n");
  68.                 }  
  69.             }
  70.  
  71.             swiWaitForVBlank();
  72.         }
  73.     }
  74.  
  75.     consoleClear();
  76.  
  77.     //Actual writes to the SRAM go here
  78.  
  79.     iprintf("Done!");
  80.  
  81.     //Loop until the DS is turned off
  82.     while(1){
  83.         swiWaitForVBlank();
  84.     }
  85.  
  86. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement