Jump to content



Photo
- - - - -

how would you script a long text on dmd that has to scroll all the way


  • Please log in to reply
6 replies to this topic

#1 dejanne

dejanne

    Hobbyist

  • Members
  • PipPip
  • 36 posts

  • Flag: Belgium

  • Favorite Pinball: indiana jones-road girls

Posted 03 January 2012 - 06:44 PM

the normal scroll stops at the beginning of the screen but it has to keep going so all the words follow each other and the dmd ends in a black screen or maybe followed by the ten high scores
the line would be: free game offered by l.s. bedding group
then followed by the high scores and then push start button or something..


#2 Mystman

Mystman

    Enthusiast

  • Members
  • PipPipPip
  • 93 posts

  • Flag: Netherlands

  • Favorite Pinball: Sonic 2

Posted 04 January 2012 - 11:13 AM

I once wrote something like that, but it might not be the most simple, userfriendly, or even the best way to get the desired result.

When you set the text of a segment display via segdisplay.Text = "Some text", and set the display to AlignLeft, it will show only show the first characters of the string. Say that our display is only 6 segments long, it will display "Some t".

My approach was to use a timer, and whenever the timer expires, remove the first character from the string. So then you get..

"ome te"
"me tex"
"e text"

Then, when you know that there are no more "hidden" characters at the end of the string, you can add some more text to the back of the string. That way, you can keep the thing scrolling for the duration of the entire game (or however long you want), and it will constantly get updated text. A further specific thing is that punctuation doesn't take any space on a segment display, so if you remove the first character and it's a comma, the scrolling effect seems to "pause". So you should also just throw away punctuation as soon as it becomes the first character in the string.

