38
38
#include "string.h"
39
39
#include "xblast/HardwareIdentifier.h"
40
40
#include "FlashDriver.h"
41
+ #include "lib/time/timeManagement.h"
41
42
42
43
JPEG jpegBackdrop ;
43
44
@@ -249,6 +250,16 @@ extern void BootResetAction ( void )
249
250
// Reset the AGP bus and start with good condition
250
251
BootAGPBUSInitialization ();
251
252
253
+ I2CTransmitByteGetReturn (0x10 , 0x11 ); // dummy Query IRQ
254
+ I2CTransmitWord (0x10 , 0x1a01 ); // Enable PIC interrupts. Cannot be deactivated once set.
255
+
256
+ unsigned char readUSB = 0 ;
257
+ if (EjectButtonPressed == 0 && isXBE () == false)
258
+ {
259
+ setLED ("rrrr" ); //Signal the user to press Eject button to avoid Quickboot.
260
+ }
261
+ wait_us_blocking (760000 );
262
+
252
263
debugSPIPrint ("Read persistent OS settings from flash.\n" );
253
264
if (bootReadXBlastOSSettings () == false)
254
265
{
@@ -257,22 +268,18 @@ extern void BootResetAction ( void )
257
268
LEDFirstBoot (NULL );
258
269
}
259
270
260
-
261
- I2CTransmitByteGetReturn (0x10 , 0x11 ); // dummy Query IRQ
262
- I2CTransmitWord (0x10 , 0x1a01 ); // Enable PIC interrupts. Cannot be deactivated once set.
271
+ #if 0
272
+ /* We'll be doing it invariably berfore the 750ms delay instead...*/
263
273
if (EjectButtonPressed == 0 && LPCmodSettings .OSsettings .Quickboot )
264
274
{
265
275
if (isXBE () == false)
266
276
{
267
277
setLED ("rrrr" ); //Signal the user to press Eject button to avoid Quickboot.
268
278
}
269
279
}
280
+ #endif
270
281
271
282
272
- //Let's set that up right here.
273
- settingsTrackerInit ();
274
- setCFGFileTransferPtr (& LPCmodSettings , & settingsPtrStruct );
275
-
276
283
if (isXBE () && isXBlastOnLPC () == false) //If coming from XBE and no XBlast Mod is detected
277
284
{
278
285
tempFanSpeed = I2CGetFanSpeed ();
@@ -312,6 +319,24 @@ extern void BootResetAction ( void )
312
319
BootLCDInit (); //Basic init. Do it even if no LCD is connected on the system.
313
320
debugSPIPrint ("BootLCDInit done.\n" );
314
321
322
+ //Stuff to do right after loading persistent settings from flash.
323
+ if (fFirstBoot == false)
324
+ {
325
+ if (emergencyRecoverSettings ())
326
+ {
327
+ debugSPIPrint ("Emergency recover triggered. Resetting settings.\n" );
328
+ fFirstBoot = true;
329
+ LEDFirstBoot (NULL );
330
+ }
331
+
332
+ if (isLCDSupported ())
333
+ {
334
+ debugSPIPrint ("Check if we need to drive the LCD.\n" );
335
+ assertInitLCD (); //Function in charge of checking if a init of LCD is needed.
336
+ debugSPIPrint ("assertInitLCD done.\n" );
337
+ }
338
+ //further init here.
339
+ }
315
340
316
341
317
342
// We disable The CPU Cache
@@ -331,18 +356,9 @@ extern void BootResetAction ( void )
331
356
332
357
I2CTransmitWord (0x10 , 0x1b04 ); // unknown
333
358
334
-
335
- //Stuff to do right after loading persistent settings from flash.
336
- if (fFirstBoot == false)
337
- {
338
- if (isLCDSupported ())
339
- {
340
- debugSPIPrint ("Check if we need to drive the LCD.\n" );
341
- assertInitLCD (); //Function in charge of checking if a init of LCD is needed.
342
- debugSPIPrint ("assertInitLCD done.\n" );
343
- }
344
- //further init here.
345
- }
359
+ //Let's set that up right here.
360
+ settingsTrackerInit ();
361
+ setCFGFileTransferPtr (& LPCmodSettings , & settingsPtrStruct );
346
362
347
363
// Load and Init the Background image
348
364
// clear the Video Ram
@@ -456,60 +472,63 @@ extern void BootResetAction ( void )
456
472
if (tsaHarddiskInfo [0 ].m_fDriveExists && tsaHarddiskInfo [0 ].m_fAtapi == false)
457
473
{
458
474
debugSPIPrint ("Master HDD exist.\n" );
459
- //TODO: Load optional JPEG backdrop from HDD here. Maybe fetch skin name from cfg file?
460
- debugSPIPrint ("Trying to load new JPEG from HDD.\n" );
461
- if (LPCMod_ReadJPGFromHDD ("\\XBlast\\icons.jpg" ) == false)
475
+ if (fFirstBoot == false)
462
476
{
463
- debugSPIPrint ("\"ìcons.jpg\" loaded. Moving on to \"backdrop.jpg\".\n" );
464
- }
465
- if (LPCMod_ReadJPGFromHDD ("\\XBlast\\backdrop.jpg" ) == false)
466
- {
467
- debugSPIPrint ("\"backdrop.jpg\" loaded. Repainting.\n" );
468
- printMainMenuHeader ();
469
- }
477
+ //TODO: Load optional JPEG backdrop from HDD here. Maybe fetch skin name from cfg file?
478
+ debugSPIPrint ("Trying to load new JPEG from HDD.\n" );
479
+ if (LPCMod_ReadJPGFromHDD ("\\XBlast\\icons.jpg" ) == false)
480
+ {
481
+ debugSPIPrint ("\"ìcons.jpg\" loaded. Moving on to \"backdrop.jpg\".\n" );
482
+ }
483
+ if (LPCMod_ReadJPGFromHDD ("\\XBlast\\backdrop.jpg" ) == false)
484
+ {
485
+ debugSPIPrint ("\"backdrop.jpg\" loaded. Repainting.\n" );
486
+ printMainMenuHeader ();
487
+ }
470
488
471
- if (isXBE () && isXBlastOnLPC () == false)
472
- {
473
- debugSPIPrint ("Trying to load settings from cfg file on HDD.\n" );
474
- _LPCmodSettings tempLPCmodSettings ;
475
- returnValue = LPCMod_ReadCFGFromHDD (& tempLPCmodSettings , & settingsPtrStruct );
476
- if (returnValue == 0 )
489
+ if (isXBE () && isXBlastOnLPC () == false)
477
490
{
478
- importNewSettingsFromCFGLoad ( & tempLPCmodSettings );
479
-
480
- partition = OpenFATXPartition ( 0 , SECTOR_SYSTEM , SYSTEM_SIZE );
481
- if (partition != NULL )
491
+ debugSPIPrint ( "Trying to load settings from cfg file on HDD.\n" );
492
+ _LPCmodSettings tempLPCmodSettings ;
493
+ returnValue = LPCMod_ReadCFGFromHDD ( & tempLPCmodSettings , & settingsPtrStruct );
494
+ if (returnValue == 0 )
482
495
{
483
- dcluster = FATXFindDir (partition , FATX_ROOT_FAT_CLUSTER , "XBlast" );
484
- if ((dcluster != -1 ) && (dcluster != 1 ))
485
- {
486
- dcluster = FATXFindDir (partition , dcluster , "scripts" );
487
- }
488
- if ((dcluster != -1 ) && (dcluster != 1 ))
496
+ importNewSettingsFromCFGLoad (& tempLPCmodSettings );
497
+
498
+ partition = OpenFATXPartition (0 , SECTOR_SYSTEM , SYSTEM_SIZE );
499
+ if (partition != NULL )
489
500
{
490
- res = FATXFindFile (partition , "bank.script" , FATX_ROOT_FAT_CLUSTER , & fileinfo );
491
- if (res == 0 || fileinfo . fileSize == 0 )
501
+ dcluster = FATXFindDir (partition , FATX_ROOT_FAT_CLUSTER , "XBlast" );
502
+ if (( dcluster != -1 ) && ( dcluster != 1 ) )
492
503
{
493
- LPCmodSettings . OSsettings . runBankScript = 0 ;
504
+ dcluster = FATXFindDir ( partition , dcluster , "scripts" ) ;
494
505
}
495
- res = FATXFindFile (partition , "boot.script" , FATX_ROOT_FAT_CLUSTER , & fileinfo );
496
- if (res == 0 || fileinfo .fileSize == 0 )
506
+ if ((dcluster != -1 ) && (dcluster != 1 ))
497
507
{
498
- LPCmodSettings .OSsettings .runBootScript = 0 ;
508
+ res = FATXFindFile (partition , "bank.script" , FATX_ROOT_FAT_CLUSTER , & fileinfo );
509
+ if (res == 0 || fileinfo .fileSize == 0 )
510
+ {
511
+ LPCmodSettings .OSsettings .runBankScript = 0 ;
512
+ }
513
+ res = FATXFindFile (partition , "boot.script" , FATX_ROOT_FAT_CLUSTER , & fileinfo );
514
+ if (res == 0 || fileinfo .fileSize == 0 )
515
+ {
516
+ LPCmodSettings .OSsettings .runBootScript = 0 ;
517
+ }
499
518
}
519
+ CloseFATXPartition (partition );
500
520
}
501
- CloseFATXPartition (partition );
502
- }
503
- //bootScriptSize should not have changed if we're here.
504
- if (LPCmodSettings .OSsettings .runBootScript && LPCmodSettings .flashScript .scriptSize == 0 )
505
- {
506
- debugSPIPrint ("Running boot script.\n" );
507
- if (loadScriptFromHDD ("\\XBlast\\scripts\\boot.script" , & fileinfo ))
521
+ //bootScriptSize should not have changed if we're here.
522
+ if (LPCmodSettings .OSsettings .runBootScript && LPCmodSettings .flashScript .scriptSize == 0 )
508
523
{
509
- i = BNKOS ;
510
- runScript (fileinfo .buffer , fileinfo .fileSize , 1 , & i );
524
+ debugSPIPrint ("Running boot script.\n" );
525
+ if (loadScriptFromHDD ("\\XBlast\\scripts\\boot.script" , & fileinfo ))
526
+ {
527
+ i = BNKOS ;
528
+ runScript (fileinfo .buffer , fileinfo .fileSize , 1 , & i );
529
+ }
530
+ debugSPIPrint ("Boot script execution done.\n" );
511
531
}
512
- debugSPIPrint ("Boot script execution done.\n" );
513
532
}
514
533
}
515
534
}
0 commit comments