/*
 *  Copyright (C) 2008 Nuke (wiinuke@gmail.com)
 *
 *  this file is part of GeckoOS for USB Gecko
 *  http://www.usbgecko.com
 *
 *  This program is free software; you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation; either version 2 of the License, or
 *  (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program; if not, write to the Free Software
 *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */

// This menu code is pretty shit, i wrote it very quickly, and just for speed.
// Would really like for someone to help out to write a decent menu
// Progress bar isn't threaded etc


#include <malloc.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <gccore.h>
#include <wiiuse/wpad.h>
#include <ogcsys.h>
#include <sys/unistd.h>
#include "geckomenu.h"
#include "font.h"
#include "apploader.h"
#include "patchcode.h"
#include "geckogreen.h"
#include "geckogrey.h"
#include "tools.h"
#include "identify.h"

#define fontheight 24
#define innermenu_start 20
#define innermenu_end 298
#define screenwidth 320
#define progtotal 132

u32 barstate;
u32 skipvalue = 0;

char textbuffer[255];

char languages[11][22] = 
{{"Console Default"},
{"Japanese"},
{"English"},
{"German"},
{"French"},
{"Spanish"},
{"Italian"},
{"Dutch"},
{"S. Chinese"},
{"T. Chinese"},
{"Korean"}};

char pal60_options[2][6] = 
{{"NO"},
{"YES"}};

char pal50_options[2][6] = 
{{"NO"},
{"YES"}};

char vi_options[2][6] = 
{{"NO"},
{"YES"}};

char ocarina_options[2][6] = 
{{"NO"},
{"YES"}};

char ntsc_options[2][6] = 
{{"NO"},
{"YES"}};

char hook_options[3][13] = 
{{"VI (Default)"},
{"Wii Pad"},
{"GC Pad"}};

char recovery_options[2][6] = 
{{"NO"},
{"YES"}};

char regionfree_options[2][6] = 
{{"NO"},
{"YES"}};

char nocopy_options[2][6] = 
{{"NO"},
{"YES"}};

char buttonskip_options[2][6] = 
{{"NO"},
{"YES"}};

extern u32 *xfb;
extern const unsigned char kenobiwii[];
extern const int kenobiwii_size;
extern s32 __SYS_LoadMenu();


u32 currentmenu = ROOTMENU;	// 0 ROOT
u32 rootmenu_item = 0;
u32 menufreeze = 0;
u32 langselect = 0;
u32 langsaved = 0;
u32 pal60select = 0;
u32 pal50select = 0;
u32 viselect = 0;
u32 ntscselect = 0;
u32 hookselect = 2;
u32 recoveryselect = 0;
u32 ocarinaselect = 0;	// Off as default
u32 regionfreeselect = -1;
u32 nocopyselect = 0;
u32 buttonskipselect = -1;

static void _plotpixel(u32 *framebuffer, u16 x, u16 y, u32 color)
{
	framebuffer[320*y+x] = color;
}

static void _drawline(u16 x1, u16 x2, u16 y1, u16 y2,u32 color)
{
	 short int dx, dy, sdx, sdy, x, y, px, py;

 x = 0;
 y = 0;
 dx = x2 - x1;
 dy = y2 - y1;
 sdx = (dx < 0) ? -1 : 1;
 sdy = (dy < 0) ? -1 : 1;
 dx = sdx * dx + 1;
 dy = sdy * dy + 1;
 px = x1;
 py = y1;

 if (dx >= dy){
	for (x = 0; x < dx; x++)
	{
		_plotpixel(xfb,px,py,color);
        y += dy;
        if (y >= dx)
		{
			y -= dx;
            py += sdy;
        }
        
		px += sdx;
	}
 }
 else {
    for (y = 0; y < dy; y++)
    {
       _plotpixel(xfb,px,py,color);
       x += dx;
       if (x >= dy)
       {
			x -= dy;
            px += sdx;
       }
       py += sdy;
     }
 }
}

