Text Mode Cursor: Difference between revisions
[unchecked revision] | [unchecked revision] |
m (How Do I Move The Cursor When I Print moved to Text Mode Cursor: See talk page) |
No edit summary |
||
Line 2: | Line 2: | ||
==Moving the Cursor with the BIOS== |
==Moving the Cursor with the BIOS== |
||
Moving the cursor with the [[BIOS]] is through Int |
Moving the cursor with the [[BIOS]] is done through Int 0x10 (The general interrupt for screen functions) with Ah set to 0x02. These are the registers used: |
||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
* DH = The row |
* DH = The row |
||
* DL = The column |
* DL = The column |
||
Then, with a quick call to interrupt |
Then, with a quick call to interrupt 0x10, you should have yourself a movable type cursor. |
||
==Moving the Cursor without the BIOS== |
==Moving the Cursor without the BIOS== |
||
Without access to [[BIOS]] calls and functions, moving the cursor requires using video hardware control. Lucky it is a simple procedure. |
Without access to [[BIOS]] calls and functions, moving the cursor requires using video hardware control. Lucky it is a simple procedure. |
||
Note, this quick example |
Note, this quick example assumes 80x25 screen mode. |
||
/* void update_cursor(int row, int col) |
/* void update_cursor(int row, int col) |
Revision as of 23:19, 6 April 2007
Moving the Cursor with the BIOS
Moving the cursor with the BIOS is done through Int 0x10 (The general interrupt for screen functions) with Ah set to 0x02. These are the registers used:
- AH = 0x02
- BH = Display Page (This is usually, if not always, 0)
- DH = The row
- DL = The column
Then, with a quick call to interrupt 0x10, you should have yourself a movable type cursor.
Moving the Cursor without the BIOS
Without access to BIOS calls and functions, moving the cursor requires using video hardware control. Lucky it is a simple procedure.
Note, this quick example assumes 80x25 screen mode.
/* void update_cursor(int row, int col) * by Dark Fiber */ void update_cursor(int row, int col) { unsigned short position=(row*80) + col; // cursor LOW port to vga INDEX register outb(0x3D4, 0x0F); outb(0x3D5, (unsigned char)(position&0xFF)); // cursor HIGH port to vga INDEX register outb(0x3D4, 0x0E); outb(0x3D5, (unsigned char )((position>>8)&0xFF)); }
Keep in mind that in/out to VGA Hardware is a slow operation. So using the hardware registers to remember of the current character location (row, col) is bad practice -- and updating position after each displayed character is poor practice (updating it only when a line/string is complete is wiser and hiding it until a user prompt is required is wisest)