To LUGNET HomepageTo LUGNET News HomepageTo LUGNET Guide Homepage
 Help on Searching
 
Post new message to lugnet.roboticsOpen lugnet.robotics in your NNTP NewsreaderTo LUGNET News Traffic PageSign In (Members)
 Robotics / 26704
26703  |  26705
Subject: 
Re: What do these macros do?
Newsgroups: 
lugnet.robotics.nxt, lugnet.robotics
Date: 
Thu, 11 Jan 2007 13:21:49 GMT
Viewed: 
1086 times
  
Ok, well, replying to my own message in the best of internet style...

I got impatient and starting prodding.  After a few hard resets, I came up with
the following:

Yes, the Get/SetDisplayNormal() permits you to write directly to screen memory.
This is obviously very useful if you're trying to update a graphical display,
like a map, or some of the games we've seen, since you don't have to wipe the
screen to redraw.

Here's how I did it:

Ignore how the screen's (x,y) coordinates for drawing points works, this is
different.

Byte 0 of screen memory controls the column of 8 pixels located in the upper
left corner of the screen. The least significant bit is in the very top corner;
the most significant is 7 pixels below that.  Byte 1 is the next column of 8
pixels to the right.  Byte 99 is in the upper right corner, and Byte 100 is the
first column of pixels in the second row of characters.  Byte 799 is the lower
right.

This is the code I ran, stripped down:
---------

#include "NXTDefs.h"

dseg segment
  jay  byte[] 0x00, 0x04, 0x44, 0x82, 0x86, 0x49, 0x31, 0x00
  eee  byte[] 0x00, 0x04, 0x0C, 0xB2, 0x52, 0x49, 0x21, 0x20
dseg ends

thread main
  TextOut(0, 0, TRUE, '')
  SetDisplayNormal(0,0,8,jay)
  Wait(3000)
  SetDisplayNormal(0,0,8,eee)
  Wait(3000)
endt

---------

First, I set up an array of bytes to write a scriptish letter 'J'  Each byte
corresponds to one column of the letter.

Sort of like this:

OOOOOXXO
OOOXXOOO
OXXOXOOO
OOOOOXOO
OOOOOOXO
OOOOOOXO
OOXOOXOO
OOOXXOOO

The TextOut() is clunky, but clears the screen.  Yes, I know there's a better
way. :)

Then, I write the eight bytes of my array to location 0,0 of the screen.  A
script 'J' appears in the upper left corner of the screen, and we wait for 3
seconds to admire the result.

The 'eee' array contains a similar scriptish 'E', which replaces the 'J' when I
make the second Set call.  After 3 more seconds, the program ends.


So what?  there are already simpler ways to write text, or copy bitmap images to
the screen.  The strength here lies in the fact that we can turn pixels OFF
without refreshing (many pixels of the 'J' turn off in order to display the 'E',
for example).  Furthermore, we can algorithmically decide which pixels to
display, and calculate what values to set.

I haven't tried the GetDisplayNormal() call yet, but I assume it allows you to
read the screen in the same fashion.  This opens the door to buffering areas of
the screen and rewriting them afterwards, or doing XOR type operations to allow
quick overlays, etc.


Some further poking around (or peeking, I guess, from my C64 days) yields that
the values of the Erase Mask and Update Mask are 0, and that the DisplayDisplay
is 38483 (I assume that's the pointer to the screen memory?), and finally that
the DisplayFlags are 0x83 or 131.  I'm wondering if flipping a bit in those
flags would cause the "Popup" screen to display instead?  It certainly *looks*
like the "Popup" calls are a second page buffer.

Some input from someone with more knowlege would be very helpful!

Jeff



Message has 1 Reply:
  Re: What do these macros do?
 
(...) Lots of very cool stuff deleted. Sorry I missed your original message, Jeff. You can write to both the Normal and Popup screen memory and toggle back and forth between which one gets displayed. This code flips between the two buffers for 10 (...) (18 years ago, 16-Jan-07, to lugnet.robotics.nxt, lugnet.robotics)

Message is in Reply To:
  What do these macros do?
 
I've been poking around with my NXT, and as usual I've decided to bite off more than I can chew. In trying to discover a way to *unset* pixels on the display without wiping the whole thing, I've been sifting through some of the less-discussed macros (...) (18 years ago, 11-Jan-07, to lugnet.robotics.nxt, lugnet.robotics)

12 Messages in This Thread:




Entire Thread on One Page:
Nested:  All | Brief | Compact | Dots
Linear:  All | Brief | Compact

This Message and its Replies on One Page:
Nested:  All | Brief | Compact | Dots
Linear:  All | Brief | Compact
    

Custom Search

©2005 LUGNET. All rights reserved. - hosted by steinbruch.info GbR