View Full Version : text output in mode 13h
zoviac
01-03-2003, 04:16 PM
just wondering how to put colored text on screen(xy) in mode13h.. cprintf dont work.. tutorials? source?
bwkaz
01-06-2003, 03:53 PM
OS? Architecture? I'm assuming DOS on x86 with a PC BIOS, but maybe not...
Did you check for an ANSI escape code reference table somewhere? That might help...
Did you consider writing your own text-output function, like I had to eventually do in mode 13h back in the bad old days of DOS?
zoviac
01-07-2003, 11:59 AM
in dos yes, im looking for a tutorial/source to write my own function, i have no idea how to do this (prolly some assembly shit)
...i would like to know how to write font engine too...
bwkaz
01-12-2003, 07:32 PM
Easy. ;)
You know how to read a bitmap file, right? (that was one of the previous examples you got here?) You can make some sort of bitmap of each character, then create an array of those bitmap objects, then index it by the ASCII value of the character you want to print. Something like:
pcx_image charset[255];
// Reads your font file into the array of pcx_image structs
read_font_pcx("your_font_file.pcx", charset);
// ...
print_string("Hello world.\n");
// ...
void print_string(const char *str)
{
for(i=0; str[i]; i++) {
if(isalnum(str[i])) {
bit_blt(charset[str[i]], x, y);
// update x and/or y, however that works
}
else {
printf("%c", str[i]); // Just echo control characters, etc.
}
}
}
Something like that, anyway. Obviously there are things I would do better (like position handling, for one), but yeah.
zoviac
01-15-2003, 10:19 AM
well that would be pretty good idea, but the drawing is bit hard :D
.. well anyway i got it thx
bwkaz
01-15-2003, 10:26 AM
In mode 13h? All you do is create a pointer to a000:0000, then say ptr[(y<<6)+(y<<8)+x] = color; to put a pixel on the screen. You could also do ptr[y*320+x], but the shifts used to be faster, so I still use them by default. Either way...
zoviac
01-15-2003, 01:12 PM
i meant drawing the characters.. like wit paintbrush, gonna take a lot time..
bwkaz
01-15-2003, 02:38 PM
Oh, I see.
You might be able to grab a screenshot of the normal BIOS 8x8 character set in mode 13... do a normal printf of all of the characters (which obviously won't be in color), then grab a screenshot, then edit it a little.
sedarious
01-20-2003, 12:04 PM
Its called google. I did a search for
"mode 13h" text
and this was the 3rd link. You need to learn to do a little work on your own man...
http://www.geocities.com/SiliconValley/Park/7113/OldPages/cGraphicsText.html
zoviac
01-21-2003, 03:39 PM
..i have tried to search google, i cant seem to find anything good, its all assembly or pascal in the sites i have found, but thx for the link
mcinvalek
10-28-2004, 11:31 AM
define macros:
/* for the foreground or text*/
#define REGFG printf('\033[31m")
#define REDBKG printf("\033[41m")
other colors include:
31m REDFG
30m BLACKFG
40m BLACKBKG
32m GRENFG
42m GREENBKG
34m BLUEFG
44m BLUEBKG
35m MAGENTAFG
45m MAGENTABKG
36m CYANFG
46m CYANBKG
37m WHITEFG
47m WHITEBKG
in your program call your macro:
BLUEBKG;
WHITEFG;
LOCATE(2,5); puts("White text, with a blue background");
vBulletin® v3.7.0, Copyright ©2000-2010, Jelsoft Enterprises Ltd.