vga: reindent memory access code

The next patch will reuse latched memory access in text modes.  Start with
a patch that moves the latched access code out of the "if".

Best reviewed with "git diff -b".

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
This commit is contained in:
Paolo Bonzini 2014-12-30 22:41:24 +01:00
parent 4d6c310502
commit ae9d71a003

View File

@ -815,27 +815,31 @@ uint32_t vga_mem_readb(VGACommonState *s, hwaddr addr)
}
if (sr(s, VGA_SEQ_MEMORY_MODE) & VGA_SR04_CHN_4M) {
/* chain 4 mode : simplest access */
/* chain 4 mode : simplest access (but it should use the same
* algorithms as below; see e.g. vga_mem_writeb's plane mask check).
*/
assert(addr < s->vram_size);
ret = s->vram_ptr[addr];
} else if (s->gr[VGA_GFX_MODE] & 0x10) {
return s->vram_ptr[addr];
}
if (s->gr[VGA_GFX_MODE] & 0x10) {
/* odd/even mode (aka text mode mapping) */
plane = (s->gr[VGA_GFX_PLANE_READ] & 2) | (addr & 1);
addr = ((addr & ~1) << 1) | plane;
if (addr >= s->vram_size) {
return 0xff;
}
ret = s->vram_ptr[addr];
} else {
return s->vram_ptr[addr];
}
/* standard VGA latched access */
plane = s->gr[VGA_GFX_PLANE_READ];
if (addr * sizeof(uint32_t) >= s->vram_size) {
return 0xff;
}
s->latch = ((uint32_t *)s->vram_ptr)[addr];
if (!(s->gr[VGA_GFX_MODE] & 0x08)) {
/* read mode 0 */
plane = s->gr[VGA_GFX_PLANE_READ];
ret = GET_PLANE(s->latch, plane);
} else {
/* read mode 1 */
@ -845,7 +849,7 @@ uint32_t vga_mem_readb(VGACommonState *s, hwaddr addr)
ret |= ret >> 8;
ret = (~ret) & 0xff;
}
}
return ret;
}
@ -895,7 +899,10 @@ void vga_mem_writeb(VGACommonState *s, hwaddr addr, uint32_t val)
s->plane_updated |= mask; /* only used to detect font change */
memory_region_set_dirty(&s->vram, addr, 1);
}
} else if (s->gr[VGA_GFX_MODE] & 0x10) {
return;
}
if (s->gr[VGA_GFX_MODE] & 0x10) {
/* odd/even mode (aka text mode mapping) */
plane = (s->gr[VGA_GFX_PLANE_READ] & 2) | (addr & 1);
mask = (1 << plane);
@ -911,7 +918,11 @@ void vga_mem_writeb(VGACommonState *s, hwaddr addr, uint32_t val)
s->plane_updated |= mask; /* only used to detect font change */
memory_region_set_dirty(&s->vram, addr, 1);
}
} else {
return;
}
mask = sr(s, VGA_SEQ_PLANE_WRITE);
/* standard VGA latched access */
write_mode = s->gr[VGA_GFX_MODE] & 3;
switch(write_mode) {
@ -974,7 +985,6 @@ void vga_mem_writeb(VGACommonState *s, hwaddr addr, uint32_t val)
do_write:
/* mask data according to sr[2] */
mask = sr(s, VGA_SEQ_PLANE_WRITE);
s->plane_updated |= mask; /* only used to detect font change */
write_mask = mask16[mask];
if (addr * sizeof(uint32_t) >= s->vram_size) {
@ -989,7 +999,6 @@ void vga_mem_writeb(VGACommonState *s, hwaddr addr, uint32_t val)
#endif
memory_region_set_dirty(&s->vram, addr << 2, sizeof(uint32_t));
}
}
typedef void *vga_draw_line_func(VGACommonState *s1, uint8_t *d,
uint32_t srcaddr, int width, int hpel);