flat assembler
Message board for the users of flat assembler.

Index > OS Construction > FONT BITMAPS

Author
Thread Post new topic Reply to topic
Redragon



Joined: 27 Nov 2004
Posts: 101
Location: U.S.
Redragon 03 Mar 2005, 03:44
I already know how to write a font bitmap for each letter, but I was wondering how you would go about writing a font bitmap that will cover all text in the OS..rather than having to individually type each letter..example,code and tutorials (all in fasm) would be much appreciated! thanks everyone
Post 03 Mar 2005, 03:44
View user's profile Send private message Reply with quote
simpaticool



Joined: 12 Jan 2005
Posts: 16
Location: Romania
simpaticool 03 Mar 2005, 07:44
hmm ...
please tell me how to write a font bitmap for each letter
Very Happy

thanks!
Post 03 Mar 2005, 07:44
View user's profile Send private message Reply with quote
Redragon



Joined: 27 Nov 2004
Posts: 101
Location: U.S.
Redragon 03 Mar 2005, 12:47
its actually quite easy, the bitmap is read backwards...like shown below..but one problem i ran into was, you can only have 4 letters, if you have any more than that, the letters wont display correctly..for instance below, was supposed to be "start" instead of "star"... each column represents a letter, each row represents the height....since it says " R A T S " you would read that from right to left, since bitmaps are read backwards



Code:
Star:    ;    R   A  T   S       < THIS IS SPELLED BACKWARDS -  
db          78h,38h,7ch,38h     ;< KNOWING WHICH NUMBERS TO USE IS      
db          40h,44h,10h,44h    ;    EASY, BUT HARD TO EXPLAIN HOW IT WORKS
db          40h,44h,10h,40h    ;    IF ANYONE WANT ME TO, I CAN TRY AND 
db          7ch,7ch,10h,38h     ;    EXPLAIN IT
db          44h,44h,10h,04h
db          44h,44h,10h,44h
db          78h,44h,10h,38h
    
Post 03 Mar 2005, 12:47
View user's profile Send private message Reply with quote
joachim_neu



Joined: 22 Dec 2003
Posts: 139
joachim_neu 03 Mar 2005, 13:08
hm... i wrote a bitmapfont for my OS. therefore my chars are in a 4x6 pixel matrix (you know what i mean!?). every pixel has the value 0 or 1, if 0 the pixel isnt drawn, if 1 the pixel is drawn in the given color. for example:

Code:
db 01101001b,10011001b,10010110b           ;simple zero as number
    


is shown like this:

Code:
 XX 
X  X
X  X
X  X
X  X
 XX
    


my routine fetchs the 3 bytes, writes them into eax and delete the other not set bits. then it rols through the pixels, checks, if 0 or 1 and then calls the function to set a pixel.

i hope i could help,

J!N
Post 03 Mar 2005, 13:08
View user's profile Send private message Visit poster's website Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 8353
Location: Kraków, Poland
Tomasz Grysztar 03 Mar 2005, 13:24
This might be a bit overblown and complicated for your simple problem, but you can take a look at the text writing routine used in my "kelvar" example (available to download from the "Examples" section of this website).
Post 03 Mar 2005, 13:24
View user's profile Send private message Visit poster's website Reply with quote
Redragon



Joined: 27 Nov 2004
Posts: 101
Location: U.S.
Redragon 03 Mar 2005, 16:11
does anyone know how to fix the 4 letter problem?
Post 03 Mar 2005, 16:11
View user's profile Send private message Reply with quote
Dex4u



Joined: 08 Feb 2005
Posts: 1601
Location: web
Dex4u 03 Mar 2005, 19:08
Here is some code from a simple dos game i made, (tasm) years ago, in my OS i do it different, but this is the same principal.
Code:
PutTextS     PROC     MOV     Row,7     MOV     DI,60234     LEA     SI,LetterB     MOV     dh,0Eh     CALL    DrawImage1     MOV     DI,60241     LEA     SI,LetterY     MOV     dh,0Eh     CALL    DrawImage1     MOV     DI,60255     LEA     SI,LetterC     MOV     dh,0Eh     CALL    DrawImage1     MOV     DI,60262     LEA     SI,LetterR     MOV     dh,0Eh     CALL    DrawImage1     MOV     DI,60269     LEA     SI,LetterA     MOV     dh,0Eh     CALL    DrawImage1     MOV     DI,60276     LEA     SI,LetterI     MOV     dh,0Eh     CALL    DrawImage1     MOV     DI,60284     LEA     SI,LetterG     MOV     dh,0Eh     CALL    DrawImage1     MOV     DI,60298     LEA     SI,LetterB     MOV     dh,0Eh     CALL    DrawImage1     MOV     DI,60305     LEA     SI,LetterA     MOV     dh,0Eh     CALL    DrawImage1     MOV     DI,60312     LEA     SI,LetterM     MOV     dh,0Eh     CALL    DrawImage1     MOV     DI,60319     LEA     SI,LetterF     MOV     dh,0Eh     CALL    DrawImage1     MOV     DI,60326     LEA     SI,LetterO     MOV     dh,0Eh     CALL    DrawImage1     MOV     DI,60333     LEA     SI,LetterR     MOV     dh,0Eh     CALL    DrawImage1     MOV     DI,60340     LEA     SI,LetterD     MOV     dh,0Eh     CALL    DrawImage1     MOV     DI,60354     LEA     SI,Two     MOV     dh,0Eh     CALL    DrawImage1     MOV     DI,60361     LEA     SI,Zero     MOV     dh,0Eh     CALL    DrawImage1     MOV     DI,60368     LEA     SI,Zero     MOV     dh,0Eh     CALL    DrawImage1     MOV     DI,60375     LEA     SI,Three     MOV     dh,0Eh     CALL    DrawImage1     MOV     DI,60385     LEA     SI,CopyrightSymbol     MOV     dh,0Eh     CALL    DrawImage1     RETPutTextS     ENDP    

