diff options
author | Alexey Yakovenko <wakeroid@gmail.com> | 2009-07-28 15:36:22 +0200 |
---|---|---|
committer | Alexey Yakovenko <wakeroid@gmail.com> | 2009-07-28 15:36:22 +0200 |
commit | 6beba9ee559fe372fcd997835441bcf94e8d3502 (patch) | |
tree | beafa3ede81b00793248e5dd1d083113dda9785c | |
parent | 5ead039965dc3d58466f982ab3eb8680e69a269c (diff) |
added some preventive byteswapping for bigendian support in the future
-rw-r--r-- | common.h | 12 | ||||
-rw-r--r-- | csid.cpp | 17 | ||||
-rw-r--r-- | psdl.c | 3 |
3 files changed, 23 insertions, 9 deletions
@@ -4,4 +4,16 @@ #define min(x,y) ((x)<(y)?(x):(y)) #define max(x,y) ((x)>(y)?(x):(y)) +inline void +le_int16 (int16_t in, char *out) { + char *pin = (char *)∈ +#if !BIGENDIAN + out[0] = pin[0]; + out[1] = pin[1]; +#else + out[1] = pin[0]; + out[0] = pin[1]; +#endif +} + #endif // __COMMON_H @@ -211,17 +211,18 @@ csid_init (const char *fname, int track, float start, float end) { md5_t md5; md5_init (&md5); md5_process (&md5, (const char *)tune->cache.get () + tune->fileOffset, tune->getInfo ().c64dataLen); - uint16_t tmp; - tmp = tune->getInfo ().initAddr; - md5_process (&md5, &tmp, 2); - tmp = tune->getInfo ().playAddr; - md5_process (&md5, &tmp, 2); - tmp = tune->getInfo ().songs; - md5_process (&md5, &tmp, 2); + char tmp[2]; + le_int16 (tune->getInfo ().initAddr, tmp); + md5_process (&md5, tmp, 2); + le_int16 (tune->getInfo ().playAddr, tmp); + md5_process (&md5, tmp, 2); + le_int16 (tune->getInfo ().songs, tmp); + md5_process (&md5, tmp, 2); for (int s = 1; s <= tune->getInfo ().songs; s++) { tune->selectSong (s); - md5_process (&md5, &tune->getInfo ().songSpeed, sizeof (tune->getInfo ().songSpeed)); + // songspeed is uint8_t, so no need for byteswap + md5_process (&md5, &tune->getInfo ().songSpeed, 1); } if (tune->getInfo ().clockSpeed == SIDTUNE_CLOCK_NTSC) { md5_process (&md5, &tune->getInfo ().clockSpeed, sizeof (tune->getInfo ().clockSpeed)); @@ -1,6 +1,7 @@ #include <SDL/SDL.h> #include "psdl.h" #include "streamer.h" +#include "common.h" static int sdl_player_numsamples = 4096; int sdl_player_freq; @@ -88,7 +89,7 @@ psdl_callback (void* userdata, Uint8 *stream, int len) { int ivolume = sdl_volume * 1000; for (int i = 0; i < bytesread/2; i++) { int16_t sample = (int16_t)(((int32_t)(((int16_t*)stream)[i])) * ivolume / 1000); - ((int16_t*)stream)[i] = sample; + le_int16 (sample, (char*)&(((int16_t*)stream)[i])); } if (bytesread < len) { memset (stream + bytesread, 0, len-bytesread); |