aboutsummaryrefslogtreecommitdiff
path: root/examples/system
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
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')
-rw-r--r--examples/system/childexec/child.c8
-rw-r--r--examples/system/childexec/makefile8
-rw-r--r--examples/system/childexec/parent.c28
-rw-r--r--examples/system/console/main.c2
-rw-r--r--examples/system/console/makefile4
-rw-r--r--examples/system/timer/makefile4
-rw-r--r--examples/system/tty/makefile4
7 files changed, 39 insertions, 19 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);
}
diff --git a/examples/system/console/main.c b/examples/system/console/main.c
index 988b428..405f0d6 100644
--- a/examples/system/console/main.c
+++ b/examples/system/console/main.c
@@ -172,7 +172,7 @@ int main(int argc, const char* argv[]) {
/* Uncomment this line if you don't have tty interfaces
* provided by n00brom or similar development environments with tty */
- AddSIO(115200);
+ //AddSIO(115200);
/* Main loop */
diff --git a/examples/system/console/makefile b/examples/system/console/makefile
index 0c27b55..d7e9374 100644
--- a/examples/system/console/makefile
+++ b/examples/system/console/makefile
@@ -1,4 +1,4 @@
-include ../../sdk-common.mk
+include ../../examples-setup.mk
# Project target name
TARGET = console.elf
@@ -19,7 +19,7 @@ INCLUDE +=
LIBDIRS +=
# Libraries to link
-LIBS = -lpsxsio -lpsxetc -lpsxgpu -lpsxgte -lpsxspu -lpsxapi -lc
+LIBS = -lpsxsio -lpsxgpu -lpsxgte -lpsxspu -lpsxetc -lpsxapi -lc
# C compiler flags
CFLAGS = -g -O2 -fno-builtin -fdata-sections -ffunction-sections
diff --git a/examples/system/timer/makefile b/examples/system/timer/makefile
index c35c445..3fe1562 100644
--- a/examples/system/timer/makefile
+++ b/examples/system/timer/makefile
@@ -1,4 +1,4 @@
-include ../../sdk-common.mk
+include ../../examples-setup.mk
TARGET = timer.elf
@@ -11,7 +11,7 @@ OFILES = $(addprefix build/,$(CFILES:.c=.o) $(CPPFILES:.cpp=.o) $(AFILES:.s=.o)
INCLUDE +=
LIBDIRS +=
-LIBS = -lpsxetc -lpsxgpu -lpsxgte -lpsxspu -lpsxapi -lc
+LIBS = -lpsxgpu -lpsxgte -lpsxspu -lpsxetc -lpsxapi -lc
CFLAGS = -g -O2 -fno-builtin -fdata-sections -ffunction-sections
CPPFLAGS = $(CFLAGS) -fno-exceptions
diff --git a/examples/system/tty/makefile b/examples/system/tty/makefile
index a3884ad..d0a8caa 100644
--- a/examples/system/tty/makefile
+++ b/examples/system/tty/makefile
@@ -1,4 +1,4 @@
-include ../../sdk-common.mk
+include ../../examples-setup.mk
# Project target name
TARGET = tty.elf
@@ -19,7 +19,7 @@ INCLUDE +=
LIBDIRS +=
# Libraries to link
-LIBS = -lpsxetc -lpsxgpu -lpsxgte -lpsxspu -lpsxapi -lc
+LIBS = -lpsxgpu -lpsxgte -lpsxspu -lpsxetc -lpsxapi -lc
# C compiler flags
CFLAGS = -g -O2 -fno-builtin -fdata-sections -ffunction-sections