static void _drawprogbox()
{
		// Top Line
	_drawline(80, 220, 200, 200,0x44B54451);
	_drawline(80, 220, 201, 201,0x44B54451);
	_drawline(80, 220, 202, 202,0x44B54451);
	_drawline(80, 220, 203, 203,0x44B54451);
	_drawline(80, 220, 204, 204,0x44B54451);
	
	// Left
	_drawline(80, 80, 200, 224,0x44B54451);
	_drawline(81, 81, 200, 224,0x44B54451);
	_drawline(82, 82, 200, 224,0x44B54451);

	// Right
	_drawline(220, 220, 200, 224,0x44B54451);
	_drawline(219, 219, 200, 224,0x44B54451);
	_drawline(218, 218, 200, 224,0x44B54451);

	// Right
	_drawline(80, 220, 200, 200,0x44B54451);
	_drawline(80, 220, 201, 201,0x44B54451);
	_drawline(80, 220, 202, 202,0x44B54451);
	_drawline(80, 220, 203, 203,0x44B54451);
	_drawline(80, 220, 204, 204,0x44B54451);

	// Bottom Line
	_drawline(80, 220, 220, 220,0x44B54451);
	_drawline(80, 220, 221, 221,0x44B54451);
	_drawline(80, 220, 222, 222,0x44B54451);
	_drawline(80, 220, 223, 223,0x44B54451);
	_drawline(80, 220, 224, 224,0x44B54451);
}

u32 doprogress(u32 progstate, u32 noelements)
{
	
	int xstart = 83;
	int	i;
	u32 remainder;
	u32 padding = 0;

	// calculate remaider if less than 133
	remainder = noelements / 135;

	if(remainder == 0){
		padding  = 135 - noelements;
	}

	// going to go over the bar max size so need a skip value which is the divider
	if(progstate == 0 && remainder > 0){
		skipvalue = remainder;
		
	}
			
	if(progstate == 0){
		barstate = 0;
		_drawprogbox();
	}

	// Running
	if(progstate == 1){
		if(!remainder){	// Less than 133
			if(barstate < noelements){
				_drawline(xstart+barstate, xstart+barstate, 206, 218,COLOR_WHITE);
				barstate++;
				return 1;
			}
		}
			
		if(remainder > 0 && skipvalue == 0){	// Higher than 133
			_drawline(xstart+barstate, xstart+barstate, 206, 218,COLOR_WHITE);
			skipvalue = remainder; // reset skip counter
			barstate++;
			return 1;
		}
		else{
			skipvalue = skipvalue - 1;
		}
	}
	// Remainder padding
	if(progstate == 2){
		if(barstate < 135){
			for(i=barstate;i<135;i++){
				_drawline(xstart+barstate, xstart+barstate, 206, 218,COLOR_WHITE);
				barstate++;
			}
			return 1;
		}
	}
	return 1;
}

void drawicon(u32 *framebuffer, u16 xscreen, u16 yscreen, u16 width, u16 height, u32 gicon)
{
	
	u16 x = 0;
	u16 y = 0;
	u32 i = 0;
	u32 colorgreen = 0;
	u32 colorgrey = 0;

	for(y = yscreen; y < yscreen+height; y++)
	{
		for(x = xscreen; x < xscreen+width; x++)
		{
			if(gicon){	// high green, grey low
				colorgreen = be32(geckogreen+i);
				_plotpixel(framebuffer, x, y, colorgreen);
			}
			else {
				colorgrey = be32(geckogrey+i);
				_plotpixel(framebuffer, x, y, colorgrey);
			}
			
			i += 4;
		}
	}
}


void clearscreen(u32 *framebuffer, u16 xscreen, u16 yscreen, u16 width, u16 height, u32 color)
{
	
	u16 x;
	u16 y;

	for(y = yscreen; y < yscreen+height; y++)
	{
		for(x = xscreen; x < xscreen+width; x++)
		{
			_plotpixel(framebuffer, x, y, color);
		}
	}
}

