aboutsummaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorJohn Wilbert M. Villamor <lameguy64@gmail.com>2019-08-17 14:44:29 +0800
committerJohn Wilbert M. Villamor <lameguy64@gmail.com>2019-08-17 14:44:29 +0800
commit82a441e7bd3a5103330c7d5ca7f9df470953e586 (patch)
treea8a933aa9f03767c6cebc5e11380c37931eae5cd /examples
parente7f9e08937f9d556793c1e0ff0a08856a3897b41 (diff)
downloadpsn00bsdk-82a441e7bd3a5103330c7d5ca7f9df470953e586.tar.gz
Added childexec example, added BIOS memory card functions, changed PAD function names, runtime library now 0.13b
Diffstat (limited to 'examples')
-rw-r--r--examples/balls/main.c3
-rw-r--r--examples/childexec/ball16c.h16
-rw-r--r--examples/childexec/child.c319
-rw-r--r--examples/childexec/child_exe.s6
-rw-r--r--examples/childexec/makefile38
-rw-r--r--examples/childexec/parent.c304
-rw-r--r--examples/fpscam/main.c4
-rw-r--r--examples/n00bdemo/overlay.c8
8 files changed, 691 insertions, 7 deletions
diff --git a/examples/balls/main.c b/examples/balls/main.c
index 4f3ab14..89c8063 100644
--- a/examples/balls/main.c
+++ b/examples/balls/main.c
@@ -200,7 +200,8 @@ int main(int argc, const char* argv[]) {
/* Sort a TPage primitive so the sprites will draw pixels from */
/* the correct texture page in VRAM */
tpri = (DR_TPAGE*)nextpri;
- setDrawTPage( tpri, 0, 0, tim.prect->x, tim.prect->y );
+ setDrawTPage( tpri, 0, 0,
+ getTPage(0, 0, tim.prect->x, tim.prect->y ));
addPrim( ot[db]+(OT_LEN-1), tpri );
nextpri += sizeof(DR_TPAGE);
diff --git a/examples/childexec/ball16c.h b/examples/childexec/ball16c.h
new file mode 100644
index 0000000..c79f273
--- /dev/null
+++ b/examples/childexec/ball16c.h
@@ -0,0 +1,16 @@
+unsigned int ball16c_size=192;
+unsigned char ball16c[] = {
+0x10,0x00,0x00,0x00,0x08,0x00,0x00,0x00,0x2c,0x00,0x00,0x00,0xc0,0x03,0x10,
+0x01,0x10,0x00,0x01,0x00,0x00,0x00,0x31,0xc6,0x73,0xce,0x94,0xd2,0x07,0x9d,
+0xd6,0xda,0x38,0xe3,0xef,0xbd,0x9b,0xef,0x8c,0xb1,0xc6,0x98,0xde,0xfb,0x4a,
+0xa9,0xa4,0x90,0xad,0xb5,0x00,0x00,0x8c,0x00,0x00,0x00,0xc0,0x03,0x00,0x01,
+0x04,0x00,0x10,0x00,0x00,0x00,0x10,0x22,0x12,0x02,0x00,0x00,0x00,0x10,0x32,
+0x33,0x23,0x11,0x04,0x00,0x00,0x23,0x55,0x66,0x35,0x72,0x47,0x00,0x20,0x52,
+0x86,0x68,0x36,0x12,0x97,0x0a,0x20,0x65,0xbb,0x8b,0x36,0x12,0x91,0x04,0x31,
+0x85,0xbb,0x68,0x35,0x12,0x97,0xdc,0x32,0x86,0x8b,0x56,0x35,0x73,0x97,0xa4,
+0x32,0x66,0x68,0x55,0x23,0x71,0x9e,0xac,0x32,0x65,0x56,0x33,0x13,0x71,0xce,
+0xa4,0x21,0x33,0x33,0x23,0x11,0xe7,0xc9,0xd4,0x12,0x22,0x22,0x13,0x71,0xe7,
+0xc9,0xda,0x10,0x17,0x11,0x77,0x77,0x9e,0x4c,0x0d,0x40,0x77,0x71,0xe7,0x9e,
+0xc9,0xd4,0x0d,0x00,0x94,0x99,0x99,0xcc,0x4c,0xda,0x00,0x00,0xa0,0xc4,0xc4,
+0x44,0xda,0x0d,0x00,0x00,0x00,0xd0,0xaa,0xda,0x0d,0x00,0x00
+};
diff --git a/examples/childexec/child.c b/examples/childexec/child.c
new file mode 100644
index 0000000..fb38b63
--- /dev/null
+++ b/examples/childexec/child.c
@@ -0,0 +1,319 @@
+#include <stdio.h>
+#include <psxapi.h>
+#include <psxgpu.h>
+#include <psxgte.h>
+#include <psxpad.h>
+#include <inline_c.h>
+
+/* OT and Packet Buffer sizes */
+#define OT_LEN 256
+#define PACKET_LEN 1024
+
+/* Screen resolution */
+#define SCREEN_XRES 320
+#define SCREEN_YRES 240
+
+/* Screen center position */
+#define CENTERX SCREEN_XRES>>1
+#define CENTERY SCREEN_YRES>>1
+
+
+/* Double buffer structure */
+typedef struct {
+ DISPENV disp; /* Display environment */
+ DRAWENV draw; /* Drawing environment */
+ int ot[OT_LEN]; /* Ordering table */
+ char p[PACKET_LEN]; /* Packet buffer */
+} DB;
+
+/* Double buffer variables */
+DB db[2];
+int db_active = 0;
+char *db_nextpri;
+
+
+/* For easier handling of vertex indices */
+typedef struct {
+ short v0,v1,v2,v3;
+} INDEX;
+
+/* Cube vertices */
+SVECTOR cube_verts[] = {
+ { -100, -100, -100, 0 },
+ { 100, -100, -100, 0 },
+ { -100, 100, -100, 0 },
+ { 100, 100, -100, 0 },
+ { 100, -100, 100, 0 },
+ { -100, -100, 100, 0 },
+ { 100, 100, 100, 0 },
+ { -100, 100, 100, 0 }
+};
+
+/* Cube face normals */
+SVECTOR cube_norms[] = {
+ { 0, 0, -ONE, 0 },
+ { 0, 0, ONE, 0 },
+ { 0, -ONE, 0, 0 },
+ { 0, ONE, 0, 0 },
+ { -ONE, 0, 0, 0 },
+ { ONE, 0, 0, 0 }
+};
+
+/* Cube vertex indices */
+INDEX cube_indices[] = {
+ { 0, 1, 2, 3 },
+ { 4, 5, 6, 7 },
+ { 5, 4, 0, 1 },
+ { 6, 7, 3, 2 },
+ { 0, 2, 5, 7 },
+ { 3, 1, 6, 4 }
+};
+
+/* Number of faces of cube */
+#define CUBE_FACES 6
+
+
+/* Light color matrix */
+/* Each column represents the color matrix of each light source and is */
+/* used as material color when using gte_ncs() or multiplied by a */
+/* source color when using gte_nccs(). 4096 is 1.0 in this matrix */
+/* A column of zeroes disables the light source. */
+MATRIX color_mtx = {
+ ONE, 0, 0, /* Red */
+ ONE, 0, 0, /* Green */
+ ONE, 0, 0 /* Blue */
+};
+
+/* Light matrix */
+/* Each row represents a vector direction of each light source. */
+/* An entire row of zeroes disables the light source. */
+MATRIX light_mtx = {
+ /* X, Y, Z */
+ -2048 , -2048 , -2048,
+ 0 , 0 , 0,
+ 0 , 0 , 0
+};
+
+char pad_buff[2][34];
+
+/* Function declarations */
+void init();
+void display();
+
+
+/* Main function */
+int main() {
+
+ int i,p,xy_temp;
+
+ SVECTOR rot = { 0 }; /* Rotation vector for Rotmatrix */
+ VECTOR pos = { 0, 0, 400 }; /* Translation vector for TransMatrix */
+ MATRIX mtx,lmtx; /* Rotation matrices for geometry and lighting */
+
+ POLY_F4 *pol4; /* Flat shaded quad primitive pointer */
+
+
+ /* Init graphics and GTE */
+ init();
+
+
+ /* Main loop */
+ while( 1 ) {
+
+ PADTYPE *pad = (PADTYPE*)pad_buff[0];
+
+ if( pad->stat == 0 ) {
+
+ // For digital pad, dual-analog and dual-shock
+ if( ( pad->type == 0x4 ) || ( pad->type == 0x5 ) || ( pad->type == 0x7 ) ) {
+
+ if( !(pad->btn&PAD_SELECT) ) {
+ break;
+ }
+
+ }
+
+ }
+
+ /* Set rotation and translation to the matrix */
+ RotMatrix( &rot, &mtx );
+ TransMatrix( &mtx, &pos );
+
+ /* Multiply light matrix by rotation matrix so light source */
+ /* won't appear relative to the model's rotation */
+ MulMatrix0( &light_mtx, &mtx, &lmtx );
+
+ /* Set rotation and translation matrix */
+ gte_SetRotMatrix( &mtx );
+ gte_SetTransMatrix( &mtx );
+
+ /* Set light matrix */
+ gte_SetLightMatrix( &lmtx );
+
+ /* Make the cube SPEEN */
+ rot.vx += 16;
+ rot.vz += 16;
+
+
+ /* Draw the cube */
+ pol4 = (POLY_F4*)db_nextpri;
+
+ for( i=0; i<CUBE_FACES; i++ ) {
+
+ /* Load the first 3 vertices of a quad to the GTE */
+ gte_ldv3(
+ &cube_verts[cube_indices[i].v0],
+ &cube_verts[cube_indices[i].v1],
+ &cube_verts[cube_indices[i].v2] );
+
+ /* Rotation, Translation and Perspective Triple */
+ gte_rtpt();
+
+ /* Compute normal clip for backface culling */
+ gte_nclip();
+
+ /* Get result*/
+ gte_stopz( &p );
+
+ /* Skip this face if backfaced */
+ if( p < 0 )
+ continue;
+
+ /* Calculate average Z for depth sorting */
+ gte_avsz4();
+ gte_stotz( &p );
+
+ /* Skip if clipping off */
+ /* (the shift right operator is to scale the depth precision) */
+ if( (p>>2) > OT_LEN )
+ continue;
+
+ /* Initialize a quad primitive */
+ setPolyF4( pol4 );
+
+ /* Set the projected vertices to the primitive */
+ gte_stsxy0( &pol4->x0 );
+ gte_stsxy1( &pol4->x1 );
+ gte_stsxy2( &pol4->x2 );
+
+ /* Compute the last vertex and set the result */
+ gte_ldv0( &cube_verts[cube_indices[i].v3] );
+ gte_rtps();
+ gte_stsxy( &pol4->x3 );
+
+ /* Load primitive color even though gte_ncs() doesn't use it. */
+ /* This is so the GTE will output a color result with the */
+ /* correct primitive code. */
+ gte_ldrgb( &pol4->r0 );
+
+ /* Load the face normal */
+ gte_ldv0( &cube_norms[i] );
+
+ /* Normal Color Single */
+ gte_ncs();
+
+ /* Store result to the primitive */
+ gte_strgb( &pol4->r0 );
+
+ /* Sort primitive to the ordering table */
+ addPrim( db[db_active].ot+(p>>2), pol4 );
+
+ /* Advance to make another primitive */
+ pol4++;
+
+ }
+
+ /* Update nextpri variable */
+ /* (IMPORTANT if you plan to sort more primitives after this) */
+ db_nextpri = (char*)pol4;
+
+ /* Swap buffers and draw the primitives */
+ display();
+
+ }
+
+ StopPAD();
+
+ return 0;
+
+}
+
+void init() {
+
+ /* Reset the GPU, also installs a VSync event handler */
+ ResetGraph( 0 );
+
+ /* Set display and draw environment areas */
+ /* (display and draw areas must be separate, otherwise hello flicker) */
+ SetDefDispEnv( &db[0].disp, 0, 0, SCREEN_XRES, SCREEN_YRES );
+ SetDefDrawEnv( &db[0].draw, SCREEN_XRES, 0, SCREEN_XRES, SCREEN_YRES );
+
+ /* Enable draw area clear and dither processing */
+ setRGB0( &db[0].draw, 63, 0, 127 );
+ db[0].draw.isbg = 1;
+ db[0].draw.dtd = 1;
+
+
+ /* Define the second set of display/draw environments */
+ SetDefDispEnv( &db[1].disp, SCREEN_XRES, 0, SCREEN_XRES, SCREEN_YRES );
+ SetDefDrawEnv( &db[1].draw, 0, 0, SCREEN_XRES, SCREEN_YRES );
+
+ setRGB0( &db[1].draw, 63, 0, 127 );
+ db[1].draw.isbg = 1;
+ db[1].draw.dtd = 1;
+
+
+ /* Apply the drawing environment of the first double buffer */
+ PutDrawEnv( &db[0].draw );
+
+
+ /* Clear both ordering tables to make sure they are clean at the start */
+ ClearOTagR( db[0].ot, OT_LEN );
+ ClearOTagR( db[1].ot, OT_LEN );
+
+ /* Set primitive pointer address */
+ db_nextpri = db[0].p;
+
+ /* Initialize the GTE */
+ InitGeom();
+
+ /* Set GTE offset (recommended method of centering) */
+ gte_SetGeomOffset( CENTERX, CENTERY );
+
+ /* Set screen depth (basically FOV control, W/2 works best) */
+ gte_SetGeomScreen( CENTERX );
+
+ /* Set light ambient color and light color matrix */
+ gte_SetBackColor( 63, 63, 63 );
+ gte_SetColorMatrix( &color_mtx );
+
+ InitPAD(pad_buff[0], 34, pad_buff[1], 34);
+ StartPAD();
+ ChangeClearPAD(0);
+
+}
+
+void display() {
+
+ /* Wait for GPU to finish drawing and vertical retrace */
+ DrawSync( 0 );
+ VSync( 0 );
+
+ /* Swap buffers */
+ db_active ^= 1;
+ db_nextpri = db[db_active].p;
+
+ /* Clear the OT of the next frame */
+ ClearOTagR( db[db_active].ot, OT_LEN );
+
+ /* Apply display/drawing environments */
+ PutDrawEnv( &db[db_active].draw );
+ PutDispEnv( &db[db_active].disp );
+
+ /* Enable display */
+ SetDispMask( 1 );
+
+ /* Start drawing the OT of the last buffer */
+ DrawOTag( db[1-db_active].ot+(OT_LEN-1) );
+
+} \ No newline at end of file
diff --git a/examples/childexec/child_exe.s b/examples/childexec/child_exe.s
new file mode 100644
index 0000000..842ac88
--- /dev/null
+++ b/examples/childexec/child_exe.s
@@ -0,0 +1,6 @@
+.section .data
+
+.global child_exe # Insert spoopypasta
+.type child_exe, @object
+child_exe:
+ .incbin "child.exe" \ No newline at end of file
diff --git a/examples/childexec/makefile b/examples/childexec/makefile
new file mode 100644
index 0000000..9cf7218
--- /dev/null
+++ b/examples/childexec/makefile
@@ -0,0 +1,38 @@
+include ../sdk-common.mk
+
+INCLUDE +=
+LIBDIRS +=
+
+LIBS = -lpsxetc -lpsxgpu -lpsxgte -lpsxspu -lc -lpsxapi
+
+CFLAGS = -g -O2 -fno-builtin -fdata-sections -ffunction-sections
+CPPFLAGS = $(CFLAGS) -fno-exceptions
+AFLAGS = -g -msoft-float
+LDFLAGS = -g -gc-sections -T $(GCC_BASE)/mipsel-unknown-elf/lib/ldscripts/elf32elmip.x
+
+LDFLAGS_P = $(LDFLAGS) -Ttext=0x80010000
+LDFLAGS_C = $(LDFLAGS) -Ttext=0x80030000
+
+CC = $(PREFIX)gcc
+LD = $(PREFIX)ld
+
+all: child parent
+
+child: build/child.o
+ $(LD) $(LDFLAGS_C) $(LIBDIRS) build/child.o $(LIBS) -o child.elf
+ elf2x 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
+
+build/%.o: %.c
+ @mkdir -p $(dir $@)
+ $(CC) $(CFLAGS) $(INCLUDE) -c $< -o $@
+
+build/%.o: %.s
+ @mkdir -p $(dir $@)
+ $(CC) $(AFLAGS) $(INCLUDE) -c $< -o $@
+
+clean:
+ rm -rf build parent.elf parent.exe child.elf child.exe
diff --git a/examples/childexec/parent.c b/examples/childexec/parent.c
new file mode 100644
index 0000000..dbaf696
--- /dev/null
+++ b/examples/childexec/parent.c
@@ -0,0 +1,304 @@
+/*
+ * LibPSn00b Example Programs
+ *
+ * Child Program Execution Example
+ * 2019 Meido-Tek Productions / PSn00bSDK Project
+ *
+ * This is a modification of the balls example, modified to execute
+ * a child program for this example.
+ *
+ * Example by Lameguy64
+ *
+ */
+
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#include <psxetc.h>
+#include <psxapi.h>
+#include <psxgte.h>
+#include <psxgpu.h>
+#include <psxpad.h>
+#include "ball16c.h"
+
+
+#define MAX_BALLS 1024
+
+#define OT_LEN 8
+
+#define SCREEN_XRES 640
+#define SCREEN_YRES 480
+
+#define CENTER_X SCREEN_XRES/2
+#define CENTER_Y SCREEN_YRES/2
+
+
+/* Display and drawing environments */
+DISPENV disp;
+DRAWENV draw;
+
+char pribuff[2][65536]; /* Primitive packet buffers */
+unsigned int ot[2][OT_LEN]; /* Ordering tables */
+char *nextpri; /* Pointer to next packet buffer offset */
+int db = 0; /* Double buffer index */
+
+
+/* Ball struct and array */
+typedef struct {
+ short x,y;
+ short xdir,ydir;
+ unsigned char r,g,b,p;
+} BALL_TYPE;
+
+BALL_TYPE balls[MAX_BALLS];
+
+
+/* TIM image parameters for loading the ball texture and drawing sprites */
+TIM_IMAGE tim;
+
+
+void run_child();
+
+char pad_buff[2][34];
+
+
+void init() {
+
+ int i;
+
+ /* Reset GPU (also installs event handler for VSync) */
+ printf("Init GPU... ");
+ ResetGraph( 0 );
+ printf("Done.\n");
+
+
+ printf("Set video mode... ");
+
+ /* Set display and draw environment parameters */
+ SetDefDispEnv( &disp, 0, 0, SCREEN_XRES, SCREEN_YRES );
+ SetDefDrawEnv( &draw, 0, 0, SCREEN_XRES, SCREEN_YRES );
+ disp.isinter = 1; /* Enable interlace (required for hires) */
+
+ /* Set clear color, area clear and dither processing */
+ setRGB0( &draw, 63, 0, 127 );
+ draw.isbg = 1;
+ draw.dtd = 1;
+
+ /* Apply the display and drawing environments */
+ PutDispEnv( &disp );
+ PutDrawEnv( &draw );
+
+ /* Enable video output */
+ SetDispMask( 1 );
+
+ printf("Done.\n");
+
+
+ /* Upload the ball texture */
+ printf("Upload texture... ");
+ GetTimInfo( (unsigned int*)ball16c, &tim ); /* Get TIM parameters */
+
+ LoadImage( tim.prect, tim.paddr ); /* Upload texture to VRAM */
+ if( tim.mode & 0x8 ) {
+ LoadImage( tim.crect, tim.caddr ); /* Upload CLUT if present */
+ }
+
+ printf("Done.\n");
+
+
+ /* Calculate ball positions */
+ printf("Calculating balls... ");
+
+ for(i=0; i<MAX_BALLS; i++) {
+
+ balls[i].x = (rand()%624);
+ balls[i].y = (rand()%464);
+ balls[i].xdir = 1-(rand()%3);
+ balls[i].ydir = 1-(rand()%3);
+ if( !balls[i].xdir ) balls[i].xdir = 1;
+ if( !balls[i].ydir ) balls[i].ydir = 1;
+ balls[i].xdir *= 2;
+ balls[i].ydir *= 2;
+ balls[i].r = (rand()%256);
+ balls[i].g = (rand()%256);
+ balls[i].b = (rand()%256);
+
+ }
+
+ printf("Done.\n");
+
+ InitPAD(pad_buff[0], 34, pad_buff[1], 34);
+ StartPAD();
+ ChangeClearPAD(0);
+
+}
+
+int main(int argc, const char* argv[]) {
+
+ SPRT_16 *sprt;
+ DR_TPAGE *tpri;
+
+ int i,counter=0;
+
+
+ /* Init graphics and stuff before doing anything else */
+ init();
+
+
+ /* Main loop */
+ printf("Entering loop...\n");
+
+ while(1) {
+
+ PADTYPE *pad = (PADTYPE*)pad_buff[0];
+
+ if( pad->stat == 0 ) {
+
+ // For digital pad, dual-analog and dual-shock
+ if( ( pad->type == 0x4 ) || ( pad->type == 0x5 ) || ( pad->type == 0x7 ) ) {
+
+ if( !(pad->btn&PAD_START) ) {
+ DrawSync(0);
+ run_child();
+ }
+
+ }
+
+ }
+
+ /* Clear ordering table and set start address of primitive */
+ /* buffer for next frame */
+ ClearOTagR( ot[db], OT_LEN );
+ nextpri = pribuff[db];
+
+ /* Sort a balls snake */
+ sprt = (SPRT_16*)nextpri;
+ srand( 64 );
+ for( i=0; i<32; i++ ) {
+
+ setSprt16( sprt );
+ setXY0( sprt,
+ (CENTER_X-8)+(isin((counter-(i<<4))<<3)>>5),
+ (CENTER_Y-8)-(icos((counter-(i<<2))<<3)>>5) );
+ setRGB0( sprt, rand()%256, rand()%256, rand()%256 );
+ setUV0( sprt, 0, 0 );
+ setClut( sprt, tim.crect->x, tim.crect->y );
+
+ addPrim( ot[db]+(OT_LEN-1), sprt );
+ sprt++;
+
+ }
+
+ /* Sort the balls */
+ for( i=0; i<MAX_BALLS; i++ ) {
+
+ setSprt16( sprt );
+ setXY0( sprt, balls[i].x, balls[i].y );
+ setRGB0( sprt, balls[i].r, balls[i].g, balls[i].b );
+ setUV0( sprt, 0, 0 );
+ setClut( sprt, tim.crect->x, tim.crect->y );
+
+ addPrim( ot[db]+(OT_LEN-1), sprt );
+ sprt++;
+
+ balls[i].x += balls[i].xdir;
+ balls[i].y += balls[i].ydir;
+
+ if( ( balls[i].x+16 ) > 640 ) {
+ balls[i].xdir = -2;
+ } else if( balls[i].x < 0 ) {
+ balls[i].xdir = 2;
+ }
+
+ if( ( balls[i].y+16 ) > 480 ) {
+ balls[i].ydir = -2;
+ } else if( balls[i].y < 0 ) {
+ balls[i].ydir = 2;
+ }
+
+ }
+ nextpri = (char*)sprt;
+
+
+ /* Sort a TPage primitive so the sprites will draw pixels from */
+ /* the correct texture page in VRAM */
+ tpri = (DR_TPAGE*)nextpri;
+ setDrawTPage( tpri, 0, 0, tim.prect->x, tim.prect->y );
+ addPrim( ot[db]+(OT_LEN-1), tpri );
+ nextpri += sizeof(DR_TPAGE);
+
+ /* Wait for GPU and VSync */
+ DrawSync( 0 );
+ VSync( 0 );
+
+ /* Since draw.isbg is non-zero this clears the screen */
+ PutDrawEnv( &draw );
+
+ /* Begin drawing the new frame */
+ DrawOTag( ot[db]+(OT_LEN-1) );
+
+ /* Alternate to the next buffer */
+ db = !db;
+
+ /* Increment counter for the snake animation */
+ counter++;
+
+ }
+
+ return 0;
+
+}
+
+// PS-EXE header structure
+typedef struct {
+ char id[16];
+ struct EXEC param;
+ char pad[1972];
+} EXE_HEAD;
+
+// Child program address
+extern char child_exe[];
+
+// Manually defined as its not defined in psxapi by default
+void SetDefaultExitFromException();
+
+void run_child() {
+
+ // So child header is readable
+ EXE_HEAD *exe = (EXE_HEAD*)child_exe;
+
+ // Copy child executable to its intended adddress
+ memcpy((void*)exe->param.t_addr, child_exe+2048, exe->param.t_size);
+
+ // Enter critical section to prepare for program execution
+ EnterCriticalSection();
+
+ // Stop pads, enable auto acknowledge
+ StopPAD();
+ ChangeClearPAD(1);
+ ChangeClearRCnt(3, 1);
+
+ // Set default exception handler just in case
+ //SetDefaultExitFromException();
+
+ // Last three function calls could be relegated to
+ // a StopCallback() function in the future.
+
+ // Execute child
+ printf("Child exec!\n");
+ Exec(&exe->param, 0, 0);
+
+ // Reset previous handler
+ EnterCriticalSection();
+ RestartCallback();
+ ExitCriticalSection();
+
+ // Re-init and re-enable pads
+ InitPAD(pad_buff[0], 34, pad_buff[1], 34);
+ StartPAD();
+ ChangeClearPAD(0);
+
+ // Set this program's display mode
+ PutDispEnv(&disp);
+
+} \ No newline at end of file
diff --git a/examples/fpscam/main.c b/examples/fpscam/main.c
index 0cde9f5..32c8de4 100644
--- a/examples/fpscam/main.c
+++ b/examples/fpscam/main.c
@@ -617,10 +617,10 @@ void init() {
// Init BIOS pad driver and set pad buffers (buffers are updated
// automatically on every V-Blank)
- _InitPad(&pad_buff[0][0], 34, &pad_buff[1][0], 34);
+ InitPAD(&pad_buff[0][0], 34, &pad_buff[1][0], 34);
// Start pad
- _StartPad();
+ StartPAD();
// Don't make pad driver acknowledge V-Blank IRQ (recommended)
ChangeClearPAD(0);
diff --git a/examples/n00bdemo/overlay.c b/examples/n00bdemo/overlay.c
index 9b04274..847bc96 100644
--- a/examples/n00bdemo/overlay.c
+++ b/examples/n00bdemo/overlay.c
@@ -126,7 +126,7 @@ void sort_overlay(int showlotl) {
nextpri = (char*)line;
tp = (DR_TPAGE*)nextpri;
- setDrawTPageVal( tp, font_tpage );
+ setDrawTPage( tp, 0, 1, font_tpage );
addPrim( ot[db], tp );
nextpri += sizeof(DR_TPAGE);
@@ -164,7 +164,7 @@ void sort_overlay(int showlotl) {
}
tp = (DR_TPAGE*)nextpri;
- setDrawTPageVal( tp, getTPage( 0, 2, 0, 0 )|0x200 );
+ setDrawTPage( tp, 0, 1, getTPage( 0, 2, 0, 0 ) );
addPrim( ot[db], tp );
nextpri += sizeof(DR_TPAGE);
@@ -177,7 +177,7 @@ void sort_overlay(int showlotl) {
nextpri += sizeof(SPRT);
tp = (DR_TPAGE*)nextpri;
- setDrawTPageVal( tp, lamelotl_tpage );
+ setDrawTPage( tp, 0, 1, lamelotl_tpage );
addPrim( ot[db], tp );
nextpri += sizeof(DR_TPAGE);
@@ -190,7 +190,7 @@ void sort_overlay(int showlotl) {
nextpri += sizeof(SPRT);
tp = (DR_TPAGE*)nextpri;
- setDrawTPageVal( tp, psn00b_tpage );
+ setDrawTPage( tp, 0, 1, psn00b_tpage );
addPrim( ot[db], tp );
nextpri += sizeof(DR_TPAGE);