Hello!
I'm writting a VESA code, it works when I use debug to run it, but it doesn't work when I run it directly.
Can anyone help me?

the code and include file:
;-- -------------------------------------begin:VESA.ASM----------------------

org 100h
include 'vesa.inc'


jmp start





start:
call getVesaInfo
call getModeInfo
call getMode
mov [omode],bx
call setMode
call line

mov ax,0
int 16h

call restoreOMode
int 20h

pixelw:
mov ax,[mode.BytesPerScanLine]
mul [y]
mov bx,[x]
shl bx,1
add ax,bx
jnc noc
inc dx
noc:
mov [ofs],ax
cmp dx,[bank]
jz same
mov [bank],dx
mov cx,[bankshift]
shl dx,cl
xor bx,bx
call far [mode.WinFuncPtr]

same:
push di
mov ax,0a000h
mov es,ax
mov di,[ofs]
mov ax,[color]
mov [es:di],ax
pop di
ret

line:
mov [color],1111100000011111b
mov [x],100
mov [y],100
call pixelw
ret

getVesaInfo:
mov di,vesa
mov ax,4f00h ;VBE get vesa info function
int 10h
ret


getModeInfo:
mov di,mode
mov ax,4f01h ;VBE get mode info function
mov cx,[vmode] ;The video mode to get the information
int 10h
ret

setMode:
mov ax,4f02h ;VBE set video mode function
mov bx,[vmode] ;One of the supported vesa modes
int 10h
mov ax,[mode.WinSize]
mov bx, [mode.WinGranularity]
div bx
g0: cmp ax,1
jne g1
mov [bankshift],0
ret
g1: cmp ax,2
jne g2
mov [bankshift],1
ret
g2: cmp ax,4
jne g3
mov [bankshift],2
ret
g3: cmp ax,8
jne g4
mov [bankshift],3
ret
g4: cmp ax,16
jne g5
mov [bankshift],4
ret
g5: cmp ax,32
jne g6
mov [bankshift],5
ret
g6: cmp ax,1
jne gd
mov [bankshift],6

gd: ret

getMode:
mov ax,4f03h ;VBE return the current video mode funtion
int 10h ;Value will be returned in BX
;mov [vmode],bx ;Put current mode in vmode
ret

restoreOMode:
mov ax,4f02h
mov bx,[omode]
int 10h
ret

vmode dw 114h
bds dw ?
vesa vesaInfo
mode vesaModeInfo

y dw ?
x dw ?
color dw ?
omode dw ? ;older mode

bank dw ?
ofs dw ?
bankshift dw ?

;---------------------------------------end:VESA.ASM----------------------

;---------------------------------------begin:VESA.INC----------------------

struc vesaInfo
{
.VbeSignature dd ? ; VBE Signature
.VbeVersion dw ? ; VBE Version
.OemStringPtr dd ? ; VbeFarPtr to OEM String
.Capabilities dd ? ; Capabilities of graphics controller
.VideoModePtr dd ? ; VbeFarPtr to VideoModeList
.TotalMemory dw ? ; Number of 64kb memory blocks
; Added for VBE 2.0+
.OemSoftwareRev dw ? ; VBE implementation Software revision
.OemVendorNamePtr dd ? ; VbeFarPtr to Vendor Name String
.OemProductNamePtr dd ? ; VbeFarPtr to Product Name String
.OemProductRevPtr dd ? ; VbeFarPtr to Product Revision String
.Reserved rb 222 ; Reserved for VBE implementation scratch area
.OemData rb 256 ; Data Area for OEM Strings
}