/* All wii remote joypad handling and menu processing */
void processwpad()
{

	WPAD_ScanPads();
	u32 pressed = WPAD_ButtonsDown(0);

	PAD_ScanPads();
	u32 pressedGC = PAD_ButtonsDown(0);

	VIDEO_WaitVSync();	 
	if(pressed & WPAD_BUTTON_B){
		boot_menu();
	}

	/* Root menu actions */
	if((pressed & WPAD_BUTTON_A && currentmenu == ROOTMENU) || (pressedGC & PAD_BUTTON_A && currentmenu == ROOTMENU))
	{
		if (rootmenu_item == 0){
			clearscreen(xfb, 20, 80, 278, 315, 0x00800080);
			write_font(185, 154, "Launching Game");
			hooktype = 1;
			memset((void*)0x80001800,0,kenobiwii_size);
			memcpy((void*)0x80001800,kenobiwii,kenobiwii_size); 
			DCFlushRange((void*)0x80001800,kenobiwii_size);
			//	checkmusicloaded();
			switch(langselect)
				{
					case 0: 
						write_font(185, 178, "Lang: Default");
						configbytes[0] = 0xCD;
					break;

					case 1: 
						write_font(185, 178, "Lang: Japanese");
						configbytes[0] = 0x00;
					break;

					case 2: 
						write_font(185, 178, "Lang: English");
						configbytes[0] = 0x01;
					break;

					case 3: 
						write_font(185, 178, "Lang: German");
						configbytes[0] = 0x02;
					break;

					case 4: 
						write_font(185, 178, "Lang: French");
						configbytes[0] = 0x03;
					break;

					case 5: 
						write_font(185, 178, "Lang: Spanish");
						configbytes[0] = 0x04;
					break;

					case 6: 
						write_font(185, 178, "Lang: Italian");
						configbytes[0] = 0x05;
					break;

					case 7: 
						write_font(185, 178, "Lang: Dutch");
						configbytes[0] = 0x06;
					break;

					case 8: 
						write_font(185, 178, "Lang: S. Chinese");
						configbytes[0] = 0x07;
					break;

					case 9: 
						write_font(185, 178, "Lang: T. Chinese");
						configbytes[0] = 0x08;
					break;

					case 10: 
						write_font(185, 178, "Lang: Korean");
						configbytes[0] = 0x09;
					break;
				}
			
			/* load configbytes[1] with correct bytes before apploader */
			if(pal60select == 0 && ntscselect == 0 && viselect == 0 && pal50select == 0){ // 0x00 (apply no patches)
				configbytes[1] = 0x00;
			}

			if(pal60select == 1){					// 0x01 (Force PAL60)
				configbytes[1] = 0x01;
			}

			if(viselect == 1){						// 0x02 (Apply VIDTV patch)
				configbytes[1] = 0x02;
			}

			if(pal60select == 1 && viselect == 1){	// 0x03 (Force PAL60 & VIDTV Patch)
				configbytes[1] = 0x03;
			}

			if(ntscselect == 1){					// 0x04 (Force NTSC)
				configbytes[1] = 0x04;
			}

			if(ntscselect == 1 && viselect == 1){	// 0x05 (Force NTSC & VIDTV Patch)
				configbytes[1] = 0x05;
			}

			if(pal50select == 1){					// 0x04 (Force PAL50)
				configbytes[1] = 0x06;
			}

			if(pal50select == 1 && viselect == 1){	// 0x03 (Force PAL50 & VIDTV Patch)
				configbytes[1] = 0x07;
			}

			switch(hookselect)
			{
				case 0:
					hooktype = 1;
				break;

				case 1:
					hooktype = 2;
				break;

				case 2:
					hooktype = 3;
				break;

			}
			nowiird = 1;
			apploader();
			sleep(2);
		}

		if (rootmenu_item == 1){
			currentmenu = CONFIGMENU;
			rootmenu_item = 0;
		}

		if (rootmenu_item == 2){
			currentmenu = REBOOTMENU;
			rootmenu_item = 0;
		}

		if (rootmenu_item == 3){
			currentmenu = ABOUTMENU;
			rootmenu_item = 0;
		}

		if (rootmenu_item == 4){
			STM_RebootSystem();
		}
	}

	/* About menu actions */
	if((pressed & WPAD_BUTTON_A && currentmenu == ABOUTMENU) || (pressedGC & PAD_BUTTON_A && currentmenu == ABOUTMENU))
	{
		if (rootmenu_item == 3){
			menufreeze = 0;
			rootmenu_item = 0;
			currentmenu = ROOTMENU;
		}
		else {
			menufreeze = 1;
			rootmenu_item = 3;
		}
		
	}

	/* Config menu actions */
	if((pressed & WPAD_BUTTON_A && currentmenu == CONFIGMENU) || (pressedGC & PAD_BUTTON_A && currentmenu == CONFIGMENU))
	{
		/* Return */
		if(rootmenu_item == 8){
			rootmenu_item = 0;
			currentmenu = ROOTMENU;
			/* check if both ntsc and pal60 modes are forced */
			if((pal60select == 1 && ntscselect == 1) || (pal50select == 1 && ntscselect == 1) || (pal50select == 1 && pal60select == 1)){
				clearscreen(xfb, 20, 80, 278, 315, 0x00800080);
				write_font(130, 154, "Can't Force Two Video Modes");
				sleep(1);
				currentmenu = CONFIGMENU;
			}
		}
		
	}

	/* Config Right*/
	if((pressed & WPAD_BUTTON_RIGHT && currentmenu == CONFIGMENU) || (pressedGC & PAD_BUTTON_RIGHT && currentmenu == CONFIGMENU))
	{
		/* language */
		if(rootmenu_item == 0){
			if(langselect == 10){
				langselect = 10;
			}
			else {
				langselect += 1;
			}	
		}
		/* pal60 */
		if(rootmenu_item == 1){
			if(pal60select == 1){
				pal60select = 1;
			}
			else {
				pal60select += 1;
			}	
		}

		/* force ntsc patch */
		if(rootmenu_item == 2){
			if(ntscselect == 1){
				ntscselect = 1;
			}
			else {
				ntscselect += 1;
			}	
		}
		/* Pal50 patch */
		if(rootmenu_item == 3){
			if(pal50select == 1){
				pal50select = 1;
			}
			else {
				pal50select += 1;
			}	
		}

		/* VI patch */
		if(rootmenu_item == 4){
			if(viselect == 1){
				viselect = 1;
			}
			else {
				viselect += 1;
			}	
		}
		/* Hooks */
		if(rootmenu_item == 5){
			if(hookselect == 2){
				hookselect = 2;
			}
			else {
				hookselect += 1;
			}	
		}
		/* Ocarina */
		if(rootmenu_item == 6){
			if(ocarinaselect == 1){
				ocarinaselect = 1;
			}
			else {
				ocarinaselect += 1;
			}	
		}

		
	}

	/* Config Left*/
	if((pressed & WPAD_BUTTON_LEFT && currentmenu == CONFIGMENU) || (pressedGC & PAD_BUTTON_LEFT && currentmenu == CONFIGMENU))
	{
		if(rootmenu_item == 0){
			if(langselect == 0){
				langselect = 0;
			}
			else {
				langselect -= 1;
			}	
		}

		if(rootmenu_item == 1){
			if(pal60select == 0){
				pal60select = 0;
			}
			else {
				pal60select -= 1;
			}	
		}

		/* force ntsc patch */
		if(rootmenu_item == 2){
			if(ntscselect == 0){
				ntscselect = 0;
			}
			else {
				ntscselect -= 1;
			}	
		}

		if(rootmenu_item == 3){
			if(pal50select == 0){
				pal50select = 0;
			}
			else {
				pal50select -= 1;
			}	
		}

		if(rootmenu_item == 4){
			if(viselect == 0){
				viselect = 0;
			}
			else {
				viselect -= 1;
			}	
		}

		if(rootmenu_item == 5){
			if(hookselect == 0){
				hookselect = 0;
			}
			else {
				hookselect -= 1;
			}	
		}

			/* Ocarina */
		if(rootmenu_item == 6){
			if(ocarinaselect == 0){
				ocarinaselect = 0;
			}
			else {
				ocarinaselect -= 1;
			}	
		}
	}

	/* REBOOT menu actions */
	if((pressed & WPAD_BUTTON_A && currentmenu == REBOOTMENU) || (pressedGC & PAD_BUTTON_A && currentmenu == REBOOTMENU))
	{
	
		if(rootmenu_item == 5){
			rootmenu_item = 0;
			currentmenu = ROOTMENU;
			/* check if both ntsc and pal60 modes are forced */
		//	if((pal60select == 1 && ntscselect == 1) || (pal50select == 1 && ntscselect == 1) || (pal50select == 1 && pal60select == 1)){
		//		clearscreen(xfb, 20, 80, 278, 315, 0x00800080);
		//		write_font(130, 154, "Can't Force Two Video Modes");
		//		sleep(1);
		//		currentmenu = CONFIGMENU;
		//	}
		}
	}
	
	/* REBOOT menu left */
	if((pressed & WPAD_BUTTON_LEFT && currentmenu == REBOOTMENU) || (pressedGC & PAD_BUTTON_LEFT && currentmenu == REBOOTMENU))
	{
		// Recovery
		if(rootmenu_item == 0){
			if(recoveryselect == 0){
				recoveryselect = 0;
			}
			else {
				recoveryselect -= 1;
			}	
		}

		if(rootmenu_item == 1){
			if(regionfreeselect == 0){
				regionfreeselect = 0;
			}
			else {
				regionfreeselect -= 1;
			}	
		}

		if(rootmenu_item == 2){
			if(nocopyselect == 0){
				nocopyselect = 0;
			}
			else {
				nocopyselect -= 1;
			}	
		}

		if(rootmenu_item == 3){
			if(buttonskipselect == 0){
				buttonskipselect = 0;
			}
			else {
				buttonskipselect -= 1;
			}	
		}
	}

	/* REBOOT menu right */
	if((pressed & WPAD_BUTTON_RIGHT && currentmenu == REBOOTMENU) || (pressedGC & PAD_BUTTON_RIGHT && currentmenu == REBOOTMENU))
	{
		// recovery
		if(rootmenu_item == 0){
			if(recoveryselect == 1){
				recoveryselect = 1;
			}
			else {
				recoveryselect += 1;
			}	
		}

		// region free
		if(rootmenu_item == 1){
			if(regionfreeselect == 1){
				regionfreeselect = 1;
			}
			else {
				regionfreeselect += 1;
			}	
		}

		// Auto boot
		if(rootmenu_item == 2){
			if(nocopyselect == 1){
				nocopyselect = 1;
			}
			else {
				nocopyselect += 1;
			}	
		}

		// buttonskip
		if(rootmenu_item == 3){
			if(buttonskipselect == 1){
				buttonskipselect = 1;
			}
			else {
				buttonskipselect += 1;
			}	
		}
	}

	/* Wiimote Pad UP */
	if((pressed & WPAD_BUTTON_UP && menufreeze == 0) || (pressedGC & PAD_BUTTON_UP && menufreeze == 0))
	{
		if(rootmenu_item == 0){
			rootmenu_item = 0;
		}
		else {
			rootmenu_item -= 1;
		}
		/* skips blank line */
		if(rootmenu_item == 7 && currentmenu == CONFIGMENU){
			rootmenu_item = 6;
		}
		/* skips blank line */
		if(rootmenu_item == 4 && currentmenu == REBOOTMENU){
			rootmenu_item = 3;
		}
	}

	/* Wiimote Pad Down */
	if((pressed & WPAD_BUTTON_DOWN && menufreeze == 0) || (pressedGC & PAD_BUTTON_DOWN && menufreeze == 0))
	{
		
		if(currentmenu == CONFIGMENU){
		
			switch(rootmenu_item)
			{
				case 6: 
					rootmenu_item = 8;
					goto out;
				break;
				
				case 8: 
					goto out;
				break;

			}		
		}
		else if(currentmenu == ROOTMENU){
			if(rootmenu_item == 4){
				goto out;
			}
		}
		else if(currentmenu == REBOOTMENU){
			switch(rootmenu_item)
			{
				case 3: 
					rootmenu_item = 5;
					goto out;
				break;
				
				case 5: 
					goto out;
				break;

			}		
		}

		rootmenu_item += 1;
	}
out:
	clearscreen(xfb, 20, 80, 278, 315, 0x00800080);

	if(currentmenu == CONFIGMENU){
		memset(textbuffer, 0, 255);
		sprintf(textbuffer,"%s",languages[langselect]);
		write_font(375, 130, languages[langselect]);
	}
	drawmenu(currentmenu);
	drawselected(rootmenu_item);
	
	/* Draw options maybe tidy this up and make a func if doing larger menus*/ 
	if(currentmenu == CONFIGMENU){
		sprintf(textbuffer,"%s",pal60_options[pal60select]);
		write_font(375, 154, pal60_options[pal60select]);
		sprintf(textbuffer,"%s",ntsc_options[ntscselect]);
		write_font(375, 178, ntsc_options[ntscselect]);
		sprintf(textbuffer,"%s",pal50_options[pal50select]);
		write_font(375, 202, pal50_options[pal50select]);
		sprintf(textbuffer,"%s",vi_options[viselect]);
		write_font(375, 226, vi_options[viselect]);
		sprintf(textbuffer,"%s",hook_options[hookselect]);
		write_font(375, 250, hook_options[hookselect]);
		sprintf(textbuffer,"%s",ocarina_options[ocarinaselect]);
		write_font(375, 274, ocarina_options[ocarinaselect]);
	}

	if(currentmenu == REBOOTMENU){
		memset(textbuffer, 0, 255);
		sprintf(textbuffer,"%s",recovery_options[recoveryselect]);
		write_font(455, 130, recovery_options[recoveryselect]);
		sprintf(textbuffer,"%s",regionfree_options[regionfreeselect]);
		write_font(455, 154, regionfree_options[regionfreeselect]);
		sprintf(textbuffer,"%s",nocopy_options[nocopyselect]);
		write_font(455, 178, nocopy_options[nocopyselect]);
		sprintf(textbuffer,"%s",buttonskip_options[buttonskipselect]);
		write_font(455, 202, buttonskip_options[buttonskipselect]);
	}
}

