Page 1 of 1
cursor operation in protected mode using ports
Posted: Wed Jul 18, 2007 4:15 am
by spectrum
hi all,
i was trying to set the cursor blinking on the screen, in a certain position. I've read documentation aboud ports 0x3d4 0x3d5, but they are not really human-readable, so i'm getting no success. I' haven't understand how to move the cursor on a certain row, column, and how to make it blink.
So i'm looking for some easy sample.
Many thanks,
angelo
Posted: Wed Jul 18, 2007 4:18 am
by Pyrofan1
this is from Bran's kernel tut
Code: Select all
/* Updates the hardware cursor: the little blinking line
* on the screen under the last character pressed! */
void move_csr(void)
{
unsigned temp;
/* The equation for finding the index in a linear
* chunk of memory can be represented by:
* Index = [(y * width) + x] */
temp = csr_y * 80 + csr_x;
/* This sends a command to indicies 14 and 15 in the
* CRT Control Register of the VGA controller. These
* are the high and low bytes of the index that show
* where the hardware cursor is to be 'blinking'. To
* learn more, you should look up some VGA specific
* programming documents. A great start to graphics:
* http://www.brackeen.com/home/vga */
outportb(0x3D4, 14);
outportb(0x3D5, temp >> 8);
outportb(0x3D4, 15);
outportb(0x3D5, temp);
}
Posted: Wed Jul 18, 2007 7:36 am
by Dex
Assembly snip-it
Code: Select all
;'''''''''''''''''''''''''''''''''''''''''''''''''''';
; Sets cursor pos ;
;----------------------------------------------------;
; ;
; Input: ;
; [screen_x] points to X ;
; ;
; [screen_Y] points to Y ;
; ;
; Output: ;
; None. ;
;....................................................;
set_cursor_pos:
push eax
push ebx
push ecx
push edx
xor ebx,ebx
mov bl,[screen_x]
mov ecx,ebx
mov bl,[screen_y]
mov eax,80
mul bx
add eax,ecx
mov edx,0x3d4
mov ecx,eax
mov al,0x0f
out dx,al
mov eax,ecx
inc edx
out dx,al
mov al,0x0e
dec edx
out dx,al
mov eax,ecx
mov al,ah
inc edx
out dx,al
pop edx
pop ecx
pop ebx
pop eax
ret
Posted: Wed Jul 18, 2007 8:02 am
by spectrum
ok, thanks
thatt works, now i can move my cusrsor right,
but for make it blink ?
Posted: Wed Jul 18, 2007 9:40 am
by Dex
May be like this
Code: Select all
;--------------------------------------;
; change cursor attribs ;
; in: bx = cursor attribs ;
;--------------------------------------;
changecursor:
push ax
push dx
mov dx, 0x3D4
mov al, 0x0A
mov ah, bh
out dx, ax
inc ax
mov ah, bl
out dx, ax
pop dx
pop ax
ret