flat assembler
Message board for the users of flat assembler.
Index
> OS Construction > FONT BITMAPS |
Author |
|
simpaticool 03 Mar 2005, 07:44
hmm ...
please tell me how to write a font bitmap for each letter thanks! |
|||
03 Mar 2005, 07:44 |
|
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 |
|||
03 Mar 2005, 12:47 |
|
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 |
|||
03 Mar 2005, 13:08 |
|
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).
|
|||
03 Mar 2005, 13:24 |
|
Redragon 03 Mar 2005, 16:11
does anyone know how to fix the 4 letter problem?
|
|||
03 Mar 2005, 16:11 |
|
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 |
|||
03 Mar 2005, 19:08 |
|
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!
|
|||
04 Mar 2005, 22:21 |
|
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 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. |
|||
05 Mar 2005, 04:32 |
|
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!
|
|||
17 Mar 2005, 19:46 |
|
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. |
|||
17 Mar 2005, 20:35 |
|
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 As an example you may also take a look at my drawing routine in MeOSEmul sources (on my homepage). |
|||
17 Mar 2005, 21:57 |
|
Redragon 17 Mar 2005, 22:39
what is the
font_start defined? |
|||
17 Mar 2005, 22:39 |
|
mike.dld 17 Mar 2005, 22:51
'font_start' is label where font declaration starts i.e. just before symbol with code 0 declaration.
|
|||
17 Mar 2005, 22:51 |
|
deltre 23 May 2005, 10:13
Quote:
??? 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. |
|||
23 May 2005, 10:13 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.