flat assembler
Message board for the users of flat assembler.

Index > OS Construction > vesa graphics-fonts

Author
Thread Post new topic Reply to topic
dosin



Joined: 24 Aug 2007
Posts: 337
dosin
I am using a 800*600 (8:8:Cool vesa graphic mode (115h) and starting to learn about fonts and printing them to screen in P-mode.. But I am not sure were to start.. If anyone knows of any good links or examples...ect...


Thanks in advance for any help!
Post 16 Oct 2007, 03:22
View user's profile Send private message Reply with quote
Dex4u



Joined: 08 Feb 2005
Posts: 1601
Location: web
Dex4u
I will give you a basic demo of how it work, its up to you to make it into a working function.
Code:
        mov   esi,Stop ;point to the fonts        call  DrawImage ; call the function        jmp $;***********************************; Draws text.;***********************************DrawImage:      mov   edi,[ModeInfo_PhysBasePtr]  ;move the screen address into edi      add   edi,0 ; you can add a screen offset here, just the top left hand corner  for this demo      xor   edx,edx ; zero edx      mov   dl,7  ; move the font high in here.      cldGetData:      lodsd ; load the top row of "STOP" into EAX      MOV     ebx,eax ;mov it in EBX      MOV     CL,32 ;move the number of bits to test.CheckBit:      test    ebx,80000000h ; here we test the bit for a 0 or 1      JZ      ZeroBit ; if 0 jump to ZeroBit label      xor    eax,eax ; if 1 put a black pixel      stosd      jmp     SkipZeroBit:      add edi,4 ; just move the pointer on by 4 (eg size of a pixel)Skip:      shl     ebx,1 ; move ebx along to test the next bit      loop    CheckBit ;loop again if cx not 0      add     edi,800*4-32*4 ;add screen X - width of "STOP"      dec     edx       jnz     GetData ;if not 0 loop      retStop:db     78h,38h,7ch,38hdb     44h,44h,10h,44hdb     44h,44h,10h,40hdb     78h,44h,10h,38hdb     40h,44h,10h,04hdb     40h,44h,10h,44hdb     40h,38h,10h,38h    


Now this is just a demo, you would normaly use single fonts, set in a font list.
So let for example do a basic 0 font
0xxx0 = 0xe
x000x = 0x11
x000x = 0x11
0xxx0 = 0xe

You would test each bit if it was a 0 you just move the pointer on one pixel, it its a 1 (but in this case x) you would put a pixel.
Post 16 Oct 2007, 18:05
View user's profile Send private message Reply with quote
dosin



Joined: 24 Aug 2007
Posts: 337
dosin
Dex4u, I noticed your stop is spelled right to left? POTS

Also: If I were to draw just an A..

I would have to change the
mov cl,32 to mov cl,8

since there is just eight bytes across.. (00000000)*1

mov dl,7 would stay the same


add edi,800*4-32*4

? add edi, screen_width*number_of_text? - total_bits_across?*number_of_text?

and last would the color be in the format of RGB?
mov eax,0x00FFFFFF


Code:

A: db 38h,44h,44h,7ch,44h,44h,44h

    


I've been away from my computer and have not been able to try it...
I am just trying to understand it....Maybe I need some rest-- lol


Thanks - again dex4u!!!
Post 17 Oct 2007, 03:59
View user's profile Send private message Reply with quote
Dex4u



Joined: 08 Feb 2005
Posts: 1601
Location: web
Dex4u
Yes you have under stud the code right Cool.
Code:
        mov   esi,LetterA ;point to the fonts        call  DrawImage ; call the function        jmp $;***********************************; Draws text.;***********************************DrawImage:      mov   edi,[ModeInfo_PhysBasePtr]  ;move the screen address into edi      add   edi,0 ; you can add a screen offset here, just the top left hand corner  for this demo      xor   edx,edx ; zero edx      mov   dl,7  ; move the font high in here.      cldGetData:      lodsb ; CHANGE THIS TO LODSB      MOV     BL,AL ; CHANGE THIS TO BL,AL      MOV     CL,8 ;CHANGE THIS TO 8.CheckBit:      test    BL,80h ; CHANGE THIS TO BL AND 80H      JZ      ZeroBit ; if 0 jump to ZeroBit label      xor    eax,eax ; if 1 put a black pixel      stosd      jmp     SkipZeroBit:      add edi,4 ; just move the pointer on by 4 (eg size of a pixel)Skip:      shl     bl,1 ; CHANGE THIS TO BL      loop    CheckBit ;loop again if cx not 0      add     edi,800*4-8*4 ;CHANGE THIS TO 800*4-8*4 as we are only puting 1 letter      dec     edx       jnz     GetData ;if not 0 loop      retLetterA: db 38h,44h,44h,7ch,44h,44h,44h    

The above code should work for on letter, but is untested.
Note: these fonts are 8x7, but if you were to use 8x16 you would need to mod things.

As for color yes, but you have to be carefull, as some card use 24bits and others 32bits, so some are 00RGB and some are RGB, most are 00RGB.

You need to test in the code for BPP eg:
Code:
PutFont:cmp  [ModeInfo_BitsPerPixel],24je  Its24BPP;do the function for 32 bits herejmp  LetsGoIts24BPP:;do the function for 24 bits hereLetsGo:     ret    

Good luck.
Post 17 Oct 2007, 06:45
View user's profile Send private message Reply with quote
dosin



Joined: 24 Aug 2007
Posts: 337
dosin
Thanks, for confirming that ... by the way I checked out your website Dex4u- pretty cool!!! Are you going to add multi-tasking latter on?

so, to posistion the text I would:

add edi,Txt_X*4+640*4*Txt_Y


All sorry but one more question...

In a text file like with note pad is all the text stored as hex data..? then once read from a file it is converted from B hex = B font to screen ?
Post 17 Oct 2007, 10:48
View user's profile Send private message Reply with quote
edfed



Joined: 20 Feb 2006
Posts: 4237
Location: 2018
edfed
no 0bh is not the code for 'b' ascii
'b' is 42h

hexadecimal is only an interpretation of a binary value
ascii is an other

hex is natural, ascii is normative

to put a letter on a screen you need some datas

x,y resolution
x,y position
a byte that represent the ascii letter
and a table were is the font

all letters in the font are table too
you have vectorial font
fixed font
variable font

so when you write a letter on the screen you only put an image of the letter loaded in the font table, at x,y position
and it is the same for all modes, text and graphic
in text mode, you don't need to load the font, it is automatic
in all graphics modes you need!!!
simple no????
Post 17 Oct 2007, 13:57
View user's profile Send private message Visit poster's website Reply with quote
Dex4u



Joined: 08 Feb 2005
Posts: 1601
Location: web
Dex4u
dosin wrote:
Thanks, for confirming that ... by the way I checked out your website Dex4u- pretty cool!!! Are you going to add multi-tasking latter on?

so, to posistion the text I would:

add edi,Txt_X*4+640*4*Txt_Y


All sorry but one more question...

In a text file like with note pad is all the text stored as hex data..? then once read from a file it is converted from B hex = B font to screen ?


Thanks dosin,
DexOS is at its hart a single-tasking OS, but it already as a demo to do multi-threading and it can load reloctable files, so it would not be too hard to make a MT ver.
To Help you fully understand how to print in vesa 800x600 mode, i have written you a simple demo, i will send you a link in a PM.
Good luck.
Post 18 Oct 2007, 01:09
View user's profile Send private message Reply with quote
dosin



Joined: 24 Aug 2007
Posts: 337
dosin
Thanks, Dex!!!!

I did get it working.. and the example was great!!!

This will help me see how the fonts work and for creating new ones!!!

I have added a screen shot from qemu of the text_graphics!


Description:
Download
Filename: os_bmp.zip
Filesize: 3.52 KB
Downloaded: 57 Time(s)

Post 18 Oct 2007, 05:26
View user's profile Send private message Reply with quote
Dex4u



Joined: 08 Feb 2005
Posts: 1601
Location: web
Dex4u
Cool it looks great.
Post 18 Oct 2007, 20:06
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-2020, Tomasz Grysztar.

Powered by rwasa.