Dear all, I want to give Mac OS 9 clients access to hardware cursor support, to improve responsiveness in absolute-cursor mode.
Would it be acceptable to add a hardware cursor interface to the VGA device? And if so, can anyone advise on an appropriate register layout? This is an example of such a patch. Because it alters the Bochs VBE interface it is ONLY an example, NOT fit for acceptance. I have omitted the changes to the binary driver qemu_vga.ndrv. Kind regards, Elliot Nunn --- hw/display/vga.c | 35 +++++++++++++++++++++++++++++++++ include/hw/display/bochs-vbe.h | 7 +++++-- pc-bios/qemu_vga.ndrv | Bin 18752 -> 20944 bytes 3 files changed, 40 insertions(+), 2 deletions(-) diff --git a/hw/display/vga.c b/hw/display/vga.c index 5dca2d1528..9b562e24e2 100644 --- a/hw/display/vga.c +++ b/hw/display/vga.c @@ -744,6 +744,10 @@ void vbe_ioport_write_data(void *opaque, uint32_t addr, uint32_t val) { VGACommonState *s = opaque; + static size_t cursorCounter; + static uint8_t cursorData[16 * 16 * 4]; + QEMUCursor *cursor; + if (s->vbe_index <= VBE_DISPI_INDEX_NB) { trace_vga_vbe_write(s->vbe_index, val); switch(s->vbe_index) { @@ -796,6 +800,37 @@ void vbe_ioport_write_data(void *opaque, uint32_t addr, uint32_t val) s->vbe_regs[s->vbe_index] = val; vga_update_memory_access(s); break; + + case VBE_DISPI_INDEX_CURSOR_IMG: + cursorData[cursorCounter++] = val >> 8; + cursorData[cursorCounter++] = val; + cursorCounter &= sizeof(cursorData) - 1; + break; + + case VBE_DISPI_INDEX_CURSOR_HOTSPOT: + cursor = cursor_alloc(16, 16); + + if (val == 0x8080) { // blank cursor + for (int i = 0; i < 16*16; i++) { + cursor->data[i] = 0; + } + } else { + for (int i = 0; i < 16*16; i++) { + cursor->data[i] = + ((uint32_t)cursorData[i*4] << 24) | + ((uint32_t)cursorData[i*4+1] << 16) | + ((uint32_t)cursorData[i*4+2] << 8) | + (uint32_t)cursorData[i*4+3]; + } + + cursor->hot_x = (int8_t)(val >> 8); + cursor->hot_y = (int8_t)val; + } + + dpy_cursor_define(s->con, cursor); + cursor_put(cursor); // dealloc + break; + default: break; } diff --git a/include/hw/display/bochs-vbe.h b/include/hw/display/bochs-vbe.h index bc2f046eee..7de409bae7 100644 --- a/include/hw/display/bochs-vbe.h +++ b/include/hw/display/bochs-vbe.h @@ -19,7 +19,10 @@ #define VBE_DISPI_INDEX_VIRT_HEIGHT 0x7 #define VBE_DISPI_INDEX_X_OFFSET 0x8 #define VBE_DISPI_INDEX_Y_OFFSET 0x9 -#define VBE_DISPI_INDEX_NB 0xa /* size of vbe_regs[] */ +#define VBE_DISPI_INDEX_CURSOR_IMG 0xb +#define VBE_DISPI_INDEX_CURSOR_HOTSPOT 0xc +#define VBE_DISPI_INDEX_CURSOR_ABS 0xd +#define VBE_DISPI_INDEX_NB 0xe /* size of vbe_regs[] */ #define VBE_DISPI_INDEX_VIDEO_MEMORY_64K 0xa /* read-only, not in vbe_regs */ /* VBE_DISPI_INDEX_ID */ @@ -54,7 +57,7 @@ /* bochs vbe register region */ #define PCI_VGA_BOCHS_OFFSET 0x500 -#define PCI_VGA_BOCHS_SIZE (0x0b * 2) +#define PCI_VGA_BOCHS_SIZE (VBE_DISPI_INDEX_NB * 2) /* qemu extension register region */ #define PCI_VGA_QEXT_OFFSET 0x600 -- 2.30.1 (Apple Git-130)