Пример #1
0
Файл: main.c Проект: clbr/SGDK
static void vintEvent()
{
    u16 i;
    u16 in, out;
    char strNum[8];
    char str[40];

    // set BUS protection for XGM driver
    if (driver->id == Z80_DRIVER_XGM)
        SND_set68KBUSProtection_XGM(TRUE);

    in = GET_VCOUNTER;

    if ((in >= 224) && (in <= 230))
    {
        switch(dmaMethod)
        {
        case 1:
            VDP_doDMAEx(VDP_DMA_VRAM, 0, 0x8000, (6 * 1024) / 2, 2);
            break;

        case 2:
            for(i = 0; i < 4; i++)
            {
                VDP_doDMAEx(VDP_DMA_VRAM, 0, 0x8000, 1024 / 2, 2);
                waitSubTick(0);
            }
            break;

        case 3:
            for(i = 0; i < 8; i++)
            {
                VDP_doDMAEx(VDP_DMA_VRAM, 0, 0x8000, 256 / 2, 2);
                waitSubTick(0);
            }
            break;
        }
    }

    out = GET_VCOUNTER;

    if (driver->id == Z80_DRIVER_XGM)
    {
        u16 load;

        // remove BUS protection for XGM driver
        SND_set68KBUSProtection_XGM(FALSE);

        // get Z80 cpu estimated load
        load = SND_getCPULoad_XGM();

        uintToStr(load, str, 3);
        strcat(str, " %");
        VDP_clearText(16, 21, 10);
        VDP_drawText(str, 16, 21);

//        {
//            u8 debugValues[12];
//
//            getZ80Debug(debugValues);
//
//            strcpy(str, "4 PCM mixing: ");
//
//            uintToStr(debugValues[0], strNum, 3);
//            strcat(str, strNum);
//            strcat(str, " ");
//            uintToStr(debugValues[4], strNum, 3);
//            strcat(str, strNum);
//
//            VDP_drawText(str, 1, 22);
//
//            strcpy(str, "XGM prep & parse: ");
//
//            uintToStr(debugValues[5], strNum, 3);
//            strcat(str, strNum);
//            strcat(str, " ");
//            uintToStr(debugValues[6], strNum, 3);
//            strcat(str, strNum);
//            strcat(str, " ");
//            uintToStr(debugValues[7], strNum, 3);
//            strcat(str, strNum);
//
//            VDP_drawText(str, 1, 23);
//
//            strcpy(str, "Ext com & sync: ");
//
//            strcat(str, strNum);
//            strcat(str, " ");
//            uintToStr(debugValues[8], strNum, 3);
//            strcat(str, strNum);
//            strcat(str, " ");
//            uintToStr(debugValues[9], strNum, 3);
//            strcat(str, strNum);
//
//            VDP_drawText(str, 1, 24);
//        }
    }
    else
    {
        VDP_clearTextLine(22);
        VDP_clearTextLine(23);
        VDP_clearTextLine(24);
    }

    if ((in >= 224) && (in <= 230))
    {
        switch(dmaMethod)
        {
        case 0:
            VDP_drawText("NONE    ", 13, 26);
            break;

        case 1:
            VDP_drawText("1 x 6KB ", 13, 26);
            break;

        case 2:
            VDP_drawText("4 x 1KB ", 13, 26);
            break;

        case 3:
            VDP_drawText("8 x 256B", 13, 26);
            break;
        }
    }
    else
        VDP_drawText("NOT DONE", 13, 26);

    if (dmaMethod)
    {
        strcpy(str, "DMA start at ");
        uintToStr(in, strNum, 3);
        strcat(str, strNum);
        strcat(str, " - end at ");
        uintToStr(out, strNum, 3);
        strcat(str, strNum);

        VDP_drawText(str, 1, 27);
    }
    else
        VDP_clearTextLine(27);
}
Пример #2
0
//Handles the Options menu selections
void BtnOptions(u16 joy, u16 changed, u16 state)
{
    u8 Vert=_FALSE;     //Flag if vert menu item was changed
    u8 Horiz=_FALSE;    //~       horiz ~
    char val[2];        //String holding Sound/Music test ID
    char name[25];      //String ~       Name of the sfx/music
    u8 i=0;             //Generic counter var
    u8 pal=2;           //Active palette to use (OBJPAL or PWRPAL)

    if (joy == JOY_1)
    {
        //If up pressed
        if (state & BUTTON_UP)
        {
            echo_play_sfx(SFX_01);  //HiLite
            HItem--;                //Decrement HItem, wrap if needed
            if (HItem<=MMin)
            {
                HItem=MMax-1;
            }
            //Set vert/horiz as changed
            Vert=PTRUE;
            Horiz=PTRUE;
        }
        //if up released
        else if (changed & BUTTON_UP)
        {
            //Set vert/horiz as unchanged
            Vert=_FALSE;
            Horiz=_FALSE;
        }

        //If down pressed
        if (state & BUTTON_DOWN)
        {
            echo_play_sfx(SFX_01);  //HiLite sfx
            HItem++;                //Increment
            if (HItem>=MMax)
            {
                HItem=MMin+1;
            }
            Vert=PTRUE;
            Horiz=PTRUE;
        }
        else if (changed & BUTTON_RIGHT)
        {
            Vert=_FALSE;
            Horiz=_FALSE;
        }

        //if left pressed
        if (state & BUTTON_LEFT)
        {
            //Process each for HItem row
            if (HItem==1)
            {
                //Decrement Opts[1], wrap if necessary
                Opts[1]--;
                if (Opts[1]==255)
                {
                    Opts[1]=2;
                }
            }

            //Toggle bool (!bool)
            if ((HItem>=2) && (HItem<=4))
            {
                if (Opts[HItem]==_FALSE)
                {
                    Opts[HItem]=PTRUE;
                }
                else
                {
                    Opts[HItem]=_FALSE;
                }

                //If toggling music
                if (HItem==3)
                {
                    //If false, stop BGM; else play Nes_Mes2 again
                    if (Opts[HItem]==_FALSE)
                    {
                        echo_stop_bgm();
                    }
                    else
                    {
                        echo_play_bgm(BGM_03);
                    }
                }
            }

            //If Sound test
            if (HItem==6)
            {
                //Decremenet S_ID, wrap if necessary
                S_ID--;
                if (S_ID<0)
                {
                    S_ID=S_Max;
                }
            }

            //If music test, decrement M_ID, wrap if necessary
            if (HItem==5)
            {
                M_ID--;
                if (M_ID<0)
                {
                    M_ID=M_Max;
                }
            }

            echo_play_sfx(SFX_02);  //Select
            Horiz=PTRUE;            //Flag horiz as changed
        }
        //If released
        else if (changed & BUTTON_LEFT)
        {
            Horiz=_FALSE;   //Unflag Horiz
        }

        //If right pressed
        if (state & BUTTON_RIGHT)
        {
            //Process each HItem row
            //Difficulty, increment, wrap as necessary
            if (HItem==1)
            {
                Opts[1]++;
                if (Opts[1]>2)
                {
                    Opts[1]=_FALSE;
                }
            }

            //Toggle bools (!bool)
            if ((HItem>=2) && (HItem<=4))
            {
                if (Opts[HItem]==_FALSE)
                {
                    Opts[HItem]=PTRUE;
                }
                else
                {
                    Opts[HItem]=_FALSE;
                }

                //If toggling music, stop bgm if false; else play Nes_Mes2
                if (HItem==3)
                {
                    if (Opts[HItem]==_FALSE)
                    {
                        echo_stop_bgm();
                    }
                    else
                    {
                        echo_play_bgm(BGM_03);
                    }
                }
            }

            //If Sound test, increment S_ID, wrap if necessary
            if (HItem==6)
            {
                S_ID++;
                if (S_ID>S_Max)
                {
                    S_ID=0;
                }
            }

            //If Music test, increment M_ID, wrap if necessary
            if (HItem==5)
            {
                M_ID++;
                if (M_ID>M_Max)
                {
                    M_ID=0;
                }
            }

            echo_play_sfx(SFX_02);  //Select sfx
            Horiz=PTRUE;            //Flag Horiz as changed
        }
        //if released, unflag horiz
        else if (changed & BUTTON_RIGHT)
        {
            Horiz=_FALSE;
        }


        //If A button pressed
        if (state & BUTTON_A)
        {
            //If Sound test, play the selected S_ID
            if (HItem==6)
            {
                echo_play_sfx(Sounds[S_ID]);
            }

            //if Music test, play the selected M_ID
            if (HItem==5)
            {
                echo_play_bgm(Songs[M_ID]);
            }
        }

        //If Start button pressed
        if (state & BUTTON_START)
        {
            echo_play_sfx(SFX_03);  //Play hockey deflect sfx
            SItem=1;                //Select item
        }

        //If vert changed
        if (Vert==PTRUE)
        {
            //Clear text rows
            for (i=10;i<=16;i++)
            {
                VDP_clearText(5, i, 1);
            }

            //Set to PWRPAL
            VDP_setTextPalette(PWRPAL);
            VDP_drawText(">",5,HItem+10);   //Disp hilighted row
        }

        //If Horiz changed
        if (Horiz==PTRUE)
        {
            //Get/set appropriate palette
            if (HItem==1){pal=PWRPAL;}else{pal=OBJPAL;}
            VDP_setTextPalette(pal);

            //Draw difficulty text and selected difficulty
            VDP_drawText("Difficulty:",6,11);
            VDP_drawText("      ",20,11);
            switch(Opts[1])
            {
                case 0:
                    VDP_drawText("Easy",20,11);
                    break;
                case 1:
                    VDP_drawText("Medium",20,11);
                    break;
                case 2:
                    VDP_drawText("Hard",20,11);
                    break;
            }

            //Get/set palettes, show lables for powerups, music, and sound toggles
            if (HItem==2){pal=PWRPAL;}else{pal=OBJPAL;}
            VDP_setTextPalette(pal);
            VDP_drawText("Powerups",6,12);

            if (HItem==3){pal=PWRPAL;}else{pal=OBJPAL;}
            VDP_setTextPalette(pal);
            VDP_drawText("Music:",6,13);

            if (HItem==4){pal=PWRPAL;}else{pal=OBJPAL;}
            VDP_setTextPalette(pal);
            VDP_drawText("Sfx:",6,14);

            //Show selected boolean states for them, with appropriate palette
            for (i=2;i<=4;i++)
            {
                if (HItem==i){pal=PWRPAL;}else{pal=OBJPAL;}
                VDP_setTextPalette(pal);
                if (Opts[i]==_FALSE)
                {
                    VDP_drawText("OFF",20,10+i);
                }
                else
                {
                    VDP_drawText("ON ",20,10+i);
                }
            }

            //Ditto for Music test
            if (HItem==5){pal=PWRPAL;}else{pal=OBJPAL;}
            VDP_setTextPalette(pal);
            VDP_drawText("Music test:",6,15);
            VDP_drawText("  ",20,15);
            intToStr(M_ID,val,1);       //Convert M_ID to string
            VDP_drawText(val,20,15);    //Display it

            //Ditto for Sound test
            if (HItem==6){pal=PWRPAL;}else{pal=OBJPAL;}
            VDP_setTextPalette(pal);
            VDP_drawText("Sound test:",6,16);
            VDP_drawText("  ",20,16);
            intToStr(S_ID,val,1);
            VDP_drawText(val,20,16);

            //If Sound/music test
            if ((HItem==5)||(HItem==6))
            {
                //Fetch and show the music/sound name
                VDP_setTextPalette(PWRPAL);
                if (HItem==5)
                {
                    VDP_drawText("Song title: ",6,18);
                    VDP_drawText("                                  ",6,19);
                    VDP_drawText(Song_Names[M_ID],6,19);//@Get song title here
                }
                else
                {
                    VDP_drawText("Sound title:",6,18);
                    VDP_drawText("                                  ",6,19);
                    VDP_drawText(Sound_Names[S_ID],6,19);//Get sfx title here
                }
            }
            else
            {
                //If neither, clear the lines
                VDP_drawText("                                  ",6,18);
                VDP_drawText("                                  ",6,19);
            }
        }
    }
}
Пример #3
0
static void drawText(char *text, u16 x, u16 y, u16 c, u16 w){
	VDP_clearText(x+c, y, w);
	VDP_drawText(text, x, y);
}