103 lines
4.4 KiB
NASM
103 lines
4.4 KiB
NASM
;
|
||
; Command & Conquer Red Alert(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/>.
|
||
;
|
||
|
||
;***************************************************************************
|
||
;** 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 : Calculate size of an MCGA region *
|
||
;* *
|
||
;* File Name : REGIONSZ.ASM *
|
||
;* *
|
||
;* Programmer : Barry W. Green *
|
||
;* *
|
||
;* Start Date : March 1, 1995 *
|
||
;* *
|
||
;* Last Update : March 1, 1995 [BWG] *
|
||
;* *
|
||
;*-------------------------------------------------------------------------*
|
||
;* Functions: *
|
||
;* VVPC::Size_Of_Region - calculate MCGA region size *
|
||
;* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - *
|
||
|
||
IDEAL
|
||
P386
|
||
MODEL USE32 FLAT
|
||
|
||
INCLUDE "mcgaprim.inc"
|
||
INCLUDE ".\gbuffer.inc"
|
||
|
||
GLOBAL MCGA_Size_Of_Region : NEAR
|
||
|
||
CODESEG
|
||
|
||
;***************************************************************************
|
||
;* VVPC::Size_Of_Region - calculate MCGA region size *
|
||
;* *
|
||
;* INPUT: DWORD the width of the region *
|
||
;* *
|
||
;* DWORD the height of the region *
|
||
;* *
|
||
;* OUTPUT: calculated size of the region (MCGA = width * height) *
|
||
;* *
|
||
;* *
|
||
;* HISTORY: *
|
||
;* 03/01/1995 BWG : Created. *
|
||
;*=========================================================================*
|
||
PROC MCGA_Size_Of_Region C near
|
||
USES ebx,ecx,edx
|
||
|
||
ARG this:DWORD ; this is a member function
|
||
ARG width:DWORD ; width of region
|
||
ARG height:DWORD ; height of region
|
||
|
||
;*===================================================================
|
||
; Get the viewport information
|
||
;*===================================================================
|
||
mov ebx,[this] ; get a pointer to viewport
|
||
xor eax,eax
|
||
mov ecx,[(GraphicViewPort ebx).GVPHeight] ; ecx = height of viewport
|
||
mov edx,[(GraphicViewPort ebx).GVPWidth] ; edx = width of viewport
|
||
|
||
;*===================================================================
|
||
; Verify that the width is legal
|
||
;*===================================================================
|
||
mov eax,[width] ; find the width
|
||
cmp eax,edx ; is it too wide?
|
||
jb short ??wok ; if not, leave it alone
|
||
mov eax,edx ; otherwise clip it
|
||
|
||
;*===================================================================
|
||
; Verify that the height is ok
|
||
;*===================================================================
|
||
??wok: mov ebx,[height] ; get the height
|
||
cmp ebx,ecx ; is it too tall?
|
||
jb ??hok ; if not, leave it alone
|
||
mov ebx,ecx ; otherwise clip it
|
||
|
||
;*===================================================================
|
||
; Now multiply 'em to calculate the size of the region
|
||
;*===================================================================
|
||
??hok: mul ebx ; size = w * h
|
||
|
||
ret
|
||
ENDP MCGA_Size_Of_Region
|
||
|
||
END
|
||
|
||
|