Code:
DrawImage1            proc      MOV     DL,Row      CLDGetData1:      LODSW      MOV     BX,AX      MOV     CL,16CheckBit1:      TEST    BX,8000h      JZ      ZeroBit1      MOV     AL,34                       ;DH      STOSB      JMP     Skip1ZeroBit1:      INC     DISkip1:      SHL     BX,1      LOOP    CheckBit1      ADD     DI,304      DEC     DL      JNZ     GetData1      RETDrawImage1            endp    

Code:
CopyrightSymbol         DW      1e00h,2100h,4c80h,4880h,4c80h,2100h,1e00hLetterA  DW      3800h,4400h,4400h,7c00h,4400h,4400h,4400hLetterB  DW      7800h,4400h,4400h,7800h,4400h,4400h,7800hLetterC  DW      3800h,4400h,4000h,4000h,4000h,4400h,3800hLetterD  DW      7800h,4400h,4400h,4400h,4400h,4400h,7800hLetterE  DW      7c00h,4000h,4000h,7800h,4000h,4000h,7c00hLetterF  DW      7c00h,4000h,4000h,7800h,4000h,4000h,4000hLetterG  DW      3800h,4400h,4000h,5c00h,4400h,4400h,3800hLetterH  DW      4400h,4400h,4400h,7c00h,4400h,4400h,4400hLetterI  DW      7c00h,1000h,1000h,1000h,1000h,1000h,7c00hLetterJ  DW      0400h,0400h,0400h,0400h,0400h,4400h,3800hLetterK  DW      4400h,4800h,5000h,6000h,5000h,4800h,4400hLetterL  DW      4000h,4000h,4000h,4000h,4000h,4000h,7c00hLetterM  DW      4400h,6c00h,5400h,4400h,4400h,4400h,4400hLetterN  DW      4400h,6400h,5400h,4c00h,4400h,4400h,4400hLetterO  DW      3800h,4400h,4400h,4400h,4400h,4400h,3800hLetterP  DW      7800h,4400h,4400h,7800h,4000h,4000h,4000hLetterQ  DW      3800h,4400h,4400h,4400h,4400h,4c00h,3c00hLetterR  DW      7800h,4400h,4400h,7800h,4400h,4400h,4400hLetterS  DW      3800h,4400h,4000h,3800h,0400h,4400h,3800hLetterT  DW      7c00h,1000h,1000h,1000h,1000h,1000h,1000hLetterU  DW      4400h,4400h,4400h,4400h,4400h,4400h,3800hLetterV  DW      4400h,4400h,4400h,4400h,4400h,2800h,1000hLetterW  DW      4400h,4400h,4400h,4400h,5400h,6c00h,4400hLetterX  DW      4400h,4400h,2800h,1000h,2800h,4400h,4400hLetterY  DW      4400h,4400h,2800h,1000h,1000h,1000h,1000hLetterZ  DW      7c00h,0400h,0800h,1000h,2000h,4000h,7c00h    


You can also look at my "CdPod" code(i was ASHLEY4. then) , as that as code for text fonts.
http://board.flatassembler.net/topic.php?t=2164&start=50
Post 03 Mar 2005, 19:08
View user's profile Send private message Reply with quote
Redragon



Joined: 27 Nov 2004
Posts: 101
Location: U.S.
Redragon 04 Mar 2005, 22:21
Dex, i tried your code for the CdPod, works good, but i was wondering what that small light blue box around the text is there for? and how i get rid of it...i also noticed a problem..you can not have more than 4 "letters" in the bitmap, otherwise it will not display correctly.. thanks for the help!
Post 04 Mar 2005, 22:21
View user's profile Send private message Reply with quote
Dex4u



Joined: 08 Feb 2005
Posts: 1601
Location: web
Dex4u 05 Mar 2005, 04:32
The blue box is to cover, the text that was there before, if i had just moved a pixel on a 0 bit, you would of got a mixer of STOP and PLAY, to get rid, just replace this :
Code:
ZeroBit:      mov     eax,0xffa6ffff      stosd    

Code:
ZeroBit:      add  edi,4    


NOTE: Some vesa use 24bpp and some 32bpp, that demo only works on 32bpp, normal you need to test, in the vesa info for 24bpp or 32bpp, if it was 24bpp you would add edi,3.

