1 /*--------------------------------------------------------------------------*
2 Project: Revolution Audio sound file converter
3 File: endian.c
4
5 Copyright (C)2001-2006 Nintendo All Rights Reserved.
6
7 These coded instructions, statements, and computer programs contain
8 proprietary information of Nintendo of America Inc. and/or Nintendo
9 Company Ltd., and are protected by Federal copyright law. They may
10 not be disclosed to third parties or copied or duplicated in any form,
11 in whole or in part, without the prior written consent of Nintendo.
12
13 $Log: endian.c,v $
14 Revision 1.2 02/09/2006 06:26:26 aka
15 Changed copyright.
16
17
18 *--------------------------------------------------------------------------*/
19 #include "types.h"
20
21 /*--------------------------------------------------------------------------*/
reverse_endian_16(u16 data)22 u16 reverse_endian_16(u16 data)
23 {
24 return (u16)(((data & 0x00FF) << 8) | ((data & 0xFF00) >> 8));
25 }
26
27 /*--------------------------------------------------------------------------*/
reverse_endian_32(u32 x)28 u32 reverse_endian_32(u32 x)
29 {
30 return(
31 ((x >> 24) & 0x000000ff) |
32 ((x >> 8) & 0x0000ff00) |
33 ((x << 8) & 0x00ff0000) |
34 ((x << 24) & 0xff000000)
35 );
36 }
37
38
39 /*--------------------------------------------------------------------------*/
reverse_buffer_16(u16 * p,int samples)40 void reverse_buffer_16(u16 *p, int samples)
41 {
42 u16 *data;
43 int count;
44
45 data = p;
46 count = samples;
47
48 while (samples)
49 {
50 *data = reverse_endian_16(*data);
51
52 data++;
53 samples--;
54 }
55 }
56