From 72bb7b094e5782d798ce4c3a17018618e3e4d782 Mon Sep 17 00:00:00 2001 From: Stefan Reinauer Date: Mon, 1 Jun 2026 13:38:59 -0700 Subject: [PATCH] pcem: make MGA high-bit masks unsigned 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 | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/pcem/vid_mga.cpp b/pcem/vid_mga.cpp index 28cb652a..891b1d8d 100644 --- a/pcem/vid_mga.cpp +++ b/pcem/vid_mga.cpp @@ -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 -- 2.47.3