flat assembler
Message board for the users of flat assembler.

Index > OS Construction > Vesa letters

Author
Thread Post new topic Reply to topic
GhostXoPCorp



Joined: 13 Dec 2008
Posts: 199
Location: 01F0:0100
GhostXoPCorp 15 Jun 2009, 07:45
i have seen how to use int 10 in printin a pixel on the screen in real mode, how can i print a letter while in the 320 X 200 graphics mode?

_________________
Oh that divide overflow. Just jumps out of the bushes every time to scare the day lights out of me.
Post 15 Jun 2009, 07:45
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20454
Location: In your JS exploiting you and your system
revolution 15 Jun 2009, 07:53
You have to plot each pixel in the character grid to either the foreground or background colour.

The BIOS can do it for you also, if you are using the BIOS. Although in PM you are on your own, the BIOS can't help you there.
Post 15 Jun 2009, 07:53
View user's profile Send private message Visit poster's website Reply with quote
cod3b453



Joined: 25 Aug 2004
Posts: 618
cod3b453 15 Jun 2009, 13:26
Just like revolution said, the easiest way is to have a bit map of pixels that make each (fixed size) character and create some pixel plotting code to draw each character from a string, keeping track of line and screen wrapping and 'cursor' position. Do you want to do this in real mode still or protected mode?

To set up VESA you want to use ax = 0x4F00/0x4F01/0x4F02/0x4F03 functions of int 0x10 these will get you a list of all supported modes, let you change to VESA mode and get the linear frame buffer (LFB) address of the new mode [as well as other useful info]. Also, make sure you enable A20 before this, otherwise the drawing will go wrong Shocked . You then draw pixels by moving pixel colour values to an offset in the LFB.

The set up code is kind of annoying but it's nice when you can write text or draw shapes at the end of it - looks awesome and makes debugging much easier Cool
Post 15 Jun 2009, 13:26
View user's profile Send private message Reply with quote
LocoDelAssembly
Your code has a bug