u32 CvtRGB (u8 r1, u8 g1, u8 b1, u8 r2, u8 g2, u8 b2)
{
  int y1, cb1, cr1, y2, cb2, cr2, cb, cr;
 
  y1 = (299 * r1 + 587 * g1 + 114 * b1) / 1000;
  cb1 = (-16874 * r1 - 33126 * g1 + 50000 * b1 + 12800000) / 100000;
  cr1 = (50000 * r1 - 41869 * g1 - 8131 * b1 + 12800000) / 100000;
 
  y2 = (299 * r2 + 587 * g2 + 114 * b2) / 1000;
  cb2 = (-16874 * r2 - 33126 * g2 + 50000 * b2 + 12800000) / 100000;
  cr2 = (50000 * r2 - 41869 * g2 - 8131 * b2 + 12800000) / 100000;
 
  cb = (cb1 + cb2) >> 1;
  cr = (cr1 + cr2) >> 1;
 
  return (y1 << 24) | (cb << 16) | (y2 << 8) | cr;
}

/* highlight selected item */
void drawselected(u32 menuidpos)
{
	u32 x;
	u32 y;
	u32 startypos = 131;
	u32 yscreen = startypos + (menuidpos * fontheight);

	for(y = yscreen; y < yscreen + fontheight; y++)
	{
		for(x = innermenu_start; x < innermenu_end; x++)
		{
			if(xfb[x + screenwidth * y] == 0x00800080){
				xfb[x + screenwidth * y] = CvtRGB(44, 120, 8, 44, 120, 8);
			}
		}
	}
}

