vga: Implement blinking of text cursor
PATCH 1/1 vga: Implement blinking of text cursor
Let the text cursor blink at 5 Hz. No timer is used, instead we rely on the fact that the display is updated periodically.
--- hw/vga.c | 14 +++++++++++++- hw/vga_int.h | 2 ++ 2 files changed, 15 insertions(+), 1 deletions(-)
hw/vga.c +13 -1
@@ -38,6 +38,8 @@//#define DEBUG_BOCHS_VBE +#define VGA_TEXT_CURSOR_PERIOD 200 +/* * Video Graphics Array (VGA) *
@@ -1300,6 +1302,7 @@ static void vga_draw_text(VGACommonState *s, int full_update)uint32_t *ch_attr_ptr;vga_draw_glyph8_func *vga_draw_glyph8;vga_draw_glyph9_func *vga_draw_glyph9; +int64_t now =qemu_get_clock_ms (vm_clock);/* compute font data address (in plane 2) */ v = s->sr[VGA_SEQ_CHARACTER_MAP ];
@@ -1370,6 +1373,11 @@ static void vga_draw_text(VGACommonState *s, int full_update) s->cursor_end = s->cr[VGA_CRTC_CURSOR_END ]; } cursor_ptr = s->vram_ptr + (s->start_addr + cursor_offset) *4 ; +if (now >= s->cursor_blink_time) { + s->cursor_blink_time = now +VGA_TEXT_CURSOR_PERIOD ; + s->cursor_blink_state ^=1 ; + full_update =1 ; + } depth_index =get_depth_index (s->ds);if (cw ==16 )
@@ -1420,7 +1428,8 @@ static void vga_draw_text(VGACommonState *s, int full_update) font_ptr, cheight, fgcol, bgcol, dup9); }if (src == cursor_ptr && - !(s->cr[VGA_CRTC_CURSOR_START ] &0x20 )) { + !(s->cr[VGA_CRTC_CURSOR_START ] &0x20 ) && + s->cursor_blink_state !=0 ) {int line_start, line_last, h;/* draw the cursor */ line_start = s->cr[VGA_CRTC_CURSOR_START ] &0x1f ;
@@ -1884,6 +1893,9 @@ static void vga_update_display(void *opaque) }if (graphic_mode != s->graphic_mode) { s->graphic_mode = graphic_mode; + s->cursor_blink_time = +qemu_get_clock_ms (vm_clock) +VGA_TEXT_CURSOR_PERIOD ; + s->cursor_blink_state =1 ; full_update =1 ; }switch (graphic_mode) {
hw/vga_int.h +2 -0
@@ -156,6 +156,8 @@ typedef struct VGACommonState {uint32_t last_scr_width, last_scr_height;/* in pixels */ uint32_t last_depth;/* in bits */ uint8_t cursor_start, cursor_end; +int cursor_blink_state; +int64_t cursor_blink_time;uint32_t cursor_offset;unsigned int (*rgb_to_pixel)(unsigned int r,unsigned int g,unsigned b);
Signature · 1 line
1.7.3.4
Quoted 31 lines · Jan Kiszka
Let the text cursor blink at 5 Hz. No timer is used, instead we rely on the fact that the display is updated periodically.
Signed-off-by Jan Kiszka <[email protected]>--- hw/vga.c | 14 +++++++++++++- hw/vga_int.h | 2 ++ 2 files changed, 15 insertions(+), 1 deletions(-)hw/vga.c +3
-0@@ -38,6 +38,8 @@//#define DEBUG_BOCHS_VBE +#define VGA_TEXT_CURSOR_PERIOD 200 +/* * Video Graphics Array (VGA) * @@ -1300,6 +1302,7 @@ static void vga_draw_text(VGACommonState *s, int full_update)uint32_t *ch_attr_ptr;vga_draw_glyph8_func *vga_draw_glyph8;vga_draw_glyph9_func *vga_draw_glyph9; +int64_t now =qemu_get_clock_ms (vm_clock);/* compute font data address (in plane 2) */ v = s->sr[VGA_SEQ_CHARACTER_MAP ];
hw/vga.c static void vga_draw_text(VGACommonState *s, int full_update) · line 1379
Quoted 7 lines
hw/vga.c +4
-0@@ -1370,6 +1373,11 @@ static void vga_draw_text(VGACommonState *s, int full_update) s->cursor_end = s->cr[VGA_CRTC_CURSOR_END ]; } cursor_ptr = s->vram_ptr + (s->start_addr + cursor_offset) *4 ; +if (now >= s->cursor_blink_time) { + s->cursor_blink_time = now +VGA_TEXT_CURSOR_PERIOD ; + s->cursor_blink_state ^=1 ; + full_update =1 ;
This would force a whole screen refresh at 5Hz. How about moving the check, which you modify below, outside of
if (full_update || ch_attr != *ch_attr_ptr) {
...
}
block?
Quoted 29 lines
hw/vga.c +6
-1+ } depth_index =get_depth_index (s->ds);if (cw ==16 )@@ -1420,7 +1428,8 @@ static void vga_draw_text(VGACommonState *s, int full_update) font_ptr, cheight, fgcol, bgcol, dup9); }if (src == cursor_ptr && - !(s->cr[VGA_CRTC_CURSOR_START ] &0x20 )) { + !(s->cr[VGA_CRTC_CURSOR_START ] &0x20 ) && + s->cursor_blink_state !=0 ) {int line_start, line_last, h;/* draw the cursor */ line_start = s->cr[VGA_CRTC_CURSOR_START ] &0x1f ;@@ -1884,6 +1893,9 @@ static void vga_update_display(void *opaque) }if (graphic_mode != s->graphic_mode) { s->graphic_mode = graphic_mode; + s->cursor_blink_time = +qemu_get_clock_ms (vm_clock) +VGA_TEXT_CURSOR_PERIOD ; + s->cursor_blink_state =1 ; full_update =1 ; }switch (graphic_mode) {hw/vga_int.h +0
-0
hw/vga_int.h typedef struct VGACommonState { · line 159
Quoted 4 lines
hw/vga_int.h +1
-0@@ -156,6 +156,8 @@ typedef struct VGACommonState {uint32_t last_scr_width, last_scr_height;/* in pixels */ uint32_t last_depth;/* in bits */ uint8_t cursor_start, cursor_end; +int cursor_blink_state;
I'd use bool and a name that tells something about the state, like bool cursor_visible;
Quoted 7 lines
hw/vga_int.h +1
-1+int64_t cursor_blink_time;uint32_t cursor_offset;unsigned int (*rgb_to_pixel)(unsigned int r,unsigned int g,unsigned b); --1.7.3.4
PATCH v2 1/1 vga: Implement blinking of text cursor
Let the text cursor blink at 5 Hz. No timer is used, instead we rely on the fact that the display is updated periodically.
---
Changes in v2:
- avoid full screen updates for cursor blinking
- convert cursor_blink_state to cursor_visible_phase
hw/vga.c | 14 ++++++++++++-- hw/vga_int.h | 2 ++ 2 files changed, 14 insertions(+), 2 deletions(-)
hw/vga.c +12 -2
@@ -38,6 +38,8 @@//#define DEBUG_BOCHS_VBE +#define VGA_TEXT_CURSOR_PERIOD 200 +/* * Video Graphics Array (VGA) *
@@ -1300,6 +1302,7 @@ static void vga_draw_text(VGACommonState *s, int full_update)uint32_t *ch_attr_ptr;vga_draw_glyph8_func *vga_draw_glyph8;vga_draw_glyph9_func *vga_draw_glyph9; +int64_t now =qemu_get_clock_ms (vm_clock);/* compute font data address (in plane 2) */ v = s->sr[VGA_SEQ_CHARACTER_MAP ];
@@ -1370,6 +1373,10 @@ static void vga_draw_text(VGACommonState *s, int full_update) s->cursor_end = s->cr[VGA_CRTC_CURSOR_END ]; } cursor_ptr = s->vram_ptr + (s->start_addr + cursor_offset) *4 ; +if (now >= s->cursor_blink_time) { + s->cursor_blink_time = now +VGA_TEXT_CURSOR_PERIOD ; + s->cursor_visible_phase = !s->cursor_visible_phase; + } depth_index =get_depth_index (s->ds);if (cw ==16 )
@@ -1390,7 +1397,7 @@ static void vga_draw_text(VGACommonState *s, int full_update) cx_max =-1 ;for (cx =0 ; cx < width; cx++) { ch_attr = *(uint16_t *)src; -if (full_update || ch_attr != *ch_attr_ptr) { +if (full_update || ch_attr != *ch_attr_ptr || src == cursor_ptr) {if (cx < cx_min) cx_min = cx;if (cx > cx_max)
@@ -1420,7 +1427,8 @@ static void vga_draw_text(VGACommonState *s, int full_update) font_ptr, cheight, fgcol, bgcol, dup9); }if (src == cursor_ptr && - !(s->cr[VGA_CRTC_CURSOR_START ] &0x20 )) { + !(s->cr[VGA_CRTC_CURSOR_START ] &0x20 ) && + s->cursor_visible_phase) {int line_start, line_last, h;/* draw the cursor */ line_start = s->cr[VGA_CRTC_CURSOR_START ] &0x1f ;
@@ -1884,6 +1892,8 @@ static void vga_update_display(void *opaque) }if (graphic_mode != s->graphic_mode) { s->graphic_mode = graphic_mode; + s->cursor_blink_time = +qemu_get_clock_ms (vm_clock) +VGA_TEXT_CURSOR_PERIOD ; full_update =1 ; }switch (graphic_mode) {
hw/vga_int.h +2 -0
@@ -156,6 +156,8 @@ typedef struct VGACommonState {uint32_t last_scr_width, last_scr_height;/* in pixels */ uint32_t last_depth;/* in bits */ uint8_t cursor_start, cursor_end; +bool cursor_visible_phase; +int64_t cursor_blink_time;uint32_t cursor_offset;unsigned int (*rgb_to_pixel)(unsigned int r,unsigned int g,unsigned b);
Signature · 1 line
1.7.3.4
Hi Jan,
please see my comments below.
Am 04.07.2012 15:40, schrieb Jan Kiszka:
Quoted 36 lines
Let the text cursor blink at 5 Hz. No timer is used, instead we rely on the fact that the display is updated periodically.
Signed-off-by Jan Kiszka<[email protected]>---
Changes in v2:
- avoid full screen updates for cursor blinking
- convertcursor_blink_statetocursor_visible_phasehw/vga.c | 14 ++++++++++++-- hw/vga_int.h | 2 ++ 2 files changed, 14 insertions(+), 2 deletions(-)hw/vga.c +3
-0@@ -38,6 +38,8 @@//#define DEBUG_BOCHS_VBE +#define VGA_TEXT_CURSOR_PERIOD 200 +/* * Video Graphics Array (VGA) * @@ -1300,6 +1302,7 @@ static void vga_draw_text(VGACommonState *s, int full_update)uint32_t *ch_attr_ptr;vga_draw_glyph8_func *vga_draw_glyph8;vga_draw_glyph9_func *vga_draw_glyph9; +int64_t now =qemu_get_clock_ms (vm_clock);/* compute font data address (in plane 2) */ v = s->sr[VGA_SEQ_CHARACTER_MAP ];
hw/vga.c static void vga_draw_text(VGACommonState *s, int full_update) · line 1380
Quoted 8 lines
hw/vga.c +4
-0@@ -1370,6 +1373,10 @@ static void vga_draw_text(VGACommonState *s, int full_update) s->cursor_end = s->cr[VGA_CRTC_CURSOR_END ]; } cursor_ptr = s->vram_ptr + (s->start_addr + cursor_offset) *4 ; +if (now>= s->cursor_blink_time) { + s->cursor_blink_time = now +VGA_TEXT_CURSOR_PERIOD ; + s->cursor_visible_phase = !s->cursor_visible_phase; + }
It's named VGA_TEXT_CURSOR_PERIOD, but it looks like it is not the period, but the time for each of two states (on/off), so it's 1/2 the period.
With your patch, I'd expect a blink frequency of 2.5 Hz.
According to the VGA documentation (I used
http://www.stanford.edu/class/cs140/projects/pintos/specs/freevga/vga/textcur.htm#blink),
the time for each state should be 16 / (60 Hz) or 266 ms resulting in a blink frequency of 1.875 Hz.
Quoted 37 lines
hw/vga.c +5
-2depth_index =get_depth_index (s->ds);if (cw ==16 )@@ -1390,7 +1397,7 @@ static void vga_draw_text(VGACommonState *s, int full_update) cx_max =-1 ;for (cx =0 ; cx< width; cx++) { ch_attr = *(uint16_t *)src; -if (full_update || ch_attr != *ch_attr_ptr) { +if (full_update || ch_attr != *ch_attr_ptr || src == cursor_ptr) {if (cx< cx_min) cx_min = cx;if (cx> cx_max)@@ -1420,7 +1427,8 @@ static void vga_draw_text(VGACommonState *s, int full_update) font_ptr, cheight, fgcol, bgcol, dup9); }if (src == cursor_ptr&& - !(s->cr[VGA_CRTC_CURSOR_START ]&0x20 )) { + !(s->cr[VGA_CRTC_CURSOR_START ]&0x20 )&& + s->cursor_visible_phase) {int line_start, line_last, h;/* draw the cursor */ line_start = s->cr[VGA_CRTC_CURSOR_START ]&0x1f ;@@ -1884,6 +1892,8 @@ static void vga_update_display(void *opaque) }if (graphic_mode != s->graphic_mode) { s->graphic_mode = graphic_mode; + s->cursor_blink_time = +qemu_get_clock_ms (vm_clock) +VGA_TEXT_CURSOR_PERIOD ; full_update =1 ; }switch (graphic_mode) {hw/vga_int.h +0
-0
hw/vga_int.h typedef struct VGACommonState { · line 163
Quoted 8 lines
hw/vga_int.h +2
-0@@ -156,6 +156,8 @@ typedef struct VGACommonState {uint32_t last_scr_width, last_scr_height;/* in pixels */ uint32_t last_depth;/* in bits */ uint8_t cursor_start, cursor_end; +bool cursor_visible_phase; +int64_t cursor_blink_time;uint32_t cursor_offset;unsigned int (*rgb_to_pixel)(unsigned int r,unsigned int g,unsigned b);
As far as I can tell, there are more cursor features missing:
do we support an invisible cursor (your patch doesn't) or cursor shape? See also this URL for more information:
http://www.stanford.edu/class/cs140/projects/pintos/specs/freevga/vga/textcur.htm
Blinking is also missing for text with the blink attribute. I don't know whether real hardware synchronizes text and cursor blinking. If it does, we should do that, too.
What about vertical blank interrupt? It is the base of text cursor blinking. We don't support it currently.
Regards,
Stefan
Quoted 39 lines · Stefan Weil
Hi Jan,
please see my comments below.
Am 04.07.2012 15:40, schrieb Jan Kiszka:
Quoted 33 lines
Let the text cursor blink at 5 Hz. No timer is used, instead we rely on the fact that the display is updated periodically.
Signed-off-by Jan Kiszka<[email protected]>---
Changes in v2:
- avoid full screen updates for cursor blinking
- convertcursor_blink_statetocursor_visible_phasehw/vga.c | 14 ++++++++++++-- hw/vga_int.h | 2 ++ 2 files changed, 14 insertions(+), 2 deletions(-)hw/vga.c +3
-0@@ -38,6 +38,8 @@//#define DEBUG_BOCHS_VBE +#define VGA_TEXT_CURSOR_PERIOD 200 +/* * Video Graphics Array (VGA) * @@ -1300,6 +1302,7 @@ static void vga_draw_text(VGACommonState *s, int full_update)uint32_t *ch_attr_ptr;vga_draw_glyph8_func *vga_draw_glyph8;vga_draw_glyph9_func *vga_draw_glyph9; +int64_t now =qemu_get_clock_ms (vm_clock);
Quoted 15 lines
hw/vga.c static void vga_draw_text(VGACommonState *s, int full_update) · line 1380
Quoted 11 lines
hw/vga.c +4
-0/* compute font data address (in plane 2) */ v = s->sr[VGA_SEQ_CHARACTER_MAP ];@@ -1370,6 +1373,10 @@ static void vga_draw_text(VGACommonState *s, int full_update) s->cursor_end = s->cr[VGA_CRTC_CURSOR_END ]; } cursor_ptr = s->vram_ptr + (s->start_addr + cursor_offset) *4 ; +if (now>= s->cursor_blink_time) { + s->cursor_blink_time = now +VGA_TEXT_CURSOR_PERIOD ; + s->cursor_visible_phase = !s->cursor_visible_phase; + }It's named
VGA_TEXT_CURSOR_PERIOD, but it looks like it is not the period, but the time for each of two states (on/off), so it's 1/2 the period.
Err, of course.
Quoted 7 lines
With your patch, I'd expect a blink frequency of 2.5 Hz.
According to the VGA documentation (I used
http://www.stanford.edu/class/cs140/projects/pintos/specs/freevga/vga/textcur.htm#blink),
the time for each state should be 16 / (60 Hz) or 266 ms resulting in a blink frequency of 1.875 Hz.
Interesting. The real hardware I was looking at is using a rate definitely larger than 2 HZ. But I can change this to the original rate.
Quoted 53 lines
Quoted 39 lines
hw/vga.c +5
-2depth_index =get_depth_index (s->ds);if (cw ==16 )@@ -1390,7 +1397,7 @@ static void vga_draw_text(VGACommonState *s, int full_update) cx_max =-1 ;for (cx =0 ; cx< width; cx++) { ch_attr = *(uint16_t *)src; -if (full_update || ch_attr != *ch_attr_ptr) { +if (full_update || ch_attr != *ch_attr_ptr || src == cursor_ptr) {if (cx< cx_min) cx_min = cx;if (cx> cx_max)@@ -1420,7 +1427,8 @@ static void vga_draw_text(VGACommonState *s, int full_update) font_ptr, cheight, fgcol, bgcol, dup9); }if (src == cursor_ptr&& - !(s->cr[VGA_CRTC_CURSOR_START ]&0x20 )) { + !(s->cr[VGA_CRTC_CURSOR_START ]&0x20 )&& + s->cursor_visible_phase) {int line_start, line_last, h;/* draw the cursor */ line_start = s->cr[VGA_CRTC_CURSOR_START ]&0x1f ;@@ -1884,6 +1892,8 @@ static void vga_update_display(void *opaque) }if (graphic_mode != s->graphic_mode) { s->graphic_mode = graphic_mode; + s->cursor_blink_time = +qemu_get_clock_ms (vm_clock) +VGA_TEXT_CURSOR_PERIOD ; full_update =1 ; }switch (graphic_mode) {hw/vga_int.h +0
-0hw/vga_int.h typedef struct VGACommonState { · line 163
Quoted 8 lines
hw/vga_int.h +2
-0@@ -156,6 +156,8 @@ typedef struct VGACommonState {uint32_t last_scr_width, last_scr_height;/* in pixels */ uint32_t last_depth;/* in bits */ uint8_t cursor_start, cursor_end; +bool cursor_visible_phase; +int64_t cursor_blink_time;uint32_t cursor_offset;unsigned int (*rgb_to_pixel)(unsigned int r,unsigned int g,unsigned b);As far as I can tell, there are more cursor features missing:
do we support an invisible cursor (your patch doesn't) or cursor shape? See also this URL for more information:
http://www.stanford.edu/class/cs140/projects/pintos/specs/freevga/vga/textcur.htm
Quoted 6 lines
Blinking is also missing for text with the blink attribute. I don't know whether real hardware synchronizes text and cursor blinking. If it does, we should do that, too.
What about vertical blank interrupt? It is the base of text cursor blinking. We don't support it currently.
As always: patches are welcome :). This covers at least the most prominent use case.
Thanks,
Jan
Signature · 2 lines
Siemens AG, Corporate Technology, CT RTC ITP SDP-DE Corporate Competence Center Embedded Linux
PATCH v3 1/1 vga: Implement blinking of text cursor
Let the text cursor blink at 1.875 Hz, the original VGA cursor frequency. No timer is used, instead we rely on the fact that the display is updated periodically.
---
Changes in v3:
- adjusted frequency to original value
- fixed semantic of VGA_TEXT_CURSOR_PERIOD_MS
hw/vga.c | 14 ++++++++++++-- hw/vga_int.h | 2 ++ 2 files changed, 14 insertions(+), 2 deletions(-)
hw/vga.c +12 -2
@@ -38,6 +38,9 @@//#define DEBUG_BOCHS_VBE +/* 16 state changes per vertical frame @60 Hz */ +#define VGA_TEXT_CURSOR_PERIOD_MS (1000 * 2 * 16 / 60) +/* * Video Graphics Array (VGA) *
@@ -1300,6 +1303,7 @@ static void vga_draw_text(VGACommonState *s, int full_update)uint32_t *ch_attr_ptr;vga_draw_glyph8_func *vga_draw_glyph8;vga_draw_glyph9_func *vga_draw_glyph9; +int64_t now =qemu_get_clock_ms (vm_clock);/* compute font data address (in plane 2) */ v = s->sr[VGA_SEQ_CHARACTER_MAP ];
@@ -1370,6 +1374,10 @@ static void vga_draw_text(VGACommonState *s, int full_update) s->cursor_end = s->cr[VGA_CRTC_CURSOR_END ]; } cursor_ptr = s->vram_ptr + (s->start_addr + cursor_offset) *4 ; +if (now >= s->cursor_blink_time) { + s->cursor_blink_time = now +VGA_TEXT_CURSOR_PERIOD_MS /2 ; + s->cursor_visible_phase = !s->cursor_visible_phase; + } depth_index =get_depth_index (s->ds);if (cw ==16 )
@@ -1390,7 +1398,7 @@ static void vga_draw_text(VGACommonState *s, int full_update) cx_max =-1 ;for (cx =0 ; cx < width; cx++) { ch_attr = *(uint16_t *)src; -if (full_update || ch_attr != *ch_attr_ptr) { +if (full_update || ch_attr != *ch_attr_ptr || src == cursor_ptr) {if (cx < cx_min) cx_min = cx;if (cx > cx_max)
@@ -1420,7 +1428,8 @@ static void vga_draw_text(VGACommonState *s, int full_update) font_ptr, cheight, fgcol, bgcol, dup9); }if (src == cursor_ptr && - !(s->cr[VGA_CRTC_CURSOR_START ] &0x20 )) { + !(s->cr[VGA_CRTC_CURSOR_START ] &0x20 ) && + s->cursor_visible_phase) {int line_start, line_last, h;/* draw the cursor */ line_start = s->cr[VGA_CRTC_CURSOR_START ] &0x1f ;
@@ -1884,6 +1893,7 @@ static void vga_update_display(void *opaque) }if (graphic_mode != s->graphic_mode) { s->graphic_mode = graphic_mode; + s->cursor_blink_time =qemu_get_clock_ms (vm_clock); full_update =1 ; }switch (graphic_mode) {
hw/vga_int.h +2 -0
@@ -156,6 +156,8 @@ typedef struct VGACommonState {uint32_t last_scr_width, last_scr_height;/* in pixels */ uint32_t last_depth;/* in bits */ uint8_t cursor_start, cursor_end; +bool cursor_visible_phase; +int64_t cursor_blink_time;uint32_t cursor_offset;unsigned int (*rgb_to_pixel)(unsigned int r,unsigned int g,unsigned b);
Signature · 1 line
1.7.3.4
Blue Swirl
AppliedThanks, applied.
Quoted 90 lines · Jan Kiszka
Let the text cursor blink at 1.875 Hz, the original VGA cursor frequency. No timer is used, instead we rely on the fact that the display is updated periodically.
Signed-off-by Jan Kiszka <[email protected]>---
Changes in v3:
- adjusted frequency to original value
- fixed semantic ofVGA_TEXT_CURSOR_PERIOD_MShw/vga.c | 14 ++++++++++++-- hw/vga_int.h | 2 ++ 2 files changed, 14 insertions(+), 2 deletions(-)hw/vga.c +12
-2@@ -38,6 +38,9 @@//#define DEBUG_BOCHS_VBE +/* 16 state changes per vertical frame @60 Hz */ +#define VGA_TEXT_CURSOR_PERIOD_MS (1000 * 2 * 16 / 60) +/* * Video Graphics Array (VGA) * @@ -1300,6 +1303,7 @@ static void vga_draw_text(VGACommonState *s, int full_update)uint32_t *ch_attr_ptr;vga_draw_glyph8_func *vga_draw_glyph8;vga_draw_glyph9_func *vga_draw_glyph9; +int64_t now =qemu_get_clock_ms (vm_clock);/* compute font data address (in plane 2) */ v = s->sr[VGA_SEQ_CHARACTER_MAP ];@@ -1370,6 +1374,10 @@ static void vga_draw_text(VGACommonState *s, int full_update) s->cursor_end = s->cr[VGA_CRTC_CURSOR_END ]; } cursor_ptr = s->vram_ptr + (s->start_addr + cursor_offset) *4 ; +if (now >= s->cursor_blink_time) { + s->cursor_blink_time = now +VGA_TEXT_CURSOR_PERIOD_MS /2 ; + s->cursor_visible_phase = !s->cursor_visible_phase; + } depth_index =get_depth_index (s->ds);if (cw ==16 )@@ -1390,7 +1398,7 @@ static void vga_draw_text(VGACommonState *s, int full_update) cx_max =-1 ;for (cx =0 ; cx < width; cx++) { ch_attr = *(uint16_t *)src; -if (full_update || ch_attr != *ch_attr_ptr) { +if (full_update || ch_attr != *ch_attr_ptr || src == cursor_ptr) {if (cx < cx_min) cx_min = cx;if (cx > cx_max)@@ -1420,7 +1428,8 @@ static void vga_draw_text(VGACommonState *s, int full_update) font_ptr, cheight, fgcol, bgcol, dup9); }if (src == cursor_ptr && - !(s->cr[VGA_CRTC_CURSOR_START ] &0x20 )) { + !(s->cr[VGA_CRTC_CURSOR_START ] &0x20 ) && + s->cursor_visible_phase) {int line_start, line_last, h;/* draw the cursor */ line_start = s->cr[VGA_CRTC_CURSOR_START ] &0x1f ;@@ -1884,6 +1893,7 @@ static void vga_update_display(void *opaque) }if (graphic_mode != s->graphic_mode) { s->graphic_mode = graphic_mode; + s->cursor_blink_time =qemu_get_clock_ms (vm_clock); full_update =1 ; }switch (graphic_mode) {hw/vga_int.h +2
-1@@ -156,6 +156,8 @@ typedef struct VGACommonState {uint32_t last_scr_width, last_scr_height;/* in pixels */ uint32_t last_depth;/* in bits */ uint8_t cursor_start, cursor_end; +bool cursor_visible_phase; +int64_t cursor_blink_time;uint32_t cursor_offset;unsigned int (*rgb_to_pixel)(unsigned int r,unsigned int g,unsigned b); --1.7.3.4