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.
distantvoices
Member
Member
Posts: 1600
Joined: Wed Oct 18, 2006 11:59 am
Location: Vienna/Austria
Contact:

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

Post by distantvoices »

well, I suggest you provide yerself with a set of the va_args macros, and then - set off and implement a worker function for your kprintf, which loops throu a character string, outputs each 'normal character' and recognizes/parses special character combinations like '%d'

HTH
... the osdever formerly known as beyond infinity ...
BlueillusionOS iso image
dh

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

Post by dh »

va_args ? how do they work? oh oh! they support that "..." thing, right. sorry I don't get this as (like I already said) a real noobie!!

I do have a simple _Print command that supports \n and \b.
distantvoices
Member
Member
Posts: 1600
Joined: Wed Oct 18, 2006 11:59 am
Location: Vienna/Austria
Contact:

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

Post by distantvoices »

Dragon? DRAAAGON???!! Stop that hiding behind being new to c, OK? I've been new to that stuff too - a long time ago. *gg*

Roughly said, yes, the va_arg macros are for variable-length argument lists, which are "popped" off the stack one after the other via va_arg(sizeof (datatype)).

Why don't you try it out, hm? have a look at Solars pdclib: there is an implementation of those macros.

... gonna rant on this when I'm at home, don't worry. You'll get a nice explanation.
... the osdever formerly known as beyond infinity ...
BlueillusionOS iso image
dh

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

Post by dh »

woow...don't rant over this. I barely know anything about C. I've been doing it less then a month!!!

Thanks for the advice...and I'll stop saying that if it helps. (I would assume that people want to know /why/ I don't understand...)

Long live BASIC!
dh

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

Post by dh »

what I ment by "long live basic" is i have a color, locate and _print command. ease of use forever.

does anybody know where to get a chart explaining the color byte? i lost mine :P.

xxx_xxxx
| |
| FG
BG


Is this right ??? ???
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:screen.c help (previously "weird text...")

Post by Pype.Clicker »

http://www.osdev.org/osfaq2/index.php/HardWareVga should be *da* place 2 check ...

iirc,

Code: Select all

enum {
   FG_BLUE = 1,
   FG_GREEN = 2,
   FG_RED=4,
   FG_BRIGHT=8,
   BG_BLUE=0x10,
   BG_GREEN=0x20,
   BG_RED=0x40,
   BLINK_OR_BG_BRIGHT_DEPENDING_ON_VGA_SETUP=0x80,
};
Yellow on dark blue is, for instance
FG_GREEN|FG_RED|FG_BRIGHT|BG_BLUE
dh

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

Post by dh »

OHHH THANKYOU!!!! I was trying to do it all by trial and error and you wouldn't believe how many possibilties there is!!

oh ya: http://osdev.neopages.net/FreeVGA/vga/colorreg.htm is broken :'P *cry*. In fact, a LOT of links are broken :'P.

Do the colors in qbasic work? They go from 0 to 15. I know that only the first 7(?) can be used for backgrounds. Input apreacheated!
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:screen.c help (previously "weird text...")

Post by Pype.Clicker »

they work the same way as shown (e.g. color 9 is BLUE|BRIGHT, color 0 is black, etc.)
BLUE|GREEN == CYAN, BLUE|RED==MAGENTA, etc.

Only 8 colors (0..7) are avl. for background because in QBASIC, the highest bit is for blinking or something alike ...

You can theorically enable 16 colors for background
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 »

Pype.Clicker wrote:Only 8 colors (0..7) are avl. for background because in QBASIC, the highest bit is for blinking or something alike ...
not only in qbasic, in textmode.
You can theorically enable 16 colors for background
if you are willing to give up blinking. there?s some vga reg you can change to do this.
"Simplicity is the ultimate sophistication."
http://bos.asmhackers.net/ - GitHub
HOS

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

Post by HOS »

bubach wrote:
You can theorically enable 16 colors for background
if you are willing to give up blinking. there?s some vga reg you can change to do this.
cool. would you mind telling how or pointing to how?
dh

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

Post by dh »

ya, I could easily do without blinking. i got something like this

Code: Select all

typedef enum ColorCodes
{
   BLACK=0
   BLUE=1
   ...
   BG_BLACK=0x01
   BG_BLUE=0x02
} ColorCodes;
With this I would assumme you would have this to combine them:

Code: Select all

void ChangeColor(ColorCodes fg, ColorCodes bg)
{
  _COLOR = fg || bg /* assuming || is or....can't remember :P */
}
AR

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

Post by AR »

/* assuming || is or....can't remember :P */
|| is a logical or (ie. if(true || true);), | is the bitwise or
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 »

sorry, i can?t remember where i read that. you?ll have to search for some vga-reg docs on google..
"Simplicity is the ultimate sophistication."
http://bos.asmhackers.net/ - GitHub
dh

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

Post by dh »

no problemo. i'll post some links for everybody else too ;P
User avatar
Candy
Member
Member
Posts: 3882
Joined: Tue Oct 17, 2006 11:33 pm
Location: Eindhoven

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

Post by Candy »

if you want to binary-or them together, you should use a single | character.

Also, you should use 0x10-folds for the background colors, IE, 0x10, 0x20 etc.
Post Reply