From: johne AT parallax DOT co DOT uk (John Eccleston) Newsgroups: comp.os.msdos.djgpp Subject: [q]: Getting access to BIOS font data Date: Fri, 21 Feb 97 09:41:49 GMT Organization: Parallax Solutions Ltd Message-ID: <856518100.402472@red.parallax.co.uk> NNTP-Posting-Host: red.parallax.co.uk Cache-Post-Path: red.parallax.co.uk!unknown AT parsnip DOT parallax DOT co DOT uk Lines: 153 To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Hi All, I am trying to get the bios font data so that I can write text to my double buffer. I have written a little piece of inline ASM to call int 10 function 11 to get the address of the font data but when I run the program, even though it works the data it brings back is not as expected. When I try using the data obtained the characters are all gibberish. On my PC even an 8x8 character set reports that it is stored as 16 bytes per character, and for font heights of 8, 14 and 16 they are all stored at the same address. The program to get the font data is added below, if anyone has any experience of doing this and could tell me what I have obviously done wrong then I would be very grateful. The problem may lie in my inline ASM which I am not used to yet. Thanks in advance John -----> Cut Here <----- #include #include #include #include #include #include typedef unsigned char BYTE; typedef struct BiosFont { int height, // In pixels width, // In pixels depth; // In bits BYTE *byteMap; } BiosFont; void getBIOSFont(BiosFont *font, int height) { int bytesPerChar, linesPerChar, size, biosHghtMarker, segment, offset; // Set up the font info including the BIOS font height designator switch (height) { case 8 : biosHghtMarker = 3; font->height = 8; font->width = 8; break; case 14 : biosHghtMarker = 2; font->height = 14; font->width = 8; break; case 16 : biosHghtMarker = 6; font->height = 16; font->width = 8; break; default : break; } /* * Use INT 10h function 11 sub function 30 to get the real mode * address of the BIOS font required. This INT returns the * segment in es and the offset in bp. dx will hold the lines of * chars and cx the bytes per char. */ __asm__ __volatile__( // Store bp and es for safe keeping "pushw %%es\n\t" "pushw %%bp\n\t" // Zero the output registers, not ebx as it has something in it "movl $0, %%eax\n\t" "movl $0, %%ecx\n\t" "movl $0, %%edx\n\t" // Set up the BIOS call, and do it BH contains the font height "movb $0x11, %%ah\n\t" "movb $0x30, %%al\n\t" "int $0x10\n\t" "movl $0, %%ebx\n\t" // Zero ebx to be safe // Copy the results to the output regs "movw %%cx, %%ax\n\t" "movw %%dx, %%bx\n\t" "movw %%es, %%dx\n\t" "movw %%bp, %%cx\n\t" // Tidy up after ourselves by restoring bp and es "popw %%bp\n\t" "popw %%es\n\t" : "=a" (bytesPerChar), "=b" (linesPerChar), "=d" (segment), "=c" (offset) // Outputs : "b" (biosHghtMarker) : "%esi", "%ebp" // Clobbered regs ); font->depth = bytesPerChar / font->width; size = ((font->height * font->width * font->depth) + 7) / 8; font->byteMap = new BYTE[size * 128]; printf("Font Info:\n"); printf("\tChar size = %d x %d\n", font->width, font->height); printf("\tStorage = %d, From %d:%d\n", size * 128, segment, offset); printf("\tBios reports %d bytes/chr and %d lines\n", bytesPerChar, linesPerChar); if (font->byteMap != NULL) { dosmemget((segment * 16) + offset, size * 128, font->byteMap); } } main() { BiosFont font8, font14, font16; getBIOSFont(&font8, 8); getBIOSFont(&font14, 14); getBIOSFont(&font16, 16); } -----> Cut Here <----- ________________________________________________________________ Parallax Solutions Ltd. Tel.: 01203 514522 Stonecourt, Fax.: 01203 514401 Siskin Drive, Web : http://www.parallax.co.uk/~johne Coventry CV3 4FJ Mail: johne AT parallax DOT co DOT uk ________________________________________________________________ Remember: There is no such thing as computer error, it's 100% YOUR fault ________________________________________________________________