HoverRace  2.0
FastMemManip.h
Go to the documentation of this file.
1 
2 // FastMemManip.h
3 //
4 // Copyright (c) 1995-1998 - Richard Langlois and Grokksoft Inc.
5 //
6 // Licensed under GrokkSoft HoverRace SourceCode License v1.0(the "License");
7 // you may not use this file except in compliance with the License.
8 //
9 // A copy of the license should have been attached to the package from which
10 // you have taken this file. If you can not find the license you can not use
11 // this file.
12 //
13 //
14 // The author makes no representations about the suitability of
15 // this software for any purpose. It is provided "as is" "AS IS",
16 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
17 // implied.
18 //
19 // See the License for the specific language governing permissions
20 // and limitations under the License.
21 //
22 
23 #pragma once
24 
25 #include "MR_Types.h"
26 
27 inline void MR_Mem32Set(MR_UInt32 * pDest, MR_UInt32 pValue, int pCount)
28 {
29  for(int lCounter = 0; lCounter < pCount; lCounter++) {
30  pDest[lCounter] = pValue;
31  }
32 }
33 
34 inline void MR_SmallMem16Set(MR_UInt16 * pDest, MR_UInt16 pValue, int pCount)
35 {
36  for(int lCounter = 0; lCounter < pCount; lCounter++) {
37  pDest[lCounter] = pValue;
38  }
39 }
40 
41 inline void MR_LargeMem16Set(MR_UInt16 * pDest, MR_UInt16 pValue, int pCount)
42 {
43 #if defined(_WIN32) && !defined(_WIN64)
44  if(pCount > 0) {
45  MR_UInt32 lValue = pValue | (pValue << 16);
46  MR_UInt32 *lDest = (MR_UInt32 *) (((int) pDest) & ~1);
47 
48  pDest[pCount - 1] = pValue;
49 
50  if((int) pDest & 1) {
51  *pDest = pValue;
52  pCount--;
53  }
54 
55  for(int lCounter = 0; lCounter < pCount / 2; lCounter++) {
56  lDest[lCounter] = lValue;
57  }
58  }
59 #else
60  MR_SmallMem16Set(pDest, pValue, pCount);
61 #endif
62 }
uint16_t MR_UInt16
Definition: MR_Types.h:42
void MR_Mem32Set(MR_UInt32 *pDest, MR_UInt32 pValue, int pCount)
Definition: FastMemManip.h:27
void MR_SmallMem16Set(MR_UInt16 *pDest, MR_UInt16 pValue, int pCount)
Definition: FastMemManip.h:34
void MR_LargeMem16Set(MR_UInt16 *pDest, MR_UInt16 pValue, int pCount)
Definition: FastMemManip.h:41
uint32_t MR_UInt32
Definition: MR_Types.h:44