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

RScreenUtils Class Reference

Direct screen access. More...

#include <RScreenUtils.h>

List of all members.

Public Methods

 RScreenUtils ()
 constuctor. More...

TInt Open ()
 Initialize class. More...

void Close ()
 Close. More...

void Blank (TUint16 aColor)
 Clear screen to color. More...

void Number (TUint aX, TUint aY, TUint32 aNumber, TUint16 aForeColor, TUint16 aBackColor)
 Draw a number in decimal. More...

void HexNumber (TUint aX, TUint aY, TUint32 aNumber, TUint16 aForeColor, TUint16 aBackColor)
 Draw a number in hexdecimal. More...

TUint16 * ScreenBase ()
 Base address of screen memory. More...

void DrawPicture (TPicture &aPicture)
 Draw a picture on the screen. More...

void BlankArea (TBlank &aBlank)
 Blank an area of the screen. More...


Private Methods

TUint32 BCDNumber (TUint32 aNumber)
 Convert a number to BCD. More...

void BlankAsm (TUint16 aColor)
 Blank the whole screen. More...

void BlankAreaAsm (TBlank *aBlank)
 Blank an area of the screen. More...

void DrawPictureAsm (TPicture *aPicture)
 Draw a picture on the screen. More...


Static Private Methods

void NumberAsm (TUint16 *aPos, TUint32 aNumber, TUint16 aForeColor, TUint16 aBackColor)
 Draws a hex number on the screen. More...


Private Attributes

TUint16 * iScreenBase
 Base address of screen memory. More...


Detailed Description

Direct screen access.

This class provides utilities to plot numbers and sprites direct to the screen. It also provides the base address of the screen. All X coordinates are in steps of 2 pixels (ie one 32 bit word).

Definition at line 26 of file RScreenUtils.h.


Constructor & Destructor Documentation

RScreenUtils::RScreenUtils  
 

constuctor.

Definition at line 37 of file RScreenUtils.cpp.

00037                            : iScreenBase(NULL) {
00038 }


Member Function Documentation

TInt RScreenUtils::Open  
 

Initialize class.

Gets the screen info and works out the screen base address.

Returns:
KErrNone if successful, KErrNotSupported if: the screen is not 640x200 or the screen info is not available.

Definition at line 49 of file RScreenUtils.cpp.

References iScreenBase.

Referenced by CMap::ConstructL(), and RStatus::Open().

00049                         {
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 }

void RScreenUtils::Close  
 

Close.

Definition at line 77 of file RScreenUtils.cpp.

References iScreenBase.

Referenced by RStatus::Close(), and CMap::ConstructL().

00077                          {
00078   iScreenBase=NULL;
00079 }

void RScreenUtils::Blank TUint16    aColor
 

Clear screen to color.

Parameters:
aColor  color to fill the screen with

Definition at line 118 of file RScreenUtils.cpp.

References BlankAsm(), and iScreenBase.

00118                                        {
00119   if(iScreenBase==NULL)
00120     return;
00121   BlankAsm(aColor);
00122 }

void RScreenUtils::Number TUint    aX,
TUint    aY,
TUint32    aNumber,
TUint16    aForeColor,
TUint16    aBackColor
 

Draw a number in decimal.

Converts the number to binary coded decimal then calls HexNumber() to plot it.

Parameters:
aX  X position to draw at (0-319)
aY  Y position to draw at (0-199)
aNumber  number to draw (0-999999), will wrap after that
aForeColor  foreground color
aBackColor  background color

Definition at line 92 of file RScreenUtils.cpp.

References BCDNumber(), and HexNumber().

Referenced by RStatus::Update().

00093                                                                 {
00094   HexNumber(aX,aY,BCDNumber(aNumber),aForeColor,aBackColor);
00095 }

void RScreenUtils::HexNumber TUint    aX,
TUint    aY,
TUint32    aNumber,
TUint16    aForeColor,
TUint16    aBackColor
 

Draw a number in hexdecimal.

Parameters:
aX  X position to draw at (0-319)
aY  Y position to draw at (0-199)
aNumber  number to draw (0-FFFFFFF), will wrap after that
aForeColor  foreground color
aBackColor  background color

Definition at line 105 of file RScreenUtils.cpp.

References iScreenBase, and NumberAsm().

Referenced by Number().

00106                                                                    {
00107                              
00108   if(iScreenBase==NULL)
00109     return;
00110   TUint offset=aX+aY*640;
00111   NumberAsm(iScreenBase+offset,aNumber,aForeColor,aBackColor);
00112 }

TUint16 * RScreenUtils::ScreenBase  
 

Base address of screen memory.

Definition at line 72 of file RScreenUtils.cpp.

References iScreenBase.

Referenced by CMap::ConstructL().

00072                                   {
00073   return iScreenBase;
00074 }

void RScreenUtils::DrawPicture TPicture   aPicture
 

Draw a picture on the screen.

Parameters:
aPicture  picture to draw

Definition at line 25 of file RScreenUtils.cpp.

References DrawPictureAsm().

Referenced by RStatus::Update(), and RStatus::UpdateSingle().

00025                                                  {
00026   DrawPictureAsm(&aPicture);
00027 }

void RScreenUtils::BlankArea TBlank   aBlank
 

Blank an area of the screen.

Parameters:
aBlank  area to blank

Definition at line 32 of file RScreenUtils.cpp.

References BlankAreaAsm().

Referenced by RStatus::UpdateSingle().

00032                                            {
00033   BlankAreaAsm(&aBlank);
00034 }

TUint32 RScreenUtils::BCDNumber TUint32    aNumber [private]
 

Convert a number to BCD.

Definition at line 125 of file RScreenUtils.cpp.

Referenced by Number().

00125                                                {
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 }

static void RScreenUtils::NumberAsm TUint16 *    iPos,
TUint32    aNumber,
TUint16    aForeColor,
TUint16    aBackColor
[static, private]
 

Draws a hex number on the screen.

Parameters:
aPos  memory location to draw number
aNumber  number to draw (0-FFFFFFF), will wrap after that
aForeColor  foreground color
aBackColor  background color
defined in the file number.s

Referenced by HexNumber().

void RScreenUtils::BlankAsm TUint16    aColor [private]
 

Blank the whole screen.

Parameters:
aColor  color to fill the screen with
defined in the file blank.s

Referenced by Blank().

void RScreenUtils::BlankAreaAsm TBlank   aBlank [private]
 

Blank an area of the screen.

Parameters:
aBlank  area and color to clear
defined in the file blankarea.s

Referenced by BlankArea().

void RScreenUtils::DrawPictureAsm TPicture   Picture [private]
 

Draw a picture on the screen.

Parameters:
aPicture  sprite information and location
defined in the file drawpicture.s

Referenced by DrawPicture().


Member Data Documentation

TUint16* RScreenUtils::iScreenBase [private]
 

Base address of screen memory.

number.s and blank.s require that this is the first data member of the object

Definition at line 72 of file RScreenUtils.h.

Referenced by Blank(), Close(), HexNumber(), Open(), and ScreenBase().


The documentation for this class was generated from the following files:
Documentation for Game (Beta) version 1.44.