Anyway. My implementation requires a few parts:
1. A segment display set to "AlignLeft" with 20 digits (you can use a different size, but then you should replace the "20" in the script below). I called it iHSD_Seg (for i High Score Display_segment. I have no idea what the i stands for).
2. A timer that I called iHSD_Timer, with an interval of 200 milliseconds. This determines the scrolling speed. Smaller interval = faster scrolling.
3. In your script, a global variable iHSD. This is used to cycle through the kind of stuff that you want to show. In my case, if iHSD = 0, I show some text, and if it's 1-10, I show the highscore for the corresponding position.
4. In your script, a global variable iHSD_CurText. This is the current text loaded into the segment display (maybe this is redundant.. can't remember).

Then for the script itself..

CODE
sub iHSD_Timer_Expired()
    Dim CC

    if (Len(iHSD_CurText) - 20) <= 2 then 'If there are no "hidden" characters left, add new text.
      if iHSD = 0 then
         iHSD_CurText = iHSD_CurText & "HighScores -- " 'use any text that you want to precede the list of scores
      else
            iHSD_CurText = iHSD_CurText & iHSD & "; " & Replace(nvHighScoreName(iHSD), ".", "") & " " & FormatScore(nvHighScore(iHSD)) & " - " 'you can change this to change the display style of the scores
      end if

        iHSD = (iHSD+1) mod 11    'cycle through text to be displayed next time

        if nvHighScore(iHSD)= 0 then 'if next position in highscore table is empty, go back to the start
         iHSD = 0
        end if
    end if

    iHSD_CurText = Mid(iHSD_CurText, 2) 'Throw away the first character

    CC = Asc(iHSD_CurText)
    if(CC = 46 OR CC = 59 OR CC = 44) then 'If new first character is , or . also throw it away.
        iHSD_CurText = Mid(iHSD_CurText, 2)
    end if

    iHSD_seg.Text = iHSD_CurText 'Actually display our text on the segment display
end sub

sub iHSD_reset()
    iHSD_Timer.enabled = true
    iHSD=0
    iHSD_CurText = "                    "
end sub


To start the scrolling behavior, call iHDS_reset(). To stop it, stop the timer.

#3 dejanne

dejanne

    Hobbyist

  • Members
  • PipPip
  • 36 posts

  • Flag: Belgium

  • Favorite Pinball: indiana jones-road girls

Posted 04 January 2012 - 05:59 PM

that's a whole sandwich man :-) i never thougt it would be that complicated
but anyway, i'm goiing to fire up fp and see how it go's!
thx alot!


#4 Glxb

Glxb

    Enthusiast

  • VIP
  • 385 posts

  • Flag: ---------

  • Favorite Pinball: The Addams Family



Posted 05 January 2012 - 10:01 AM

I've never used it myself, but do a search in the help file for dmd and look at the bit about queuetext.
There is some scrolling stuff in there, you would just need to break it up into chunks in a queue.

GLXB
Follow me on twitter. @GLXB

#5 Mystman

Mystman

    Enthusiast

  • Members
  • PipPipPip
  • 93 posts

  • Flag: Netherlands

  • Favorite Pinball: Sonic 2

Posted 05 January 2012 - 11:52 AM

Ah... the opening post specified dmd, not segment display... my bad coffee1.gif

#6 dejanne

dejanne

    Hobbyist

  • Members
  • PipPip
  • 36 posts

  • Flag: Belgium

  • Favorite Pinball: indiana jones-road girls

Posted 06 January 2012 - 05:45 AM

pfff, tried like everything but nothing seems the give a perfect result, the best was to cut the line in pieces(mostly three words) but there were sometimes alot of spaces between the pieces
and i looked a bit around on other tables with dmd but i haven't seen one who uses this kind of feature, i think it's strange the makers of fp didn't give this a standard scriptingline..

#7 Sebek74

Sebek74

    Enthusiast

  • Members
  • PipPipPip
  • 114 posts
  • Location:Lodz, Poland

  • Flag: Poland

  • Favorite Pinball: Pinball Dreams: Ignition

Posted 07 July 2012 - 09:47 AM

Hi

The QueueText function with scrolling swithces is the basic solution that can work for you. However it's not suffcient if you want to roll the longer text. QueueText can be also to scroll the text pixel by pixel but it's also limited because it has also limitation in queue lenght.

I can describe how I'm doing this in my tables.
You need one timer object (MyTimer) and some extra routine that can count the width of the whole text (stored in myText variable) in pixels. Let's assume you are using 128x32 DMD.
1. Add extra variable ("Dim scrollPos" or use MyTimer.UserData for that) and set it to 128.
2. Launch the timer (MyTimer.Set TRUE, 20), 20 means the scroll speed, the higher value, the slower speed.
3. In MyTimer_Expired body display the whole text at proper position with simple Text function:
MyDmd.Text = "[f1][yc][x" & scrollPos & "]" & myText
then advance the scroll postion (scrollPos = scrollPos-1)
4. Notice that if scrollPos reaches negative values only the middle part of the text if displayed. Now you need to figure out when the scrolling is completed (how low need to be scrollPos to hide the all text). You can make it with try & fail method or write the special function for your font that counts the text width in pixel character by character (notice that in some fonts some character width can be narrower than others f.e. I vs W.
5. When scrollPos reaches the position -TextLen(myText) the timer need to be stopped (MyTimer.Enabled=FALSE) and you need to call another subroutine that handles your dmd.
Here is the sample:

CODE
MyDmd.AddFont 1, "dmd09x15po"
MyDmdMainRoutine()


Dim scrollPos, scrollText

Function TextLen(text)
    TextLen = Len(text)*9

End Function

Sub ScrollMe(text)
    scrollPos = 128
    scrollText = text
    MyTimer.Set TRUE, 30
End Sub

Sub MyTimer_Expired()
    MyDmd.Text = "[f1][yc][x" & scrollPos & "]" & scrollText
    scrollPos = scrollPos - 1
    if scrollPos<-TextLen(scrollText) then
        MyTimer.Enabled = FALSE
        MyDmdMainRoutine()
    end if
End Sub

Sub MyDmdMainRoutine()
    ScrollMe "MY SCROLLING SAMPLE BLAH BLAH BLAH, ANOTHER PART OF TEXT"
End Sub


The scroll should work fine however you can observe the jerk when scrollPos reaches -1. It's FP problem and if anyone is interested in I can modify the sample to avoid that.
Sebek74
Visit http://futurepinball.mm.com.pl/ for my tables download: Ignition, Beat-Box, Nightmare, Billion Dollar Gameshow, Wild West
http://futurepinball...om.pl/Gfx2DmdF/ for Gfx2DmdF font conversion
http://picasaweb.google.com/sebek74 - personal photo gallery