--- /dev/null
+#ifndef COMMON_ENDIANNESS_H_INCLUDED
+#define COMMON_ENDIANNESS_H_INCLUDED
+
+#include <stdint.h>
+
+#define SWAP_VAR(a, b) do { unsigned char t = a; a = b; b = t; } while(0)
+
+static inline int16_t short2swap (int16_t x) {
+ union {
+ uint8_t a[2];
+ int16_t x;
+ } y;
+ y.x = x;
+ SWAP_VAR(y.a[0], y.a[1]);
+ return y.x;
+}
+
+static inline int32_t int2swap (int32_t x) {
+ union {
+ uint8_t a[4];
+ int32_t x;
+ } y;
+ y.x = x;
+ SWAP_VAR(y.a[0], y.a[3]);
+ SWAP_VAR(y.a[1], y.a[2]);
+ return y.x;
+}
+
+#undef SWAP_VAR
+
+static inline int16_t short2host (int16_t x) {
+#if __BIG_ENDIAN__
+ return short2swap(x);
+#else
+ return x;
+#endif
+}
+
+static inline int32_t int2host (int32_t x) {
+#if __BIG_ENDIAN__
+ return int2swap(x);
+#else
+ return x;
+#endif
+}
+
+#endif /* COMMON_ENDIANNESS_H_INCLUDED */
\ No newline at end of file
-#include "streams.h"
+#include "common/streams.h"
+#include "common/endianness.h"
#include <stddef.h>
#include <stdint.h>
-#include "misc.h" // endianness conversion
-
void stream_read (void *data, size_t size, size_t n, Reader *r) {
r->read(r, data, size, n);
}
#include "switch.h" // sw_secrets
#include "cp866.h"
+#include "common/endianness.h"
#ifdef __APPLE__
# include <OpenGL/gl.h>
void Z_splash (obj_t *p, int n);
void Z_calc_time(dword t, word *h, word *m, word *s);
-int16_t short2host (int16_t x);
-int32_t int2host (int32_t x);
-
#endif /* MISC_H_INCLUDED */
t = t / 60;
*h = t;
}
-
-#define SWAP_VAR(a, b) do { unsigned char t = a; a = b; b = t; } while(0)
-
-static int16_t short2swap (int16_t x) {
- union {
- uint8_t a[2];
- int16_t x;
- } y;
- y.x = x;
- SWAP_VAR(y.a[0], y.a[1]);
- return y.x;
-}
-
-static int32_t int2swap (int32_t x) {
- union {
- uint8_t a[4];
- int32_t x;
- } y;
- y.x = x;
- SWAP_VAR(y.a[0], y.a[3]);
- SWAP_VAR(y.a[1], y.a[2]);
- return y.x;
-}
-
-#undef SWAP_VAR
-
-int16_t short2host (int16_t x) {
-#if __BIG_ENDIAN__
- return short2swap(x);
-#else
- return x;
-#endif
-}
-
-int32_t int2host (int32_t x) {
-#if __BIG_ENDIAN__
- return int2swap(x);
-#else
- return x;
-#endif
-}
#include "glob.h"
#include "error.h"
-#include "misc.h"
+#include "common/endianness.h"
+
#include <stdio.h>
#include <stdint.h>
#include <assert.h>
#include "files.h" // F_findres F_getreslen
#include "memory.h" // M_lock M_unlock
-#include "misc.h" // int2host
#include "error.h" // logo
+#include "common/endianness.h"
+
#ifdef __APPLE__
# include <OpenAL/al.h>
# include <OpenAL/alc.h>
#include "glob.h"
#include "sound.h"
#include "music.h"
-#include "misc.h" // int2host
#include "memory.h" // M_lock M_unlock
#include "files.h" // F_findres
#include "error.h"
+#include "common/endianness.h"
+
#include "SDL.h"
#include "SDL_mixer.h"
#include <assert.h>
#include "files.h"
#include "system.h"
+#include "common/endianness.h"
+
#include <string.h>
#include <assert.h>