In SX Microcontrollers, SX/B Compiler and SX-Key Tool, JonnyMac wrote: After spending some time with David's code I was able to get the text scrolling algorithm straight (in my own head) and add it to my version of the program. This version supports characters from $20 (space) to $FF (arrow; non-ASCII), and will scroll text left or right. The character maps for $20 to $7F are store in contiguous DATA statements which makes access of this data quite straightforward. The program uses current SX/B standards encapsulating features into subroutines so they can be used very easy. The text scrolling routines, SCROLL_LF and SCROLL_RT, can use inline strings or strings stored in a DATA statement. If the DATA statement is used then you can embed a bell character (#7) into the string and the beeper will beep at that point while retrieving the next character. You can also embed a CLS (#12) character into the string. Scrolling speed is controlled with a variable so you can adjust this parameter before putting text on the screen. This version of the program takes advantage of a subtle feature in SX/B: you can pass five parameters to a subroutine (or function) -- yes, five. To do this, however, you must pass exactly five (and the SUB or FUNC has to be defined that way). When this is the case the register that usually holds the parameter count (__PARAMCNT) is used as the fifth parameter (it is also aliased as __PARAM5). Here's how I use it in this program to play a set of animation frames: [code]' Use: PLAY_FRAMES Label, FrameCount, FrameTiming, Loops ' -- displays animation frames at "Label" ' -- "FrameCount" is number of 15-column frames in animation ' -- "FrameTiming" is display time for frame in milliseconds ' -- "Loops" is number of times to play frames sequence SUB PLAY_FRAMES tmpW2 = __WPARAM12 ' address of first frame tmpB1 = __PARAM3 ' number of frames tmpB2 = __PARAM4 ' delay between frames tmpB3 = __PARAM5 ' animation loops DO WHILE tmpB3 > 0 ' any loops left? tmpW3 = tmpW2 ' point to first frame tmpB4 = tmpB1 ' copy frame count DO WHILE tmpB4 > 0 FOR tmpB5 = 0 TO 14 ' grab a frame READINC tmpW3, dispBuf(tmpB5) ' move frame to display NEXT DELAY_MS tmpB2 ' hold DEC tmpB4 ' move to next frame LOOP DEC tmpB3 ' update loop count LOOP ENDSUB[/code] ---------- End of Message ---------- You can view the post on-line at: http://forums.parallax.com/forums/default.aspx?f=7&p=1&m=198932#m199577 Need assistance? Send an email to the Forum Administrator at forumadmin@parallax.com The Parallax Forums are powered by dotNetBB Forums, copyright 2002-2007 (http://www.dotNetBB.com)