struc vesaModeInfo
{
.ModeAttributes dw ? ; mode attributes
.WinAAttributes db ? ; window A attributes
.WinBAttributes db ? ; window B attributes
.WinGranularity dw ? ; window granularity
.WinSize dw ? ; window size
.WinASegment dw ? ; window A start segment
.WinBSegment dw ? ; window B start segment
.WinFuncPtr dd ? ; real mode pointer to window function
.BytesPerScanLine dw ? ; bytes per scan line

; Mandatory information for VBE 1.2 and above
.XResolution dw ? ; horizontal resolution in pixels or characters3
.YResolution dw ? ; vertical resolution in pixels or characters
.XCharSize db ? ; character cell width in pixels
.YCharSize db ? ; character cell height in pixels
.NumberOfPlanes db ? ; number of memory planes
.BitsPerPixel db ? ; bits per pixel
.NumberOfBanks db ? ; number of banks
.MemoryModel db ? ; memory model type
.BankSize db ? ; bank size in KB
.NumberOfImagePages db ? ; number of images
.Reserved1 db ? ; reserved for page function

; Direct Color fields (required for direct/6 and YUV/7 memory models)
.RedMaskSize db ? ; size of direct color red mask in bits
.RedFieldPosition db ? ; bit position of lsb of red mask
.GreenMaskSize db ? ; size of direct color green mask in bits
.GreenFieldPosition db ? ; bit position of lsb of green mask
.BlueMaskSize db ? ; size of direct color blue mask in bits
.BlueFieldPosition db ? ; bit position of lsb of blue mask
.RsvdMaskSize db ? ; size of direct color reserved mask in bits
.RsvdFieldPosition db ? ; bit position of lsb of reserved mask
.DirectColorModeInfo db ? ; direct color mode attributes

; Mandatory information for VBE 2.0 and above
.PhysBasePtr dd ? ; physical address for flat memory frame buffer
.Reserved2 dd ? ; Reserved - always set to 0
.Reserved3 dw ? ; Reserved - always set to 0

; Mandatory information for VBE 3.0 and above
.LinBytesPerScanLine dw ? ; bytes per scan line for linear modes
.BnkNumberOfImagePages db ? ; number of images for banked modes
.LinNumberOfImagePages db ? ; number of images for linear modes
.LinRedMaskSize db ? ; size of direct color red mask (linear modes)
.LinRedFieldPosition db ? ; bit position of lsb of red mask (linear modes)
.LinGreenMaskSize db ? ; size of direct color green mask (linear modes)
.LinGreenFieldPosition db ? ; bit position of lsb of green mask (linear modes)
.LinBlueMaskSize db ? ; size of direct color blue mask (linear modes)
.LinBlueFieldPosition db ? ; bit position of lsb of blue mask (linear modes)
.LinRsvdMaskSize db ? ; size of direct color reserved mask (linear modes)
.LinRsvdFieldPosition db ? ; bit position of lsb of reserved mask (linear modes)
.MaxPixelClock dd ? ; maximum pixel clock (in Hz) for graphics mode
.Reserved4 rb 189 ; remainder of ModeInfoBlock

}
;---------------------------------------end:VESA.INC----------------------
Thank You!!!
Posted on 2002-09-30 15:50:19 by Despero
Hi Despero,
can you tell us what system are you running it from and what OS?
Maybe you have conflicts because of that.
Posted on 2002-10-02 09:59:24 by slop
I'm testing it in a
486 DX2 66Mhz
4Mb RAM
VESA 1.2 compatible

In DOS 7.0 version
Posted on 2002-10-02 13:59:28 by Despero
Hi again Despero,

I think the problem can be solved with this:


virtual at 0
vesa vesaInfo
mode vesaModeInfo
end virtual


This is required to acces the struct as an offset.

Tell us if it works.
Posted on 2002-10-04 09:55:25 by slop
Hi Sloppy!
I discover what's the problem, it was at SETMODE:
there was a "DIV BX" to discover then bankshift.

I was blind and I see the light!
When I put "virtual at 0" where you said I received an error "Divided by 0",
so I remembered:
DIV BL --> AX divided by BL
DIV BX --> DX:AX divided by BX
DIV EBX --> EDX:EAX divided by EBX

I think the problem occur because DX isn't 0, the result doens't fit in AX and quotient in DX, so I use XOR DX,DX before the DIV BX and program worked!

I bilieve that in debug the program work becaus DX is set to 0 when then debug starts.

THANK YOU!!!


Everbody is a little sleepwalker!!!
Posted on 2002-10-04 14:18:01 by Despero
Hello Despero

