flat assembler
Message board for the users of flat assembler.

Index > OS Construction > vesa problem (background, box, write text)

Author
Thread Post new topic Reply to topic
grunge



Joined: 11 Sep 2005
Posts: 21
Location: Brasil
grunge 16 Oct 2006, 02:02
Hello All

I use in my OS the video mode "12h"(16 colors), but I trying other video mode(256 colors), but my old functions( Box, Background, Write Text) not run in my new video mode, I need help for translate my old functions for the new video mode, thanks...

My source code:

Code:
ORG 100h 

;   Mov   AX,12h ; My old video mode
;   Int   10h


   Mov   AH,4Fh   ; vesa mode (256 colors)
   Mov   AL,02h
   Mov   BX,0101h ;640 x 480
   Int   10h 

   Mov   [x],0
   Mov   [y],0
   Mov   [color],0

   
   ; My old background and box function, 
   ; not run in vesa mode, but run in "AX,12h (16 colors)"

   Mov   AH,7h        ; Roll
   Mov   AL,0
   Mov   BH,1         ; Blue
   Mov   CL,0         ; X
   Mov   CH,0         ; Y
   Mov   DL,79
   Mov   DH,34
   Int   10h
   Mov   BX,0

   Mov   SI,texto   ; this is the call of my string
   Call  WriteText  ; not run in vesa mode, but run in "AX,12h (16 colors)"

Loop1:
   Inc   [x]
   Inc   [color]
   Call  Pixel
   Cmp   [color],255
   Jne   Loop1

   Jmp   Sair


Pixel:
   Push  ES
   Mov   AX,0A000h 
   Mov   ES,AX
   Mov   AX,320 
   Mul   [y] 
   Add   AX,[x] 
   Mov   BX,AX
   Mov   DL,[color] 
   Mov   [ES:BX],DL
   Pop   ES
   Retn


; my old write text function

WriteText:
   Mov   AH,2    ; set position of cursor
   Mov   DL,100  ; 100/100 (position x/y)
   Mov   DH,100
   Int   10h
   

LoopWrite:
   LodSB
   Cmp   AL,0
   Je    Back
   Mov   AH,0Eh     ; Write Text
   Mov   BL,15      ; White color
   Int   10h
   Jmp   LoopWrite
Back:
   Retn


Sair:          ; exit
   Mov   AX,1
   Int   16h
   Mov   AX,3h
   Int   10h
   Mov   AX,4C00h
   Int   21h

x dw 0
y dw 0
color db 0
texto DB 13,10,'MEU TEXTO/MY TEXT Smile!',0    
Post 16 Oct 2006, 02:02
View user's profile Send private message Reply with quote
Niels



Joined: 17 Sep 2006
Posts: 255
Niels 16 Oct 2006, 17:32
Hello grunge,

Code:
ORG 100h 

;   Mov   AX,12h ; My old video mode
;   Int   10h


   Mov   AH,4Fh   ; vesa mode (256 colors)
   Mov   AL,02h
   Mov   BX,0101h ;640 x 480
   Int   10h 

   Mov   [x],0
   Mov   [y],0
   Mov   [color],0

   
   ; My old background and box function, 
   ; not run in vesa mode, but run in "AX,12h (16 colors)"

;   Mov   AH,7h        ; Roll
;   Mov   AL,0
;   Mov   BH,1         ; Blue
;   Mov   CL,0         ; X
;   Mov   CH,0         ; Y
;   Mov   DL,79
;   Mov   DH,34
;   Int   10h
;   Mov   BX,0

   Mov   SI,texto   ; this is the call of my string
   Call  WriteText  ; not run in vesa mode, but run in "AX,12h (16 colors)"

Loop1:
   Inc   [x]
   Inc   [color]
   Call  Pixel
   Cmp   [color],255
   Jne   Loop1

   Jmp   Sair


