Jump to content
IGNORED

!Looped Horizontal Scrolling


jacobus

Recommended Posts

I hope there is a quick and easy answer to this...

 

I have a fairly typical DL with LMS instructions for each line - each pointing to a separate 256 byte page - as follows (please forget fine scrolling for now)

 

...

116 5 21

116 5 22

116 5 23

...

 

I'm scrolling by manipulating the LSB of the address, and it works fine going back and forth. However, if I try to scroll left (de-incrementing the LSB) past zero the entire existing portion of the PF moves up a line when the LSB flips to 255. The "new" portion of the scrolling line stays in the correct position. At first I assumed that the MSB must be incrementing when the LSB flipped over, but that doesn't seem to happen.

 

...

116 250 21

116 250 22

116 250 23

...

 

Is there any easy way to avoid this behaviour? What is the recommended or standard way to effect this kind of scroll?

 

thank you!

 

Link to comment
Share on other sites

Without seeing the code, and I admit to not fully understanding your explanation of what's going on, maybe you are crossing a 4k boundary, or a bug in your code is trashing your display list?

 

Also, and this might be because I don't understand what you are trying to do:

 

If you have LMS lines each 256 bytes long, you are trying to scroll past 0 ? Wouldn't zero be the left edge of your screen memory, and the furthest left you can go, and 255-40 the right most edge of the screen memory? If that's the case, then I think what you need to do is load screen data in at the right edge of the screen (255-40) and then "jump" back to that location to give the impression of an endless horizontal scrolling. Could be totally wrong about what you're trying to do though!

Edited by Shawn Jefferson
  • Like 1
Link to comment
Share on other sites

Without seeing the code, and I admit to not fully understanding your explanation of what's going on, maybe you are crossing a 4k boundary, or a bug in your code is trashing your display list?

 

The 4k limit for screen RAM is not a memory boundary limit like Player/Missile or Character set data. The 4K limit is ANTIC's ability to keep auto incrementing the LMS counter on its own from mode line to mode line when there is no LMS directive on the mode lines. He's using an LMS on every line, so this is not the issue. What idiot wrote this?

 

 

If you have LMS lines each 256 bytes long, you are trying to scroll past 0 ? Wouldn't zero be the left edge of your screen memory, and the furthest left you can go, and 255-40 the right most edge of the screen memory? If that's the case, then I think what you need to do is load screen data in at the right edge of the screen (255-40) and then "jump" back to that location to give the impression of an endless horizontal scrolling. Could be totally wrong about what you're trying to do though!

 

I'm also thinking its something along those lines.

 

 

When the LMS is set to 255/21 the next byte displayed should be 0/22, then 1/22, 2/22, 3/22, etc.

 

If this is supposed to show continuous scrolling then the last 40 bytes (well, 39 bytes) of screen RAM for the line should be the same as the first bytes of screen ram so the scroll jumps from 255-39 to 0 and vice versa in the other direction.

 

