I'm making a small game for a university course in assembly, in which we use DosBox. In the game there's a small chat window, but there are some shapes as well. I have to enter graphics mode to draw the shapes, however the font looks big and ugly in graphics mode. Is there a way I can mix between the two modes? Maybe have half of the screen as graphical and the other as text? If not, can I make the graphics mode font smaller or adjust how I want the characters to look like?
Asked
Active
Viewed 2,675 times
1
-
3VGA as far as I remember is not capable to compose screen from two video modes (like Commodore and Atari were, both in 8b and 16b IIRC). But you can use 640x480 16 colour mode (`mov ax,12h` `int 10h`) to get finer resolution. Be prepared to endure major pain to draw anything in it (requires banking, and working with bit planes), or use "draw pixel" of `int 10h`, and get too old till it finish drawing anything. (even if it's possible to bend real VGA enough to such thing, I doubt it will work under emulators) – Ped7g Nov 20 '17 at 21:01
-
Font smaller = *"the computer says no"*. At least as long as again you intend to use `int 10h`. You can of course design your own font as pixel data, and create own draw font routines (I did myself, took me about 2-3 days IIRC, drawing the font on graph paper (With size about 5x8 pixels mostly), translating that into byte values, and then write them from paper to computer. Also allowed me to use variable char width, defined by hand for every glyph, so the output was proportional). Still 320x200 kind of sucks for texts. But 256 colours vs 16 .... – Ped7g Nov 20 '17 at 21:05
-
2@Ped7g: Then don't use mode `10h`. Dosbox emulates a number of SVGA adapters. Actually, it does support raster tricks to some extent as well if wanting to go the plain VGA route though I am also somewhat doubtful as to whether is capable of pull off a vertical text/graphic mode split. And though it might be an interesting little project to find out I suspect that it lies somewhat outside the scope of this question. – doynax Nov 20 '17 at 21:50
-
1@doynax yeah. The SVGA modes are good idea too, they will suck just as much as the 0x12 mode (banking and/or bitplanes), but at least resolution will be even better, and also colours. Anyway, anything other than 320x200 256col in 16b real mode was lot of hassle, I was so glad we did start to use DOS4GW and VBE2.0 and later DirectX 3.0 video buffers under win32... the pure 16b DOS was just pain. – Ped7g Nov 20 '17 at 21:57
-
1@Ped7g: Well, yeah, use a linear frame buffer in extended mode. Dosbox supports them and 32-bit assembly is a whole lot nicer to work with, even if it is still `x86` we are talking about. – doynax Nov 20 '17 at 21:59
-
back in the days in 320x200 graphics I used a [8x8 font](https://stackoverflow.com/a/44797902/2521214) (you can use any if you render yourself). But switching to higher resolutions is better option, but requires handling pages and VESA related stuff. As start I recommend to combine text and graphical modes. use text mode for menus and graphic for the game like I did here: [What is the best way to move an object on the screen?](https://stackoverflow.com/a/29579522/2521214). – Spektre Nov 21 '17 at 16:05
-
A moment ago I added an answer how to display bit letters in text mode, but you can actually turn it into graphics mode with some modifications, and it shows how to use proportional font definition and do the manual font drawing pixel by pixel (or char by char in text mode) ... doesn't contain full font definition (and it would be too big for your purpose, as you need small ones), but the main algorithm is same as you can incorporate in your graphic mode: https://stackoverflow.com/a/47551530/4271923 – Ped7g Nov 29 '17 at 11:22
1 Answers
3
You could try 640x480 256 colors, so long as you set the machine type in the configuration file to:
machine=svga_s3
Use int 10h to set the video mode:
mov ax, 4f02h
mov bx, 101h
int 10h
There are plenty of other video modes as well 800x600, 1024x768, etc.
Here's the reference I usually use: http://www.wagemakers.be/english/doc/vga
Also, you could create your own character set if you're in a graphics mode. Just define your bitmapped characters as variables, then write them to the pixel buffer which starts at a000:0000.
Byte values from 0 to 0ffh map to one of the 256 colors in the vga color palette (you can google the default palette). So, if you write value 4 to a000:0000 the pixel in the upper left corner of the screen will be set to red.

bad
- 939
- 6
- 18
-
2Note that 640x480@8bpp is 300KiB of memory, which not only is out of the VGA capabilities but cannot be mapped entirely in the standard 128KiB hole at 0a0000h. Unless bit 14 is set in the video mode number, the VRAM is banked in the said standard hole. [Int 10h/AX=4f05](http://www.ctyme.com/intr/rb-0278.htm) can be used to switch bank. – Margaret Bloom Nov 21 '17 at 11:43
-
Yeah, you're right. I made a mistake. I edited the part about the pixel buffer being 64,000 bytes long out. – bad Nov 21 '17 at 12:40