News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

Mode 13h text???

Started by wossname, November 12, 2005, 01:41:00 PM

Previous topic - Next topic

wossname

Is it possible to print text to the screen in graphics mode 13h?

I'd also like to be able to choose the color of the text and its background too.

If this is not possible with interrupts then i'll have to do it a pixel at a time?

BytePtr

Of course it is, with asm u can do everything. You can write directly to videomem. Then set colors etc.
Dunno how to do that??

hutch--

The old DOS graphics modes do not really apply in 32 bit Windows. You have 3 basic methods available, the old school GDI windows functions that work fine on non-high speed stuff, OpenGL for really smart fast stuff and DirectX if you can suffer the COM interface.
Download site for MASM32      New MASM Forum
https://masm32.com          https://masm32.com/board/index.php

wossname

Quote from: BytePtr on November 12, 2005, 02:30:16 PM
Of course it is, with asm u can do everything. You can write directly to videomem. Then set colors etc.
Dunno how to do that??

Yes I do know how to do that but I have never drawn text in mode 13h.  Is there an existing set of instructions that I can use or do I have to invent my own code to draw the text one pixel at a time?

Basically if I wanted to do a "hello world" program in mode 13h how would I do it? :wink

BytePtr

I coded simple example for you from scratch. Without using direct mem.
.model small
.stack 200h
.data
text_ db "Hi, from MODE 13h" ; our text do display
txtlen_ equ $-text_ ; get text length

.code ; code seg starts
.386 ; at least 386 cpu
.startup ; program starts
pushad ; save all regs

mov ax, 13h ; mode 13h = 320x200x256
int 10h


mov ax, @data ; AX points to data segment
mov es, ax ; and ES now points to data segment
mov bp, offset text_ ; mov offset of our text to Base Pointer
mov ah, 13h ; int 10h funtion for text displaying
mov al, 01h ; move cursor
xor bh, bh ; videopage 0
mov bl, 10 ; lime
mov cx, txtlen_ ; text length to cx
mov dh, 00h ; row 0
mov dl, 00h ; column 0
int 10h ; video intterupt 10


xor ah, ah ; wait for keypress
int 16h

mov ax, 03h ; back to textmode
int 10h

popad ; restore all regs
.exit ; give control back  to DOS
end    ; end of program


Commented fully and needs at least TASM 3 to compile
Works OK on XP Pro. maybe not the best method but it does the job.
Enjoy it, as i enjoyed writing it.   :8)

wossname

Nice one Byteptr!  :U

Ok, so if I wanted pixel perfect text placement I'd have to draw it manually by direct memory addressing?

(Byteptr's code also compiles and runs in MASM6.15 too)

BytePtr

Quote from: wossname on November 12, 2005, 04:53:05 PM
Ok, so if I wanted pixel perfect text placement I'd have to draw it manually by direct memory addressing?

You don't need to use DMA, u can place this text in any co-ordinates on screen, just change row (max 200) and column (max 320) in 13h in code. Anyway i dont recommend using DMA on NT systems.
Writing directly to videomem is used only when you need speed, for example: DOS GAMES | DOS GRAPHICS DEMOS. But if u are writing only [TEXT ONLY/NO GRAPHICS] (13h or whatever mode) program then DMA is not needed.

MichaelW

If by pixel-perfect text placement you mean having the ability to position the character pixel patterns at any pixel location, such a thing would be doable but it would require considerably more effort that just using the VGA BIOS as BytePtr did. It would be easiest to use a packed pixel mode, so VGA BIOS mode 13h would probably be the best choice. For mode 13h each pixel on the screen maps to one byte in the display buffer, and the entire display buffer is accessible in a single 64000-byte segment. You could provide your own font pixel-patterns, or use the ones stored in the VGA BIOS. The code would basically need to set all of the non-character pixels to a background color, and all of the character pixels to a foreground color.

eschew obfuscation