This repository was archived by the owner on Feb 27, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 511
/
Copy pathDPMI.CPP
169 lines (147 loc) · 4.95 KB
/
DPMI.CPP
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
/*
** Command & Conquer(tm)
** Copyright 2025 Electronic Arts Inc.
**
** This program is free software: you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation, either version 3 of the License, or
** (at your option) any later version.
**
** This program is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/* $Header: F:\projects\c&c\vcs\code\dpmi.cpv 2.17 16 Oct 1995 16:49:36 JOE_BOSTIC $ */
/***********************************************************************************************
*** C O N F I D E N T I A L --- W E S T W O O D S T U D I O S ***
***********************************************************************************************
* *
* Project Name : Command & Conquer *
* *
* File Name : DPMI.CPP *
* *
* Programmer : Joe L. Bostic *
* *
* Start Date : July 2, 1994 *
* *
* Last Update : July 2, 1994 [JLB] *
* *
*---------------------------------------------------------------------------------------------*
* Functions: *
* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
#ifdef __FLAT__
#pragma inline
#endif
#include "function.h"
#include "dpmi.h"
#ifndef __FLAT__
void DOSSegmentClass::Swap(DOSSegmentClass &src, int soffset, DOSSegmentClass &dest, int doffset, int size)
{
if (!size) return;
unsigned short ssel = src.Selector;
unsigned short dsel = dest.Selector;
asm {
push es
push ds
mov si,soffset
mov di,doffset
mov cx,size
mov ax,ssel
mov dx,dsel
mov ds,ax
mov es,dx
}
again:
asm {
mov al,ds:[si]
mov ah,es:[di]
mov ds:[si],ah
mov es:[di],al
inc di
inc si
dec cx
jnz again
pop ds
pop es
}
}
#endif
void DOSSegmentClass::Swap(DOSSegmentClass &src, int soffset, DOSSegmentClass &dest, int doffset, int size)
{
extern void dss_swap(char *src, char *dest, int size);
#pragma aux dss_swap = \
"again: mov al,[esi]" \
"mov ah,[edi]" \
"mov [esi],ah" \
"stosb" \
"inc esi" \
"loop again" \
parm [esi] [edi] [ecx] \
modify [ax];
if (!size) return;
dss_swap((char *)(src.Selector + soffset), (char *)(dest.Selector + doffset), size);
}
#ifdef OBSOLETE
void DOSSegmentClass::Copy(DOSSegmentClass &src, int soffset, DOSSegmentClass &dest, int doffset, int size)
{
extern void dss_copy(char *src, char *dest, int size);
#pragma aux dss_copy = \
"mov ebx,ecx" \
"shr ecx,2" \
"jecxz copskip1" \
"rep movsd" \
"copskip1: mov ecx,ebx" \
"and ecx,3" \
"jecxz copskip2" \
"rep movsb" \
"copskip2:" \
parm [esi edi ecx] \
modify [ebx];
if (!size) return;
dss_copy((char *)(src.Selector + soffset), (char *)(dest.Selector + doffset), size);
}
#endif
#ifdef OBSOLETE
void DOSSegmentClass::Copy_To(void *source, int dest, int size)
{
extern void dss_copy_to(void *src, (void *)dest, int size);
#pragma aux dss_copy_to = \
"mov ebx,ecx" \
"shr ecx,2" \
"jecxz cop2skip1" \
"rep movsd" \
"cop2skip1: mov ecx,ebx" \
"and ecx,3" \
"jecxz cop2skip2" \
"rep movsb" \
"cop2skip2:" \
parm [esi edi ecx] \
modify [ebx];
if (!size) return;
dss_copy_to(src, (void *)(Selector + dest), size);
}
#endif
#ifdef OBSOLETE
void DOSSegmentClass::Copy_From(void *dest, int source, int size)
{
extern void dss_copy_from(void *dest, (void *)source, int size);
#pragma aux dss_copy_from = \
"mov ebx,ecx" \
"shr ecx,2" \
"jecxz copfskip1" \
"rep movsd" \
"copfskip1: mov ecx,ebx" \
"and ecx,3" \
"jecxz copfskip2" \
"rep movsb" \
"copfskip2:" \
parm [edi esi ecx] \
modify [ebx];
if (!size) return;
dss_copy_from(dest, (void *)(Selector + source), size);
}
#endif