screen.c help (previously "weird text...")

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.
dh

screen.c help (previously "weird text...")

Post 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 :P). 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...
astrocrep

Re:weird text...

Post by astrocrep »

it should be y * 160 + x

give that a try,

Rich
dh

Re:weird text...

Post by dh »

ok, after I fix my account. I killed it with chmod somehow ???. Love linux

thanks
dh

Re:weird text...

Post 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)
HOS

Re:weird text...

Post 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.
dh

Re:weird text...

Post by dh »

ha ha. realized that while making the change. thanks anyway.

works great! thanks eveyone!
dh

Re:weird text...

Post 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 ;)
KieranFoot

Re:screen.c help (previously "weird text...")

Post 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...
User avatar
gaf
Member
Member
Posts: 349
Joined: Thu Oct 21, 2004 11:00 pm
Location: Munich, Germany

Re:screen.c help (previously "weird text...")

Post 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
dh

Re:screen.c help (previously "weird text...")

Post 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
}
}
}
User avatar
bubach
Member
Member
Posts: 1223
Joined: Sat Oct 23, 2004 11:00 pm
Location: Sweden
Contact:

Re:screen.c help (previously "weird text...")

Post 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...?
"Simplicity is the ultimate sophistication."
http://bos.asmhackers.net/ - GitHub
User avatar
df
Member
Member
Posts: 1076
Joined: Fri Oct 22, 2004 11:00 pm
Contact:

Re:screen.c help (previously "weird text...")

Post 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...
-- Stu --
dh

Re:screen.c help (previously "weird text...")

Post by dh »

ha ha *sigh*, never noticed that... :P.
*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]
dh

Re:screen.c help (previously "weird text...")

Post by dh »

Thanks guys :D. 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.
dh

Re:screen.c help (previously "weird text...")

Post by dh »

ok! time to make a kPrint command. where is it suggested that I begin?
Post Reply