Shop OBEX P1 Docs P2 Docs Learn Events
TV_Text .str - ASCII values within the STRING() function — Parallax Forums

TV_Text .str - ASCII values within the STRING() function

John KauffmanJohn Kauffman Posts: 653
edited 2012-01-08 15:45 in Propeller 1
I’m having a hard time understanding the parameters in the STRING() function as used with the TV_Text object.str method.

In the example from TV_Text_Demo there is a line as follows where "text" is the name of the instantiation of the TV_Text object.

text.str(STRING(13," TV Text Demo...",13,13,$C,5," OBJ and VAR require only 2.8KB ",$C,1))

which produces a white on blue first message and then a blue on green message followed by a CR. Analyzing the argument for STRING() I get:

13 is the cr prior to the text
“ “ The text
13,13 two cr
$C ?
5 ?
“ “ second string of text
$C ?
1 ?

Some experimenting yields changes in color with changes in the $C and 5. I see the color palette listed in the DAT section of TV_text but I don’t see the correlation to $C or 5 in the list. I have tried to trace this back through the TV_Text.str and then to TV_Text.out and the TV_Text.print, but have not found an explanatory comment.


Q1: Why two number systems?
Why use hex for $C and dec for 5? I see $C can be replaced by 12 and it works. The 5 can be replaced with a $05 and the result is the same. Why not provide both values in the same number system?

Q2 ASCII format code versus color
Why does the TV_Text.str interpret $C (=12) as a color code? Why does it not interpret it as the ASCII format code 12 which is “paper feed”? That would be consistent with a code of 13 = ASCII format code for CR.

Q3 Palette values
I see the palette chart in the DAT of TV_Text but there is no entry for $C or 5 (although 5 is mentioned in the comments). Here is a section as an example
DAT
' fore back
' color color
palette byte $07, $0A '0 white / dark blue
byte $3D, $3B '4 cyan / dark cyan
byte $6B, $6E '5 green / gray-green
byte $BB, $CE '6 red / pink

Q4: order of arguments
How does the TV_Text know which argument is for foreground color and which for background color?

Much Thanks.

Comments

  • KaloKalo Posts: 5
    edited 2012-01-08 15:45
    "Some experimenting yields changes in color with changes in the $C and 5. I see the color palette listed in the DAT section of TV_text but I don’t see the correlation to $C or 5 in the list."

    Right idea, wrong listing. Scroll up a bit until you get the the 'PUB out' method. There you will find $C is a sort of preparatory command, informing the Prop that color is about to be set for the text field that follows. The '5' comes from the DAT table labeled 'palette'.

    1) The 2 number systems, I'm guessing, is for code readability. No need to count the commas if the function can be determined without extreme scrutiny, yes?

    2) Well, it doesn't. I can see how you might think it did with fairly random substitution examinations, but this is actually a defined 'binding key' in this case.

    3) Yeah... once you've told the Prop there is a palette designation on the way, this listing is used to determine which selection is desired by referencing '5' against the presets in this list.

    4) They are pre-arranged in this program and can only be called in designated pairs via the decimal value that follows a '$C. This designates the fore/background palette choices for the text field to come.

    HTH.

    -K
Sign In or Register to comment.