aboutsummaryrefslogtreecommitdiff
path: root/examples
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
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')
-rw-r--r--examples/beginner/hello/makefile4
-rw-r--r--examples/cdrom/cdbrowse/main.c44
-rw-r--r--examples/cdrom/cdbrowse/makefile4
-rw-r--r--examples/cdrom/cdxa/main.c7
-rw-r--r--examples/cdrom/cdxa/makefile4
-rw-r--r--examples/demos/n00bdemo/makefile4
-rw-r--r--examples/examples-setup.mk63
-rw-r--r--examples/graphics/balls/makefile4
-rw-r--r--examples/graphics/billboard/makefile4
-rw-r--r--examples/graphics/fpscam/makefile4
-rw-r--r--examples/graphics/gte/makefile4
-rw-r--r--examples/graphics/render2tex/makefile4
-rw-r--r--examples/graphics/rgb24/makefile4
-rw-r--r--examples/sdk-common.mk34
-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
21 files changed, 151 insertions, 95 deletions
diff --git a/examples/beginner/hello/makefile b/examples/beginner/hello/makefile
index 1893a48..27ca670 100644
--- a/examples/beginner/hello/makefile
+++ b/examples/beginner/hello/makefile
@@ -1,4 +1,4 @@
-include ../../sdk-common.mk
+include ../../examples-setup.mk
# Project target name
TARGET = hello.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
diff --git a/examples/cdrom/cdbrowse/main.c b/examples/cdrom/cdbrowse/main.c
index 65475ad..772ddc1 100644
--- a/examples/cdrom/cdbrowse/main.c
+++ b/examples/cdrom/cdbrowse/main.c
@@ -39,7 +39,7 @@
*
* Up/Down - Move selection cursor.
* Cross - Enter directory.
- * Circle - Go back to root directory.
+ * Circle - Go back to parent directory.
*
*
* Example by Lameguy64
@@ -48,6 +48,8 @@
* Changelog:
*
* February 25, 2020: Initial version.
+ *
+ * July 12, 2020: Updated CD-ROM directory query logic on disc change slightly.
*/
#include <stdio.h>
@@ -70,7 +72,6 @@
#define OT_LEN 8 /* Ordering table length */
-
/* Screen coordinates */
#define SCREEN_XRES 320
#define SCREEN_YRES 240
@@ -146,6 +147,9 @@ void init()
{
int i;
+ /* Uncomment to send tty messages to SIO */
+ //AddSIO( 115200 );
+
/* Reset GPU (also installs event handler for VSync) */
printf("Init GPU... ");
ResetGraph( 0 );
@@ -158,7 +162,7 @@ void init()
/* Initialize SPU and CD-ROM */
printf("Initializing CD-ROM... ");
- SpuInit();
+ //SpuInit();
CdInit();
printf("Done.\n");
@@ -218,10 +222,14 @@ void init()
/* Initialize pad */
+ EnterCriticalSection();
+
InitPAD(padbuff[0], 34, padbuff[1], 34);
StartPAD();
ChangeClearPAD(0);
+ ExitCriticalSection();
+
}
@@ -258,6 +266,10 @@ int main(int argc, const char* argv[])
disc_present = false;
update_listing = true;
+ printf( "Calling CdStatus()...\n" );
+ CdStatus();
+ printf( "Call done.\n" );
+
while(1) {
/* Set flag if disc has been removed */
@@ -383,23 +395,19 @@ int main(int argc, const char* argv[])
/* Updates directory listing */
if( update_listing )
{
- if ( (CdStatus()&0x12) == 0x2 )
+ /* Reset path and update label if new disc inserted */
+ if( !disc_present )
{
-
- /* Reset path and update label if new disc inserted */
- if( !disc_present )
- {
- strcpy( path, "\\" );
- CdGetVolumeLabel(disc_label);
- disc_present = true;
- }
-
- /* Query directory */
- files_found = query_dir( path, files, 40 );
- sel_channel = 0;
- list_scroll = 0;
-
+ strcpy( path, "\\" );
+ CdGetVolumeLabel(disc_label);
+ disc_present = true;
}
+
+ /* Query directory */
+ files_found = query_dir( path, files, 40 );
+ sel_channel = 0;
+ list_scroll = 0;
+
update_listing = false;
}
diff --git a/examples/cdrom/cdbrowse/makefile b/examples/cdrom/cdbrowse/makefile
index f5ee962..adbc9cb 100644
--- a/examples/cdrom/cdbrowse/makefile
+++ b/examples/cdrom/cdbrowse/makefile
@@ -1,4 +1,4 @@
-include ../../sdk-common.mk
+include ../../examples-setup.mk
TARGET = cdbrowse.elf
@@ -10,7 +10,7 @@ OFILES = $(addprefix build/,$(CFILES:.c=.o) $(CPPFILES:.cpp=.o) $(AFILES:.s=.o)
PREFIX = mipsel-unknown-elf-
-LIBS = -lpsxcd -lpsxetc -lpsxgpu -lpsxgte -lpsxspu -lpsxsio -lpsxapi -lc
+LIBS = -lpsxcd -lpsxgpu -lpsxgte -lpsxspu -lpsxsio -lpsxetc -lpsxapi -lc
CFLAGS = -g -O2 -fno-builtin -fdata-sections -ffunction-sections
CPPFLAGS = $(CFLAGS) \
diff --git a/examples/cdrom/cdxa/main.c b/examples/cdrom/cdxa/main.c
index 55cb508..0112437 100644
--- a/examples/cdrom/cdxa/main.c
+++ b/examples/cdrom/cdxa/main.c
@@ -235,14 +235,13 @@ void init()
{
int i;
+ /* Uncomment to direct tty messages to serial */
+ //AddSIO(115200);
+
/* Reset GPU (also installs event handler for VSync) */
printf("Init GPU... ");
ResetGraph( 0 );
printf("Done.\n");
-
-
- /* Uncomment to direct tty messages to serial */
- AddSIO(115200);
/* Initialize SPU and CD-ROM */
diff --git a/examples/cdrom/cdxa/makefile b/examples/cdrom/cdxa/makefile
index 8858979..3e46301 100644
--- a/examples/cdrom/cdxa/makefile
+++ b/examples/cdrom/cdxa/makefile
@@ -1,4 +1,4 @@
-include ../../sdk-common.mk
+include ../../examples-setup.mk
TARGET = cdxa.elf
@@ -10,7 +10,7 @@ OFILES = $(addprefix build/,$(CFILES:.c=.o) $(CPPFILES:.cpp=.o) $(AFILES:.s=.o)
PREFIX = mipsel-unknown-elf-
-LIBS = -lpsxcd -lpsxetc -lpsxgpu -lpsxgte -lpsxspu -lpsxsio -lpsxapi -lc
+LIBS = -lpsxcd -lpsxgpu -lpsxgte -lpsxspu -lpsxsio -lpsxetc -lpsxapi -lc
CFLAGS = -g -O2 -fno-builtin -fdata-sections -ffunction-sections
CPPFLAGS = $(CFLAGS) \
diff --git a/examples/demos/n00bdemo/makefile b/examples/demos/n00bdemo/makefile
index 63dc345..f90fb11 100644
--- a/examples/demos/n00bdemo/makefile
+++ b/examples/demos/n00bdemo/makefile
@@ -1,4 +1,4 @@
-include ../../sdk-common.mk
+include ../../examples-setup.mk
TARGET = demo.elf
@@ -9,7 +9,7 @@ OFILES = $(addprefix build/,$(CFILES:.c=.o) $(AFILES:.s=.o))
INCLUDE += -I../../../libpsn00b/lzp
-LIBS = -llzp -lc -lpsxetc -lpsxgpu -lpsxgte -lpsxspu -lpsxapi -lc
+LIBS = -llzp -lpsxgpu -lpsxgte -lpsxspu -lpsxetc -lpsxapi -lc
CFLAGS = -g -O2 -fno-builtin -fdata-sections -ffunction-sections
CPPFLAGS = $(CFLAGS) -fno-exceptions
diff --git a/examples/examples-setup.mk b/examples/examples-setup.mk
new file mode 100644
index 0000000..a5cfc20
--- /dev/null
+++ b/examples/examples-setup.mk
@@ -0,0 +1,63 @@
+# PSn00bSDK examples setup file
+# Part of the PSn00bSDK Project
+# 2019 - 2020 Lameguy64 / Meido-Tek Productions
+#
+# This is only for the PSn00bSDK example programs, not recommended
+# for use with user projects
+
+PREFIX = mipsel-unknown-elf-
+
+ifndef GCC_VERSION
+
+GCC_VERSION = 7.4.0
+
+endif # GCC_VERSION
+
+# PSn00bSDK library/include path setup
+ifndef PSN00BSDK_LIBS
+
+# Default assumes libpsn00b is just in the parent dir of the examples dir
+
+LIBDIRS = -L../../../libpsn00b
+INCLUDE = -I../../../libpsn00b/include
+
+else
+
+LIBDIRS = -L$(PSN00BSDK_LIBS)
+INCLUDE = -I$(PSN00BSDK_LIBS)/include
+
+endif # PSN00BSDK_LIBS
+
+# PSn00bSDK toolchain path setup
+ifndef GCC_BASE
+
+ifndef PSN00BSDK_TC
+
+# Default assumes GCC toolchain is in root of C drive or /usr/local
+
+ifeq "$(OS)" "Windows_NT"
+
+GCC_BASE = /c/mipsel-unknown-elf
+GCC_BIN =
+
+else
+
+GCC_BASE = /usr/local/mipsel-unknown-elf
+GCC_BIN =
+
+endif
+
+else
+
+GCC_BASE = $(PSN00BSDK_TC)
+GCC_BIN = $(PSN00BSDK_TC)/bin/
+
+endif # PSN00BSDK_TC
+
+endif # GCC_BASE
+
+CC = $(GCC_BIN)$(PREFIX)gcc
+CXX = $(GCC_BIN)$(PREFIX)g++
+AS = $(GCC_BIN)$(PREFIX)as
+AR = $(GCC_BIN)$(PREFIX)ar
+RANLIB = $(GCC_BIN)$(PREFIX)ranlib \ No newline at end of file
diff --git a/examples/graphics/balls/makefile b/examples/graphics/balls/makefile
index 50ed0f1..c5ae67b 100644
--- a/examples/graphics/balls/makefile
+++ b/examples/graphics/balls/makefile
@@ -1,4 +1,4 @@
-include ../../sdk-common.mk
+include ../../examples-setup.mk
# Project target name
TARGET = balls.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
diff --git a/examples/graphics/billboard/makefile b/examples/graphics/billboard/makefile
index d6add7a..6537d49 100644
--- a/examples/graphics/billboard/makefile
+++ b/examples/graphics/billboard/makefile
@@ -1,4 +1,4 @@
-include ../../sdk-common.mk
+include ../../examples-setup.mk
TARGET = billboard.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/graphics/fpscam/makefile b/examples/graphics/fpscam/makefile
index 339bb91..fe62ea8 100644
--- a/examples/graphics/fpscam/makefile
+++ b/examples/graphics/fpscam/makefile
@@ -1,4 +1,4 @@
-include ../../sdk-common.mk
+include ../../examples-setup.mk
TARGET = fpscam.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/graphics/gte/makefile b/examples/graphics/gte/makefile
index 8b3f81f..2cd5ed5 100644
--- a/examples/graphics/gte/makefile
+++ b/examples/graphics/gte/makefile
@@ -1,4 +1,4 @@
-include ../../sdk-common.mk
+include ../../examples-setup.mk
TARGET = gte.elf
@@ -11,7 +11,7 @@ OFILES = $(addprefix build/,$(CFILES:.c=.o) $(CPPFILES:.cpp=.o) $(AFILES:.s=.o)
INCLUDE +=
LIBDIRS +=
-LIBS = -lc -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/graphics/render2tex/makefile b/examples/graphics/render2tex/makefile
index aaa3b1d..a6c2e91 100644
--- a/examples/graphics/render2tex/makefile
+++ b/examples/graphics/render2tex/makefile
@@ -1,4 +1,4 @@
-include ../../sdk-common.mk
+include ../../examples-setup.mk
TARGET = render2tex.elf
@@ -11,7 +11,7 @@ OFILES = $(addprefix build/,$(CFILES:.c=.o) $(CPPFILES:.cpp=.o) $(AFILES:.s=.o)
INCLUDE +=
LIBDIRS +=
-LIBS = -lc -lpsxetc -lpsxgpu -lpsxgte -lpsxspu -lpsxapi -lgcc
+LIBS = -lpsxgpu -lpsxgte -lpsxspu -lpsxetc -lpsxapi -lc
CFLAGS = -g -O2 -fno-builtin -fdata-sections -ffunction-sections
CPPFLAGS = $(CFLAGS) -fno-exceptions
diff --git a/examples/graphics/rgb24/makefile b/examples/graphics/rgb24/makefile
index 61ef24f..ca99600 100644
--- a/examples/graphics/rgb24/makefile
+++ b/examples/graphics/rgb24/makefile
@@ -1,4 +1,4 @@
-include ../../sdk-common.mk
+include ../../examples-setup.mk
TARGET = rgb24.elf
@@ -11,7 +11,7 @@ OFILES = $(addprefix build/,$(CFILES:.c=.o) $(CPPFILES:.cpp=.o) $(AFILES:.s=.o)
INCLUDE +=
LIBDIRS +=
-LIBS = -lpsxgpu -lpsxapi -lc
+LIBS = -lpsxgpu -lpsxetc -lpsxapi -lc
CFLAGS = -g -O2 -fno-builtin -fdata-sections -ffunction-sections
CPPFLAGS = $(CFLAGS) -fno-exceptions
diff --git a/examples/sdk-common.mk b/examples/sdk-common.mk
deleted file mode 100644
index 0503b57..0000000
--- a/examples/sdk-common.mk
+++ /dev/null
@@ -1,34 +0,0 @@
-# Adjustable common makefile values for PSn00bSDK example programs.
-# You may need to modify these values to match with your toolchain setup.
-
-# Toolchain prefix
-PREFIX = mipsel-unknown-elf-
-
-# Include directories
-INCLUDE = -I../../../libpsn00b/include
-
-# Library directories, last entry must point toolchain libraries
-LIBDIRS = -L../../../libpsn00b
-
-ifndef GCC_VERSION
-
-GCC_VERSION = 7.4.0
-
-endif
-
-ifndef GCC_BASE
-
-ifeq "$(OS)" "Windows_NT" # For Windows
-
-GCC_BASE = /c/mipsel-unknown-elf
-
-else # For Linux/BSDs
-
-GCC_BASE = /usr/local/mipsel-unknown-elf
-
-endif
-
-endif
-
-LIBDIRS += -L$(GCC_BASE)/lib/gcc/mipsel-unknown-elf/$(GCC_VERSION)
-INCLUDE += -I$(GCC_BASE)/lib/gcc/mipsel-unknown-elf/$(GCC_VERSION)/include
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