void video_init() { gsGlobal = gsKit_init_global(); gsFontM = gsKit_init_fontm(); 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); Black = GS_SETREG_RGBAQ(0x00,0x00,0x00,0xFF,0x00); White = GS_SETREG_RGBAQ(0xFF,0xFF,0xFF,0x00,0x00); Red = CircleColor = GS_SETREG_RGBAQ(0xFF,0x00,0x00,0x00,0x00); Blue = GS_SETREG_RGBAQ(0x00,0x00,0xFF,0x00,0x00); FontColor = GS_SETREG_RGBAQ(0x2F,0x20,0x20,0xFF,0x00); gsGlobal->PrimAlphaEnable = GS_SETTING_ON; gsKit_init_screen(gsGlobal); gsKit_fontm_upload(gsGlobal, gsFontM); gsFontM->Spacing = 0.75f; gsKit_mode_switch(gsGlobal, GS_ONESHOT); }
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; }
int main() { jpgData *jpg; SifInitRpc(0); printf("start\n"); dmaKit_init(D_CTRL_RELE_ON, 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 = gsKit_init_global(GS_MODE_NTSC); gsGlobal->PSM = GS_PSM_CT24; gsKit_init_screen(gsGlobal); printf("display raw jpeg\n"); jpg = jpgOpenRAW(jpegtest, sizeof(jpegtest)); if (jpg == NULL) { printf("error opening raw jpeg\n"); } else { displayjpeg(jpg); } printf("display cdrom0:\\TEST.JPG;1\n"); jpg = jpgOpen("cdrom0:\\TEST.JPG;1"); if (jpg == NULL) { printf("error opening cdrom0:\\TEST.JPG;1\n"); } else { displayjpeg(jpg); } printf("display host0:testorig.jpg\n"); jpg = jpgOpen("host0:testorig.jpg"); if (jpg == NULL) { printf("error opening host0:testorig.jpg\n"); } else { displayjpeg(jpg); } printf("create screenshot file host0:screen.jpg\n"); //ps2_screenshot_jpg("host0:screen.jpg", 0, 640, 480, GS_PSM_CT32); jpgScreenshot("host0:screen.jpg", gsGlobal->CurrentPointer, gsGlobal->Width, gsGlobal->Height, gsGlobal->PSM); return 0; }
void init_custom_screen() { if (Settings.display == 0) { gsGlobal->Mode = GS_MODE_NTSC; gsGlobal->Interlace = GS_INTERLACED; gsGlobal->Field = GS_FIELD; gsGlobal->Width = 640; gsGlobal->Height = 448; VCK = 4; } else if (Settings.display == 1) { gsGlobal->Mode = GS_MODE_PAL; gsGlobal->Interlace = GS_INTERLACED; gsGlobal->Field = GS_FIELD; gsGlobal->Width = 640; gsGlobal->Height = 512; VCK = 4; } else if (Settings.display == 2) { gsGlobal->Mode = GS_MODE_DTV_480P; gsGlobal->Interlace = GS_NONINTERLACED; gsGlobal->Field = GS_FRAME; gsGlobal->Width = 640; gsGlobal->Height = 480; VCK = 2; } if (Settings.display == 0 || Settings.display == 1) { if (!Settings.interlace) { gsGlobal->Interlace = GS_NONINTERLACED; gsGlobal->Height = gsGlobal->Height / 2; VCK = 2; } } gsKit_vram_clear(gsGlobal); gsKit_init_screen(gsGlobal); /* Apply settings. */ gsKit_set_display_offset(gsGlobal, Settings.offset_x * VCK, Settings.offset_y); gsKit_mode_switch(gsGlobal, GS_ONESHOT); }
int rmSetMode(int force) { if (gVMode < RM_VMODE_AUTO || gVMode >= NUM_RM_VMODES) gVMode = RM_VMODE_AUTO; // we don't want to set the vmode without a reason... int changed = (vmode != gVMode || force); if (changed) { vmode = gVMode; gsGlobal->Mode = rm_mode_table[vmode].mode; gsGlobal->Height = rm_mode_table[vmode].height; if (vmode == RM_VMODE_DTV480P || vmode == RM_VMODE_DTV576P || vmode == RM_VMODE_VGA_640_60) { gsGlobal->Interlace = GS_NONINTERLACED; gsGlobal->Field = GS_FRAME; } else { gsGlobal->Interlace = GS_INTERLACED; gsGlobal->Field = GS_FIELD; } gsGlobal->Width = 640; gsGlobal->PSM = GS_PSM_CT24; gsGlobal->PSMZ = GS_PSMZ_16S; gsGlobal->ZBuffering = GS_SETTING_OFF; gsGlobal->PrimAlphaEnable = GS_SETTING_ON; gsGlobal->DoubleBuffering = GS_SETTING_ON; if ((gsGlobal->Mode) == GS_MODE_DTV_576P) { // Write X, Y, DW and DH positions for DTV576P (not covered by GSKit lib) gsGlobal->StartX = 324; gsGlobal->StartY = 72; gsGlobal->DW = 1280; gsGlobal->DH = 512; } gsKit_init_screen(gsGlobal); if (vmode == RM_VMODE_DTV480P) { // Overwrite X, Y and DW GSKit params for DTV480P gsGlobal->StartX = 312; gsGlobal->StartY = 37 + (480-448)/2; gsGlobal->DW = 1280; gsGlobal->DH = 448; } else if (vmode == RM_VMODE_VGA_640_60) { // Overwrite X, Y GSKit params for VGA_640_60 gsGlobal->StartX = 276; gsGlobal->StartY = 42; } if ((vmode == RM_VMODE_DTV480P) || (vmode == RM_VMODE_VGA_640_60)) { // Commit settings for DTV480P and VGA_650_60 DIntr(); // disable interrupts 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 __asm__("sync.l; sync.p;"); EIntr(); // enable interrupts } gsKit_mode_switch(gsGlobal, GS_ONESHOT); gsKit_set_test(gsGlobal, GS_ZTEST_OFF); // reset the contents of the screen to avoid garbage being displayed gsKit_clear(gsGlobal, gColBlack); gsKit_sync_flip(gsGlobal); LOG("RENDERMAN New vmode: %d, %d x %d\n", vmode, gsGlobal->Width, gsGlobal->Height); } return changed; }
/** Browser Menu Display: PAL/NTSC Emulated System: PAL/NTSC Center Screen Configure Save Path: (browse to path) Configure Elf Path: (browse to path) Exit to Elf Path Exit to PS2Browser **/ int Browser_Menu(void) { char *temp; char cnfpath[2048]; int i,selection = 0; oldselect = -1; int option_changed = 0; int menu_x1 = gsGlobal->Width*0.25; int menu_y1 = gsGlobal->Height*0.15; int menu_x2 = gsGlobal->Width*0.75; int menu_y2 = gsGlobal->Height*0.85+FONT_HEIGHT; int text_line = menu_y1 + 4; char options[12][39] = { { "Display: " }, { "Interlacing: " }, { "Emulated System: " }, { "Center Screen" }, { "Configure Save Path: " }, { "" }, { "Configure ELF Path: " }, { "" }, { "Save FCEUltra.cnf"}, { "Power Off" }, { "Exit to ELF" }, { "Exit Options Menu" } }; //fill lines with values for(i=0;i<12;i++) { switch(i) { case 0: if(!Settings.display) { sprintf(options[i],"%s%s",options[i],"NTSC"); } else { sprintf(options[i],"%s%s",options[i],"PAL"); } break; case 1: if(Settings.interlace) { sprintf(options[i],"%s%s",options[i],"On"); } else { sprintf(options[i],"%s%s",options[i],"Off"); } break; case 2: if(!Settings.emulation) { sprintf(options[i],"%s%s",options[i],"NTSC"); } else { sprintf(options[i],"%s%s",options[i],"PAL"); } break; case 5: strzncpy(options[5],Settings.savepath,38); break; case 7: strzncpy(options[7],Settings.elfpath,38); break; } } while(1) { selected = 0; //clear selected flag selection += menu_input(0,0); if(selection > 11) { selection = 0; } if(selection < 0) { selection = 11; } if(selection == 5 && oldselect == 4) { selection++; } //5 is savepath if(selection == 5 && oldselect == 6) { selection--; } if(selection == 7 && oldselect == 6) { selection++; } //7 is elfpath if(selection == 7 && oldselect == 8) { selection--; } if((oldselect != selection) || option_changed) { gsKit_clear(gsGlobal,GS_SETREG_RGBAQ(0x00,0x00,0x00,0x80,0x00)); menu_primitive("Options", &MENU_TEX, menu_x1, menu_y1, menu_x2, menu_y2); for(i=0;i<12;i++) { if(selection == i) { //font_print(gsGlobal, menu_x1+10.0f, text_line + i*FONT_HEIGHT, 2, DarkYellowFont, options[i]); printXY(options[i],menu_x1+10,text_line+i*FONT_HEIGHT, 4, FCEUSkin.highlight, 1, 0); } else { //font_print(gsGlobal, menu_x1+10.0f, text_line + i*FONT_HEIGHT, 2, WhiteFont, options[i]); printXY(options[i],menu_x1+10,text_line + i*FONT_HEIGHT, 4, FCEUSkin.textcolor, 1, 0); } } DrawScreen(gsGlobal); if(power_off) option_changed = 1; power_off--; if(!power_off) { strcpy(cnfpath,"xyz:/imaginary/hypothetical/doesn't.exist"); FILE *File; File = fopen(cnfpath,"r"); if(File != NULL) fclose(File); } } oldselect = selection; option_changed = 0; if(selected) { if(selected == 2) { selection = 11; } i = selection; switch(i) { case 0: //Display PAL/NTSC Settings.display ^= 1; if(Settings.display) { gsGlobal->Mode = GS_MODE_PAL; gsGlobal->Height = 512; defaulty = 72; temp = strstr(options[i],"NTSC"); *temp = 0; strcat(options[i],"PAL"); } else { gsGlobal->Mode = GS_MODE_NTSC; gsGlobal->Height = 448; defaulty = 50; temp = strstr(options[i],"PAL"); *temp = 0; strcat(options[i],"NTSC"); } gsGlobal->Width = 640; gsGlobal->Field = GS_FIELD; if (gsGlobal->Interlace == GS_NONINTERLACED) { gsGlobal->Height = gsGlobal->Height/2; gsGlobal->StartY = gsGlobal->StartY/2 -1 ; } gsGlobal->StartY = gsGlobal->StartY + Settings.offset_y; //if(Settings.interlace && (gsGlobal->Mode == GS_MODE_NTSC)) //gsGlobal->StartY = gsGlobal->StartY + 22; //else //gsGlobal->StartY = gsGlobal->StartY + 11; //normalize_screen(); gsKit_init_screen(gsGlobal); /* Apply settings. */ gsKit_mode_switch(gsGlobal, GS_ONESHOT); menu_x1 = gsGlobal->Width*0.25; menu_y1 = gsGlobal->Height*0.15; menu_x2 = gsGlobal->Width*0.75; menu_y2 = gsGlobal->Height*0.85+FONT_HEIGHT; text_line = menu_y1 + 4; option_changed = 1; //SetGsCrt(gsGlobal->Interlace,gsGlobal->Mode,gsGlobal->Field); break; case 1: //Interlacing Off/On Settings.interlace ^= 1; if (gsGlobal->Mode == GS_MODE_PAL) gsGlobal->Height = 512; else gsGlobal->Height = 448; if(Settings.interlace) { gsGlobal->Interlace = GS_INTERLACED; //gsGlobal->StartY = (gsGlobal->StartY-1)*2; temp = strstr(options[i],"Off"); *temp = 0; strcat(options[i],"On"); } else { gsGlobal->Interlace = GS_NONINTERLACED; gsGlobal->StartY = gsGlobal->StartY/2 + 1; gsGlobal->Height = gsGlobal->Height/2; temp = strstr(options[i],"On"); *temp = 0; strcat(options[i],"Off"); } gsGlobal->Width = 640; gsGlobal->Field = GS_FIELD; //normalize_screen(); gsKit_init_screen(gsGlobal); /* Apply settings. */ gsKit_mode_switch(gsGlobal, GS_ONESHOT); menu_x1 = gsGlobal->Width*0.25; menu_y1 = gsGlobal->Height*0.15; menu_x2 = gsGlobal->Width*0.75; menu_y2 = gsGlobal->Height*0.85+FONT_HEIGHT; text_line = menu_y1 + 4; option_changed = 1; //SetGsCrt(gsGlobal->Interlace,gsGlobal->Mode,gsGlobal->Field); break; case 2: //Emulated System Settings.emulation ^= 1; if(Settings.emulation) { temp = strstr(options[i],"NTSC"); *temp = 0; strcat(options[i],"PAL"); } else { temp = strstr(options[i],"PAL"); *temp = 0; strcat(options[i],"NTSC"); } FCEUI_SetVidSystem(Settings.emulation); option_changed = 1; break; case 3: //Center Screen while(menu_input(0,2) != 2) {} i = 0x10000; while(i--) asm("nop\nnop\nnop\nnop"); option_changed = 1; break; case 4: //Configure Save Path h = 0; //reset browser selection = 0; oldselect = -1; selected = 0; strcpy(path,"path"); //end reset browser strcpy(Settings.savepath,Browser(0,1)); printf("%s",Settings.savepath); strzncpy(options[5],Settings.savepath,38); selected_dir = 0; h = 0; selection = 0; oldselect = -1; strcpy(path,"path"); option_changed = 1; selected = 0; break; case 6: //Configure ELF Path h = 0; selection = 0; oldselect = -1; selected = 0; strcpy(path,"path"); strcpy(Settings.elfpath,Browser(1,2)); strzncpy(options[7],Settings.elfpath,38); h = 0; selection = 0; oldselect = -1; strcpy(path,"path"); option_changed = 1; selected = 0; break; case 8: //Save CNF fioMkdir("mc0:FCEUMM"); Save_Global_CNF("mc0:/FCEUMM/FCEUltra.cnf"); break; case 9: //Power Off poweroffShutdown(); if(Settings.display) power_off = 50/4; else power_off = 60/4; option_changed = 1; break; case 10: //Exit to ELF return 2; case 11: //Exit Options Menu selected = 0; 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 #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(); //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; }
int main(int argc, char *argv[]) { GSGLOBAL *gsGlobal = gsKit_init_global(); GSTEXTURE bigtex; u64 Black = GS_SETREG_RGBAQ(0x00,0x00,0x00,0x00,0x00); u64 TexCol = GS_SETREG_RGBAQ(0x80,0x80,0x80,0x80,0x00); // 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); gsKit_init_screen(gsGlobal); bigtex.Width = 640; bigtex.Height = 480; bigtex.PSM = GS_PSM_CT24; bigtex.Filter = GS_FILTER_NEAREST; // gsKit_texture_raw(gsGlobal, &bigtex, "host:bigtex.raw"); gsKit_texture_bmp(gsGlobal, &bigtex, "host:bigtex.bmp"); // gsKit_texture_jpeg(gsGlobal, &bigtex, "host:bigtex.jpg"); float x = 0.0f; float x2 = gsGlobal->Width; int shrinkx = 1; int shrinkx2 = 0; gsKit_mode_switch(gsGlobal, GS_ONESHOT); while(1) { gsKit_clear(gsGlobal, Black); gsKit_set_clamp(gsGlobal, GS_CMODE_CLAMP); gsKit_prim_sprite_striped_texture(gsGlobal, &bigtex, x, // X1 // gsKit_prim_sprite_texture(gsGlobal, &bigtex, x, // X1 0.0f, // Y2 0.0f, // U1 0.0f, // V1 x2, // X2 bigtex.Height, // Y2 bigtex.Width, // U2 bigtex.Height, // V2 2, TexCol); gsKit_queue_exec(gsGlobal); gsKit_sync_flip(gsGlobal); if(shrinkx) { if(x < 78.0f) x += 0.25f; else shrinkx = 0; } else { if(x > 0.0f) x -= 0.25f; else shrinkx = 1; } if(shrinkx2) { if(x2 < gsGlobal->Width) x2 += 0.25f; else shrinkx2 = 0; } else { if(x2 > (gsGlobal->Width - 78.0f)) x2 -= 0.25f; else shrinkx2 = 1; } } return 0; }
int main(int argc, char *argv[]) { #ifdef HIRES_MODE GSGLOBAL *gsGlobal = gsKit_hires_init_global(); #else GSGLOBAL *gsGlobal = gsKit_init_global(); #endif int iPassCount; #if 0 gsGlobal->Mode = GS_MODE_NTSC; gsGlobal->Interlace = GS_INTERLACED; //gsGlobal->Field = GS_FIELD; gsGlobal->Field = GS_FRAME; gsGlobal->Width = 704; gsGlobal->Height = 464; iXOffset = -32; iYOffset = 8; iPassCount = 2; #endif #if 0 gsGlobal->Mode = GS_MODE_PAL; gsGlobal->Interlace = GS_INTERLACED; //gsGlobal->Field = GS_FIELD; gsGlobal->Field = GS_FRAME; gsGlobal->Width = 704; gsGlobal->Height = 556; iXOffset = -10; iYOffset = 5; iPassCount = 3; #endif #if 0 gsGlobal->Mode = GS_MODE_DTV_480P; gsGlobal->Interlace = GS_NONINTERLACED; gsGlobal->Field = GS_FRAME; gsGlobal->Width = 704; gsGlobal->Height = 462; iXOffset = -4; iYOffset = 3; iPassCount = 2; #endif #if 0 gsGlobal->Mode = GS_MODE_DTV_576P; gsGlobal->Interlace = GS_NONINTERLACED; gsGlobal->Field = GS_FRAME; gsGlobal->Width = 704; gsGlobal->Height = 556; iXOffset = 0; iYOffset = 0; iPassCount = 3; #endif #if 0 gsGlobal->Mode = GS_MODE_DTV_720P; gsGlobal->Interlace = GS_NONINTERLACED; gsGlobal->Field = GS_FRAME; gsGlobal->Width = 1280; gsGlobal->Height = 720;//704; iXOffset = 0; iYOffset = 0; iPassCount = 3; #endif #if 1 gsGlobal->Mode = GS_MODE_DTV_1080I; gsGlobal->Interlace = GS_INTERLACED; //gsGlobal->Field = GS_FIELD; gsGlobal->Field = GS_FRAME; gsGlobal->Width = 1920; gsGlobal->Height = 1080; iXOffset = 0; iYOffset = 0; iPassCount = 3; #endif #if 0 gsGlobal->Mode = GS_MODE_VGA_1280_60; gsGlobal->Interlace = GS_NONINTERLACED; gsGlobal->Field = GS_FRAME; gsGlobal->Width = 1280; gsGlobal->Height = 1024; iXOffset = 0; iYOffset = 0; iPassCount = 4; #endif if ((gsGlobal->Interlace == GS_INTERLACED) && (gsGlobal->Field == GS_FRAME)) gsGlobal->Height /= 2; gsGlobal->PSM = GS_PSM_CT16S; gsGlobal->PSMZ = GS_PSMZ_16S; gsGlobal->Dithering = GS_SETTING_ON; gsGlobal->DoubleBuffering = GS_SETTING_ON; 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); #ifdef HIRES_MODE gsKit_hires_init_screen(gsGlobal, iPassCount); #else gsKit_init_screen(gsGlobal); #endif gsKit_set_display_offset(gsGlobal, iXOffset, iYOffset); render(gsGlobal); #ifdef HIRES_MODE gsKit_hires_deinit_global(gsGlobal); #else gsKit_deinit_global(gsGlobal); #endif 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; }
int main(int argc, char *argv[]) { u64 White, Black, BlackFont, WhiteFont, RedFont, GreenFont, BlueFont, BlueTrans, RedTrans, GreenTrans, WhiteTrans; GSGLOBAL *gsGlobal = gsKit_init_global(); GSFONT *gsFont = gsKit_init_font(GSKIT_FTYPE_BMP_DAT, "host:dejavu.bmp"); //GSFONT *gsFont = gsKit_init_font(GSKIT_FTYPE_PNG_DAT, "host:dejavu.png"); 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); Black = GS_SETREG_RGBAQ(0x00,0x00,0x00,0x00,0x00); White = GS_SETREG_RGBAQ(0xFF,0xFF,0xFF,0x00,0x00); WhiteFont = GS_SETREG_RGBAQ(0xFF,0xFF,0xFF,0x80,0x00); BlackFont = GS_SETREG_RGBAQ(0x00,0x00,0x00,0x80,0x00); RedFont = GS_SETREG_RGBAQ(0xFF,0x00,0x00,0x80,0x00); GreenFont = GS_SETREG_RGBAQ(0x00,0xFF,0x00,0x80,0x00); BlueFont = GS_SETREG_RGBAQ(0x00,0x00,0xFF,0x80,0x00); BlueTrans = GS_SETREG_RGBAQ(0x00,0x00,0xFF,0x40,0x00); RedTrans = GS_SETREG_RGBAQ(0xFF,0x00,0x00,0x60,0x00); GreenTrans = GS_SETREG_RGBAQ(0x00,0xFF,0x00,0x50,0x00); WhiteTrans = GS_SETREG_RGBAQ(0xFF,0xFF,0xFF,0x50,0x00); gsGlobal->PrimAlpha = GS_BLEND_FRONT2BACK; gsKit_init_screen(gsGlobal); gsKit_mode_switch(gsGlobal, GS_PERSISTENT); gsKit_font_upload(gsGlobal, gsFont); gsKit_clear(gsGlobal, Black); gsKit_font_print(gsGlobal, gsFont, 50, 50, 1, WhiteFont, "Hello World!"); gsKit_font_print(gsGlobal, gsFont, 50, 80, 1, RedFont, "red"); gsKit_font_print(gsGlobal, gsFont, 50, 110, 1, GreenFont, "green"); gsKit_font_print(gsGlobal, gsFont, 50, 140, 1, BlueFont, "blue"); gsKit_font_print_scaled(gsGlobal, gsFont, 400, 160, 2, 2.0f, BlueFont, "scaled 1\n"\ "scaled 2\n"\ "scaled 3\n"); gsKit_font_print(gsGlobal, gsFont, 100, 200, 2, WhiteFont, "Testing 1\n"\ "Testing 2\n"\ "Testing 3\n"\ "Testing 4\n"\ "Testing 5\n"\ "Testing 6\n"\ "Testing 7\n"\ "Testing 8\n"\ "Testing 9\n"\ "Testing 10\n"); while(1) { gsKit_sync_flip(gsGlobal); gsKit_queue_exec(gsGlobal); } return 0; }