static void __blitmenu (char items[][27], u32 maxitems)
{
	int i;
	u32 startypos = 130;
	
	for(i=0;i<maxitems;i++)
	{
		write_font(175, startypos, (char *) items[i]);
		startypos += 24;
	}
}

void drawmenu(u32 menuid)
{
	char rootitems[7][27] = {{"Launch Game"},{"Config Options"},{"Rebooter Options"},{"About"},{"Exit OS"},{""},{"Press B to Launch Rebooter"}};
	char aboutitems[4][27] = {{"Backup Loader - WiiGator"},{"Graphic - WiiShizzza"}, {""},{"Return to Menu"}};
	char configitems[9][27] = {{"Boot Lang:"},{"Force PAL60:"},{"Force NTSC:"},{"Force PAL50:"},{"VIDTV Patch:"},{"Hook Type:"},{"Ocarina On:"},{""},{"Return to Menu"}};
	char rebooteritems[6][27] = {{"Recovery Mode:"},{"Region Free:"},{"Remove Copy Flags:"},{"Button Skip:"},{""},{"Return to Menu"}};


	switch(menuid)
	{
		case 0:
			__blitmenu(&rootitems[0], root_itemcount);
		break;

		case 1:
			__blitmenu(&aboutitems[0], about_itemcount);
		break;

		case 2:
			__blitmenu(&configitems[0], config_itemcount);
		break;

		case 3:
			__blitmenu(&rebooteritems[0], rebooter_itemcount);
		break;
	}
}
