Wing Commander II
Reconstructed Win32 source (1996)
Loading...
Searching...
No Matches
hugemove.c
Go to the documentation of this file.
1/*
2 * Overlap-safe huge memory copy.
3 *
4 * Retail object 0x419A40-0x419C0F (link order; see docs/ORDER.md).
5 */
6#include "game.h"
7
8/* Function start: 0x419A40 */
9void CopyHugeMemoryOverlapSafe(void *destination, void *source, int count)
10{
11 if (count == 0)
12 return;
13 if (DosFarPtrToNear(source) < DosFarPtrToNear(destination)) {
14 destination = DosNearPtrToFar(DosFarPtrToNear(destination) + count);
15 source = DosNearPtrToFar(DosFarPtrToNear(source) + count);
16 for (;;) {
17 if ((count -= 0xffff) > -1) {
18 source = DosNearPtrToFar(DosFarPtrToNear(source) - 0xffff);
19 destination = DosNearPtrToFar(
20 DosFarPtrToNear(destination) - 0xffff);
21 DosMemmove(destination, source, 0xffff);
22 } else
23 break;
24 }
25 count += 0xffff;
26 source = DosNearPtrToFar(DosFarPtrToNear(source) - count);
27 destination = DosNearPtrToFar(DosFarPtrToNear(destination) - count);
28 DosMemmove(destination, source, (unsigned int)count);
29 } else {
30 for (;;) {
31 if ((count -= 0xffff) > -1) {
32 DosMemmove(destination, source, 0xffff);
33 source = DosNearPtrToFar(DosFarPtrToNear(source) + 0xffff);
34 destination = DosNearPtrToFar(
35 DosFarPtrToNear(destination) + 0xffff);
36 } else
37 break;
38 }
39 count += 0xffff;
40 DosMemmove(destination, source, (unsigned int)count);
41 }
42}
unsigned int DosFarPtrToNear(void *v)
Definition eventmgr.c:441
void DosMemmove(void *dst, const void *src, unsigned short n)
void * DosNearPtrToFar(unsigned int v)
Definition eventmgr.c:447
void CopyHugeMemoryOverlapSafe(void *destination, void *source, int count)
Definition hugemove.c:9
Shared Win32 declarations, types and library interfaces.