void drawChar(unsigned int c, int x, int y, int z, u64 colour) { int i, j, pixBase, pixMask; u8 *cm; if(!Settings.interlace){ y = y & -2; } if(c >= FONT_COUNT) c = '_'; if(c > 0xFF) //if char is beyond normal ascii range cm = &font_uLE[c*16]; // cm points to special char def in default font else //else char is inside normal ascii range cm = &FontBuffer[c*16]; // cm points to normal char def in active font pixMask = 0x80; for(i=0; i<8; i++){ //for i == each pixel column pixBase = -1; for(j=0; j<16; j++){ //for j == each pixel row if((pixBase < 0) && (cm[j] & pixMask)){ //if start of sequence pixBase = j; } else if((pixBase > -1) && !(cm[j] & pixMask)){ //if end of sequence gsKit_prim_sprite(gsGlobal, x+i, y+pixBase-1, x+i+1, y+j-1, z, colour); pixBase = -1; } }//ends for j == each pixel row if(pixBase > -1) //if end of sequence including final row gsKit_prim_sprite(gsGlobal, x+i, y+pixBase-1, x+i+1, y+j-1, z, colour); pixMask >>= 1; }//ends for i == each pixel column }
void menu_background( float x1, float y1, float x2, float y2, int z) { int thickness = 3; //border gsKit_prim_sprite(gsGlobal, x1, y1, x2, y1+thickness, z, FCEUSkin.frame); //top gsKit_prim_sprite(gsGlobal, x1, y1, x1+thickness, y2, z, FCEUSkin.frame); //left gsKit_prim_sprite(gsGlobal, x2-thickness, y1, x2, y2, z, FCEUSkin.frame); //right gsKit_prim_sprite(gsGlobal, x1, y2-thickness, x2, y2, z, FCEUSkin.frame); //bottom //background gsKit_prim_quad_gouraud(gsGlobal, x1+thickness, y1+thickness, x2-thickness, y1+thickness, x1+thickness, y2-thickness, x2-thickness, y2-thickness, z+1, FCEUSkin.bgColor1, FCEUSkin.bgColor2, FCEUSkin.bgColor3, FCEUSkin.bgColor4); }
void gsKit_clear(GSGLOBAL *gsGlobal, u64 color) { u8 PrevZState = gsGlobal->Test->ZTST; gsKit_set_test(gsGlobal, GS_ZTEST_OFF); u8 strips = gsGlobal->Width / 64; u8 remain = gsGlobal->Width % 64; u32 pos = 0; strips++; while(strips-- > 0) { gsKit_prim_sprite(gsGlobal, pos, 0, pos + 64, gsGlobal->Height, 0, color); pos += 64; } if(remain > 0) { gsKit_prim_sprite(gsGlobal, pos, 0, remain + pos, gsGlobal->Height, 0, color); } gsGlobal->Test->ZTST = PrevZState; gsKit_set_test(gsGlobal, 0); }
void menu_bgtexture( GSTEXTURE *gsTexture, float x1, float y1, float x2, float y2, int z) { int thickness = 3; //border gsKit_prim_sprite(gsGlobal, x1, y1, x2, y1+thickness, z, FCEUSkin.frame); //top gsKit_prim_sprite(gsGlobal, x1, y1, x1+thickness, y2, z, FCEUSkin.frame); //left gsKit_prim_sprite(gsGlobal, x2-thickness, y1, x2, y2, z, FCEUSkin.frame); //right gsKit_prim_sprite(gsGlobal, x1, y2-thickness, x2, y2, z, FCEUSkin.frame); //bottom gsKit_prim_sprite_texture( gsGlobal, gsTexture, x1+thickness, /* X1 */ y1+thickness, /* Y1 */ 0.0f, /* U1 */ 0.0f, /* V1 */ x2-thickness, /* X2 */ y2-thickness, /* Y2 */ gsTexture->Width, /* U2 */ gsTexture->Height, /* V2*/ z+1, /* Z */ GS_SETREG_RGBA(0x80,0x80,0x80,0x80) /* RGBA */ ); }
int main(void) { GSGLOBAL *gsGlobal = gsKit_init_global(); //GS_MODE_VGA_640_60 #ifdef HAVE_LIBTIFF GSTEXTURE Sprite; u64 TexCol = GS_SETREG_RGBAQ(0x80,0x80,0x80,0x80,0x00); #endif u64 White = GS_SETREG_RGBAQ(0xFF,0xFF,0xFF,0x00,0x00); u64 Red = GS_SETREG_RGBAQ(0xFF,0x00,0x00,0x00,0x00); u64 Green = GS_SETREG_RGBAQ(0x00,0xFF,0x00,0x00,0x00); u64 Blue = GS_SETREG_RGBAQ(0x00,0x00,0xFF,0x00,0x00); u64 BlueTrans = GS_SETREG_RGBAQ(0x00,0x00,0xFF,0x40,0x00); float x = 10; float y = 10; float width = 150; float height = 150; float VHeight = gsGlobal->Height; 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); dmaKit_chan_init(DMA_CHANNEL_FROMSPR); dmaKit_chan_init(DMA_CHANNEL_TOSPR); gsGlobal->PrimAlphaEnable = GS_SETTING_ON; gsKit_init_screen(gsGlobal); #ifdef HAVE_LIBTIFF if(gsKit_texture_tiff(gsGlobal, &Sprite, "host:alpha.tiff") < 0) { printf("Loading Failed!\n"); } #endif gsKit_mode_switch(gsGlobal, GS_PERSISTENT); while(1) { if( y <= 10 && (x + width) < (gsGlobal->Width - 10)) x+=10; else if( (y + height) < (VHeight - 10) && (x + width) >= (gsGlobal->Width - 10) ) y+=10; else if( (y + height) >= (VHeight - 10) && x > 10 ) x-=10; else if( y > 10 && x <= 10 ) y-=10; gsKit_clear(gsGlobal, White); gsKit_prim_quad_gouraud(gsGlobal, 250.0f, 50.0f, 250.0f, 400.0f, 400.0f, 50.0f, 400.0f, 400.0f, 1, Red, Green, Blue, White); gsKit_prim_sprite(gsGlobal, x, y, x + width, y + height, 2, BlueTrans); gsKit_set_primalpha(gsGlobal, GS_SETREG_ALPHA(0,1,0,1,0), 0); gsKit_set_test(gsGlobal, GS_ATEST_OFF); #ifdef HAVE_LIBTIFF 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); gsKit_queue_reset(gsGlobal->Per_Queue); } return 0; }
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; }