Shop OBEX P1 Docs P2 Docs Learn Events
Vga.text - displaying a pattern from DAT array — Parallax Forums

Vga.text - displaying a pattern from DAT array

John KauffmanJohn Kauffman Posts: 653
edited 2010-11-23 07:50 in Propeller 1
Using VGA_Text, I can't seem to display a pattern the way I expect. The series of dots and characters is stored in a DAT array. I think comments in the code below describe the problem.
Thanks.


{{ create the following shape to VGA - should look like two circles of # characters. Eventually dots will be replaced by spaces; dots are easier to see in debug

    .##...##
    #..#.#..#
    #..#.#..#
    .##...## 

The definitions / variables I set up, but I may be on the wrong track
        'row' = always 4, 0 at top, row 3 at bottom
        'section' is a group of dots between #. Sections are numbered from left to right.
                there are from 0 to 3 dots in a section
                There are four sections per row:
                  left of left circle, middle of left circle,
                  left of right circle, middle of right circle
                each section is followed by a # character (always four # per row)
                In graphic above, row 0 sections hold following number of dots: 1,0,3,0
The problem seems to me to get the right number of dots in each section
Since I could not think of an algorithm to determine number of dots, I made an array with the right number of dots per section in DAT.
}}

CON
  _CLKMODE = XTAL1 + PLL16X
  _XINFREQ = 5_000_000
VAR
  byte CountSection    ' count sections: 0 to left of left circ, 1 inside left circle, 2 between circles, 3 inside right circle
  byte CountDots       ' count of loop to put dots in a section 
OBJ
 VgaText  :  "VGA_Text.spin"
PUB Start
VgaText.Start(16)
' n.b. - since row0 is not working, I did nto continue to next rows 
'row 0                                                                  ' first row
repeat CountSection from 0 to 3                                         ' Process one section per loop
   repeat CountDots from 0 to byte[@Row0SectionSize[CountSection]]      ' Process one dot per loop. Get dot count from DAT
     vgatext.str(STRING("."))                                                   ' write the dot
  vgatext.str(STRING("#"))                                              ' add # at end of section
vgatext.out(13)                                                         ' end row

' I expected above code to produce:
'    .##...##
' but above code puts out:
'    ..#.#....#.#
DAT
        Row0SectionSize     byte    1,0,3,0     '   .##...##
        Row1SectionSize     byte    0,2,1,2     '   #..#.#..#
        Row2SectionSize     byte    0,2,1,2     '   #..#.#..#
        Row3SectionSize     byte    1,0,3,0     '   .##...## 

Comments

  • ColeyColey Posts: 1,112
    edited 2010-11-22 23:57
    Hi John,

    Your counting from 0 to number of dots so when you put a 1 in the array you are actually doing it twice (from 0 to 1) either count from 1 to number of dots or reduce the number in the array by 1.
    You might also want to consider a check for 0 to do nothing.....

    I hope that helps.

    Regards,

    Coley
  • John KauffmanJohn Kauffman Posts: 653
    edited 2010-11-23 07:50
    The problem was solved by adding a check for a zero coming out of the DAT read.
    Much thanks.
Sign In or Register to comment.