Joined: 06 May 2005
Posts: 4624
Location: Argentina
LocoDelAssembly 15 Jun 2009, 15:14
(Perhaps I've posted this already somewhere)
Code:
; TODO: Allow the user to change the zoom factor in runtime (the code is somewhat ready for that)
; TODO: After implementing the TODO above, draw the character on the center of the screen
ESQ   = 27
COLOR = 9;12;9
ZOOM  = 12

org $100

      mov     ax, $13
      int     $10

begin:
      xor     ax, ax
      int     $16

      cmp     al, ESQ
      je      exit

      xor     ah, ah
      mov     cl, 4
      shl     ax, cl
      push    ax

      mov     ax, $1130 ; VIDEO - GET FONT INFORMATION (EGA, MCGA, VGA)
      mov     bh, 6     ; 06h ROM 8x16 font (MCGA, VGA)
      int     $10       ; Return: ES:BP = specified pointer

      pop     di
      lea     si, [bp + di + 1]
      xor     di, di
      push    es
      pop     ds
      mov     ax, $A000
      mov     es, ax
      mov     bl, 16 ; 16 rows
      mov     ch, ZOOM
      mov     cl, ZOOM
      mov     bp, -ZOOM*8

; SI = font pointer
; DI = screen pointer
; BL = rows counter
; BH = columns counter
; CH = row zoom counter
; DH = column zoom counter
; CL = zoom factor

paint:
      dec     si

outerLoop:
      lodsb
      mov     dl, al
      mov     bh, 8  ; 8 columns

innerLoop:
      mov     dh, ZOOM
      shl     dl, 1
      sbb     al, al
      and     al, COLOR

putPixel:
      stosb
      dec     dh
      jnz     putPixel

      dec     bh
      jnz     innerLoop

      lea     di, [di+320+bp]

      dec     ch
      jnz     paint

      mov     ch, ZOOM
      dec     bl
      jnz     outerLoop

      jmp     begin

exit:
      mov     ax, 3
      int     $10

      int     $20    


The font rendering does not use any int.

At least under Windows if you press ALT+X where X is a number in the [0..255] range typed with the numeric pad you'll see the corresponding 437 codepage character.
Post 15 Jun 2009, 15:14
View user's profile Send private message Reply with quote
DOS386



Joined: 08 Dec 2006
Posts: 1905
DOS386 15 Jun 2009, 15:15
revolution wrote:
You have to plot each pixel in the character grid to either the foreground or background colour.


YES.

Quote:
The BIOS can do it for you also, if you are using the BIOS. Although in PM you are on your own, the BIOS can't help you there.


It can .. but it's a bad idea to (painfully) call it for this purpose.
Post 15 Jun 2009, 15:15
View user's profile Send private message Reply with quote
GhostXoPCorp



Joined: 13 Dec 2008
Posts: 199
Location: 01F0:0100
GhostXoPCorp 15 Jun 2009, 16:46
ok, thanks for replying

_________________
Oh that divide overflow. Just jumps out of the bushes every time to scare the day lights out of me.
Post 15 Jun 2009, 16:46
View user's profile Send private message Reply with quote
bitshifter



Joined: 04 Dec 2007
Posts: 796
Location: Massachusetts, USA
bitshifter 16 Jun 2009, 07:53
OMG
DOS386 used the quote button Razz
Post 16 Jun 2009, 07:53
View user's profile Send private message Reply with quote
DOS386



Joined: 08 Dec 2006
Posts: 1905
DOS386 16 Jun 2009, 11:21
bitshifter wrote:
OMG DOS386 used the quote button Razz


Code:
     OMG EAX, EAX
    


Quote:
VESA letters

letter while in the 320 X 200 graphics mode?


FYI, 320x200x8bp is VGA, NOT VESA Laughing

_________________
Bug Nr.: 12345

Title: Hello World program compiles to 100 KB !!!

Status: Closed: NOT a Bug
Post 16 Jun 2009, 11:21
View user's profile Send private message Reply with quote
GhostXoPCorp



Joined: 13 Dec 2008
Posts: 199
Location: 01F0:0100
GhostXoPCorp 16 Jun 2009, 18:07
dos386: sorry, i am still learning the basics of vesa, as you can see, i havent learned much since i dont know which video mode vesa uses
Post 16 Jun 2009, 18:07
View user's profile Send private message Reply with quote
Dex4u



Joined: 08 Feb 2005
Posts: 1601
Location: web
Dex4u 19 Jun 2009, 15:40
You can print in that mode without doing your own fonts, like this
Code:
;**************************************
; First written for tasm
; Converted for fasm
; Assemble with fasm
; C:\fasm FirstOS.asm FirstOS.com
;**************************************
org 100h                            ; code starts at offset 100h
        use16                           ; use 16-bit code
   jmp   start
CR               EQU     13
LF                EQU     10
EOS               EQU     0
; *** Macros ***
;-------------------------------------------
; Fade the text in and out
;-------------------------------------------
Macro    Text_Stuff
{
        mov     dx,3C8h
     mov     al,100                  ; Color reg 100
     out     dx,al
       inc     dx                      ; DX = Color data
   xor     al,al
       out     dx,al                   ; R = 0
     mov     ah,Byte[ds:Text_Color]
  mov     al,ah
       shr     al,2                    ; Color / 4
 out     dx,al                   ; G
 mov     al,ah
       out     dx,al                   ; B

     cmp     Byte[ds:Fade_Dir],1
     je      @@800

; Fade up (INC)
        inc     al
  cmp     al,62
       jne     @@990
       inc     Byte[ds:Fade_Dir]      ; Set fade down flag (1)
 jmp     @@990


; Fade down (DEC)
@@800:        sub     al,2
        jnz     @@990
       dec     Byte[ds:Fade_Dir]

@@990: mov     Byte[ds:Text_Color],al
}
;-------------------------------------------
; Draw the frame buffer to the screen
;-------------------------------------------
Macro  Draw_Flame
{
        mov     al,Byte[ds:Y_Len]
       cmp     al,94
       je      @@105
       inc     al
  cmp     al,1
        mov     Byte[ds:Y_Len],al
       jge     @@105
       jmp     Return


@@105:    cmp     Word[ds:Flame_Ofs],320 * (200-94) + 4
   je      @@205
       sub     Word[ds:Flame_Ofs],320

@@205:    mov     Word[ds:Temp],Frame + 104
       mov     di,Word[ds:Flame_Ofs]
   mov     bl,Byte[ds:Y_Len]
       xor     eax,eax

Line_Loop:
       mov     cx,3                    ; Draw 3 copies

@@305:       push    cx
  mov     si,Word[ds:Temp]       ; Display First image
    mov     cx,104/4
    rep     movsd
       pop     cx
  loop    @@305

   xor     eax,eax
     stosd
       stosd
       add     Word[ds:Temp],104      ; Next line
      dec     bl
  jnz     Line_Loop
Return:
}
;-------------------------------------------
; Calculate the next frame buffer
;-------------------------------------------
Macro        Calc_Flame
{
        mov     si,Frame + 104 - 3
  mov     cx,104 * (94+9-2)

@@101:     mov     al,Byte[ds:si+2*104]   ; Each point is set as the average of
    mov     bl,Byte[ds:si]             ; four pixels to the left below it.
  add     ax,bx
       mov     bl,Byte[ds:si+1]
        sub     ax,3
        add     ax,bx
       mov     bl,Byte[ds:si+104]
      add     ax,bx

   sar     ax,2
        jge     @@201
       xor     ax,ax

@@201: mov     Byte[ds:si-104 + 3],al
  inc     si
  loop    @@101


; Setup botom line with random numbers
     mov     si,Frame+104*(94+9-2)
       mov     cx,104
      xor     dx,dx

@@301: call    Random
      or      ax,ax
       js      @@401
       call    Random

@@401:        sub     al,35  
     mov     Byte[ds:si+104+3],al
    and     al,07fh
     mov     Byte[ds:si],al
  add     si,2
        loop    @@301
}
;------------------------------
; Wait for the start of VR
;------------------------------
Macro    Wait_VR
{
   mov     dx,3DAh
@@100:   in      al,dx
       test    al,8
        je      @@100
@@110:     in      al,dx
       test    al,8
        jne     @@110
}
;************************
; Main loop starts here *
;************************

start:        push    cs                      ; DS = ES = Data in code seg
        pop     ds
  push    cs
  pop     es
  mov     ax,13h                  ; 320 X 200 , 256 colors
    int     10h
 cld


; Clear variables
    mov     di,Frame
    mov     cx,(104*104*2) / 4
  xor     eax,eax
     rep     stosd


; Create fire palette
      mov     di,Palette
  xor     al,al

   mov     cx,6                    ; Black to blue  (CH = ZERO!)
       mov     bx,0102h
    mov     dx,0002h
    call    Make_Pal


; Darkblue to midblue
   mov     cl,10
       xor     ah,ah                   ; I = 0

@@10:        stosb                           ; R
 stosb                           ; G
 mov     bl,14
       sub     bl,ah                   ; B = 14 - I
        mov     Byte [ds:di],bl     ; Store I (B)
       inc     di
  inc     ah                      ; I = I+1
   loop    @@10
        
    
    mov     cl,24                   ; Midblue to brightblue
     mov     bx,182Fh
    mov     dx,0010h
    call    Make_Pal


    mov     cl,32                   ; Brightblue to lightblue/cyan
      mov     bx,101Fh
    mov     dx,0100h
    call    Make_Pal


; Setup palette
 mov     si,Palette
  mov     cl,72*3
     mov     dx,3C8h
     xor     al,al
       out     dx,al
       inc     dx
  rep     outsb


; Write string
     mov     ax,1300h
    mov     bx,0064h
    mov     cl,Byte[ds:Len_String]
  mov     dl,Byte[ds:String_Start]
        mov     dh,0Ah
      mov     bp,String
   int     10h

     push    0A000h                  ; ES = Video RAM
    pop     es

      mov   cx,350 ;1000                   ; time lenth
Main_Loop:
 push  cx
    Wait_VR
     Text_Stuff
  Draw_Flame
  Calc_Flame
  pop  cx
     dec  cx
     cmp  cx,0
   jne  Main_Loop
 
; Exit        
       mov     ax,03h                  ; Set text mode
     int     10h
 mov     ax,04C00h
   int     21h


;------------------------------
; Make one shade
;------------------------------
; In :  CX = Number of colors
;       BL = *
;       BH = /
;       DH = 0 or 1
;       AL Must be zero
;------------------------------
Make_Pal:
        xor     ah,ah                   ; AH = I

@@10a:      push    ax
  stosb                           ; Red
       stosb                           ; Green
     mov     al,ah                   ; AL = I
    mul     bl                      ; AX = AL * BL (I*BL)
       div     bh                      ; AL = AX / BH (I/BH)
       add     al,dl                   ; AL = I + DL

   or      dh,dh
       jz      @@20
        dec     di                      ; Write Green innsted
       stosb
       mov     al,63                   ; B = 63

@@20:       stosb
       pop     ax
  inc     ah                      ; I = I+1 
  loop    @@10a

   ret

;------------------------------
; AX = "Random" number
;------------------------------
Random:
    mov     ax,Word[ds:Seed]
        imul    ax,8905h
    inc     ax
  mov     Word[ds:Seed],ax

    ret


;------------------------------
; Boot program data
;------------------------------
      
Seed              dw      4321h           ; Random seed
Flame_Ofs      dw      320*200 + 4


String            db       '         WELCOME TO MiniDOS!          '
                       
Len_String   dw      38
String_Start      db      1


; The rest of memory is unused so we can use it for our buffers
Frame           =       $               ; 104*(94+9) Words
Temp              =       $ + (104*103)*2 ; Word
Y_Len         =       Temp + 2        ; Byte
Text_Color    =       Y_Len + 1       ; Byte
Fade_Dir      =       Text_Color + 1  ; Byte
Palette       =       Fade_Dir + 1    ; 72 * 3 Bytes
;------------------------------
; Boot program End
;------------------------------

    

Note: this is only that big because of the rest of the demo.


Description:
Filesize: 14.51 KB
Viewed: 5141 Time(s)

MinDos.jpg


Post 19 Jun 2009, 15:40
View user's profile Send private message Reply with quote
GhostXoPCorp



Joined: 13 Dec 2008
Posts: 199
Location: 01F0:0100
GhostXoPCorp 19 Jun 2009, 17:28
now that was what i was looking for Smile , thanks dex
Post 19 Jun 2009, 17:28
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-2025, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.