mirror of
https://github.com/holub/mame
synced 2025-07-01 08:18:59 +03:00
replace BITSWAP8/16/24/32 macros with constexpr function that works for any number of bits
This commit is contained in:
parent
af6b18bd68
commit
8aebdfc06d
@ -19,7 +19,6 @@
|
|||||||
|
|
||||||
#define CLOCK_MULTIPLIER 1
|
#define CLOCK_MULTIPLIER 1
|
||||||
|
|
||||||
#define BIT(x,n) (((x)>>(n))&1)
|
|
||||||
#define BITS(x,m,n) (((x)>>(n))&(((UINT32)1<<((m)-(n)+1))-1))
|
#define BITS(x,m,n) (((x)>>(n))&(((UINT32)1<<((m)-(n)+1))-1))
|
||||||
#define CLR_BITS(x,m,n) ((x) & ~((((UINT32)1 << ((m) - (n) + 1)) - 1) << n))
|
#define CLR_BITS(x,m,n) ((x) & ~((((UINT32)1 << ((m) - (n) + 1)) - 1) << n))
|
||||||
|
|
||||||
|
@ -284,7 +284,6 @@ void s3c44b0_device::device_reset()
|
|||||||
|
|
||||||
#define CLOCK_MULTIPLIER 1
|
#define CLOCK_MULTIPLIER 1
|
||||||
|
|
||||||
#define BIT(x,n) (((x)>>(n))&1)
|
|
||||||
#define BITS(x,m,n) (((x)>>(n))&(((UINT32)1<<((m)-(n)+1))-1))
|
#define BITS(x,m,n) (((x)>>(n))&(((UINT32)1<<((m)-(n)+1))-1))
|
||||||
#define CLR_BITS(x,m,n) ((x) & ~((((UINT32)1 << ((m) - (n) + 1)) - 1) << n))
|
#define CLR_BITS(x,m,n) ((x) & ~((((UINT32)1 << ((m) - (n) + 1)) - 1) << n))
|
||||||
|
|
||||||
|
@ -26,7 +26,6 @@ static inline void ATTR_PRINTF(3,4) verboselog( device_t &device, int n_level, c
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#define BIT(x,n) (((x)>>(n))&1)
|
|
||||||
#define BITS(x,m,n) (((x)>>(n))&(((UINT32)1<<((m)-(n)+1))-1))
|
#define BITS(x,m,n) (((x)>>(n))&(((UINT32)1<<((m)-(n)+1))-1))
|
||||||
|
|
||||||
#define GF4500_FRAMEBUF_OFFSET 0x20000
|
#define GF4500_FRAMEBUF_OFFSET 0x20000
|
||||||
|
@ -7,10 +7,10 @@
|
|||||||
General core utilities and macros used throughout the emulator.
|
General core utilities and macros used throughout the emulator.
|
||||||
***************************************************************************/
|
***************************************************************************/
|
||||||
|
|
||||||
#pragma once
|
#ifndef MAME_EMU_EMUCORE_H
|
||||||
|
#define MAME_EMU_EMUCORE_H
|
||||||
|
|
||||||
#ifndef __EMUCORE_H__
|
#pragma once
|
||||||
#define __EMUCORE_H__
|
|
||||||
|
|
||||||
// standard C includes
|
// standard C includes
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
@ -240,36 +240,24 @@ inline TYPE operator--(TYPE &value, int) { TYPE const old(value); --value; retur
|
|||||||
#define ENDIAN_VALUE_NE_NNE(endian,neval,nneval) (((endian) == ENDIANNESS_NATIVE) ? (neval) : (nneval))
|
#define ENDIAN_VALUE_NE_NNE(endian,neval,nneval) (((endian) == ENDIANNESS_NATIVE) ? (neval) : (nneval))
|
||||||
|
|
||||||
|
|
||||||
// useful macros to deal with bit shuffling encryptions
|
// useful functions to deal with bit shuffling encryptions
|
||||||
#define BIT(x,n) (((x)>>(n))&1)
|
#define BIT(x, n) (((x) >> (n)) & 1)
|
||||||
|
|
||||||
#define BITSWAP8(val,B7,B6,B5,B4,B3,B2,B1,B0) \
|
template <typename T, typename U> constexpr T bitswap(T val, U b)
|
||||||
((BIT(val,B7) << 7) | (BIT(val,B6) << 6) | (BIT(val,B5) << 5) | (BIT(val,B4) << 4) | \
|
{
|
||||||
(BIT(val,B3) << 3) | (BIT(val,B2) << 2) | (BIT(val,B1) << 1) | (BIT(val,B0) << 0))
|
return BIT(val, b) << 0U;
|
||||||
|
}
|
||||||
|
|
||||||
#define BITSWAP16(val,B15,B14,B13,B12,B11,B10,B9,B8,B7,B6,B5,B4,B3,B2,B1,B0) \
|
template <typename T, typename U, typename... V> constexpr T bitswap(T val, U b, V... c)
|
||||||
((BIT(val,B15) << 15) | (BIT(val,B14) << 14) | (BIT(val,B13) << 13) | (BIT(val,B12) << 12) | \
|
{
|
||||||
(BIT(val,B11) << 11) | (BIT(val,B10) << 10) | (BIT(val, B9) << 9) | (BIT(val, B8) << 8) | \
|
return (BIT(val, b) << sizeof...(c)) | bitswap(val, c...);
|
||||||
(BIT(val, B7) << 7) | (BIT(val, B6) << 6) | (BIT(val, B5) << 5) | (BIT(val, B4) << 4) | \
|
}
|
||||||
(BIT(val, B3) << 3) | (BIT(val, B2) << 2) | (BIT(val, B1) << 1) | (BIT(val, B0) << 0))
|
|
||||||
|
|
||||||
#define BITSWAP24(val,B23,B22,B21,B20,B19,B18,B17,B16,B15,B14,B13,B12,B11,B10,B9,B8,B7,B6,B5,B4,B3,B2,B1,B0) \
|
// legacy names for backwards compatibility
|
||||||
((BIT(val,B23) << 23) | (BIT(val,B22) << 22) | (BIT(val,B21) << 21) | (BIT(val,B20) << 20) | \
|
template <typename T, typename... U> constexpr T BITSWAP8(T val, U... b) { return bitswap(val, b...); }
|
||||||
(BIT(val,B19) << 19) | (BIT(val,B18) << 18) | (BIT(val,B17) << 17) | (BIT(val,B16) << 16) | \
|
template <typename T, typename... U> constexpr T BITSWAP16(T val, U... b) { return bitswap(val, b...); }
|
||||||
(BIT(val,B15) << 15) | (BIT(val,B14) << 14) | (BIT(val,B13) << 13) | (BIT(val,B12) << 12) | \
|
template <typename T, typename... U> constexpr T BITSWAP24(T val, U... b) { return bitswap(val, b...); }
|
||||||
(BIT(val,B11) << 11) | (BIT(val,B10) << 10) | (BIT(val, B9) << 9) | (BIT(val, B8) << 8) | \
|
template <typename T, typename... U> constexpr T BITSWAP32(T val, U... b) { return bitswap(val, b...); }
|
||||||
(BIT(val, B7) << 7) | (BIT(val, B6) << 6) | (BIT(val, B5) << 5) | (BIT(val, B4) << 4) | \
|
|
||||||
(BIT(val, B3) << 3) | (BIT(val, B2) << 2) | (BIT(val, B1) << 1) | (BIT(val, B0) << 0))
|
|
||||||
|
|
||||||
#define BITSWAP32(val,B31,B30,B29,B28,B27,B26,B25,B24,B23,B22,B21,B20,B19,B18,B17,B16,B15,B14,B13,B12,B11,B10,B9,B8,B7,B6,B5,B4,B3,B2,B1,B0) \
|
|
||||||
((BIT(val,B31) << 31) | (BIT(val,B30) << 30) | (BIT(val,B29) << 29) | (BIT(val,B28) << 28) | \
|
|
||||||
(BIT(val,B27) << 27) | (BIT(val,B26) << 26) | (BIT(val,B25) << 25) | (BIT(val,B24) << 24) | \
|
|
||||||
(BIT(val,B23) << 23) | (BIT(val,B22) << 22) | (BIT(val,B21) << 21) | (BIT(val,B20) << 20) | \
|
|
||||||
(BIT(val,B19) << 19) | (BIT(val,B18) << 18) | (BIT(val,B17) << 17) | (BIT(val,B16) << 16) | \
|
|
||||||
(BIT(val,B15) << 15) | (BIT(val,B14) << 14) | (BIT(val,B13) << 13) | (BIT(val,B12) << 12) | \
|
|
||||||
(BIT(val,B11) << 11) | (BIT(val,B10) << 10) | (BIT(val, B9) << 9) | (BIT(val, B8) << 8) | \
|
|
||||||
(BIT(val, B7) << 7) | (BIT(val, B6) << 6) | (BIT(val, B5) << 5) | (BIT(val, B4) << 4) | \
|
|
||||||
(BIT(val, B3) << 3) | (BIT(val, B2) << 2) | (BIT(val, B1) << 1) | (BIT(val, B0) << 0))
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -426,4 +414,4 @@ inline UINT64 d2u(double d)
|
|||||||
return u.vv;
|
return u.vv;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* __EMUCORE_H__ */
|
#endif /* MAME_EMU_EMUCORE_H */
|
||||||
|
@ -39,7 +39,6 @@ SYSINTR_GPS = INT_EINT3, INT_EINT8_23 (EINT18)
|
|||||||
#define VERBOSE_LEVEL ( 0 )
|
#define VERBOSE_LEVEL ( 0 )
|
||||||
|
|
||||||
|
|
||||||
#define BIT(x,n) (((x)>>(n))&1)
|
|
||||||
#define BITS(x,m,n) (((x)>>(n))&(((UINT32)1<<((m)-(n)+1))-1))
|
#define BITS(x,m,n) (((x)>>(n))&(((UINT32)1<<((m)-(n)+1))-1))
|
||||||
|
|
||||||
class gizmondo_state : public driver_device
|
class gizmondo_state : public driver_device
|
||||||
|
@ -43,7 +43,6 @@ static inline void ATTR_PRINTF(3,4) verboselog(device_t &device, int n_level, co
|
|||||||
#define MPLLCON 1
|
#define MPLLCON 1
|
||||||
#define UPLLCON 2
|
#define UPLLCON 2
|
||||||
|
|
||||||
#define BIT(x,n) (((x)>>(n))&1)
|
|
||||||
#define BITS(x,m,n) (((x)>>(n))&((1<<((m)-(n)+1))-1))
|
#define BITS(x,m,n) (((x)>>(n))&((1<<((m)-(n)+1))-1))
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user