Пример #1
0
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;
}
Пример #2
0
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;
}
Пример #3
0
/** 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;

            }
        }
    }
}
Пример #4
0
int menu_input(int port, int center_screen)
{
    int ret[2];
    u32 paddata[2];
    u32 new_pad[2];
    u16 slot = 0;

    int change = 0;

    //check to see if pads are disconnected
    ret[port]=padGetState(0, slot);
    if((ret[port] != PAD_STATE_STABLE) && (ret[port] != PAD_STATE_FINDCTP1)) {
        if(ret[port]==PAD_STATE_DISCONN) {
            printf("Pad(%d, %d) is disconnected\n", 0, slot);
        }
        ret[port]=padGetState(0, slot);
    }
    ret[port] = padRead(0, slot, &buttons[port]); // port, slot, buttons
    if (ret[port] != 0) {
        paddata[port]= 0xffff ^ buttons[port].btns;
        new_pad[port] = paddata[port] & ~old_pad[port]; // buttons pressed AND NOT buttons previously pressed
        old_pad[port] = paddata[port];

        if(paddata[port] & PAD_LEFT && center_screen) {
            Settings.offset_x--;
            change = 1;
        }
        if(new_pad[port] & PAD_DOWN && !center_screen) {
            change = 1;
        }
        if(paddata[port] & PAD_DOWN && center_screen) {
            Settings.offset_y++;
            change = 1;
        }
        if(paddata[port] & PAD_RIGHT && center_screen) {
            Settings.offset_x++;
            change = 1;
        }
        if(new_pad[port] & PAD_UP && !center_screen) {
            change = -1;
        }
        if(paddata[port] & PAD_UP && center_screen) {
            Settings.offset_y--;
            change = 1;
        }
        if(new_pad[port] & PAD_START && center_screen) {
            change = 2;
        }
        if(new_pad[port] & PAD_SELECT && center_screen) {
            Settings.offset_x = 0;
            Settings.offset_y = 0;
            change = 1;
        }
        if(new_pad[port] & PAD_CIRCLE) {
            selected = 1;
        }
        if(new_pad[port] & PAD_CROSS) {
        }
        if((new_pad[port] == Settings.PlayerInput[port][0]) && !center_screen) {
            selected = 2;
        }
    }
    if((center_screen && change) || (center_screen == 2)) {
        gsGlobal->StartX = defaultx + Settings.offset_x;
        gsGlobal->StartY = defaulty + Settings.offset_y;

        normalize_screen();

        gsKit_clear(gsGlobal,GS_SETREG_RGBAQ(0x00,0x00,0x00,0x00,0x00));

        menu_primitive("Centering", &BG_TEX, 0, 0, gsGlobal->Width, gsGlobal->Height);

        DrawScreen(gsGlobal);

        center_screen = 1;
    }
  return change;
}
Пример #5
0
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;
}
Пример #6
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;
}
Пример #7
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;
}
Пример #8
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;
}
Пример #9
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);
}
Пример #10
0
void clear_screen()
{
	gsKit_clear(gsGlobal, White);
}
Пример #11
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;
}
Пример #12
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;
}