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; }
void displayjpeg(jpgData *jpg) { GSTEXTURE tex; u8 *data; int i; data = malloc(jpg->width * jpg->height * (jpg->bpp/8)); jpgReadImage(jpg, data); tex.Width = jpg->width; tex.Height = jpg->height; tex.PSM = GS_PSM_CT24; tex.Vram = 0; tex.Mem = (u32*) data; gsKit_texture_upload(gsGlobal, &tex); jpgClose(jpg); free(data); for (i=0; i<120; i++) { gsKit_vsync(); } }
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; }