You are right.The problem is in DIV BX .
You must use XOR DX,DX before the DIV BX .
I program with MASM.
A few days ago,I begun programming with FASM.
I think that is better.I work at programming with VESA.
But i have a problem.VESA has by default refresh ratio 60 Hz.
With this refresh the screen flicker.I attempt to change the refresh
but i can not accomplish this.
If you or any other know about this,tell me.

In your code i have insert a part of code to see this.
Build this as '.COM'.
;-------------------------------start: VESA.asm-------------------------------------
org 100h
include 'vesa.inc'

jmp start

start:
call getVesaInfo
call getModeInfo
call getMode
mov ,bx
call setMode

mov ,1111100000011111b
mov ,0
loopY:
mov ,0
loopX:
call pixelw
inc
cmp ,800
jne loopX
inc
cmp ,600
jne loopY

mov ax,0
int 16h

call restoreOMode
int 20h

pixelw:
mov ax,
mul
mov bx,
shl bx,1
add ax,bx
jnc noc
inc dx
noc:
mov ,ax
cmp dx,
jz same
mov ,dx
mov cx,
shl dx,cl
xor bx,bx
call far

same:
push di
mov ax,0a000h
mov es,ax
mov di,
mov ax,
mov ,ax
pop di
ret

line:
mov ,1111100000011111b
mov ,100
mov ,100
call pixelw
ret

getVesaInfo:
mov di,vesa
mov ax,4f00h ;VBE get vesa info function
int 10h
ret


getModeInfo:
mov di,mode
mov ax,4f01h ;VBE get mode info function
mov cx, ;The video mode to get the information
int 10h
ret

setMode:
mov ax,4f02h ;VBE set video mode function
mov bx, ;One of the supported vesa modes
int 10h
mov ax,
mov bx,
xor dx,dx
div bx
g0: cmp ax,1
jne g1
mov ,0
ret
g1: cmp ax,2
jne g2
mov ,1
ret
g2: cmp ax,4
jne g3
mov ,2
ret
g3: cmp ax,8
jne g4
mov ,3
ret
g4: cmp ax,16
jne g5
mov ,4
ret
g5: cmp ax,32
jne g6
mov ,5
ret
g6: cmp ax,1
jne gd
mov ,6

gd: ret

getMode:
mov ax,4f03h ;VBE return the current video mode funtion
int 10h ;Value will be returned in BX
;mov ,bx ;Put current mode in vmode
ret

restoreOMode:
mov ax,4f02h
mov bx,
int 10h
ret

vmode dw 114h
bds dw ?
vesa vesaInfo
mode vesaModeInfo

y dw ?
x dw ?
color dw ?
omode dw ? ;older mode

bank dw ?
ofs dw ?
bankshift dw ?

