Skip to content

Commit c5b1343

Browse files
bennyboybennyboy
bennyboy
authored and
bennyboy
committed
Fixed demo.script
Fixed ScriptChecker PC tool Moved helper function in ScriptEngine Added setting reset on boot with button combination on xpad (broke xpad in XBE version on 1.0 consoles)
1 parent 51cc4ce commit c5b1343

14 files changed

+598
-2866
lines changed

Makefile

+5-1
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,7 @@ OBJECTS-CROM += $(TOPDIR)/obj/crc32.o
199199
OBJECTS-CROM += $(TOPDIR)/obj/strtol.o
200200
OBJECTS-CROM += $(TOPDIR)/obj/cromSystem.o
201201
OBJECTS-CROM += $(TOPDIR)/obj/xblastScriptEngine.o
202+
OBJECTS-CROM += $(TOPDIR)/obj/functionsAccessor.o
202203
OBJECTS-CROM += $(TOPDIR)/obj/xblastSettings.o
203204
OBJECTS-CROM += $(TOPDIR)/obj/xblastSettingsChangeTracker.o
204205
OBJECTS-CROM += $(TOPDIR)/obj/xblastSettingsImportExport.o
@@ -341,7 +342,10 @@ crcbin:
341342
gcc -o bin/crcbin bin/crcbin.o bin/crc32.o
342343

343344
scriptchecker:
344-
gcc -g -o bin/scriptChecker pc_tools/scriptChecker/scriptChecker.c
345+
gcc -g -Iinclude -o pc_tools/scriptChecker/functionsAccessor.o -c pc_tools/scriptChecker/functionsAccessor.c
346+
gcc -g -o pc_tools/scriptChecker/scriptChecker.o -c pc_tools/scriptChecker/scriptChecker.c
347+
gcc -g -DSCRIPTCHECKER -Iinclude -Ipc_tools/scriptChecker -o pc_tools/scriptChecker/xblastScriptEngine.o -c xblast/scriptEngine/xblastScriptEngine.c
348+
gcc -g -o bin/scriptChecker pc_tools/scriptChecker/functionsAccessor.o pc_tools/scriptChecker/scriptChecker.o pc_tools/scriptChecker/xblastScriptEngine.o
345349

346350
imagecompress: obj/image-crom.bin bin/imagebld
347351
cp obj/image-crom.bin obj/c

bin/demo.script

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
VAR padButton = 0
22
VAR newFanSpeed = 20
33
VAR changeFanSpeed = 0
4-
VAR newLEDColor = 0
4+
VAR newLedColor = 0
55
VAR quit = 0
66

77
$buttonReleaseLoop

boot/BootResetAction.c

+80-61
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
#include "string.h"
3939
#include "xblast/HardwareIdentifier.h"
4040
#include "FlashDriver.h"
41+
#include "lib/time/timeManagement.h"
4142

4243
JPEG jpegBackdrop;
4344

@@ -249,6 +250,16 @@ extern void BootResetAction ( void )
249250
// Reset the AGP bus and start with good condition
250251
BootAGPBUSInitialization();
251252

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+
252263
debugSPIPrint("Read persistent OS settings from flash.\n");
253264
if(bootReadXBlastOSSettings() == false)
254265
{
@@ -257,22 +268,18 @@ extern void BootResetAction ( void )
257268
LEDFirstBoot(NULL);
258269
}
259270

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...*/
263273
if(EjectButtonPressed == 0 && LPCmodSettings.OSsettings.Quickboot)
264274
{
265275
if(isXBE() == false)
266276
{
267277
setLED("rrrr"); //Signal the user to press Eject button to avoid Quickboot.
268278
}
269279
}
280+
#endif
270281

271282

272-
//Let's set that up right here.
273-
settingsTrackerInit();
274-
setCFGFileTransferPtr(&LPCmodSettings, &settingsPtrStruct);
275-
276283
if(isXBE() && isXBlastOnLPC() == false) //If coming from XBE and no XBlast Mod is detected
277284
{
278285
tempFanSpeed = I2CGetFanSpeed();
@@ -312,6 +319,24 @@ extern void BootResetAction ( void )
312319
BootLCDInit(); //Basic init. Do it even if no LCD is connected on the system.
313320
debugSPIPrint("BootLCDInit done.\n");
314321

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+
}
315340

316341

317342
// We disable The CPU Cache
@@ -331,18 +356,9 @@ extern void BootResetAction ( void )
331356

332357
I2CTransmitWord(0x10, 0x1b04); // unknown
333358

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);
346362

