Shop OBEX P1 Docs P2 Docs Learn Events
How to display a bitmap/tile with VGA driver ? — Parallax Forums

How to display a bitmap/tile with VGA driver ?

HHaysHHays Posts: 15
edited 2007-09-11 21:33 in Propeller 1
I have spent way longer on this than I'm willing to admit. I am attempting to display a tile - 16x16, 32x32 - whatever, using one of Chip's VGA objects. In general, Chip's objects inbed the base address of the bitmap in either the upper 10 bits, or the lower 10 bits (depending on the object) of a long-aligned word. The remaining 6 bits are used to specify a palette.


I have downloaded every VGA related object, lurked for 2 weeks, and studied, but I cannot seem to accomplish this. There are no examples of displaying a tile in VGA in any code that I can find. The closest thing is in a couple of Chip's demo's, the propeller hat (32x32) is displayed, but that is a cursor and doesn't apply here. I have shifted bits left, tried different ways of addressing the tile, etc.



Here is an example of my question. The code below is a snippet of Chip's 1024x768 demo, with some extraneous code removed. Let's say I wish to display the "propeller hat" in the DAT section. Without boring you folks with the many things I have tried, could someone please replace the question marks with the correct line(s) of code? I realize this is elementary, for some reason, I'm having a tough time of it.



I would of asked for help sooner, but deSilva scares me :[noparse][[/noparse]



Thanks!



CON
cols = 64
rows = 48
tiles = cols * rows

VAR
long col, row, color
long array[noparse][[/noparse]tiles/2]

OBJ

vga : "vga_1024x768_Driver"

PUB start | t, s
vga.start(16, @array, @vgacolors, 0, 0, 0)


?????????????????????????????????

DAT
propeller long

long %00000000_00000000_00000000_00000000
long %01111110_00000000_00000011_11111000
long %11111111_11110001_10111111_11111110
long %11111111_11111111_11111111_11111111
long %01111111_11111101_10001111_11111111
long %00011111_11000001_10000000_01111110
long %00000000_00000011_11000000_00000000
long %00000000_00000011_11000000_00000000
long %00000000_00000001_10000000_00000000
long %00000000_00001111_11110000_00000000
long %00000000_01111001_10011110_00000000
long %00000001_11110011_11001111_10000000
long %00000011_11100011_11000111_11000000
long %00000111_11000111_11100011_11100000
long %00001111_10000111_11100001_11110000
long %00011111_10000111_11100001_11111000
long %00011111_00000111_11100000_11111000
long %00111111_00001111_11110000_11111100
long %00111110_00001111_11110000_01111100
long %00111110_00001111_11110000_01111100
long %01111110_00001111_11110000_01111110
long %01111100_00001111_11110000_00111110
long %01111100_00011111_11111000_00111110
long %01111111_11111111_11111111_11111110
long %01111111_11110000_00001111_11111110
long %01111000_00000000_00000000_00011110
long %01100000_00000000_00000000_00000110
long %00111100_00000000_00000000_00111100
long %00001111_11110000_00001111_11110000
long %00000011_11111111_11111111_11000000
long %00000000_00011111_11111000_00000000
long %00000000_00000000_00000000_00000000

Post Edited (HHays) : 9/11/2007 8:56:34 PM GMT

Comments

  • Ken PetersonKen Peterson Posts: 806
    edited 2007-09-11 18:21
    Dont' worry about deSilva. He sometimes barks like a German Shepherd behind a chainlink fence, but he means well. wink.gif

    I've never used the 1024 x 768 VGA, only the standard one that comes with the Propeller Tool. Have you tried that one first?

    Also, again I'm not sure about the 1024 x 768 VGA, but the standard VGA and TV drivers provided use a pointer like CCCCCCPPPPPPPPPP. Where C is a color index and P is the pointer to the bitmap for a given tile. However, there are only 10 bits in that pointer, so it is rounded off to the nearest 64-byte (16 long) block. This means the lower 6 bits of the address are 0 If you are using this scheme, your graphic bitmap must be aligned to a 64-byte block in memory.

    I've been trying to figure out a good way to do that, the only way I know how is to define a blank bitmap area in memory and precede it by a pad of 15 longs. Then, create a pointer to your bitmap and round it off to the nearest 16 longs (pointer &= $FFC0). Then you can do a longmove to copy your propeller to the area pointed to by your pointer.

    I know I didn't write code for you, but I hope this makes some sense.

    Ken

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔


    The more I know, the more I know I don't know.· Is this what they call Wisdom?
  • RaymanRayman Posts: 14,162
    edited 2007-09-11 18:53
    I posted an example showing how to use·custom 16x16 graphics tiles with the 1024x768 VGA driver last week...



    I did find one little error·yesterday though...

    Change $FF00 to $FFC0 as shown below:

    '64 byte align the user characters
    · user_charbase := @uchar & $FFC0 'destination
    · longmove(user_charbase,@uchar,16*nuchars)



    ·
  • RaymanRayman Posts: 14,162
    edited 2007-09-11 18:56
    PS: I made a little web applet to help generate the character info:

    http://www.rayslogic.com/propeller/Programming/Characters.htm
  • HHaysHHays Posts: 15
    edited 2007-09-11 20:33
    Thanks so much to the both of you. Oddly enough, some of Chip's VGA objects put the base address in the lower 10 bits, some in the upper. At any rate, you guys really saved the day (month) for me.

    Thanks again!
  • QuattroRS4QuattroRS4 Posts: 916
    edited 2007-09-11 21:33
    Rayman ... nice job ...


    Regards,
    John

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    'Necessity is the mother of invention'
Sign In or Register to comment.