From nobody Sat Apr 27 20:37:20 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1529357972386729.0218504727907; Mon, 18 Jun 2018 14:39:32 -0700 (PDT) Received: from localhost ([::1]:36986 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fV1s3-0001x8-Ol for importer@patchew.org; Mon, 18 Jun 2018 17:39:31 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37441) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fV1rC-0001eH-7p for qemu-devel@nongnu.org; Mon, 18 Jun 2018 17:38:39 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fV1r8-0006fR-6h for qemu-devel@nongnu.org; Mon, 18 Jun 2018 17:38:38 -0400 Received: from relay2.mail.vrmd.de ([81.28.224.28]:58817) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1fV1r8-0006fI-03 for qemu-devel@nongnu.org; Mon, 18 Jun 2018 17:38:34 -0400 Received: from [188.106.101.8] (helo=murray.fritz.box) by relay2.mail.vrmd.de with esmtpa (Exim 4.86_2) (envelope-from ) id 1fV1qz-000Q63-Mi; Mon, 18 Jun 2018 23:38:25 +0200 From: Sebastian Bauer To: mail@sebastianbauer.info Date: Mon, 18 Jun 2018 23:38:16 +0200 Message-Id: <20180618213816.5966-1-mail@sebastianbauer.info> X-Mailer: git-send-email 2.17.1 X-Relay-User: mail@sebastianbauer.info X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 81.28.224.28 Subject: [Qemu-devel] [PATCH] sm501: Fix hardware cursor color conversion X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: qemu-devel@nongnu.org, david@gibson.dropbear.id.au Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" According to the sm501 specs the hardware cursor colors are to be given in the rgb565 format, but the code currently interprets them as bgr565. Therefore, the colors of the hardware cursors are wrong in the QEMU display, e.g., the standard mouse pointer of AmigaOS appears blue instead of red. This change fixes this issue by replacing the existing naive bgr565 =3D> rgb888 conversion with a standard rgb565 =3D> rgb888 one that a= lso scales the color component values properly. Signed-off-by: Sebastian Bauer --- hw/display/sm501.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/hw/display/sm501.c b/hw/display/sm501.c index 0488ab69d3..6c7f8483f3 100644 --- a/hw/display/sm501.c +++ b/hw/display/sm501.c @@ -668,9 +668,9 @@ static inline void get_hwc_palette(SM501State *state, i= nt crt, uint8_t *palette) } else { rgb565 =3D color_reg & 0xFFFF; } - palette[i * 3 + 0] =3D (rgb565 << 3) & 0xf8; /* red */ - palette[i * 3 + 1] =3D (rgb565 >> 3) & 0xfc; /* green */ - palette[i * 3 + 2] =3D (rgb565 >> 8) & 0xf8; /* blue */ + palette[i * 3 + 0] =3D ((rgb565 >> 11) * 527 + 23) >> 6; /* r */ + palette[i * 3 + 1] =3D (((rgb565 >> 5) & 0x3f) * 259 + 33) >> 6; /= * g */ + palette[i * 3 + 2] =3D ((rgb565 & 0x1f) * 527 + 23) >> 6; /* b */ } } =20 --=20 2.17.1