CnC_Remastered_Collection

Command and Conquer: Red Alert
Log | Files | Refs | README | LICENSE

DPMI.CPP (5234B)


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