(its late and I'm starting to babble. i might try hacking up a quick example tomorrow if this isn;t solved by then.)

Link to comment
Share on other sites

If you have LMS lines each 256 bytes long, you are trying to scroll past 0 ? Wouldn't zero be the left edge of your screen memory, and the furthest left you can go, and 255-40 the right most edge of the screen memory? If that's the case, then I think what you need to do is load screen data in at the right edge of the screen (255-40) and then "jump" back to that location to give the impression of an endless horizontal scrolling. Could be totally wrong about what you're trying to do though!

I assumed I would have to do that - scroll normally through memory until I hit 0/255 and then feed one column at a time from the opposite end to simulate the looped screen. However I noticed that scrolling the LSB past 0 works flawlessly except for the way the screen moves up. So, at that point I assumed that rolling the LSB over was incrementing/deincrementing the MSB and I could easily fix that. Not so unfortunately...

 

When the LMS is set to 255/21 the next byte displayed should be 0/22, then 1/22, 2/22, 3/22, etc.

Interestingly the LMS seems to count like this - 255/21 - next byte scrolled - 0/21, then 1/21, then 2/21 ...

 

 

If this is supposed to show continuous scrolling then the last 40 bytes (well, 39 bytes) of screen RAM for the line should be the same as the first bytes of screen ram so the scroll jumps from 255-39 to 0 and vice versa in the other direction.

Yeah, but I'm looking for a cheap and easy solution! ;-)

Link to comment
Share on other sites

For a looped horizontal scroll like you describe to work properly, you'd want to avoid the display crossing the page boundary.

As such, you'd want the LMS value low byte to stay well under a value of 255, in fact for a HScroll enabled 40 column mode you'd probably want it to not exceed about 208 - consider 48 bytes fetched in such modes in normal or wide width.

 

Assuming you want a smooth looping landscape, you'd want to repeat the initial screen data at the end, and if the value exceeds the threshold of ~ 208, then set it back to zero.

 

In doing this, you shouldn't need to worry about the Antic 4K problem, since you'd not even be crossing 256 byte boundaries.

  • Like 2
Link to comment
Share on other sites

The 4k limit for screen RAM is not a memory boundary limit like Player/Missile or Character set data. The 4K limit is ANTIC's ability to keep auto incrementing the LMS counter on its own from mode line to mode line when there is no LMS directive on the mode lines.

 

(its late and I'm starting to babble. i might try hacking up a quick example tomorrow if this isn;t solved by then.)

Yes, i was babbling. And nobody corrected me.

 

Did a short test (which i can post later). At the end of the last page of a 4K block Antic's fetching wraps around to the first byte in that 4K block. Which means if one wants to one can burn 4k of data for per horizontal scrolling line and not stop the lms at byte 216 on the last page because antic will automatically wrap to the start of the 4k block.

 

And of course where the 4K boundary is not present antic goes from 256 byte page to the next page automatically. E.g from (page/byte) 33/255 to 34/0.

Link to comment
Share on other sites

For a looped horizontal scroll like you describe to work properly, you'd want to avoid the display crossing the page boundary.

As such, you'd want the LMS value low byte to stay well under a value of 255, in fact for a HScroll enabled 40 column mode you'd probably want it to not exceed about 208 - consider 48 bytes fetched in such modes in normal or wide width.

 

Assuming you want a smooth looping landscape, you'd want to repeat the initial screen data at the end, and if the value exceeds the threshold of ~ 208, then set it back to zero.

 

In doing this, you shouldn't need to worry about the Antic 4K problem, since you'd not even be crossing 256 byte boundaries.

Thank you Rybags - dropping the value to just over 200 seems to do the trick - thanks very much!

Link to comment
Share on other sites

Just for reference. . . . .

 

The example is BASIC XL (because this thing Dpoke's like there's no tomorrow.) The test runs on Altirra. Hardcoded addresses mean minium of 40K is required. Uses joystick.

 

The string in line 23 contains bytes for screen codes that do not copy well to the web. The "PQR...XY" should be changed to "ctrl-P, ctrl-Q, ctrl-R ... ctrl-X, ctrl-Y." Do NOT change the "abcdef".

 

This sets up 4 horizontal scrolling lines on a Graphics mode 0 (antic 2) display pulling the data for the scrolling lines from other 256 byte blocks in memory.

 

The scrolling lines are populated to show the relative position in each page. The first two lines show the values 00 to FF in ascending order, and the last two lines show the positions from FF to 00 descending. The last 39 bytes of each line are in inverse video to show the data that should mirror the start of the line in order to present continuous scrolling.

 

Use the joystick to scroll left and right. The program automatically handles the correct jump (for coarse scrolling 40 characters) from 0 to 216. However, holding the trigger down will cause it to skip that check allowing the scroll to move through positions 217 to 255 to see the effect.

 

The second scrolling line on screen is the last page of a 4K block ($8f00). Bypassing the scroll limiter will show that at the end of the line ANTIC wraps around to show the bytes in the first page of that 4K block ($8000). When the scroll limiter is bypassed the other lines show ANTIC continues reading sequentially; crossing from the end of one page into the start of the next page.

.

10 Rem SAVE "H1:TESTSCR.BXL"
11 Graphics 0
12 Dpoke 709,$900a:Poke 752,1:Poke 82,0
13 Poke 559,0:Dl=Dpeek(560)
14 Rem MOVE TO MAKE SPACE, REWRITE DL
15 Move Dl,Dl-10,20:Dl=Dl-10
16   For I=11 To 23 Step 3:Poke Dl+I,$42:Next I
17 Rem LMS ADDRESS ASSIGNMENTS
18 Dpoke Dl+12,$8e00:Dpoke Dl+15,$8f00
19 Dpoke Dl+18,$9000:Dpoke Dl+21,$9100
20 Dpoke Dl+24,Dpeek(Dl+4)+400
21 Dpoke 560,Dl:Poke 559,34
22 Rem STUFF HEX LABELS IN SCROLLER
23 N$="PQRSTUVWXYabcdef":N=Adr(N$): Rem P to Y are Ctrl-P, Ctrl-Q ... Ctrl-Y
24   For H=0 To 15:I=H*16:Hb=Peek(N+H)
25     For L=0 To 15:Lb=Peek(N+L)
26     Poke $8e00+I+L,Hb
27     Poke $8f00+I+L,Lb
28     Poke $90ff-(I+L),Hb
29     Poke $91ff-(I+L),Lb
30     Next L:Next H
31 Rem REVERSE VIDEO LAST 39 BYTES
32   For L=0 To 38
33   Poke $8eff-L,Peek($8eff-L)+$80
34   Poke $8fff-L,Peek($8fff-L)+$80
35   Poke $90ff-L,Peek($90ff-L)+$80
36   Poke $91ff-L,Peek($91ff-L)+$80
37   Next L
38 Rem FOR 4K TEST, DATA IN 1ST PAGE
39   For I=0 To 48 Step 2:Dpoke $8000+I,$2b14:Next I
40 Rem USER INPUT SETUP
41 X=0:Dim D$(11)=Adr(D$)
42 Move Dl+12,D,11
43 Rem INPUT LOOP
44 X=X+Hstick(0):T=Strig(0):Poke 77,0
45   If X<0:Rem ROLL OFF MIN
46     If T=1:X=$d8:Else =$ff:Endif
47   Endif
48   If X>$d8:Rem ROLL OFF MAX?
49     If T=1:X=$00:Endif
50   Endif
51 If X>$ff Then X=0
52 Rem UPDATE DL LMS
53 Poke D,X:Poke D+3,X
54 Poke D+6,X:Poke D+9,X
55 Move D,Dl+12,11
56 Position 0,0:? "Horiz Scroll Test X == ";Hex$(X);" = ";X;"  ";
57 Goto 44

.

The first picture shows the display at position 0. The second shows the scroll at position 216. The last picture shows what happens when the scroll limiter is bypassed and ANTIC crosses from page to page. In the case of the second line it wraps around in the 4K block.

.

(FYI: Modified to fill the start of the first 4K page with the text "4K".)

post-32235-0-34257600-1424827559_thumb.png

post-32235-0-05069800-1424827574_thumb.png

post-32235-0-37630000-1424908275_thumb.png

  • Like 2
Link to comment
Share on other sites

And it depends on what you actually need. How much do you need to scroll, how much memory you have free, if you are drawing the "level" on the fly or want to have it prepared beforehand etc. For every situation there is different solution which should fit best.

Link to comment
Share on other sites

Just for reference. . . . .

 

The example is BASIC XL (because this thing Dpoke's like there's no tomorrow.) The test runs on Altirra. Hardcoded addresses mean minium of 40K is required. Uses joystick.

 

The string in line 23 contains bytes for screen codes that do not copy well to the web. The "PQR...XY" should be changed to "ctrl-P, ctrl-Q, ctrl-R ... ctrl-X, ctrl-Y." Do NOT change the "abcdef".

 

This sets up 4 horizontal scrolling lines on a Graphics mode 0 (antic 2) display pulling the data for the scrolling lines from other 256 byte blocks in memory.

 

The scrolling lines are populated to show the relative position in each page. The first two lines show the values 00 to FF in ascending order, and the last two lines show the positions from FF to 00 descending. The last 39 bytes of each line are in inverse video to show the data that should mirror the start of the line in order to present continuous scrolling.

 

Use the joystick to scroll left and right. The program automatically handles the correct jump (for coarse scrolling 40 characters) from 0 to 216. However, holding the trigger down will cause it to skip that check allowing the scroll to move through positions 217 to 255 to see the effect.

 

The second scrolling line on screen is the last page of a 4K block ($8f00). Bypassing the scroll limiter will show that at the end of the line ANTIC wraps around to show the bytes in the first page of that 4K block ($8000). When the scroll limiter is bypassed the other lines show ANTIC continues reading sequentially; crossing from the end of one page into the start of the next page.

.

.

The first picture shows the display at position 0. The second shows the scroll at position 216. The last picture shows what happens when the scroll limiter is bypassed and ANTIC crosses from page to page. In the case of the second line it wraps around in the 4K block.

.

Thank you for the (mind-blowingly thorough) explanation!

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...