CnC_Remastered_Collection

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

REMAP.ASM (5115B)


      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 ;**   C O N F I D E N T I A L --- W E S T W O O D   A S S O C I A T E S   **
     18 ;***************************************************************************
     19 ;*                                                                         *
     20 ;*                 Project Name : Westwood 32 bit Library                  *
     21 ;*                                                                         *
     22 ;*                    File Name : REMAP.ASM                                *
     23 ;*                                                                         *
     24 ;*                   Programmer : Phil W. Gorrow                           *
     25 ;*                                                                         *
     26 ;*                   Start Date : July 1, 1994                             *
     27 ;*                                                                         *
     28 ;*                  Last Update : July 1, 1994   [PWG]                     *
     29 ;*                                                                         *
     30 ;*-------------------------------------------------------------------------*
     31 ;* Functions:                                                              *
     32 ;* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - *
     33 
     34 
     35 IDEAL
     36 P386
     37 MODEL USE32 FLAT
     38 
     39 INCLUDE ".\drawbuff.inc"
     40 INCLUDE ".\gbuffer.inc"
     41 
     42 
     43 CODESEG
     44 
     45 	PROC	Buffer_Remap C NEAR
     46 	USES	eax,ebx,ecx,edx,esi,edi
     47 
     48 	;*===================================================================
     49 	;* Define the arguements that our function takes.
     50 	;*===================================================================
     51 	ARG	this_object:DWORD
     52 	ARG	x0_pixel:DWORD
     53 	ARG	y0_pixel:DWORD
     54 	ARG	region_width:DWORD
     55 	ARG	region_height:DWORD
     56 	ARG	remap	:DWORD
     57 
     58 	;*===================================================================
     59 	; Define some locals so that we can handle things quickly
     60 	;*===================================================================
     61 	local	x1_pixel  : DWORD
     62 	local	y1_pixel  : DWORD
     63 	local	win_width : dword
     64 	local	counter_x : dword
     65 
     66 
     67 	cmp	[ remap ] , 0
     68 	jz	??real_out
     69 
     70 ; Clip Source Rectangle against source Window boundaries.
     71 	mov  	esi , [ this_object ]	    ; get ptr to src
     72 	xor 	ecx , ecx
     73 	xor 	edx , edx
     74 	mov	edi , [ (GraphicViewPort esi) . GVPWidth ]  ; get width into register
     75 	mov	ebx , [ x0_pixel ]
     76 	mov	eax , [ x0_pixel ]
     77 	add	ebx , [ region_width ]
     78 	shld	ecx , eax , 1
     79 	mov	[ x1_pixel ] , ebx
     80 	inc	edi
     81 	shld	edx , ebx , 1
     82 	sub	eax , edi
     83 	sub	ebx , edi
     84 	shld	ecx , eax , 1
     85 	shld	edx , ebx , 1
     86 
     87 	mov	edi,[ ( GraphicViewPort esi) . GVPHeight ] ; get height into register
     88 	mov	ebx , [ y0_pixel ]
     89 	mov	eax , [ y0_pixel ]
     90 	add	ebx , [ region_height ]
     91 	shld	ecx , eax , 1
     92 	mov	[ y1_pixel ] , ebx
     93 	inc	edi
     94 	shld	edx , ebx , 1
     95 	sub	eax , edi
     96 	sub	ebx , edi
     97 	shld	ecx , eax , 1
     98 	shld	edx , ebx , 1
     99 
    100 	xor	cl , 5
    101 	xor	dl , 5
    102 	mov	al , cl
    103 	test	dl , cl
    104 	jnz	??real_out
    105 	or	al , dl
    106 	jz	??do_remap
    107 
    108 	test	cl , 1000b
    109 	jz	??scr_left_ok
    110 	mov	[ x0_pixel ] , 0
    111 
    112 ??scr_left_ok:
    113 	test	cl , 0010b
    114 	jz	??scr_bottom_ok
    115 	mov	[ y0_pixel ] , 0
    116 
    117 ??scr_bottom_ok:
    118 	test	dl , 0100b
    119 	jz	??scr_right_ok
    120 	mov	eax , [ (GraphicViewPort esi) . GVPWidth ]  ; get width into register
    121 	mov	[ x1_pixel ] , eax
    122 ??scr_right_ok:
    123 	test	dl , 0001b
    124 	jz	??do_remap
    125 	mov	eax , [ (GraphicViewPort esi) . GVPHeight ]  ; get width into register
    126 	mov	[ y1_pixel ] , eax
    127 
    128 
    129 ??do_remap:
    130        cld
    131        mov	edi , [ (GraphicViewPort esi) . GVPOffset ]
    132        mov	eax , [ (GraphicViewPort esi) . GVPXAdd ]
    133        mov	ebx , [ x1_pixel ]
    134        add	eax , [ (GraphicViewPort esi) . GVPWidth ]
    135        add	eax , [ (GraphicViewPort esi) . GVPPitch ]
    136        mov	esi , eax
    137        mul	[ y0_pixel ]
    138        add	edi , [ x0_pixel ]
    139        sub	ebx , [ x0_pixel ]
    140        jle	??real_out
    141        add	edi , eax
    142        sub	esi , ebx
    143 
    144        mov	ecx , [ y1_pixel ]
    145        sub	ecx , [ y0_pixel ]
    146        jle	??real_out
    147        mov	eax , [ remap ]
    148        mov	[ counter_x ] , ebx
    149        xor	edx , edx
    150 
    151 ??outer_loop:
    152        mov	ebx , [ counter_x ]
    153 ??inner_loop:
    154        mov	dl , [ edi ]
    155        mov	dl , [ eax + edx ]
    156        mov	[ edi ] , dl
    157        inc	edi
    158        dec	ebx
    159        jnz	??inner_loop
    160        add	edi , esi
    161        dec	ecx
    162        jnz	??outer_loop
    163 
    164 
    165 
    166 
    167 ??real_out:
    168 	ret
    169 
    170 	ENDP	Buffer_Remap
    171 
    172 	END