PDA

View Full Version : Pixel-definitions in assembly



propwell
04-06-2009, 07:30 AM
Hi together,

i've tried to understand the pixel-definition of the Graphics_demo now for several hours, but i'm not coming to an end.


pixdef word 'crosshair
byte 2,7,3,3
word %%00333000,%%00000000
word %%03020300,%%00000000
word %%30020030,%%00000000
word %%32222230,%%00000000
word %%30020030,%%02000000
word %%03020300,%%22200000
word %%00333000,%%02000000


I also looked at the explanations in the Graphics.spin, but i cant draw a conclusion.

Can someone explain it to me shortly? And: is there a way to create more complex pixel-forms in an easier way?

Thank you very much!!!
propwell

Beau Schwabe
04-06-2009, 11:00 AM
propwell,

This notation is fairly compact if you still want it to be "human readable"... It took me awhile to figure this notation out also.

It might help if first you know the difference between representing a value as % or %%....

% is used to indicate a Binary number

%% is used to indicate a Quaternary number

relation:
%00 = %%0
%01 = %%1
%10 = %%2
%11 = %%3

In the 'crosshair' data you provided the Quaternary number is referenced as a word, because there are 8 Quaternary digits in each field. Each Quaternary digit equals 2 bits... so 8 Quaternary digits times 2 bits equals a 16-bit 'word'.

For this though, since the tv graphics driver is only capable of delivering 4 individual colors per tile, a Quaternary numbering system made sense... the value in the table simply represents one of the four colors we want to use within a particular tile.

The data at the top determines the dimensions for the sprite...

byte 2,7,3,3

Where...

2 represents the number of words wide the sprite is
7 represents the number of lines high the sprite is

the next two represent the relative center you want the sprite to be drawn from.
a 3, 3 in this case places the relative center at the center of the "+". Remember '0' is a valid position

...So when you call the sprite and tell it to draw at 10,10, the center of the '+' will be at 10,10 relative to the rest of the sprite.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Beau Schwabe (mailto:bschwabe@parallax.com)

IC Layout Engineer
Parallax, Inc.

propwell
04-06-2009, 03:20 PM
wow, thank you for your fast and detailed help.

And with the words in quarternary format i paint the single pixels? and each digit is one pixel?

Beau Schwabe
04-06-2009, 11:15 PM
propwell,

"And with the words in quaternary format I paint the single pixels? and each digit is one pixel?" - Yes, that is correct on both counts.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Beau Schwabe (mailto:bschwabe@parallax.com)

IC Layout Engineer
Parallax, Inc.