Pixel:
   Push  ES
   Mov   AX,0A000h 
   Mov   ES,AX
   Mov   AX,320 
   Mul   [y] 
   Add   AX,[x] 
   Mov   BX,AX
   Mov   DL,[color] 
   Mov   [ES:BX],DL
   Pop   ES
   Retn


; my old write text function

WriteText:
   Mov   AH,2    ; set position of cursor
   Mov   DL,100  ; 100/100 (position x/y)
   Mov   DH,100
   Int   10h
   

LoopWrite:
   LodSB
   Cmp   AL,0
   Je    Back
   Mov   AH,0Eh     ; Write Text
   Mov   BL,15      ; White color
   Int   10h
   Jmp   LoopWrite
Back:
   Retn


Sair:          ; exit
   Mov   AX,1
   Int   16h
   Mov   AX,3h
   Int   10h
   Mov   AX,4C00h
   Int   21h

x dw 0
y dw 0
color db 0
texto DB 13,10,'MEU TEXTO/MY TEXT Smile!',0
    
Post 16 Oct 2006, 17:32
View user's profile Send private message Reply with quote
Niels



Joined: 17 Sep 2006
Posts: 255
Niels 16 Oct 2006, 19:28
Hello grunge,

I seldom use this type of interrupts.

Code:
ORG 100h 

;   Mov   AX,12h ; My old video mode
;   Int   10h


   Mov   AH,4Fh   ; vesa mode (256 colors)
   Mov   AL,02h
   Mov   BX,0101h ;640 x 480
   Int   10h 

   Mov   [x],0
   Mov   [y],0
   Mov   [color],0

   
   ; My old background and box function, 
   ; not run in vesa mode, but run in "AX,12h (16 colors)"

   Mov   AH,7h        ; Roll
   Mov   AL,0
   Mov   BH,1         ; Blue
   Mov   CL,0         ; X
   Mov   CH,1         ; Y
   Mov   DL,79
   Mov   DH,34
   Int   10h
   Mov   BX,0

   Mov   SI,texto   ; this is the call of my string
   Call  WriteText  ; not run in vesa mode, but run in "AX,12h (16 colors)"

Loop1:
   Inc   [x]
   Inc   [color]
   Call  Pixel
   Cmp   [color],255
   Jne   Loop1

   Jmp   Sair


Pixel:
   Push  ES
   Mov   AX,0A000h 
   Mov   ES,AX
   Mov   AX,320 
   Mul   [y] 
   Add   AX,[x] 
   Mov   BX,AX
   Mov   DL,[color] 
   Mov   [ES:BX],DL
   Pop   ES
   Retn


; my old write text function

WriteText:
   Mov   AH,2    ; set position of cursor
   Mov   DL,100  ; 100/100 (position x/y)
   Mov   DH,100
   Int   10h
   

LoopWrite:
   LodSB
   Cmp   AL,0
   Je    Back
   Mov   AH,0Eh     ; Write Text
   Mov   BL,15      ; White color
   Int   10h
   Jmp   LoopWrite
Back:
   Retn


Sair:          ; exit
   Mov   AX,1
   Int   16h
   Mov   AX,3h
   Int   10h
   Mov   AX,4C00h
   Int   21h

x dw 0
y dw 0
color db 0
texto DB 13,10,'MEU TEXTO/MY TEXT Smile!',0
    
Post 16 Oct 2006, 19:28
View user's profile Send private message Reply with quote
grunge



Joined: 11 Sep 2005
Posts: 21
Location: Brasil
grunge 16 Oct 2006, 21:55
Hello Niels

thanks for your help... I trying the Internet.... but not found one solution...
Post 16 Oct 2006, 21:55
View user's profile Send private message Reply with quote
Dex4u



