scroll screen

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
Tom le

scroll screen

Post by Tom le »

Helo guys,

I want to have soft scroll in my os. I think i know how to do it, but i want somewhere i can get some code that shows me the way to implement it.

any one can heko me please??
Curufir

Re:scroll screen

Post by Curufir »

If you're doing it in software then quite simply this isn't rocket science or anything.

All scrolling actually involves is copying the entire page into video memory only shifted up one row (Or as many as are requested). The principle is exactly the same whether you are scrolling in text mode or graphics mode.

The only nuances involved are whether you are maintaining a history larger than a single page, whether you want to allow scrolling of more than one line (In a graphics mode you might want to scroll by more than one pixel at a time), how many degrees of freedom you want to allow scrolling for (This is reliant on maintaining screen history of course). None of which change the principle, just implementation of it.

Basic outline of a scroll would be something like this:
  • Find out where the new top of page starts in memory (Ie one complete line from the current top).
  • Copy everything from that point to the bottom of the page into screen memory (Or a buffer if you're not writing directly to screen).
  • Add a blank line at the bottom and start any further output at the start of it.
You can do this in assembler in a very very small amount of instructions. Should also be exceedingly straightforward to implement in C/Whatever you are using.

Hope that helps, it's probably just confirmation of what you were already thinking.

Hardware scrolling involves changing the base address of the text page, an interesting problem, but not particularily worth the effort IMO.
Mastermind

Re:scroll screen

Post by Mastermind »

(sorry) Reading this, I think I'll post my question.
I would like to save several screen-fulls of text and be able to recall them at will, sort of like a text buffer. I am thinking of using two dimentional arrays for the characters and the attributes. However, is the max number of elements 999? If so, how can I store 80x25 chars in a var (not a file)?
User avatar
Pype.Clicker
Member
Member
Posts: 5964
Joined: Wed Oct 18, 2006 2:31 am
Location: In a galaxy, far, far away
Contact:

Re:scroll screen

Post by Pype.Clicker »

Mastermind wrote: (sorry) Reading this, I think I'll post my question.
However, is the max number of elements 999?
What would it be so ?
What kind of magic do you see in 999 ? (except it's 666 if you look it upside-down ?)
If so, how can I store 80x25 chars in a var (not a file)?
char screen[80][25] should do it.
However, on a screen, you have 80x25x2 = 4000 characters, not 80x25 ...
so you're likely to prefer

Code: Select all

short screen[80][25] 
Post Reply