Added new #define ENDIANNESS_NATIVE, which maps to either ENDIANNESS_LITTLE

or ENDIANNESS_BIG based on the LSB_FIRST definition. Unlink LSB_FIRST,
ENDIANNESS_NATIVE always exists and can be used in expressions without
invoking the preprocessor.

Added macro ENDIAN_VALUE_LE_BE() which selects one of two values based
on the endianness passed in. Also added NATIVE_ENDIAN_VALUE_LE_BE()
which calls ENDIAN_VALUE_LE_BE with ENDIANNESS_NATIVE.

Updated a number of drivers and call sites to use these macros in favor
of #ifdef LSB_FIRST.
This commit is contained in:
Aaron Giles 2009-01-17 23:03:17 +00:00
parent 79dbafbd2f
commit eb8366c740
24 changed files with 127 additions and 225 deletions

View File

@ -148,11 +148,7 @@ drcfe_state *drcfe_init(const device_config *cpu, const drcfe_config *config, vo
drcfe->program = memory_find_address_space(cpu, ADDRESS_SPACE_PROGRAM);
drcfe->pageshift = cpu_get_page_shift(cpu, ADDRESS_SPACE_PROGRAM);
drcfe->translate = (cpu_translate_func)device_get_info_fct(cpu, CPUINFO_FCT_TRANSLATE);
#ifdef LSB_FIRST
if (cpu_get_endianness(cpu) == ENDIANNESS_BIG)
#else
if (cpu_get_endianness(cpu) == ENDIANNESS_LITTLE)
#endif
if (cpu_get_endianness(cpu) != ENDIANNESS_NATIVE)
drcfe->codexor = (cpu_get_databus_width(cpu, ADDRESS_SPACE_PROGRAM) / 8 / cpu_get_min_opcode_bytes(cpu) - 1) * cpu_get_min_opcode_bytes(cpu);
return drcfe;

View File

@ -91,11 +91,7 @@ extern unsigned dasmmips3(char *buffer, unsigned pc, UINT32 op);
MACROS
***************************************************************************/
#ifdef LSB_FIRST
#define LOPTR(x) ((UINT32 *)(x))
#else
#define LOPTR(x) ((UINT32 *)(x) + 1)
#endif
#define LOPTR(x) ((UINT32 *)(x) + NATIVE_ENDIAN_VALUE_LE_BE(0,1))
#define R32(reg) mips3->impstate->regmaplo[reg].type, mips3->impstate->regmaplo[reg].value
#define LO32 R32(REG_LO)

View File

@ -49,17 +49,10 @@
* higher bit positions.
* That's the reason for the ordering in the following pointer table.
**************************************************************************/
#ifdef LSB_FIRST
#define RB(n) regs.B[((((n) & 7) << 1) | (((n) & 8) >> 3)) ^ 7]
#define RW(n) regs.W[(n) ^ 3]
#define RL(n) regs.L[((n) >> 1) ^ 1]
#define RQ(n) regs.Q[((n) >> 2)]
#else
#define RB(n) regs.B[(((n) & 7) << 1) | (((n) & 8) >> 3)]
#define RW(n) regs.W[(n)]
#define RL(n) regs.L[((n) >> 1)]
#define RQ(n) regs.Q[((n) >> 2)]
#endif
#define RB(n) regs.B[BYTE8_XOR_BE((((n) & 7) << 1) | (((n) & 8) >> 3))]
#define RW(n) regs.W[BYTE4_XOR_BE(n)]
#define RL(n) regs.L[BYTE_XOR_BE((n) >> 1)]
#define RQ(n) regs.Q[(n) >> 2]
/* the register used as stack pointer */
#define SP 15

View File

@ -2467,11 +2467,7 @@ static const memory_subview_item *memory_view_enumerate_subviews(running_machine
subview->index = curindex++;
subview->base = memory_region(machine, rgntag);
subview->length = memory_region_length(machine, rgntag);
#ifdef LSB_FIRST
subview->offsetxor = width - 1;
#else
subview->offsetxor = 0;
#endif
subview->offsetxor = NATIVE_ENDIAN_VALUE_LE_BE(width - 1, 0);
subview->endianness = little_endian ? ENDIANNESS_LITTLE : ENDIANNESS_BIG;
subview->prefsize = MIN(width, 8);
strcpy(subview->name, astring_c(tempstring));
@ -2510,11 +2506,7 @@ static const memory_subview_item *memory_view_enumerate_subviews(running_machine
subview->base = base;
subview->length = valcount * valsize;
subview->offsetxor = 0;
#ifdef LSB_FIRST
subview->endianness = ENDIANNESS_LITTLE;
#else
subview->endianness = ENDIANNESS_BIG;
#endif
subview->endianness = ENDIANNESS_NATIVE;
subview->prefsize = MIN(valsize, 8);
strcpy(subview->name, astring_c(tempstring));

View File

@ -138,15 +138,22 @@ typedef union
#endif
/* Endianness constants */
enum
{
ENDIANNESS_LITTLE = 0, /* emulated CPU is little endian */
ENDIANNESS_BIG /* emulated CPU is big endian */
ENDIANNESS_LITTLE = 0,
ENDIANNESS_BIG
};
/* Native endianness */
#ifdef LSB_FIRST
#define ENDIANNESS_NATIVE ENDIANNESS_LITTLE
#else
#define ENDIANNESS_NATIVE ENDIANNESS_BIG
#endif
/* orientation of bitmaps */
#define ORIENTATION_FLIP_X 0x0001 /* mirror everything in the X direction */
#define ORIENTATION_FLIP_Y 0x0002 /* mirror everything in the Y direction */
@ -196,6 +203,15 @@ enum
#define DEGREE_TO_RADIAN(x) ((M_PI / 180.0) * (x))
/* endian-based value: first value is if 'endian' is little-endian, second is if 'endian' is big-endian */
#define ENDIAN_VALUE_LE_BE(endian,leval,beval) (((endian) == ENDIANNESS_LITTLE) ? (leval) : (beval))
/* endian-based value: first value is if native endianness is little-endian, second is if native is big-endian */
#define NATIVE_ENDIAN_VALUE_LE_BE(leval,beval) ((ENDIANNESS_NATIVE == ENDIANNESS_LITTLE) ? (leval) : (beval))
/* endian-based value: first value is if 'endian' matches native, second is if 'endian' doesn't match native */
#define ENDIAN_VALUE_NE_NNE(endian,leval,beval) (((endian) == ENDIANNESS_NATIVE) ? (neval) : (nneval))
/* Useful macros to deal with bit shuffling encryptions */
#define BIT(x,n) (((x)>>(n))&1)

View File

@ -582,37 +582,30 @@ union _addrmap64_token
/* macros for accessing bytes and words within larger chunks */
#ifdef LSB_FIRST
#define BYTE_XOR_BE(a) ((a) ^ 1) /* read/write a byte to a 16-bit space */
#define BYTE_XOR_LE(a) (a)
#define BYTE4_XOR_BE(a) ((a) ^ 3) /* read/write a byte to a 32-bit space */
#define BYTE4_XOR_LE(a) (a)
#define WORD_XOR_BE(a) ((a) ^ 2) /* read/write a word to a 32-bit space */
#define WORD_XOR_LE(a) (a)
#define BYTE8_XOR_BE(a) ((a) ^ 7) /* read/write a byte to a 64-bit space */
#define BYTE8_XOR_LE(a) (a)
#define WORD2_XOR_BE(a) ((a) ^ 6) /* read/write a word to a 64-bit space */
#define WORD2_XOR_LE(a) (a)
#define DWORD_XOR_BE(a) ((a) ^ 4) /* read/write a dword to a 64-bit space */
#define DWORD_XOR_LE(a) (a)
/* read/write a byte to a 16-bit space */
#define BYTE_XOR_BE(a) ((a) ^ NATIVE_ENDIAN_VALUE_LE_BE(1,0))
#define BYTE_XOR_LE(a) ((a) ^ NATIVE_ENDIAN_VALUE_LE_BE(0,1))
#else
/* read/write a byte to a 32-bit space */
#define BYTE4_XOR_BE(a) ((a) ^ NATIVE_ENDIAN_VALUE_LE_BE(3,0))
#define BYTE4_XOR_LE(a) ((a) ^ NATIVE_ENDIAN_VALUE_LE_BE(0,3))
#define BYTE_XOR_BE(a) (a)
#define BYTE_XOR_LE(a) ((a) ^ 1) /* read/write a byte to a 16-bit space */
#define BYTE4_XOR_BE(a) (a)
#define BYTE4_XOR_LE(a) ((a) ^ 3) /* read/write a byte to a 32-bit space */
#define WORD_XOR_BE(a) (a)
#define WORD_XOR_LE(a) ((a) ^ 2) /* read/write a word to a 32-bit space */
#define BYTE8_XOR_BE(a) (a)
#define BYTE8_XOR_LE(a) ((a) ^ 7) /* read/write a byte to a 64-bit space */
#define WORD2_XOR_BE(a) (a)
#define WORD2_XOR_LE(a) ((a) ^ 6) /* read/write a word to a 64-bit space */
#define DWORD_XOR_BE(a) (a)
#define DWORD_XOR_LE(a) ((a) ^ 4) /* read/write a dword to a 64-bit space */
/* read/write a word to a 32-bit space */
#define WORD_XOR_BE(a) ((a) ^ NATIVE_ENDIAN_VALUE_LE_BE(2,0))
#define WORD_XOR_LE(a) ((a) ^ NATIVE_ENDIAN_VALUE_LE_BE(0,2))
#endif
/* read/write a byte to a 64-bit space */
#define BYTE8_XOR_BE(a) ((a) ^ NATIVE_ENDIAN_VALUE_LE_BE(7,0))
#define BYTE8_XOR_LE(a) ((a) ^ NATIVE_ENDIAN_VALUE_LE_BE(0,7))
/* read/write a word to a 64-bit space */
#define WORD2_XOR_BE(a) ((a) ^ NATIVE_ENDIAN_VALUE_LE_BE(6,0))
#define WORD2_XOR_LE(a) ((a) ^ NATIVE_ENDIAN_VALUE_LE_BE(0,6))
/* read/write a dword to a 64-bit space */
#define DWORD_XOR_BE(a) ((a) ^ NATIVE_ENDIAN_VALUE_LE_BE(4,0))
#define DWORD_XOR_LE(a) ((a) ^ NATIVE_ENDIAN_VALUE_LE_BE(0,4))

View File

@ -613,12 +613,12 @@ static void region_post_process(rom_load_data *romdata, const char *rgntag)
UINT32 regionlength = memory_region_length(romdata->machine, rgntag);
UINT32 regionflags = memory_region_flags(romdata->machine, rgntag);
UINT8 *regionbase = memory_region(romdata->machine, rgntag);
int littleendian = ((regionflags & ROMREGION_ENDIANMASK) == ROMREGION_LE);
int endianness = ((regionflags & ROMREGION_ENDIANMASK) == ROMREGION_LE) ? ENDIANNESS_LITTLE : ENDIANNESS_BIG;
int datawidth = 1 << ((regionflags & ROMREGION_WIDTHMASK) >> 8);
UINT8 *base;
int i, j;
LOG(("+ datawidth=%d little=%d\n", datawidth, littleendian));
LOG(("+ datawidth=%d little=%d\n", datawidth, endianness == ENDIANNESS_LITTLE));
/* if the region is inverted, do that now */
if (regionflags & ROMREGION_INVERTMASK)
@ -629,11 +629,7 @@ static void region_post_process(rom_load_data *romdata, const char *rgntag)
}
/* swap the endianness if we need to */
#ifdef LSB_FIRST
if (datawidth > 1 && !littleendian)
#else
if (datawidth > 1 && littleendian)
#endif
if (datawidth > 1 && endianness != ENDIANNESS_NATIVE)
{
LOG(("+ Byte swapping region\n"));
for (i = 0, base = regionbase; i < regionlength; i += datawidth)

View File

@ -280,12 +280,13 @@ static void get_audio_data(cdda_info *info, stream_sample_t *bufL, stream_sample
info->audio_length -= sectoread;
/* CD-DA data on the disc is big-endian, flip if we're not */
#ifdef LSB_FIRST
for( i = 0; i < info->audio_samples * 2; i++ )
if (ENDIANNESS_NATIVE == ENDIANNESS_LITTLE)
{
audio_cache[ i ] = BIG_ENDIANIZE_INT16( audio_cache[ i ] );
for( i = 0; i < info->audio_samples * 2; i++ )
{
audio_cache[ i ] = BIG_ENDIANIZE_INT16( audio_cache[ i ] );
}
}
#endif
/* reset feedout ptr */
info->audio_bptr = 0;

View File

@ -37,21 +37,13 @@ struct samples_info
read_wav_sample - read a WAV file as a sample
-------------------------------------------------*/
#ifdef LSB_FIRST
#define intelLong(x) (x)
#else
#define intelLong(x) (((x << 24) | (((unsigned long) x) >> 24) | (( x & 0x0000ff00) << 8) | (( x & 0x00ff0000) >> 8)))
#endif
static int read_wav_sample(mame_file *f, struct loaded_sample *sample)
{
unsigned long offset = 0;
UINT32 length, rate, filesize;
UINT16 bits, temp16;
char buf[32];
#ifndef LSB_FIRST
UINT32 sindex;
#endif
/* read the core header and make sure it's a WAVE file */
offset += mame_fread(f, buf, 4);
@ -64,7 +56,7 @@ static int read_wav_sample(mame_file *f, struct loaded_sample *sample)
offset += mame_fread(f, &filesize, 4);
if (offset < 8)
return 0;
filesize = intelLong(filesize);
filesize = LITTLE_ENDIANIZE_INT32(filesize);
/* read the RIFF file type and make sure it's a WAVE file */
offset += mame_fread(f, buf, 4);
@ -78,7 +70,7 @@ static int read_wav_sample(mame_file *f, struct loaded_sample *sample)
{
offset += mame_fread(f, buf, 4);
offset += mame_fread(f, &length, 4);
length = intelLong(length);
length = LITTLE_ENDIANIZE_INT32(length);
if (memcmp(&buf[0], "fmt ", 4) == 0)
break;
@ -103,7 +95,7 @@ static int read_wav_sample(mame_file *f, struct loaded_sample *sample)
/* sample rate */
offset += mame_fread(f, &rate, 4);
rate = intelLong(rate);
rate = LITTLE_ENDIANIZE_INT32(rate);
/* bytes/second and block alignment are ignored */
offset += mame_fread(f, buf, 6);
@ -123,7 +115,7 @@ static int read_wav_sample(mame_file *f, struct loaded_sample *sample)
{
offset += mame_fread(f, buf, 4);
offset += mame_fread(f, &length, 4);
length = intelLong(length);
length = LITTLE_ENDIANIZE_INT32(length);
if (memcmp(&buf[0], "data", 4) == 0)
break;
@ -162,10 +154,9 @@ static int read_wav_sample(mame_file *f, struct loaded_sample *sample)
sample->data = auto_malloc(sizeof(*sample->data) * (length/2));
mame_fread(f, sample->data, length);
sample->length /= 2;
#ifndef LSB_FIRST
for (sindex = 0; sindex < sample->length; sindex++)
sample->data[sindex] = LITTLE_ENDIANIZE_INT16(sample->data[sindex]);
#endif
if (ENDIANNESS_NATIVE != ENDIANNESS_LITTLE)
for (sindex = 0; sindex < sample->length; sindex++)
sample->data[sindex] = LITTLE_ENDIANIZE_INT16(sample->data[sindex]);
}
return 1;
}

View File

@ -8,13 +8,6 @@ struct _wav_file
UINT32 data_offs;
};
#ifdef LSB_FIRST
#define intel_long(x) (x)
#define intel_short(x) (x)
#else
#define intel_long(x) (((x << 24) | (((unsigned long) x) >> 24) | (( x & 0x0000ff00) << 8) | (( x & 0x00ff0000) >> 8)))
#define intel_short(x) (((x) << 8) | ((x) >> 8))
#endif
wav_file *wav_open(const char *filename, int sample_rate, int channels)
{
@ -50,33 +43,33 @@ wav_file *wav_open(const char *filename, int sample_rate, int channels)
fwrite("fmt ", 1, 4, wav->file);
/* write the format length */
temp32 = intel_long(16);
temp32 = LITTLE_ENDIANIZE_INT32(16);
fwrite(&temp32, 1, 4, wav->file);
/* write the format (PCM) */
temp16 = intel_short(1);
temp16 = LITTLE_ENDIANIZE_INT16(1);
fwrite(&temp16, 1, 2, wav->file);
/* write the channels */
temp16 = intel_short(channels);
temp16 = LITTLE_ENDIANIZE_INT16(channels);
fwrite(&temp16, 1, 2, wav->file);
/* write the sample rate */
temp32 = intel_long(sample_rate);
temp32 = LITTLE_ENDIANIZE_INT32(sample_rate);
fwrite(&temp32, 1, 4, wav->file);
/* write the bytes/second */
bps = sample_rate * 2 * channels;
temp32 = intel_long(bps);
temp32 = LITTLE_ENDIANIZE_INT32(bps);
fwrite(&temp32, 1, 4, wav->file);
/* write the block align */
align = 2 * channels;
temp16 = intel_short(align);
temp16 = LITTLE_ENDIANIZE_INT16(align);
fwrite(&temp16, 1, 2, wav->file);
/* write the bits/sample */
temp16 = intel_short(16);
temp16 = LITTLE_ENDIANIZE_INT16(16);
fwrite(&temp16, 1, 2, wav->file);
/* write the 'data' tag */
@ -101,13 +94,13 @@ void wav_close(wav_file *wav)
/* update the total file size */
fseek(wav->file, wav->total_offs, SEEK_SET);
temp32 = total - (wav->total_offs + 4);
temp32 = intel_long(temp32);
temp32 = LITTLE_ENDIANIZE_INT32(temp32);
fwrite(&temp32, 1, 4, wav->file);
/* update the data size */
fseek(wav->file, wav->data_offs, SEEK_SET);
temp32 = total - (wav->data_offs + 4);
temp32 = intel_long(temp32);
temp32 = LITTLE_ENDIANIZE_INT32(temp32);
fwrite(&temp32, 1, 4, wav->file);
fclose(wav->file);

View File

@ -569,11 +569,7 @@ state_save_error state_save_write_file(running_machine *machine, mame_file *file
/* generate the header */
memcpy(&header[0], ss_magic_num, 8);
header[8] = SAVE_VERSION;
#ifdef LSB_FIRST
header[9] = 0;
#else
header[9] = SS_MSB_FIRST;
#endif
header[9] = NATIVE_ENDIAN_VALUE_LE_BE(0, SS_MSB_FIRST);
strncpy((char *)&header[0x0a], machine->gamedrv->name, 0x1c - 0x0a);
*(UINT32 *)&header[0x1c] = LITTLE_ENDIANIZE_INT32(signature);
@ -629,11 +625,7 @@ state_save_error state_save_read_file(running_machine *machine, mame_file *file)
return STATERR_INVALID_HEADER;
/* determine whether or not to flip the data when done */
#ifdef LSB_FIRST
flip = ((header[9] & SS_MSB_FIRST) != 0);
#else
flip = ((header[9] & SS_MSB_FIRST) == 0);
#endif
flip = NATIVE_ENDIAN_VALUE_LE_BE((header[9] & SS_MSB_FIRST) != 0, (header[9] & SS_MSB_FIRST) == 0);
/* read all the data, flipping if necessary */
for (entry = global->entrylist; entry != NULL; entry = entry->next)

View File

@ -330,11 +330,7 @@ Notes:
#define LOAD_CD_CONTENT 1
#define DEBUG_PRINTF 0
#ifdef LSB_FIRST
#define DMA_XOR(a) ((a) ^ 1)
#else
#define DMA_XOR(a) ((a) ^ 2)
#endif
#define DMA_XOR(a) ((a) ^ NATIVE_ENDIAN_VALUE_LE_BE(1,2))
static UINT32* decrypted_bios;

View File

@ -501,13 +501,6 @@ ADDRESS_MAP_END
/* Z80 Sound Hardware - based on MESS code, to be improved, it can do some strange things */
#ifdef LSB_FIRST
#define BYTE_XOR(a) ((a) ^ 1)
#else
#define BYTE_XOR(a) (a)
#endif
static WRITE8_HANDLER ( genesis_bank_select_w ) /* note value will be meaningless unless all bits are correctly set in */
{
@ -613,9 +606,9 @@ READ8_HANDLER ( genesis_z80_bank_r )
logerror("z80 read from address %x\n", address);
/* Read the data out of the 68k ROM */
if (base != NULL && address < 0x400000) return base[BYTE_XOR(address)];
if (base != NULL && address < 0x400000) return base[BYTE_XOR_BE(address)];
/* else read the data out of the 68k RAM */
// else if (address > 0xff0000) return genesis_68k_ram[BYTE_XOR(offset)];
// else if (address > 0xff0000) return genesis_68k_ram[BYTE_XOR_BE(offset)];
return -1;
}

View File

@ -1909,11 +1909,7 @@ INPUT_PORTS_END
/******************************************************************************/
#ifdef LSB_FIRST
#define XOR(x) ((x)^8)
#else
#define XOR(x) (x)
#endif
#define XOR(x) ((x)^NATIVE_ENDIAN_VALUE_LE_BE(8,0))
static const gfx_layout charlayout =
{

View File

@ -15,7 +15,6 @@ extern UINT8 *cvs_color_ram;
extern UINT8 *cvs_video_ram;
extern UINT8 *cvs_bullet_ram;
extern UINT8 *cvs_palette_ram;
extern UINT8 *cvs_character_ram;
extern UINT8 *cvs_s2636_0_ram;
extern UINT8 *cvs_s2636_1_ram;
extern UINT8 *cvs_s2636_2_ram;

View File

@ -605,13 +605,10 @@ static void deco_decrypt(running_machine *machine,const char *rgntag,const UINT8
UINT16 *buffer = malloc_or_die(len*2);
int i;
#ifdef LSB_FIRST
/* we work on 16-bit words but data is loaded as 8-bit, so swap bytes on LSB machines */
for (i = 0;i < len;i++)
{
rom[i] = (rom[i] >> 8) | (rom[i] << 8);
}
#endif
if (ENDIANNESS_NATIVE == ENDIANNESS_LITTLE)
for (i = 0;i < len;i++)
rom[i] = BIG_ENDIANIZE_INT16(rom[i]);
memcpy(buffer,rom,len*2);
@ -644,13 +641,10 @@ static void deco_decrypt(running_machine *machine,const char *rgntag,const UINT8
free(buffer);
#ifdef LSB_FIRST
/* we work on 16-bit words but data is loaded as 8-bit, so swap bytes on LSB machines */
for (i = 0;i < len;i++)
{
rom[i] = (rom[i] >> 8) | (rom[i] << 8);
}
#endif
if (ENDIANNESS_NATIVE == ENDIANNESS_LITTLE)
for (i = 0;i < len;i++)
rom[i] = BIG_ENDIANIZE_INT16(rom[i]);
}
void deco56_decrypt_gfx(running_machine *machine, const char *tag)

View File

@ -7,14 +7,6 @@
#include "includes/n64.h"
#include "sound/dmadac.h"
#ifdef LSB_FIRST
#define BYTE_ADDR_XOR 3
#define WORD_ADDR_XOR 1
#else
#define BYTE_ADDR_XOR 0
#define WORD_ADDR_XOR 0
#endif
UINT32 *rdram;
UINT32 *rsp_imem;
UINT32 *rsp_dmem;

View File

@ -10,12 +10,6 @@
#include "includes/atari.h"
#include "video/gtia.h"
#ifdef LSB_FIRST
#define BYTE_XOR(n) (n)
#else
#define BYTE_XOR(n) ((n)^1)
#endif
#define VERBOSE 0
#define LOG(x) do { if (VERBOSE) logerror x; } while (0)
@ -990,16 +984,16 @@ static void antic_linerefresh(running_machine *machine)
if ( (antic.cmd & ANTIC_HSCR) == 0 || (antic.pfwidth == 48) || (antic.pfwidth == 32))
{
/* no hscroll */
dst[3] = antic.color_lookup[src[BYTE_XOR(0)]] | antic.color_lookup[src[BYTE_XOR(1)]] << 16;
dst[3] = antic.color_lookup[src[BYTE_XOR_LE(0)]] | antic.color_lookup[src[BYTE_XOR_LE(1)]] << 16;
src += 2;
dst += 4;
for( x = 1; x < HCHARS-1; x++ )
{
*dst++ = antic.color_lookup[src[BYTE_XOR(0)]] | antic.color_lookup[src[BYTE_XOR(1)]] << 16;
*dst++ = antic.color_lookup[src[BYTE_XOR(2)]] | antic.color_lookup[src[BYTE_XOR(3)]] << 16;
*dst++ = antic.color_lookup[src[BYTE_XOR_LE(0)]] | antic.color_lookup[src[BYTE_XOR_LE(1)]] << 16;
*dst++ = antic.color_lookup[src[BYTE_XOR_LE(2)]] | antic.color_lookup[src[BYTE_XOR_LE(3)]] << 16;
src += 4;
}
dst[0] = antic.color_lookup[src[BYTE_XOR(0)]] | antic.color_lookup[src[BYTE_XOR(1)]] << 16;
dst[0] = antic.color_lookup[src[BYTE_XOR_LE(0)]] | antic.color_lookup[src[BYTE_XOR_LE(1)]] << 16;
}
else
{
@ -1032,9 +1026,9 @@ static void antic_linerefresh(running_machine *machine)
}
else
{
*dst++ = antic.color_lookup[src[BYTE_XOR(0)]] | antic.color_lookup[src[BYTE_XOR(1)]] << 16;
*dst++ = antic.color_lookup[src[BYTE_XOR_LE(0)]] | antic.color_lookup[src[BYTE_XOR_LE(1)]] << 16;
}
*dst++ = antic.color_lookup[src[BYTE_XOR(2)]] | antic.color_lookup[src[BYTE_XOR(3)]] << 16;
*dst++ = antic.color_lookup[src[BYTE_XOR_LE(2)]] | antic.color_lookup[src[BYTE_XOR_LE(3)]] << 16;
src += 4;
}
for ( ; x < HCHARS-1; x++ )

View File

@ -36,11 +36,7 @@ static const device_config *genesis_screen;
#define VDP_VRAM_WORD(x) ((VDP_VRAM_BYTE(x) << 8) | VDP_VRAM_BYTE((x) + 1))
#define VDP_VSRAM_WORD(x) ((VDP_VSRAM_BYTE(x) << 8) | VDP_VSRAM_BYTE((x) + 1))
#ifdef LSB_FIRST
#define EXTRACT_PIXEL(x,i) (((x) >> (((i) ^ 1) * 4)) & 0x0f)
#else
#define EXTRACT_PIXEL(x,i) (((x) >> (((i) ^ 7) * 4)) & 0x0f)
#endif
#define EXTRACT_PIXEL(x,i) (((x) >> (((i) ^ NATIVE_ENDIAN_VALUE_LE_BE(1,7)) * 4)) & 0x0f)

View File

@ -18,11 +18,8 @@
#define DISPLAY_SPEEDUPS 0
#ifdef LSB_FIRST
#define MASK(n) (0x000000ffUL << ((n) * 8))
#else
#define MASK(n) (0xff000000UL >> (((n) ^ 1) * 8))
#endif
#define MASK(n) NATIVE_ENDIAN_VALUE_LE_BE(0x000000ffUL << ((n) * 8), 0xff000000UL >> (((n) ^ 1) * 8))
/*************************************

View File

@ -35,10 +35,8 @@ static void tilemap_get_info(
int tilemap_color,
int use_4bpp_gfx )
{
#ifdef LSB_FIRST
UINT16 *source;
static UINT8 mask_data[8];
#endif
int data = tilemap_videoram[tile_index];
int tile = data&0xfff;
@ -62,20 +60,21 @@ static void tilemap_get_info(
else
{
SET_TILE_INFO( gfx,tile,tilemap_color,0 );
#ifdef LSB_FIRST
source = shaperam+4*tile;
mask_data[0] = source[0]>>8;
mask_data[1] = source[0]&0xff;
mask_data[2] = source[1]>>8;
mask_data[3] = source[1]&0xff;
mask_data[4] = source[2]>>8;
mask_data[5] = source[2]&0xff;
mask_data[6] = source[3]>>8;
mask_data[7] = source[3]&0xff;
tileinfo->mask_data = mask_data;
#else
tileinfo->mask_data = (UINT8 *)(shaperam+4*tile);
#endif
if (ENDIANNESS_NATIVE == ENDIANNESS_BIG)
tileinfo->mask_data = (UINT8 *)(shaperam+4*tile);
else
{
source = shaperam+4*tile;
mask_data[0] = source[0]>>8;
mask_data[1] = source[0]&0xff;
mask_data[2] = source[1]>>8;
mask_data[3] = source[1]&0xff;
mask_data[4] = source[2]>>8;
mask_data[5] = source[2]&0xff;
mask_data[6] = source[3]>>8;
mask_data[7] = source[3]&0xff;
tileinfo->mask_data = mask_data;
}
}
} /* tilemap_get_info */
@ -105,21 +104,22 @@ static TILE_GET_INFO( roz_get_info )
}
else
{
#ifdef LSB_FIRST
UINT16 *source;
static UINT8 mask_data[8];
source = shaperam+4*tile;
mask_data[0] = source[0]>>8;
mask_data[1] = source[0]&0xff;
mask_data[2] = source[1]>>8;
mask_data[3] = source[1]&0xff;
mask_data[4] = source[2]>>8;
mask_data[5] = source[2]&0xff;
mask_data[6] = source[3]>>8;
mask_data[7] = source[3]&0xff;
#else
UINT8 *mask_data = (UINT8 *)(shaperam+4*tile);
#endif
if (ENDIANNESS_NATIVE == ENDIANNESS_LITTLE)
{
UINT16 *source = (UINT16 *)mask_data;
static UINT8 conv_data[9];
conv_data[0] = source[0]>>8;
conv_data[1] = source[0]&0xff;
conv_data[2] = source[1]>>8;
conv_data[3] = source[1]&0xff;
conv_data[4] = source[2]>>8;
conv_data[5] = source[2]&0xff;
conv_data[6] = source[3]>>8;
conv_data[7] = source[3]&0xff;
mask_data = conv_data;
}
SET_TILE_INFO( gfx,tile,tilemap_color,0 );
tileinfo->mask_data = mask_data;
}

View File

@ -612,11 +612,7 @@ ApplyGamma( running_machine *machine, bitmap_t *bitmap )
int x,y;
if( mbSuperSystem22 )
{ /* super system 22 */
#ifdef LSB_FIRST
#define XORPAT 0x3
#else
#define XORPAT 0x0
#endif
#define XORPAT NATIVE_ENDIAN_VALUE_LE_BE(3,0)
const UINT8 *rlut = (const UINT8 *)&namcos22_gamma[0x100/4];
const UINT8 *glut = (const UINT8 *)&namcos22_gamma[0x200/4];
const UINT8 *blut = (const UINT8 *)&namcos22_gamma[0x300/4];

View File

@ -189,11 +189,7 @@
*
*************************************/
#ifdef LSB_FIRST
#define SWAP_HALVES(x) (x)
#else
#define SWAP_HALVES(x) (((x) >> 16) | ((x) << 16))
#endif
#define SWAP_HALVES(x) NATIVE_ENDIAN_VALUE_LE_BE(x, ((x) >> 16) | ((x) << 16))

View File

@ -937,15 +937,9 @@ INLINE void f3_alpha_set_level(void)
/*============================================================================*/
#ifdef LSB_FIRST
#define COLOR1 0
#define COLOR2 1
#define COLOR3 2
#else
#define COLOR1 3
#define COLOR2 2
#define COLOR3 1
#endif
#define COLOR1 BYTE4_XOR_LE(0)
#define COLOR2 BYTE4_XOR_LE(1)
#define COLOR3 BYTE4_XOR_LE(2)