diff options
| author | John Wilbert M. Villamor <lameguy64@gmail.com> | 2020-09-19 20:43:05 +0800 |
|---|---|---|
| committer | John Wilbert M. Villamor <lameguy64@gmail.com> | 2020-09-19 20:43:05 +0800 |
| commit | 9f4891f95070c66ea9f1aba99d72724d4ab24e5a (patch) | |
| tree | 723e3ef2118a3d1a9e6dafa811ed1b8b1bc9196e /examples/system/childexec | |
| parent | 6762c39551ded059450d17d8bb0cb80642c8aaab (diff) | |
| download | psn00bsdk-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')
| -rw-r--r-- | examples/system/childexec/child.c | 8 | ||||
| -rw-r--r-- | examples/system/childexec/makefile | 8 | ||||
| -rw-r--r-- | examples/system/childexec/parent.c | 28 |
3 files changed, 32 insertions, 12 deletions
diff --git a/examples/system/childexec/child.c b/examples/system/childexec/child.c index fb38b63..2ed656b 100644 --- a/examples/system/childexec/child.c +++ b/examples/system/childexec/child.c @@ -102,7 +102,7 @@ void display(); /* Main function */ -int main() { +int main(int argc, const char *argv[]) { int i,p,xy_temp; @@ -113,6 +113,12 @@ int main() { POLY_F4 *pol4; /* Flat shaded quad primitive pointer */ + printf( "Arguments passed: %d\n", argc ); + for( i=0; i<argc; i++ ) + { + printf( "%s\n", argv[i] ); + } + /* Init graphics and GTE */ init(); diff --git a/examples/system/childexec/makefile b/examples/system/childexec/makefile index 79a27b6..4475832 100644 --- a/examples/system/childexec/makefile +++ b/examples/system/childexec/makefile @@ -1,9 +1,9 @@ -include ../../sdk-common.mk +include ../../examples-setup.mk INCLUDE += LIBDIRS += -LIBS = -lpsxetc -lpsxgpu -lpsxgte -lpsxspu -lc -lpsxapi +LIBS = -lpsxgpu -lpsxgte -lpsxspu -lpsxetc -lpsxapi -lc CFLAGS = -g -O2 -fno-builtin -fdata-sections -ffunction-sections CPPFLAGS = $(CFLAGS) -fno-exceptions @@ -20,11 +20,11 @@ all: child parent child: build/child.o $(LD) $(LDFLAGS_C) $(LIBDIRS) build/child.o $(LIBS) -o child.elf - elf2x child.elf + elf2x -q child.elf parent: build/parent.o build/child_exe.o $(LD) $(LDFLAGS_P) $(LIBDIRS) build/parent.o build/child_exe.o $(LIBS) -o parent.elf - elf2x parent.elf + elf2x -q parent.elf build/%.o: %.c @mkdir -p $(dir $@) 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); } |
