CnC_Remastered_Collection

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

COORDA.h (7109B)


      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 /*
     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  I N C  **
     19 ;***************************************************************************
     20 ;*                                                                         *
     21 ;*                 Project Name : Command & Conquer                        *
     22 ;*                                                                         *
     23 ;*                    File Name : COORDA.ASM                               *
     24 ;*                                                                         *
     25 ;*                   Programmer : Barry W. Green                           *
     26 ;*                                                                         *
     27 ;*                   Start Date : February 17, 1995                        *
     28 ;*                                                                         *
     29 ;*                  Last Update : February 17, 1995  [BWG]                 *
     30 ;*                                                                         *
     31 ;*-------------------------------------------------------------------------*
     32 ;* Functions:                                                              *
     33 ;*   Cardinal_To_Fixed -- Converts cardinal numbers into a fixed point number.                 *
     34 ;* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - *
     35 */
     36 
     37 #ifndef COORD_A_H
     38 
     39 //IDEAL
     40 //P386
     41 //MODEL USE32 FLAT
     42 
     43 //global C	Cardinal_To_Fixed	:NEAR
     44 //global C	Fixed_To_Cardinal	:NEAR
     45 
     46 //	CODESEG
     47 /*
     48 ;***********************************************************************************************
     49 ;* Cardinal_To_Fixed -- Converts cardinal numbers into a fixed point number.                   *
     50 ;*                                                                                             *
     51 ;*    This utility function will convert cardinal numbers into a fixed point fraction. The     *
     52 ;*    use of fixed point numbers occurs throughout the product -- since it is a convenient     *
     53 ;*    tool. The fixed point number is based on the formula:                                    *
     54 ;*                                                                                             *
     55 ;*       result = cardinal / base                                                              *
     56 ;*                                                                                             *
     57 ;*    The accuracy of the fixed point number is limited to 1/256 as the lowest and up to       *
     58 ;*    256 as the largest.                                                                      *
     59 ;*                                                                                             *
     60 ;* INPUT:   base     -- The key number to base the fraction about.                             *
     61 ;*                                                                                             *
     62 ;*          cardinal -- The other number (hey -- what do you call it?)                         *
     63 ;*                                                                                             *
     64 ;* OUTPUT:  Returns with the fixed point number of the "cardinal" parameter as it relates      *
     65 ;*          to the "base" parameter.                                                           *
     66 ;*                                                                                             *
     67 ;* WARNINGS:   none                                                                            *
     68 ;*                                                                                             *
     69 ;* HISTORY:                                                                                    *
     70 ;*   02/17/1995 BWG : Created.                                                                 *
     71 ;*=============================================================================================*/
     72 
     73 unsigned int __cdecl Cardinal_To_Fixed(unsigned base, unsigned cardinal);
     74 
     75 #if (0)
     76 	PROC	Cardinal_To_Fixed C near
     77 	USES	ebx, edx
     78 
     79 	ARG	base:DWORD
     80 	ARG	cardinal:DWORD
     81 
     82 	mov	eax,0FFFFh		; establish default return value
     83 
     84 	mov	ebx,[base]
     85 	or	ebx,ebx
     86 	jz	near ??retneg1		; if base==0, return 65535
     87 
     88 	mov	eax,[cardinal]		; otherwise, return (cardinal*256)/base
     89 	shl	eax,8
     90 	xor	edx,edx
     91 	div	ebx
     92 
     93 ??retneg1:
     94 	ret
     95 
     96 	ENDP	Cardinal_To_Fixed
     97 #endif
     98 
     99 /*
    100 ;***********************************************************************************************
    101 ;* Fixed_To_Cardinal -- Converts a fixed point number into a cardinal number.                  *
    102 ;*                                                                                             *
    103 ;*    Use this routine to convert a fixed point number into a cardinal number.                 *
    104 ;*                                                                                             *
    105 ;* INPUT:   base     -- The base number that the original fixed point number was created from. *
    106 ;*                                                                                             *
    107 ;*          fixed    -- The fixed point number to convert.                                     *
    108 ;*                                                                                             *
    109 ;* OUTPUT:  Returns with the reconverted number.                                               *
    110 ;*                                                                                             *
    111 ;* WARNINGS:   none                                                                            *
    112 ;*                                                                                             *
    113 ;* HISTORY:                                                                                    *
    114 ;*   02/17/1995 BWG : Created.                                                                 *
    115 ;*=============================================================================================*/
    116 
    117 unsigned int __cdecl Fixed_To_Cardinal(unsigned base, unsigned fixed);
    118 
    119 #if (0)
    120 	mov	eax,[base]
    121 	mul	[fixed]
    122 	add	eax,080h		; eax = (base * fixed) + 0x80
    123 
    124 	test	eax,0FF000000h		; if high byte set, return FFFF
    125 	jnz	??rneg1
    126 	shr	eax,8			; else, return eax/256
    127 	ret
    128 ??rneg1	:
    129 	mov	eax,0FFFFh		; establish default return value
    130 	ret
    131 
    132 	ENDP	Fixed_To_Cardinal
    133 
    134 	END
    135 #endif
    136 
    137 
    138 
    139 
    140 
    141 #endif COORD_A_H