Bochs/bochs/patches/patch.textmode-cursor
2001-12-02 16:45:55 +00:00

253 lines
9.3 KiB
Plaintext

----------------------------------------------------------------------
Patch name: patch.textmode-cursor
Author: Volker Ruppert <Volker.Ruppert@t-online.de>
Date: Sun Dec 2 13:22:00 CET 2001
Detailed description:
This is an improvement for the textmode cursor.
The cursor can be disabled (X and win32 GUI) and it
can appear in different sizes (X only). I have tested
the patch using the elpin VGA BIOS in DOS 7.1.
The 'doskey' utility, 'edit' and 'scandisk' are working
okay.
TODO:
- cursor size feature for win32
- implentation for other GUIs
Patch was created with:
diff -u
Apply patch to what version:
cvs checked out on DATE
Instructions:
To patch, go to main bochs directory.
Type "patch -p0 < THIS_PATCH_FILE".
----------------------------------------------------------------------
diff -u ../bochs/gui/amigaos.cc gui/amigaos.cc
--- ../bochs/gui/amigaos.cc Wed Oct 3 15:10:37 2001
+++ gui/amigaos.cc Sun Dec 2 09:47:56 2001
@@ -380,7 +380,7 @@
void
bx_gui_c::text_update(Bit8u *old_text, Bit8u *new_text,
unsigned long cursor_x, unsigned long cursor_y,
- unsigned nrows)
+ Bit16u cursor_state, unsigned nrows)
{
int i;
int cursori;
diff -u ../bochs/gui/beos.cc gui/beos.cc
--- ../bochs/gui/beos.cc Wed Oct 3 15:10:37 2001
+++ gui/beos.cc Sun Dec 2 09:48:22 2001
@@ -302,7 +302,7 @@
void
bx_gui_c::text_update(Bit8u *old_text, Bit8u *new_text,
unsigned long cursor_x, unsigned long cursor_y,
- unsigned nrows)
+ Bit16u cursor_state, unsigned nrows)
{
unsigned i, x, y;
BPoint point;
diff -u ../bochs/gui/carbon.cc gui/carbon.cc
--- ../bochs/gui/carbon.cc Wed Oct 3 15:10:37 2001
+++ gui/carbon.cc Sun Dec 2 09:51:28 2001
@@ -796,7 +796,7 @@
void bx_gui_c::text_update(Bit8u *old_text, Bit8u *new_text,
unsigned long cursor_x, unsigned long cursor_y,
- unsigned nrows)
+ Bit16u cursor_state, unsigned nrows)
{
int i;
unsigned char achar;
diff -u ../bochs/gui/gui.h gui/gui.h
--- ../bochs/gui/gui.h Mon Nov 26 10:54:12 2001
+++ gui/gui.h Sat Dec 1 18:17:23 2001
@@ -34,7 +34,7 @@
unsigned x_tilesize, unsigned y_tilesize, unsigned header_bar_y);
static void text_update(Bit8u *old_text, Bit8u *new_text,
unsigned long cursor_x, unsigned long cursor_y,
- unsigned rows);
+ Bit16u cursor_state, unsigned rows);
static void graphics_update(Bit8u *snapshot);
static void graphics_tile_update(Bit8u *snapshot, unsigned x, unsigned y);
static void handle_events(void);
diff -u ../bochs/gui/macintosh.cc gui/macintosh.cc
--- ../bochs/gui/macintosh.cc Wed Oct 3 15:10:37 2001
+++ gui/macintosh.cc Sun Dec 2 09:52:19 2001
@@ -791,7 +791,7 @@
void bx_gui_c::text_update(Bit8u *old_text, Bit8u *new_text,
unsigned long cursor_x, unsigned long cursor_y,
- unsigned nrows)
+ Bit16u cursor_state, unsigned nrows)
{
int i;
unsigned char achar;
diff -u ../bochs/gui/nogui.cc gui/nogui.cc
--- ../bochs/gui/nogui.cc Wed Oct 3 15:10:37 2001
+++ gui/nogui.cc Sun Dec 2 09:53:13 2001
@@ -136,12 +136,13 @@
void
bx_gui_c::text_update(Bit8u *old_text, Bit8u *new_text,
unsigned long cursor_x, unsigned long cursor_y,
- unsigned nrows)
+ Bit16u cursor_state, unsigned nrows)
{
UNUSED(old_text);
UNUSED(new_text);
UNUSED(cursor_x);
UNUSED(cursor_y);
+ UNUSED(cursor_state);
UNUSED(nrows);
}
diff -u ../bochs/gui/rfb.cc gui/rfb.cc
--- ../bochs/gui/rfb.cc Mon Nov 12 18:56:47 2001
+++ gui/rfb.cc Sun Dec 2 09:54:31 2001
@@ -522,7 +522,7 @@
// cursor_x: new x location of cursor
// cursor_y: new y location of cursor
-void bx_gui_c::text_update(Bit8u *old_text, Bit8u *new_text, unsigned long cursor_x, unsigned long cursor_y, unsigned nrows)
+void bx_gui_c::text_update(Bit8u *old_text, Bit8u *new_text, unsigned long cursor_x, unsigned long cursor_y, Bit16u cursor_state, unsigned nrows)
{
unsigned char cChar;
unsigned int nchars;
diff -u ../bochs/gui/term.cc gui/term.cc
--- ../bochs/gui/term.cc Wed Oct 3 15:10:37 2001
+++ gui/term.cc Sun Dec 2 10:05:39 2001
@@ -395,8 +395,10 @@
void
bx_gui_c::text_update(Bit8u *old_text, Bit8u *new_text,
unsigned long cursor_x, unsigned long cursor_y,
- unsigned nrows)
+ Bit16u cursor_state, unsigned nrows)
{
+ UNUSED(cursor_state);
+
unsigned ncols = 4000/nrows/2;
// XXX There has GOT to be a better way of doing this
for(int i=0;i<4001;i+=2) {
diff -u ../bochs/gui/win32.cc gui/win32.cc
--- ../bochs/gui/win32.cc Mon Nov 26 08:24:16 2001
+++ gui/win32.cc Sun Dec 2 13:21:12 2001
@@ -683,12 +683,16 @@
void bx_gui_c::text_update(Bit8u *old_text, Bit8u *new_text,
unsigned long cursor_x, unsigned long cursor_y,
- unsigned nrows) {
+ Bit16u cursor_state, unsigned nrows) {
HDC hdc;
unsigned char cChar;
unsigned i, x, y;
+ Bit8u cursor_start, cursor_end;
unsigned nchars;
+ cursor_start = cursor_state >> 8;
+ cursor_end = cursor_state & 0xff;
+
if (!stInfo.UIinited) return;
EnterCriticalSection(&stInfo.drawCS);
@@ -722,7 +726,7 @@
prev_block_cursor_y = cursor_y;
// now draw character at new block cursor location in reverse
- if ((cursor_y*80 + cursor_x) < nchars ) {
+ if (((cursor_y*80 + cursor_x) < nchars ) && (cursor_start <= cursor_end)) {
cChar = new_text[(cursor_y*80 + cursor_x)*2];
//reverse background and foreground colors
char cAttr = new_text[((cursor_y*80 + cursor_x)*2)+1];
diff -u ../bochs/gui/x.cc gui/x.cc
--- ../bochs/gui/x.cc Mon Nov 12 01:45:09 2001
+++ gui/x.cc Sun Dec 2 13:22:02 2001
@@ -461,7 +461,7 @@
XSetState(bx_x_display, gc, white_pixel, black_pixel, GXcopy,AllPlanes);
- XSetState(bx_x_display, gc_inv, black_pixel, white_pixel, GXcopy,AllPlanes);
+ XSetState(bx_x_display, gc_inv, black_pixel, white_pixel, GXinvert,AllPlanes);
XSetState(bx_x_display, gc_headerbar, black_pixel, white_pixel, GXcopy,AllPlanes);
@@ -945,14 +945,18 @@
void
bx_gui_c::text_update(Bit8u *old_text, Bit8u *new_text,
unsigned long cursor_x, unsigned long cursor_y,
- unsigned nrows)
+ Bit16u cursor_state, unsigned nrows)
{
int font_height;
unsigned i, x, y, curs;
unsigned new_foreground, new_background;
Bit8u string[1];
+ Bit8u cursor_start, cursor_end;
unsigned nchars;
+ cursor_start = cursor_state >> 8;
+ cursor_end = cursor_state & 0xff;
+
font_height = font_info->ascent + font_info->descent;
// Number of characters on screen, variable number of rows
@@ -1007,15 +1011,15 @@
XSetBackground(bx_x_display, gc, black_pixel);
// now draw character at new block cursor location in reverse
- if ( (cursor_y*80 + cursor_x) < nchars ) {
- string[0] = new_text[(cursor_y*80 + cursor_x)*2];
- if (string[0] == 0) string[0] = ' '; // convert null to space
- XDrawImageString(bx_x_display, win,
- gc_inv,
- cursor_x * font_info->max_bounds.width,
- cursor_y * font_height + font_info->max_bounds.ascent + bx_headerbar_y,
- (char *) string,
- 1);
+ if ( ( (cursor_y*80 + cursor_x) < nchars ) && (cursor_start <= cursor_end) ) {
+ for (unsigned i = cursor_start; i <= cursor_end; i++)
+ XDrawLine(bx_x_display, win,
+ gc_inv,
+ cursor_x * font_info->max_bounds.width,
+ cursor_y * font_height + bx_headerbar_y + i,
+ (cursor_x + 1) * font_info->max_bounds.width - 1,
+ cursor_y * font_height + bx_headerbar_y + i
+ );
}
XFlush(bx_x_display);
diff -u ../bochs/iodev/vga.cc iodev/vga.cc
--- ../bochs/iodev/vga.cc Wed Oct 3 15:10:38 2001
+++ iodev/vga.cc Sun Dec 2 12:25:01 2001
@@ -1305,6 +1305,7 @@
else { // text mode
unsigned long start_address;
unsigned long cursor_address, cursor_x, cursor_y;
+ Bit16u cursor_state;
switch (BX_VGA_THIS s.graphics_ctrl.memory_mapping) {
@@ -1323,9 +1324,10 @@
cursor_x = ((cursor_address - start_address)/2) % 80;
cursor_y = ((cursor_address - start_address)/2) / 80;
}
+ cursor_state = (bx_vga.s.CRTC.reg[0x0a] << 8) | bx_vga.s.CRTC.reg[0x0b];
bx_gui.text_update(BX_VGA_THIS s.text_snapshot,
&BX_VGA_THIS s.vga_memory[0x10000 + start_address],
- cursor_x, cursor_y, 25);
+ cursor_x, cursor_y, cursor_state, 25);
// screen updated, copy new VGA memory contents into text snapshot
memcpy(BX_VGA_THIS s.text_snapshot,
&BX_VGA_THIS s.vga_memory[0x10000 + start_address],
@@ -1358,9 +1360,10 @@
cursor_x = ((cursor_address - start_address)/2) % 80;
cursor_y = ((cursor_address - start_address)/2) / 80;
}
+ cursor_state = (bx_vga.s.CRTC.reg[0x0a] << 8) | bx_vga.s.CRTC.reg[0x0b];
bx_gui.text_update(BX_VGA_THIS s.text_snapshot,
&BX_VGA_THIS s.vga_memory[0x18000 + start_address],
- cursor_x, cursor_y, rows);
+ cursor_x, cursor_y, cursor_state, rows);
// screen updated, copy new VGA memory contents into text snapshot
memcpy(BX_VGA_THIS s.text_snapshot,
&BX_VGA_THIS s.vga_memory[0x18000 + start_address],