aboutsummaryrefslogtreecommitdiff
path: root/examples/system/childexec/parent.c
diff options
context:
space:
mode:
authorJohn Wilbert M. Villamor <lameguy64@gmail.com>2020-09-19 20:43:05 +0800
committerJohn Wilbert M. Villamor <lameguy64@gmail.com>2020-09-19 20:43:05 +0800
commit9f4891f95070c66ea9f1aba99d72724d4ab24e5a (patch)
tree723e3ef2118a3d1a9e6dafa811ed1b8b1bc9196e /examples/system/childexec/parent.c
parent6762c39551ded059450d17d8bb0cb80642c8aaab (diff)
downloadpsn00bsdk-9f4891f95070c66ea9f1aba99d72724d4ab24e5a.tar.gz
Revised makefiles, added strtok(), command line arguments, SetHeapSize(), moved ISR and callback system to psxetc, moved debug font to psxgpu, fixed CD-ROM library crashing on PSIO, fixed interrupt callback setup to fix crashing on ResetGraph()
Diffstat (limited to 'examples/system/childexec/parent.c')
-rw-r--r--examples/system/childexec/parent.c28
1 files changed, 21 insertions, 7 deletions
diff --git a/examples/system/childexec/parent.c b/examples/system/childexec/parent.c
index 7f577e4..ed5710a 100644
--- a/examples/system/childexec/parent.c
+++ b/examples/system/childexec/parent.c
@@ -2,9 +2,14 @@
* LibPSn00b Example Programs
*
* Child Program Execution Example
- * 2019 Meido-Tek Productions / PSn00bSDK Project
+ * 2020 Meido-Tek Productions / PSn00bSDK Project
*
- * This is a modification of the balls example, modified to execute
+ * This example demonstrates how to execute a child PS-EXE from a parent
+ * PS-EXE using the Exec() function, and transferring execution back from
+ * the child PS-EXE to the parent PS-EXE. Passing arguments to the child
+ * PS-EXE is also demonstrated here.
+ *
+ * This is actually a modification of the balls example, modified to execute
* a child program for this example.
*
* Example by Lameguy64
@@ -88,9 +93,6 @@ void init() {
PutDispEnv( &disp );
PutDrawEnv( &draw );
- /* Enable video output */
- SetDispMask( 1 );
-
printf("Done.\n");
@@ -232,6 +234,9 @@ int main(int argc, const char* argv[]) {
DrawSync( 0 );
VSync( 0 );
+ /* Enable video output */
+ SetDispMask( 1 );
+
/* Since draw.isbg is non-zero this clears the screen */
PutDrawEnv( &draw );
@@ -265,6 +270,14 @@ void SetDefaultExitFromException();
void run_child() {
+ // Arguments for the child program
+ char *args[] =
+ {
+ "SAMPLE=0",
+ "SESSION=1",
+ "ARGH!"
+ };
+
// So child header is readable
EXE_HEAD *exe = (EXE_HEAD*)child_exe;
@@ -287,9 +300,9 @@ void run_child() {
// Execute child
printf("Child exec!\n");
- Exec(&exe->param, 0, 0);
+ Exec(&exe->param, 3, args);
- // Reset previous handler
+ // Restore interrupts for this PS-EXE
EnterCriticalSection();
RestartCallback();
ExitCriticalSection();
@@ -300,6 +313,7 @@ void run_child() {
ChangeClearPAD(0);
// Set this program's display mode
+ SetDispMask(0);
PutDispEnv(&disp);
}