Guest User

Untitled

a guest
Jun 27th, 2014
512
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 3.30 KB | None | 0 0
  1. if( ((*(vu32*)0xCC003000)>>16) == 1 && CheckMagicWords() == 0) //if( ((*(vu32*)0xCC003000)>>16)&1 && !CheckMagicWords())
  2.     {
  3.         //Check autoboot settings
  4.         switch( Bootstate )
  5.         {
  6.             case TYPE_UNKNOWN: //255 or -1, only seen when shutting down from MIOS or booting dol from HBC. it is actually an invalid value
  7.                 temp = GetStateFlags();
  8.                 gprintf("Bootstate %u detected. DiscState %u ,ReturnTo %u & Flags %u\n",temp.type,temp.discstate,temp.returnto,temp.flags);
  9.                 if( temp.flags == 130 ) //&& temp.discstate != 2)
  10.                 {
  11.                     //if the flag is 130, its probably shutdown from mios. in that case system menu
  12.                     //will handle it perfectly (and i quote from SM's OSreport : "Shutdown system from GC!")
  13.                     //it seems to reboot into bootstate 5. but its safer to let SM handle it
  14.                     gprintf("255:System Menu\n");
  15.                     BootMainSysMenu(0);
  16.                 }
  17.                 else
  18.                 {
  19.                     Autoboot_System();
  20.                 }
  21.                 break;
  22.             case TYPE_SHUTDOWNSYSTEM: // 5 - shutdown
  23.                 ClearState();
  24.                 //check for valid nandboot shitzle. if its found we need to change bootstate to 4.
  25.                 //yellow8 claims system menu reset everything then, but it didn't on my wii (joy). this is why its not activated code.
  26.                 //its not fully confirmed system menu does it(or ios while being standby) and if system menu does indeed clear it.
  27.                 /*if(VerifyNandBootInfo())
  28.                 {
  29.                     gprintf("Verifty of NandBootInfo : 1\nbootstate changed to %d\n",CheckBootState());
  30.                 }
  31.                 else
  32.                 {
  33.                     gprintf("Verifty of NandBootInfo : 0\n");
  34.                 }*//*
  35.                 if(!SGetSetting(SETTING_SHUTDOWNTOPRELOADER))
  36.                 {
  37.                     gprintf("Shutting down...\n");
  38.                     DVDStopDisc(true);
  39.                     ShutdownDevices();
  40.                     USB_Deinitialize();
  41.                     *(vu32*)0xCD8000C0 &= ~0x20;
  42.                     Control_VI_Regs(0);
  43.                     while(DvdKilled() < 1);
  44.                     if( SGetSetting(SETTING_IGNORESHUTDOWNMODE) )
  45.                     {
  46.                         STM_ShutdownToStandby();
  47.  
  48.                     } else {
  49.                         if( CONF_GetShutdownMode() == CONF_SHUTDOWN_STANDBY )
  50.                         {
  51.                             //standby = red = off
  52.                             STM_ShutdownToStandby();
  53.                         }
  54.                         else
  55.                         {
  56.                             //idle = orange = standby
  57.                             s32 ret;
  58.                             ret = CONF_GetIdleLedMode();
  59.                             if (ret >= 0 && ret <= 2)
  60.                                 STM_SetLedMode(ret);
  61.                             STM_ShutdownToIdle();
  62.                         }
  63.                     }
  64.                 }
  65.                 break;
  66.             case RETURN_TO_ARGS: //2 - normal reboot which funny enough doesn't happen very often
  67.             case TYPE_RETURN: //3 - return to system menu
  68.                 switch( SGetSetting(SETTING_RETURNTO) )
  69.                 {
  70.                     case RETURNTO_SYSMENU:
  71.                         gprintf("ReturnTo:System Menu\n");
  72.                         BootMainSysMenu(0);
  73.                     break;
  74.  
  75.                     case RETURNTO_AUTOBOOT:
  76.                         Autoboot_System();
  77.                     break;
  78.  
  79.                     default:
  80.                     break;
  81.                 }
  82.                 break;
  83.             case TYPE_NANDBOOT: // 4 - nandboot
  84.                 //apparently a boot state in which the system menu auto boots a title. read more : http://wiibrew.org/wiki/WiiConnect24#WC24_title_booting
  85.                 //as it hardly happens i guess nothing bad can happen if we ignore it and just do autoboot instead :)
  86.             case RETURN_TO_SETTINGS: // 1 - Boot when fully shutdown & wiiconnect24 is off. why its called RETURN_TO_SETTINGS i have no clue...
  87.             case RETURN_TO_MENU: // 0 - boot when wiiconnect24 is on
  88.                 Autoboot_System();
  89.                 break;
  90.             default :
  91.                 if( ClearState() < 0 )
  92.                 {
  93.                     error = ERROR_STATE_CLEAR;
  94.                     gprintf("ClearState failure\n");
  95.                 }
  96.                 break;
  97.  
  98.         }
  99. }
Advertisement
Add Comment
Please, Sign In to add comment