diff options
author | Marcus Brinkmann <marcus@gnu.org> | 2002-09-18 20:48:36 +0000 |
---|---|---|
committer | Marcus Brinkmann <marcus@gnu.org> | 2002-09-18 20:48:36 +0000 |
commit | 15f5579d8184d7c23a83e76de8506090f700096d (patch) | |
tree | 55848638b2a814f9f5a1dc6fea489b7e8e711402 /console-client | |
parent | 1387460130760179bb62909bb7c7696102fdd0e7 (diff) |
2002-09-19 Marcus Brinkmann <marcus@gnu.org>
* vga-support.c (vga_read_write_font_buffer): New function. It
turns out that reading and writing needs the same register
settings.
(vga_write_font_buffer): Implement in terms of
vga_read_write_font_buffer.
(vga_read_font_buffer): Likewise.
Diffstat (limited to 'console-client')
-rw-r--r-- | console-client/ChangeLog | 9 | ||||
-rw-r--r-- | console-client/vga-support.c | 72 |
2 files changed, 41 insertions, 40 deletions
diff --git a/console-client/ChangeLog b/console-client/ChangeLog index 31e7144c..9093466f 100644 --- a/console-client/ChangeLog +++ b/console-client/ChangeLog @@ -1,3 +1,12 @@ +2002-09-19 Marcus Brinkmann <marcus@gnu.org> + + * vga-support.c (vga_read_write_font_buffer): New function. It + turns out that reading and writing needs the same register + settings. + (vga_write_font_buffer): Implement in terms of + vga_read_write_font_buffer. + (vga_read_font_buffer): Likewise. + 2002-09-18 Marcus Brinkmann <marcus@gnu.org> * ncursesw.c: Add an entry for the clear function. diff --git a/console-client/vga-support.c b/console-client/vga-support.c index babdfa46..30ed6533 100644 --- a/console-client/vga-support.c +++ b/console-client/vga-support.c @@ -223,40 +223,47 @@ vga_fini (void) } -/* Write DATALEN bytes from DATA to the font buffer BUFFER, starting - from glyph INDEX. */ -void -vga_write_font_buffer (int buffer, int index, char *data, size_t datalen) +/* Access the font buffer BUFFER, starting from glyph INDEX, and + either read DATALEN bytes into DATA (if WRITE is 0) or write + DATALEN bytes from DATA (if WRITE is not 0). */ +static void +vga_read_write_font_buffer (int write, int buffer, int index, + char *data, size_t datalen) { char saved_seq_map; char saved_seq_mode; + char saved_gfx_map; char saved_gfx_mode; char saved_gfx_misc; int offset = buffer * VGA_FONT_SIZE + index * VGA_FONT_HEIGHT; assert (offset >= 0 && offset + datalen <= VGA_VIDEO_MEM_LENGTH); - /* Select plane 2 for sequential writing. */ + /* Select plane 2 for sequential writing. You might think it is not + necessary for reading, but it is. Likewise for read settings + when writing. Joy. */ outb (VGA_SEQ_MAP_ADDR, VGA_SEQ_ADDR_REG); saved_seq_map = inb (VGA_SEQ_DATA_REG); outb (VGA_SEQ_MAP_PLANE2, VGA_SEQ_DATA_REG); outb (VGA_SEQ_MODE_ADDR, VGA_SEQ_ADDR_REG); saved_seq_mode = inb (VGA_SEQ_DATA_REG); - outb (VGA_SEQ_MODE_SEQUENTIAL | VGA_SEQ_MODE_EXT | 0x1 /* XXX Why? */, - VGA_SEQ_DATA_REG); + outb (VGA_SEQ_MODE_SEQUENTIAL | VGA_SEQ_MODE_EXT, VGA_SEQ_DATA_REG); - /* Set write mode 0, but assume that rotate count, enable set/reset, - logical operation and bit mask fields are set to their - `do-not-modify-host-value' default. The misc register is set to - select sequential addressing in text mode. */ + /* Read sequentially from plane 2. */ + outb (VGA_GFX_MAP_ADDR, VGA_GFX_ADDR_REG); + saved_gfx_map = inb (VGA_GFX_DATA_REG); + outb (VGA_GFX_MAP_PLANE2, VGA_GFX_DATA_REG); outb (VGA_GFX_MODE_ADDR, VGA_GFX_ADDR_REG); saved_gfx_mode = inb (VGA_GFX_DATA_REG); - outb (VGA_GFX_MODE_WRITE0, VGA_GFX_DATA_REG); + outb (VGA_GFX_MODE_READ0, VGA_GFX_DATA_REG); outb (VGA_GFX_MISC_ADDR, VGA_GFX_ADDR_REG); saved_gfx_misc = inb (VGA_GFX_DATA_REG); - outb (VGA_GFX_MISC_A0TOAF, VGA_GFX_DATA_REG); + outb (VGA_GFX_MISC_A0TOBF, VGA_GFX_DATA_REG); - memcpy (vga_videomem + offset, data, datalen); + if (write) + memcpy (vga_videomem + offset, data, datalen); + else + memcpy (data, vga_videomem + offset, datalen); /* Restore sequencer and graphic register values. */ outb (VGA_SEQ_MAP_ADDR, VGA_SEQ_ADDR_REG); @@ -264,6 +271,8 @@ vga_write_font_buffer (int buffer, int index, char *data, size_t datalen) outb (VGA_SEQ_MODE_ADDR, VGA_SEQ_ADDR_REG); outb (saved_seq_mode, VGA_SEQ_DATA_REG); + outb (VGA_GFX_MAP_ADDR, VGA_GFX_ADDR_REG); + outb (saved_gfx_map, VGA_GFX_DATA_REG); outb (VGA_GFX_MODE_ADDR, VGA_GFX_ADDR_REG); outb (saved_gfx_mode, VGA_GFX_DATA_REG); outb (VGA_GFX_MISC_ADDR, VGA_GFX_ADDR_REG); @@ -271,37 +280,20 @@ vga_write_font_buffer (int buffer, int index, char *data, size_t datalen) } +/* Write DATALEN bytes from DATA to the font buffer BUFFER, starting + from glyph INDEX. */ +void +vga_write_font_buffer (int buffer, int index, char *data, size_t datalen) +{ + vga_read_write_font_buffer (1, buffer, index, data, datalen); +} + /* Read DATALEN bytes into DATA from the font buffer BUFFER, starting from glyph INDEX. */ void vga_read_font_buffer (int buffer, int index, char *data, size_t datalen) { - char saved_gfx_map; - char saved_gfx_mode; - char saved_gfx_misc; - - int offset = buffer * VGA_FONT_SIZE + index * VGA_FONT_HEIGHT; - assert (offset >= 0 && offset + datalen <= VGA_VIDEO_MEM_LENGTH); - - /* Read sequentially from plane 2. */ - outb (VGA_GFX_MAP_ADDR, VGA_GFX_ADDR_REG); - saved_gfx_map = inb (VGA_GFX_DATA_REG); - outb (VGA_GFX_MAP_PLANE2, VGA_GFX_DATA_REG); - outb (VGA_GFX_MODE_ADDR, VGA_GFX_ADDR_REG); - saved_gfx_mode = inb (VGA_GFX_DATA_REG); - outb (VGA_GFX_MODE_READ0, VGA_GFX_DATA_REG); - outb (VGA_GFX_MISC_ADDR, VGA_GFX_ADDR_REG); - saved_gfx_misc = inb (VGA_GFX_DATA_REG); - outb (VGA_GFX_MISC_A0TOBF, VGA_GFX_DATA_REG); - - memcpy (data, vga_videomem + offset, datalen); - - outb (VGA_GFX_MAP_ADDR, VGA_GFX_ADDR_REG); - outb (saved_gfx_map, VGA_GFX_DATA_REG); - outb (VGA_GFX_MODE_ADDR, VGA_GFX_ADDR_REG); - outb (saved_gfx_mode, VGA_GFX_DATA_REG); - outb (VGA_GFX_MISC_ADDR, VGA_GFX_ADDR_REG); - outb (saved_gfx_misc, VGA_GFX_DATA_REG); + vga_read_write_font_buffer (0, buffer, index, data, datalen); } |