Joined: 08 Feb 2005
Posts: 1601
Location: web
Dex4u 17 Oct 2006, 01:53
Here is some code i did when i first started, it uses vesa1 and fonts
Code:
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;                                           ;;;; fasm example.By Craig Bamford (Dex) 2002. ;;;; 640*480 8bpp (256 colors) vesa1           ;;;; C:\fasm vesa1.asm vesa1.com               ;;;;                                           ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;ORG    100hStart:        mov ax,4f02h        mov bx,101h        int 10h        mov dx,0xa000        mov es,dx        call windowStartAgain:        xor dx,dxMainLoop:        push dx        call window        xor bx,bx        mov al,0x00        call static        call PutTextB        call PutTextS        pop dx        cmp dx,4        je StartAgain        inc dx        mov ah,00h        int 16h        jz MainLoop        mov ax,0003h        int 10h        retwindow:        mov ax,4f05h            mov bx,0        int 10h        xor bx,bx        retstatic:        stosb        inc bx        cmp bx,0x00000        jne static        retPutTopBackGround:        xor di,di        mov cx,0x1900        mov al,0x81        rep stosb        ret                     PutBottomBackGround:        mov di,58240        mov cx,0x17c0        mov al,0x81        rep stosb        retDrawImage:        mov di,bx        mov dl,[Row]        cldGetData:             lodsw        mov bx,ax        mov cl,16CheckBit:        test bx,0x8000        jz ZeroBit        mov al,dh            stosb        jmp Skip                    ZeroBit:        inc diSkip:        shl bx,1        loop CheckBit                  add di,624        dec dl        jnz  GetData        retPutTextB:        mov byte [Row],16        xor di,di        mov di,716        mov bx,di        mov SI,TextS        mov dh,0x0a        call DrawImage        xor di,di        mov di,733        mov bx,di        mov SI,TextP        mov dh,0x0a        call DrawImage        xor di,di        mov di,750        mov bx,di        mov SI,TextA        mov dh,0x0a        call DrawImage        xor di,di        mov di,767        mov bx,di        mov SI,TextC        mov dh,0x0a        call DrawImage        xor di,di        mov di,784        mov bx,di        mov SI,TextE        mov dh,0x0a        call DrawImage        xor di,di        mov di,813        mov bx,di        mov SI,TextP        mov dh,0x0a        call DrawImage        xor di,di        mov di,830        mov bx,di        mov SI,TextO        mov dh,0x0a        call DrawImage        xor di,di        mov di,847        mov bx,di        mov SI,TextN        mov dh,0x0a        call DrawImage        xor di,di        mov di,864        mov bx,di        mov SI,TextG        mov dh,0x0a        call DrawImage        ret   PutTextS:        mov byte [Row],7        mov di,60234        mov bx,di        mov si,LetterB        mov dh,0ah        call DrawImage        mov di,60241        mov bx,di        mov si,LetterY        mov dh,0ah        call DrawImage            mov di,60255        mov bx,di        mov si,LetterC        mov dh,0ah        call DrawImage             mov di,60262        mov bx,di        mov si,LetterR        mov dh,0ah        call DrawImage        mov di,60269        mov bx,di        mov si,LetterA        mov dh,0ah        call DrawImage        mov di,60276        mov bx,di        mov si,LetterI        mov dh,0ah        call DrawImage        mov di,60284        mov bx,di        mov si,LetterG        mov dh,0ah        call DrawImage        mov di,60298        mov bx,di        mov si,LetterB        mov dh,0ah        call DrawImage        mov di,60305        mov bx,di        mov si,LetterA        mov dh,0ah        call DrawImage        mov di,60312        mov bx,di        mov si,LetterM        mov dh,0ah        call DrawImage        mov di,60319        mov bx,di        mov si,LetterF        mov dh,0ah        call DrawImage        mov di,60326        mov bx,di        mov si,LetterO        mov dh,0ah        call DrawImage        mov di,60333        mov bx,di        mov si,LetterR        mov dh,0ah        call DrawImage        mov di,60340        mov bx,di        mov si,LetterD        mov dh,0ah        call DrawImage        mov di,60354        mov bx,di        mov si,Two        mov dh,0ah        call DrawImage        mov di,60361        mov bx,di        mov si,Zero        mov dh,0ah        call DrawImage           mov di,60368        mov bx,di        mov si,Zero        mov dh,0ah        call DrawImage        mov di,60375        mov bx,di        mov si,Three        mov dh,0ah        call DrawImage        mov di,60385        mov bx,di        mov si,CopyrightSymbol        mov dh,0ah        call DrawImage        retRow      DB         0TextA    DW         0FFFFh,08001h,08001h,08001h,087E1h,08421h,08421h,087E1h         DW         08001h,08001h,087E1h,08421h,08421h,08421h,08421h,0FC3FhTextC    DW         0FFFEh,08002h,08002h,087E2h,0843Eh,08400h,08400h,08400h         DW         08400h,08400h,0843Eh,08422h,087E2h,08002h,08002h,0FFFEhTextE    DW         0FFFFh,08001h,08001h,087FFh,08400h,08400h,087FEh,08002h         DW         08002h,087FEh,08400h,08400h,087FFh,08001h,08001h,0FFFFhTextS    DW         0FFFFh,08001h,08001h,087E1h,0843Fh,08400h,087FFh,08001h         DW         08001h,0FFE1h,00021h,0FC21h,087E1h,08001h,08001h,0FFFFhTextM1   DW         0FFFFh,08000h,08000h,08000h,09FE7h,09024h,09024h,09024h         DW         09024h,09024h,09024h,09024h,09024h,09024h,09024h,0F03ChTextM2   DW         0FF00h,00100h,00100h,00100h,0F900h,00900h,00900h,00900h         DW         00900h,00900h,00900h,00900h,00900h,00900h,00900h,00F00hTextP    DW         0FFFFh,08001h,08001h,087F9h,08409h,08409h,08409h,087F9h         DW         08001h,08001h,087FFh,08400h,08400h,08400h,08400h,0FC00h TextO    DW         0FFFFh,08001h,08001h,087E1h,08421h,08421h,08421h,08421h         DW         08421h,08421h,08421h,08421h,087E1h,08001h,08001h,0FFFFh  TextN    DW         0FFFFh,08001h,08001h,087E1h,08421h,08421h,08421h,08421h         DW         08421h,08421h,08421h,08421h,08421h,08421h,08421h,0FC3FhTextG    DW         0FFFEh,08002h,08002h,087E2h,0843Eh,08400h,08400h,08400h         DW         0847Fh,08441h,08463h,08422h,087E2h,08002h,08002h,0FFFEhTwo      DW         3800h,4400h,0400h,1800h,2000h,4000h,7c00hZero     DW         3800h,4400h,4c00h,5400h,6400h,4400h,3800hThree    DW         3800h,4400h,0400h,1800h,0400h,4400h,3800hLetterA  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,7c00hCopyrightSymbol DW  1e00h,2100h,4c80h,4880h,4c80h,2100h,1e00h    
Post 17 Oct 2006, 01:53
View user's profile Send private message Reply with quote
Niels



