Page 1 of 3
screen.c help (previously "weird text...")
Posted: Mon Nov 22, 2004 4:52 pm
by dh
Remember me? "Alpha Zetta Z". Doesn't matter.
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.
thanks ahead...
Re:weird text...
Posted: Mon Nov 22, 2004 5:06 pm
by astrocrep
it should be y * 160 + x
give that a try,
Rich
Re:weird text...
Posted: Mon Nov 22, 2004 6:08 pm
by dh
ok, after I fix my account. I killed it with chmod somehow ???. Love linux
thanks
Re:weird text...
Posted: Tue Nov 23, 2004 10:37 am
by dh
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)
Re:weird text...
Posted: Tue Nov 23, 2004 1:02 pm
by HOS
Dragon_Hilord wrote:
keeping in mind that the x axis goes left to right and y top to bottom :p.
this is exactly why you want to multiply y by 160, not x. for every y (row) you want the position in memory 160 bytes further.
Re:weird text...
Posted: Tue Nov 23, 2004 5:23 pm
by dh
ha ha. realized that while making the change. thanks anyway.
works great! thanks eveyone!
Re:weird text...
Posted: Thu Nov 25, 2004 11:24 am
by dh
Problem #2 has just surfaced. (and 3 and 4...)
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.)
Thanks for the help
Re:screen.c help (previously "weird text...")
Posted: Fri Nov 26, 2004 9:16 am
by KieranFoot
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...
Re:screen.c help (previously "weird text...")
Posted: Fri Nov 26, 2004 11:14 am
by gaf
I made a kScreenClear() command...but it wont clear (im setting all letters to null and color standard 0x07).
Actually it's already enought if you simply overwrite the whole console with zeros. Who cares about the color if there're no letters ?
Code: Select all
int* vidmem = 0xB8000;
for(int i=0; i<80*25; i++)
{
vidmem[i] = 0;
}
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.
Could you post the code ?
regards,
gaf
Re:screen.c help (previously "weird text...")
Posted: Fri Nov 26, 2004 2:30 pm
by dh
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
}
}
}
Re:screen.c help (previously "weird text...")
Posted: Fri Nov 26, 2004 2:50 pm
by bubach
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...?
Re:screen.c help (previously "weird text...")
Posted: Fri Nov 26, 2004 4:05 pm
by df
yeah its back to front.
should be
x < _VIDEO_TXT_WIDTH_LIMIT
and
y < _VIDEO_TXT_HEIGHT_LIMIT
plus its clearning by columns instead of rows (nothing wrong with that its just... odd...)...
most people would do height by width, not width by height...
Re:screen.c help (previously "weird text...")
Posted: Sat Nov 27, 2004 4:36 pm
by dh
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]
Re:screen.c help (previously "weird text...")
Posted: Sun Nov 28, 2004 1:01 pm
by dh
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.
Re:screen.c help (previously "weird text...")
Posted: Thu Dec 02, 2004 2:26 pm
by dh
ok! time to make a kPrint command. where is it suggested that I begin?