Shop OBEX P1 Docs P2 Docs Learn Events
VGA.spin Dissection — Parallax Forums

VGA.spin Dissection

tdeyletdeyle Posts: 85
edited 2010-02-13 17:07 in Propeller 1
I have been hacking away at the video driver, trying to learn how the prop generates the video for VGA monitors. Specifically, the VGA.spin driver found in the library.

I have been reading A. Lamothe's book about programming the Hydra console and gained alot of insight into how the video generator works, the way the memory is setup for colour, pixels, etc.

But when I arrived to the actual pixel generating area of the code, I was a tad confused.

To make this example easier to explain, I have made a few considerations when figuring out this code:
This is the first run of the code, the Propeller was just turned on.
Also, the Bitmap Memory Address is located @ $0000_0000.

The way it looks to me, the line that states

:tile   rdword  tile,screen 




reads the WORD sized pointer from the screen variable to tile. This pointer points to the starting address of the tile in the bitmap memory and the colourset used to determine the four colors used in that tile. Here is how I understand it:

Bits 0..1 are included for boundary purposes,
bits 2..5 is the address of the LONG within the individual tile address,
bits 6..15 are the address of each 64 byte tile within the Bitmap Memory.

Now on to the confusing part. The next two lines:

add     tile,line               'ADD line=$0006_0000 to tile, 
rol     tile,#6                 'ROtate tile Left by 6




Okay, the first line adds %0000_0000_0000_0110_0000_0000_0000_0000 into the tile variable. Since the tile variable is WORD length, that would change the resulting tile variable into a LONG, correct?

For example, let's say that the tile variable equals %0100_0000_0000_0000 before it gets to the ADD command. After the ADD occurs, the tile variable equals %0000_0000_0000_0110_0100_0000_0000_0000, correct?

Continuing, the ROL command rotates the tile variable 6 places to the left:
With my example: %0000_0001_1001_0000_0000_0000_0000_0000

Now this is where the issue is for me. In the next line:

rdlong  pixels,tile




Considering that this is the first execution of this code, the tile variable should point to the address of the first row, of the first tile, yes? If the tile variable equals %0000_0001_1001_0000_0000_0000_0000_0000, wouldn't that point to the incorrect location in the memory?

But if the address was the first 16 bits of this LONG, then I could understand it: In other words, if the address was %0000_0000_0000_0000.

My question is, how does this work? What does the RDLONG command read? Bits 0..15, or the entire LONG? How does it only access bits 0..15 to get the address?

Any help would be greatly appreciated.

Theo

Comments

  • RaymanRayman Posts: 14,877
    edited 2010-02-12 20:43
    Ok, as I recall, the rol command moves the address bits into the correct position and moves the color bits above the lower 16 bits. Then, the rdlong command ignores the upper 16 bits of "tile" and gets the pixel data from the address in the lower 16 bits...

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    My Prop Info&Apps: ·http://www.rayslogic.com/propeller/propeller.htm
  • tdeyletdeyle Posts: 85
    edited 2010-02-12 23:24
    Thanks Ray;

    Can I get some clarification on the "ignoring" aspect of the RDLONG instruction? Whether or not it actually dies this and if it does, how?
  • kuronekokuroneko Posts: 3,623
    edited 2010-02-13 00:48
    tdeyle said...
    Can I get some clarification on the "ignoring" aspect of the RDLONG instruction? Whether or not it actually dies this and if it does, how?
    They (rdlong/wrlong & Co) all do ignore what's not relevant. As for how, I'd say that's hard-wired [noparse]:)[/noparse] Have a look at the propeller data sheet chapter 6.4 Propeller Assembler Instruction Table. You'll find descriptions along the lines of:

    Read main memory byte S[noparse][[/noparse]15..0] into D (0-extended)
    Read main memory word S[noparse][[/noparse]15..1] into D (0-extended)
    Read main memory long S[noparse][[/noparse]15..2] into D
    


    Important bits here are the used source bit ranges (S[noparse][[/noparse]31..16] is ignored).
  • RaymanRayman Posts: 14,877
    edited 2010-02-13 01:35
    I think that's right... Since there's only 32kB of address space, the upper 16 bits have no affect...

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    My Prop Info&Apps: ·http://www.rayslogic.com/propeller/propeller.htm
  • tdeyletdeyle Posts: 85
    edited 2010-02-13 02:13
    Thanks guys!
  • mparkmpark Posts: 1,305
    edited 2010-02-13 17:07
    Rayman said...
    I think that's right... Since there's only 32kB of address space, the upper 16 bits have no affect...

    Slight correction: the hub address space is 64k (32k RAM, 32k ROM). 64k implies 16-bit addressing.

    I'm sure that's what Rayman meant to say.
Sign In or Register to comment.