GuitarDemo/source
Jump to navigation
Jump to search
Source code for v0.2
#include <stdio.h>
#include <stdlib.h>
#include <gccore.h>
#include <wiiuse/wpad.h>
#include <wiiuse/wiiuse.h>
static void *xfb = NULL;
static GXRModeObj *rmode = NULL;
int main(int argc, char **argv) {
VIDEO_Init();
WPAD_Init();
rmode = VIDEO_GetPreferredMode(NULL);
xfb = MEM_K0_TO_K1(SYS_AllocateFramebuffer(rmode));
console_init(xfb,20,20,rmode->fbWidth,rmode->xfbHeight,rmode->fbWidth*VI_DISPLAY_PIX_SZ);
VIDEO_Configure(rmode);
VIDEO_SetNextFramebuffer(xfb);
VIDEO_SetBlack(FALSE);
VIDEO_Flush();
VIDEO_WaitVSync();
if(rmode->viTVMode&VI_NON_INTERLACE) VIDEO_WaitVSync();
int nl = 0;
int nt = 1;
int ot = 1;
while(1) {
ot = nt;nt = 1;
WPAD_ScanPads();
u32 held = WPAD_ButtonsHeld(0);
u32 down = WPAD_ButtonsDown(0);
if((down & WPAD_GUITAR_HERO_3_BUTTON_STRUM_DOWN) || (down & WPAD_GUITAR_HERO_3_BUTTON_STRUM_UP)) // If the Strum is Played
{
printf("\n Played: ");
if (held & WPAD_GUITAR_HERO_3_BUTTON_GREEN) // If there is a button held down, and green is.
{
printf("Green ");
nt = nt*2;
}
if (held & WPAD_GUITAR_HERO_3_BUTTON_RED) // If there is a button held down, and red is.
{
printf("Red ");
nt = nt*3;
}
if (held & WPAD_GUITAR_HERO_3_BUTTON_YELLOW) // If there is a button held down and yellow is.
{
printf("Yellow ");
nt = nt*4;
}
if (held & WPAD_GUITAR_HERO_3_BUTTON_BLUE) // If there is a button held down and blue is.
{
printf("Blue ");
nt = nt*5;
}
if (held & WPAD_GUITAR_HERO_3_BUTTON_ORANGE) // If there is a button held down and orange is.
{
printf("Orange ");
nt = nt*7;
}
} else {
if (ot == nt && nt != 1 && nl != 0) { nl = 1;printf("."); } // If the buttons haven't changed since they were held down.
else if (nl == 1) { nl = 0; }
}
VIDEO_WaitVSync();
}
return 0;
}