Hardware Cursor in Text Mode 80*25 with CRTC (Solved)
Posted: Mon Mar 19, 2007 3:09 am
I have written an Update Cursor procedure that allows the Row and the Column to be specified as parameters and then attempts to show the Hardware Cursor at the specified position. The problem is that the procedure works on Rows and Columns that already have a character written to them. If, for example, position(ROW, COLUMN) (0x0A, 0x0B) does not have a character printed at it, the Hardware Cursor is not shown. Below is the code if it helps spotting the problem:
Code: Select all
__UpdateHardwareCursor:
; void __UpdateHardwareCursor (DWORD Column, DWORD Row); StdCall;
PUSH EAX ; Push the accumulator onto the stack
PUSH EBX ; Push the base index onto the stack
PUSH EDX ; Push the data register onto the stack
PUSH EBP ; Push the base pointer onto the stack
MOV EBP , ESP ; Move the stack pointer to the base pointer
MOV EAX , DWORD PTR [EBP + 0x18] ; Accumulator now holds the [Row] parameter
MOV EBX , DWORD PTR [EBP + 0x14] ; Base Index now holds the [Column] parameter
SHL EAX , 0x00000004 ; Multiply the row by 80, Step 1
LEA EAX , [EAX + 0x04*EAX] ; Multiply the row by 80, Step 2
ADD EBX , EAX ; Add the Column to the Row, Keep in the EBX
MOV EDX , 0x000003D4 ; CRTC Address Register
MOV EAX , 0x0000000F ; Cursor Location Low Register
OUT DX , AL ; Tell the CRTC Address Register the Index
MOV EAX , EBX ; Get the calculated location in EAX
INC EDX ; EDX = CRTC Data Register (0x03D5)
OUT DX , AL ; Put the Cursor Location Low Address
DEC EDX ; EDX = CRTC Address Register (0x03D4)
MOV AL , 0x0000000E ; Cursor Location High Register
OUT DX , AL ; Tell the CRTC Address Register the Index
INC EDX ; EDX = CRTC Data Register (0x03D5)
MOV EAX , EBX ; Get the Calculated Location again
SHR EAX , 0x00000008 ; Get the High Byte in AL
OUT DX , AL ; Tell the CRTC Data Register the Index
POP EBP ; Restore the base pointer
POP EDX ; Restore the data register
POP EBX ; Restore the base index
POP EAX ; Restore the accumulator
RET 0x08 ; Return to the calling procedure
; And sweep 4 parameters off the stack