[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH 6/7] hw/display/artist: Fix artist screen resolution
From: |
Helge Deller |
Subject: |
Re: [PATCH 6/7] hw/display/artist: Fix artist screen resolution |
Date: |
Thu, 3 Sep 2020 08:08:54 +0200 |
New patch #2:
From b0f0d24563df504b8221fbc934d25c5a896e0a49 Mon Sep 17 00:00:00 2001
From: Helge Deller <deller@gmx.de>
Subject: [PATCH] hw/display/artist: Refactor x/y coordination extraction
Simplify the code by using new introduced ADDR_TO_Y() and ADDR_TO_X()
macros. Those macros extract the x/y-coordinate from the given uint32.
As further simplification the extraction of the x/y coordinates for
VRAM_WRITE_INCR_Y and VRAM_WRITE_INCR_X can be done centrally in
vram_bit_write(), so move this code up into the function.
ADDR_TO_Y() is still limited to 10 bits which allow to address up to of
1024 lines - this will be increased in a follow-up patch.
Signed-off-by: Helge Deller <deller@gmx.de>
diff --git a/hw/display/artist.c b/hw/display/artist.c
index ff1532fdc1..16d85c65f8 100644
--- a/hw/display/artist.c
+++ b/hw/display/artist.c
@@ -192,6 +192,10 @@ static const char *artist_reg_name(uint64_t addr)
}
#undef REG_NAME
+/* artist has a fixed line length of 2048 bytes. */
+#define ADDR_TO_Y(addr) extract32(addr, 11, 10)
+#define ADDR_TO_X(addr) extract32(addr, 0, 11)
+
static int16_t artist_get_x(uint32_t reg)
{
return reg >> 16;
@@ -348,13 +352,13 @@ static void artist_invalidate_cursor(ARTISTState *s)
y, s->cursor_height);
}
-static void vram_bit_write(ARTISTState *s, int posx, int posy, bool incr_x,
+static void vram_bit_write(ARTISTState *s, int posy, bool incr_x,
int size, uint32_t data)
{
struct vram_buffer *buf;
uint32_t vram_bitmask = s->vram_bitmask;
int mask, i, pix_count, pix_length;
- unsigned int offset, width;
+ unsigned int posx, offset, width;
uint8_t *data8, *p;
pix_count = vram_write_pix_per_transfer(s);
@@ -366,6 +370,8 @@ static void vram_bit_write(ARTISTState *s, int posx, int
posy, bool incr_x,
if (s->cmap_bm_access) {
offset = s->vram_pos;
} else {
+ posx = ADDR_TO_X(s->vram_pos >> 2);
+ posy += ADDR_TO_Y(s->vram_pos >> 2);
offset = posy * width + posx;
}
@@ -858,7 +864,6 @@ static void artist_reg_write(void *opaque, hwaddr addr,
uint64_t val,
unsigned size)
{
ARTISTState *s = opaque;
- int posx, posy;
int width, height;
trace_artist_reg_write(size, addr, artist_reg_name(addr & ~3ULL), val);
@@ -881,16 +886,12 @@ static void artist_reg_write(void *opaque, hwaddr addr,
uint64_t val,
break;
case VRAM_WRITE_INCR_Y:
- posx = (s->vram_pos >> 2) & 0x7ff;
- posy = (s->vram_pos >> 13) & 0x3ff;
- vram_bit_write(s, posx, posy + s->vram_char_y++, false, size, val);
+ vram_bit_write(s, s->vram_char_y++, false, size, val);
break;
case VRAM_WRITE_INCR_X:
case VRAM_WRITE_INCR_X2:
- posx = (s->vram_pos >> 2) & 0x7ff;
- posy = (s->vram_pos >> 13) & 0x3ff;
- vram_bit_write(s, posx, posy + s->vram_char_y, true, size, val);
+ vram_bit_write(s, s->vram_char_y, true, size, val);
break;
case VRAM_IDX:
@@ -1156,8 +1157,7 @@ static void artist_vram_write(void *opaque, hwaddr addr,
uint64_t val,
{
ARTISTState *s = opaque;
struct vram_buffer *buf;
- int posy = (addr >> 11) & 0x3ff;
- int posx = addr & 0x7ff;
+ unsigned int posy, posx;
unsigned int offset;
trace_artist_vram_write(size, addr, val);
@@ -1170,6 +1170,9 @@ static void artist_vram_write(void *opaque, hwaddr addr,
uint64_t val,
}
buf = vram_write_buffer(s);
+ posy = ADDR_TO_Y(addr);
+ posx = ADDR_TO_X(addr);
+
if (!buf->size) {
return;
}
@@ -1212,7 +1215,7 @@ static uint64_t artist_vram_read(void *opaque, hwaddr
addr, unsigned size)
ARTISTState *s = opaque;
struct vram_buffer *buf;
uint64_t val;
- int posy, posx;
+ unsigned int posy, posx;
if (s->cmap_bm_access) {
buf = &s->vram_buffer[ARTIST_BUFFER_CMAP];
@@ -1229,8 +1232,8 @@ static uint64_t artist_vram_read(void *opaque, hwaddr
addr, unsigned size)
return 0;
}
- posy = (addr >> 13) & 0x3ff;
- posx = (addr >> 2) & 0x7ff;
+ posy = ADDR_TO_Y(addr);
+ posx = ADDR_TO_X(addr);
if (posy > buf->height || posx > buf->width) {
return 0;
- Re: [PATCH 4/7] hw/hppa: Inform SeaBIOS about fw_cfg port address, (continued)
[PATCH 5/7] hw/hppa: Add power button emulation, Helge Deller, 2020/09/01
[PATCH 6/7] hw/display/artist: Fix artist screen resolution, Helge Deller, 2020/09/01
- Re: [PATCH 6/7] hw/display/artist: Fix artist screen resolution, Richard Henderson, 2020/09/01
- Re: [PATCH 6/7] hw/display/artist: Fix artist screen resolution, Helge Deller, 2020/09/02
- Re: [PATCH 6/7] hw/display/artist: Fix artist screen resolution, Richard Henderson, 2020/09/02
- Re: [PATCH 6/7] hw/display/artist: Fix artist screen resolution, Helge Deller, 2020/09/03
- Re: [PATCH 6/7] hw/display/artist: Fix artist screen resolution,
Helge Deller <=
- Re: [PATCH 6/7] hw/display/artist: Fix artist screen resolution, Helge Deller, 2020/09/03
- Re: [PATCH 6/7] hw/display/artist: Fix artist screen resolution, Richard Henderson, 2020/09/03
[PATCH 3/7] hw/hppa: Store boot device in fw_cfg section, Helge Deller, 2020/09/01
[PATCH 1/7] seabios-hppa: Update SeaBIOS to hppa-qemu-5.2-2 tag, Helge Deller, 2020/09/01
[PATCH 7/7] target/hppa: Fix boot with old Linux installation CDs, Helge Deller, 2020/09/01
[PATCH 2/7] hw/hppa: Make number of TLB and BTLB entries configurable, Helge Deller, 2020/09/01