347363
// Load and Init the Background image
348364
// clear the Video Ram
@@ -456,60 +472,63 @@ extern void BootResetAction ( void )
456472
if(tsaHarddiskInfo[0].m_fDriveExists && tsaHarddiskInfo[0].m_fAtapi == false)
457473
{
458474
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)
462476
{
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+
}
470488

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)
477490
{
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)
482495
{
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)
489500
{
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))
492503
{
493-
LPCmodSettings.OSsettings.runBankScript = 0;
504+
dcluster = FATXFindDir(partition, dcluster, "scripts");
494505
}
495-
res = FATXFindFile(partition, "boot.script", FATX_ROOT_FAT_CLUSTER, &fileinfo);
496-
if(res == 0 || fileinfo.fileSize == 0)
506+
if((dcluster != -1) && (dcluster != 1))
497507
{
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+
}
499518
}
519+
CloseFATXPartition(partition);
500520
}
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)
508523
{
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");
511531
}
512-
debugSPIPrint("Boot script execution done.\n");
513532
}
514533
}
515534
}

drivers/flash/FlashDriver.c

+13-18
Original file line numberDiff line numberDiff line change
@@ -497,34 +497,29 @@ bool bootReadXBlastOSSettings(void)
497497

498498
populateSettingsStructWithDefault(&LPCmodSettings);
499499

500-
if(risefall_xpad_BUTTON(TRIGGER_XPAD_TRIGGER_RIGHT) &&
501-
risefall_xpad_BUTTON(TRIGGER_XPAD_TRIGGER_LEFT) &&
502-
risefall_xpad_STATE(XPAD_STATE_START)
503-
&& XPAD_current[0].keys[5]) //white button
500+
if(returnValue)
504501
{
505-
return returnValue;
506-
}
502+
FlashProgress progress = Flash_ReadXBlastOSSettingsRequest();
507503

508-
FlashProgress progress = Flash_ReadXBlastOSSettingsRequest();
504+
while(cromwellLoop())
505+
{
506+
progress = Flash_getProgress();
509507

510-
while(cromwellLoop())
511-
{
512-
progress = Flash_getProgress();
508+
if(progress.currentFlashOp == FlashOp_Completed || progress.currentFlashOp == FlashOp_Error)
509+
{
510+
debugSPIPrint("Read Settings from flash completed.\n");
511+
returnValue = Flash_LoadXBlastOSSettings(&LPCmodSettings);
513512

514-
if(progress.currentFlashOp == FlashOp_Completed || progress.currentFlashOp == FlashOp_Error)
515-
{
516-
debugSPIPrint("Read Settings from flash completed.\n");
517-
returnValue = Flash_LoadXBlastOSSettings(&LPCmodSettings);
518513

519514

515+
break;
516+
}
520517

521-
break;
518+
Flash_executeFlashFSM();
522519
}
523-
524-
Flash_executeFlashFSM();
520+
memcpy(&LPCmodSettingsOrigFromFlash, &LPCmodSettings, sizeof(_LPCmodSettings));
525521
}
526522

527-
memcpy(&LPCmodSettingsOrigFromFlash, &LPCmodSettings, sizeof(_LPCmodSettings));
528523
Flash_freeFlashFSM();
529524

530525
return returnValue;
+88
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
/*
2+
* functionsAccessor.c
3+
*
4+
* Created on: May 6, 2017
5+
* Author: bennyboy
6+
*/
7+
8+
#include "../../xblast/scriptEngine/functionsAccessor.h"
9+
#include <string.h>
10+
#include <stdio.h>
11+
12+
bool gpiFunction(unsigned char port)
13+
{
14+
return true;
15+
}
16+
17+
bool gpoFunction(unsigned char port, unsigned char value)
18+
{
19+
return true;
20+
}
21+
22+
bool waitFunction(int ms)
23+
{
24+
return true;
25+
}
26+
27+
bool bootFunction(FlashBank bank)
28+
{
29+
return true;
30+
}
31+
32+
bool fanFunction(unsigned char value)
33+
{
34+
return true;
35+
}
36+
37+
bool ledFunction(char * value)
38+
{
39+
printf("LED %s\n", value);
40+
return true;
41+
}
42+
43+
bool lcdPrintFunction(unsigned char line, char * text, unsigned char stringLength)
44+
{
45+
return true;
46+
}
47+
48+
bool lcdClearLineFunction(unsigned char line)
49+
{
50+
return true;
51+
}
52+
bool lcdResetFunction(void)
53+
{
54+
return true;
55+
}
56+
57+
bool lcdBacklightFunction(unsigned char value)
58+
{
59+
return true;
60+
}
61+
62+
bool lcdPowerFunction(unsigned char value)
63+
{
64+
return true;
65+
}
66+
67+
unsigned char SPIRead(void)
68+
{
69+
unsigned char i, result = 0;
70+
71+
return result;
72+
}
73+
74+
bool SPIWrite(unsigned char data)
75+
{
76+
return true;
77+
}
78+
79+
unsigned char XPADRead(int xpadVariable)
80+
{
81+
unsigned char pad = 1;
82+
return pad;
83+
}
84+
85+
bool emergencyEscape()
86+
{
87+
return false;
88+
}

0 commit comments

Comments
 (0)