/home/jonas/tidevel/adt/Advanced Dialogs/source/Util.c

00001 /*
00002         Advanved Dialogs v1.05
00003         Copyright (C) 2005-2007 Jonas Gehring
00004 
00005         Advanced Dialogs is free software; you can redistribute it and/or modify
00006         it under the terms of the GNU Lesser General Public License as published by
00007         the Free Software Foundation; either version 2 of the License, or
00008         (at your option) any later version.
00009 
00010         Advanced Dialogs is distributed in the hope that it will be useful,
00011         but WITHOUT ANY WARRANTY; without even the implied warranty of
00012         MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013         GNU Lesser General Public License for more details.
00014 
00015         You should have received a copy of the GNU Lesser General Public License
00016         along with this program.  If not, see <http://www.gnu.org/licenses/>.
00017 */
00018 
00019 
00020 // C Source File
00021 // Created 29.08.2005; 23:03:04
00022 
00023 
00024 #include <extgraph.h>                                                   // ExtGraph by TI-Chess Team
00025 
00026 #include "AdvDialogs.h"                                                 // This should be obvious ;)
00027 #include "Internal.h"                                                   // This header should not be included in programs using Advanced Dialogs
00028 
00029 
00030 #ifndef OSdequeue
00031 #define OSdequeue _rom_call(short,(__pushort,void*),3AA)
00032 #endif
00033 
00034 
00035 // Clears the keyboard queue
00036 void ClearKbdQueue(void)
00037 {
00038         while (_rowread(0)) continue;
00039 }
00040 
00041 
00042 // Waits for a keypress and stores it in key
00043 void GetKey(void *kbq, short *key)
00044 {
00045         // Wait for keypress and mask out key repitition
00046         while (OSdequeue(key, kbq)) continue;
00047         *key &= 0xF7FF;
00048 }
00049 
00050 
00051 // Draws a colored string (black or white)
00052 void GrayDrawColorString(short x, short y, const char *str, uchar color, uchar mode)
00053 {
00054         if (color == COLOR_WHITE)
00055         {       
00056                 GraySetAMSPlane(LIGHT_PLANE);
00057                 DrawStr((mode == TXT_CENTERED ? (LCD_WIDTH - DrawStrWidth(str, F_4x6)) >> 1 : x), y, str, A_XOR);
00058         }
00059         else
00060         {
00061                 GrayDrawStrExt(x, y, str, A_NORMAL | (mode == TXT_CENTERED ? A_CENTERED : 0), F_4x6);
00062         }
00063 }
00064 
00065 
00066 // Save grayscale screen contents
00067 void SaveScreen(void)
00068 {
00069         if (tscr == NULL)
00070         {
00071                 // Allocate space for the LCD buffers
00072                 if ((tscr = malloc(sizeof(LCD_BUFFER)*2)) == NULL)
00073                 {
00074                         return;
00075                 }
00076                 
00077                 // Save contents
00078                 FastCopyScreen_R(GrayGetPlane(LIGHT_PLANE), tscr);
00079                 FastCopyScreen_R(GrayGetPlane(DARK_PLANE), tscr+sizeof(LCD_BUFFER));    
00080         }
00081 }
00082 
00083 
00084 // Restore grayscale screen contents
00085 void RestoreScreen(void)
00086 {
00087         if (tscr)
00088         {
00089                 FastCopyScreen_R(tscr, GrayGetPlane(LIGHT_PLANE));
00090                 FastCopyScreen_R(tscr+sizeof(LCD_BUFFER), GrayGetPlane(DARK_PLANE));
00091                 free(tscr);
00092                 tscr = NULL;
00093         }
00094 }
00095 
00096 
00097 
00098 

Generated on Thu Oct 4 19:42:03 2007 for Advanced Dialogs by  doxygen 1.5.1