From 1aa0e17df7c325a41de8cf8a57f52ed853f08bf3 Mon Sep 17 00:00:00 2001 From: "John Wilbert M. Villamor" Date: Fri, 24 Apr 2020 19:01:28 +0800 Subject: Refined toolchain instructions, organized examples, added automatic retry for CdRead(), added FIOCSCAN ioctl in psxsio TTY driver, added tty and console examples. --- examples/balls/main.c | 228 -------------------------------------------------- 1 file changed, 228 deletions(-) delete mode 100644 examples/balls/main.c (limited to 'examples/balls/main.c') diff --git a/examples/balls/main.c b/examples/balls/main.c deleted file mode 100644 index 89c8063..0000000 --- a/examples/balls/main.c +++ /dev/null @@ -1,228 +0,0 @@ -/* - * LibPSn00b Example Programs - * - * Balls Example - * 2019 Meido-Tek Productions / PSn00bSDK Project - * - * Draws a bunch of ball sprites that bounce around the screen, - * along with a ball snake that might be difficult to see. - * - * - * Example by Lameguy64 - * - * Changelog: - * - * November 20, 2018 - Initial version. - * - */ - -#include -#include -#include -#include -#include -#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 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>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; ix, 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, - getTPage(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; - -} -- cgit v1.2.3