×

Discussion Board

Results 1 to 2 of 2
  1. #1
    Regular Contributor
    Join Date
    Mar 2003
    Location
    IL/USA
    Posts
    341

    Direct Screen Access (Please Comment!)

    I use the following code to get the screen address, I took it from code that I found on forum:
    Code:
    #if !defined(__WINS__) // device code
      // fetch screen buffer address
      TScreenInfoV01 screenInfo;
      TPckg<TScreenInfoV01> sInfo(screenInfo);
      UserSvr::ScreenInfo(sInfo);
    
      iScreenAddr = screenInfo.iScreenAddressValid ? (TUint8*)iScreenInfo.iScreenAddress : 0;
      User::LeaveIfNull(iScreenAddr);
    
      //skip the palette data (assumes screen mode is 12-bit)
      iScreenAddr += 32;
    
    #else // begin emulator code
      iOffScreenBufferedBmp = new (ELeave)CFbsBitmap;
      iOffScreenBmp = new (ELeave) CFbsBitmap;
      iOffScreenBmp->Create(iScreenDevice.SizeInPixels(), EColor4K);
      iOffScreenBufferedBmp->Create(iScreenDevice.SizeInPixels(),EColor4K);
      iScreenAddr = (TUint8*)iOffScreenBmp->DataAddress();
    #endif
    On the emulator side, where do I get iScreenDevice from? Once I have iScreenAddr, can I write directly to the screen the same way for both device and emu using iScreenAddr, For example:
    Code:
    void ClearScreen(TUint16 color) 
    {
      TUint16* tmpScreenAddress = iScreenAddr;
      for(TInt k = 0; k < 176 * 208; k++)
        *(tmpScreenAddress++) = color;
    }
    The above code will clear the screen on both the device and emulator?

    This is code that I created to BitBlt to the screen:
    Code:
    --- header--
    private:
      TUint8* iScreenAddr;              //device/emu screen addr
      CFbsBitmap* iOffScreenBmp; // offscreen buffer
    #if defined(__WINS__)
      CFbsBitmap* iOffScreenBufferedBmp; // for emu create another area for buffering data
    #endif
    
    --- cpp ---
    void CGraphicsEngine::BitBlt()
    {
    #if !defined(__WINS__) // device code
      AsmBitBlt(iScreenAddr, iOffscreenBmp->DataAddress())
      TRawEvent redraw;
      redraw.Set(TRawEvent::ERedraw);
      UserSvr::AddEvent(redraw);
    #else // emu code
      Mem::Copy(iScreenAddr, iOffScreenBufferedBmp->DataAddress(), 208*176);
      TRawEvent redraw;
      redraw.Set(TRawEvent::ERedraw);
      UserSvr::AddEvent(redraw);
    #endif
    }
    Is this code correct? I haven't tested it yet, but I compiled it using various questions from previous forum questions. I don't know what "
    TRawEvent redraw;
    redraw.Set(TRawEvent::ERedraw);
    UserSvr::AddEvent(redraw);"
    does, or even if it's necessary, because I copied it from the forum code too.

    The reason that I am not using CDirectScreenAccess is becaues I am not concerned with interfering with WinServer because the Asm routine should be so fast that it will never interfere with the WinServer and thus the screen will not get garbled. Please Comment!

    Thank You!
    earamsey
    Last edited by earamsey; 2004-08-29 at 01:18.

  2. #2
    Registered User
    Join Date
    Jul 2006
    Posts
    3

    Re: Direct Screen Access (Please Comment!)

    Hi,

    TRawEventredraw;
    redraw.Set(TRawEvent::ERedraw);
    UserSvr::AddEvent(redraw);

    This code is for forcing a screen update by creating a redraw event, the reason of this it's because UserSvr::ScreenInfo() returns the address of the “off-screen” buffer and this is not immediately displayed on the screen.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×