PDA

View Full Version : Special effects



Newzed
10-18-2006, 05:25 AM
Mike, is there any way to "blink" a word - for instance the "Select" that follows the Menu display?

Sid

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Sid Weaver
Don't have VGA?

Newzed@aol.com (mailto:Module?Newzed@aol.com)
ˇ

Mike Green
10-18-2006, 05:36 AM
Sid,
There's currently no nice neat way to do this. What you could do is assign a color number to the Menu text that's different from the default (say color #3) and make it the same colors as the default. Set up a cog that just sits in a REPEAT loop with a WAITCNT for a pause of maybe 1/2 second, then just swap the foreground and background colors for the blink color in the color table. That would invert the colors every 1/2 second of every character using that color number.

I'm currently working on changes to the TV and lores VGA drivers to support cursors and will probably do it this way (but integrate it into the drivers). I haven't decided what to do with the hires VGA driver since it already has cursors, but not a blink mode.
Mike

Newzed
10-18-2006, 06:43 AM
Mike, I wrote:

PUB blink
ˇ repeat 5
ˇˇˇ text.str(string(19,30,240,10,"Select"))
ˇˇˇ waitcnt(clkfreq/2 + cnt)
ˇˇˇ text.str(string(19,30,240,10," "))
ˇˇˇ waitcnt(clkfreq/2 + cnt)
ˇˇˇ text.str(string(19,30,62,10,"Select"))
ˇˇˇ waitcnt(clkfreq/2 + cnt)
ˇˇˇ text.str(string(19,30,240,10," "))
ˇˇˇ waitcnt(clkfreq/2 + cnt)ˇˇˇˇˇˇˇˇˇˇˇˇˇˇ

Select changed colors every 1/2 second but it printed a new Select -ˇ I would up with 10!ˇ How can I make it display at the same X-Y position so I don't get duplicate words?

Sid

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Sid Weaver
Don't have VGA?

Newzed@aol.com (mailto:Module?Newzed@aol.com)
ˇ

Mike Green
10-18-2006, 07:01 AM
Sid,
I'm assuming that you're using the hires VGA text routines. Colors work a bit differently in the TV and lowres VGA text routines. For the hires ones, each line on the display has a foreground and background color associated with it. When you change a line's colors, the whole line changes regardless of the text on the line. You don't have to rewrite the text on the line to change the colors, just change the colors associated with the whole line. In addition, to make the text on a line disappear, just make the foreground and background colors the same. You don't have to replace the word "Select" with a blank (unless you have other text on the line that you want to display).

There are display commands "MoveX", "MoveY", and "MoveXY" that you can use to reposition to a specific place on the screen. Look at the comments in the display routines for the numeric values. You can also use "text#MoveXY" or "text#SetColor" if you want to use the actual names (for clarity).

Newzed
10-18-2006, 07:21 AM
OK, Mike - I've got Select changing colors but staying in the same place.ˇ Now last question - I wrote repeat 5 and that's what is does.ˇ However, I would like for it to jump to the getchoice method when I press a key.ˇ I wrote:

repeat until key.getkey

but then it doesn't change color and it takesˇa key stroke to get to getchoice.ˇ Is there any way for it to keep changing colors until I press a key, and then go directly to the desired method?

Sid



▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Sid Weaver
Don't have VGA?

Newzed@aol.com (mailto:Module?Newzed@aol.com)
ˇ

Mike Green
10-18-2006, 09:07 AM
Try:



repeat until code := key.key
' blink stuff
case code
"x": ...
"y": ...

Tom Walker
10-18-2006, 08:07 PM
Does key.key return, essentially, a FALSE value (don't have code in front of me) when nothing is available? If not, then == is probably called for instead of :=.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Truly Understand the Fundamentals and the Path will be so much easier...

Newzed
10-18-2006, 08:35 PM
Mike, I tried your bit of code and I just couldn't get it to work right.ˇ Then I moved the blink method into getchoice:

PRI getChoice : selectedOption
{ Accept menu choice. Returns uppercase letter. }
ˇ 'key.clearkeys
ˇ repeat until code := key.key
ˇ 'blink stuff
ˇ repeat
ˇˇˇ selectedOption :=ˇkey.getkey
ˇˇˇ if (selectedOption => "a") and (selectedOption =<"z")
ˇˇˇˇˇˇ selectedOption -= ("a" - "A")
until (lookdown (selectedOption : "ABCDEFOQGTPRSMWX"))

It worked but I had to hit the key I wanted twice.ˇ So then I changed

selectedOption :=ˇcode

and everything worked with only one key press!ˇ There was an appreciable delay between the time I pressed the key and the action was performed, so in the blink section I changed:

waitcnt(clkfreq/2+ cnt)

to

waitcnt(clkfreq/4 + cnt)

and that helped things considerably.ˇ Thanks a lot for the code bithttp://forums.parallax.com/images/smilies/yeah.gif

Sid

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Sid Weaver
Don't have VGA?

Newzed@aol.com (mailto:Module?Newzed@aol.com)
ˇ

Mike Green
10-18-2006, 09:03 PM
Tom and Sid,
"key.key" returns a zero if there's no keyboard key to return. It returns the character code if there is one. Sid's routine should look like



PRI getChoice : selectedOption
{ Accept menu choice. Returns uppercase letter. }
'key.clearkeys
repeat
repeat until selectedOption := key.key
'blink stuff
if (selectedOption => "a") and (selectedOption =<"z")
selectedOption -= ("a" - "A")
until (lookdown (selectedOption : "ABCDEFOQGTPRSMWX"))



The "repeat until selectedOption := key.key" is correct. It gets the current key (or zero) and saves it as "selectedOption". The "repeat until", like ALL Boolean operations, treats a non-zero value as TRUE, so the repeat statement repeats (and blinks the menu item) as long as no key is pressed. Once a key is pressed, it exits the repeat loop (after the last blink is done), checks "selectedOption" for validity, and returns to the caller if the entered code is valid (otherwise goes back to wait for another keypress).

I've left Sid's test for validity even though it's not complete. If the user were to enter control codes (using the control shift key), they could end up in the same range (0 to whatever) and falsely be accepted by the lookdown statement. In practice, this will work, but I wouldn't use it for some other project where the general public or children were going to use it.

Post Edited (Mike Green) : 10/18/2006 2:08:22 PM GMT