diff --git a/common/irandom.cpp b/common/irandom.cpp index 73c17a1a..ea9ee54b 100644 --- a/common/irandom.cpp +++ b/common/irandom.cpp @@ -32,6 +32,7 @@ #include #include #include "irandom.h" +#include "endianness.h" unsigned int RandNumb = 0x12349876; @@ -59,6 +60,18 @@ unsigned char Random() ** This treats the number as bytes so setting it on bit endian machines needs to byte swap. */ unsigned char* bytes = reinterpret_cast(&RandNumb); +#ifdef __BIG_ENDIAN__ + unsigned char cf1 = (bytes[3] >> 1) & 1; + unsigned char tmp_a = bytes[3] >> 2; + unsigned char cf2 = (bytes[1] >> 7) & 1; + bytes[1] = (bytes[1] << 1) | cf1; + cf1 = (bytes[2] >> 7) & 1; + bytes[2] = (bytes[2] << 1) | cf2; + cf2 = (tmp_a - (RandNumb + (cf1 != 1))) & 1; + bytes[3] = (bytes[3] >> 1) | (cf2 << 7); + + return bytes[2] ^ bytes[3]; +#else unsigned char cf1 = (bytes[0] >> 1) & 1; unsigned char tmp_a = bytes[0] >> 2; unsigned char cf2 = (bytes[2] >> 7) & 1; @@ -69,6 +82,7 @@ unsigned char Random() bytes[0] = (bytes[0] >> 1) | (cf2 << 7); return bytes[1] ^ bytes[0]; +#endif } int Get_Random_Mask(int maxval) diff --git a/tiberiandawn/dialog.cpp b/tiberiandawn/dialog.cpp index acf06cb5..b20427a6 100644 --- a/tiberiandawn/dialog.cpp +++ b/tiberiandawn/dialog.cpp @@ -133,6 +133,12 @@ void Draw_Box(int x, int y, int w, int h, BoxStyleEnum up, bool filled) useGoldStyle = Settings.Video.ButtonStyle == 1; } + /* If DOSMode is enabled then force disable of goldstyle buttons once the + textures may not be available. */ + if (Get_Resolution_Factor() == 0) { + useGoldStyle = false; + } + w--; h--; BoxStyleType const& style = useGoldStyle ? ButtonColorsGold[up] : ButtonColorsClassic[up];