Joined: 17 Sep 2006
Posts: 255
Niels 17 Oct 2006, 15:41
grunge wrote:
Quote:
I trying the Internet.... but not found one solution...


Isn't this the internet or did you not found any solution? Smile

Niels.
Post 17 Oct 2006, 15:41
View user's profile Send private message Reply with quote
grunge



Joined: 11 Sep 2005
Posts: 21
Location: Brasil
grunge 17 Oct 2006, 16:05
Hello All

Dex4u, thanks for your help... this solution is very good for my project... I go working in the "background" and "box"...

Niels, thanks... it is the Internet... Smile

"Iternet... one parallel world..." Smile
Post 17 Oct 2006, 16:05
View user's profile Send private message Reply with quote
grunge



Joined: 11 Sep 2005
Posts: 21
Location: Brasil
grunge 18 Oct 2006, 02:20
I have found one limitation

When I use one resolution 640x480(or other), the position of image is limited in 100 px(Y position), is one limitation?

Ex:
PosY = 100
PosX = 100
PosY * 640 + PosY correct? = 64100

Code:
        mov byte [Row],7
        mov di,64100
        mov bx,di
        mov si,LetterR
        mov dh,0ah
        call DrawImage    


Thanks...
Post 18 Oct 2006, 02:20
View user's profile Send private message Reply with quote
Dex4u



