Jump to content

how to change characters font

- - - - -

  • Please log in to reply
13 replies to this topic

#1
H2010

H2010

    Newbie

  • Members
  • PipPip
  • 21 posts
hello,

i find this code but i don't know how it works
please if is there anyone know how to change characters font i need a sample example

 push ds   ;
 pop es   ; make sure ES = DS
 mov bp,offset OurFont ;
 mov cx,02   ; we'll change just 2 of them
 mov dx,65   ;   A and B --> our A and B
 mov bh,14   ; 14 bytes per char
 xor bl,bl   ; RAM block
 mov ax,1100h  ; change font to our font
 int 10h   ; video interrupt
 mov ax,4C00h  ; exit to DOS
 int 21h   ;

     OurFont db 00000000b
                db 01111111b
 db 01100011b
 db 01100011b
 db 01100011b
 db 01111111b
 db 01100011b
 db 01100011b
 db 01100011b
 db 01100011b
 db 01100011b
 db 01100011b
 db 00000000b
 db 00000000b

 db 00000000b
 db 01111110b
 db 01100110b
 db 01100110b
 db 01100110b
 db 01111111b
 db 01100011b
 db 01100011b
 db 01100011b
 db 01100011b
 db 01100011b
 db 01111111b
 db 00000000b
 db 00000000b

Edited by dargueta, 09 December 2010 - 04:24 PM.
Added code tags


#2
mebob

mebob

    Programming Expert

  • Members
  • PipPipPipPipPipPip
  • 490 posts
I'm pretty sure that to change fonts, you need to do some I/O writes to the VGA controller.
Latinamne loqueris?

#3
H2010

H2010

    Newbie

  • Members
  • PipPip
  • 21 posts
thank you mebob for your reply

but how we can do that

#4
mebob

mebob

    Programming Expert

  • Members
  • PipPipPipPipPipPip
  • 490 posts
I'm not sure, I tried finding information on the internet about it, but didn't find much. This might help: VGA/SVGA Video Programming--VGA Text Mode Operation
Latinamne loqueris?

#5
H2010

H2010

    Newbie

  • Members
  • PipPip
  • 21 posts
i found this code it works well but i didn't understand it can you tell me how this code work because i haven't experience and i work on tasm


;=========================================================================

;MASM 5.1

.model small, c

.386

.stack

;=========================================================================

.data


    bitPatterns label byte


    db 00000000b

    db 00000000b

    db 00000000b

    db 00000000b

    db 00000000b

    db 000[COLOR="Red"]11[/COLOR]000b

    db 000[COLOR="Red"]11[/COLOR]000b

    db 0[COLOR="Red"]11[/COLOR]00[COLOR="Red"]11[/COLOR]0b

    db 0[COLOR="Red"]11[/COLOR]00[COLOR="Red"]11[/COLOR]0b

    db 000[COLOR="Red"]11[/COLOR]000b

    db 000[COLOR="Red"]11[/COLOR]000b

    db 00000000b

    db 00000000b

    db 00000000b

    db 00000000b

    db 00000000b


    db 00000000b

    db 00000000b

    db 00000000b

    db 000[COLOR="Red"]11[/COLOR]000b

    db 00[COLOR="Red"]1[/COLOR]00[COLOR="Red"]1[/COLOR]00b

    db 000[COLOR="Red"]11[/COLOR]000b

    db 000[COLOR="Red"]11[/COLOR]000b

    db 00[COLOR="Red"]1[/COLOR]00[COLOR="Red"]1[/COLOR]00b

    db 00[COLOR="Red"]1[/COLOR]00[COLOR="Red"]1[/COLOR]00b

    db 0[COLOR="Red"]1[/COLOR]0000[COLOR="Red"]1[/COLOR]0b

    db 0[COLOR="Red"]1[/COLOR]0000[COLOR="Red"]1[/COLOR]0b

    db [COLOR="Red"]1[/COLOR]000000[COLOR="Red"]1[/COLOR]b

    db [COLOR="Red"]11[/COLOR]0000[COLOR="Red"]11[/COLOR]b

    db 00000000b

    db 00000000b

    db 00000000b


    db 00000000b

    db [COLOR="Red"]11111111[/COLOR]b

    db [COLOR="Red"]11111111[/COLOR]b

    db 00[COLOR="Red"]1111[/COLOR]00b

    db 00[COLOR="Red"]1111[/COLOR]00b

    db 00[COLOR="Red"]1111[/COLOR]00b

    db 00[COLOR="Red"]1111[/COLOR]00b

    db 00[COLOR="Red"]1111[/COLOR]00b

    db 00[COLOR="Red"]1111[/COLOR]00b

    db 00[COLOR="Red"]1111[/COLOR]00b

    db 00[COLOR="Red"]1111[/COLOR]00b

    db 00[COLOR="Red"]1111[/COLOR]00b

    db 00[COLOR="Red"]1111[/COLOR]00b

    db [COLOR="Red"]11111111[/COLOR]b

    db [COLOR="Red"]11111111[/COLOR]b

    db 00000000b


    db 11111111b

    db 10000001b

    db 10000001b

    db 10000001b

    db 10000001b

    db 10000001b

    db 10000001b

    db 10000001b

    db 10000001b

    db 10000001b

    db 10000001b

    db 10000001b

    db 10000001b

    db 10000001b

    db 10000001b

    db 11111111b


    db 00011000b

    db 00111100b

    db 01111110b

    db 11111111b

    db 01111110b

    db 00111100b

    db 00011000b

    db 00111100b

    db 01111110b

    db 11111111b

    db 01111110b

    db 00111100b

    db 00011000b

    db 00111100b

    db 01111110b

    db 11111111b


