]> git.unchartedbackwaters.co.uk Git - francis/winuae.git/commitdiff
pcem: make MGA high-bit masks unsigned
authorStefan Reinauer <stefan.reinauer@coreboot.org>
Mon, 1 Jun 2026 20:38:59 +0000 (13:38 -0700)
committerStefan Reinauer <stefan.reinauer@coreboot.org>
Mon, 1 Jun 2026 20:38:59 +0000 (13:38 -0700)
MGA defines several bit-31 masks from a signed int literal.
Shifting a signed 1 into the sign bit is undefined behavior in C.

Use UINT32_C(1) so the masks are built in unsigned arithmetic.
This matches the same cleanup merged upstream in 86Box, with the
extra OPTION_POWERPC mask that exists in this imported copy.

pcem/vid_mga.cpp

index 28cb652a7b1bcff0a9e06aadd2a81e45c530789b..891b1d8d0a20b0a99fd161dde577c92726259106 100644 (file)
@@ -47,7 +47,7 @@ extern void activate_debugger(void);
 
 #define FIFO_SIZE        65536
 #define FIFO_MASK        (FIFO_SIZE - 1)
-#define FIFO_ENTRY_SIZE  (1 << 31)
+#define FIFO_ENTRY_SIZE  (UINT32_C(1) << 31)
 #define FIFO_THRESHOLD   0xe000
 
 #define WAKE_DELAY       (100 * TIMER_USEC) /* 100us */
@@ -337,7 +337,7 @@ extern void activate_debugger(void);
 #define MACCESS_FOGEN                 (1 << 26)
 #define MACCESS_TLUTLOAD              (1 << 29)
 #define MACCESS_NODITHER              (1 << 30)
-#define MACCESS_DIT555                (1 << 31)
+#define MACCESS_DIT555                (UINT32_C(1) << 31)
 
 #define PITCH_MASK                    0xfe0
 #define PITCH_YLIN                    (1 << 15)
@@ -386,7 +386,7 @@ extern void activate_debugger(void);
 #define TEXCTL_CLAMPU                 (1 << 28)
 #define TEXCTL_TMODULATE              (1 << 29)
 #define TEXCTL_STRANS                 (1 << 30)
-#define TEXCTL_ITRANS                 (1 << 31)
+#define TEXCTL_ITRANS                 (UINT32_C(1) << 31)
 
 #define TEXHEIGHT_TH_MASK             (0x3f << 0)
 #define TEXHEIGHT_THMASK_SHIFT        (18)
@@ -407,7 +407,7 @@ extern void activate_debugger(void);
 
 /*PCI configuration registers*/
 #define OPTION_INTERLEAVE (1 << 12)
-#define OPTION_POWERPC (1 << 31)
+#define OPTION_POWERPC (UINT32_C(1) << 31)
 
 enum {
     MGA_2064W,  /*Millennium*/
@@ -3922,7 +3922,7 @@ blit_iload_iload(mystique_t *mystique, uint32_t data, int size)
 
                 case DWGCTRL_BLTMOD_BMONOWF:
                     data      = (data >> 24) | ((data & 0x00ff0000) >> 8) | ((data & 0x0000ff00) << 8) | (data << 24);
-                    data_mask = (1 << 31);
+                    data_mask = (UINT32_C(1) << 31);
                 case DWGCTRL_BLTMOD_BMONOLEF:
                     while (size) {
                         if (mystique->dwgreg.xdst >= mystique->dwgreg.cxleft && mystique->dwgreg.xdst <= mystique->dwgreg.cxright && mystique->dwgreg.ydst_lin >= mystique->dwgreg.ytop && mystique->dwgreg.ydst_lin <= mystique->dwgreg.ybot && ((data & data_mask) || !(mystique->dwgreg.dwgctrl_running & DWGCTRL_TRANSC)) && trans[mystique->dwgreg.xdst & 3]) {
@@ -7207,4 +7207,4 @@ const device_t productiva_g100_device = {
 };
 #endif
 
-#endif
\ No newline at end of file
+#endif