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.
I recently began working on a _REAL_ os (not qbasic) and things have been pretty smooth. I just put in a kPutChar command, but my pointer math is off (i'm still learning C ). I got:
(0xB8000 + (x * 80)) + y
pretty bad ea? I think I need (0xB8000 + (x * 160)) + y due to the fact that you need room for the color info.
It _does_ work, but color is WAY off.
good news and bad news.
good: the text is positioed mostly right
bad: colors messed up still
and i think i know why. in english we're watching some movie. well i pulled out some paper and jotted down some numbers and such and came to this (seems right ):
position = address + ((x * 160) + y * 2)
keeping in mind that the x axis goes left to right and y top to bottom :p. I did a picture up as well to check:
|C,0x07|a,0x07|t,0x07|
^ ^
| |
| This is character 2 and located at address + 4 or (y * 2)
This is character 1 and is locaed at address + 2 or (y * 2)
I made a kScreenClear() command...but it wont clear (im setting all letters to null and color standard 0x07).
I made a _Print() command...but it is hard to test with GRUB stuff all over the screen.
I made a _screencheck() which sets _X and _Y to be withen their limits and such.
Finally I made a "Locate" (back to the old qbasic stuff) command to move the cursor. It sets to file-wide variables (_X and _Y) which are used by _Print to tell kPutChar where to put the character.
(Everything revolves around the limits for screen size at this point (width and height are 80x25) but this seems to be cutting off the _Print()'s text.)
ok, y do u need to know the screen limits, my print routines dont need them at all, my WrapPrint routine uses row widths only for word wrapping otherwise wrapping occurs anyway...
as for your screen clear routine theory is right, thats exactly how mine works...
I made a _Print() command...but it is hard to test with GRUB stuff all over the screen.
I made a _screencheck() which sets _X and _Y to be withen their limits and such.
Finally I made a "Locate" (back to the old qbasic stuff) command to move the cursor. It sets to file-wide variables (_X and _Y) which are used by _Print to tell kPutChar where to put the character.
I was working on the stuff yesterday and got everything working except kScreenClear.
Basically the code is (from memory):
void kScreenClear(void)
{
int x, y;
for (x = 0; x > _VIDEO_TXT_WIDTH_LIMIT; x++)
{
for (y = 0; y > _VIDEO_TXT_HEIGHT_LIMIT; y++)
{
kPutChar(y, x, 0xFFF, 0x00); //Please note that 0xFFF is
//regarded as "standard color" by all screen commands
}
}
}
Dragon_Hilord wrote:Basically the code is (from memory):
void kScreenClear(void)
{
int x, y;
for (x = 0; x > _VIDEO_TXT_WIDTH_LIMIT; x++)
{
for (y = 0; y > _VIDEO_TXT_HEIGHT_LIMIT; y++)
{
kPutChar(y, x, 0xFFF, 0x00); //Please note that 0xFFF is
//regarded as "standard color" by all screen commands
}
}
}
i don?t get this, you loop as long as x and y is over the width and height limit? this will never happen as both x and y starts with 0, so the loop is never runned.
> should be <...
Or am i totally...?
ha ha *sigh*, never noticed that... .
*bows* root oh holly sir. my thanks.
thanks guys, i'll try that. what was i thinking??
[edit] I was thinking that was the termination field. That's a C noob for you. here in the flesh. thanks again ;D [/edit]
Thanks guys . screen.c is now fully operational (moving on to other stuff now). I'll be going back to it soon though as I need a proper kPrint function and family.