Homebrew Where am I going wrong?

VashTS

Beat it, son
OP
Member
Joined
Mar 14, 2009
Messages
4,308
Trophies
1
Age
40
Location
Upstate NY
XP
3,807
Country
United States
For some reason this program just loops the printed text over and over infinitely. Pressing Home works to end the program, but what am I doing wrong? I working with the codemii site to try to learn some programming for the Wii.

CODE#include
#include
#include
#include

static u32 *xfb;
static GXRModeObj *rmode;


void Initialise() {
ÂÂ
ÂÂÂÂ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 main()

{
ÂÂÂÂInitialise();
ÂÂÂÂ
ÂÂÂÂprintf("Hello World! My first Wii program.\n");
ÂÂÂÂ
ÂÂÂÂwhile(1) {
ÂÂÂÂ
ÂÂÂÂWPAD_ScanPads();
ÂÂÂÂ
ÂÂÂÂu16 buttonsDown = WPAD_ButtonsDown(0);
ÂÂÂÂif (buttonsDown & WPAD_BUTTON_A);
ÂÂÂÂ{
ÂÂÂÂÂÂÂÂprintf("You pressed button A! Good job!\n");
ÂÂÂÂ}
ÂÂÂÂ
ÂÂÂÂu16 buttonsHeld = WPAD_ButtonsHeld(0);
ÂÂÂÂif (buttonsHeld & WPAD_BUTTON_A);
ÂÂÂÂ{
ÂÂÂÂÂÂÂÂprintf("You held button A! Good job!\n");
ÂÂÂÂ}
ÂÂÂÂ
ÂÂÂÂif (buttonsHeld & WPAD_BUTTON_B);
ÂÂÂÂ{
ÂÂÂÂÂÂÂÂprintf("You held button B! Good Job!\n");
ÂÂÂÂ}
ÂÂÂÂ
ÂÂÂÂif (buttonsHeld & WPAD_BUTTON_1);
ÂÂÂÂ{
ÂÂÂÂÂÂÂÂprintf("You held button 1! Good Job!\n");
ÂÂÂÂ}
ÂÂÂÂ
ÂÂÂÂu16 buttonsUp = WPAD_ButtonsUp(0);
ÂÂÂÂif (buttonsUp & WPAD_BUTTON_A);
ÂÂÂÂ{
ÂÂÂÂÂÂÂÂprintf("You released button A! Good job!\n");
ÂÂÂÂ}
ÂÂÂÂ
ÂÂÂÂif (buttonsDown & WPAD_BUTTON_HOME)
ÂÂÂÂ{
ÂÂÂÂÂÂÂÂexit(0);
ÂÂÂÂ}
}

return 0;

}

Can anyone shed some light?
 

obcd

Well-Known Member
Member
Joined
Apr 5, 2011
Messages
1,594
Trophies
0
XP
432
Country
Belgium
I would expect the buttonsheld to trigger every loop with the most actual state of the buttons.
In that case, you will need to save that state and you should only do a print when the state of a button changes.
You also need a Video_WaitVsync(); in your while loop. It will give the cpu some idle time.

That are the 2 things that cross my mind right away, as I am not totally awake yet.
 

Site & Scene News

Popular threads in this forum

General chit-chat
Help Users
  • BakerMan @ BakerMan:
    we're cooked, possibly literally
  • BakerMan @ BakerMan:
    if you have a habitable basement, the heat shouldn't be down there and that's where you should hang out
  • Sicklyboy @ Sicklyboy:
    No, but, the air conditioner in my living room gets fuckin icy
  • Sicklyboy @ Sicklyboy:
    In a good way, not as in a "my coils are freezing" kind of way
  • K3Nv2 @ K3Nv2:
    Not everyone lives in theirs mom's basement gosh
  • BakerMan @ BakerMan:
    nah, my mom's basement is just for the weekends to check in on the family
  • BakerMan @ BakerMan:
    i usually live in your mom's basement
    +1
  • BakerMan @ BakerMan:
    saves a lot of time fr
  • Sicklyboy @ Sicklyboy:
    It's 11:30 PM here, I just took the trash out and my god is it awful outside
  • Sicklyboy @ Sicklyboy:
    This heatwave can eat my ass
    +3
  • MysticStarlight @ MysticStarlight:
    omg same, it's VERY hot here, too
  • BakerMan @ BakerMan:
    fuck this heatwave, i don't usually sleep with a fan, but i believe the fan is getting put on the bed rather than beside it
  • BakerMan @ BakerMan:
    IT'S 12:30 IN THE FUCKING MORNING AND IT'S STILL 78°, WHAT THE FUCK?
    +1
  • NinStar @ NinStar:
    78º seems abnormal for any part of the day
  • BigOnYa @ BigOnYa:
    Yea it was 96 F for the high, 78 F for the low today, in Ohio, bout same for bakerman in Michigan
  • BigOnYa @ BigOnYa:
    F- fahrenheit C-Celsius. We in USA use F as our temp ratings
  • Sicklyboy @ Sicklyboy:
    F = Freedom units
    +2
  • HiradeGirl @ HiradeGirl:
    So... C = Cum units?
    +1
  • K3Nv2 @ K3Nv2:
    Clip units
  • SylverReZ @ SylverReZ:
    @HiradeGirl, That's how they get bigger loans at the bank.
    +1
  • HiradeGirl @ HiradeGirl:
    Welp.
    HiradeGirl @ HiradeGirl: Welp.