|
Post by Tom Maneiro on Dec 26, 2004 10:48:31 GMT -5
How i can made a scrolling text like these present in most demos? I am trying to make a sort-of x-mas demo (yes, a litte late), but i am stuck with the scrolling thing.
|
|
oompa loompa
I AM THE GOVERNATOR
"Git 'Er Dun!"
Posts: 1,301
|
Post by oompa loompa on Jan 4, 2005 19:41:26 GMT -5
okay =)
first you need to set which scroll plane you want to scroll. There's plane A, which is on top of plane B (plane A has higher priority). To set the scrolling plane, use the command SETSCROLLPLANE followed by SCROLL_A or SCROLL_B.
next, you need to know how you want to scroll that plane, ehere horizontally, or vertically, you need to tell the compiler how much. Use the command: SETSCROLL MODE. This is the syntax: SetScrollMode <HSCROLL_OVERALL/HSCROLL_CELL/HSCROLL_LINE>, <VSCROLL_OVERALL/VSCROLL_2CELL>. The first argument sets the mode for scrolling in the horizontal direction (left-right). HSCROLL_OVERALL = make the entire screen scroll all at once. HSCROLL_CELL = Make each cell scroll by a certain amount of pixels (there are more than 1 cells). HSCROLL_LINE = Make each line scroll. The cell and line are specified in another command, SCROLL or SCROLL2. VSCROLL_OVERALL and VSCROLL_2CELL are the same as above, except it scrolls up-down, and VSCROLL_2CELL scrolls 2 cells at once, instead of 1 like HSCROLL.
next, you use the SCROLL or SCROLL2 command. SCROLL shifts the screen relative to the its old scroll value. SCROLL2 shifts the screen absolute. Entry is the cell, or line in which you want to scroll
To make a marquee, you just scroll the screen in whatever direction, and when you hit 8 pixels, you load your character into the end of the screen and you keep on shifing again
|
|
|
Post by Tom Maneiro on Jan 5, 2005 11:32:31 GMT -5
Well, sounds OK, and it can be done using Right(), but i want to use a LARGE text, like 4KB of text, so.... is there a better way for load the text?
Or simply to print it in a LOOOOOOOOOONG layer?
|
|
oompa loompa
I AM THE GOVERNATOR
"Git 'Er Dun!"
Posts: 1,301
|
Post by oompa loompa on Jan 5, 2005 14:32:07 GMT -5
you don't need to have a huge plane just to scroll text. like i said, all you need to do is draw one character screen on the undrawn part of the screen (left, right, up, etc depending on which direction you're scrolling text). Then you just scroll the screen 8 pixels. You'll immediately see your character come into view on the drawn part of the screen. Repeat this loop over again with the begining of displaying another character. To display the characters, i would just store the position of the text message in a data pointer. to read the next character, i would just use regular byte read. to display it, i would use the PUTS command. you need to store the edge position of the screen in a variable because when you scroll, the very edge of the screen address changes. make sure the address in PUTS does not exceed the size of the screen plane (64*64) or else you're going to end up writing to some other foreign address. here's how i'd do it: data "This is my text, and dont you forget about that."
' SCROLL_A because that's where we draw to, and that's where we want to scroll setscrollplane SCROLL_A ' We want to scroll the entire screen, not individual cells/lines setscrollmode HSCROLL_OVERALL, VSCROLL_OVERALL ' On reset, the very edge of the screen is X position 40 (40 cell mode) edgepos=40
' Repeat the loop forever or until an EXIT WHILE while 1 ' Read one character from out string read char ' If the character is a null (end of string) then make it a space and ' reload back to the start of the text if char=0 then reload char=&h20 endif ' Now draw the character on the non-visible part of the screen ' 5<<6+ is the same as 5 multiplied by 64 (use the PUTS formula) ' We use chr$ because the character is stored in integer puts 5<<6+edgepos, chr$(char) ' Now here's the actual scrolling part the player sees. We scroll left ' 8 times because one character is 8 pixels wide and we're scrolling one ' pixel at a time for scroll=1 to 8 ' Our delay so the scroll isn't too fast sleep 1 ' Wait for verticle blank or else the scrolling will look ' disoriented (after sleep, we are directly in the drawing ' period of the screen). Try commenting the line out and see ' what happens =P valt ' Scroll the entire screen left by one pixel scroll LEFT, 1 next ' Since we've moved 8 pixels, increase the edge address by 1 because ' scrolling the screen scrolls address positions with it (if this ' weren't to happen, there would be no such thing as a scroll) edgepos++ ' If we've past the very edge of the layer (not the screen), then set ' it back to 0 because the screen will wrap around again if edgepos=64 then edgepos=0 wend
|
|
|
Post by Tom Maneiro on Jan 5, 2005 18:47:33 GMT -5
Nice. and it works with long texts. Thanks!
But i have another question. You pointed this:
' Wait for verticle blank or else the scrolling will look ' disoriented (after sleep, we are directly in the drawing ' period of the screen). Try commenting the line out and see ' what happens =P val
I see no difference... or it is a Gens bug?
And the read command.... it reads a single char, no?
Another question: How i can play a song, and scroll text at the same time? I have composed a crappy PSG tune, but i want to know if there is a way to run the sond and the scroller in a asynchronic way, without using LOTS of If's..
|
|
oompa loompa
I AM THE GOVERNATOR
"Git 'Er Dun!"
Posts: 1,301
|
Post by oompa loompa on Jan 5, 2005 19:31:45 GMT -5
Oh, to see the effect of messing with the vdp when its drawing, change "5<<6+" to "0+". this will draw the text at the very top of the screen (right after verticle blank)
uhm, to play music at the same time, you need to make some kind of timer/counter. like for every character that scrolls by, you then play a note on the psg
|
|
|
Post by Tom Maneiro on Jan 6, 2005 17:52:28 GMT -5
|
|
oompa loompa
I AM THE GOVERNATOR
"Git 'Er Dun!"
Posts: 1,301
|
Post by oompa loompa on Jan 6, 2005 19:25:46 GMT -5
damn, that's a long scroll =D
|
|