/* ----------------------------------------------- GTASC - GTA adaptation for TI Calculators ----------------------------------------------- Programmed by : Olivier SANGALA Version : 1.2 License : Free under GNU General Public License ( see "gpl.txt" ) Release Date : 05/01/2007 Platform : TI89/TI92+/V200 Website : http://olivier.sangala.free.fr Email : olivier_sangala@hotmail.com ---------- License ---------- Copyright (C) 2002-2007 Olivier SANGALA 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 */ //----------------------------------------------------------------------------- #include // Include All Header Files #include #include "kblib.h" #include "menulib.h" //-------------------------------------------------------------------------- extern short kb_state; extern short kb_state_DOWN; extern short kb_state_UP; //----------------------------------------------------------------------------- extern char * Plane0; extern char * Plane1; //-------------------------------------------------------------------------- TMenu * Menu; //-------------------------------------------------------------------------- void DrawStrCenter(int x,int y,char*s) { // parameter 'x' not used int x2 = (160-6*strlen(s))/2; DrawStr(x2,y,s,A_NORMAL); } //-------------------------------------------------------------------------- void MenuNew2(void) { strcpy(Menu->Title,""); Menu->ItemCounter = 0; Menu->Index = 0; } //-------------------------------------------------------------------------- void MenuAddItem(char * str) { strcpy(Menu->Items[Menu->ItemCounter++].Caption,str); } //-------------------------------------------------------------------------- void MenuAddTitle(char * str) { strcpy(Menu->Title,str); } //-------------------------------------------------------------------------- void MenuDo(void) { int a; char*ptr1; Menu->Index = 0; PortSet(GetPlane(0),239,127); ClrScr(); PortSet(GetPlane(1),239,127); ClrScr(); DrawStrCenter(-1,0,Menu->Title); for (a=0;aItemCounter;a++) DrawStrCenter(-1,16+8*a,Menu->Items[a].Caption); for(;;) { // Selection XOR ptr1=(char*)GetPlane(1)+(240*(Menu->Index+2)); for (a=0;a<240;a++) *ptr1++^=255; // key = ngetchx(); WaitForKeyDOWN(~0); short kbs=kb_state_DOWN; WaitForAllKeysReleased(); // Selection XOR ptr1=(char*)GetPlane(1)+(240*(Menu->Index+2)); for (a=0;a<240;a++) *ptr1++^=255; if (kbs&KEYFLAGS_UP) { if (Menu->Index>0) Menu->Index--; else Menu->Index = Menu->ItemCounter-1; } else if (kbs&KEYFLAGS_DOWN) { if (Menu->IndexItemCounter-1) Menu->Index++; else Menu->Index = 0; } else if (kbs&KEYFLAGS_2ND) { break; } } PortRestore(); } //--------------------------------------------------------------------------