int main(int argc, char *argv[]) { u64 White, Black; GSTEXTURE tex; GSTEXTURE tex8; GSGLOBAL *gsGlobal = gsKit_init_global(); dmaKit_init(D_CTRL_RELE_OFF,D_CTRL_MFD_OFF, D_CTRL_STS_UNSPEC, D_CTRL_STD_OFF, D_CTRL_RCYC_8, 1 << DMA_CHANNEL_GIF); // Initialize the DMAC dmaKit_chan_init(DMA_CHANNEL_GIF); White = GS_SETREG_RGBAQ(0xFF,0xFF,0xFF,0x00,0x00); Black = GS_SETREG_RGBAQ(0x00,0x00,0x00,0x00,0x00); gsGlobal->PSM = GS_PSM_CT24; gsGlobal->ZBuffering = GS_SETTING_OFF; gsKit_init_screen(gsGlobal); gsKit_mode_switch(gsGlobal, GS_PERSISTENT); tex.Width = 256; tex.Height = 256; tex.PSM = GS_PSM_CT24; tex.Mem = (void *)testorig; tex.Vram = gsKit_vram_alloc(gsGlobal, gsKit_texture_size(tex.Width, tex.Height, tex.PSM), GSKIT_ALLOC_USERBUFFER); tex.Filter = GS_FILTER_LINEAR; gsKit_texture_upload(gsGlobal, &tex); tex8.Width = 256; tex8.Height = 256; tex8.PSM = GS_PSM_T8; tex8.Mem = (void *)image_pixel; tex8.Vram = gsKit_vram_alloc(gsGlobal, gsKit_texture_size(tex8.Width, tex8.Height, tex8.PSM), GSKIT_ALLOC_USERBUFFER); tex8.Clut = image_clut32; tex8.ClutPSM = GS_PSM_CT32; tex8.VramClut = gsKit_vram_alloc(gsGlobal, gsKit_texture_size(16, 16, GS_PSM_CT32), GSKIT_ALLOC_USERBUFFER); tex8.Filter = GS_FILTER_LINEAR; gsKit_texture_upload(gsGlobal, &tex8); gsKit_clear(gsGlobal, Black); gsKit_clear(gsGlobal, White); gsKit_prim_sprite_texture(gsGlobal, &tex, 0, 0, 0, 0, 256, 256, 256, 256, 0, 0x80808080); gsKit_prim_sprite_texture(gsGlobal, &tex8, 256, 0, 0, 0, 512, 256, 256, 256, 0, 0x80808080); while(1) { gsKit_sync_flip(gsGlobal); gsKit_queue_exec(gsGlobal); } return 0; }
static int rmUploadTexture(GSTEXTURE* txt) { // For clut based textures... if (txt->Clut) { // upload CLUT first if (!rmUploadClut((GSCLUT *)txt->Clut)) return 0; // copy the new VramClut txt->VramClut = ((GSCLUT*)txt->Clut)->VramClut; } u32 size = gsKit_texture_size(txt->Width, txt->Height, txt->PSM); // alignment of the allocation size = (-GS_VRAM_BLOCKSIZE_256)&(size+GS_VRAM_BLOCKSIZE_256-1); // too large to fit VRAM with the currently allocated space? if(gsGlobal->CurrentPointer + size >= __VRAM_SIZE) { if (size >= __VRAM_SIZE) { // Only log this if the allocation is too large itself LOG("RENDERMAN Requested texture allocation is bigger than VRAM!\n"); // We won't allocate this, it's too large txt->Vram = GSKIT_ALLOC_ERROR; return 0; } rmFlush(); // Should not flush CLUT away. If this happenned we have to reupload if (txt->Clut) { if (!rmUploadClut((GSCLUT *)txt->Clut)) return 0; txt->VramClut = ((GSCLUT*)txt->Clut)->VramClut; } // only could fit CLUT but not the pixmap with it! if(gsGlobal->CurrentPointer + size >= __VRAM_SIZE) return 0; } txt->Vram = gsGlobal->CurrentPointer; gsGlobal->CurrentPointer += size; rmAppendUploadedTextures(txt); // We can't do gsKit_texture_upload since it'd assume txt->Clut is the CLUT table directly // whereas we're using it as a pointer to our structure containg clut data gsKit_setup_tbw(txt); SyncDCache(txt->Mem, (u8*)(txt->Mem)+size); gsKit_texture_send_inline(gsGlobal, txt->Mem, txt->Width, txt->Height, txt->Vram, txt->PSM, txt->TBW, txt->Clut ? GS_CLUT_TEXTURE : GS_CLUT_NONE); return 1; }
int main(int argc, char *argv[]) { #ifdef USEBMP GSTEXTURE backtex; #endif GSTEXTURE fb; GSGLOBAL *gsGlobal; /* initialize dmaKit */ dmaKit_init(D_CTRL_RELE_OFF,D_CTRL_MFD_OFF, D_CTRL_STS_UNSPEC, D_CTRL_STD_OFF, D_CTRL_RCYC_8, 1 << DMA_CHANNEL_GIF); dmaKit_chan_init(DMA_CHANNEL_GIF); /* allocate GSGLOBAL structure */ gsGlobal = gsKit_init_global(); /* initialize screen */ gsGlobal->PSM = GS_PSM_CT24; gsGlobal->ZBuffering = GS_SETTING_OFF; /* spare some vram */ // If we disable double buffering, we can't fill the frame fast enough. // When this happens, we get a line through the top texture about 20% up // from the bottom of the screen. // gsGlobal->DoubleBuffering = GS_SETTING_OFF; /* only one screen */ gsKit_init_screen(gsGlobal); gsKit_mode_switch(gsGlobal, GS_PERSISTENT); fb.Width = 320; fb.Height = 200; fb.PSM = GS_PSM_T8; fb.ClutPSM = GS_PSM_CT32; fb.Mem = memalign(128, gsKit_texture_size_ee(fb.Width, fb.Height, fb.PSM)); fb.Clut = memalign(128, gsKit_texture_size_ee(16, 16, fb.ClutPSM)); fb.VramClut = gsKit_vram_alloc(gsGlobal, gsKit_texture_size(16, 16, fb.ClutPSM), GSKIT_ALLOC_USERBUFFER); fb.Vram = gsKit_vram_alloc(gsGlobal, gsKit_texture_size(fb.Width, fb.Height, fb.PSM), GSKIT_ALLOC_USERBUFFER); fb.Filter = GS_FILTER_LINEAR; /* enable bilinear filtering */ generate_palette(&fb); #ifdef USEBMP gsKit_texture_bmp(gsGlobal, &backtex, "host:bsdgirl.bmp"); #endif /* print out useless debug information */ printf("CLUT Texture:\n"); printf("\tHost start: 0x%08x, end: 0x%08x\n", (unsigned)fb.Mem, (unsigned)(gsKit_texture_size_ee(fb.Width, fb.Height, fb.PSM) + fb.Mem)); printf("\tLocal start: 0x%08x, end: 0x%08x\n", (unsigned)fb.Vram, (unsigned)(gsKit_texture_size(fb.Width, fb.Height, fb.PSM) + fb.Vram)); printf("\tWidth - %d : Height - %d : TBW - %d : Page - %d : Block %d\n", fb.Width, fb.Height, fb.TBW, (fb.Vram / 8192), (fb.Vram / 256)); printf("CLUT Pallete:\n"); printf("\tHost start: 0x%08x, end: 0x%08x\n", (unsigned)fb.Clut, (unsigned)(gsKit_texture_size_ee(16, 16, GS_PSM_CT32) + fb.Clut)); printf("\tLocal start: 0x%08x, end: 0x%08x\n", (unsigned)fb.VramClut, (unsigned)(gsKit_texture_size(16, 16, GS_PSM_CT32) + fb.VramClut)); printf("\tWidth - %d : Height - %d : TBW - %d : Page - %d : Block %d\n", 16, 16, 1, (fb.VramClut / 8192), (fb.VramClut / 256)); #ifdef USEBMP printf("BMP Texture:\n"); printf("\tHost start: 0x%08x, end: 0x%08x\n", (unsigned)backtex.Mem, (unsigned)(gsKit_texture_size_ee(backtex.Width, backtex.Height, backtex.PSM) + backtex.Mem)); printf("\tLocal start: 0x%08x, end: 0x%08x\n", (unsigned)backtex.Vram, (unsigned)(gsKit_texture_size(backtex.Width, backtex.Height, backtex.PSM) + backtex.Vram)); printf("\tWidth - %d : Height - %d : TBW - %d : Page - %d : Block %d\n", backtex.Width, backtex.Height, backtex.TBW, (backtex.Vram / 8192), (backtex.Vram / 256)); #endif printf("VRAM Alignment Check - Value of \"0\" is OKAY! Anything else is BAD!\n"); printf("VRAM - CLUT Pallete - Start Address Aligned: %d\n", fb.VramClut % GS_VRAM_BLOCKSIZE_256); printf("VRAM - CLUT Texture - Start Address Aligned: %d\n", fb.Vram % GS_VRAM_BLOCKSIZE_256); #ifdef USEBMP printf("VRAM - BMP Texture - Start Address Aligned: %d\n", backtex.Vram % GS_VRAM_BLOCKSIZE_256); #endif /* clear buffer */ gsKit_clear(gsGlobal, GS_SETREG_RGBAQ(0x00,0x00,0x00,0x00,0x00)); /* render frame buffer */ gsKit_prim_sprite_texture( gsGlobal, &fb, 0.0f, /* X1 */ 0.0f, /* Y1 */ 0.0f, /* U1 */ 0.0f, /* V1 */ gsGlobal->Width, /* X2 */ gsGlobal->Height, /* Y2 */ fb.Width, /* U2 */ fb.Height, /* V2*/ 1, /* Z */ GS_SETREG_RGBAQ(0x80,0x80,0x80,0x80,0x00) /* RGBAQ */ ); #ifdef USEBMP gsKit_prim_sprite_texture(gsGlobal, &backtex, (gsGlobal->Width /2) - (backtex.Width / 2), /* X1 */ 0.0f, /* Y1 */ 0.0f, /* U1 */ 0.0f, /* V1 */ backtex.Width + ((gsGlobal->Width /2) - (backtex.Width / 2)), /* X2 */ backtex.Height, /* Y2 */ backtex.Width, /* U2 */ backtex.Height, /* V2*/ 2, /* Z */ GS_SETREG_RGBAQ(0x80,0x80,0x80,0x80,0x00) /* RGBAQ */ ); #endif while (1) { /* generate next frame */ generate_frame(&fb); /* upload new frame buffer */ gsKit_texture_upload(gsGlobal, &fb); /* vsync and flip buffer */ gsKit_sync_flip(gsGlobal); /* execute render queue */ gsKit_queue_exec(gsGlobal); } /* keep compilers happy (tm) */ return 0; }
int main(void) { GSGLOBAL *gsGlobal = gsKit_init_global(); //GS_MODE_VGA_640_60 GSTEXTURE Sprite; u64 White = GS_SETREG_RGBAQ(0xFF,0xFF,0xFF,0x00,0x00); #ifdef HAVE_LIBPNG u64 TexCol = GS_SETREG_RGBAQ(0x80,0x80,0x80,0x80,0x00); #endif gsGlobal->PSM = GS_PSM_CT24; gsGlobal->PSMZ = GS_PSMZ_16S; // gsGlobal->DoubleBuffering = GS_SETTING_OFF; // gsGlobal->ZBuffering = GS_SETTING_OFF; dmaKit_init(D_CTRL_RELE_OFF,D_CTRL_MFD_OFF, D_CTRL_STS_UNSPEC, D_CTRL_STD_OFF, D_CTRL_RCYC_8, 1 << DMA_CHANNEL_GIF); // Initialize the DMAC dmaKit_chan_init(DMA_CHANNEL_GIF); gsGlobal->PrimAlphaEnable = GS_SETTING_ON; gsKit_init_screen(gsGlobal); Sprite.Delayed = GS_SETTING_ON; #ifdef HAVE_LIBPNG if(gsKit_texture_png(gsGlobal, &Sprite, "host:texstream.png") < 0) { printf("Loading Failed!\n"); } #endif Sprite.Vram = gsKit_vram_alloc(gsGlobal, gsKit_texture_size(Sprite.Width, Sprite.Height, Sprite.PSM), GSKIT_ALLOC_USERBUFFER); gsKit_mode_switch(gsGlobal, GS_ONESHOT); while(1) { gsKit_clear(gsGlobal, White); gsKit_texture_send_inline(gsGlobal, Sprite.Mem, Sprite.Width, Sprite.Height, Sprite.Vram, Sprite.PSM, Sprite.TBW, GS_CLUT_NONE); gsKit_set_primalpha(gsGlobal, GS_SETREG_ALPHA(0,1,0,1,0), 0); gsKit_set_test(gsGlobal, GS_ATEST_OFF); #ifdef HAVE_LIBPNG gsKit_prim_sprite_texture(gsGlobal, &Sprite, 310.0f, // X1 50.0f, // Y2 0.0f, // U1 0.0f, // V1 Sprite.Width + 310.0f, // X2 Sprite.Height + 50.0f, // Y2 Sprite.Width, // U2 Sprite.Height, // V2 3, TexCol); #endif gsKit_set_test(gsGlobal, GS_ATEST_ON); gsKit_set_primalpha(gsGlobal, GS_BLEND_BACK2FRONT, 0); gsKit_sync_flip(gsGlobal); gsKit_queue_exec(gsGlobal); } return 0; }
void gsKit_init_screen(GSGLOBAL *gsGlobal) { u64 *p_data; u64 *p_store; int size = 18; if((gsGlobal->Dithering == GS_SETTING_ON) && ((gsGlobal->PSM == GS_PSM_CT16) || (gsGlobal->PSM == GS_PSM_CT16S))) size = 19; gsKit_set_buffer_attributes(gsGlobal); #ifdef DEBUG printf("Screen Mode:\n"); printf("------------\n"); printf("Width : %d\n", gsGlobal->Width); printf("Height: %d\n", gsGlobal->Height); printf("StartX: %d\n", gsGlobal->StartX); printf("StartY: %d\n", gsGlobal->StartY); printf("MagH : %d\n", gsGlobal->MagH); printf("MagV : %d\n", gsGlobal->MagV); printf("DW : %d\n", gsGlobal->DW); printf("DH : %d\n", gsGlobal->DH); #endif GS_RESET(); __asm__("sync.p; nop;"); *GS_CSR = 0x00000000; // Clean CSR registers GsPutIMR(0x0000F700); // Unmasks all of the GS interrupts SetGsCrt(gsGlobal->Interlace, gsGlobal->Mode, gsGlobal->Field); gsGlobal->FirstFrame = GS_SETTING_ON; if(gsGlobal->ZBuffering == GS_SETTING_OFF) { gsGlobal->Test->ZTE = GS_SETTING_ON; gsGlobal->Test->ZTST = 1; } DIntr(); // disable interrupts GS_SET_PMODE( 0, // Read Circuit 1 1, // Read Circuit 2 0, // Use ALP Register for Alpha Blending 1, // Alpha Value of Read Circuit 2 for Output Selection 0, // Blend Alpha with output of Read Circuit 2 0x80); // Alpha Value = 1.0 GS_SET_DISPFB1( 0, // Frame Buffer Base Pointer (Address/2048) gsGlobal->Width / 64, // Buffer Width (Address/64) gsGlobal->PSM, // Pixel Storage Format 0, // Upper Left X in Buffer 0); GS_SET_DISPFB2( 0, // Frame Buffer Base Pointer (Address/2048) gsGlobal->Width / 64, // Buffer Width (Address/64) gsGlobal->PSM, // Pixel Storage Format 0, // Upper Left X in Buffer 0); // Upper Left Y in Buffer GS_SET_DISPLAY1(gsGlobal->StartX, // X position in the display area (in VCK unit gsGlobal->StartY, // Y position in the display area (in Raster u gsGlobal->MagH, // Horizontal Magnification gsGlobal->MagV, // Vertical Magnification gsGlobal->DW - 1, // Display area width gsGlobal->DH - 1); // Display area height GS_SET_DISPLAY2(gsGlobal->StartX, // X position in the display area (in VCK units) gsGlobal->StartY, // Y position in the display area (in Raster units) gsGlobal->MagH, // Horizontal Magnification gsGlobal->MagV, // Vertical Magnification gsGlobal->DW - 1, // Display area width gsGlobal->DH - 1); // Display area height GS_SET_BGCOLOR( gsGlobal->BGColor->Red, // Red gsGlobal->BGColor->Green, // Green gsGlobal->BGColor->Blue); // Blue EIntr(); //enable interrupts gsGlobal->CurrentPointer = 0; // reset vram pointer too // Context 1 gsGlobal->ScreenBuffer[0] = gsKit_vram_alloc( gsGlobal, gsKit_texture_size(gsGlobal->Width, gsGlobal->Height, gsGlobal->PSM), GSKIT_ALLOC_SYSBUFFER ); if(gsGlobal->DoubleBuffering == GS_SETTING_OFF) { gsGlobal->ScreenBuffer[1] = gsGlobal->ScreenBuffer[0]; } else // Context 2 gsGlobal->ScreenBuffer[1] = gsKit_vram_alloc( gsGlobal, gsKit_texture_size(gsGlobal->Width, gsGlobal->Height, gsGlobal->PSM), GSKIT_ALLOC_SYSBUFFER ); if(gsGlobal->ZBuffering == GS_SETTING_ON) gsGlobal->ZBuffer = gsKit_vram_alloc( gsGlobal, gsKit_texture_size(gsGlobal->Width, gsGlobal->Height, gsGlobal->PSMZ), GSKIT_ALLOC_SYSBUFFER ); // Z Buffer gsGlobal->TexturePointer = gsGlobal->CurrentPointer; // first useable address for textures p_data = p_store = (u64 *)gsGlobal->dma_misc; *p_data++ = GIF_TAG( size - 1, 1, 0, 0, 0, 1 ); *p_data++ = GIF_AD; *p_data++ = 1; *p_data++ = GS_PRMODECONT; *p_data++ = GS_SETREG_FRAME_1( gsGlobal->ScreenBuffer[0], gsGlobal->Width / 64, gsGlobal->PSM, 0 ); *p_data++ = GS_FRAME_1; *p_data++ = GS_SETREG_XYOFFSET_1( gsGlobal->OffsetX, gsGlobal->OffsetY); *p_data++ = GS_XYOFFSET_1; *p_data++ = GS_SETREG_SCISSOR_1( 0, gsGlobal->Width - 1, 0, gsGlobal->Height - 1 ); *p_data++ = GS_SCISSOR_1; *p_data++ = GS_SETREG_TEST( gsGlobal->Test->ATE, gsGlobal->Test->ATST, gsGlobal->Test->AREF, gsGlobal->Test->AFAIL, gsGlobal->Test->DATE, gsGlobal->Test->DATM, gsGlobal->Test->ZTE, gsGlobal->Test->ZTST ); *p_data++ = GS_TEST_1; *p_data++ = GS_SETREG_CLAMP(gsGlobal->Clamp->WMS, gsGlobal->Clamp->WMT, gsGlobal->Clamp->MINU, gsGlobal->Clamp->MAXU, gsGlobal->Clamp->MINV, gsGlobal->Clamp->MAXV); *p_data++ = GS_CLAMP_1; if(gsGlobal->ZBuffering == GS_SETTING_ON) { if((gsGlobal->PSM == GS_PSM_CT16) && (gsGlobal->PSMZ != GS_PSMZ_16)) gsGlobal->PSMZ = GS_PSMZ_16; // seems only non-S 16-bit z depth works with this mode if((gsGlobal->PSM != GS_PSM_CT16) && (gsGlobal->PSMZ == GS_PSMZ_16)) gsGlobal->PSMZ = GS_PSMZ_16S; // other depths don't seem to work with 16-bit non-S z depth *p_data++ = GS_SETREG_ZBUF_1( gsGlobal->ZBuffer / 8192, gsGlobal->PSMZ, 0 ); *p_data++ = GS_ZBUF_1; } if(gsGlobal->ZBuffering == GS_SETTING_OFF) { *p_data++ = GS_SETREG_ZBUF_1( NULL, gsGlobal->PSM, 1 ); *p_data++ = GS_ZBUF_1; } *p_data++ = GS_SETREG_COLCLAMP( 255 ); *p_data++ = GS_COLCLAMP; *p_data++ = GS_SETREG_FRAME_1( gsGlobal->ScreenBuffer[1], gsGlobal->Width / 64, gsGlobal->PSM, 0 ); *p_data++ = GS_FRAME_2; *p_data++ = GS_SETREG_XYOFFSET_1( gsGlobal->OffsetX, gsGlobal->OffsetY); *p_data++ = GS_XYOFFSET_2; *p_data++ = GS_SETREG_SCISSOR_1( 0, gsGlobal->Width - 1, 0, gsGlobal->Height - 1); *p_data++ = GS_SCISSOR_2; *p_data++ = GS_SETREG_TEST( gsGlobal->Test->ATE, gsGlobal->Test->ATST, gsGlobal->Test->AREF, gsGlobal->Test->AFAIL, gsGlobal->Test->DATE, gsGlobal->Test->DATM, gsGlobal->Test->ZTE, gsGlobal->Test->ZTST ); *p_data++ = GS_TEST_2; *p_data++ = GS_SETREG_CLAMP(gsGlobal->Clamp->WMS, gsGlobal->Clamp->WMT, gsGlobal->Clamp->MINU, gsGlobal->Clamp->MAXU, gsGlobal->Clamp->MINV, gsGlobal->Clamp->MAXV); *p_data++ = GS_CLAMP_2; if(gsGlobal->ZBuffering == GS_SETTING_ON) { *p_data++ = GS_SETREG_ZBUF_1( gsGlobal->ZBuffer / 8192, gsGlobal->PSMZ, 0 ); *p_data++ = GS_ZBUF_2; } if(gsGlobal->ZBuffering == GS_SETTING_OFF) { *p_data++ = GS_SETREG_ZBUF_1( NULL, gsGlobal->PSM, 1 ); *p_data++ = GS_ZBUF_2; } *p_data++ = GS_BLEND_BACK2FRONT; *p_data++ = GS_ALPHA_1; *p_data++ = GS_BLEND_BACK2FRONT; *p_data++ = GS_ALPHA_2; *p_data++ = GS_SETREG_DIMX(gsGlobal->DitherMatrix[0],gsGlobal->DitherMatrix[1], gsGlobal->DitherMatrix[2],gsGlobal->DitherMatrix[3],gsGlobal->DitherMatrix[4], gsGlobal->DitherMatrix[5],gsGlobal->DitherMatrix[6],gsGlobal->DitherMatrix[7], gsGlobal->DitherMatrix[8],gsGlobal->DitherMatrix[9],gsGlobal->DitherMatrix[10], gsGlobal->DitherMatrix[11],gsGlobal->DitherMatrix[12],gsGlobal->DitherMatrix[13], gsGlobal->DitherMatrix[14],gsGlobal->DitherMatrix[15]); // 4x4 dither matrix *p_data++ = GS_DIMX; if((gsGlobal->Dithering == GS_SETTING_ON) && ((gsGlobal->PSM == GS_PSM_CT16) || (gsGlobal->PSM == GS_PSM_CT16S))) { *p_data++ = 1; *p_data++ = GS_DTHE; } dmaKit_send_ucab(DMA_CHANNEL_GIF, p_store, size); dmaKit_wait_fast(); // do a single frame here to get rid whatever needs to be done during the first frame gsKit_clear(gsGlobal, GS_SETREG_RGBAQ(0x00,0x00,0x00,0x00,0x00)); // clear the screen gsKit_queue_exec(gsGlobal); gsKit_sync_flip(gsGlobal); gsKit_queue_reset(gsGlobal->Os_Queue); }
int main(void) { GSGLOBAL *gsGlobal = gsKit_init_global(); GSTEXTURE Tex1; int x = 0, y = 0; #ifdef HAVE_LIBPNG u64 TexCol = GS_SETREG_RGBAQ(0x80,0x80,0x80,0x80,0x00); #endif u64 White = GS_SETREG_RGBAQ(0xFF,0xFF,0xFF,0x00,0x00); u64 BlueTrans = GS_SETREG_RGBAQ(0x00,0x00,0xFF,0x40,0x00); u64 Green = GS_SETREG_RGBAQ(0x00,0xFF,0x00,0x00,0x00); gsGlobal->PSM = GS_PSM_CT32; gsGlobal->PSMZ = GS_PSMZ_16S; gsGlobal->ZBuffering = GS_SETTING_ON; dmaKit_init(D_CTRL_RELE_OFF,D_CTRL_MFD_OFF, D_CTRL_STS_UNSPEC, D_CTRL_STD_OFF, D_CTRL_RCYC_8, 1 << DMA_CHANNEL_GIF); // Initialize the DMAC dmaKit_chan_init(DMA_CHANNEL_GIF); dmaKit_chan_init(DMA_CHANNEL_FROMSPR); dmaKit_chan_init(DMA_CHANNEL_TOSPR); #ifdef HAVE_LIBPNG printf("alpha\n"); gsGlobal->PrimAlphaEnable = GS_SETTING_ON; #endif gsKit_init_screen(gsGlobal); float VHeight = gsGlobal->Height; gsKit_clear(gsGlobal, White); #ifdef HAVE_LIBPNG gsKit_texture_png(gsGlobal, &Tex1, "host:test.png"); printf("Texture 1 Height: %i\n",Tex1.Height); printf("Texture 1 Width: %i\n",Tex1.Width); printf("Texure 1 VRAM Range = 0x%X - 0x%X\n",Tex1.Vram, Tex1.Vram +gsKit_texture_size(Tex1.Width, Tex1.Height, Tex1.PSM) - 1); #endif gsKit_mode_switch(gsGlobal, GS_PERSISTENT); while(1) { if( y <= 10 && (x + Tex1.Width) < (gsGlobal->Width - 10)) x+=10; else if( (y + Tex1.Height) < (VHeight - 10) && (x + Tex1.Width) >= (gsGlobal->Width - 10) ) y+=10; else if( (y + Tex1.Height) >= (VHeight - 10) && x > 10 ) x-=10; else if( y > 10 && x <= 10 ) y-=10; gsKit_clear(gsGlobal, Green); gsKit_prim_sprite(gsGlobal, x, y, x + Tex1.Width, y + Tex1.Height, 1, BlueTrans); #ifdef HAVE_LIBPNG gsKit_set_primalpha(gsGlobal, GS_SETREG_ALPHA(0,1,0,1,0), 0); gsKit_set_test(gsGlobal, GS_ATEST_OFF); gsKit_prim_sprite_texture(gsGlobal, &Tex1, 0.0f, // X1 0.0f, // Y2 0.0f, // U1 0.0f, // V1 Tex1.Width, // X2 Tex1.Height, // Y2 Tex1.Width, // U2 Tex1.Height, // V2 2, TexCol); gsKit_set_test(gsGlobal, GS_ATEST_ON); gsKit_set_primalpha(gsGlobal, GS_BLEND_BACK2FRONT, 0); #endif gsKit_sync_flip(gsGlobal); gsKit_queue_exec(gsGlobal); #ifdef HAVE_LIBPNG gsKit_queue_reset(gsGlobal->Per_Queue); #endif } return 0; }