gbadev.org forum archive

This is a read-only mirror of the content originally found on forum.gbadev.org (now offline), salvaged from Wayback machine copies. A new forum can be found here.

C/C++ > Variables using VisualHAM (Need Help)

#43261 - Symphony - Sat May 21, 2005 4:53 am

I have trouble with a variable in VisualHAM (using C).

Here is my code. Read the comments I made for further details

Code:

/*
 * Created by using HAM 2.8
 * Author: Symphony
*/

#include "mygba.h"


//I expect a size about 40 KByte, depending on Code.
MULTIBOOT

//The Variable has the Name: SelectState
//This one is messed up, it won't work.
//plz help me with this.
u32 SelectState=0;

//Not used yet
//void Pad_read(void);

//This is my
void SelectMenu(void);
/************************************************************
 * Program entry point
 *************************************************************/
int main(void)
{

   // Initialize HAMlib
   // Behaviour of HAMlib is undefined if you comment this out.
   ham_Init();
   // Init the Text display system on the bg of your choice
   // This function must be called if you want to use HAMlibs text display system.
   // After calling this, you can use ham_DrawText and ham_SetTextCol.
   ham_InitText(0);

   //Zeile 1 (Line 1) (unused line)
   ham_DrawText(2,2,"Type    :");
   ham_DrawText(2,3,"Name    :");
   ham_DrawText(2,4,"Level   :");
   ham_DrawText(2,5,"Gender  :");
   //Zeile 6 (Line 6)
   ham_DrawText(2,7,"Attack 1:");
   ham_DrawText(2,8,"Attack 2:");
   ham_DrawText(2,9,"Attack 3:");
   ham_DrawText(2,10,"Attack 4:");
   //Zeile 11 (Line 11)
   ham_DrawText(2,12,"Item    :");
   //Zeile 13 (Line 13)
   ham_DrawText(2,13,"Status  :");
   //Zeile 15 (Line 15)
   ham_DrawText(2,16,"Trade");

   //Debug purposal, used as Placeholder
   //for Design
   ham_DrawText(12,2,"XXXXXXXXX");


   while(1)
   {
    //If D-Down is pressed, then
    if(F_CTRLINPUT_DOWN_PRESSED)
   {
      //Draw Text on the Statusline
      ham_DrawText(12,13,"Down");
      //increase the Variable by 1
      //If this is wrong, plz fix it for me
      SelectState++;
      //Call function
      SelectMenu();
    }
    //Same as above only in opposite direction
      if(F_CTRLINPUT_UP_PRESSED)
   {
      ham_DrawText(12,13,"Up");
      //Is resetting, but there is more then 2
      //so it should decreasing instead.
      //Can you fix that for me?
      SelectState=0;
      SelectMenu();
    }
        //This is used as Embedded Debug
        //If the A Button is pressed, then..
          if(F_CTRLINPUT_A_PRESSED)
   {
       //Print the Text including the Value from the Variable
      //in the Statusline. (Not working, plz fix it for meee -.-)
      ham_DrawText(12,13," " &SelectState " ");
      //Refreshing
      SelectMenu();
    }
//A rest of code - USED LATER, NOT USED YET
//    if (SelectState == 2);
//    {
//    ham_DrawText(23,2,"  ");
//    ham_DrawText(23,3,"  ");
//    ham_DrawText(23,4,"(-");
//    }
//    Pad_read();

}
}
//THis places the cursor depending on the Value from da Variable
void SelectMenu(void)
{
    //If -Variable Value- equals 0 Then:
    if (SelectState == 0);
    {
    //Draw some text which is my Cursor
    //The Cursor is the  (-  .
    ham_DrawText(23,2,"(-");
    ham_DrawText(23,3,"  ");
    ham_DrawText(23,4,"  ");
    }
   //If -Variable Value- equals 1 Then:
    if (SelectState == 1);
    {
    ham_DrawText(23,2,"  ");
    ham_DrawText(23,3,"(-");
    ham_DrawText(23,4,"  ");
    }
}
//This was a extra function for reading the Controls
//and computing the Variable - not used now.
//void Pad_read(void)
//{

//}


/* END OF FILE */


Everything is fine, except this one little Thing...
_________________
Learning VisualHAM

#43320 - Symphony - Sat May 21, 2005 10:55 pm

Nevermind I just figured it out...

Code:

ham_DrawText(12,13,"%2x",SelectState);


It works.
_________________
Learning VisualHAM