flat assembler
Message board for the users of flat assembler.

Index > OS Construction > Write character on vga mode

Author
Thread Post new topic Reply to topic
Arturx87



Joined: 16 Mar 2023
Posts: 1
Arturx87 16 Mar 2023, 07:44
How to draw character in vga mode (13h) in my select position (example 2px x 4px)
Code:
Mov al,’a’
Mov ah,0eh
Int10h
    



Thanks for Help
Post 16 Mar 2023, 07:44
View user's profile Send private message Reply with quote
macomics



Joined: 26 Jan 2021
Posts: 909
Location: Russia
macomics 16 Mar 2023, 09:17
If I remember correctly, there is no function for drawing text in an arbitrary position for VGA mode. But if you just need to output the text, then you can use the function AH=13h.
Code:
push es
push cs
pop es
mov ax, 1300h ; al = mode
mov bx, 0007h ; bh = page, bl = color
mov cx, text0.Length ; ...
mov dx, 0402h ; dh = row, dl = column
mov bp, text0 ; es:bp = string
int 10h
pop es

push es
push cs
pop es
mov ax, 1301h ; al = mode
mov bx, 0007h ; bh = page, bl = color
mov cx, text1.Length ; ...
mov dx, 0607h ; dh = row, dl = column
mov bp, text1 ; es:bp = string
int 10h
pop es

push es
push cs
pop es
mov ax, 1302h ; al = mode
mov bh, 00h ; bh = page
mov cx, text2.Length ; ...
mov dx, 0802h ; dh = row, dl = column
mov bp, text2 ; es:bp = string
int 10h
pop es

push es
push cs
pop es
mov ax, 1303h ; al = mode
mov bh, 00h ; bh = page
mov cx, text3.Length ; ...
mov dx, 0A04h ; dh = row, dl = column
mov bp, text3 ; es:bp = string
int 10h
pop es

text0 db 'Hello'
.Length = $ - text0
text1 db 'world'
.Length = $ - text1
text2 db 'H', 01h, 'e', 02h, 'l', 03h, 'l', 04h, 'o', 05h
.Length = ($ - text2) shr 1
text3 db 'w', 10h, 'o', 20h, 'r', 30h, 'l', 40h, 'd', 50h
.Length = ($ - text3) shr 1    
But if you need to output the text in a completely arbitrary position, then you should use the function AH=1130h. You get a pointer to the character generator table, use it to decipher the character and output it by points with the function AH=0Ch or by direct access to video memory.
Post 16 Mar 2023, 09:17
View user's profile Send private message Reply with quote
edfed



Joined: 20 Feb 2006
Posts: 4324
Location: Now
edfed 17 Mar 2023, 15:52
Code:
print:
.char:
        pushad
        movzx esi,al
        shl esi,3
        add esi,bioschars
        mov edi,.base
        mov eax,[edi+.x]
        mov ebx,[edi+.y]
        mov ch,8
.loadline:
        mov dh,[esi]
        mov dl,80h
.nextdot:
        test dh,dl
        je @f
        mov cl,[edi+.c];31
        call put.pixel
@@:
        inc eax
        shr dl,1
        jne .nextdot
        inc ebx
        mov eax,[edi+.x]
        inc esi
        dec ch
        jne .loadline
        add dword[edi+.x],8
        popad
        ret

.string:
;esi asciiz string
@@:
        lodsb
        or al,al
        je @f
        call .char
        jmp @b
@@:
        ret


.base = 10200h
.x    = 0
.y    = 4
.c    = 8

bioschars = 0ffa6eh
.xl=16
.yl=16
    


char table is at 0ffa6eh

putpixel is just like that:
Code:
.pixel:
        push ebx
        cmp eax,screen.xl
        jae @f
        cmp ebx,screen.yl
        jae @f
        imul ebx,screen.xl
        mov [screen.base+eax+ebx],cl
;        xor [screen.base+eax+ebx],cl
@@:
        pop ebx
        ret              
    


and screen.base can be the double buffer, or direct to vram, as you want.

for CGA mode, it starts at 0a0000h

this code is intended for protected mode but just whows how to print chars.
Post 17 Mar 2023, 15:52
View user's profile Send private message Visit poster's website Reply with quote
DimonSoft



Joined: 03 Mar 2010
Posts: 1228
Location: Belarus
DimonSoft 17 Mar 2023, 20:17
There used to be functions that set/retrieve the current cursor position. Then one has to just add 1 plus 1.
Post 17 Mar 2023, 20:17
View user's profile Send private message Visit poster's website Reply with quote
macomics



Joined: 26 Jan 2021
Posts: 909
Location: Russia
macomics 17 Mar 2023, 20:43
edfed wrote:
char table is at 0ffa6eh
Only the first 128 characters.

To get pointers to the sign generator tables , there is a function AH=0x1130

DimonSoft wrote:
There used to be functions that set/retrieve the current cursor position. Then one has to just add 1 plus 1.
But not in graphical mode. The cursor works, of course, but you need to draw it yourself, but the coordinates continue to be tracked quite well. Although they work in text columns and rows, not in pixels.
Post 17 Mar 2023, 20:43
View user's profile Send private message Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.