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.

Help Wanted > Menu Maker

#102900 - jester - Sun Sep 17, 2006 8:37 pm

A Menu helper for my DS Game

#102921 - zzo38computer - Mon Sep 18, 2006 12:12 am

Here is a example of making a menu in NDS software:
Code:
void show_menu() {
   u32 i,j,k,sel;
   sel=0;

   while(1) {
      swiWaitForVBlank();
      k=keysDown();

      if(mylevel==0) printtext(7,8,(sel==0)?15:6,"Start Game");
      else printtext(7,8,(sel==0)?15:6,"Resume Game");
      if(mylevel==0) printtext(8,8,(sel==1)?15:6,"Load Game");
      else if(mylevel==1) printtext(8,8,(sel==1)?15:6,"Save Game");
      else printtext(8,8,(sel==1)?15:6,"Exit Level");
      printtext(9,8,(sel==2)?15:6,"Speed: ");
      if(maxvblanks==15) disp_sub(9,15,(sel==2)?15:6,'S');
      if(maxvblanks==7) disp_sub(9,15,(sel==2)?15:6,'M');
      if(maxvblanks==2) disp_sub(9,15,(sel==2)?15:6,'F');
      printtext(10,8,(sel==3)?15:6,"Backlight");
      printtext(11,8,(sel==4)?15:6,"Contrast: ");
      disp_sub(11,18,(sel==4)?15:6,'0'+pal_main/5);
      printtext(12,8,(sel==5)?15:6,"Sound Test");

      if(k&KEY_UP && sel>0) sel-=1;
      if(k&KEY_DOWN && sel<5) sel+=1;
      if(k&KEY_SELECT) {
         if(sel==0) return;
         if(sel==1 && mylevel>1) {
            PlaySound(SNDFX_START);
            mylevel=1;
            myhearts=oldhearts;
            myarrows=oldarrows;
            mykeys=oldkeys;
            myscore=oldscore;
            load_map();
            return;
         }
         if(sel==2) {
            if(maxvblanks==15) maxvblanks=7;
            else if(maxvblanks==7) maxvblanks=2;
            else maxvblanks=15;
         }
         if(sel==3) PlaySound(50);
         if(sel==4) {
            pal_main=(pal_main+5)%30;
            if(pal_main==0) pal_main=5;
            pal_hi=30-pal_main;
            load_palette();
         }
         if(sel==5) {
            cleartext(5,23);
            soundtest_menu();
            cleartext(5,23);
         }
      }
   }
}


Obiously this isn't what you need and you probably can't use this code exactly, but it will give you a idea how to do it
_________________
Important: Please send messages about FWNITRO to the public forum, not privately to me.

#102923 - brennan - Mon Sep 18, 2006 12:16 am

I think he's coding his game in Lua.

EDIT: In which case, I can help. Drop me an IM.
_________________
Hardware: GBAMP v2, Datel MML, NDS phat (Flashme v7)

#102978 - jester - Mon Sep 18, 2006 12:13 pm

thanks i will talk to u brennan on MSN