PS: Here is some old code i did, when first starting vesa text ( its in nasm), its not commented or very well written, i had not been coding very long then Crying or Very sad
just assemble it as a com file and run in dos, may help you ?.

http://myfilebucket.com/u/ASHLEY40/VesaText.asm

It should print string in vesa mode 640x480 256 colors using vesa-windows.

PS: To boot from the Hdd , go here http://alexfru.chat.ru/epm.html#bootprog
and get bootprog.zip in it is code to boot from fat12 floppy or fat16 Hdd.
you can try my OS if you like here: http://falconrybells.co.uk/
froum here: http://dex.7.forumer.com/

Hope this helps.
Post 05 Mar 2005, 04:32
View user's profile Send private message Reply with quote
Redragon



Joined: 27 Nov 2004
Posts: 101
Location: U.S.
Redragon 17 Mar 2005, 19:46
i was wondering though, how menuet did its font defining, to show text in it, all you have to do is test db "hello" , and it shows the text, which means you dont have to individually do each letter, how does that work? thanks!
Post 17 Mar 2005, 19:46
View user's profile Send private message Reply with quote
Dex4u



Joined: 08 Feb 2005
Posts: 1601
Location: web
Dex4u 17 Mar 2005, 20:35
Here is how to do it in a easy to understand way.
Say you take a normal print string function in asm, normaly it test the first char of string for things like "linefeed" or "0" or "carragereturn" etc, if not found it calls a print char function.
So what you do is the same up to the call print char function, but you call this function:
Code:
get_text:        cmp   al,"A"        jne   z1        mov   si,LetterA        jmp   enddz1:        cmp   al,"B"        jne   z2        mov   si,LetterB        jmp   enddz2:        cmp   al,"C"        jne   z3        mov   si,LetterC        jmp   endd;loads more go here;endd:        retSpace         DB      00h,00h,00h,00h,00h,00h,00hLetterA       DB      38h,44h,44h,7ch,44h,44h,44hLetterB       DB      78h,44h,44h,78h,44h,44h,78hLetterC       DB      38h,44h,40h,40h,40h,44h,38h; loads more go here    


Now you can call the draw char function.
Note: You also need vesa function for Y, X ,and scroll etc.
Post 17 Mar 2005, 20:35
View user's profile Send private message Reply with quote
mike.dld



Joined: 03 Oct 2003
Posts: 235
Location: Belarus, Minsk
mike.dld 17 Mar 2005, 21:57
I don't understand what's so hard in drawing text??? As you mentioned Menuet, it has 2 font files (char.mt & char2.mt). One of them with fixed pitch, another one with variable pitch. There's no need to compare if current symbol to draw is 'a' or 'b', you just need to have an array of 'records' (128 'records' for ASCII, 256 otherwise), every of which describes one letter. To determine which 'record' to use in drawing current symbol you just need to multiply symbol code with 'record' size and you'll get offset in array of needed symbol data.
For example, each symbol described as follows:
Code:
...
; 'A' symbol
db 00010000b
db 00101000b
db 01000100b
db 10000010b
db 10000010b
db 11111110b
db 10000010b
db 10000010b
...
movzx eax,byte[esi] ; load next letter into eax
lea eax,[font_start+eax*8] ; determine letter 'record' offset
; draw character data from eax address    
In this case you just need to properly setup text output coordinates and write only one function for characters drawing. For fonts with variable pitch you also need to remember X coordinate for the very right pixel plotted for current character.

As an example you may also take a look at my drawing routine in MeOSEmul sources (on my homepage).
Post 17 Mar 2005, 21:57
View user's profile Send private message Visit poster's website ICQ Number Reply with quote
Redragon



Joined: 27 Nov 2004
Posts: 101
Location: U.S.
Redragon 17 Mar 2005, 22:39
what is the

font_start defined?
Post 17 Mar 2005, 22:39
View user's profile Send private message Reply with quote
mike.dld



Joined: 03 Oct 2003
Posts: 235
Location: Belarus, Minsk
mike.dld 17 Mar 2005, 22:51
'font_start' is label where font declaration starts i.e. just before symbol with code 0 declaration.
Post 17 Mar 2005, 22:51
View user's profile Send private message Visit poster's website ICQ Number Reply with quote
deltre



Joined: 17 Apr 2005
Posts: 12
Location: Netherlands
deltre 23 May 2005, 10:13
Quote:

z1:
cmp al,"B"
jne z2
mov si,LetterB
jmp endd


???

For example, lets use 16x16 bitmaps for each char. This way, every char takes up 256 bytes.
Load a table next to your text draw handling routine that holds 256*256 bytes worth of character bitmaps.

Now upload the bitmap for the capital A into the 65th index of that table (65 * 256), 66 for B, etc.

To display a character, calculate char_table_offset + 256*char_to_display.

If the characters aren't fixed size, use a vector table to address the bitmaps.
Post 23 May 2005, 10:13
View user's profile Send private message Visit poster's website MSN Messenger 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.