.code

;=========================================================================


  start:


    ;-------------------------------------------------------

    ; When the OS loads the program it leaves DS and ES set

    ; to the segment address of the Program Segment Prefix.

    ; To access the program's data we must set DS to the

    ; segment address of the program's data segment.

    ;

    ; ML 6.0 and later provides a .STARTUP directive that

    ; can be used to do this.

    ;-------------------------------------------------------


    mov ax, DGROUP

    mov ds, ax


    ;----------------------------

    ; Make the cursor invisible.

    ;----------------------------


    mov ah, 1

    mov ch, 00100000b

    int 10h


    ;-----------------------------------------------

    ; Set the cursor position to row 10, column 32.

    ;-----------------------------------------------


    mov ah, 2

    mov bh, 0

    mov dh, 10

    mov dl, 32

    int 10h


    ;---------------------------------------------------------

    ; Under Windows the loaded characters will not be used if

    ; the app is running in a window. Delay for ~5 seconds to

    ; give the user time to switch to full-screen mode.

    ;---------------------------------------------------------


    push 40h

    pop es

    mov bx, 6ch

    mov ecx, es:[bx]

    add ecx, 18*5

  L1:

    mov eax, es:[bx]

    cmp eax, ecx

    jb  L1


    ;-----------------------------------------------------

    ; Load the bit patterns for 5 characters, starting at

    ; character offset 224 in block 0 of the area of the

    ; display memory that is used to store loaded fonts.

    ;-----------------------------------------------------


    mov cx, 5

    mov dx, 224

    mov bl, 0

    mov bh, 16

    push ds

    pop es

    mov bp, OFFSET bitPatterns

    mov ax, 1100h

    int 10h


    ;------------------------------------------------------------

    ; Display the new characters. The REPT directive repeats the

    ; statements between it and the ENDM directive the specified

    ; number of times. For each repeat the current value of N is

    ; substutited in the mov dl, N statement. So the first block

    ; will be assembled as:

    ;   mov ah, 2

    ;   mov dl, 224

    ;   int 21h

    ;   mov ah, 2

    ;   mov dl, 32

    ;   int 21h

    ;   mov ah, 2

    ;   mov dl, 32

    ;   int 21h

    ; The next as:

    ;   mov ah, 2

    ;   mov dl, 225

    ;   int 21h

    ;   . . .

    ; And so on.

    ;------------------------------------------------------------


    N=224

    REPT 5

        mov ah, 2

        mov dl, N

        int 21h

        mov ah, 2

        mov dl, 32

        int 21h

        mov ah, 2

        mov dl, 32

        int 21h

        N=N+1

    ENDM


    ;--------------------------------------

    ; Wait for a key press before exiting.

    ;--------------------------------------


    xor ah, ah

    int 16h


    ;----------------------------------------------------------------

    ; Terminate the program by calling the DOS End Program function.

    ;

    ; ML 6.0 and later provides a .EXIT directive that can be used

    ; to do this.

    ;----------------------------------------------------------------


    mov ax, 4c00h

    int 21h


;=========================================================================

end start



#6
mebob

mebob

    Programming Expert

  • Members
  • PipPipPipPipPipPip
  • 490 posts
Basically, it just uses INT 10 Function 1100h to load the font data.
Latinamne loqueris?

#7
H2010

H2010

    Newbie

  • Members
  • PipPip
  • 21 posts
can you give an example because i'm a newbie in assembly

#8
mebob

mebob

    Programming Expert

  • Members
  • PipPipPipPipPipPip
  • 490 posts
Is there a specific way you want to do it? Like, using interrupts or using PIO?
Latinamne loqueris?

#9
H2010

H2010

    Newbie

  • Members
  • PipPip
  • 21 posts
i don't know what is it mean PIO? but if it is better than using interrupts i want to do it

#10
mebob

mebob

    Programming Expert

  • Members
  • PipPipPipPipPipPip
  • 490 posts
PIO means using the x86 instructions IN and OUT. Interrupts are easier, but PIO is faster. If speed isn't important, than you should just use interrupts.

What OS are you using? DOS or Windows (up to Windows ME, of course)
Latinamne loqueris?

#11
H2010

H2010

    Newbie

  • Members
  • PipPip
  • 21 posts
i'm using WIN XP

#12
mebob

mebob

    Programming Expert

  • Members
  • PipPipPipPipPipPip
  • 490 posts
Oh. In that case, just use interrupts (Int 10/AX=1100h) . Here is an example in NASM syntax. You will probably need to adapt it to TASM syntax:
...Program Startup...
mov ax,0x1100
mov cx,NUMBER_OF_FONTS
mov dx,0
mov bl,1
mov bh,FONT_SIZE_IN_BYTES
int 0x10
...Rest of program...
I have no idea if this will work. It is just a rough example.

Edited by dargueta, 09 December 2010 - 04:26 PM.
Fixed formatting

Latinamne loqueris?




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users