Пример #1
0
void Ingame_Menu(void)
{
    char *temp;
    int i,selection = 0;
    oldselect = -1;
    char stateoption[16];
    strcpy(stateoption,"State number: ");

    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[14][23] = {
        { "State number: " },
        { "Save State" },
        { "Load State" },
        { "Filtering: "},
        { "LowPass: "******"Configure Input" },
        { "Rapidfire Switch: "},
        { "RapidFire P1: " },
        { "RapidFire P2: " },
        { "Reset Game" },
        { "Exit Game" },
        { "Exit Menu" },
        { "Palette:" },
        { "" }
    };

    for(i=0;i<14;i++) {
        switch(i) {
            case 0:
                sprintf(options[i],"%s%d",options[i],statenum);
                break;
            case 3:
                if(!Settings.filter)
                    sprintf(options[i],"%s%s",options[i],"Off");
                else
                    sprintf(options[i],"%s%s",options[i],"On");
                break;
            case 4:
                if(!Settings.lowpass)
                    sprintf(options[i],"%s%s",options[i],"Off");
                else
                    sprintf(options[i],"%s%s",options[i],"On");
                break;
            case 6:
                if(!Settings.turbo) {
                    sprintf(options[i],"%s%s",options[i],"Off");
                }
                else {
                    sprintf(options[i],"%s%s",options[i],"On");
                }
                break;
            case 7:
                switch(aorborab[0]) {
                    case 0:
                        sprintf(options[i],"%s%s",options[i],"Off");
                        break;
                    case 1:
                        sprintf(options[i],"%s%s",options[i],"A");
                        break;
                    case 2:
                        sprintf(options[i],"%s%s",options[i],"B");
                        break;
                    case 3:
                        sprintf(options[i],"%s%s",options[i],"AB");
                        break;
                }
                break;
            case 8:
                switch(aorborab[1]) {
                    case 0:
                        sprintf(options[i],"%s%s",options[i],"Off");
                        break;
                    case 1:
                        sprintf(options[i],"%s%s",options[i],"A");
                        break;
                    case 2:
                        sprintf(options[i],"%s%s",options[i],"B");
                        break;
                    case 3:
                        sprintf(options[i],"%s%s",options[i],"AB");
                        break;
                }
				break;
            case 13:
				sprintf(options[i],"%s%s",options[i],palette_names[Settings.current_palette - 1].name);
                break;
        }
    }

#ifdef SOUND_ON
    audsrv_stop_audio();
#endif
    gsKit_mode_switch(gsGlobal, GS_ONESHOT);
    gsGlobal->DrawOrder = GS_PER_OS;

    while(1) {
        selected = 0; //clear selected flag
        selection += menu_input(0,0);

		if(selection == 12 && oldselect == 11) { selection++; } //12 is palette
        if(selection == 12 && oldselect == 13) { selection--; }
        if(selection > 13) { selection = 0; }
        if(selection < 0) { selection = 13; }

        if(oldselect != selection || option_changed) {
            i = 0x10000;
            while(i--) asm("nop\nnop\nnop\nnop");
            gsKit_queue_reset(gsGlobal->Os_Queue);

            option_changed = 0;

            menu_primitive("Options", &MENU_TEX, menu_x1, menu_y1, menu_x2, menu_y2);

            for(i=0;i<14;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);
        }

        oldselect = selection;

        if(selected) {
            if(selected == 2) { //menu combo pressed again
                selection = 11;
            }
            i = selection;
            switch(i) {
                case 0: //State Number
                    statenum++;
                    if(statenum > 9) {statenum = 0;}
                    sprintf(options[i],"%s%d",stateoption,statenum);
                    FCEUI_SelectState(statenum);
                    option_changed = 1;
                    break;
                case 1:
                    FCEUI_SaveState(NULL);
                    SetupNESGS();
                    return;
                case 2:
                    FCEUI_LoadState(NULL);
                    SetupNESGS();
                    return;
                case 3:
                    Settings.filter ^= 1;
                    if(Settings.filter) {
                        temp = strstr(options[i],"Off");
                        *temp = 0;
                        strcat(options[i],"On");
                    }
                    else {
                        temp = strstr(options[i],"On");
                        *temp = 0;
                        strcat(options[i],"Off");
                    }
                    option_changed = 1;
                    break;
                case 4:
                    Settings.lowpass ^= 1;
                    if(Settings.lowpass) {
                        FCEUI_SetLowPass(Settings.lowpass);
                        temp = strstr(options[i],"Off");
                        *temp = 0;
                        strcat(options[i],"On");
                    }
                    else {
                        FCEUI_SetLowPass(Settings.lowpass);
                        temp = strstr(options[i],"On");
                        *temp = 0;
                        strcat(options[i],"Off");
                    }
                    option_changed = 1;
                    break;
                case 6:
                    Settings.turbo ^= 1;
                    if(Settings.turbo) {
                        temp = strstr(options[i],"Off");
                        *temp = 0;
                        strcat(options[i],"On");
                    }
                    else {
                        temp = strstr(options[i],"On");
                        *temp = 0;
                        strcat(options[i],"Off");
                    }
                    option_changed = 1;
                    break;
                case 7:
                    aorborab[0]++;
                    if(aorborab[0] > 3)
                        aorborab[0] = 0;
                    switch(aorborab[0]) {
                        case 0: //Off
                            rapidfire_a[0] = 0;
                            rapidfire_b[0] = 0;
                            temp = strstr(options[i],"AB");
                            *temp = 0;
                            strcat(options[i],"Off");
                            break;
                        case 1: //A
                            rapidfire_a[0] = 1;
                            rapidfire_b[0] = 0;
                            temp = strstr(options[i],"Off");
                            *temp = 0;
                            strcat(options[i],"A");
                            break;
                        case 2: //B
                            rapidfire_a[0] = 0;
                            rapidfire_b[0] = 1;
                            temp = strstr(options[i]," A");
                            *temp = 0;
                            strcat(options[i]," B");
                            break;
                        case 3: //AB
                            rapidfire_a[0] = 1;
                            rapidfire_b[0] = 1;
                            temp = strstr(options[i]," B");
                            *temp = 0;
                            strcat(options[i]," AB");
                            break;
                    }
                    option_changed = 1;
                    break;
                case 8:
                    aorborab[1]++;
                    if(aorborab[1] > 3)
                        aorborab[1] = 0;
                    switch(aorborab[1]) {
                        case 0: //Off
                            rapidfire_a[1] = 0;
                            rapidfire_b[1] = 0;
                            temp = strstr(options[i],"AB");
                            *temp = 0;
                            strcat(options[i],"Off");
                            break;
                        case 1: //A
                            rapidfire_a[1] = 1;
                            rapidfire_b[1] = 0;
                            temp = strstr(options[i],"Off");
                            *temp = 0;
                            strcat(options[i],"A");
                            break;
                        case 2: //B
                            rapidfire_a[1] = 0;
                            rapidfire_b[1] = 1;
                            temp = strstr(options[i]," A");
                            *temp = 0;
                            strcat(options[i]," B");
                            break;
                        case 3: //AB
                            rapidfire_a[1] = 1;
                            rapidfire_b[1] = 1;
                            temp = strstr(options[i]," B");
                            *temp = 0;
                            strcat(options[i]," AB");
                            break;
                    }
                    option_changed = 1;
                    break;
                case 9:
                    FCEUI_ResetNES();
                    SetupNESGS();
                    return;
                case 10:
                    fdsswap = 0;
                    statenum = 0;
                    exitgame = 1;
                    selected = 0;
                    return;
                case 11:
                    SetupNESGS();
                    return;
                case 13:
                    Settings.current_palette++;
                    if(Settings.current_palette > MAXPAL) {Settings.current_palette = 1;}
					sprintf(options[i],"%s",palette_names[Settings.current_palette - 1].name);
					SetupNESTexture();
					option_changed = 1;
                    break;
            }
        }
    }
}
Пример #2
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);
}
Пример #3
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;
}
Пример #4
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;
}