;---------------------------------------end:VESA.ASM----------------------
Regards,Manos.
Posted on 2002-11-03 09:05:22 by Anonymous
Add this to vesa.inc, you'll need this to set refresh rate. You'll need to compute this values. I didn't test this yet. So, please, read about vesa programming before and try to find any problem in the code first.
If I not wrong, you can find more info on www.vesa.org (or .com, I don't remember now) there you can find the file vbe3.pdf what I think you must read while you are programming vesa.
Take care when using this to prevent any Hardware Damage.

struc CRTCInfoBlock
{
.HorizontalTotal dw ? ; Horizontal total in pixels
.HorizontalSyncStart dw ? ; Horizontal sync start in pixels
.HorizontalSyncEnd dw ? ; Horizontal sync end in pixels
.VerticalTotal dw ? ; Vertical total in lines
.VerticalSyncStart dw ? ; Vertical sync start in lines
.VerticalSyncEnd dw ? ; Vertical sync end in lines
.Flags db ? ; Flags (Interlaced, Double Scan etc)
.PixelClock dd ? ; Pixel clock in units of Hz
.RefreshRate dw ? ; Refresh rate in units of 0.01 Hz

.Reserved rb 40 ; remainder of ModeInfoBlock
}

Now you put this when set video mode in vesa.asm:

setMode:
mov ax,4f02h ;VBE set video mode function
mov bx, ;One of the supported vesa modes
or bx,0800h ; 100000000000b set bit D11 to use CRTC info, if not set.
push ds ;
pop es ; load es with the segment of CRTC
mov di,CRTC ; load di with the offset of CRTC
int 10h


; setting the granularity
mov ax,
mov bx,
xor dx,dx
div bx
g0: cmp ax,1
jne g1
mov ,0
ret
g1: cmp ax,2
jne g2
mov ,1
ret
g2: cmp ax,4
jne g3
mov ,2
ret
g3: cmp ax,8
jne g4
mov ,3
ret
g4: cmp ax,16
jne g5
mov ,4
ret
g5: cmp ax,32
jne g6
mov ,5
ret
g6: cmp ax,1
jne gd
mov ,6

gd: ret

in data you must put this:

CRTC CRTCInfoBlock

You need to put the right data in CRTCInfoBlock before you use it.
to compute the refresh rate:

refreshRate = PixelClock / (HorizontalTotal * VerticalTotal)

you can use the MaxPixelClock from vesaModeInfo

or use the current PixelClock, to get or set you use vesa function 0Bh.
mov ax,4f0bh ;get / set pixel clock
mov bl,00h ;to get
mov ecx, ; you compute before in Hz unit.
mov dx, ; the video mode you want to change the pixel clock.
int 10h

; output:
; ax shows the status
; ecx shows the closest pixel clock (using bl = 0)

I think I didn't forget anything.
Good Bye.
Posted on 2002-11-04 09:31:32 by Despero
Hello Despero.

I had use something like your code with MASM but it had fails.
Now,it is fine.

Note:The refresh rate calculate in 0.01 units.
For examble,a number 8500=85 Hz.

Look the following and build it as '.COM'.

org 100h
include 'vesa.inc'

jmp start

start:

mov ,114h
call getVesaInfo
call getModeInfo
call getMode
mov ,bx

mov ,1072
mov ,848
mov ,936
mov ,636
mov ,601
mov ,604
mov ,0
mov ,57952320
mov ,8500 ;85 Hz
call setMode

mov ,1111100000011111b
mov ,0
loopY:
mov ,0
loopX:
call pixelw
inc
cmp ,800
jne loopX
inc
cmp ,600
jne loopY

mov ax,0
int 16h

call restoreOMode
int 20h

pixelw:
mov ax,
mul
mov bx,
shl bx,1
add ax,bx
jnc noc
inc dx
noc:
mov ,ax
cmp dx,
jz same
mov ,dx
mov cx,
shl dx,cl
xor bx,bx
call far

same:
push di
mov ax,0a000h
mov es,ax
mov di,
mov ax,
mov ,ax
pop di
ret

line:
mov ,1111100000011111b
mov ,100
mov ,100
call pixelw
ret

getVesaInfo:
mov di,vesa
mov ax,4f00h ;VBE get vesa info function
int 10h
ret


getModeInfo:
mov di,mode
mov ax,4f01h ;VBE get mode info function
mov cx, ;The video mode to get the information
int 10h
ret

setMode:
mov ax,4f02h ;VBE set video mode function
mov bx, ;One of the supported vesa modes
or bx,0800h ; 100000000000b set bit D11 to use CRTC info, if not set.
push ds ;
pop es ; load es with the segment of CRTC
mov di,CRTC ; load di with the offset of CRTC
int 10h
mov ax,
mov bx,
xor dx,dx
div bx
g0: cmp ax,1
jne g1
mov ,0
ret
g1: cmp ax,2
jne g2
mov ,1
ret
g2: cmp ax,4
jne g3
mov ,2
ret
g3: cmp ax,8
jne g4
mov ,3
ret
g4: cmp ax,16
jne g5
mov ,4
ret
g5: cmp ax,32
jne g6
mov ,5
ret
g6: cmp ax,1
jne gd
mov ,6

gd: ret

getMode:
mov ax,4f03h ;VBE return the current video mode funtion
int 10h ;Value will be returned in BX
mov ,bx ;Put current mode in vmode
ret

restoreOMode:
mov ax,4f02h
mov bx,
int 10h
ret

vmode dw ?
bds dw ?
vesa vesaInfo
mode vesaModeInfo
CRTC CRTCInfoBlock

y dw ?
x dw ?
color dw ?
omode dw ? ;older mode

bank dw ?
ofs dw ?
bankshift dw ?

;---------------------------------------end:VESA.ASM----------------------
Note:
If you want,tell me how can i calculate a color value.

Thanks very much.Manos.
Posted on 2002-11-04 11:47:29 by Anonymous
the mode 114h has 16 bits.
bits 0 to 4 - to blue
bits 5 to 10 - to green
and 11 to 15 - to red

the order of bits:
RRRRRGGGGGGBBBBB ; (5:6:5) Note green has 6 bits in mode 114h and all 16 bits mode.

in mode 113h for example (15 bits) you have the order:
URRRRRGGGGGBBBBB ; (1:5:5:5) Five bits per color

24 bits (8:8:8) and 32 bits are esier to use, you can the value directly in memory without any calculation.

Let me remember, I used a function to convert a (8:8:8) 24bits value to convert to 16 bits or 15 bits.

pixelw function put a 15 or 16 bit pixel.
you'll need other to 24 and 32 bit, other to 8 bit (DAC colors), or 4 bits (16 colors).


assuming you have in data:
red db ?
blue db ?
green db ?
color dw ? ;it can be used by 15 and 16 bits. I won't use this in this example.

;converting red, green, blue(8:8:8-24bits) to (5:6:5-16bits)
m16bits:
xor ax,ax
shr ,2
mov ah,
shr ax,3
and , 11111000b
or ah,
shr ,3
or al,
mov ,ax
ret

;you must put the values in red, green and blue before calling m16bits.
Posted on 2002-11-05 05:56:54 by Despero
Hello Despero.

It works fine.

But there is a problem.
When i build the above program in MASM,it fails.
Also,because i have make a mini OS,when i use the above program as a Kernel,
the refresh ratio is OK,but the shape is bad and the CPU not responding
in Ctrl+Alt+Del.
I don't know why.
If you have any idea,tell me.

Regards,Manos.
Posted on 2002-11-05 12:58:22 by Anonymous
Did you already try to change 'org 100h' to 'org 7C00h' or 'org 0h'

Try putting the same value to cs, ds, es when testing the program as kernel.


Ctrl+alt+del: I'm not sure but I used 'int 20h' at the end of my file to exit program. But as you tested the program like a kernel I don't know what happen when 'int 20h' is executed. you can try to use 'hlt' to halt de cpu.

I'll look this source in masm to see why it failed.

Tell me what happened.

Bye.
Posted on 2002-11-06 04:30:23 by Despero
Hello Despero.

You are right.
If i set 'org 7c00h',is OK,although i take from Linker a warning.
Instead of your code, i change the banks in PutPixel procedure.
I don't know whether is faster.Check it if you have the time.
Following is my code in MASM.I don't take information of VESA,for simplicity.
If press the left button of mouse,paint a rectangle.To exit press 'Esc'.
You must press the left button of mouse,otherwise you can not exit.
I use mode 103h (800x600x256 colors).
-------------My code in MASM:--------------------------

.MODEL TINY
.386

;-----------------------------
CRT struct
HorzTotal dw ?
HorzStart dw ?
HorzEnd dw ?
VertTotal dw ?
VertStart dw ?
VertEnd dw ?
Flags db ?
PxClock dd ?
RfrRate dw ?
Reserv db 40 dup(?)
CRT ends
;-----------------------------
.DATA?
CrtInf CRT {}
oldMode dw ?

.DATA
CurrentBank dd 0

.STACK

.CODE

org 7c00h
;----------------------------------------
MAIN PROC

call GetMode ;store old mode

mov CrtInf.HorzTotal,1072
mov CrtInf.HorzStart,848
mov CrtInf.HorzEnd,936
mov CrtInf.VertTotal,636
mov CrtInf.VertStart,601
mov CrtInf.VertEnd,604
mov CrtInf.Flags,0
mov CrtInf.PxClock,57952320
mov CrtInf.RfrRate,8500
call SetMode

;------------Fill screen---------------------------
mov bl,3 ;--green color--
xor edx,edx
LoopY:
xor ecx,ecx
LoopX:
call PutPixel
inc ecx
cmp ecx,800
jne LoopX
inc edx
cmp edx,600
jne LoopY
;------Paint a rectangle when press the left button of mouse----
;------Note:The mouse does not appear,simply press left button.-
LOOP2:
mov ax,3
int 33h ;Wait for mouse
mov ax,bx
cmp ax,1 ;Left button down
jne LOOP2
;------Paint a rectangle 200x160 pixels-------
mov bl,5 ; another color
xor edx,edx
LoopY1:
xor ecx,ecx
LoopX1:
call PutPixel
inc ecx
cmp ecx,200
jne LoopX1
inc edx
cmp edx,160
jne LoopY1

;-----------------Press Esc to exit-----------------------------
LOOP1:

MOV AH,8 ;Wait for KeyPress 27 (Esc)
INT 21h
CMP AL,27
JNE LOOP1

call RestoreOldMode

MOV AX,4C00h
INT 21h
;-------------------
MAIN ENDP
;----------------------------------------
PutPixel proc ;ecx=X ,edx=Y, bl=Color
push eax
push es
push ecx
push edx
push ebx
lea eax, ;multiply by 5
lea eax, ;multiply by 5
xor edx,edx ;prepare for division
mov ebx,dword ptr 65536 ;in VESA each bank have 64Kb
shl eax,5 ;multiply by 32
add eax,ecx ;eax=Y+X
div ebx
mov ecx,edx
cmp eax,CurrentBank ;eax=quotient,edx=remainder
je Lbl
mov CurrentBank,eax ;new bank
mov dx,ax
mov ax,4f05h ;SetBank
xor ebx,ebx
int 10h
Lbl:
pop ebx
mov ax,0A000h
mov es,ax
mov es:,bl
pop edx
pop ecx
pop es
pop eax
ret
PutPixel endp
;----------------------------
SetMode proc
push ebx
push edi
push es
push ds
mov ax,4f02h
mov bx,103h ;800x600x256
or bx,0800h
push ds
pop es
mov di,offset CrtInf
int 10h
pop ds
pop es
pop edi
pop ebx

ret
SetMode endp
;---------------------------
GetMode proc
push eax
push ebx
mov ax,4f03h
int 10h
mov oldMode,bx
pop ebx
pop eax
ret

GetMode endp
;---------------------------
RestoreOldMode proc
push eax
push ebx
mov ax,4f02h
mov bx,oldMode
int 10h
pop ebx
pop eax
ret

RestoreOldMode endp
;---------------------------

END MAIN
;------------------------------------------End of code---------------------------------
Note:I don't know how calculate the colors in 256 colors.
If you know,tell me about pallete.

Regards,Manos.
Posted on 2002-11-06 12:17:05 by Anonymous
tip: You can put values in CRT struct, then you won't need to use 'mov' to set the data.

like this:
struc CRTCInfoBlock
{
.HorizontalTotal dw 1072 ; Horizontal total in pixels
.HorizontalSyncStart dw 848 ; Horizontal sync start in pixels
.HorizontalSyncEnd dw 936 ; Horizontal sync end in pixels
.VerticalTotal dw 636 ; Vertical total in lines
.VerticalSyncStart dw 601 ; Vertical sync start in lines
.VerticalSyncEnd dw 604 ; Vertical sync end in lines
.Flags db 0 ; Flags (Interlaced, Double Scan etc)
.PixelClock dd 57952320 ; Pixel clock in units of Hz
.RefreshRate dw 8500 ; Refresh rate in units of 0.01 Hz

.Reserved rb 40 ; remainder of ModeInfoBlock
}
I think this is faster, put it before uninitialized data to not increase the program size.


You can use vesa function to set DAC palette:

Input: AX = 4F08h VBE Set/Get Palette Format
BL = 00h Set DAC Palette Format
= 01h Get DAC Palette Format
BH = Desired bits of color per primary
(Set DAC Palette Format only)
(Default is 6bits(0-63 per color) you can change to 8bits(0-255 p/ color)

Output: AX = VBE Return Status
BH = Current number of bits of color per primary

Input: AX = 4F09h VBE Load/Unload Palette Data
BL = 00h Set Palette Data
= 01h Get Palette Data
= 02h Set Secondary Palette Data
= 03h Get Secondary Palette Data
= 80h Set Palette Data during Vertical Retrace
with Blank Bit on
CX = Number of palette registers to update
DX = First palette register to update
ES:DI = Table of palette values (see below for format)

Output: AX = VBE Return Status

Format of Palette Values: Alignment byte, Red byte, Green byte, Blue byte

palette structure to use with vesa:

;begin
struc color
{
.red db ?
.green db ?
.blue db ?
}

struc palette
{
.c0 color
.c1 color
.c2 color
.c3 color
.c4 color
.c5 color
.c6 color
.c7 color
.c8 color
.c9 color
.c10 color
.c11 color
.c12 color
.c13 color
.c14 color
.c15 color
.c16 color
.c17 color
.c18 color
.c19 color
.c20 color
.c21 color
.c22 color
.c23 color
.c24 color
.c25 color
.c26 color
.c27 color
.c28 color
.c29 color
.c30 color
.c31 color
.c32 color
.c33 color
.c34 color
.c35 color
.c36 color
.c37 color
.c38 color
.c39 color
.c40 color
.c41 color
.c42 color
.c43 color
.c44 color
.c45 color
.c46 color
.c47 color
.c48 color
.c49 color
.c50 color
.c51 color
.c52 color
.c53 color
.c54 color
.c55 color
.c56 color
.c57 color
.c58 color
.c59 color
.c60 color
.c61 color
.c62 color
.c63 color
.c64 color
.c65 color
.c66 color
.c67 color
.c68 color
.c69 color
.c70 color
.c71 color
.c72 color
.c73 color
.c74 color
.c75 color
.c76 color
.c77 color
.c78 color
.c79 color
.c80 color
.c81 color
.c82 color
.c83 color
.c84 color
.c85 color
.c86 color
.c87 color
.c88 color
.c89 color
.c90 color
.c91 color
.c92 color
.c93 color
.c94 color
.c95 color
.c96 color
.c97 color
.c98 color
.c99 color
.c100 color
.c101 color
.c102 color
.c103 color
.c104 color
.c105 color
.c106 color
.c107 color
.c108 color
.c109 color
.c110 color
.c111 color
.c112 color
.c113 color
.c114 color
.c115 color
.c116 color
.c117 color
.c118 color
.c119 color
.c120 color
.c121 color
.c122 color
.c123 color
.c124 color
.c125 color
.c126 color
.c127 color
.c128 color
.c129 color
.c130 color
.c131 color
.c132 color
.c133 color
.c134 color
.c135 color
.c136 color
.c137 color
.c138 color
.c139 color
.c140 color
.c141 color
.c142 color
.c143 color
.c144 color
.c145 color
.c146 color
.c147 color
.c148 color
.c149 color
.c150 color
.c151 color
.c152 color
.c153 color
.c154 color
.c155 color
.c156 color
.c157 color
.c158 color
.c159 color
.c160 color
.c161 color
.c162 color
.c163 color
.c164 color
.c165 color
.c166 color
.c167 color
.c168 color
.c169 color
.c170 color
.c171 color
.c172 color
.c173 color
.c174 color
.c175 color
.c176 color
.c177 color
.c178 color
.c179 color
.c180 color
.c181 color
.c182 color
.c183 color
.c184 color
.c185 color
.c186 color
.c187 color
.c188 color
.c189 color
.c190 color
.c191 color
.c192 color
.c193 color
.c194 color
.c195 color
.c196 color
.c197 color
.c198 color
.c199 color
.c200 color
.c201 color
.c202 color
.c203 color
.c204 color
.c205 color
.c206 color
.c207 color
.c208 color
.c209 color
.c210 color
.c211 color
.c212 color
.c213 color
.c214 color
.c215 color
.c216 color
.c217 color
.c218 color
.c219 color
.c220 color
.c221 color
.c222 color
.c223 color
.c224 color
.c225 color
.c226 color
.c227 color
.c228 color
.c229 color
.c230 color
.c231 color
.c232 color
.c233 color
.c234 color
.c235 color
.c236 color
.c237 color
.c238 color
.c239 color
.c240 color
.c241 color
.c242 color
.c243 color
.c244 color
.c245 color
.c246 color
.c247 color
.c248 color
.c249 color
.c250 color
.c251 color
.c252 color
.c253 color
.c254 color
.c255 color
}
;end palett structure


or:

You can write to the palette, first you send a byte to port 3c8h telling it which color you want to change. Then, it takes the next 3 values at port 3c9h. So you just INCed dx. The 3 values you give it are the amounts of red, green, and blue your new color will contain. Each one has a value from 0 to 63. Giving it 3 0's would result in black, and at the opposite extreme, 3 63's results in pure white.

code:
mov dx,03c8h ;putting the port value in dx
mov al,0 ;putting the color you want to change
out dx,ax ;sending to port the color
inc dx ;changing the port to 3c9h yo send RGB values
mov al,63 ;red value
out dx,ax
mov al,0 ;green value
out dx,al
mov al,0 ;blue value
out dx,al

;This will change the black, color 0, to red.
;Color index increments automatically, so if you send more values to port 3c9h you'll change the
;next color.
Posted on 2002-11-08 08:58:21 by Despero
Hello Despero.

I'll try your exambles.

Thanks,Manos.
Posted on 2002-11-08 12:01:11 by Anonymous
Hello Despero.

I have understand you code.
I don't want put values in CRT struct,because i use the CRT struct
in more than one modes and each member of this struct have different value
in differends modes.
Now,i try to handler the mouse,without DOS.But,without DOS the INT 33h does not works.
I need the Video Cursor Interface (VCI) of VESA,but i can't find this.
If you have an idea,tell me.

Regards,Manos.
Posted on 2002-11-10 07:07:38 by Anonymous
Hello Manos,
I don't know about VCI of VESA.

about mouse, I think you can read about 'INT 0Ch'
text from 'Ralf Brow Interrupt list' about 'INT 0Ch':

Inp.:
Desc: automatically asserted by the UART when COM1 needs attention, if the
UART has been programmed to generate interrupts
BUG: this vector is modified but not restored by Direct Access v4.0, and
may be left dangling by other programs written with the same version
of compiled BASIC
Notes: on many PC's, COM3 shares this interrupt
may be masked by setting bit 4 on I/O port 21h

Copied from Ralf Brown's Interrupt List

and you can read about port 3f8 too:

you can find some helpfull documents in this site: 'http://www.autistici.org/itassembly/'
see 'documenti vari' in main menu.

regards.
Posted on 2002-11-10 19:08:13 by Despero
Hi Despero.

I have copied Interrupt List from Ralf Brown's.
I interest for INT 15,function 0C2h.
But i can not do anything.
If you know about this,tell me.

Thanks,Manos.
Posted on 2002-11-15 09:31:52 by Anonymous
hello, Manos!

I don't know about mouse!
Maybe you could to start a new thead!

Did you try to initialize with 'int 15h' and with function '0c205h'
and try to intall a handler with '0c207h'
before to use '0c200h'?
Posted on 2002-11-15 19:25:38 by Despero
Hello Despero.

Can you tell me,if you know,how can i write characters on screen
using graphics mode,i.e mode 103h ,with fasm ?

Regards,Manos.
Posted on 2003-01-14 14:40:13 by Anonymous
Hello Manos!

You can use video interrupt to write characters at screen,
but you need to test if the video mode you choose support this function.
Regarding the code I used in this thread I used this to test:

; begin - write 'A' 5 times at screen

mov ax, ;the bit D2 tell if it's possible to use some video interrupt functions

and ax,100b ;test bit D0

jz withoutext ; if bit is not set the video mode doesn't support 'int 10h'

mov ah,09h ; video function to write chars at cursor position
mov al,65 ; 65 = A
mov bh,0 ; page 0
mov bl,2 ; green color
mov cx,5 ; repeat 5 times
int 10h
withoutext:

;end

I tested this code in some video modes, all 256 color mode support to write using 'int 10h', but the 15bits and 16bits video mode doesn't support.
I didn't test in 24bits or 32bits video mode.

I think if you want to use some true type font you'll need to create a procedure to do it!

Regards, Despero
Posted on 2003-01-14 17:24:14 by Despero