al - Audio Library Functions gDP - DP GBI Macros gdSP - General GBI Macros gSP - SP GBI Macros gt - Turbo Microcode RDP gu - Graphics Utilities Math - Math Functions nuSys - NuSystem os - N64 Operating System sp - Sprite Library Functions uh - Host to Target IO 64DD - N64 Disk Drive
|
gSPSprite2DBaseFormat#include "gbi.h" gSPSprite2DBase(Gfx *gdl, usprite *SpritePointer) gsSPSprite2DBase(usprite *SpritePointer)Arguments
It gains access to the sprite microcode. The optimized, full-featured 2D sprite geometry microcode supports automatic subdivision and loads any size of all of the texture format sizes and types supported in the macro, and sends it directly to the RDP. Additionally, images can be scaled up or inverted in the X or Y directions. You can gain access to the sprite microcode through a combination of four macros:
To display a sprite, use this code: #include "gu.h" #include "gbi.h" uSprite MySprite; guSprite2DInit(Mysprite, ImagePointer, TlutPointer, ImageWidth, RectangleWidth, RetangleHeight, ImageType, ImageSize, TextureStartS, TextureStartT); gSPSprite2DBase(glistp++, OS_K0_TO_PHYSICAL(MySprite)); gSPSprite2DScaleFlip (glistp++, ScaleX, ScaleY, FlipTextureX, FlipTextureY); gSPSprite2DDraw (glistp++, PScreenX, PScreenY) typedef struct { void *SourceImagePointer; void *TlutPointer; short Stride; short SubImageWidth; short SubImageHeight; char SourceImageType; char SourceImageBitSize; short SourceImageOffsetS; short SourceImageOffsetT; /* 20 bytes for above */ /* padding to bring structure size to 64-bit alignment */; char dummy[4]; } uSprite_t; typedef union { uSprite_t s; /* make sure this is 64-bit aligned */; long long intNotes The sprite microcode does not directly support Z-Buffering. This is unnecessary as Z-Buffering can be accomplished outside of the sprite microcode by setting up the proper rendering mode and making use of the hardware primitive depth registers. The following is a code fragment for doing Z-Buffering: gDPSetRenderMode(glistp++, G_RM_AA_ZB_OPA_SURF, G_RM_AA_ZB_OPA_SURF2); gDPSetDepthSource(glistp++, G_ZS_PRIM); gDPSetCombineMode(glistp++, G_CC_DECALRGB, G_CC_DECALRGB); gDPSetPrimDepth(glistp++, ZBufferValue, 0); guSprite2DInit(MySprite, ImagePointer, TlutPointer, ImageWidth, RectangleWidth, RectangleHeight, ImageType, ImageSize, TextureStartS, TextureStartT); gSPSprite2DBase(glistp++, OS_K0_TO_PHYSICAL(MySprite)); gSPSprite2DScaleFlip(glistp++, ScaleX, ScaleY, FlipTextureX, FlipTextureY); gSPSprite2DDraw(glistp++, PScreenX, PScreenY);Warnings, Limitations, and Workarounds Images that have been non-unit scaled and flipped around the Y axis may not be smoothly converted in the vertical direction, depending on the quantity of sub-pixels. Jumping will occur at a certain quantity. The solution is to convert non-unit scaling to unit amounts in the vertical direction. The Sprite Microcode was designed to be able to scale up images by any amount. Images can also be scaled down together with some attendant artifacts. Please note that, while the TextureScaleX and TextureScaleY parameters are s 5.10 fixed-point numbers, they are restricted to being positive. Consequently, the largest useable scale value is 32767, which corresponds to a texel to pixel ratio of 31.999. Texture images that are either scaled in the Y axis or placed on a subpixel scanline boundary require filtering by the hardware texture filter unit. This filtering requires that at least one extra line in the screen image be loaded in the texture memory so that the filtering can occur. Because the texture memory is limited to 4KB, the following restrictions are in effect:
gSPSprite2DBase gSPSprite2DScaleFlip gSPSprite2DDraw gspSprite2D
|