Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 15:22 14 Nov 2025 Privacy Policy
Jump to

Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.

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 States
Posts: 405
Posted: 06:56pm 20 Aug 2020
Copy link to clipboard 
Print this post

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 States
Posts: 110
Posted: 07:31pm 20 Aug 2020
Copy link to clipboard 
Print this post

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 States
Posts: 110
Posted: 08:17pm 20 Aug 2020
Copy link to clipboard 
Print this post

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: Australia
Posts: 342
Posted: 01:34am 21 Aug 2020
Copy link to clipboard 
Print this post

  William Leue said  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 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 Kingdom
Posts: 10580
Posted: 07:02am 21 Aug 2020
Copy link to clipboard 
Print this post

  Quote  I can't see any errors in your code. You may have found a bug. Do you know what version firmware you are running?


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: Australia
Posts: 342
Posted: 07:26am 21 Aug 2020
Copy link to clipboard 
Print this post

  matherp said  
  Quote  I can't see any errors in your code. You may have found a bug. Do you know what version firmware you are running?


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.
 
capsikin
Guru

Joined: 30/06/2020
Location: Australia
Posts: 342
Posted: 01:55pm 21 Aug 2020
Copy link to clipboard 
Print this post

  capsikin said  
  matherp said  
  Quote  I can't see any errors in your code. You may have found a bug. Do you know what version firmware you are running?


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

 
Print this page


To reply to this topic, you need to log in.

The Back Shed's forum code is written, and hosted, in Australia.
© JAQ Software 2025