Shop OBEX P1 Docs P2 Docs Learn Events
VGA_HiRes_Text has me stumped — Parallax Forums

VGA_HiRes_Text has me stumped

ElectrodudeElectrodude Posts: 1,665
edited 2011-06-21 07:38 in Propeller 1
I'm trying to modify VGA_HiRes_Text so that I can control the color of every character individually instead of being stuck with one color per line. I'm making a codewars game involving Funge-98 and the tile drivers can't fit enough characters on the screen. I need 128x32 characters (half the screen), which this driver can already do. However, I need to be able to have at least five different background colors for each character: no-man's land, blue territory, yellow territory, blue IP, and yellow IP. I got the driver to change color every four lines instead of every 12, but I can't get it to do the colors how I need it to. I'm also considering just using a tile driver and making the tiles smaller. I wouldn't mind using two more cogs for the VGA_HiRes_Text driver, but I would mind using a normal tile driver because they don't have enough tiles and usually use too many cogs. Am I wasting my time or is it possible?

Thanks,
Electrodude

Comments

  • kwinnkwinn Posts: 8,697
    edited 2011-06-16 10:00
    I am pretty sure you just cannot do that.
  • ElectrodudeElectrodude Posts: 1,665
    edited 2011-06-16 10:21
    What if I use more than 2 cogs?
  • ElectrodudeElectrodude Posts: 1,665
    edited 2011-06-17 18:56
    I got the program to change color every line but can't understand how it draws lines. It seems like each line is drawn with only six waitvids somehow. If someone can help me decipher the scancode routine and what it looks like after the init code is run (the code in comments is obviously not complete) then I think I might be able to get the program to work, but I might need help adding more cogs.
  • kwinnkwinn Posts: 8,697
    edited 2011-06-17 21:10
    The waitvid instruction shifts out 16 four color or 32 2 color pixels depending on the mode. IIRC VGA hi res text uses the 32 2 color pixels. That means that for a line of 640 pixels you would need 20 waitvid instructions (not counting front and back porches etc,). 32 pixels would be 4 character widths so the best you could hope for would be to change the color of groups of 4 characters. And that is assuming you have the time to execute the instruction between each waitvid.

    BTW did you download and read AN004-GUI-StartVGA-v1.0_0 ?
  • AntoineDoinelAntoineDoinel Posts: 312
    edited 2011-06-18 04:49
    Hi Electrodude

    http://forums.parallax.com/showthread.php?122305-VGA-colour-and-VT100-objects
    have you tried this already?

    I don't know if it's able to do 128x32 as well, but it should support attribute per single char.
  • localrogerlocalroger Posts: 3,452
    edited 2011-06-18 05:47
    Electrodude, you are probably wasting your time, unless you want to pursue a solution requiring four or more cogs. At VGA dot rates there simply isn't time to do more than one hub ram read in the time it takes to scan past a character; and there isn't time to do even that if the hub isn't synced to the video signal, which it can't be since they are running at different frequencies, so the Hires_ drivers work by having one cog do hub reads and using them to write code to produce the next scan line while the other cog is displaying the scan line it built previously. After a cog builds the next line it waits for the hsync and then runs the code it wrote, basically a bunch of consecutive waitvids.

    To do what you are asking the cog would have to read both character and color information to build the waitvid instructions for the next line. I'm pretty sure that would take more than one scan line to do, so you'd need more than 2 cogs. I did some work on VGA drivers earlier this year (and made a 3-cog driver that does 18 rows of 40 columns using the ROM font, with individual character colors and user defined expansion characters. For the character and color density you're seeking I suspect you would need 4 cogs using a HiRes_ style scheme with each cog writing the code to generate its next scan line.
  • ElectrodudeElectrodude Posts: 1,665
    edited 2011-06-18 18:22
    @localroger: I was thinking something close to that. Instead of having 2 cogs do 4 lines at a time I was thinking of having 4 cogs do 2 lines at a time. The scan buffers would then be half as big. I would then put color data in the other half of the scan buffer. I still can't do that until I can understand the scancode function, however. Does it rebuild itself every time it's run? Why does it have to rebuild itself at all? This is the first time I've ever messed with a VGA driver's ASM code. If I can't get the code to work then maybe I could use a different driver with less tiles, but it would have to be scrolling and that would be a mess.
  • kwinnkwinn Posts: 8,697
    edited 2011-06-18 21:13
    Electrodude, I have attached a copy of VGA_Hi_Res_Text with a bunch of added comments from when I was trying to modify it for something else. Eventually I realized I could not accomplish what I wanted to do and abandoned the effort. The added comments may be of help.

    What I can tell you is that the first thing the PASM program does is to relocate itself to the highest area of the cog ram and then writes a group of "waitvid x,scanbuff+0" and "shr scanbuff+0,#8" instructions to the low memory addresses of the cog. The number of instructions is the same as the number of columns. The two cogs are synchronized. While one is creating the next scan line the other one is displaying the scan line it already created. I am not sure it would be possible to synchronize cogs so that one could produce the first half of a scan line and the other one the last half of the scan line. I have a feeling you would end up with an artifact down the center of the display.
  • kwinnkwinn Posts: 8,697
    edited 2011-06-18 21:15
    Oops forgot the attachment.
  • ElectrodudeElectrodude Posts: 1,665
    edited 2011-06-20 08:00
    Thanks. I usually can't understand self-modifying code, but those added comments cleared everything up for me. I want to make each cog do 2 lines at a time, not half.
  • ElectrodudeElectrodude Posts: 1,665
    edited 2011-06-21 07:38
    Would it be easier if I started with a 4 cog, 4 color per tile, tile driver and made the tiles 8x12 pixels instead of 16x16?
Sign In or Register to comment.