/* ============================================================================= File: SPRITE01.C Author: Radouan Khechane (rad@cyberdude.com) Date: 31st October 1998 Description: Displays a sprite on the Net Yaroze PlayStation Copyright (c) 1998 by Radouan Khechane. ============================================================================= */ /* ==================== I N C L U D E S ==================== */ #include // PlayStation library #include "pad.h" // joypad header file /* ==================== D E F I N E S ==================== */ #define OT_LENGTH (1) // length of Ordering Table #define SPRITE_MAX (1) // number of sprites #define SCREEN_WIDTH (320) // screen x resolution #define SCREEN_HEIGHT (240) // screen y resolution #define SPRITE_ADDR (0x80090000) // location of TIM in main memory /* ==================== G L O B A L S ==================== */ GsOT OT_Header[2]; // Ordering Table Headers GsOT_TAG OT_Tag[2][1<x = x; sprite->y = y; switch (image.pmode) // check pixel mode { case 0x08 : // 4bit CLUT sprite->attribute = 0x00000000; sprite->w = image.pw * 4; sprite->tpage = GetTPage(0, 0, image.px, image.py); break; case 0x09 : // 8bit CLUT sprite->attribute = 0x01000000; sprite->w = image.pw * 2; sprite->tpage = GetTPage(1, 0, image.px, image.py); break; default : // 16bit DIRECT sprite->attribute = 0x02000000; sprite->w = image.pw; sprite->tpage = GetTPage(2, 0, image.px, image.py); } // sprite height sprite->h = image.ph; // texture page offset coordinates sprite->u = sprite->v = 0; // CLUT location sprite->cx = image.cx; sprite->cy = image.cy; // RGB brightness of sprite sprite->r = sprite->g = sprite->b = 128; // sprite origin (used for scaling and rotation) sprite->mx = sprite->w / 2; // centre of sprite sprite->my = sprite->h / 2; // centre of sprite // sprite scale (ONE = 4097) sprite->scalex = sprite->scaley = ONE; // original size // sprite rotation (ONE = 4097 = 1 degree) sprite->rotate = 0; // original orientation } /* ================ DrawScreen() ================ */ void DrawScreen (void) { int activeBuffer; // double buffer index // get drawing buffer number activeBuffer = GsGetActiveBuff(); // set drawing command storage address GsSetWorkBase((PACKET*)GpuPacketArea[activeBuffer]); // initialise odering table GsClearOt(0, 0, &OT_Header[activeBuffer]); // register sprite into the odering table GsSortSprite(&sprite, &OT_Header[activeBuffer], 0); // wait for completion of all drawing DrawSync(0); // wait for vertical retrace VSync(0); // swap double buffers (display and drawing buffer) GsSwapDispBuff(); // register clear (screen) command GsSortClear(0x0, 0x0, 0x0, &OT_Header[activeBuffer]); // register request to draw ordering table GsDrawOt(&OT_Header[activeBuffer]); }