summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authortwinaphex2015-11-10 04:30:51 +0100
committertwinaphex2015-11-10 04:30:51 +0100
commit741516b02c03c7af9fe2ec303edf0ccaccfd39a8 (patch)
tree99bc8929fa5340664e042fbcfb19b7d6d61f008c /src
parentbed2a54f68865abcd6630b5514dce9ba06d9e4b0 (diff)
downloadsnes9x2002-741516b02c03c7af9fe2ec303edf0ccaccfd39a8.tar.gz
snes9x2002-741516b02c03c7af9fe2ec303edf0ccaccfd39a8.tar.bz2
snes9x2002-741516b02c03c7af9fe2ec303edf0ccaccfd39a8.zip
Use MSB_FIRST
Diffstat (limited to 'src')
-rw-r--r--src/65c816.h6
-rw-r--r--src/gfx.c68
-rw-r--r--src/gfx.h14
-rw-r--r--src/gfx16.c70
-rw-r--r--src/globals.c12
-rw-r--r--src/port.h2
-rw-r--r--src/snaporig.h12
-rw-r--r--src/spc700.h6
-rw-r--r--src/srtc.c12
9 files changed, 99 insertions, 103 deletions
diff --git a/src/65c816.h b/src/65c816.h
index f1e21f5..fe040c6 100644
--- a/src/65c816.h
+++ b/src/65c816.h
@@ -99,15 +99,15 @@
typedef union
{
-#ifdef LSB_FIRST
+#ifdef MSB_FIRST
struct
{
- uint8 l, h;
+ uint8 h, l;
} PACKING B;
#else
struct
{
- uint8 h, l;
+ uint8 l, h;
} PACKING B;
#endif
uint16 W;
diff --git a/src/gfx.c b/src/gfx.c
index b37dd24..5f27b25 100644
--- a/src/gfx.c
+++ b/src/gfx.c
@@ -259,24 +259,7 @@ bool8_32 S9xGraphicsInit()
register uint32 h = 0;
register uint32 l = 0;
-#if defined(LSB_FIRST)
- if (i & 8)
- h |= PixelOdd;
- if (i & 4)
- h |= PixelOdd << 8;
- if (i & 2)
- h |= PixelOdd << 16;
- if (i & 1)
- h |= PixelOdd << 24;
- if (i & 8)
- l |= PixelOdd;
- if (i & 4)
- l |= PixelOdd << 8;
- if (i & 2)
- l |= PixelOdd << 16;
- if (i & 1)
- l |= PixelOdd << 24;
-#else
+#if defined(MSB_FIRST)
if (i & 8)
h |= (PixelOdd << 24);
if (i & 4)
@@ -293,30 +276,30 @@ bool8_32 S9xGraphicsInit()
l |= (PixelOdd << 8);
if (i & 1)
l |= PixelOdd;
-#endif
-
- odd_high[bitshift][i] = h;
- odd_low[bitshift][i] = l;
- h = l = 0;
-
-#if defined(LSB_FIRST)
+#else
if (i & 8)
- h |= PixelEven;
+ h |= PixelOdd;
if (i & 4)
- h |= PixelEven << 8;
+ h |= PixelOdd << 8;
if (i & 2)
- h |= PixelEven << 16;
+ h |= PixelOdd << 16;
if (i & 1)
- h |= PixelEven << 24;
+ h |= PixelOdd << 24;
if (i & 8)
- l |= PixelEven;
+ l |= PixelOdd;
if (i & 4)
- l |= PixelEven << 8;
+ l |= PixelOdd << 8;
if (i & 2)
- l |= PixelEven << 16;
+ l |= PixelOdd << 16;
if (i & 1)
- l |= PixelEven << 24;
-#else
+ l |= PixelOdd << 24;
+#endif
+
+ odd_high[bitshift][i] = h;
+ odd_low[bitshift][i] = l;
+ h = l = 0;
+
+#if defined(MSB_FIRST)
if (i & 8)
h |= (PixelEven << 24);
if (i & 4)
@@ -333,6 +316,23 @@ bool8_32 S9xGraphicsInit()
l |= (PixelEven << 8);
if (i & 1)
l |= PixelEven;
+#else
+ if (i & 8)
+ h |= PixelEven;
+ if (i & 4)
+ h |= PixelEven << 8;
+ if (i & 2)
+ h |= PixelEven << 16;
+ if (i & 1)
+ h |= PixelEven << 24;
+ if (i & 8)
+ l |= PixelEven;
+ if (i & 4)
+ l |= PixelEven << 8;
+ if (i & 2)
+ l |= PixelEven << 16;
+ if (i & 1)
+ l |= PixelEven << 24;
#endif
even_high[bitshift][i] = h;
diff --git a/src/gfx.h b/src/gfx.h
index e9ec04a..ff197cf 100644
--- a/src/gfx.h
+++ b/src/gfx.h
@@ -183,18 +183,16 @@ extern uint8 mul_brightness [16][32];
#define READ_2BYTES(s) (*(uint16 *) (s))
#define WRITE_2BYTES(s, d) *(uint16 *) (s) = (d)
#else
-#ifdef LSB_FIRST
-#define READ_2BYTES(s) (*(uint16 *) (s))
-#define WRITE_2BYTES(s, d) *(uint16 *) (s) = (d)
-//#define READ_2BYTES(s) (*(uint8 *) (s) | (*((uint8 *) (s) + 1) << 8))
-//#define WRITE_2BYTES(s, d) *(uint8 *) (s) = (d), \
-// *((uint8 *) (s) + 1) = (d) >> 8
-#else // else MSB_FISRT
+#ifdef MSB_FIRST
#define READ_2BYTES(s) (*(uint8 *) (s) | (*((uint8 *) (s) + 1) << 8))
#define WRITE_2BYTES(s, d) *(uint8 *) (s) = (d), \
*((uint8 *) (s) + 1) = (d) >> 8
-#endif // LSB_FIRST
+#else
+#define READ_2BYTES(s) (*(uint16 *) (s))
+#define WRITE_2BYTES(s, d) *(uint16 *) (s) = (d)
+#endif
+
#endif // i386
#define SUB_SCREEN_DEPTH 0
diff --git a/src/gfx16.c b/src/gfx16.c
index 3bea6c6..63c5c2d 100644
--- a/src/gfx16.c
+++ b/src/gfx16.c
@@ -263,25 +263,7 @@ bool8_32 S9xGraphicsInit()
register uint32 h = 0;
register uint32 l = 0;
-#if defined(LSB_FIRST)
- // Wiz usa LSB_FIRST
- if (i & 8)
- h |= PixelOdd;
- if (i & 4)
- h |= PixelOdd << 8;
- if (i & 2)
- h |= PixelOdd << 16;
- if (i & 1)
- h |= PixelOdd << 24;
- if (i & 8)
- l |= PixelOdd;
- if (i & 4)
- l |= PixelOdd << 8;
- if (i & 2)
- l |= PixelOdd << 16;
- if (i & 1)
- l |= PixelOdd << 24;
-#else
+#if defined(MSB_FIRST)
if (i & 8)
h |= (PixelOdd << 24);
if (i & 4)
@@ -298,30 +280,31 @@ bool8_32 S9xGraphicsInit()
l |= (PixelOdd << 8);
if (i & 1)
l |= PixelOdd;
-#endif
-
- odd_high[bitshift][i] = h;
- odd_low[bitshift][i] = l;
- h = l = 0;
-
-#if defined(LSB_FIRST)
+#else
+ // Wiz usa
if (i & 8)
- h |= PixelEven;
+ h |= PixelOdd;
if (i & 4)
- h |= PixelEven << 8;
+ h |= PixelOdd << 8;
if (i & 2)
- h |= PixelEven << 16;
+ h |= PixelOdd << 16;
if (i & 1)
- h |= PixelEven << 24;
+ h |= PixelOdd << 24;
if (i & 8)
- l |= PixelEven;
+ l |= PixelOdd;
if (i & 4)
- l |= PixelEven << 8;
+ l |= PixelOdd << 8;
if (i & 2)
- l |= PixelEven << 16;
+ l |= PixelOdd << 16;
if (i & 1)
- l |= PixelEven << 24;
-#else
+ l |= PixelOdd << 24;
+#endif
+
+ odd_high[bitshift][i] = h;
+ odd_low[bitshift][i] = l;
+ h = l = 0;
+
+#if defined(MSB_FIRST)
if (i & 8)
h |= (PixelEven << 24);
if (i & 4)
@@ -338,6 +321,23 @@ bool8_32 S9xGraphicsInit()
l |= (PixelEven << 8);
if (i & 1)
l |= PixelEven;
+#else
+ if (i & 8)
+ h |= PixelEven;
+ if (i & 4)
+ h |= PixelEven << 8;
+ if (i & 2)
+ h |= PixelEven << 16;
+ if (i & 1)
+ h |= PixelEven << 24;
+ if (i & 8)
+ l |= PixelEven;
+ if (i & 4)
+ l |= PixelEven << 8;
+ if (i & 2)
+ l |= PixelEven << 16;
+ if (i & 1)
+ l |= PixelEven << 24;
#endif
even_high[bitshift][i] = h;
diff --git a/src/globals.c b/src/globals.c
index a433fa4..5edbe14 100644
--- a/src/globals.c
+++ b/src/globals.c
@@ -268,19 +268,19 @@ int NoiseFreq [32] =
uint32 HeadMask [4] =
{
-#ifdef LSB_FIRST
- 0xffffffff, 0xffffff00, 0xffff0000, 0xff000000
-#else
+#ifdef MSB_FIRST
0xffffffff, 0x00ffffff, 0x0000ffff, 0x000000ff
+#else
+ 0xffffffff, 0xffffff00, 0xffff0000, 0xff000000
#endif
};
uint32 TailMask [5] =
{
-#ifdef LSB_FIRST
- 0x00000000, 0x000000ff, 0x0000ffff, 0x00ffffff, 0xffffffff
-#else
+#ifdef MSB_FIRST
0x00000000, 0xff000000, 0xffff0000, 0xffffff00, 0xffffffff
+#else
+ 0x00000000, 0x000000ff, 0x0000ffff, 0x00ffffff, 0xffffffff
#endif
};
diff --git a/src/port.h b/src/port.h
index 0c48da6..b203d8d 100644
--- a/src/port.h
+++ b/src/port.h
@@ -122,7 +122,6 @@ typedef short int16_32;
//Misc Items
#define VAR_CYCLES
//#define SPC700_SHUTDOWN
-#define LSB_FIRST
#define STATIC static
#define FASTCALL
#define PIXEL_FORMAT RGB565
@@ -133,7 +132,6 @@ typedef short int16_32;
#define ZeroMemory(a,b) memset((a),0,(b))
#define PACKING __attribute__ ((packed))
#define ALIGN_BY_ONE __attribute__ ((aligned (1), packed))
-#define LSB_FIRST
#undef FAST_LSB_WORD_ACCESS
#define SUPER_FX
#ifdef ASMCPU
diff --git a/src/snaporig.h b/src/snaporig.h
index 13f1556..e8b77be 100644
--- a/src/snaporig.h
+++ b/src/snaporig.h
@@ -94,15 +94,15 @@ struct SOrigAPU
typedef union
{
-#ifdef LSB_FIRST
+#ifdef MSB_FIRST
struct
{
- uint8 A, Y;
+ uint8 Y, A;
} B;
#else
struct
{
- uint8 Y, A;
+ uint8 A, Y;
} B;
#endif
uint16 W;
@@ -320,15 +320,15 @@ struct SOrigDMA
typedef union
{
-#ifdef LSB_FIRST
+#ifdef MSB_FIRST
struct
{
- uint8 l, h;
+ uint8 h, l;
} B;
#else
struct
{
- uint8 h, l;
+ uint8 l, h;
} B;
#endif
uint16 W;
diff --git a/src/spc700.h b/src/spc700.h
index 9dd1180..805392c 100644
--- a/src/spc700.h
+++ b/src/spc700.h
@@ -86,15 +86,15 @@
typedef union
{
-#ifdef LSB_FIRST
+#ifdef MSB_FIRST
struct
{
- uint8 A, Y;
+ uint8 Y, A;
} B;
#else
struct
{
- uint8 Y, A;
+ uint8 A, Y;
} B;
#endif
uint16 W;
diff --git a/src/srtc.c b/src/srtc.c
index e9fa4ee..136599b 100644
--- a/src/srtc.c
+++ b/src/srtc.c
@@ -469,9 +469,7 @@ void S9xSRTCPreSaveState()
SRAM [s + 3 + MAX_RTC_INDEX] = rtc.index;
SRAM [s + 4 + MAX_RTC_INDEX] = rtc.mode;
-#ifdef LSB_FIRST
- memmove(&SRAM [s + 5 + MAX_RTC_INDEX], &rtc.system_timestamp, 8);
-#else
+#ifdef MSB_FIRST
SRAM [s + 5 + MAX_RTC_INDEX] = (uint8)(rtc.system_timestamp >> 0);
SRAM [s + 6 + MAX_RTC_INDEX] = (uint8)(rtc.system_timestamp >> 8);
SRAM [s + 7 + MAX_RTC_INDEX] = (uint8)(rtc.system_timestamp >> 16);
@@ -480,6 +478,8 @@ void S9xSRTCPreSaveState()
SRAM [s + 10 + MAX_RTC_INDEX] = (uint8)(rtc.system_timestamp >> 40);
SRAM [s + 11 + MAX_RTC_INDEX] = (uint8)(rtc.system_timestamp >> 48);
SRAM [s + 12 + MAX_RTC_INDEX] = (uint8)(rtc.system_timestamp >> 56);
+#else
+ memmove(&SRAM [s + 5 + MAX_RTC_INDEX], &rtc.system_timestamp, 8);
#endif
}
}
@@ -499,9 +499,7 @@ void S9xSRTCPostLoadState()
rtc.index = SRAM [s + 3 + MAX_RTC_INDEX];
rtc.mode = SRAM [s + 4 + MAX_RTC_INDEX];
-#ifdef LSB_FIRST
- memmove(&rtc.system_timestamp, &SRAM [s + 5 + MAX_RTC_INDEX], 8);
-#else
+#ifdef MSB_FIRST
rtc.system_timestamp |= (SRAM [s + 5 + MAX_RTC_INDEX] << 0);
rtc.system_timestamp |= (SRAM [s + 6 + MAX_RTC_INDEX] << 8);
rtc.system_timestamp |= (SRAM [s + 7 + MAX_RTC_INDEX] << 16);
@@ -510,6 +508,8 @@ void S9xSRTCPostLoadState()
rtc.system_timestamp |= (SRAM [s + 10 + MAX_RTC_INDEX] << 40);
rtc.system_timestamp |= (SRAM [s + 11 + MAX_RTC_INDEX] << 48);
rtc.system_timestamp |= (SRAM [s + 12 + MAX_RTC_INDEX] << 56);
+#else
+ memmove(&rtc.system_timestamp, &SRAM [s + 5 + MAX_RTC_INDEX], 8);
#endif
S9xUpdateSrtcTime();
}