In VGA mode 10h you can scroll vertically one-pixel-line at a time at high speed and without limit to the length of the data you need to scroll through. You can achieve this by changing the address of video memory to be used for the top left corner of the screen and by writing the data for the new bottom line (or top line if scrolling upwards) to two different locations in video memory - one of these lines will be displayed straight away, but the other one is needed so that you can jump the address for the top left corner back to the start of video memory as soon as it reaches the point where it's beyond the original bottom of the screen - this jump can be made without the screen content appearing to change at all.
Now, if you change the address by a single byte instead of 80, you can obviously scroll sideways too, though unfortunately it will jump 8 pixels at a time due to the way mode 10h works, so it won't be smooth. It would however let you scroll around a large diagram without having to rewrite any more bytes than the ones down the edge of the screen. In mode 13h or mode X you could use this method to scroll smoothly in any direction, but the resolution would be poor. I have never used any VESA modes and have no idea how much they vary from machine to machine, but I have heard that they often have gaps at the end of each line into which you should avoid writing data - any mode with this feature will only suit vertical scrolling, and it won't even do that unless there's twice as much video memory available as can be displayed in one go.
So, here's the question for those of you who are experienced with the workings of VESA. Is there likely to be a VESA mode of reasonable resolution available on any machine which suits this idea of smooth horizontal (and vertical) scrolling? By reasonable resolution I'm thinking in terms of 640x480 with at least one byte per pixel. If there is, it would enable you to lock the mouse cursor to a diagram or even a photo and scroll around it in any direction at ipad speed even on a fairly old machine. Maybe that's how it's normally done anyway - I wouldn't know.
Smooth sideways scrolling
- DavidCooper
- Member
- Posts: 1150
- Joined: Wed Oct 27, 2010 4:53 pm
- Location: Scotland
Smooth sideways scrolling
Help the people of Laos by liking - https://www.facebook.com/TheSBInitiative/?ref=py_c
MSB-OS: http://www.magicschoolbook.com/computing/os-project - direct machine code programming
MSB-OS: http://www.magicschoolbook.com/computing/os-project - direct machine code programming
Re: Smooth sideways scrolling
Use attribute controller register 13h for smooth scrolling (write lower 3 bits of scroll position into this register).
- Combuster
- Member
- Posts: 9301
- Joined: Wed Oct 18, 2006 3:45 am
- Libera.chat IRC: [com]buster
- Location: On the balcony, where I can actually keep 1½m distance
- Contact:
Re: Smooth sideways scrolling
I have a device in my collection that lack scrolling ability altogether and only flip between buffer A and B. Fortunately it does not come with a VBE-compatible bios so is not an issue, but it does mean that you might encounter hardware that's just lacking the features you have. Specifically, the VBE specification mentions that scrolling over memory or horizontal boundaries may be failed at the driver's leasure, and you might not be able to set the virtual width to cover that loophole.
That said, most devices have VGA compatibility, and therefore are likely to have pixel-scrolling features even in native modes. Your chances may not be as good as in native VGA mode, so you might want to stick to Gigasoft's suggestion. If not, selecting the best supported mode may be more relevant than the scrolling ability. If you need to hardcode anything, try 640x480x8.
That said, most devices have VGA compatibility, and therefore are likely to have pixel-scrolling features even in native modes. Your chances may not be as good as in native VGA mode, so you might want to stick to Gigasoft's suggestion. If not, selecting the best supported mode may be more relevant than the scrolling ability. If you need to hardcode anything, try 640x480x8.
- DavidCooper
- Member
- Posts: 1150
- Joined: Wed Oct 27, 2010 4:53 pm
- Location: Scotland
Re: Smooth sideways scrolling
I don't know what attribute controller register 13h is. Is this some trick for use with VGA modes 10h and 12h to change the horizontal alignment by a single bit instead of having to jump sideways by a whole byte's worth of pixels?
I've just been reading through this: http://www.petesqbsite.com/sections/tut ... s/vbe3.pdf - I had given up hunting for proper information on VESA before because it appeared that you had to pay quite a bit of money to access it (added to which it wasn't and still isn't an immediate priority for me), but this document seems to open the door to it. On pag 52 it says this:-
I've just been reading through this: http://www.petesqbsite.com/sections/tut ... s/vbe3.pdf - I had given up hunting for proper information on VESA before because it appeared that you had to pay quite a bit of money to access it (added to which it wasn't and still isn't an immediate priority for me), but this document seems to open the door to it. On pag 52 it says this:-
It appears that some VESA modes are intended to be used this way, and the protected mode interface allows you to set the start address at any time without having to switch back to real mode. The next paragraph on p52 also refers to pixel perfect smooth scrolling, and at the top of p51 it mentions pixel perfect horizontal panning. I don't know how many machines this would actually work on as it may only be available on more recent machines, but it does look as if it could be used to make an OS and its apps a lot more responsive and impressive. What isn't clear is how far it would let you scroll to the side before it maybe runs into a brick wall of impossibility.Note also that the display start address passed for subfunctions 02h, 03h, 82h and 83h are defined as a byte address in video memory rather than as a pixel coordinate. This is in contrast to the values passed to the 32-bit version which is a byte address divided by four, and allows for controllers that can perform hardware scrolling to a byte boundary for pixel perfect horizontal scrolling.
Help the people of Laos by liking - https://www.facebook.com/TheSBInitiative/?ref=py_c
MSB-OS: http://www.magicschoolbook.com/computing/os-project - direct machine code programming
MSB-OS: http://www.magicschoolbook.com/computing/os-project - direct machine code programming
- Owen
- Member
- Posts: 1700
- Joined: Fri Jun 13, 2008 3:21 pm
- Location: Cambridge, United Kingdom
- Contact:
Re: Smooth sideways scrolling
VESA give away VBE and most of their other older/legacy standards for free.
Re: Smooth sideways scrolling
Then you ought to add this page to your favourites: http://www.osdever.net/FreeVGA/vga/vga.htmDavidCooper wrote:I don't know what attribute controller register 13h is. Is this some trick for use with VGA modes 10h and 12h to change the horizontal alignment by a single bit instead of having to jump sideways by a whole byte's worth of pixels?
It's vital to understand everything there, if you plan to make use of the VGA interface in an advanced manner. The attributer controller registers are listed here: http://www.osdever.net/FreeVGA/vga/attrreg.htm
- DavidCooper
- Member
- Posts: 1150
- Joined: Wed Oct 27, 2010 4:53 pm
- Location: Scotland
Re: Smooth sideways scrolling
I remember now that I gave up the last time as it insists that you register and give them all sorts of information about who you are, but I think I have enough information now to be able to manage without their direct help.Owen wrote:VESA give away VBE and most of their other older/legacy standards for free.
I hope that means yes. I bookmarked one of those pages long ago, but I wasn't thinking about smooth horizontal scrolling back then. I will certainly experiment with it now. Thanks for pointing me towards this.Gigasoft wrote:Then you ought to add this page to your favourites: http://www.osdever.net/FreeVGA/vga/vga.htmDavidCooper wrote:I don't know what attribute controller register 13h is. Is this some trick for use with VGA modes 10h and 12h to change the horizontal alignment by a single bit instead of having to jump sideways by a whole byte's worth of pixels?
It's vital to understand everything there, if you plan to make use of the VGA interface in an advanced manner. The attributer controller registers are listed here: http://www.osdever.net/FreeVGA/vga/attrreg.htm
Edit:-
I've done some experiments now with VESA and hardware scrolling in any direction is easy and fast - the limiting factor for continuous scrolling is going to be how long it takes to write data to memory to create the new edge that's coming into the frame, but it should still be fast enough. So far I've done all this by switching in and out of real mode to make each change to the byte chosen to be in the top left corner, and the delays are trivial, though a more complex OS would take longer to go through that process, so emulating the BIOS code would be a better route to go down. I haven't tried it properly yet, but it looks as if for horizontal scrolling you'd want to make the scan line a multiple of 4 bytes longer than the horizontal resolution of the screen so that you can write to memory more efficiently (and of course do so while it's off screen). I don't know if there's a maximum width, but it may be that you can pre-write many screen's worth of pictures and scroll sideways at very high speed across the whole lot pixel line by pixel line.
Help the people of Laos by liking - https://www.facebook.com/TheSBInitiative/?ref=py_c
MSB-OS: http://www.magicschoolbook.com/computing/os-project - direct machine code programming
MSB-OS: http://www.magicschoolbook.com/computing/os-project - direct machine code programming