printf function
printf function
when i call a printf function is there a technique i can use to save the last location of the chracter printed to memory so that when i call printf again, it will start printing after the last char printed before.
- Pype.Clicker
- Member
- Posts: 5964
- Joined: Wed Oct 18, 2006 2:31 am
- Location: In a galaxy, far, far away
- Contact:
Re:printf function
Yes. Store the offset of the next output in a static variable (top-level) rather than in an automatic (function-hosted) variable.
Re:printf function
Or two statics (x, y) if you want to be able to position them anywhere on the screen. That would probably be better done in a console driver, so everything works correctly when you go from 80x25 to another mode.
That way, if you hit a \n character, then it's simply a matter of setting x to 0 and adding 1 to y to perform a crlf (carriage return, line feed).
That way, if you hit a \n character, then it's simply a matter of setting x to 0 and adding 1 to y to perform a crlf (carriage return, line feed).
Re:printf function
Hi, I am just trying to figure out for some days what the situation will be when implementing virtual consoles in that case since screen output will be a kind of shared resource we will have some problems;
- Our console driver should be aware of the fact that no two consoles should be able to access(write) video memory at the same time.
- (a result of first one) While doing some of your jobs with one virtual console other console's(or consoles') output should be directed to somewhere else like screen buffer of virtual consoles.
- When one virtual console are called back to screen, screen contents should be copied into currently running virtual console's screen buffer and the screen buffer of console that will be run newly should be copied back to actual video memory.
- Pype.Clicker
- Member
- Posts: 5964
- Joined: Wed Oct 18, 2006 2:31 am
- Location: In a galaxy, far, far away
- Contact:
Re:printf function
if you plan to have several virtual consoles, then store the offset of the next char to be written within the vconsole structure.
When you print to a console, you always print into its private memory structure.
If you're really worried about consistent display, you could for instance disable interrupts while you're copying things to the virtualscreen memory.
When a console switch is asked by the user, you just
When you print to a console, you always print into its private memory structure.
If you're really worried about consistent display, you could for instance disable interrupts while you're copying things to the virtualscreen memory.
When a console switch is asked by the user, you just
Code: Select all
static console* curr_console;
switchto(console *next_console) {
memcpy (curr_console->data,screen,80*25*2);
memcpy (screen,next_console->data,80*25*2);
curr_console->active=curr_console->data;
next_console->active=screen;
curr_console=next_console;
}