Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members   Related Pages  

RScreenUtils.cpp

Go to the documentation of this file.
00001 // Copyright 2002 Kenneth Guy,
00002 // 
00003 // You are free to take the source and do as you wish with it.
00004 // However it would be nice if you let me know if the code was useful
00005 // to you and give me an acknowledgement if you use a significant portion
00006 // of the code in an application.
00007 // 
00008 // RScreenUtils.cpp
00009 
00014 #include <e32std.h>
00015 #include <e32svr.h>
00016 
00017 //data
00018 #include "numbers.h"
00019 
00020 #include "RScreenUtils.h"
00021 
00025 void RScreenUtils::DrawPicture(TPicture &aPicture) {
00026   DrawPictureAsm(&aPicture);
00027 }
00028 
00032 void RScreenUtils::BlankArea(TBlank &aBlank) {
00033   BlankAreaAsm(&aBlank);
00034 }
00035 
00037 RScreenUtils::RScreenUtils() : iScreenBase(NULL) {
00038 }
00039 
00040 
00049 TInt RScreenUtils::Open() {
00050   // get the screen info so we can work out the base address of the screen
00051   TPckgBuf<TScreenInfoV01> info;
00052   UserSvr::ScreenInfo(info);
00053   if(info().iScreenAddressValid==EFalse ||
00054      info().iScreenSize.iWidth!=640 ||
00055      info().iScreenSize.iHeight!=200) {
00056     return KErrNotSupported;
00057   }
00058     
00059   // screen memory is 2 bytes per pixel, top 4 bits unused,
00060   // 4 bits green, 4 bits blue.
00061   iScreenBase=STATIC_CAST(TUint16*,info().iScreenAddress);
00062   // there is palette information at the start of the screen
00063   // memory, for 12 bits per pixel this is 16 2 byte entries,
00064   // the first of which defines that the pixel size is 12 bits.
00065   // actual pallete information is ignored.
00066   iScreenBase += 16;
00067   return (KErrNone);
00068 }
00069 
00070 
00072 TUint16 *RScreenUtils::ScreenBase() {
00073   return iScreenBase;
00074 }
00075 
00077 void RScreenUtils::Close() {
00078   iScreenBase=NULL;
00079 }
00080 
00092 void RScreenUtils::Number(TUint aX,TUint aY,TUint32 aNumber,
00093                           TUint16 aForeColor,TUint16 aBackColor){
00094   HexNumber(aX,aY,BCDNumber(aNumber),aForeColor,aBackColor);
00095 }
00096 
00105 void RScreenUtils::HexNumber(TUint aX,TUint aY,TUint32 aNumber,
00106                              TUint16 aForeColor,TUint16 aBackColor){
00107                              
00108   if(iScreenBase==NULL)
00109     return;
00110   TUint offset=aX+aY*640;
00111   NumberAsm(iScreenBase+offset,aNumber,aForeColor,aBackColor);
00112 }
00113 
00118 void RScreenUtils::Blank(TUint16 aColor) {
00119   if(iScreenBase==NULL)
00120     return;
00121   BlankAsm(aColor);
00122 }
00123 
00125 TUint32 RScreenUtils::BCDNumber(TUint32 aNumber) {
00126   TUint32 out=0;
00127   TInt digit=0;
00128   while(aNumber!=0) {
00129     out += (aNumber%10) << (4*digit);
00130     digit++;
00131     aNumber /= 10;
00132   }
00133   return out;
00134 }
00135 
00136 

Documentation for Game (Beta) version 1.44.