|
Forum Index : Microcontroller and PC projects : How can one implement a scrolling subwindow cleanly?
| Author | Message | ||||
| William Leue Guru Joined: 03/07/2020 Location: United StatesPosts: 405 |
I have wanted to be able to locate a scrolling subwindow anywhere on the screen that is otherwise occupied with graphics or something else that does NOT scroll. I have had a little success when splitting the screen into two pieces that sit side by side using something like this: sub PrintMsg msg$ page write 2 sprite scrollr MSGX, MSGY, MSGW, MSGH, 0, SCRL, RGB(BLACK) text MSGX, 500, msg$ 'print msg$ page write 0 blit MSGX, MSGY, MSGX, MSGY, MSGW, MSGH, 2 end sub Unfortunately, this does not work if I want to locate some fixed graphics ABOVE the scrolling box; the graphics scrolls vertically right along with the text, even though the graphics are outside of the bounding box defined by the scrollr method. Does anyone have a clue how to implement this sort of thing correctly? Thanks! -Bill |
||||
| berighteous Senior Member Joined: 18/07/2020 Location: United StatesPosts: 110 |
why dont you draw the text in a tall thin framebuffer and then blit a moving "window"from that to a stationary place on page 0? Should be dead simple to set up. |
||||
| berighteous Senior Member Joined: 18/07/2020 Location: United StatesPosts: 110 |
You gave me an idea to scroll text over the asteroids and whatall in the game I'm working on, OidZone. I was overlaying text on top of the frame before but now I scroll the text onscreen and up to it's position ![]() YouTube Link to video of scrolling text I pre-draw the text on page 23 (in mode 3,8) Then to scroll it on screen I use the frame counter to control the scroll it from frame 200 to frame 390 and then hold it after frame 390 if j>200 and j<390 then blit 0,0,0,400-j,320,j-200,23,&b100 else if j=> 350 then blit 0,0,0,10,320,190,23,&b100 end if: end if so it copies the data from 0,0 width 320 height from 1 to 190 increasing each frame to frame 390, to in this case page 8 at 0,400-j so 199 to 10 going up to line 10. The &b100 masks out the masking color on the blit. I'm using my own font and font draw code. Edited 2020-08-21 06:27 by berighteous |
||||
| capsikin Guru Joined: 30/06/2020 Location: AustraliaPosts: 342 |
berighteous has suggested another way to do it. I can't see any errors in your code. You may have found a bug. Do you know what version firmware you are running? I'm thinking I should be able to do something like with your sub: input "Press enter to start";answer$ ' ignore answer$ circle 100,100,10 ' x=100, y=100, radius 10 MSGX=20 MSGY=120 MSGW=160 MSGH=70 SCRL=20 pause 1000 PrintMsg "Scroll test" pause 1000 PrintMsg "did the circle move?" pause 1000 PrintMsg "It shouldn't" I might try it later. |
||||
| matherp Guru Joined: 11/12/2012 Location: United KingdomPosts: 10582 |
If someone can produce a runnable code sample that demonstrates a bug I can look at it but the above gives me nothing to go on. |
||||
| capsikin Guru Joined: 30/06/2020 Location: AustraliaPosts: 342 |
Okay I can do this later, if Bill or someone else doesn't get to it first. |
||||
| capsikin Guru Joined: 30/06/2020 Location: AustraliaPosts: 342 |
If someone can produce a runnable code sample that demonstrates a bug I can look at it but the above gives me nothing to go on. Okay I can do this later, if Bill or someone else doesn't get to it first. No bug found by my test, my code below behaves correctly on my CMM2. (it was also correct when I drew everything on page 2 and used a page copy instead of blit) The text scrolls, while the circles to the left, right, top and bottom of the scrolling area stay in place. Bill, here's an example of scrolling a text window without affecting things outside it. sub PrintMsg msg$ page write 2 sprite scrollr MSGX, MSGY, MSGW, MSGH, 0, SCRL, RGB(BLACK) text MSGX, 500, msg$ 'print msg$ page write 0 blit MSGX, MSGY, MSGX, MSGY, MSGW, MSGH, 2 end sub page write 2:cls page write 0:cls input "Press enter to start";answer$ ' ignore answer$ circle 100,100,10 ' x=100, y=100, radius 10 circle 100,585,10 circle 10,300,5 circle 190,300,5 'message area, X from 20 to 179, Y from 120 to 569 'circles are outside this area. MSGX=20 MSGY=120 MSGW=160 MSGH=450 SCRL=20 do pause 1000 PrintMsg "Scroll test" pause 1000 PrintMsg "did the circle move?" pause 1000 PrintMsg "It shouldn't" loop |
||||
| The Back Shed's forum code is written, and hosted, in Australia. | © JAQ Software 2025 |