Joined: 08 Feb 2005
Posts: 1601
Location: web
Dex4u 18 Oct 2006, 03:23
As your in realmode you limted to 64k, so this mode uses 1 boxs 64k in size, you need to swich boxs eg:
********box0****
64k
********box1****
64k
********box2****
64k
********box3****
64k
********box4****
64k
****************
Here this may help
Code:
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;                                           ;;;; fasm example.By Craig Bamford (Dex) 2002. ;;;; 640*480 8bpp (256 colors) vesa1           ;;;; C:\fasm vesa1.asm vesa1.com               ;;;;                                           ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;ORG    100hStart:        mov ax,4f02h        mov bx,101h        int 10h        mov dx,0xa000        mov es,dx        call windowStartAgain:        xor dx,dx        mov [color],0      MainLoop:        push dx        call window        xor bx,bx        inc [color]        mov al,[color]        call static        pop dx        cmp dx,4        je StartAgain        inc dx  ;<** here is box number        mov ah,01h        int 16h        jz MainLoop        mov ah,00h        int 16h        mov ax,0003h        int 10h        retwindow:        mov ax,4f05h        mov bx,0        int 10h        xor bx,bx        retstatic:                 stosb        inc bx        cmp bx,0x00000        jne static        retcolor    db         0Row      db         0    

PS: I for got that old code loop once, as it only used on box, the above will do all windows (boxs).


Last edited by Dex4u on 19 Oct 2006, 21:58; edited 1 time in total
Post 18 Oct 2006, 03:23
View user's profile Send private message Reply with quote
grunge



Joined: 11 Sep 2005
Posts: 21
Location: Brasil
grunge 19 Oct 2006, 21:50
Hello Dex4u

I use your suggestion, I replace the register DI(position) for register EDI(for big numbers) and work in 64k blocks.

Thanks...
Post 19 Oct 2006, 21:50
View user's profile Send private message Reply with quote
Dex4u



Joined: 08 Feb 2005
Posts: 1601
Location: web
Dex4u 19 Oct 2006, 22:03
Your welcome, if you goto Pmode and have vesa2, you can use LFB much easier and quicker, i havewritten a demo for this, if you want a look let me know.
Post 19 Oct 2006, 22:03
View user's profile Send private message Reply with quote
grunge



Joined: 11 Sep 2005
Posts: 21
Location: Brasil
grunge 19 Oct 2006, 23:22
Hi Dex4u

I interest in your demo, I will have one hard work in my OS... but it is necessary... Smile

Thanks...
Post 19 Oct 2006, 23:22
View user's profile Send private message Reply with quote
Dex4u



Joined: 08 Feb 2005
Posts: 1601
Location: web
Dex4u 20 Oct 2006, 18:00
You can get it here, but you need vesa2

Note: first i was call "ASHLEY4" when i made this, also this demo shows going to and from pmode to change from vesa mode to text mode every 10 seconds.


Last edited by Dex4u on 15 Mar 2011, 17:30; edited 1 time in total
Post 20 Oct 2006, 18:00
View user's profile Send private message Reply with quote
grunge



Joined: 11 Sep 2005
Posts: 21
Location: Brasil
grunge 21 Oct 2006, 00:47
Dex4u, thanks for all help...
Post 21 Oct 2006, 00:47
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.