Initial commit of Command & Conquer Red Alert source code.
This commit is contained in:
462
WIN32LIB/DRAWBUFF/BITBLIT.ASM
Normal file
462
WIN32LIB/DRAWBUFF/BITBLIT.ASM
Normal file
@@ -0,0 +1,462 @@
|
||||
;
|
||||
; 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 A S S O C I A T E S **
|
||||
;***************************************************************************
|
||||
;* *
|
||||
;* Project Name : Westwood 32 bit Library *
|
||||
;* *
|
||||
;* File Name : BITBLIT.ASM *
|
||||
;* *
|
||||
;* Programmer : Julio R. Jerez *
|
||||
;* *
|
||||
;* Start Date : Feb 6, 1995 *
|
||||
;* *
|
||||
;* *
|
||||
;*-------------------------------------------------------------------------*
|
||||
;* Functions: *
|
||||
;* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - *
|
||||
|
||||
IDEAL
|
||||
P386
|
||||
MODEL USE32 FLAT
|
||||
LOCALS ??
|
||||
|
||||
INCLUDE ".\drawbuff.inc"
|
||||
INCLUDE ".\gbuffer.inc"
|
||||
|
||||
CODESEG
|
||||
|
||||
PROC Linear_Blit_To_Linear C near
|
||||
USES ebx,ecx,edx,esi,edi
|
||||
|
||||
;*===================================================================
|
||||
;* define the arguements that our function takes.
|
||||
;*===================================================================
|
||||
ARG this_object :DWORD ; this is a member function
|
||||
ARG dest :DWORD ; what are we blitting to
|
||||
ARG x_pixel :DWORD ; x pixel position in source
|
||||
ARG y_pixel :DWORD ; y pixel position in source
|
||||
ARG dest_x0 :dword
|
||||
ARG dest_y0 :dword
|
||||
ARG pixel_width :DWORD ; width of rectangle to blit
|
||||
ARG pixel_height:DWORD ; height of rectangle to blit
|
||||
ARG trans :DWORD ; do we deal with transparents?
|
||||
|
||||
;*===================================================================
|
||||
; Define some locals so that we can handle things quickly
|
||||
;*===================================================================
|
||||
LOCAL x1_pixel :dword
|
||||
LOCAL y1_pixel :dword
|
||||
LOCAL dest_x1 : dword
|
||||
LOCAL dest_y1 : dword
|
||||
LOCAL scr_ajust_width:DWORD
|
||||
LOCAL dest_ajust_width:DWORD
|
||||
LOCAL source_area : dword
|
||||
LOCAL dest_area : dword
|
||||
|
||||
;This Clipping algorithm is a derivation of the very well known
|
||||
;Cohen-Sutherland Line-Clipping test. Due to its simplicity and efficiency
|
||||
;it is probably the most commontly implemented algorithm both in software
|
||||
;and hardware for clipping lines, rectangles, and convex polygons against
|
||||
;a rectagular clipping window. For reference see
|
||||
;"COMPUTER GRAPHICS principles and practice by Foley, Vandam, Feiner, Hughes
|
||||
; pages 113 to 177".
|
||||
; Briefly consist in computing the Sutherland code for both end point of
|
||||
; the rectangle to find out if the rectangle is:
|
||||
; - trivially accepted (no further clipping test, display rectangle)
|
||||
; - trivially rejected (return with no action)
|
||||
; - retangle must be iteratively clipped again edges of the clipping window
|
||||
; and the remaining retangle is display.
|
||||
|
||||
; Clip Source Rectangle against source Window boundaries.
|
||||
mov esi,[this_object] ; get ptr to src
|
||||
xor ecx,ecx ; Set sutherland code to zero
|
||||
xor edx,edx ; Set sutherland code to zero
|
||||
|
||||
; compute the difference in the X axis and get the bit signs into ecx , edx
|
||||
mov edi,[(GraphicViewPort esi).GVPWidth] ; get width into register
|
||||
mov ebx,[x_pixel] ; Get first end point x_pixel into register
|
||||
mov eax,[x_pixel] ; Get second end point x_pixel into register
|
||||
add ebx,[pixel_width] ; second point x1_pixel = x + width
|
||||
shld ecx, eax,1 ; the sign bit of x_pixel is sutherland code0 bit4
|
||||
mov [x1_pixel],ebx ; save second for future use
|
||||
inc edi ; move the right edge by one unit
|
||||
shld edx,ebx,1 ; the sign bit of x1_pixel is sutherland code0 bit4
|
||||
sub eax,edi ; compute the difference x0_pixel - width
|
||||
sub ebx,edi ; compute the difference x1_pixel - width
|
||||
shld ecx,eax,1 ; the sign bit of the difference is sutherland code0 bit3
|
||||
shld edx,ebx,1 ; the sign bit of the difference is sutherland code0 bit3
|
||||
|
||||
; the following code is just a repeticion of the above code
|
||||
; in the Y axis.
|
||||
mov edi,[(GraphicViewPort esi).GVPHeight] ; get height into register
|
||||
mov ebx,[y_pixel]
|
||||
mov eax,[y_pixel]
|
||||
add ebx,[pixel_height]
|
||||
shld ecx,eax,1
|
||||
mov [y1_pixel ],ebx
|
||||
inc edi
|
||||
shld edx,ebx,1
|
||||
sub eax,edi
|
||||
sub ebx,edi
|
||||
shld ecx,eax,1
|
||||
shld edx,ebx,1
|
||||
|
||||
; Here we have the to Sutherland code into cl and dl
|
||||
xor cl,5 ; bit 2 and 0 are complented, reverse then
|
||||
xor dl,5 ; bit 2 and 0 are complented, reverse then
|
||||
mov al,cl ; save code1 in case we have to clip iteratively
|
||||
test dl,cl ; if any bit in code0 and its counter bit
|
||||
jnz ??real_out ; in code1 is set then the rectangle in outside
|
||||
or al,dl ; if all bit of code0 the counter bit in
|
||||
jz ??clip_against_dest ; in code1 is set to zero, then all
|
||||
; end points of the rectangle are
|
||||
; inside the clipping window
|
||||
|
||||
; if we are here the polygon have to be clip iteratively
|
||||
test cl,1000b ; if bit 4 in code0 is set then
|
||||
jz ??scr_left_ok ; x_pixel is smaller than zero
|
||||
mov [x_pixel],0 ; set x_pixel to cero.
|
||||
|
||||
??scr_left_ok:
|
||||
test cl,0010b ; if bit 2 in code0 is set then
|
||||
jz ??scr_bottom_ok ; y_pixel is smaller than zero
|
||||
mov [ y_pixel ],0 ; set y_pixel to cero.
|
||||
|
||||
??scr_bottom_ok:
|
||||
test dl,0100b ; if bit 3 in code1 is set then
|
||||
jz ??scr_right_ok ; x1_pixel is greater than the width
|
||||
mov eax,[(GraphicViewPort esi).GVPWidth] ; get width into register
|
||||
mov [ x1_pixel ],eax ; set x1_pixel to width.
|
||||
??scr_right_ok:
|
||||
test dl,0001b ; if bit 0 in code1 is set then
|
||||
jz ??clip_against_dest ; y1_pixel is greater than the width
|
||||
mov eax,[(GraphicViewPort esi).GVPHeight] ; get height into register
|
||||
mov [ y1_pixel ],eax ; set y1_pixel to height.
|
||||
|
||||
; Clip Source Rectangle against destination Window boundaries.
|
||||
??clip_against_dest:
|
||||
|
||||
; build the destination rectangle before clipping
|
||||
; dest_x1 = dest_x0 + ( x1_pixel - x_pixel )
|
||||
; dest_y1 = dest_y0 + ( y1_pixel - y_pixel )
|
||||
mov eax,[dest_x0] ; get dest_x0 into eax
|
||||
mov ebx,[dest_y0] ; get dest_y0 into ebx
|
||||
sub eax,[x_pixel] ; subtract x_pixel from eax
|
||||
sub ebx,[y_pixel] ; subtract y_pixel from ebx
|
||||
add eax,[x1_pixel] ; add x1_pixel to eax
|
||||
add ebx,[y1_pixel] ; add y1_pixel to ebx
|
||||
mov [dest_x1],eax ; save eax into dest_x1
|
||||
mov [dest_y1],ebx ; save eax into dest_y1
|
||||
|
||||
|
||||
; The followin code is a repeticion of the Sutherland clipping
|
||||
; descrived above.
|
||||
mov esi,[dest] ; get ptr to src
|
||||
xor ecx,ecx
|
||||
xor edx,edx
|
||||
mov edi,[(GraphicViewPort esi).GVPWidth] ; get width into register
|
||||
mov eax,[dest_x0]
|
||||
mov ebx,[dest_x1]
|
||||
shld ecx,eax,1
|
||||
inc edi
|
||||
shld edx,ebx,1
|
||||
sub eax,edi
|
||||
sub ebx,edi
|
||||
shld ecx,eax,1
|
||||
shld edx,ebx,1
|
||||
|
||||
mov edi,[( GraphicViewPort esi) . GVPHeight ] ; get height into register
|
||||
mov eax,[dest_y0]
|
||||
mov ebx,[dest_y1]
|
||||
shld ecx,eax,1
|
||||
inc edi
|
||||
shld edx,ebx,1
|
||||
sub eax,edi
|
||||
sub ebx,edi
|
||||
shld ecx,eax,1
|
||||
shld edx,ebx,1
|
||||
|
||||
xor cl,5
|
||||
xor dl,5
|
||||
mov al,cl
|
||||
test dl,cl
|
||||
jnz ??real_out
|
||||
or al,dl
|
||||
jz ??do_blit
|
||||
|
||||
test cl,1000b
|
||||
jz ??dest_left_ok
|
||||
mov eax,[ dest_x0 ]
|
||||
mov [ dest_x0 ],0
|
||||
sub [ x_pixel ],eax
|
||||
|
||||
??dest_left_ok:
|
||||
test cl,0010b
|
||||
jz ??dest_bottom_ok
|
||||
mov eax,[ dest_y0 ]
|
||||
mov [ dest_y0 ],0
|
||||
sub [ y_pixel ],eax
|
||||
|
||||
|
||||
??dest_bottom_ok:
|
||||
test dl,0100b
|
||||
jz ??dest_right_ok
|
||||
mov ebx,[ (GraphicViewPort esi) . GVPWidth ] ; get width into register
|
||||
mov eax,[ dest_x1 ]
|
||||
mov [ dest_x1 ],ebx
|
||||
sub eax,ebx
|
||||
sub [ x1_pixel ],eax
|
||||
|
||||
??dest_right_ok:
|
||||
test dl,0001b
|
||||
jz ??do_blit
|
||||
mov ebx,[ (GraphicViewPort esi) . GVPHeight ] ; get width into register
|
||||
mov eax,[ dest_y1 ]
|
||||
mov [ dest_y1 ],ebx
|
||||
sub eax,ebx
|
||||
sub [ y1_pixel ],eax
|
||||
|
||||
|
||||
; Here is where we do the actual blit
|
||||
??do_blit:
|
||||
cld
|
||||
mov ebx,[this_object]
|
||||
mov esi,[(GraphicViewPort ebx).GVPOffset]
|
||||
mov eax,[(GraphicViewPort ebx).GVPXAdd]
|
||||
add eax,[(GraphicViewPort ebx).GVPWidth]
|
||||
add eax,[(GraphicViewPort ebx).GVPPitch]
|
||||
mov ecx,eax
|
||||
mul [y_pixel]
|
||||
add esi,[x_pixel]
|
||||
mov [source_area],ecx
|
||||
add esi,eax
|
||||
|
||||
add ecx,[x_pixel ]
|
||||
sub ecx,[x1_pixel ]
|
||||
mov [scr_ajust_width ],ecx
|
||||
|
||||
mov ebx,[dest]
|
||||
mov edi,[(GraphicViewPort ebx).GVPOffset]
|
||||
mov eax,[(GraphicViewPort ebx).GVPXAdd]
|
||||
add eax,[(GraphicViewPort ebx).GVPWidth]
|
||||
add eax,[(GraphicViewPort ebx).GVPPitch]
|
||||
mov ecx,eax
|
||||
mul [ dest_y0 ]
|
||||
add edi,[ dest_x0 ]
|
||||
mov [ dest_area ],ecx
|
||||
add edi,eax
|
||||
|
||||
mov eax,[ dest_x1 ]
|
||||
sub eax,[ dest_x0 ]
|
||||
jle ??real_out
|
||||
sub ecx,eax
|
||||
mov [ dest_ajust_width ],ecx
|
||||
|
||||
mov edx,[ dest_y1 ]
|
||||
sub edx,[ dest_y0 ]
|
||||
jle ??real_out
|
||||
|
||||
cmp esi,edi
|
||||
jz ??real_out
|
||||
jl ??backupward_blit
|
||||
|
||||
; ********************************************************************
|
||||
; Forward bitblit
|
||||
|
||||
test [ trans ],1
|
||||
jnz ??forward_Blit_trans
|
||||
|
||||
|
||||
; the inner loop is so efficient that
|
||||
; the optimal consept no longer apply because
|
||||
; the optimal byte have to by a number greather than 9 bytes
|
||||
cmp eax,10
|
||||
jl ??forward_loop_bytes
|
||||
|
||||
??forward_loop_dword:
|
||||
mov ecx,edi
|
||||
mov ebx,eax
|
||||
neg ecx
|
||||
and ecx,3
|
||||
sub ebx,ecx
|
||||
rep movsb
|
||||
mov ecx,ebx
|
||||
shr ecx,2
|
||||
rep movsd
|
||||
mov ecx,ebx
|
||||
and ecx,3
|
||||
rep movsb
|
||||
add esi,[ scr_ajust_width ]
|
||||
add edi,[ dest_ajust_width ]
|
||||
dec edx
|
||||
jnz ??forward_loop_dword
|
||||
ret
|
||||
|
||||
??forward_loop_bytes:
|
||||
mov ecx,eax
|
||||
rep movsb
|
||||
add esi,[ scr_ajust_width ]
|
||||
add edi,[ dest_ajust_width ]
|
||||
dec edx
|
||||
jnz ??forward_loop_bytes
|
||||
ret
|
||||
|
||||
??forward_Blit_trans:
|
||||
mov ecx,eax
|
||||
and ecx,01fh
|
||||
lea ecx,[ ecx + ecx * 4 ]
|
||||
neg ecx
|
||||
shr eax,5
|
||||
lea ecx,[ ??transp_reference + ecx * 2 ]
|
||||
mov [ y1_pixel ],ecx
|
||||
|
||||
??forward_loop_trans:
|
||||
mov ecx,eax
|
||||
jmp [ y1_pixel ]
|
||||
??forward_trans_line:
|
||||
REPT 32
|
||||
local transp_pixel
|
||||
mov bl,[ esi ]
|
||||
test bl,bl
|
||||
jz transp_pixel
|
||||
mov [ edi ],bl
|
||||
transp_pixel:
|
||||
inc esi
|
||||
inc edi
|
||||
ENDM
|
||||
??transp_reference:
|
||||
dec ecx
|
||||
jge ??forward_trans_line
|
||||
add esi,[ scr_ajust_width ]
|
||||
add edi,[ dest_ajust_width ]
|
||||
dec edx
|
||||
jnz ??forward_loop_trans
|
||||
ret
|
||||
|
||||
|
||||
; ************************************************************************
|
||||
; backward bitblit
|
||||
|
||||
??backupward_blit:
|
||||
|
||||
mov ebx,[ source_area ]
|
||||
dec edx
|
||||
add esi,eax
|
||||
imul ebx,edx
|
||||
std
|
||||
lea esi,[ esi + ebx - 1 ]
|
||||
|
||||
mov ebx,[ dest_area ]
|
||||
add edi,eax
|
||||
imul ebx,edx
|
||||
lea edi,[ edi + ebx - 1]
|
||||
|
||||
test [ trans ],1
|
||||
jnz ??backward_Blit_trans
|
||||
|
||||
cmp eax,15
|
||||
jl ??backward_loop_bytes
|
||||
|
||||
??backward_loop_dword:
|
||||
push edi
|
||||
push esi
|
||||
lea ecx,[edi+1]
|
||||
mov ebx,eax
|
||||
and ecx,3 ; Get non aligned bytes.
|
||||
sub ebx,ecx ; remove that from the total size to be copied later.
|
||||
rep movsb ; do the copy.
|
||||
sub esi,3
|
||||
mov ecx,ebx ; Get number of bytes left.
|
||||
sub edi,3
|
||||
shr ecx,2 ; Do 4 bytes at a time.
|
||||
rep movsd ; do the dword copy.
|
||||
mov ecx,ebx
|
||||
add esi,3
|
||||
add edi,3
|
||||
and ecx,03h
|
||||
rep movsb ; finnish the remaining bytes.
|
||||
pop esi
|
||||
pop edi
|
||||
sub esi,[ source_area ]
|
||||
sub edi,[ dest_area ]
|
||||
dec edx
|
||||
jge ??backward_loop_dword
|
||||
cld
|
||||
ret
|
||||
|
||||
??backward_loop_bytes:
|
||||
push edi
|
||||
mov ecx,eax ; remove that from the total size to be copied later.
|
||||
push esi
|
||||
rep movsb ; do the copy.
|
||||
pop esi
|
||||
pop edi
|
||||
sub esi,[ source_area ]
|
||||
sub edi,[ dest_area ]
|
||||
dec edx
|
||||
jge ??backward_loop_bytes
|
||||
cld
|
||||
ret
|
||||
|
||||
??backward_Blit_trans:
|
||||
mov ecx,eax
|
||||
and ecx,01fh
|
||||
lea ecx,[ ecx + ecx * 4 ]
|
||||
neg ecx
|
||||
shr eax,5
|
||||
lea ecx,[ ??back_transp_reference + ecx * 2 ]
|
||||
mov [ y1_pixel ],ecx
|
||||
|
||||
??backward_loop_trans:
|
||||
mov ecx,eax
|
||||
push edi
|
||||
push esi
|
||||
jmp [ y1_pixel ]
|
||||
??backward_trans_line:
|
||||
REPT 32
|
||||
local transp_pixel
|
||||
mov bl,[ esi ]
|
||||
test bl,bl
|
||||
jz transp_pixel
|
||||
mov [ edi ],bl
|
||||
transp_pixel:
|
||||
dec esi
|
||||
dec edi
|
||||
ENDM
|
||||
??back_transp_reference:
|
||||
dec ecx
|
||||
jge ??backward_trans_line
|
||||
pop esi
|
||||
pop edi
|
||||
sub esi,[ source_area ]
|
||||
sub edi,[ dest_area ]
|
||||
dec edx
|
||||
jge ??backward_loop_trans
|
||||
cld
|
||||
ret
|
||||
|
||||
??real_out:
|
||||
ret
|
||||
ENDP Linear_Blit_To_Linear
|
||||
|
||||
|
||||
|
||||
END
|
131
WIN32LIB/DRAWBUFF/BUFFER.CPP
Normal file
131
WIN32LIB/DRAWBUFF/BUFFER.CPP
Normal file
@@ -0,0 +1,131 @@
|
||||
/*
|
||||
** 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 A S S O C I A T E S **
|
||||
***************************************************************************
|
||||
* *
|
||||
* Project Name : Westwood 32 Bit Library *
|
||||
* *
|
||||
* File Name : BUFFER.CPP *
|
||||
* *
|
||||
* Programmer : Phil W. Gorrow *
|
||||
* *
|
||||
* Start Date : May 18, 1994 *
|
||||
* *
|
||||
* Last Update : June 1, 1994 [PWG] *
|
||||
* *
|
||||
*-------------------------------------------------------------------------*
|
||||
* Functions: *
|
||||
* BC::BufferClass -- The default (void) constructor for a buffer class *
|
||||
* BC::~BufferClass -- The destructor for the buffer class *
|
||||
* BC::BufferClass -- The standard constructor for a buffer class *
|
||||
* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
|
||||
|
||||
#ifndef BUFFER_H
|
||||
#include "buffer.h"
|
||||
#endif
|
||||
|
||||
/*=========================================================================*/
|
||||
/* The following PRIVATE functions are in this file: */
|
||||
/*=========================================================================*/
|
||||
|
||||
|
||||
/*= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =*/
|
||||
|
||||
/***************************************************************************
|
||||
* BC::BufferClass -- The standard constructor for a buffer class *
|
||||
* *
|
||||
* INPUT: VOID * buffer to which should be included in buffer class *
|
||||
* LONG size of the buffer which we included *
|
||||
* *
|
||||
* OUTPUT: NONE *
|
||||
* *
|
||||
* WARNINGS: If the buffer passed to this function is equal to NULL, *
|
||||
* the buffer will be allocated using new. *
|
||||
* *
|
||||
* HISTORY: *
|
||||
* 06/01/1994 PWG : Created. *
|
||||
*=========================================================================*/
|
||||
BufferClass::BufferClass(VOID *buffer, LONG size)
|
||||
{
|
||||
Size = size; // find size of physical buffer
|
||||
|
||||
if (buffer) { // if buffer is specified
|
||||
Buffer = (BYTE *)buffer; // point to it and mark
|
||||
Allocated = FALSE; // it as user allocated
|
||||
} else {
|
||||
Buffer = new BYTE[Size]; // otherwise allocate it and
|
||||
Allocated = TRUE; // mark it system alloced
|
||||
}
|
||||
}
|
||||
|
||||
/***************************************************************************
|
||||
* BC::BufferClass -- constructor for BufferClass with size only *
|
||||
* *
|
||||
* INPUT: LONG the size of the buffer that needs to be allocated *
|
||||
* *
|
||||
* OUTPUT: none *
|
||||
* *
|
||||
* HISTORY: *
|
||||
* 06/01/1994 PWG : Created. *
|
||||
*=========================================================================*/
|
||||
BufferClass::BufferClass(LONG size)
|
||||
{
|
||||
Size = size;
|
||||
Buffer = new BYTE[Size]; // otherwise allocate it and
|
||||
Allocated = TRUE; // mark it system alloced
|
||||
}
|
||||
|
||||
/***************************************************************************
|
||||
* BC::BufferClass -- The default (void) constructor for a buffer class *
|
||||
* *
|
||||
* INPUT: none *
|
||||
* *
|
||||
* OUTPUT: none *
|
||||
* *
|
||||
* NOTES: The primary function of this class is to be called by a *
|
||||
* derived class which will fill in the values after the *
|
||||
* fact. *
|
||||
* *
|
||||
* HISTORY: *
|
||||
* 06/01/1994 PWG : Created. *
|
||||
*=========================================================================*/
|
||||
BufferClass::BufferClass(VOID)
|
||||
{
|
||||
Buffer = NULL;
|
||||
Size = 0;
|
||||
Allocated = FALSE;
|
||||
}
|
||||
|
||||
/***************************************************************************
|
||||
* BC::~BUFFERCLASS -- The destructor for the buffer class *
|
||||
* *
|
||||
* INPUT: none *
|
||||
* *
|
||||
* OUTPUT: none *
|
||||
* *
|
||||
* HISTORY: *
|
||||
* 06/01/1994 PWG : Created. *
|
||||
*=========================================================================*/
|
||||
BufferClass::~BufferClass(VOID)
|
||||
{
|
||||
if (Allocated) {
|
||||
delete[] Buffer;
|
||||
}
|
||||
}
|
124
WIN32LIB/DRAWBUFF/BUFFER.H
Normal file
124
WIN32LIB/DRAWBUFF/BUFFER.H
Normal file
@@ -0,0 +1,124 @@
|
||||
/*
|
||||
** 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 A S S O C I A T E S **
|
||||
***************************************************************************
|
||||
* *
|
||||
* Project Name : Westwood 32 Bit Library *
|
||||
* *
|
||||
* File Name : GBUFFER.H *
|
||||
* *
|
||||
* Programmer : Phil W. Gorrow *
|
||||
* *
|
||||
* Start Date : May 26, 1994 *
|
||||
* *
|
||||
* Last Update : July 5, 1994 [PWG] *
|
||||
* *
|
||||
*-------------------------------------------------------------------------*
|
||||
* Functions: *
|
||||
* BC::Get_Size -- Returns the buffer size of the BufferClass instance *
|
||||
* BC::Get_Buffer -- Returns pointer to buffer inherent to BufferClass *
|
||||
* BC::BufferClass -- inline constructor for BufferClass with size only *
|
||||
* BC::To_Page -- Copys a buffer class to a page with definable x, y, w, h*
|
||||
* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
|
||||
|
||||
#ifndef BUFFER_H
|
||||
#define BUFFER_H
|
||||
|
||||
|
||||
/*=========================================================================*/
|
||||
/* If we have not already loaded the standard library header, than we can */
|
||||
/* load it. */
|
||||
/*=========================================================================*/
|
||||
#ifndef WWSTD_H
|
||||
#include "wwstd.h"
|
||||
#endif
|
||||
|
||||
class GraphicViewPortClass;
|
||||
|
||||
/*=========================================================================*/
|
||||
/* BufferClass - A base class which holds buffer information including a */
|
||||
/* pointer and the size of the buffer. */
|
||||
/*=========================================================================*/
|
||||
class BufferClass {
|
||||
public:
|
||||
/*===================================================================*/
|
||||
/* Define the base constructor and destructors for the class */
|
||||
/*===================================================================*/
|
||||
BufferClass(void *ptr, long size);
|
||||
BufferClass(long size);
|
||||
BufferClass();
|
||||
~BufferClass();
|
||||
/*===================================================================*/
|
||||
/* Define functions which work with the buffer class. */
|
||||
/*===================================================================*/
|
||||
long To_Page(GraphicViewPortClass &view);
|
||||
long To_Page(int w, int h, GraphicViewPortClass &view);
|
||||
long To_Page(int x, int y, int w, int h, GraphicViewPortClass &view);
|
||||
|
||||
/*===================================================================*/
|
||||
/* define functions to get at the protected data members */
|
||||
/*===================================================================*/
|
||||
void *Get_Buffer(void);
|
||||
long Get_Size(void);
|
||||
|
||||
private:
|
||||
/*===================================================================*/
|
||||
/* Define the operators we do not want to happen which are the copy */
|
||||
/* and equal constructors. These are bad because the Allocated flag */
|
||||
/* could be copied and the associated buffer freed. If this were to */
|
||||
/* gappen it could cause weird general protection fault. */
|
||||
/*===================================================================*/
|
||||
BufferClass(BufferClass const &);
|
||||
BufferClass &operator=(BufferClass const &);
|
||||
|
||||
protected:
|
||||
void *Buffer;
|
||||
long Size;
|
||||
BOOL Allocated;
|
||||
};
|
||||
/***************************************************************************
|
||||
* BC::GET_SIZE -- Returns the buffer size of the BufferClass instance *
|
||||
* *
|
||||
* INPUT: none *
|
||||
* *
|
||||
* OUTPUT: long the size of the buffer *
|
||||
* *
|
||||
* HISTORY: *
|
||||
* 06/01/1994 PWG : Created. *
|
||||
*=========================================================================*/
|
||||
inline long BufferClass::Get_Size(void)
|
||||
{
|
||||
return(Size);
|
||||
}
|
||||
/***************************************************************************
|
||||
* BC::GET_BUFFER -- Returns pointer to buffer inherent to BufferClass *
|
||||
* *
|
||||
* INPUT: none *
|
||||
* *
|
||||
* OUTPUT: void * to the inherent buffer. *
|
||||
* *
|
||||
* HISTORY: *
|
||||
* 06/01/1994 PWG : Created. *
|
||||
*=========================================================================*/
|
||||
inline void *BufferClass::Get_Buffer(void)
|
||||
{
|
||||
return(Buffer);
|
||||
}
|
||||
#endif
|
83
WIN32LIB/DRAWBUFF/BUFFGLBL.CPP
Normal file
83
WIN32LIB/DRAWBUFF/BUFFGLBL.CPP
Normal file
@@ -0,0 +1,83 @@
|
||||
/*
|
||||
** 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 : Westwood 32 bit Library *
|
||||
* *
|
||||
* File Name : BUFFGLBL.CPP *
|
||||
* *
|
||||
* Programmer : Phil W. Gorrow *
|
||||
* *
|
||||
* Start Date : January 10, 1995 *
|
||||
* *
|
||||
* Last Update : January 10, 1995 [PWG] *
|
||||
* *
|
||||
* This module holds the global fixup tables for the MCGA buffer class. *
|
||||
*-------------------------------------------------------------------------*
|
||||
* Functions: *
|
||||
* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
|
||||
#include "gbuffer.h"
|
||||
|
||||
/*=========================================================================*/
|
||||
/* The following PRIVATE functions are in this file: */
|
||||
/*=========================================================================*/
|
||||
|
||||
|
||||
/*= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =*/
|
||||
|
||||
/*=========================================================================*/
|
||||
/* Globals required by GraphicBufferClass for function pointers. These */
|
||||
/* pointers will be set to the proper function when set mode is called. */
|
||||
/*=========================================================================*/
|
||||
BOOL (*GVPC_Blit_to_VVPC_Func)(void *, void *, int, int, int, int, int, int, BOOL);
|
||||
BOOL (*GVPC_Scale_To_VVPC)( void *, void *, int, int, int, int, int, int, int, int, BOOL, char *);
|
||||
|
||||
#ifdef not_any_more_it_doesnt
|
||||
/*=========================================================================*/
|
||||
/* Globals required by VideoBufferClass for function pointers. These */
|
||||
/* pointers will be set to the proper function when set mode is called. */
|
||||
/*=========================================================================*/
|
||||
void (*VVPC_Clear_Func)(void *, unsigned char);
|
||||
long (*VVPC_To_Buffer_Func)(void *,int x, int y, int w, int h, void *buff, long size);
|
||||
void (*VVPC_Put_Pixel_Func)(void *,int x, int y, unsigned char color);
|
||||
int (*VVPC_Get_Pixel_Func)(void *, int x, int y);
|
||||
long (*VVPC_Buffer_To_Page)(int x, int y, int w, int h, void *Buffer, void *view);
|
||||
BOOL (*VVPC_Blit_to_GVPC_Func)(void *, void *, int, int, int, int, int, int, BOOL);
|
||||
BOOL (*VVPC_Blit_to_VVPC_Func)(void *, void *, int, int, int, int, int, int, BOOL);
|
||||
BOOL (*VVPC_Scale_To_GVPC)( void *, void *, int, int, int, int, int, int, int, int, BOOL, char *);
|
||||
BOOL (*VVPC_Scale_To_VVPC)( void *, void *, int, int, int, int, int, int, int, int, BOOL, char *);
|
||||
LONG (*VVPC_Print_Func)( void *, const char *, int, int, int, int);
|
||||
void (*VVPC_Draw_Stamp)(void *, void *, int, int, int, void *);
|
||||
long (*VVPC_Size_Of_Region)(void *, int, int);
|
||||
|
||||
#endif //not_any_more_it_doesnt
|
||||
|
||||
/*=========================================================================*/
|
||||
/* We need to keep a pointer to the logic page hanging around somewhere */
|
||||
/*=========================================================================*/
|
||||
GraphicViewPortClass *LogicPage;
|
||||
|
||||
BOOL IconCacheAllowed = TRUE;
|
||||
|
||||
/*
|
||||
** Pointer to a function we will call if we detect loss of focus
|
||||
*/
|
||||
void (*Gbuffer_Focus_Loss_Function)(void) = NULL;
|
130
WIN32LIB/DRAWBUFF/CLEAR.ASM
Normal file
130
WIN32LIB/DRAWBUFF/CLEAR.ASM
Normal file
@@ -0,0 +1,130 @@
|
||||
;
|
||||
; 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 : Clear the Full Graphics Buffer *
|
||||
;* *
|
||||
;* File Name : CLEAR.ASM *
|
||||
;* *
|
||||
;* Programmer : Phil Gorrow *
|
||||
;* *
|
||||
;* Start Date : June 7, 1994 *
|
||||
;* *
|
||||
;* Last Update : August 23, 1994 [SKB] *
|
||||
;* *
|
||||
;*-------------------------------------------------------------------------*
|
||||
;* Functions: *
|
||||
;* GVPC::Clear -- Clears a virtual viewport instance *
|
||||
;* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - *
|
||||
|
||||
IDEAL
|
||||
P386
|
||||
MODEL USE32 FLAT
|
||||
|
||||
INCLUDE ".\drawbuff.inc"
|
||||
INCLUDE ".\gbuffer.inc"
|
||||
|
||||
CODESEG
|
||||
|
||||
;***************************************************************************
|
||||
;* VVPC::CLEAR -- Clears a virtual viewport instance *
|
||||
;* *
|
||||
;* INPUT: UBYTE the color (optional) to clear the view port to *
|
||||
;* *
|
||||
;* OUTPUT: none *
|
||||
;* *
|
||||
;* NOTE: This function is optimized to handle viewport with no XAdd *
|
||||
;* value. It also handles DWORD aligning the destination *
|
||||
;* when speed can be gained by doing it. *
|
||||
;* HISTORY: *
|
||||
;* 06/07/1994 PWG : Created. *
|
||||
;* 08/23/1994 SKB : Clear the direction flag to always go forward. *
|
||||
;*=========================================================================*
|
||||
PROC Buffer_Clear C near
|
||||
USES eax,ebx,ecx,edx,esi,edi
|
||||
|
||||
ARG this_object:DWORD ; this is a member function
|
||||
ARG color:BYTE ; what color should we clear to
|
||||
|
||||
cld ; always go forward
|
||||
|
||||
mov ebx,[this_object] ; get a pointer to viewport
|
||||
mov edi,[(GraphicViewPort ebx).GVPOffset] ; get the correct offset
|
||||
mov edx,[(GraphicViewPort ebx).GVPHeight] ; ecx = height of viewport
|
||||
mov esi,[(GraphicViewPort ebx).GVPWidth] ; edx = width of viewport
|
||||
push [dword (GraphicViewPort ebx).GVPPitch] ; extra pitch of direct draw surface
|
||||
mov ebx,[(GraphicViewPort ebx).GVPXAdd] ; esi = add for each line
|
||||
add ebx,[esp] ; Yes, I know its nasty but
|
||||
add esp,4 ; it works!
|
||||
|
||||
;*===================================================================
|
||||
; Convert the color byte to a DWORD for fast storing
|
||||
;*===================================================================
|
||||
mov al,[color] ; get color to clear to
|
||||
mov ah,al ; extend across WORD
|
||||
mov ecx,eax ; extend across DWORD in
|
||||
shl eax,16 ; several steps
|
||||
mov ax,cx
|
||||
|
||||
;*===================================================================
|
||||
; Find out if we should bother to align the row.
|
||||
;*===================================================================
|
||||
|
||||
cmp esi , OPTIMAL_BYTE_COPY ; is it worth aligning them?
|
||||
jl ??byte_by_byte ; if not then skip
|
||||
|
||||
;*===================================================================
|
||||
; Figure out the alignment offset if there is any
|
||||
;*===================================================================
|
||||
push ebx
|
||||
??dword_aligned_loop:
|
||||
mov ecx , edi
|
||||
mov ebx , esi
|
||||
neg ecx
|
||||
and ecx , 3
|
||||
sub ebx , ecx
|
||||
rep stosb
|
||||
mov ecx , ebx
|
||||
shr ecx , 2
|
||||
rep stosd
|
||||
mov ecx , ebx
|
||||
and ecx , 3
|
||||
rep stosb
|
||||
add edi , [ esp ]
|
||||
dec edx ; decrement the height
|
||||
jnz ??dword_aligned_loop ; if more to do than do it
|
||||
pop eax
|
||||
ret
|
||||
|
||||
;*===================================================================
|
||||
; If not enough bytes to bother aligning copy each line across a byte
|
||||
; at a time.
|
||||
;*===================================================================
|
||||
??byte_by_byte:
|
||||
mov ecx,esi ; get total width in bytes
|
||||
rep stosb ; store the width
|
||||
add edi,ebx ; handle the xadd
|
||||
dec edx ; decrement the height
|
||||
jnz ??byte_by_byte ; if any left then next line
|
||||
??exit:
|
||||
ret
|
||||
ENDP Buffer_Clear
|
||||
END
|
67
WIN32LIB/DRAWBUFF/DRAWBUFF.H
Normal file
67
WIN32LIB/DRAWBUFF/DRAWBUFF.H
Normal file
@@ -0,0 +1,67 @@
|
||||
/*
|
||||
** 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/>.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef DRAWBUFF_H
|
||||
#define DRAWBUFF_H
|
||||
|
||||
|
||||
#ifndef WWSTD_H
|
||||
#include "wwstd.h"
|
||||
#endif
|
||||
|
||||
class GraphicViewPortClass;
|
||||
class GraphicBufferClass;
|
||||
/*=========================================================================*/
|
||||
/* Define functions which have not under-gone name mangling */
|
||||
/*=========================================================================*/
|
||||
|
||||
extern "C" {
|
||||
/*======================================================================*/
|
||||
/* Externs for all of the common functions between the video buffer */
|
||||
/* class and the graphic buffer class. */
|
||||
/*======================================================================*/
|
||||
long __cdecl Buffer_Size_Of_Region(void *thisptr, int w, int h);
|
||||
|
||||
void __cdecl Buffer_Put_Pixel(void * thisptr, int x, int y, unsigned char color);
|
||||
int __cdecl Buffer_Get_Pixel(void * thisptr, int x, int y);
|
||||
void __cdecl Buffer_Clear(void *thisptr, unsigned char color);
|
||||
long __cdecl Buffer_To_Buffer(void *thisptr, int x, int y, int w, int h, void *buff, long size);
|
||||
long __cdecl Buffer_To_Page(int x, int y, int w, int h, void *Buffer, void *view);
|
||||
BOOL __cdecl Linear_Blit_To_Linear( void *thisptr, void * dest, int x_pixel, int y_pixel, int dx_pixel,
|
||||
int dy_pixel, int pixel_width, int pixel_height, BOOL trans);
|
||||
BOOL __cdecl Linear_Scale_To_Linear( void *, void *, int, int, int, int, int, int, int, int, BOOL, char *);
|
||||
|
||||
LONG __cdecl Buffer_Print(void *thisptr, const char *str, int x, int y, int fcolor, int bcolor);
|
||||
|
||||
/*======================================================================*/
|
||||
/* Externs for all of the graphic buffer class only functions */
|
||||
/*======================================================================*/
|
||||
VOID __cdecl Buffer_Draw_Line(void *thisptr, int sx, int sy, int dx, int dy, unsigned char color);
|
||||
VOID __cdecl Buffer_Fill_Rect(void *thisptr, int sx, int sy, int dx, int dy, unsigned char color);
|
||||
VOID __cdecl Buffer_Remap(void * thisptr, int sx, int sy, int width, int height, void *remap);
|
||||
VOID __cdecl Buffer_Fill_Quad(void * thisptr, VOID *span_buff, int x0, int y0, int x1, int y1,
|
||||
int x2, int y2, int x3, int y3, int color);
|
||||
void __cdecl Buffer_Draw_Stamp(void const *thisptr, void const *icondata, int icon, int x_pixel, int y_pixel, void const *remap);
|
||||
void __cdecl Buffer_Draw_Stamp_Clip(void const *thisptr, void const *icondata, int icon, int x_pixel, int y_pixel, void const *remap, int ,int,int,int);
|
||||
void * __cdecl Get_Font_Palette_Ptr ( void );
|
||||
}
|
||||
|
||||
extern GraphicViewPortClass *LogicPage;
|
||||
extern BOOL AllowHardwareBlitFills;
|
||||
#endif
|
93
WIN32LIB/DRAWBUFF/DRAWBUFF.INC
Normal file
93
WIN32LIB/DRAWBUFF/DRAWBUFF.INC
Normal file
@@ -0,0 +1,93 @@
|
||||
;
|
||||
; 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 : Westwood 32 bit Library *
|
||||
;* *
|
||||
;* File Name : DRAWBUFF.INC *
|
||||
;* *
|
||||
;* Programmer : Phil W. Gorrow *
|
||||
;* *
|
||||
;* Start Date : January 16, 1995 *
|
||||
;* *
|
||||
;* Last Update : January 16, 1995 [PWG] *
|
||||
;* *
|
||||
;*-------------------------------------------------------------------------*
|
||||
;* Functions: *
|
||||
;* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - *
|
||||
|
||||
; Externs from REGIONSZ.ASM module of the DRAWBUFF library
|
||||
GLOBAL C Buffer_Size_Of_Region :NEAR
|
||||
|
||||
; Externs from GETPIX.ASM module of the DRAWBUFF library
|
||||
GLOBAL C Buffer_Get_Pixel :NEAR
|
||||
|
||||
; Externs from PUTPIX.ASM module of the DRAWBUFF library
|
||||
GLOBAL C Buffer_Put_Pixel :NEAR
|
||||
|
||||
; Externs from CLEAR.ASM module of the DRAWBUFF library
|
||||
GLOBAL C Buffer_Clear :NEAR
|
||||
|
||||
; Externs from BITBLIT.ASM module of the DRAWBUFF library
|
||||
GLOBAL C Linear_Blit_To_Linear :NEAR
|
||||
|
||||
; Externs from TOBUFF.ASM module of the DRAWBUFF library
|
||||
GLOBAL C Buffer_To_Buffer :NEAR
|
||||
|
||||
; Externs from TOPAGE.ASM module of the DRAWBUFF library
|
||||
GLOBAL C Buffer_To_Page :NEAR
|
||||
|
||||
; Externs from SCALE.ASM module of the DRAWBUFF library
|
||||
GLOBAL C Linear_Scale_To_Linear :NEAR
|
||||
|
||||
; Externs from TXTPRNT.ASM module of the DRAWBUFF library
|
||||
GLOBAL C Buffer_Print :NEAR
|
||||
|
||||
|
||||
;*-------------------------------------------------------------------------*
|
||||
;* Define Buffer only assembly GLOBALS *
|
||||
;*-------------------------------------------------------------------------*
|
||||
|
||||
; Externs from DRAWLINE.ASM module of the DRAWBUFF library
|
||||
GLOBAL C Buffer_Draw_Line:NEAR
|
||||
|
||||
; Externs from FILLQUAD.ASM module of the DRAWBUFF library
|
||||
GLOBAL C Buffer_Fill_Quad :NEAR
|
||||
|
||||
; Externs from FILLRECT.ASM module of the DRAWBUFF library
|
||||
GLOBAL C Buffer_Fill_Rect :NEAR
|
||||
|
||||
; Externs from REMAP.ASM module of the DRAWBUFF library
|
||||
GLOBAL C Buffer_Remap :NEAR
|
||||
|
||||
; Externs from STAMP.ASM module of the DRAWBUFF library
|
||||
GLOBAL C Buffer_Draw_Stamp :NEAR
|
||||
|
||||
GLOBAL C get_clip : NEAR
|
||||
|
||||
struc RECTANGLE
|
||||
x0 dd ?
|
||||
y0 dd ?
|
||||
x1 dd ?
|
||||
y1 dd ?
|
||||
ends RECTANGLE
|
||||
|
464
WIN32LIB/DRAWBUFF/DRAWLINE.ASM
Normal file
464
WIN32LIB/DRAWBUFF/DRAWLINE.ASM
Normal file
@@ -0,0 +1,464 @@
|
||||
;
|
||||
; 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 A S S O C I A T E S **
|
||||
;***************************************************************************
|
||||
;* *
|
||||
;* Project Name : Westwood 32 bit Library *
|
||||
;* *
|
||||
;* File Name : DRAWLINE.ASM *
|
||||
;* *
|
||||
;* Programmer : Phil W. Gorrow *
|
||||
;* *
|
||||
;* Start Date : June 16, 1994 *
|
||||
;* *
|
||||
;* Last Update : August 30, 1994 [IML] *
|
||||
;* *
|
||||
;*-------------------------------------------------------------------------*
|
||||
;* Functions: *
|
||||
;* VVC::Scale -- Scales a virtual viewport to another virtual viewport *
|
||||
;* Normal_Draw -- jump loc for drawing scaled line of normal pixel *
|
||||
;* __DRAW_LINE -- Assembly routine to draw a line *
|
||||
;* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - *
|
||||
|
||||
IDEAL
|
||||
P386
|
||||
MODEL USE32 FLAT
|
||||
|
||||
INCLUDE ".\drawbuff.inc"
|
||||
INCLUDE ".\gbuffer.inc"
|
||||
|
||||
|
||||
CODESEG
|
||||
|
||||
|
||||
|
||||
;***************************************************************************
|
||||
;* VVC::DRAW_LINE -- Scales a virtual viewport to another virtual viewport *
|
||||
;* *
|
||||
;* INPUT: WORD sx_pixel - the starting x pixel position *
|
||||
;* WORD sy_pixel - the starting y pixel position *
|
||||
;* WORD dx_pixel - the destination x pixel position *
|
||||
;* WORD dy_pixel - the destination y pixel position *
|
||||
;* WORD color - the color of the line to draw *
|
||||
;* *
|
||||
;* Bounds Checking: Compares sx_pixel, sy_pixel, dx_pixel and dy_pixel *
|
||||
;* with the graphic viewport it has been assigned to. *
|
||||
;* *
|
||||
;* HISTORY: *
|
||||
;* 06/16/1994 PWG : Created. *
|
||||
;* 08/30/1994 IML : Fixed clipping bug. *
|
||||
;*=========================================================================*
|
||||
PROC Buffer_Draw_Line C NEAR
|
||||
USES eax,ebx,ecx,edx,esi,edi
|
||||
|
||||
;*==================================================================
|
||||
;* Define the arguements that the function takes.
|
||||
;*==================================================================
|
||||
ARG this_object:DWORD ; associated graphic view port
|
||||
ARG x1_pixel:DWORD ; the start x pixel position
|
||||
ARG y1_pixel:DWORD ; the start y pixel position
|
||||
ARG x2_pixel:DWORD ; the dest x pixel position
|
||||
ARG y2_pixel:DWORD ; the dest y pixel position
|
||||
ARG color:DWORD ; the color we are drawing
|
||||
|
||||
;*==================================================================
|
||||
;* Define the local variables that we will use on the stack
|
||||
;*==================================================================
|
||||
LOCAL clip_min_x:DWORD
|
||||
LOCAL clip_max_x:DWORD
|
||||
LOCAL clip_min_y:DWORD
|
||||
LOCAL clip_max_y:DWORD
|
||||
LOCAL clip_var:DWORD
|
||||
LOCAL accum:DWORD
|
||||
LOCAL bpr:DWORD
|
||||
|
||||
;*==================================================================
|
||||
;* Take care of find the clip minimum and maximums
|
||||
;*==================================================================
|
||||
mov ebx,[this_object]
|
||||
xor eax,eax
|
||||
mov [clip_min_x],eax
|
||||
mov [clip_min_y],eax
|
||||
mov eax,[(GraphicViewPort ebx).GVPWidth]
|
||||
mov [clip_max_x],eax
|
||||
add eax,[(GraphicViewPort ebx).GVPXAdd]
|
||||
add eax,[(GraphicViewPort ebx).GVPPitch]
|
||||
mov [bpr],eax
|
||||
mov eax,[(GraphicViewPort ebx).GVPHeight]
|
||||
mov [clip_max_y],eax
|
||||
|
||||
;*==================================================================
|
||||
;* Adjust max pixels as they are tested inclusively.
|
||||
;*==================================================================
|
||||
dec [clip_max_x]
|
||||
dec [clip_max_y]
|
||||
|
||||
;*==================================================================
|
||||
;* Set the registers with the data for drawing the line
|
||||
;*==================================================================
|
||||
mov eax,[x1_pixel] ; eax = start x pixel position
|
||||
mov ebx,[y1_pixel] ; ebx = start y pixel position
|
||||
mov ecx,[x2_pixel] ; ecx = dest x pixel position
|
||||
mov edx,[y2_pixel] ; edx = dest y pixel position
|
||||
|
||||
;*==================================================================
|
||||
;* This is the section that "pushes" the line into bounds.
|
||||
;* I have marked the section with PORTABLE start and end to signify
|
||||
;* how much of this routine is 100% portable between graphics modes.
|
||||
;* It was just as easy to have variables as it would be for constants
|
||||
;* so the global vars ClipMaxX,ClipMinY,ClipMaxX,ClipMinY are used
|
||||
;* to clip the line (default is the screen)
|
||||
;* PORTABLE start
|
||||
;*==================================================================
|
||||
|
||||
cmp eax,[clip_min_x]
|
||||
jl short ??clip_it
|
||||
cmp eax,[clip_max_x]
|
||||
jg short ??clip_it
|
||||
cmp ebx,[clip_min_y]
|
||||
jl short ??clip_it
|
||||
cmp ebx,[clip_max_y]
|
||||
jg short ??clip_it
|
||||
cmp ecx,[clip_min_x]
|
||||
jl short ??clip_it
|
||||
cmp ecx,[clip_max_x]
|
||||
jg short ??clip_it
|
||||
cmp edx,[clip_min_y]
|
||||
jl short ??clip_it
|
||||
cmp edx,[clip_max_y]
|
||||
jle short ??on_screen
|
||||
|
||||
;*==================================================================
|
||||
;* Takes care off clipping the line.
|
||||
;*==================================================================
|
||||
??clip_it:
|
||||
call NEAR PTR ??set_bits
|
||||
xchg eax,ecx
|
||||
xchg ebx,edx
|
||||
mov edi,esi
|
||||
call NEAR PTR ??set_bits
|
||||
mov [clip_var],edi
|
||||
or [clip_var],esi
|
||||
jz short ??on_screen
|
||||
test edi,esi
|
||||
jne short ??off_screen
|
||||
shl esi,2
|
||||
call [DWORD PTR cs:??clip_tbl+esi]
|
||||
jc ??clip_it
|
||||
xchg eax,ecx
|
||||
xchg ebx,edx
|
||||
shl edi,2
|
||||
call [DWORD PTR cs:??clip_tbl+edi]
|
||||
jmp ??clip_it
|
||||
|
||||
??on_screen:
|
||||
jmp ??draw_it
|
||||
|
||||
??off_screen:
|
||||
jmp ??out
|
||||
|
||||
;*==================================================================
|
||||
;* Jump table for clipping conditions
|
||||
;*==================================================================
|
||||
??clip_tbl DD ??nada,??a_up,??a_dwn,??nada
|
||||
DD ??a_lft,??a_lft,??a_dwn,??nada
|
||||
DD ??a_rgt,??a_up,??a_rgt,??nada
|
||||
DD ??nada,??nada,??nada,??nada
|
||||
|
||||
??nada:
|
||||
clc
|
||||
retn
|
||||
|
||||
??a_up:
|
||||
mov esi,[clip_min_y]
|
||||
call NEAR PTR ??clip_vert
|
||||
stc
|
||||
retn
|
||||
|
||||
??a_dwn:
|
||||
mov esi,[clip_max_y]
|
||||
neg esi
|
||||
neg ebx
|
||||
neg edx
|
||||
call NEAR PTR ??clip_vert
|
||||
neg ebx
|
||||
neg edx
|
||||
stc
|
||||
retn
|
||||
|
||||
;*==================================================================
|
||||
;* xa'=xa+[(miny-ya)(xb-xa)/(yb-ya)]
|
||||
;*==================================================================
|
||||
??clip_vert:
|
||||
push edx
|
||||
push eax
|
||||
mov [clip_var],edx ; clip_var = yb
|
||||
sub [clip_var],ebx ; clip_var = (yb-ya)
|
||||
neg eax ; eax=-xa
|
||||
add eax,ecx ; (ebx-xa)
|
||||
mov edx,esi ; edx=miny
|
||||
sub edx,ebx ; edx=(miny-ya)
|
||||
imul edx
|
||||
idiv [clip_var]
|
||||
pop edx
|
||||
add eax,edx
|
||||
pop edx
|
||||
mov ebx,esi
|
||||
retn
|
||||
|
||||
??a_lft:
|
||||
mov esi,[clip_min_x]
|
||||
call NEAR PTR ??clip_horiz
|
||||
stc
|
||||
retn
|
||||
|
||||
??a_rgt:
|
||||
mov esi,[clip_max_x]
|
||||
neg eax
|
||||
neg ecx
|
||||
neg esi
|
||||
call NEAR PTR ??clip_horiz
|
||||
neg eax
|
||||
neg ecx
|
||||
stc
|
||||
retn
|
||||
|
||||
;*==================================================================
|
||||
;* ya'=ya+[(minx-xa)(yb-ya)/(xb-xa)]
|
||||
;*==================================================================
|
||||
??clip_horiz:
|
||||
push edx
|
||||
mov [clip_var],ecx ; clip_var = xb
|
||||
sub [clip_var],eax ; clip_var = (xb-xa)
|
||||
sub edx,ebx ; edx = (yb-ya)
|
||||
neg eax ; eax = -xa
|
||||
add eax,esi ; eax = (minx-xa)
|
||||
imul edx ; eax = (minx-xa)(yb-ya)
|
||||
idiv [clip_var] ; eax = (minx-xa)(yb-ya)/(xb-xa)
|
||||
add ebx,eax ; ebx = xa+[(minx-xa)(yb-ya)/(xb-xa)]
|
||||
pop edx
|
||||
mov eax,esi
|
||||
retn
|
||||
|
||||
;*==================================================================
|
||||
;* Sets the condition bits
|
||||
;*==================================================================
|
||||
??set_bits:
|
||||
xor esi,esi
|
||||
cmp ebx,[clip_min_y] ; if y >= top its not up
|
||||
jge short ??a_not_up
|
||||
or esi,1
|
||||
|
||||
??a_not_up:
|
||||
cmp ebx,[clip_max_y] ; if y <= bottom its not down
|
||||
jle short ??a_not_down
|
||||
or esi,2
|
||||
|
||||
??a_not_down:
|
||||
cmp eax,[clip_min_x] ; if x >= left its not left
|
||||
jge short ??a_not_left
|
||||
or esi,4
|
||||
|
||||
??a_not_left:
|
||||
cmp eax,[clip_max_x] ; if x <= right its not right
|
||||
jle short ??a_not_right
|
||||
or esi,8
|
||||
|
||||
??a_not_right:
|
||||
retn
|
||||
|
||||
;*==================================================================
|
||||
;* Draw the line to the screen.
|
||||
;* PORTABLE end
|
||||
;*==================================================================
|
||||
??draw_it:
|
||||
sub edx,ebx ; see if line is being draw down
|
||||
jnz short ??not_hline ; if not then its not a hline
|
||||
jmp short ??hline ; do special case h line
|
||||
|
||||
??not_hline:
|
||||
jg short ??down ; if so there is no need to rev it
|
||||
neg edx ; negate for actual pixel length
|
||||
xchg eax,ecx ; swap x's to rev line draw
|
||||
sub ebx,edx ; get old edx
|
||||
|
||||
??down:
|
||||
push edx
|
||||
push eax
|
||||
mov eax,[bpr]
|
||||
mul ebx
|
||||
mov ebx,eax
|
||||
mov eax,[this_object]
|
||||
add ebx,[(GraphicViewPort eax).GVPOffset]
|
||||
pop eax
|
||||
pop edx
|
||||
|
||||
mov esi,1 ; assume a right mover
|
||||
sub ecx,eax ; see if line is right
|
||||
jnz short ??not_vline ; see if its a vertical line
|
||||
jmp ??vline
|
||||
|
||||
??not_vline:
|
||||
jg short ??right ; if so, the difference = length
|
||||
|
||||
??left:
|
||||
neg ecx ; else negate for actual pixel length
|
||||
neg esi ; negate counter to move left
|
||||
|
||||
??right:
|
||||
cmp ecx,edx ; is it a horiz or vert line
|
||||
jge short ??horiz ; if ecx > edx then |x|>|y| or horiz
|
||||
|
||||
??vert:
|
||||
xchg ecx,edx ; make ecx greater and edx lesser
|
||||
mov edi,ecx ; set greater
|
||||
mov [accum],ecx ; set accumulator to 1/2 greater
|
||||
shr [accum],1
|
||||
|
||||
;*==================================================================
|
||||
;* at this point ...
|
||||
;* eax=xpos ; ebx=page line offset; ecx=counter; edx=lesser; edi=greater;
|
||||
;* esi=adder; accum=accumulator
|
||||
;* in a vertical loop the adder is conditional and the inc constant
|
||||
;*==================================================================
|
||||
??vert_loop:
|
||||
add ebx,eax
|
||||
mov eax,[color]
|
||||
|
||||
??v_midloop:
|
||||
mov [ebx],al
|
||||
dec ecx
|
||||
jl ??out
|
||||
add ebx,[bpr]
|
||||
sub [accum],edx ; sub the lesser
|
||||
jge ??v_midloop ; any line could be new
|
||||
add [accum],edi ; add greater for new accum
|
||||
add ebx,esi ; next pixel over
|
||||
jmp ??v_midloop
|
||||
|
||||
??horiz:
|
||||
mov edi,ecx ; set greater
|
||||
mov [accum],ecx ; set accumulator to 1/2 greater
|
||||
shr [accum],1
|
||||
|
||||
;*==================================================================
|
||||
;* at this point ...
|
||||
;* eax=xpos ; ebx=page line offset; ecx=counter; edx=lesser; edi=greater;
|
||||
;* esi=adder; accum=accumulator
|
||||
;* in a vertical loop the adder is conditional and the inc constant
|
||||
;*==================================================================
|
||||
??horiz_loop:
|
||||
add ebx,eax
|
||||
mov eax,[color]
|
||||
|
||||
??h_midloop:
|
||||
mov [ebx],al
|
||||
dec ecx ; dec counter
|
||||
jl ??out ; end of line
|
||||
add ebx,esi
|
||||
sub [accum],edx ; sub the lesser
|
||||
jge ??h_midloop
|
||||
add [accum],edi ; add greater for new accum
|
||||
add ebx,[bpr] ; goto next line
|
||||
jmp ??h_midloop
|
||||
|
||||
;*==================================================================
|
||||
;* Special case routine for horizontal line draws
|
||||
;*==================================================================
|
||||
??hline:
|
||||
cmp eax,ecx ; make eax < ecx
|
||||
jl short ??hl_ac
|
||||
xchg eax,ecx
|
||||
|
||||
??hl_ac:
|
||||
sub ecx,eax ; get len
|
||||
inc ecx
|
||||
|
||||
push edx
|
||||
push eax
|
||||
mov eax,[bpr]
|
||||
mul ebx
|
||||
mov ebx,eax
|
||||
mov eax,[this_object]
|
||||
add ebx,[(GraphicViewPort eax).GVPOffset]
|
||||
pop eax
|
||||
pop edx
|
||||
add ebx,eax
|
||||
mov edi,ebx
|
||||
cmp ecx,15
|
||||
jg ??big_line
|
||||
mov al,[byte color]
|
||||
rep stosb ; write as many words as possible
|
||||
jmp short ??out ; get outt
|
||||
|
||||
|
||||
??big_line:
|
||||
mov al,[byte color]
|
||||
mov ah,al
|
||||
mov ebx,eax
|
||||
shl eax,16
|
||||
mov ax,bx
|
||||
test edi,3
|
||||
jz ??aligned
|
||||
mov [edi],al
|
||||
inc edi
|
||||
dec ecx
|
||||
test edi,3
|
||||
jz ??aligned
|
||||
mov [edi],al
|
||||
inc edi
|
||||
dec ecx
|
||||
test edi,3
|
||||
jz ??aligned
|
||||
mov [edi],al
|
||||
inc edi
|
||||
dec ecx
|
||||
|
||||
??aligned:
|
||||
mov ebx,ecx
|
||||
shr ecx,2
|
||||
rep stosd
|
||||
mov ecx,ebx
|
||||
and ecx,3
|
||||
rep stosb
|
||||
jmp ??out
|
||||
|
||||
|
||||
;*==================================================================
|
||||
;* a special case routine for vertical line draws
|
||||
;*==================================================================
|
||||
??vline:
|
||||
mov ecx,edx ; get length of line to draw
|
||||
inc ecx
|
||||
add ebx,eax
|
||||
mov eax,[color]
|
||||
|
||||
??vl_loop:
|
||||
mov [ebx],al ; store bit
|
||||
add ebx,[bpr]
|
||||
dec ecx
|
||||
jnz ??vl_loop
|
||||
|
||||
??out:
|
||||
ret
|
||||
ENDP Buffer_Draw_Line
|
||||
|
||||
|
||||
END
|
68
WIN32LIB/DRAWBUFF/DRAWRECT.CPP
Normal file
68
WIN32LIB/DRAWBUFF/DRAWRECT.CPP
Normal file
@@ -0,0 +1,68 @@
|
||||
/*
|
||||
** 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 A S S O C I A T E S **
|
||||
***************************************************************************
|
||||
* *
|
||||
* Project Name : Westwood 32 Bit Library *
|
||||
* *
|
||||
* File Name : DRAWRECT.C *
|
||||
* *
|
||||
* Programmer : Christopher Yates *
|
||||
* *
|
||||
* Last Update : August 20, 1993 [JLB] *
|
||||
* *
|
||||
*-------------------------------------------------------------------------*
|
||||
* Functions: *
|
||||
* Draw_Rect -- Draws a rectangle to the LogicPage. *
|
||||
* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
|
||||
|
||||
#include "gbuffer.h"
|
||||
|
||||
/***************************************************************************
|
||||
* Draw_Rect -- Draws a rectangle to the LogicPage. *
|
||||
* *
|
||||
* This routine will draw a rectangle to the LogicPage. The rectangle *
|
||||
* doesn't have to be aligned on the vertical or horizontal axis. In *
|
||||
* fact, it doesn't even have to be a rectangle. The "square" can be *
|
||||
* skewed. *
|
||||
* *
|
||||
* INPUT: x1_pixel, y1_pixel -- One corner. *
|
||||
* *
|
||||
* x2_pixel, y2_pixel -- The other corner. *
|
||||
* *
|
||||
* color -- The color to draw the lines. *
|
||||
* *
|
||||
* OUTPUT: none *
|
||||
* *
|
||||
* WARNINGS: None, but the rectangle will be clipped to the current *
|
||||
* draw line clipping rectangle. *
|
||||
* *
|
||||
* HISTORY: *
|
||||
* 08/20/1993 JLB : Created. *
|
||||
*=========================================================================*/
|
||||
VOID GraphicViewPortClass::Draw_Rect(int x1_pixel, int y1_pixel, int x2_pixel, int y2_pixel, unsigned char color)
|
||||
{
|
||||
Lock();
|
||||
Draw_Line(x1_pixel, y1_pixel, x2_pixel, y1_pixel, color);
|
||||
Draw_Line(x1_pixel, y2_pixel, x2_pixel, y2_pixel, color);
|
||||
Draw_Line(x1_pixel, y1_pixel, x1_pixel, y2_pixel, color);
|
||||
Draw_Line(x2_pixel, y1_pixel, x2_pixel, y2_pixel, color);
|
||||
Unlock();
|
||||
}
|
669
WIN32LIB/DRAWBUFF/FILLQUAD.ASM
Normal file
669
WIN32LIB/DRAWBUFF/FILLQUAD.ASM
Normal file
@@ -0,0 +1,669 @@
|
||||
;
|
||||
; 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 A S S O C I A T E S **
|
||||
;***************************************************************************
|
||||
;* *
|
||||
;* Project Name : Westwood 32 bit Library *
|
||||
;* *
|
||||
;* File Name : FILLQUAD.ASM *
|
||||
;* *
|
||||
;* Programmer : Ian M. Leslie *
|
||||
;* *
|
||||
;* Start Date : August 11, 1994 *
|
||||
;* *
|
||||
;* Last Update : August 30, 1994 [IML] *
|
||||
;* *
|
||||
;*-------------------------------------------------------------------------*
|
||||
;* Functions: *
|
||||
;* Fill_Quad -- Flood fills an arbitrary convex quadrilateral *
|
||||
;* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - *
|
||||
|
||||
IDEAL
|
||||
P386
|
||||
MODEL USE32 FLAT
|
||||
|
||||
INCLUDE ".\drawbuff.inc"
|
||||
INCLUDE ".\gbuffer.inc"
|
||||
|
||||
SLOT_VACANT EQU 80008000h
|
||||
NULL EQU 0h
|
||||
|
||||
|
||||
CODESEG
|
||||
|
||||
;***************************************************************************
|
||||
;* VVC::FILL_QUAD -- Flood fills an arbitrary convex quadrilateral *
|
||||
;* *
|
||||
;* INPUT: DWORD this_object - associated graphic viewport *
|
||||
;* DWORD span_buff - pointer to span array *
|
||||
;* DWORD x0_pixel - the zeroth x pixel position *
|
||||
;* DWORD y0_pixel - the zeroth y pixel position *
|
||||
;* DWORD x1_pixel - the first x pixel position *
|
||||
;* DWORD y1_pixel - the first y pixel position *
|
||||
;* DWORD x2_pixel - the second x pixel position *
|
||||
;* DWORD y2_pixel - the second y pixel position *
|
||||
;* DWORD x3_pixel - the third x pixel position *
|
||||
;* DWORD y3_pixel - the third y pixel position *
|
||||
;* DWORD color - the color of the quad to fill *
|
||||
;* *
|
||||
;* Bounds Checking: Compares quad points with the graphic viewport it *
|
||||
;* has been assigned to. *
|
||||
;* *
|
||||
;* Rasterization Rules: FILL_QUAD is designed to be used within a quad *
|
||||
;* mesh. There is no pixel overlapping or stitching *
|
||||
;* effects at shared borders. FILL_QUAD is NOT *
|
||||
;* recommended for isolated quads. * *
|
||||
;* HISTORY: *
|
||||
;* 08/11/1994 IML : Created. *
|
||||
;* 08/26/1994 IML : Various optimizations. *
|
||||
;* 08/30/1994 IML : Added rasterization rules for shared borders. *
|
||||
;*=========================================================================*
|
||||
PROC Buffer_Fill_Quad C NEAR
|
||||
USES eax,ebx,ecx,edx,esi,edi
|
||||
|
||||
|
||||
;*==================================================================
|
||||
;* Define the arguments that the function takes.
|
||||
;*==================================================================
|
||||
ARG this_object:DWORD ; associated graphic viewport
|
||||
ARG span_buff:DWORD ; pointer to span array
|
||||
ARG x0_pixel:DWORD ; the zeroth x pixel position
|
||||
ARG y0_pixel:DWORD ; the zeroth y pixel position
|
||||
ARG x1_pixel:DWORD ; the first x pixel position
|
||||
ARG y1_pixel:DWORD ; the first y pixel position
|
||||
ARG x2_pixel:DWORD ; the second x pixel position
|
||||
ARG y2_pixel:DWORD ; the second y pixel position
|
||||
ARG x3_pixel:DWORD ; the third x pixel position
|
||||
ARG y3_pixel:DWORD ; the third y pixel position
|
||||
ARG color:DWORD ; the color of the quad
|
||||
|
||||
|
||||
;*==================================================================
|
||||
;* Define the local variables that we will use on the stack.
|
||||
;*==================================================================
|
||||
LOCAL clip_min_x:DWORD ; boundary of viewport
|
||||
LOCAL clip_max_x:DWORD ;
|
||||
LOCAL clip_min_y:DWORD ;
|
||||
LOCAL clip_max_y:DWORD ;
|
||||
LOCAL clip_var:DWORD
|
||||
LOCAL left_clip_base:DWORD:2 ; storage for additional edges
|
||||
LOCAL left_clip_index:DWORD ; generated by clipping
|
||||
LOCAL right_clip_base:DWORD:2 ;
|
||||
LOCAL right_clip_index:DWORD ;
|
||||
LOCAL scanline_min:DWORD ; vertical extent of quad
|
||||
LOCAL scanline_max:DWORD
|
||||
LOCAL realignment:DWORD
|
||||
LOCAL bpr:DWORD ; bytes per row of associated buffer
|
||||
|
||||
|
||||
;*==================================================================
|
||||
;* Extract essential GraphicViewPort info.
|
||||
;*==================================================================
|
||||
mov ebx,[this_object]
|
||||
mov eax,[(GraphicViewPort ebx).GVPXPos]
|
||||
mov [clip_min_x],eax
|
||||
mov eax,[(GraphicViewPort ebx).GVPYPos]
|
||||
mov [clip_min_y],eax
|
||||
mov eax,[(GraphicViewPort ebx).GVPWidth]
|
||||
mov [clip_max_x],eax
|
||||
add eax,[(GraphicViewPort ebx).GVPXAdd]
|
||||
add eax,[(GraphicViewPort ebx).GVPPitch]
|
||||
mov [bpr],eax
|
||||
mov eax,[(GraphicViewPort ebx).GVPHeight]
|
||||
mov [clip_max_y],eax
|
||||
|
||||
|
||||
;*==================================================================
|
||||
;* Adjust top and right edges of viewport for rasterization rules.
|
||||
;*==================================================================
|
||||
dec [clip_max_y]
|
||||
dec [clip_min_y]
|
||||
|
||||
|
||||
;*==================================================================
|
||||
;* Find the vertical extent of the quad BEFORE clipping.
|
||||
;* y0_pixel = y0, y1_pixel = y1, y2_pixel = y2, y3_pixel = y3
|
||||
;*==================================================================
|
||||
mov eax,[y0_pixel]
|
||||
cmp eax,[y1_pixel]
|
||||
jle short ??y1_not_smaller
|
||||
mov eax,[y1_pixel]
|
||||
|
||||
??y1_not_smaller:
|
||||
cmp eax,[y2_pixel]
|
||||
jle short ??y2_not_smaller
|
||||
mov eax,[y2_pixel]
|
||||
|
||||
??y2_not_smaller:
|
||||
cmp eax,[y3_pixel]
|
||||
jle short ??y3_not_smaller
|
||||
mov eax,[y3_pixel]
|
||||
|
||||
??y3_not_smaller:
|
||||
cmp eax,[clip_min_y]
|
||||
jge short ??no_clamp_min_min
|
||||
mov eax,[clip_min_y]
|
||||
|
||||
??no_clamp_min_min:
|
||||
cmp eax,[clip_max_y]
|
||||
jle short ??no_clamp_max_min
|
||||
mov eax,[clip_max_y]
|
||||
; scanline_min = MIN (y0, y1, y2, y3)
|
||||
??no_clamp_max_min: ; scanline_min = MAX (scanline_min, clip_min_y)
|
||||
mov [scanline_min],eax ; scanline_min = MIN (scanline_min, clip_max_y)
|
||||
|
||||
mov eax,[y0_pixel]
|
||||
cmp eax,[y1_pixel]
|
||||
jge short ??y1_not_greater
|
||||
mov eax,[y1_pixel]
|
||||
|
||||
??y1_not_greater:
|
||||
cmp eax,[y2_pixel]
|
||||
jge short ??y2_not_greater
|
||||
mov eax,[y2_pixel]
|
||||
|
||||
??y2_not_greater:
|
||||
cmp eax,[y3_pixel]
|
||||
jge short ??y3_not_greater
|
||||
mov eax,[y3_pixel]
|
||||
|
||||
??y3_not_greater:
|
||||
cmp eax,[clip_min_y]
|
||||
jge short ??no_clamp_min_max
|
||||
mov eax,[clip_min_y]
|
||||
|
||||
??no_clamp_min_max:
|
||||
cmp eax,[clip_max_y]
|
||||
jle short ??no_clamp_max_max
|
||||
mov eax,[clip_max_y]
|
||||
; scanline_max = MAX (y0, y1, y2, y3)
|
||||
??no_clamp_max_max: ; scanline_max = MAX (scanline_max, clip_min_y)
|
||||
mov [scanline_max],eax ; scanline_max = MIN (scanline_max, clip_max_y)
|
||||
|
||||
|
||||
;*==================================================================
|
||||
;* Initialize memory for spans.
|
||||
;*==================================================================
|
||||
sub eax,[scanline_min]
|
||||
je ??abort_fill_quad ; don't render quads with zero height
|
||||
mov ebx,eax
|
||||
mov eax,[span_buff] ; check span_buff for NULL ptr
|
||||
cmp eax,NULL
|
||||
je ??abort_fill_quad
|
||||
sal ebx,2
|
||||
|
||||
??span_initialize_loop:
|
||||
mov [DWORD PTR eax + ebx],SLOT_VACANT
|
||||
sub ebx,4
|
||||
jl short ??exit_span_initialize
|
||||
mov [DWORD PTR eax + ebx],SLOT_VACANT
|
||||
sub ebx,4
|
||||
jl short ??exit_span_initialize
|
||||
mov [DWORD PTR eax + ebx],SLOT_VACANT
|
||||
sub ebx,4
|
||||
jl short ??exit_span_initialize
|
||||
mov [DWORD PTR eax + ebx],SLOT_VACANT
|
||||
sub ebx,4
|
||||
jge short ??span_initialize_loop
|
||||
|
||||
|
||||
;*==================================================================
|
||||
;* Clip and scan convert the four edges defining the quad.
|
||||
;*==================================================================
|
||||
??exit_span_initialize:
|
||||
mov [left_clip_index],0
|
||||
mov [right_clip_index],0
|
||||
|
||||
mov eax,[x0_pixel]
|
||||
mov ebx,[y0_pixel]
|
||||
mov ecx,[x1_pixel]
|
||||
mov edx,[y1_pixel]
|
||||
call NEAR PTR ??clip_and_scan_convert
|
||||
mov eax,[x1_pixel]
|
||||
mov ebx,[y1_pixel]
|
||||
mov ecx,[x2_pixel]
|
||||
mov edx,[y2_pixel]
|
||||
call NEAR PTR ??clip_and_scan_convert
|
||||
mov eax,[x2_pixel]
|
||||
mov ebx,[y2_pixel]
|
||||
mov ecx,[x3_pixel]
|
||||
mov edx,[y3_pixel]
|
||||
call NEAR PTR ??clip_and_scan_convert
|
||||
mov eax,[x3_pixel]
|
||||
mov ebx,[y3_pixel]
|
||||
mov ecx,[x0_pixel]
|
||||
mov edx,[y0_pixel]
|
||||
call NEAR PTR ??clip_and_scan_convert
|
||||
|
||||
|
||||
;*==================================================================
|
||||
;* Scan convert up to 2 additional left and right vertical edges
|
||||
;* generated by the clipping process.
|
||||
;*==================================================================
|
||||
cmp [left_clip_index],0
|
||||
je short ??no_left_edge
|
||||
mov eax,[clip_min_x]
|
||||
mov ebx,[left_clip_base]
|
||||
mov ecx,eax
|
||||
mov edx,[left_clip_base + 4]
|
||||
call NEAR PTR ??scan_convert
|
||||
|
||||
??no_left_edge:
|
||||
cmp [right_clip_index],0
|
||||
je short ??no_right_edge
|
||||
mov eax,[clip_max_x]
|
||||
mov ebx,[right_clip_base]
|
||||
mov ecx,eax
|
||||
mov edx,[right_clip_base + 4]
|
||||
call NEAR PTR ??scan_convert
|
||||
|
||||
|
||||
;*==================================================================
|
||||
;* Fill the quad with specified color. Use DWORD copies where
|
||||
;* appropriate.
|
||||
;*==================================================================
|
||||
??no_right_edge:
|
||||
mov eax,[this_object]
|
||||
mov edi,[(GraphicViewPort eax).GVPOffset]
|
||||
mov eax,[scanline_min] ; eax = scanline_min
|
||||
|
||||
mov ebx,[scanline_max]
|
||||
sub ebx,[scanline_min] ; ebx = span count
|
||||
|
||||
mov esi,[span_buff] ; esi = address of top span
|
||||
|
||||
mul [bpr]
|
||||
add edi,eax ; edi = address of top scanline
|
||||
; containing quad
|
||||
mov al,[BYTE PTR color] ; extend pixel color into eax ready
|
||||
mov ah,al ; for DWORD copies
|
||||
mov edx,eax
|
||||
shl eax,16
|
||||
mov ax,dx
|
||||
|
||||
cld ; only fill forwards
|
||||
|
||||
jmp ??skip_span ; rasterization rule: don't
|
||||
; render topmost span
|
||||
|
||||
??quad_fill_loop:
|
||||
cmp [DWORD PTR esi],SLOT_VACANT ; test for unused spans due to clipping
|
||||
je ??skip_span
|
||||
xor ecx,ecx
|
||||
xor edx,edx
|
||||
mov cx,[WORD PTR esi]
|
||||
mov dx,[WORD PTR esi + 2]
|
||||
sub ecx,edx
|
||||
push edi
|
||||
jns short ??not_negative_count
|
||||
add edi,ecx
|
||||
neg ecx ; ecx = span width
|
||||
|
||||
??not_negative_count:
|
||||
add edi,edx ; edi = address of start of span
|
||||
cmp ecx,OPTIMAL_BYTE_COPY ; does span width justify DWORD copies?
|
||||
jl short ??byte_copy
|
||||
mov edx,ecx
|
||||
mov ecx,edi
|
||||
and ecx,3 ; if (ecx == 0) edi is already
|
||||
jz short ??dword_copy_no_alignment ; DWORD aligned
|
||||
xor ecx,3
|
||||
inc ecx ; ecx = number of pixels before alignment
|
||||
sub edx,ecx
|
||||
rep stosb
|
||||
|
||||
??dword_copy_no_alignment:
|
||||
mov ecx,edx ; ecx = remaining pixels on span
|
||||
shr ecx,2 ; copy (ecx / 4) DWORDS
|
||||
rep stosd
|
||||
mov ecx,edx
|
||||
and ecx,3 ; ecx = remaining pixels on span
|
||||
|
||||
??byte_copy:
|
||||
rep stosb ; byte copy remaining pixels on span
|
||||
pop edi
|
||||
|
||||
??skip_span:
|
||||
add edi,[bpr] ; edi = address of start of next scanline
|
||||
add esi,4 ; esi = address of next span
|
||||
dec ebx
|
||||
jge short ??quad_fill_loop ; is span count >= 0?
|
||||
|
||||
??abort_fill_quad:
|
||||
ret
|
||||
|
||||
|
||||
;*==================================================================
|
||||
;* This is the section that "pushes" the edge into bounds.
|
||||
;* I have marked the section with PORTABLE start and end to signify
|
||||
;* how much of this routine is 100% portable between graphics modes.
|
||||
;* It was just as easy to have variables as it would be for constants
|
||||
;* so the global vars clip_min_x, clip_min_y, clip_max_x, clip_max_y
|
||||
;* are used to clip the edge (default is the screen).
|
||||
;* PORTABLE start.
|
||||
;*==================================================================
|
||||
|
||||
|
||||
;*==================================================================
|
||||
;* Clip an edge against the viewport.
|
||||
;*==================================================================
|
||||
??clip_and_scan_convert:
|
||||
call NEAR PTR ??set_left_right_bits
|
||||
xchg eax,ecx
|
||||
xchg ebx,edx
|
||||
mov edi,esi
|
||||
call NEAR PTR ??set_left_right_bits
|
||||
mov [clip_var],edi
|
||||
or [clip_var],esi
|
||||
jz ??clip_up_down ; trivial acceptance?
|
||||
test edi,esi
|
||||
jne ??exit ; trivial rejection?
|
||||
shl esi,2
|
||||
call [DWORD PTR cs:??clip_tbl+esi]
|
||||
xchg eax,ecx
|
||||
xchg ebx,edx
|
||||
shl edi,2
|
||||
call [DWORD PTR cs:??clip_tbl+edi]
|
||||
|
||||
??clip_up_down:
|
||||
call NEAR PTR ??set_up_down_bits
|
||||
xchg eax,ecx
|
||||
xchg ebx,edx
|
||||
mov edi,esi
|
||||
call NEAR PTR ??set_up_down_bits
|
||||
mov [clip_var],edi
|
||||
or [clip_var],esi
|
||||
jz ??scan_convert ; trivial acceptance?
|
||||
test edi,esi
|
||||
jne ??exit ; trivial rejection?
|
||||
shl esi,2
|
||||
call [DWORD PTR cs:??clip_tbl+esi]
|
||||
xchg eax,ecx
|
||||
xchg ebx,edx
|
||||
shl edi,2
|
||||
call [DWORD PTR cs:??clip_tbl+edi]
|
||||
jmp ??scan_convert
|
||||
|
||||
|
||||
;*==================================================================
|
||||
;* Subroutine table for clipping conditions.
|
||||
;*==================================================================
|
||||
??clip_tbl DD ??nada,??a_lft,??a_rgt,??nada
|
||||
DD ??a_up,??nada,??nada,??nada
|
||||
DD ??a_dwn
|
||||
|
||||
|
||||
;*==================================================================
|
||||
;* Subroutines for clipping conditions.
|
||||
;*==================================================================
|
||||
??nada:
|
||||
retn
|
||||
|
||||
??a_up:
|
||||
mov esi,[clip_min_y]
|
||||
call NEAR PTR ??clip_vert
|
||||
retn
|
||||
|
||||
??a_dwn:
|
||||
mov esi,[clip_max_y]
|
||||
call NEAR PTR ??clip_vert
|
||||
retn
|
||||
|
||||
??a_lft:
|
||||
mov esi,[clip_min_x]
|
||||
call NEAR PTR ??clip_horiz
|
||||
push ebx
|
||||
mov esi,[left_clip_index]
|
||||
cmp ebx,[clip_min_y]
|
||||
jge ??no_left_min_clip
|
||||
mov ebx,[clip_min_y]
|
||||
|
||||
??no_left_min_clip:
|
||||
cmp ebx,[clip_max_y]
|
||||
jle ??no_left_max_clip
|
||||
mov ebx,[clip_max_y]
|
||||
|
||||
??no_left_max_clip:
|
||||
mov [left_clip_base + esi],ebx ; a left edge will be generated
|
||||
mov [left_clip_index],4 ; store off yb
|
||||
pop ebx
|
||||
retn
|
||||
|
||||
??a_rgt:
|
||||
mov esi,[clip_max_x]
|
||||
call NEAR PTR ??clip_horiz
|
||||
push ebx
|
||||
mov esi,[right_clip_index]
|
||||
cmp ebx,[clip_min_y]
|
||||
jge ??no_right_min_clip
|
||||
mov ebx,[clip_min_y]
|
||||
|
||||
??no_right_min_clip:
|
||||
cmp ebx,[clip_max_y]
|
||||
jle ??no_right_max_clip
|
||||
mov ebx,[clip_max_y]
|
||||
|
||||
??no_right_max_clip:
|
||||
mov [right_clip_base + esi],ebx ; a right edge will be generated
|
||||
mov [right_clip_index],4 ; store off yb
|
||||
pop ebx
|
||||
retn
|
||||
|
||||
|
||||
;*==================================================================
|
||||
;* Clip a line against a horizontal edge at clip_y.
|
||||
;* (eax,ebx) = (xa,ya), (ecx,edx) = (xb,yb)
|
||||
;* xa' = xa+[(clip_y-ya)(xb-xa)/(yb-ya)]
|
||||
;* ya' = clip_y
|
||||
;*==================================================================
|
||||
??clip_vert:
|
||||
push edx
|
||||
push eax
|
||||
mov [clip_var],edx ; clip_var = yb
|
||||
sub [clip_var],ebx ; clip_var = (yb-ya)
|
||||
neg eax ; eax = -xa
|
||||
add eax,ecx ; eax = (xb-xa)
|
||||
mov edx,esi ; edx = clip_y
|
||||
sub edx,ebx ; edx = (clip_y-ya)
|
||||
imul edx ; eax = (clip_y-ya)(xb-xa)
|
||||
idiv [clip_var] ; eax = (clip_y-ya)(xb-xa)/(yb-ya)
|
||||
pop edx
|
||||
add eax,edx ; eax = xa+[(clip_y-ya)(xb-xa)/(yb-ya)]
|
||||
pop edx
|
||||
mov ebx,esi ; ebx = clip_y
|
||||
retn
|
||||
|
||||
|
||||
;*==================================================================
|
||||
;* Clip a line against a vertical edge at clip_x.
|
||||
;* (eax,ebxx) = (xa,ya), (ecx,edxx) = (xb,yb)
|
||||
;* ya' = ya+[(clip_x-xa)(yb-ya)/(xb-xa)]
|
||||
;* xa' = clip_x
|
||||
;*==================================================================
|
||||
??clip_horiz:
|
||||
push edx
|
||||
mov [clip_var],ecx ; clip_var = xb
|
||||
sub [clip_var],eax ; clip_var = (xb-xa)
|
||||
sub edx,ebx ; edx = (yb-ya)
|
||||
neg eax ; eax = -xa
|
||||
add eax,esi ; eax = (clip_x-xa)
|
||||
imul edx ; eax = (clip_x-xa)(yb-ya)
|
||||
idiv [clip_var] ; eax = (clip_x-xa)(yb-ya)/(xb-xa)
|
||||
add ebx,eax ; ebx = ya+[(clip_x-xa)(yb-ya)/(xb-xa)]
|
||||
pop edx
|
||||
mov eax,esi ; eax = clip_x
|
||||
retn
|
||||
|
||||
|
||||
;*==================================================================
|
||||
;* Set the condition bits for the subroutine table.
|
||||
;*==================================================================
|
||||
??set_left_right_bits:
|
||||
xor esi,esi
|
||||
cmp eax,[clip_min_x] ; if x >= left its not left
|
||||
jge short ??a_not_left
|
||||
or esi,1
|
||||
|
||||
??a_not_left:
|
||||
cmp eax,[clip_max_x] ; if x <= right its not right
|
||||
jle short ??a_not_right
|
||||
or esi,2
|
||||
|
||||
??a_not_right:
|
||||
retn
|
||||
|
||||
??set_up_down_bits:
|
||||
xor esi,esi
|
||||
cmp ebx,[clip_min_y] ; if y >= top its not up
|
||||
jge short ??a_not_up
|
||||
or esi,4
|
||||
|
||||
??a_not_up:
|
||||
cmp ebx,[clip_max_y] ; if y <= bottom its not down
|
||||
jle short ??a_not_down
|
||||
or esi,8
|
||||
|
||||
??a_not_down:
|
||||
retn
|
||||
|
||||
|
||||
;*==================================================================
|
||||
;* PORTABLE end.
|
||||
;*==================================================================
|
||||
|
||||
;*==================================================================
|
||||
;* Scan convert an edge.
|
||||
;* (eax,ebx) = (xa,ya), (ecx,edx) = (xb,yb)
|
||||
;*==================================================================
|
||||
??scan_convert:
|
||||
cmp ebx,edx
|
||||
je ??exit ; if (ya == yb) don't scan convert
|
||||
jl short ??no_swap ; if (ya < yb) swap vertices
|
||||
xchg eax,ecx
|
||||
xchg ebx,edx
|
||||
|
||||
??no_swap:
|
||||
sub edx,ebx ; edx = (yb - ya)
|
||||
sub ebx,[scanline_min]
|
||||
sal ebx,2
|
||||
add ebx,[span_buff] ; ebx = span_buff + 4(ya - clip_min_y)
|
||||
sub ecx,eax ; ecx = (xb - xa)
|
||||
je ??v_scan ; if the edge is vertical use a
|
||||
; special case routine
|
||||
push eax
|
||||
mov eax,ecx ; eax = (xb - xa)
|
||||
mov ecx,edx ; ecx = (yb - ya)
|
||||
sal edx,1
|
||||
mov [realignment],edx ; realignment = 2(yb - ya)
|
||||
cwd
|
||||
idiv cx
|
||||
cwde
|
||||
movsx edx,dx
|
||||
mov edi,eax ; edi = (xb - xa) / (yb - ya)
|
||||
mov esi,edx
|
||||
mov edx,ecx
|
||||
pop eax ; eax = xa
|
||||
neg edx ; edx = -(yb - ya)
|
||||
sal esi,1 ; esi = 2[(xb - xa) % (yb - ya)]
|
||||
jns short ??r_scan ; scan to the left or right?
|
||||
neg esi
|
||||
|
||||
;*==================================================================
|
||||
;* Edge scan conversion DDA moving down and to the left.
|
||||
;* eax = xpos, ebx = span to reference
|
||||
;*==================================================================
|
||||
cmp ebx,[span_buff]
|
||||
jg ??l_scan_convert
|
||||
|
||||
??l_scan_convert_loop:
|
||||
cmp [DWORD PTR ebx],SLOT_VACANT ; if the left slot of span is
|
||||
jne short ??l_next_slot ; vacant fill it with xpos
|
||||
mov [ebx],ax
|
||||
|
||||
??l_next_slot:
|
||||
mov [ebx + 2],ax ; otherwise fill the right slot
|
||||
; with xpos
|
||||
??l_scan_convert:
|
||||
dec ecx
|
||||
jl short ??exit
|
||||
add ebx,4
|
||||
add eax,edi
|
||||
add edx,esi
|
||||
jle short ??l_scan_convert_loop
|
||||
dec eax
|
||||
sub edx,[realignment]
|
||||
jmp ??l_scan_convert_loop
|
||||
|
||||
|
||||
;*==================================================================
|
||||
;* Edge scan conversion DDA moving down and to the right.
|
||||
;* eax = xpos, ebx = span to reference
|
||||
;*==================================================================
|
||||
??r_scan:
|
||||
cmp ebx,[span_buff]
|
||||
jg ??r_scan_convert
|
||||
|
||||
??r_scan_convert_loop:
|
||||
cmp [DWORD PTR ebx],SLOT_VACANT ; if the left slot of span is
|
||||
jne short ??r_next_slot ; vacant fill it with xpos
|
||||
mov [ebx],ax
|
||||
|
||||
??r_next_slot:
|
||||
mov [ebx + 2],ax ; otherwise fill the right slot
|
||||
; with xpos
|
||||
??r_scan_convert:
|
||||
dec ecx
|
||||
jl short ??exit
|
||||
add ebx,4
|
||||
add eax,edi
|
||||
add edx,esi
|
||||
jle short ??r_scan_convert_loop
|
||||
inc eax
|
||||
sub edx,[realignment]
|
||||
jmp ??r_scan_convert_loop
|
||||
|
||||
|
||||
;*==================================================================
|
||||
;* Scan convert a vertical edge.
|
||||
;* eax = xpos, ebx = span to reference
|
||||
;*==================================================================
|
||||
??v_scan:
|
||||
cmp ebx,[span_buff]
|
||||
jg ??v_scan_convert
|
||||
|
||||
??v_scan_convert_loop:
|
||||
cmp [DWORD PTR ebx],SLOT_VACANT ; if the left slot of span is
|
||||
jne short ??v_next_slot ; vacant fill it with xpos
|
||||
mov [ebx],ax
|
||||
|
||||
??v_next_slot:
|
||||
mov [ebx + 2],ax ; otherwise fill the right slot
|
||||
; with xpos
|
||||
??v_scan_convert:
|
||||
add ebx,4
|
||||
dec edx
|
||||
jge ??v_scan_convert_loop
|
||||
|
||||
??exit:
|
||||
retn
|
||||
|
||||
ENDP Buffer_Fill_Quad
|
||||
|
||||
END
|
275
WIN32LIB/DRAWBUFF/FILLRECT.ASM
Normal file
275
WIN32LIB/DRAWBUFF/FILLRECT.ASM
Normal file
@@ -0,0 +1,275 @@
|
||||
;
|
||||
; 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 : GraphicViewPortClass *
|
||||
;* *
|
||||
;* File Name : CLEAR.ASM *
|
||||
;* *
|
||||
;* Programmer : Phil Gorrow *
|
||||
;* *
|
||||
;* Start Date : June 7, 1994 *
|
||||
;* *
|
||||
;* Last Update : June 7, 1994 [PWG] *
|
||||
;* *
|
||||
;*-------------------------------------------------------------------------*
|
||||
;* Functions: *
|
||||
;* GVPC::Fill_Rect -- draws a filled rectangle to a graphics buffer *
|
||||
;* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - *
|
||||
|
||||
IDEAL
|
||||
P386
|
||||
MODEL USE32 FLAT
|
||||
|
||||
INCLUDE ".\drawbuff.inc"
|
||||
INCLUDE ".\gbuffer.inc"
|
||||
|
||||
|
||||
CODESEG
|
||||
|
||||
;***************************************************************************
|
||||
;* GVPC::FILL_RECT -- Fills a rectangular region of a graphic view port *
|
||||
;* *
|
||||
;* INPUT: WORD the left hand x pixel position of region *
|
||||
;* WORD the upper x pixel position of region *
|
||||
;* WORD the right hand x pixel position of region *
|
||||
;* WORD the lower x pixel position of region *
|
||||
;* UBYTE the color (optional) to clear the view port to *
|
||||
;* *
|
||||
;* OUTPUT: none *
|
||||
;* *
|
||||
;* NOTE: This function is optimized to handle viewport with no XAdd *
|
||||
;* value. It also handles DWORD aligning the destination *
|
||||
;* when speed can be gained by doing it. *
|
||||
;* HISTORY: *
|
||||
;* 06/07/1994 PWG : Created. *
|
||||
;*=========================================================================*
|
||||
PROC Buffer_Fill_Rect C near
|
||||
USES eax,ebx,ecx,edx,esi,edi,ebp
|
||||
|
||||
;*===================================================================
|
||||
;* define the arguements that our function takes.
|
||||
;*===================================================================
|
||||
ARG this_object:DWORD ; this is a member function
|
||||
ARG x1_pixel:WORD
|
||||
ARG y1_pixel:WORD
|
||||
ARG x2_pixel:WORD
|
||||
ARG y2_pixel:WORD
|
||||
ARG color:BYTE ; what color should we clear to
|
||||
;*===================================================================
|
||||
; Define some locals so that we can handle things quickly
|
||||
;*===================================================================
|
||||
LOCAL VPwidth:DWORD ; the width of the viewport
|
||||
LOCAL VPheight:DWORD ; the height of the viewport
|
||||
LOCAL VPxadd:DWORD ; the additional x offset of viewport
|
||||
LOCAL VPbpr:DWORD ; the number of bytes per row of viewport
|
||||
|
||||
;*===================================================================
|
||||
;* save off the viewport characteristics on the stack
|
||||
;*===================================================================
|
||||
mov ebx,[this_object] ; get a pointer to viewport
|
||||
mov eax,[(GraphicViewPort ebx).GVPWidth] ; get width from viewport
|
||||
mov ecx,[(GraphicViewPort ebx).GVPHeight] ; get height from viewport
|
||||
mov edx,[(GraphicViewPort ebx).GVPXAdd] ; get xadd from viewport
|
||||
add edx,[(GraphicViewPort ebx).GVPPitch] ; extra pitch of direct draw surface
|
||||
mov [VPwidth],eax ; store the width of locally
|
||||
mov [VPheight],ecx
|
||||
mov [VPxadd],edx
|
||||
add eax,edx
|
||||
mov [VPbpr],eax
|
||||
|
||||
;*===================================================================
|
||||
;* move the important parameters into local registers
|
||||
;*===================================================================
|
||||
movsx eax,[x1_pixel]
|
||||
movsx ebx,[y1_pixel]
|
||||
movsx ecx,[x2_pixel]
|
||||
movsx edx,[y2_pixel]
|
||||
|
||||
;*===================================================================
|
||||
;* Convert the x2 and y2 pixel to a width and height
|
||||
;*===================================================================
|
||||
cmp eax,ecx
|
||||
jl ??no_swap_x
|
||||
xchg eax,ecx
|
||||
|
||||
??no_swap_x:
|
||||
sub ecx,eax
|
||||
cmp ebx,edx
|
||||
jl ??no_swap_y
|
||||
xchg ebx,edx
|
||||
??no_swap_y:
|
||||
sub edx,ebx
|
||||
inc ecx
|
||||
inc edx
|
||||
|
||||
;*===================================================================
|
||||
;* Bounds check source X.
|
||||
;*===================================================================
|
||||
cmp eax, [VPwidth] ; compare with the max
|
||||
jge ??out ; starts off screen, then later
|
||||
jb short ??sx_done ; if it's not negative, it's ok
|
||||
|
||||
;------ Clip source X to left edge of screen.
|
||||
add ecx, eax ; Reduce width (add in negative src X).
|
||||
xor eax, eax ; Clip to left of screen.
|
||||
??sx_done:
|
||||
|
||||
;*===================================================================
|
||||
;* Bounds check source Y.
|
||||
;*===================================================================
|
||||
cmp ebx, [VPheight] ; compare with the max
|
||||
jge ??out ; starts off screen, then later
|
||||
jb short ??sy_done ; if it's not negative, it's ok
|
||||
|
||||
;------ Clip source Y to top edge of screen.
|
||||
add edx, ebx ; Reduce height (add in negative src Y).
|
||||
xor ebx, ebx ; Clip to top of screen.
|
||||
|
||||
??sy_done:
|
||||
;*===================================================================
|
||||
;* Bounds check width versus width of source and dest view ports
|
||||
;*===================================================================
|
||||
push ebx ; save off ebx for later use
|
||||
mov ebx,[VPwidth] ; get the source width
|
||||
sub ebx, eax ; Maximum allowed pixel width (given coordinates).
|
||||
sub ebx, ecx ; Pixel width undershoot.
|
||||
jns short ??width_ok ; if not signed no adjustment necessary
|
||||
add ecx, ebx ; Reduce width to screen limits.
|
||||
|
||||
??width_ok:
|
||||
pop ebx ; restore ebx to old value
|
||||
|
||||
;*===================================================================
|
||||
;* Bounds check height versus height of source view port
|
||||
;*===================================================================
|
||||
push eax ; save of eax for later use
|
||||
mov eax, [VPheight] ; get the source height
|
||||
sub eax, ebx ; Maximum allowed pixel height (given coordinates).
|
||||
sub eax, edx ; Pixel height undershoot.
|
||||
jns short ??height_ok ; if not signed no adjustment necessary
|
||||
add edx, eax ; Reduce height to screen limits.
|
||||
??height_ok:
|
||||
pop eax ; restore eax to old value
|
||||
|
||||
;*===================================================================
|
||||
;* Perform the last minute checks on the width and height
|
||||
;*===================================================================
|
||||
or ecx,ecx
|
||||
jz ??out
|
||||
|
||||
or edx,edx
|
||||
jz ??out
|
||||
|
||||
cmp ecx,[VPwidth]
|
||||
ja ??out
|
||||
cmp edx,[VPheight]
|
||||
ja ??out
|
||||
|
||||
;*===================================================================
|
||||
;* Get the offset into the virtual viewport.
|
||||
;*===================================================================
|
||||
xchg edi,eax ; save off the contents of eax
|
||||
xchg esi,edx ; and edx for size test
|
||||
mov eax,ebx ; move the y pixel into eax
|
||||
mul [VPbpr] ; multiply by bytes per row
|
||||
add edi,eax ; add the result into the x position
|
||||
mov ebx,[this_object]
|
||||
add edi,[(GraphicViewPort ebx).GVPOffset]
|
||||
|
||||
mov edx,esi ; restore edx back to real value
|
||||
mov eax,ecx ; store total width in ecx
|
||||
sub eax,[VPwidth] ; modify xadd value to include clipped
|
||||
sub [VPxadd],eax ; width bytes (subtract a negative number)
|
||||
|
||||
;*===================================================================
|
||||
; Convert the color byte to a DWORD for fast storing
|
||||
;*===================================================================
|
||||
mov al,[color] ; get color to clear to
|
||||
mov ah,al ; extend across WORD
|
||||
mov ebx,eax ; extend across DWORD in
|
||||
shl eax,16 ; several steps
|
||||
mov ax,bx
|
||||
|
||||
;*===================================================================
|
||||
; If there is no row offset then adjust the width to be the size of
|
||||
; the entire viewport and adjust the height to be 1
|
||||
;*===================================================================
|
||||
mov esi,[VPxadd]
|
||||
or esi,esi ; set the flags for esi
|
||||
jnz ??row_by_row_aligned ; and act on them
|
||||
|
||||
xchg eax,ecx ; switch bit pattern and width
|
||||
mul edx ; multiply by edx to get size
|
||||
xchg eax,ecx ; switch size and bit pattern
|
||||
mov edx,1 ; only 1 line off view port size to do
|
||||
|
||||
;*===================================================================
|
||||
; Find out if we should bother to align the row.
|
||||
;*===================================================================
|
||||
??row_by_row_aligned:
|
||||
mov ebp,ecx ; width saved in ebp
|
||||
cmp ecx,OPTIMAL_BYTE_COPY ; is it worth aligning them?
|
||||
jl ??row_by_row ; if not then skip
|
||||
|
||||
;*===================================================================
|
||||
; Figure out the alignment offset if there is any
|
||||
;*===================================================================
|
||||
mov ebx,edi ; get output position
|
||||
and ebx,3 ; is there a remainder?
|
||||
jz ??aligned_loop ; if not we are aligned
|
||||
xor ebx,3 ; find number of align bytes
|
||||
inc ebx ; this number is off by one
|
||||
sub ebp,ebx ; subtract from width
|
||||
|
||||
;*===================================================================
|
||||
; Now that we have the alignment offset copy each row
|
||||
;*===================================================================
|
||||
??aligned_loop:
|
||||
mov ecx,ebx ; get number of bytes to align
|
||||
rep stosb ; and move them over
|
||||
mov ecx,ebp ; get number of aligned bytes
|
||||
shr ecx,2 ; convert to DWORDS
|
||||
rep stosd ; and move them over
|
||||
mov ecx,ebp ; get number of aligned bytes
|
||||
and ecx,3 ; find the remainder
|
||||
rep stosb ; and move it over
|
||||
add edi,esi ; fix the line offset
|
||||
dec edx ; decrement the height
|
||||
jnz ??aligned_loop ; if more to do than do it
|
||||
jmp ??exit ; we are all done
|
||||
|
||||
;*===================================================================
|
||||
; If not enough bytes to bother aligning copy each line across a byte
|
||||
; at a time.
|
||||
;*===================================================================
|
||||
??row_by_row:
|
||||
mov ecx,ebp ; get total width in bytes
|
||||
rep stosb ; store the width
|
||||
add edi,esi ; handle the xadd
|
||||
dec edx ; decrement the height
|
||||
jnz ??row_by_row ; if any left then next line
|
||||
??out:
|
||||
??exit:
|
||||
ret
|
||||
ENDP Buffer_Fill_Rect
|
||||
|
||||
END
|
106
WIN32LIB/DRAWBUFF/FTPUTPIX.ASM
Normal file
106
WIN32LIB/DRAWBUFF/FTPUTPIX.ASM
Normal file
@@ -0,0 +1,106 @@
|
||||
;
|
||||
; 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 : GraphicViewPortClass *
|
||||
;* *
|
||||
;* File Name : GETPIXEL.ASM *
|
||||
;* *
|
||||
;* Programmer : Phil Gorrow *
|
||||
;* *
|
||||
;* Start Date : June 7, 1994 *
|
||||
;* *
|
||||
;* Last Update : June 7, 1994 [PWG] *
|
||||
;* *
|
||||
;*-------------------------------------------------------------------------*
|
||||
;* Functions: *
|
||||
;* VVPC::Buffer_Get_Pixel -- get the colour of a pixel at given coords *
|
||||
;* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - *
|
||||
|
||||
IDEAL
|
||||
P386
|
||||
MODEL USE32 FLAT
|
||||
|
||||
INCLUDE ".\drawbuff.inc"
|
||||
INCLUDE ".\gbuffer.inc"
|
||||
|
||||
|
||||
CODESEG
|
||||
|
||||
;***************************************************************************
|
||||
;* VVPC::GET_PIXEL -- Gets a pixel from the current view port *
|
||||
;* *
|
||||
;* INPUT: WORD the x pixel on the screen. *
|
||||
;* WORD the y pixel on the screen. *
|
||||
;* *
|
||||
;* OUTPUT: UBYTE the pixel at the specified location *
|
||||
;* *
|
||||
;* WARNING: If pixel is to be placed outside of the viewport then *
|
||||
;* this routine will abort. *
|
||||
;* *
|
||||
;* HISTORY: *
|
||||
;* 06/07/1994 PWG : Created. *
|
||||
;*=========================================================================*
|
||||
PROC Buffer_Get_Pixel C near
|
||||
USES ebx,ecx,edx,edi
|
||||
|
||||
ARG this_object:DWORD ; this is a member function
|
||||
ARG x_pixel:DWORD ; x position of pixel to set
|
||||
ARG y_pixel:DWORD ; y position of pixel to set
|
||||
|
||||
;*===================================================================
|
||||
; Get the viewport information and put bytes per row in ecx
|
||||
;*===================================================================
|
||||
mov ebx,[this_object] ; get a pointer to viewport
|
||||
xor eax,eax
|
||||
mov edi,[(GraphicViewPort ebx).GVPOffset] ; get the correct offset
|
||||
mov ecx,[(GraphicViewPort ebx).GVPHeight] ; edx = height of viewport
|
||||
mov edx,[(GraphicViewPort ebx).GVPWidth] ; ecx = width of viewport
|
||||
|
||||
;*===================================================================
|
||||
; Verify that the X pixel offset if legal
|
||||
;*===================================================================
|
||||
mov eax,[x_pixel] ; find the x position
|
||||
cmp eax,edx ; is it out of bounds
|
||||
jae short ??exit ; if so then get out
|
||||
add edi,eax ; otherwise add in offset
|
||||
|
||||
;*===================================================================
|
||||
; Verify that the Y pixel offset if legal
|
||||
;*===================================================================
|
||||
mov eax,[y_pixel] ; get the y position
|
||||
cmp eax,ecx ; is it out of bounds
|
||||
jae ??exit ; if so then get out
|
||||
add edx,[(GraphicViewPort ebx).GVPXAdd] ; otherwise find bytes per row
|
||||
add edx,[(GraphicViewPort ebx).GVPPitch] ; otherwise find bytes per row
|
||||
mul edx ; offset = bytes per row * y
|
||||
add edi,eax ; add it into the offset
|
||||
|
||||
;*===================================================================
|
||||
; Write the pixel to the screen
|
||||
;*===================================================================
|
||||
xor eax,eax ; clear the word
|
||||
mov al,[edi] ; read in the pixel
|
||||
??exit:
|
||||
ret
|
||||
ENDP Buffer_Get_Pixel
|
||||
|
||||
END
|
711
WIN32LIB/DRAWBUFF/GBUFFER.CPP
Normal file
711
WIN32LIB/DRAWBUFF/GBUFFER.CPP
Normal file
@@ -0,0 +1,711 @@
|
||||
/*
|
||||
** 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 A S S O C I A T E S **
|
||||
***************************************************************************
|
||||
* *
|
||||
* Project Name : Westwood 32 bit Library *
|
||||
* *
|
||||
* File Name : GBUFFER.CPP *
|
||||
* *
|
||||
* Programmer : Phil W. Gorrow *
|
||||
* *
|
||||
* Start Date : May 3, 1994 *
|
||||
* *
|
||||
* Last Update : October 9, 1995 [] *
|
||||
* *
|
||||
*-------------------------------------------------------------------------*
|
||||
* Functions: *
|
||||
* VVPC::VirtualViewPort -- Default constructor for a virtual viewport *
|
||||
* VVPC:~VirtualViewPortClass -- Destructor for a virtual viewport *
|
||||
* VVPC::Clear -- Clears a graphic page to correct color *
|
||||
* VBC::VideoBufferClass -- Lowlevel constructor for video buffer class *
|
||||
* GVPC::Change -- Changes position and size of a Graphic View Port *
|
||||
* VVPC::Change -- Changes position and size of a Video View Port *
|
||||
* Set_Logic_Page -- Sets LogicPage to new buffer *
|
||||
* GBC::DD_Init -- Inits a direct draw surface for a GBC *
|
||||
* GBC::Init -- Core function responsible for initing a GBC *
|
||||
* GBC::Lock -- Locks a Direct Draw Surface *
|
||||
* GBC::Unlock -- Unlocks a direct draw surface *
|
||||
* GBC::GraphicBufferClass -- Default constructor (requires explicit init)*
|
||||
* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
|
||||
|
||||
#ifndef GBUFFER_H
|
||||
#include "gbuffer.h"
|
||||
#include "misc.h"
|
||||
#endif
|
||||
#pragma inline
|
||||
|
||||
int TotalLocks;
|
||||
BOOL AllowHardwareBlitFills = TRUE;
|
||||
|
||||
|
||||
//int CacheAllowed;
|
||||
|
||||
/*=========================================================================*/
|
||||
/* The following PRIVATE functions are in this file: */
|
||||
/*=========================================================================*/
|
||||
|
||||
|
||||
/*= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =*/
|
||||
|
||||
|
||||
|
||||
/***************************************************************************
|
||||
* GVPC::GRAPHICVIEWPORTCLASS -- Constructor for basic view port class *
|
||||
* m *
|
||||
* INPUT: GraphicBufferClass * gbuffer - buffer to attach to *
|
||||
* int x - x offset into buffer *
|
||||
* int y - y offset into buffer *
|
||||
* int w - view port width in pixels *
|
||||
* int h - view port height in pixels *
|
||||
* *
|
||||
* OUTPUT: Constructors may not have a return value *
|
||||
* *
|
||||
* HISTORY: *
|
||||
* 05/09/1994 PWG : Created. *
|
||||
*=========================================================================*/
|
||||
GraphicViewPortClass::GraphicViewPortClass(GraphicBufferClass *gbuffer, int x, int y, int w, int h) :
|
||||
LockCount(0),
|
||||
GraphicBuff(NULL)
|
||||
{
|
||||
Attach(gbuffer, x, y, w, h);
|
||||
}
|
||||
|
||||
/***************************************************************************
|
||||
* GVPC::GRAPHICVIEWPORTCLASS -- Default constructor for view port class *
|
||||
* *
|
||||
* INPUT: none *
|
||||
* *
|
||||
* OUTPUT: none *
|
||||
* *
|
||||
* HISTORY: *
|
||||
* 05/09/1994 PWG : Created. *
|
||||
*=========================================================================*/
|
||||
GraphicViewPortClass::GraphicViewPortClass(void)
|
||||
{
|
||||
}
|
||||
|
||||
/***************************************************************************
|
||||
* GVPC::~GRAPHICVIEWPORTCLASS -- Destructor for GraphicViewPortClass *
|
||||
* *
|
||||
* INPUT: none *
|
||||
* *
|
||||
* OUTPUT: A destructor may not return a value. *
|
||||
* *
|
||||
* HISTORY: *
|
||||
* 05/10/1994 PWG : Created. *
|
||||
*=========================================================================*/
|
||||
GraphicViewPortClass::~GraphicViewPortClass(void)
|
||||
{
|
||||
Offset = 0;
|
||||
Width = 0; // Record width of Buffer
|
||||
Height = 0; // Record height of Buffer
|
||||
XAdd = 0; // Record XAdd of Buffer
|
||||
XPos = 0; // Record XPos of Buffer
|
||||
YPos = 0; // Record YPos of Buffer
|
||||
Pitch = 0; // Record width of Buffer
|
||||
IsDirectDraw = FALSE;
|
||||
LockCount = 0;
|
||||
GraphicBuff = NULL;
|
||||
}
|
||||
|
||||
/***************************************************************************
|
||||
* GVPC::ATTACH -- Attaches a viewport to a buffer class *
|
||||
* *
|
||||
* INPUT: GraphicBufferClass *g_buff - pointer to gbuff to attach to *
|
||||
* int x - x position to attach to *
|
||||
* int y - y position to attach to *
|
||||
* int w - width of the view port *
|
||||
* int h - height of the view port *
|
||||
* *
|
||||
* OUTPUT: none *
|
||||
* *
|
||||
* HISTORY: *
|
||||
* 05/10/1994 PWG : Created. *
|
||||
*=========================================================================*/
|
||||
void GraphicViewPortClass::Attach(GraphicBufferClass *gbuffer, int x, int y, int w, int h)
|
||||
{
|
||||
/*======================================================================*/
|
||||
/* Can not attach a Graphic View Port if it is actually the physical */
|
||||
/* representation of a Graphic Buffer. */
|
||||
/*======================================================================*/
|
||||
if (this == Get_Graphic_Buffer()) {
|
||||
return;
|
||||
}
|
||||
|
||||
/*======================================================================*/
|
||||
/* Verify that the x and y coordinates are valid and placed within the */
|
||||
/* physical buffer. */
|
||||
/*======================================================================*/
|
||||
if (x < 0) // you cannot place view port off
|
||||
x = 0; // the left edge of physical buf
|
||||
if (x >= gbuffer->Get_Width()) // you cannot place left edge off
|
||||
x = gbuffer->Get_Width() - 1; // the right edge of physical buf
|
||||
if (y < 0) // you cannot place view port off
|
||||
y = 0; // the top edge of physical buf
|
||||
if (y >= gbuffer->Get_Height()) // you cannot place view port off
|
||||
y = gbuffer->Get_Height() - 1; // bottom edge of physical buf
|
||||
|
||||
/*======================================================================*/
|
||||
/* Adjust the width and height of necessary */
|
||||
/*======================================================================*/
|
||||
if (x + w > gbuffer->Get_Width()) // if the x plus width is larger
|
||||
w = gbuffer->Get_Width() - x; // than physical, fix width
|
||||
|
||||
if (y + h > gbuffer->Get_Height()) // if the y plus height is larger
|
||||
h = gbuffer->Get_Height() - y; // than physical, fix height
|
||||
|
||||
/*======================================================================*/
|
||||
/* Get a pointer to the top left edge of the buffer. */
|
||||
/*======================================================================*/
|
||||
Offset = gbuffer->Get_Offset() + ((gbuffer->Get_Width()+gbuffer->Get_Pitch()) * y) + x;
|
||||
|
||||
/*======================================================================*/
|
||||
/* Copy over all of the variables that we need to store. */
|
||||
/*======================================================================*/
|
||||
XPos = x;
|
||||
YPos = y;
|
||||
XAdd = gbuffer->Get_Width() - w;
|
||||
Width = w;
|
||||
Height = h;
|
||||
Pitch = gbuffer->Get_Pitch();
|
||||
GraphicBuff = gbuffer;
|
||||
IsDirectDraw= gbuffer->IsDirectDraw;
|
||||
}
|
||||
|
||||
|
||||
/***************************************************************************
|
||||
* GVPC::CHANGE -- Changes position and size of a Graphic View Port *
|
||||
* *
|
||||
* INPUT: int the new x pixel position of the graphic view port *
|
||||
* int the new y pixel position of the graphic view port *
|
||||
* int the new width of the viewport in pixels *
|
||||
* int the new height of the viewport in pixels *
|
||||
* *
|
||||
* OUTPUT: BOOL whether the Graphic View Port could be sucessfully *
|
||||
* resized. *
|
||||
* *
|
||||
* WARNINGS: You may not resize a Graphic View Port which is derived *
|
||||
* from a Graphic View Port Buffer, *
|
||||
* *
|
||||
* HISTORY: *
|
||||
* 09/14/1994 SKB : Created. *
|
||||
*=========================================================================*/
|
||||
BOOL GraphicViewPortClass::Change(int x, int y, int w, int h)
|
||||
{
|
||||
/*======================================================================*/
|
||||
/* Can not change a Graphic View Port if it is actually the physical */
|
||||
/* representation of a Graphic Buffer. */
|
||||
/*======================================================================*/
|
||||
if (this == Get_Graphic_Buffer()) {
|
||||
return(FALSE);
|
||||
}
|
||||
|
||||
/*======================================================================*/
|
||||
/* Since there is no allocated information, just re-attach it to the */
|
||||
/* existing graphic buffer as if we were creating the */
|
||||
/* GraphicViewPort. */
|
||||
/*======================================================================*/
|
||||
Attach(Get_Graphic_Buffer(), x, y, w, h);
|
||||
return(TRUE);
|
||||
}
|
||||
|
||||
|
||||
/***************************************************************************
|
||||
* GBC::DD_INIT -- Inits a direct draw surface for a GBC *
|
||||
* *
|
||||
* INPUT: none *
|
||||
* *
|
||||
* OUTPUT: none *
|
||||
* *
|
||||
* HISTORY: *
|
||||
* 10/09/1995 : Created. *
|
||||
*=========================================================================*/
|
||||
void GraphicBufferClass::DD_Init(GBC_Enum flags)
|
||||
{
|
||||
//
|
||||
// Create the direct draw surface description
|
||||
//
|
||||
memset (&VideoSurfaceDescription , 0 , sizeof ( VideoSurfaceDescription ));
|
||||
|
||||
VideoSurfaceDescription.dwSize = sizeof( VideoSurfaceDescription );
|
||||
VideoSurfaceDescription.dwFlags = DDSD_CAPS;
|
||||
VideoSurfaceDescription.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE;
|
||||
|
||||
|
||||
if (!(flags & GBC_VISIBLE)) {
|
||||
VideoSurfaceDescription.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN;
|
||||
VideoSurfaceDescription.dwFlags |= DDSD_HEIGHT | DDSD_WIDTH;
|
||||
VideoSurfaceDescription.dwHeight = Height;
|
||||
VideoSurfaceDescription.dwWidth = Width;
|
||||
}
|
||||
|
||||
//
|
||||
// Need to set the DDSCAPS_MODEX flag if we want a 320 wide mode
|
||||
//
|
||||
if ( Width == 320 ) {
|
||||
VideoSurfaceDescription.ddsCaps.dwCaps |= DDSCAPS_MODEX;
|
||||
}
|
||||
|
||||
//
|
||||
// Call CreateSurface
|
||||
//
|
||||
DirectDrawObject->CreateSurface( &VideoSurfaceDescription , &VideoSurfacePtr , NULL);
|
||||
AllSurfaces.Add_DD_Surface (VideoSurfacePtr);
|
||||
|
||||
if ( GBC_VISIBLE & flags ){
|
||||
PaletteSurface=VideoSurfacePtr;
|
||||
}
|
||||
|
||||
Allocated = FALSE; // even if system alloced, dont flag it cuz
|
||||
// we dont want it freed.
|
||||
IsDirectDraw = TRUE; // flag it as a video surface
|
||||
Offset = NOT_LOCKED; // flag it as unavailable for reading or writing
|
||||
LockCount = 0; // surface is not locked
|
||||
}
|
||||
|
||||
|
||||
void GraphicBufferClass::Attach_DD_Surface (GraphicBufferClass * attach_buffer)
|
||||
{
|
||||
VideoSurfacePtr->AddAttachedSurface (attach_buffer->Get_DD_Surface());
|
||||
}
|
||||
|
||||
|
||||
/***************************************************************************
|
||||
* GBC::INIT -- Core function responsible for initing a GBC *
|
||||
* *
|
||||
* INPUT: int - the width in pixels of the GraphicBufferClass *
|
||||
* int - the heigh in pixels of the GraphicBufferClass *
|
||||
* void * - pointer to user supplied buffer (system will *
|
||||
* allocate space if buffer is NULL) *
|
||||
* long - size of the user provided buffer *
|
||||
* GBC_Enum - flags if this is defined as a direct draw *
|
||||
* surface *
|
||||
* *
|
||||
* OUTPUT: none *
|
||||
* *
|
||||
* HISTORY: *
|
||||
* 10/09/1995 : Created. *
|
||||
*=========================================================================*/
|
||||
void GraphicBufferClass::Init(int w, int h, void *buffer, long size, GBC_Enum flags)
|
||||
{
|
||||
Size = size; // find size of physical buffer
|
||||
Width = w; // Record width of Buffer
|
||||
Height = h; // Record height of Buffer
|
||||
|
||||
//
|
||||
// If the surface we are creating is a direct draw object then
|
||||
// we need to do a direct draw init. Otherwise we will do
|
||||
// a normal alloc.
|
||||
//
|
||||
if (flags & (GBC_VIDEOMEM | GBC_VISIBLE)) {
|
||||
DD_Init(flags);
|
||||
} else {
|
||||
if (buffer) { // if buffer is specified
|
||||
Buffer = (BYTE *)buffer; // point to it and mark
|
||||
Allocated = FALSE; // it as user allocated
|
||||
} else {
|
||||
if (!Size) Size = w*h;
|
||||
Buffer = new BYTE[Size]; // otherwise allocate it and
|
||||
Allocated = TRUE; // mark it system alloced
|
||||
}
|
||||
Offset = (long)Buffer; // Get offset to the buffer
|
||||
IsDirectDraw = FALSE;
|
||||
}
|
||||
|
||||
Pitch = 0; // Record width of Buffer
|
||||
XAdd = 0; // Record XAdd of Buffer
|
||||
XPos = 0; // Record XPos of Buffer
|
||||
YPos = 0; // Record YPos of Buffer
|
||||
GraphicBuff = this; // Get a pointer to our self
|
||||
}
|
||||
|
||||
|
||||
/***********************************************************************************************
|
||||
* GBC::Un_Init -- releases the video surface belonging to this gbuffer *
|
||||
* *
|
||||
* *
|
||||
* *
|
||||
* INPUT: Nothing *
|
||||
* *
|
||||
* OUTPUT: Nothing *
|
||||
* *
|
||||
* WARNINGS: None *
|
||||
* *
|
||||
* HISTORY: *
|
||||
* 6/6/96 12:44PM ST : Created *
|
||||
*=============================================================================================*/
|
||||
|
||||
void GraphicBufferClass::Un_Init (void)
|
||||
{
|
||||
if ( IsDirectDraw ){
|
||||
|
||||
if ( VideoSurfacePtr ){
|
||||
|
||||
while ( LockCount ){
|
||||
|
||||
if (VideoSurfacePtr->Unlock ( NULL ) == DDERR_SURFACELOST){
|
||||
if (Gbuffer_Focus_Loss_Function){
|
||||
Gbuffer_Focus_Loss_Function();
|
||||
}
|
||||
AllSurfaces.Restore_Surfaces();
|
||||
}
|
||||
}
|
||||
|
||||
AllSurfaces.Remove_DD_Surface (VideoSurfacePtr);
|
||||
VideoSurfacePtr->Release();
|
||||
VideoSurfacePtr = NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/***************************************************************************
|
||||
* GBC::GRAPHICBUFFERCLASS -- Default constructor (requires explicit init) *
|
||||
* *
|
||||
* INPUT: none *
|
||||
* *
|
||||
* OUTPUT: none *
|
||||
* *
|
||||
* HISTORY: *
|
||||
* 10/09/1995 : Created. *
|
||||
*=========================================================================*/
|
||||
GraphicBufferClass::GraphicBufferClass(void)
|
||||
{
|
||||
GraphicBuff = this; // Get a pointer to our self
|
||||
VideoSurfacePtr = NULL;
|
||||
memset(&VideoSurfaceDescription, 0, sizeof(DDSURFACEDESC));
|
||||
}
|
||||
|
||||
|
||||
/***************************************************************************
|
||||
* GBC::GRAPHICBUFFERCLASS -- Constructor for fixed size buffers *
|
||||
* *
|
||||
* INPUT: long size - size of the buffer to create *
|
||||
* int w - width of buffer in pixels (default = 320) *
|
||||
* int h - height of buffer in pixels (default = 200) *
|
||||
* void *buffer - a pointer to the buffer if any (optional) *
|
||||
* *
|
||||
* OUTPUT: *
|
||||
* *
|
||||
* WARNINGS: *
|
||||
* *
|
||||
* HISTORY: *
|
||||
* 05/13/1994 PWG : Created. *
|
||||
*=========================================================================*/
|
||||
GraphicBufferClass::GraphicBufferClass(int w, int h, void *buffer, long size)
|
||||
{
|
||||
Init(w, h, buffer, size, GBC_NONE);
|
||||
}
|
||||
/*=========================================================================*
|
||||
* GBC::GRAPHICBUFFERCLASS -- inline constructor for GraphicBufferClass *
|
||||
* *
|
||||
* INPUT: int w - width of buffer in pixels (default = 320) *
|
||||
* int h - height of buffer in pixels (default = 200) *
|
||||
* void *buffer - a pointer to the buffer if any (optional) *
|
||||
* *
|
||||
* OUTPUT: none *
|
||||
* *
|
||||
* HISTORY: *
|
||||
* 05/03/1994 PWG : Created. *
|
||||
*=========================================================================*/
|
||||
GraphicBufferClass::GraphicBufferClass(int w, int h, void *buffer)
|
||||
{
|
||||
Init(w, h, buffer, w * h, GBC_NONE);
|
||||
}
|
||||
|
||||
/*====================================================================================*
|
||||
* GBC::GRAPHICBUFFERCLASS -- contructor for GraphicsBufferClass with special flags *
|
||||
* *
|
||||
* INPUT: int w - width of buffer in pixels (default = 320) *
|
||||
* int h - height of buffer in pixels (default = 200) *
|
||||
* void *buffer - unused *
|
||||
* unsigned flags - flags for creation of special buffer types *
|
||||
* GBC_VISIBLE - buffer is a visible screen surface *
|
||||
* GBC_VIDEOMEM - buffer resides in video memory *
|
||||
* *
|
||||
* OUTPUT: none *
|
||||
* *
|
||||
* HISTORY: *
|
||||
* 09-21-95 04:19pm ST : Created *
|
||||
*====================================================================================*/
|
||||
GraphicBufferClass::GraphicBufferClass(int w, int h, GBC_Enum flags)
|
||||
{
|
||||
Init(w, h, NULL, w * h, flags);
|
||||
}
|
||||
|
||||
/*=========================================================================*
|
||||
* GBC::~GRAPHICBUFFERCLASS -- Destructor for the graphic buffer class *
|
||||
* *
|
||||
* INPUT: none *
|
||||
* *
|
||||
* OUTPUT: none *
|
||||
* *
|
||||
* HISTORY: *
|
||||
* 05/03/1994 PWG : Created. *
|
||||
*=========================================================================*/
|
||||
GraphicBufferClass::~GraphicBufferClass()
|
||||
{
|
||||
|
||||
//
|
||||
// Release the direct draw surface if it exists
|
||||
//
|
||||
Un_Init();
|
||||
}
|
||||
|
||||
|
||||
|
||||
/***************************************************************************
|
||||
* SET_LOGIC_PAGE -- Sets LogicPage to new buffer *
|
||||
* *
|
||||
* INPUT: GraphicBufferClass * the buffer we are going to set *
|
||||
* *
|
||||
* OUTPUT: GraphicBufferClass * the previous buffer type *
|
||||
* *
|
||||
* WARNINGS: *
|
||||
* *
|
||||
* HISTORY: *
|
||||
* 02/23/1995 PWG : Created. *
|
||||
*=========================================================================*/
|
||||
GraphicViewPortClass *Set_Logic_Page(GraphicViewPortClass *ptr)
|
||||
{
|
||||
GraphicViewPortClass *old = LogicPage;
|
||||
LogicPage = ptr;
|
||||
return(old);
|
||||
}
|
||||
|
||||
/***************************************************************************
|
||||
* SET_LOGIC_PAGE -- Sets LogicPage to new buffer *
|
||||
* *
|
||||
* INPUT: GraphicBufferClass & the buffer we are going to set *
|
||||
* *
|
||||
* OUTPUT: GraphicBufferClass * the previous buffer type *
|
||||
* *
|
||||
* WARNINGS: *
|
||||
* *
|
||||
* HISTORY: *
|
||||
* 02/23/1995 PWG : Created. *
|
||||
*=========================================================================*/
|
||||
GraphicViewPortClass *Set_Logic_Page(GraphicViewPortClass &ptr)
|
||||
{
|
||||
GraphicViewPortClass *old = LogicPage;
|
||||
LogicPage = &ptr;
|
||||
return(old);
|
||||
}
|
||||
|
||||
|
||||
/***************************************************************************
|
||||
* GBC::LOCK -- Locks a Direct Draw Surface *
|
||||
* *
|
||||
* INPUT: none *
|
||||
* *
|
||||
* OUTPUT: none *
|
||||
* *
|
||||
* HISTORY: *
|
||||
* 10/09/1995 : Created. *
|
||||
* 10/09/1995 : Code stolen from Steve Tall *
|
||||
*=========================================================================*/
|
||||
extern void Colour_Debug (int call_number);
|
||||
extern BOOL GameInFocus;
|
||||
|
||||
extern void Block_Mouse(GraphicBufferClass *buffer);
|
||||
extern void Unblock_Mouse(GraphicBufferClass *buffer);
|
||||
|
||||
BOOL GraphicBufferClass::Lock(void)
|
||||
{
|
||||
HRESULT result;
|
||||
int restore_attempts=0;
|
||||
|
||||
//
|
||||
// If its not a direct draw surface then the lock is always sucessful.
|
||||
//
|
||||
if (!IsDirectDraw) return(TRUE);
|
||||
|
||||
/*
|
||||
** If the video surface pointer is null then return
|
||||
*/
|
||||
if (!VideoSurfacePtr) return (FALSE);
|
||||
|
||||
/*
|
||||
** If we dont have focus then return failure
|
||||
*/
|
||||
if (!GameInFocus) return (FALSE);
|
||||
|
||||
|
||||
Block_Mouse(this);
|
||||
|
||||
|
||||
//
|
||||
// If surface is already locked then inc the lock count and return true
|
||||
//
|
||||
if (LockCount){
|
||||
LockCount++;
|
||||
Unblock_Mouse(this);
|
||||
return(TRUE);
|
||||
}
|
||||
|
||||
//
|
||||
// If it isn't locked at all then we will have to request that Direct
|
||||
// Draw actually lock the surface.
|
||||
//
|
||||
|
||||
if (VideoSurfacePtr){
|
||||
while (!LockCount && restore_attempts<2) {
|
||||
result = VideoSurfacePtr->Lock ( NULL
|
||||
, &(VideoSurfaceDescription)
|
||||
, DDLOCK_WAIT
|
||||
, NULL);
|
||||
|
||||
switch (result){
|
||||
case DD_OK :
|
||||
Offset = (unsigned long)VideoSurfaceDescription.lpSurface;
|
||||
Pitch = VideoSurfaceDescription.lPitch;
|
||||
Pitch -= Width;
|
||||
LockCount++; // increment count so we can track if
|
||||
TotalLocks++; // Total number of times we have locked (for debugging)
|
||||
//Colour_Debug (1);
|
||||
Unblock_Mouse(this);
|
||||
return (TRUE); // we locked it multiple times.
|
||||
|
||||
case DDERR_SURFACELOST :
|
||||
if (Gbuffer_Focus_Loss_Function){
|
||||
Gbuffer_Focus_Loss_Function();
|
||||
}
|
||||
AllSurfaces.Restore_Surfaces();
|
||||
restore_attempts++;
|
||||
break;
|
||||
|
||||
default :
|
||||
Unblock_Mouse(this);
|
||||
return (FALSE);
|
||||
}
|
||||
}
|
||||
}
|
||||
//Colour_Debug(1);
|
||||
Unblock_Mouse(this);
|
||||
return (FALSE); //Return false because we couldnt lock or restore the surface
|
||||
}
|
||||
|
||||
/***************************************************************************
|
||||
* GBC::UNLOCK -- Unlocks a direct draw surface *
|
||||
* *
|
||||
* INPUT: none *
|
||||
* *
|
||||
* OUTPUT: none *
|
||||
* *
|
||||
* HISTORY: *
|
||||
* 10/09/1995 : Created. *
|
||||
* 10/09/1995 : Code stolen from Steve Tall *
|
||||
*=========================================================================*/
|
||||
|
||||
|
||||
BOOL GraphicBufferClass::Unlock(void)
|
||||
{
|
||||
//
|
||||
// If there is no lock count or this is not a direct draw surface
|
||||
// then just return true as there is no harm done.
|
||||
//
|
||||
if (!(LockCount && IsDirectDraw)) {
|
||||
return(TRUE);
|
||||
}
|
||||
|
||||
//
|
||||
// If lock count is directly equal to one then we actually need to
|
||||
// unlock so just give it a shot.
|
||||
//
|
||||
if (LockCount == 1 && VideoSurfacePtr) {
|
||||
Block_Mouse(this);
|
||||
if ( VideoSurfacePtr->Unlock ( NULL ) != DD_OK ){
|
||||
Unblock_Mouse(this);
|
||||
return(FALSE);
|
||||
} else {
|
||||
Offset=NOT_LOCKED;
|
||||
LockCount--;
|
||||
Unblock_Mouse(this);
|
||||
return(TRUE);
|
||||
}
|
||||
}
|
||||
//Colour_Debug (0);
|
||||
LockCount--;
|
||||
return(TRUE);
|
||||
}
|
||||
|
||||
|
||||
/***********************************************************************************************
|
||||
* GVPC::DD_Linear_Blit_To_Linear -- blit using the hardware blitter *
|
||||
* *
|
||||
* *
|
||||
* *
|
||||
* INPUT: destination vvpc *
|
||||
* x coord to blit from *
|
||||
* y coord to blit from *
|
||||
* x coord to blit to *
|
||||
* y coord to blit to *
|
||||
* width to blit *
|
||||
* height to blit *
|
||||
* *
|
||||
* OUTPUT: DD_OK if successful *
|
||||
* *
|
||||
* WARNINGS: None *
|
||||
* *
|
||||
* HISTORY: *
|
||||
* 09-22-95 11:05am ST : Created *
|
||||
*=============================================================================================*/
|
||||
|
||||
HRESULT GraphicViewPortClass::DD_Linear_Blit_To_Linear (
|
||||
GraphicViewPortClass &dest
|
||||
, int source_x
|
||||
, int source_y
|
||||
, int dest_x
|
||||
, int dest_y
|
||||
, int width
|
||||
, int height
|
||||
, BOOL mask )
|
||||
|
||||
{
|
||||
RECT source_rectangle;
|
||||
RECT dest_rectangle;
|
||||
int key_source=0;
|
||||
|
||||
if ( mask ){
|
||||
key_source=DDBLT_KEYSRC;
|
||||
}
|
||||
|
||||
|
||||
source_rectangle.left = source_x;
|
||||
source_rectangle.top = source_y;
|
||||
source_rectangle.right = source_x+width;
|
||||
source_rectangle.bottom = source_y+height;
|
||||
|
||||
dest_rectangle.left = dest_x;
|
||||
dest_rectangle.top = dest_y;
|
||||
dest_rectangle.right = dest_x+width;
|
||||
dest_rectangle.bottom = dest_y+height;
|
||||
|
||||
return ( dest.GraphicBuff->Get_DD_Surface()->Blt ( &dest_rectangle,
|
||||
GraphicBuff->Get_DD_Surface(),
|
||||
&source_rectangle,
|
||||
key_source | DDBLT_WAIT | DDBLT_ASYNC,
|
||||
NULL ) );
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
1366
WIN32LIB/DRAWBUFF/GBUFFER.H
Normal file
1366
WIN32LIB/DRAWBUFF/GBUFFER.H
Normal file
File diff suppressed because it is too large
Load Diff
51
WIN32LIB/DRAWBUFF/GBUFFER.INC
Normal file
51
WIN32LIB/DRAWBUFF/GBUFFER.INC
Normal file
@@ -0,0 +1,51 @@
|
||||
;
|
||||
; 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 A S S O C I A T E S **
|
||||
;***************************************************************************
|
||||
;* *
|
||||
;* Project Name : Westwood 32 Bit Library *
|
||||
;* *
|
||||
;* File Name : GBUFFER.INC *
|
||||
;* *
|
||||
;* Programmer : Phil W. Gorrow *
|
||||
;* *
|
||||
;* Start Date : May 26, 1994 *
|
||||
;* *
|
||||
;* Last Update : May 26, 1994 [PWG] *
|
||||
;* *
|
||||
;* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - *
|
||||
|
||||
;******************************************************************************
|
||||
; Much testing was done to determine that only when there are 14 or more bytes
|
||||
; being copied does it speed the time it takes to do copies in this algorithm.
|
||||
; For this reason and because 1 and 2 byte copies crash, is the special case
|
||||
; used. SKB 4/21/94. Tested on 486 66mhz. Copied by PWG 6/7/04.
|
||||
OPTIMAL_BYTE_COPY equ 14
|
||||
|
||||
STRUC GraphicViewPort
|
||||
GVPOffset DD ? ; offset to virtual viewport
|
||||
GVPWidth DD ? ; width of virtual viewport
|
||||
GVPHeight DD ? ; height of virtual viewport
|
||||
GVPXAdd DD ? ; x mod to get to next line
|
||||
GVPXPos DD ? ; x pos relative to Graphic Buff
|
||||
GVPYPos DD ? ; y pos relative to Graphic Buff
|
||||
GVPPitch dd ? ; modulo of graphic view port
|
||||
GVPBuffPtr DD ? ; ptr to associated Graphic Buff
|
||||
ENDS
|
115
WIN32LIB/DRAWBUFF/GETCLIP.ASM
Normal file
115
WIN32LIB/DRAWBUFF/GETCLIP.ASM
Normal file
@@ -0,0 +1,115 @@
|
||||
;
|
||||
; 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 A S S O C I A T E S **
|
||||
;***************************************************************************
|
||||
;* *
|
||||
;* Project Name : Westwood 32 bit Library *
|
||||
;* *
|
||||
;* File Name : BITBLIT.ASM *
|
||||
;* *
|
||||
;* Programmer : Julio R. Jerez *
|
||||
;* *
|
||||
;* Start Date : Feb 6, 1995 *
|
||||
;* *
|
||||
;* *
|
||||
;*-------------------------------------------------------------------------*
|
||||
;* Functions: *
|
||||
;* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - *
|
||||
|
||||
IDEAL
|
||||
P386
|
||||
MODEL USE32 FLAT
|
||||
LOCALS ??
|
||||
|
||||
INCLUDE ".\drawbuff.inc"
|
||||
INCLUDE "gbuffer.inc"
|
||||
|
||||
|
||||
; typedef struct {
|
||||
; int x0 , y0 ;
|
||||
; int x1 , y1 ;
|
||||
; } CLIP_WIN ;
|
||||
; Note for efficiency reasons x1 must be >= x0 and y1 >= y0
|
||||
; int get_clip ( CLIP_WIN * window , CLIP_WIN * sorce_rect ) ;
|
||||
|
||||
CODESEG
|
||||
|
||||
PROC get_clip C near
|
||||
USES eax , ebx
|
||||
|
||||
;*===================================================================
|
||||
;* define the arguements that our function takes.
|
||||
;*===================================================================
|
||||
ARG win : dword
|
||||
ARG rect : dword
|
||||
|
||||
|
||||
mov edi , [ rect ]
|
||||
mov esi , [ win ]
|
||||
xor eax , eax
|
||||
xor edx , edx
|
||||
|
||||
mov ecx , [ (RECTANGLE edi) . x0 ]
|
||||
mov ebx , [ (RECTANGLE edi) . x1 ]
|
||||
sub ecx , [ (RECTANGLE esi) . x0 ]
|
||||
sub ebx , [ (RECTANGLE esi) . x0 ]
|
||||
shld eax , ecx , 1
|
||||
shld edx , ebx , 1
|
||||
|
||||
; mov ebx , [ (RECTANGLE esi) . x1 ]
|
||||
; inc ebx
|
||||
; mov [ rect ] , ebx
|
||||
mov ecx , [ (RECTANGLE edi) . x0 ]
|
||||
mov ebx , [ (RECTANGLE edi) . x1 ]
|
||||
sub ecx , [ (RECTANGLE esi) . x1 ]
|
||||
sub ebx , [ (RECTANGLE esi) . x1 ]
|
||||
dec ecx
|
||||
dec ebx
|
||||
shld eax , ecx , 1
|
||||
shld edx , ebx , 1
|
||||
|
||||
mov ecx , [ (RECTANGLE edi) . y0 ]
|
||||
mov ebx , [ (RECTANGLE edi) . y1 ]
|
||||
sub ecx , [ (RECTANGLE esi) . y0 ]
|
||||
sub ebx , [ (RECTANGLE esi) . y0 ]
|
||||
shld eax , ecx , 1
|
||||
shld edx , ebx , 1
|
||||
|
||||
; mov ebx , [ (RECTANGLE esi) . y1 ]
|
||||
; inc ebx
|
||||
; mov [ rect ] , ebx
|
||||
mov ecx , [ (RECTANGLE edi) . y0 ]
|
||||
mov ebx , [ (RECTANGLE edi) . y1 ]
|
||||
sub ecx , [ (RECTANGLE esi) . y1 ]
|
||||
sub ebx , [ (RECTANGLE esi) . y1 ]
|
||||
dec ecx
|
||||
dec ebx
|
||||
shld eax , ecx , 1
|
||||
shld edx , ebx , 1
|
||||
|
||||
xor al , 5
|
||||
xor dl , 5
|
||||
mov ah , dl
|
||||
ret
|
||||
ENDP get_clip
|
||||
|
||||
|
||||
|
||||
END
|
106
WIN32LIB/DRAWBUFF/GETPIX.ASM
Normal file
106
WIN32LIB/DRAWBUFF/GETPIX.ASM
Normal file
@@ -0,0 +1,106 @@
|
||||
;
|
||||
; 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 : GraphicViewPortClass *
|
||||
;* *
|
||||
;* File Name : GETPIXEL.ASM *
|
||||
;* *
|
||||
;* Programmer : Phil Gorrow *
|
||||
;* *
|
||||
;* Start Date : June 7, 1994 *
|
||||
;* *
|
||||
;* Last Update : June 7, 1994 [PWG] *
|
||||
;* *
|
||||
;*-------------------------------------------------------------------------*
|
||||
;* Functions: *
|
||||
;* VVPC::Buffer_Get_Pixel -- get the colour of a pixel at given coords *
|
||||
;* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - *
|
||||
|
||||
IDEAL
|
||||
P386
|
||||
MODEL USE32 FLAT
|
||||
|
||||
INCLUDE ".\drawbuff.inc"
|
||||
INCLUDE ".\gbuffer.inc"
|
||||
|
||||
|
||||
CODESEG
|
||||
|
||||
;***************************************************************************
|
||||
;* VVPC::GET_PIXEL -- Gets a pixel from the current view port *
|
||||
;* *
|
||||
;* INPUT: WORD the x pixel on the screen. *
|
||||
;* WORD the y pixel on the screen. *
|
||||
;* *
|
||||
;* OUTPUT: UBYTE the pixel at the specified location *
|
||||
;* *
|
||||
;* WARNING: If pixel is to be placed outside of the viewport then *
|
||||
;* this routine will abort. *
|
||||
;* *
|
||||
;* HISTORY: *
|
||||
;* 06/07/1994 PWG : Created. *
|
||||
;*=========================================================================*
|
||||
PROC Buffer_Get_Pixel C near
|
||||
USES ebx,ecx,edx,edi
|
||||
|
||||
ARG this_object:DWORD ; this is a member function
|
||||
ARG x_pixel:DWORD ; x position of pixel to set
|
||||
ARG y_pixel:DWORD ; y position of pixel to set
|
||||
|
||||
;*===================================================================
|
||||
; Get the viewport information and put bytes per row in ecx
|
||||
;*===================================================================
|
||||
mov ebx,[this_object] ; get a pointer to viewport
|
||||
xor eax,eax
|
||||
mov edi,[(GraphicViewPort ebx).GVPOffset] ; get the correct offset
|
||||
mov ecx,[(GraphicViewPort ebx).GVPHeight] ; edx = height of viewport
|
||||
mov edx,[(GraphicViewPort ebx).GVPWidth] ; ecx = width of viewport
|
||||
|
||||
;*===================================================================
|
||||
; Verify that the X pixel offset if legal
|
||||
;*===================================================================
|
||||
mov eax,[x_pixel] ; find the x position
|
||||
cmp eax,edx ; is it out of bounds
|
||||
jae short ??exit ; if so then get out
|
||||
add edi,eax ; otherwise add in offset
|
||||
|
||||
;*===================================================================
|
||||
; Verify that the Y pixel offset if legal
|
||||
;*===================================================================
|
||||
mov eax,[y_pixel] ; get the y position
|
||||
cmp eax,ecx ; is it out of bounds
|
||||
jae ??exit ; if so then get out
|
||||
add edx,[(GraphicViewPort ebx).GVPXAdd] ; otherwise find bytes per row
|
||||
add edx,[(GraphicViewPort ebx).GVPPitch] ; otherwise find bytes per row
|
||||
mul edx ; offset = bytes per row * y
|
||||
add edi,eax ; add it into the offset
|
||||
|
||||
;*===================================================================
|
||||
; Write the pixel to the screen
|
||||
;*===================================================================
|
||||
xor eax,eax ; clear the word
|
||||
mov al,[edi] ; read in the pixel
|
||||
??exit:
|
||||
ret
|
||||
ENDP Buffer_Get_Pixel
|
||||
|
||||
END
|
609
WIN32LIB/DRAWBUFF/ICONCACH.CPP
Normal file
609
WIN32LIB/DRAWBUFF/ICONCACH.CPP
Normal file
@@ -0,0 +1,609 @@
|
||||
/*
|
||||
** 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 : Drawbuff - Westwood win95 library *
|
||||
* *
|
||||
* File Name : Iconcach.CPP *
|
||||
* *
|
||||
* Programmer : Steve Tall *
|
||||
* *
|
||||
* Start Date : November 8th, 1995 *
|
||||
* *
|
||||
* Last Update : November 13th, 1995 [ST] *
|
||||
* *
|
||||
*---------------------------------------------------------------------------------------------*
|
||||
* Overview: This file cantains members of the IconCacheClass and associated non member *
|
||||
* functions. All functions are to do with caching individual icons from icon sets *
|
||||
* into video memory to improve the speed of subsequent drawing *
|
||||
* *
|
||||
* Functions: *
|
||||
* Cache_New_Icon -- Call the Cache_It member to cache a registered icon to video memory *
|
||||
* Invalidate_Cached_Icons -- Uncache all the icons *
|
||||
* Restore_Cached_Icons -- restore cached icons after a focus loss *
|
||||
* Register_Icon_Set -- register an icon set as cachable *
|
||||
* Get_Free_Cache_Slot -- find an empty cache slot *
|
||||
* IconCacheClass::IconCacheClass -- IconCacheClass constructor *
|
||||
* IconCacheClass::~IconCacheClass -- IconCacheClass destructor *
|
||||
* IconCacheClass::Restore -- restore the icons surface and recache it *
|
||||
* IconCacheClass::Cache_It -- cache an icon into video memory *
|
||||
* IconCacheClass::Uncache_It -- restore the video memory used by a cached icon *
|
||||
* IconCacheClass::Draw_It -- use the blitter to draw the cached icon *
|
||||
* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
|
||||
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
#define _WIN32
|
||||
|
||||
#include <windows.h>
|
||||
#include "ddraw.h"
|
||||
#include "misc.h"
|
||||
#include "iconcach.h"
|
||||
#include "gbuffer.h"
|
||||
|
||||
|
||||
static DDSURFACEDESC VideoSurfaceDescription;
|
||||
|
||||
IconCacheClass CachedIcons[MAX_CACHED_ICONS];
|
||||
|
||||
extern "C"{
|
||||
IconSetType IconSetList[MAX_ICON_SETS];
|
||||
short IconCacheLookup[MAX_LOOKUP_ENTRIES];
|
||||
}
|
||||
|
||||
int CachedIconsDrawn=0; //Counter of number of cache hits
|
||||
int UnCachedIconsDrawn=0; //Counter of number of cache misses
|
||||
BOOL CacheMemoryExhausted; //Flag set if we have run out of video RAM
|
||||
|
||||
|
||||
|
||||
|
||||
/***********************************************************************************************
|
||||
* Optimise_Video_Memory_Cache -- optimises usage of video memory *
|
||||
* *
|
||||
* *
|
||||
* *
|
||||
* INPUT: Nothing *
|
||||
* *
|
||||
* OUTPUT: TRUE if memory was freed up *
|
||||
* *
|
||||
* WARNINGS: None *
|
||||
* *
|
||||
* HISTORY: *
|
||||
* 11/29/95 12:47PM ST : Created *
|
||||
*=============================================================================================*/
|
||||
BOOL Optimize_Video_Memory_Cache (void)
|
||||
{
|
||||
|
||||
if (CacheMemoryExhausted &&
|
||||
(UnCachedIconsDrawn+CachedIconsDrawn > 1000) &&
|
||||
UnCachedIconsDrawn > CachedIconsDrawn){
|
||||
|
||||
int cache_misses[MAX_CACHED_ICONS];
|
||||
int cache_hits[MAX_CACHED_ICONS];
|
||||
int total_cache_misses=0;
|
||||
int total_cache_hits=0;
|
||||
int counter;
|
||||
int i;
|
||||
int j;
|
||||
int temp;
|
||||
BOOL swapped;
|
||||
|
||||
/*
|
||||
** make list of icons that have failed to cache more than 5 times
|
||||
*/
|
||||
for (counter=0 ; counter<MAX_CACHED_ICONS ; counter++){
|
||||
|
||||
if (CachedIcons[counter].TimesFailed>5){
|
||||
cache_misses[total_cache_misses++] = counter;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
** Make list of icons that have been drawn less than 3 times
|
||||
*/
|
||||
for (counter=0 ; counter<MAX_CACHED_ICONS ; counter++){
|
||||
|
||||
if (CachedIcons[counter].TimesDrawn<3){
|
||||
cache_hits[total_cache_hits++] = counter;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
** Sort drawn icons into order
|
||||
*/
|
||||
if (total_cache_hits > 1){
|
||||
for (i = 0 ; i<total_cache_hits ; i++){
|
||||
swapped=FALSE;
|
||||
for (j=0 ; j<total_cache_hits-1 ; j++){
|
||||
|
||||
if (CachedIcons[cache_hits[j]].TimesDrawn > CachedIcons[cache_hits[j+1]].TimesDrawn){
|
||||
temp=cache_hits[j];
|
||||
cache_hits[j]=cache_hits[j+1];
|
||||
cache_hits[j+1]=temp;
|
||||
swapped = TRUE;
|
||||
}
|
||||
}
|
||||
if (!swapped) break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
** Uncache icons up to the number of failed icons
|
||||
*/
|
||||
|
||||
for (counter=0 ; counter<total_cache_misses && counter<total_cache_hits; counter++){
|
||||
CachedIcons[cache_hits[counter]].Uncache_It();
|
||||
}
|
||||
|
||||
CacheMemoryExhausted=FALSE;
|
||||
CachedIconsDrawn=0;
|
||||
UnCachedIconsDrawn=0;
|
||||
return (TRUE);
|
||||
}
|
||||
return (FALSE);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/***********************************************************************************************
|
||||
* Cache_New_Icon -- cache a registered icon to video memory *
|
||||
* *
|
||||
* *
|
||||
* *
|
||||
* INPUT: icon_index -- index into registered icon table of icon to cache *
|
||||
* icon_ptr -- ptr to icon data *
|
||||
* *
|
||||
* OUTPUT: BOOL success *
|
||||
* *
|
||||
* WARNINGS: icon must already have been registered and assigned an index *
|
||||
* *
|
||||
* HISTORY: *
|
||||
* 11/13/95 9:36AM ST : Created *
|
||||
*=============================================================================================*/
|
||||
BOOL Cache_New_Icon (int icon_index, void *icon_ptr)
|
||||
{
|
||||
if (!CacheMemoryExhausted){
|
||||
return (CachedIcons[icon_index].Cache_It(icon_ptr));
|
||||
} else {
|
||||
CachedIcons[icon_index].TimesFailed++;
|
||||
if (Optimize_Video_Memory_Cache()){
|
||||
return (CachedIcons[icon_index].Cache_It(icon_ptr));
|
||||
} else {
|
||||
return (FALSE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/***********************************************************************************************
|
||||
* Invalidat_Cached_Icons -- used to release any icons that have been cached *
|
||||
* *
|
||||
* *
|
||||
* *
|
||||
* INPUT: Nothing *
|
||||
* *
|
||||
* OUTPUT: Nothing *
|
||||
* *
|
||||
* WARNINGS: None *
|
||||
* *
|
||||
* HISTORY: *
|
||||
* 11/13/95 9:37AM ST : Created *
|
||||
*=============================================================================================*/
|
||||
void Invalidate_Cached_Icons (void)
|
||||
{
|
||||
for (int i=0 ; i<MAX_CACHED_ICONS ; i++){
|
||||
CachedIcons[i].Uncache_It();
|
||||
}
|
||||
|
||||
memset (&IconCacheLookup[0] , -1 ,MAX_LOOKUP_ENTRIES*sizeof(IconCacheLookup[0]));
|
||||
|
||||
for (i=0 ; i<MAX_ICON_SETS ; i++){
|
||||
IconSetList[i].IconSetPtr=NULL;
|
||||
}
|
||||
|
||||
CacheMemoryExhausted=FALSE;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/***********************************************************************************************
|
||||
* Restore_Cached_Icons -- re-cache icons into video memory after a loss of focus *
|
||||
* *
|
||||
* *
|
||||
* *
|
||||
* INPUT: Nothing *
|
||||
* *
|
||||
* OUTPUT: Nothing *
|
||||
* *
|
||||
* WARNINGS: Assumes that the pointers that were originally used to cache the icons *
|
||||
* are still valid. *
|
||||
* *
|
||||
* HISTORY: *
|
||||
* 11/13/95 9:38AM ST : Created *
|
||||
*=============================================================================================*/
|
||||
void Restore_Cached_Icons (void)
|
||||
{
|
||||
for (int i=0 ; i<MAX_CACHED_ICONS ; i++){
|
||||
CachedIcons[i].Restore();
|
||||
}
|
||||
CacheMemoryExhausted=FALSE;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/***********************************************************************************************
|
||||
* Register_Icon_Set -- used to register an icon set as cachable *
|
||||
* *
|
||||
* *
|
||||
* *
|
||||
* INPUT: icon_data - ptr to icon set *
|
||||
* pre_cache -- should we pre-cache the icon data? *
|
||||
* *
|
||||
* OUTPUT: Nothing *
|
||||
* *
|
||||
* WARNINGS: None *
|
||||
* *
|
||||
* HISTORY: *
|
||||
* 11/13/95 9:39AM ST : Created *
|
||||
*=============================================================================================*/
|
||||
void Register_Icon_Set (void *icon_data , BOOL pre_cache)
|
||||
{
|
||||
|
||||
for (int i=0 ; i<MAX_ICON_SETS ; i++){
|
||||
if (!IconSetList[i].IconSetPtr){
|
||||
IconSetList[i].IconSetPtr = (IControl_Type*)icon_data;
|
||||
|
||||
if (i){
|
||||
IControl_Type *previous_set = IconSetList[i-1].IconSetPtr;
|
||||
IconSetList[i].IconListOffset = IconSetList[i-1].IconListOffset + ((int)previous_set->Count)*2;
|
||||
if (IconSetList[i].IconListOffset > MAX_LOOKUP_ENTRIES*2){
|
||||
IconSetList[i].IconSetPtr = NULL;
|
||||
}
|
||||
} else {
|
||||
IconSetList[i].IconListOffset = 0;
|
||||
}
|
||||
|
||||
if (pre_cache){
|
||||
for (i=0 ; i<256 ; i++){
|
||||
Is_Icon_Cached(icon_data,i);
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/***********************************************************************************************
|
||||
* Get_Free_Cache_Slot -- find a free slot in which to cache an icon *
|
||||
* *
|
||||
* *
|
||||
* *
|
||||
* INPUT: Nothing *
|
||||
* *
|
||||
* OUTPUT: int - icon index *
|
||||
* *
|
||||
* WARNINGS: None *
|
||||
* *
|
||||
* HISTORY: *
|
||||
* 11/13/95 9:40AM ST : Created *
|
||||
*=============================================================================================*/
|
||||
int Get_Free_Cache_Slot (void)
|
||||
{
|
||||
for (int i=0 ; i<MAX_CACHED_ICONS ; i++){
|
||||
if (!CachedIcons[i].Get_Is_Cached()){
|
||||
return (i);
|
||||
}
|
||||
}
|
||||
return (-1);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/***********************************************************************************************
|
||||
* ICC::IconCacheClass -- constructor for icon cache class *
|
||||
* *
|
||||
* *
|
||||
* *
|
||||
* INPUT: Nothing *
|
||||
* *
|
||||
* OUTPUT: Nothing *
|
||||
* *
|
||||
* WARNINGS: None *
|
||||
* *
|
||||
* HISTORY: *
|
||||
* 11/13/95 9:41AM ST : Created *
|
||||
*=============================================================================================*/
|
||||
IconCacheClass::IconCacheClass (void)
|
||||
{
|
||||
IsCached =FALSE;
|
||||
SurfaceLost =FALSE;
|
||||
DrawFrequency =0;
|
||||
CacheSurface =NULL;
|
||||
IconSource =NULL;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/***********************************************************************************************
|
||||
* ICC::~IconCacheClass -- destructor for icon cache class *
|
||||
* *
|
||||
* *
|
||||
* *
|
||||
* INPUT: Nothing *
|
||||
* *
|
||||
* OUTPUT: Nothing *
|
||||
* *
|
||||
* WARNINGS: None *
|
||||
* *
|
||||
* HISTORY: *
|
||||
* 11/13/95 9:41AM ST : Created *
|
||||
*=============================================================================================*/
|
||||
IconCacheClass::~IconCacheClass (void)
|
||||
{
|
||||
if (IsCached && CacheSurface){
|
||||
CacheSurface->Release();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/***********************************************************************************************
|
||||
* ICC::Restore -- Restores the icons video surface memory and reloads it based on the original*
|
||||
* icon pointer *
|
||||
* *
|
||||
* *
|
||||
* INPUT: Nothing *
|
||||
* *
|
||||
* OUTPUT: Nothing *
|
||||
* *
|
||||
* WARNINGS: Relies on the icons original pointer still being valie *
|
||||
* *
|
||||
* HISTORY: *
|
||||
* 11/13/95 9:43AM ST : Created *
|
||||
*=============================================================================================*/
|
||||
void IconCacheClass::Restore (void)
|
||||
{
|
||||
if (IsCached && CacheSurface){
|
||||
CacheSurface->Restore();
|
||||
if (IconSource){
|
||||
Cache_It(IconSource);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/***********************************************************************************************
|
||||
* ICC::Cache_It -- allocate video memory and copy an icon to it *
|
||||
* *
|
||||
* *
|
||||
* *
|
||||
* INPUT: icon_ptr -- ptr to icon data *
|
||||
* *
|
||||
* OUTPUT: bool -- success? *
|
||||
* *
|
||||
* WARNINGS: None *
|
||||
* *
|
||||
* HISTORY: *
|
||||
* 11/13/95 9:44AM ST : Created *
|
||||
*=============================================================================================*/
|
||||
BOOL IconCacheClass::Cache_It (void *icon_ptr)
|
||||
{
|
||||
DDSCAPS surface_capabilities;
|
||||
BOOL return_value;
|
||||
|
||||
/*
|
||||
** If we dont have a direct draw interface yet then just fail
|
||||
*/
|
||||
if (!DirectDrawObject) return(FALSE);
|
||||
|
||||
/*
|
||||
** Set up the description of the surface we want to create
|
||||
*/
|
||||
memset (&VideoSurfaceDescription , 0 , sizeof ( VideoSurfaceDescription ));
|
||||
|
||||
VideoSurfaceDescription.dwSize = sizeof( VideoSurfaceDescription );
|
||||
VideoSurfaceDescription.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN;
|
||||
VideoSurfaceDescription.dwFlags = DDSD_CAPS | DDSD_HEIGHT | DDSD_WIDTH;
|
||||
VideoSurfaceDescription.dwHeight = ICON_WIDTH;
|
||||
VideoSurfaceDescription.dwWidth = ICON_HEIGHT;
|
||||
|
||||
/*
|
||||
** If this cache object doesnt already have a surface then create one
|
||||
*/
|
||||
if (!CacheSurface){
|
||||
if (DD_OK!=DirectDrawObject->CreateSurface( &VideoSurfaceDescription , &CacheSurface , NULL)){
|
||||
CacheMemoryExhausted = TRUE;
|
||||
return(FALSE);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
** Make sure the surface we created isnt really in system memory
|
||||
*/
|
||||
if (DD_OK != CacheSurface->GetCaps(&surface_capabilities)){
|
||||
return(FALSE);
|
||||
}
|
||||
|
||||
if ((DDSCAPS_SYSTEMMEMORY & surface_capabilities.dwCaps) == DDSCAPS_SYSTEMMEMORY){
|
||||
CacheSurface->Release();
|
||||
return(FALSE);
|
||||
}
|
||||
|
||||
return_value=FALSE;
|
||||
/*
|
||||
** Lock the surface so we can copy the icon to it
|
||||
*/
|
||||
if (DD_OK== CacheSurface->Lock ( NULL
|
||||
, &(VideoSurfaceDescription)
|
||||
, DDLOCK_WAIT
|
||||
, NULL)){
|
||||
/*
|
||||
** Copy the icon to the surface and flag that icon is cached
|
||||
*/
|
||||
Cache_Copy_Icon (icon_ptr , VideoSurfaceDescription.lpSurface , VideoSurfaceDescription.lPitch);
|
||||
IsCached=TRUE;
|
||||
SurfaceLost=FALSE;
|
||||
IconSource=icon_ptr;
|
||||
return_value=TRUE;
|
||||
}
|
||||
CacheSurface->Unlock(NULL);
|
||||
return (return_value);
|
||||
}
|
||||
|
||||
|
||||
/***********************************************************************************************
|
||||
* ICC::Uncache_It -- release the video memory used to cache an icon *
|
||||
* *
|
||||
* *
|
||||
* *
|
||||
* INPUT: Nothing *
|
||||
* *
|
||||
* OUTPUT: Nothing *
|
||||
* *
|
||||
* WARNINGS: None *
|
||||
* *
|
||||
* HISTORY: *
|
||||
* 11/13/95 9:48AM ST : Created *
|
||||
*=============================================================================================*/
|
||||
void IconCacheClass::Uncache_It(void)
|
||||
{
|
||||
|
||||
if (IsCached && CacheSurface){
|
||||
CacheSurface->Release();
|
||||
IsCached=FALSE;
|
||||
CacheSurface=NULL;
|
||||
IconSource=NULL;
|
||||
CacheMemoryExhausted=FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/***********************************************************************************************
|
||||
* ICC::Draw_It -- use the blitter to draw a cached icon *
|
||||
* *
|
||||
* *
|
||||
* *
|
||||
* INPUT: surface to draw to *
|
||||
* x coord to draw to (relative to window) *
|
||||
* y coord to draw to (relative to window) *
|
||||
* window left coord *
|
||||
* window top coord *
|
||||
* window width *
|
||||
* window height *
|
||||
* *
|
||||
* OUTPUT: Nothing *
|
||||
* *
|
||||
* WARNINGS: None *
|
||||
* *
|
||||
* HISTORY: *
|
||||
* 11/13/95 9:48AM ST : Created *
|
||||
*=============================================================================================*/
|
||||
void IconCacheClass::Draw_It (LPDIRECTDRAWSURFACE dest_surface , int x_pixel, int y_pixel, int window_left , int window_top , int window_width , int window_height)
|
||||
{
|
||||
RECT source_rectangle;
|
||||
RECT dest_rectangle;
|
||||
int clip;
|
||||
HRESULT return_code;
|
||||
|
||||
/*
|
||||
** Set up the source and destination coordinates as required by direct draw
|
||||
*/
|
||||
source_rectangle.left = 0;
|
||||
source_rectangle.top = 0;
|
||||
source_rectangle.right = ICON_WIDTH;
|
||||
source_rectangle.bottom = ICON_HEIGHT;
|
||||
|
||||
dest_rectangle.left = window_left+x_pixel;
|
||||
dest_rectangle.top = window_top+y_pixel;
|
||||
dest_rectangle.right = dest_rectangle.left+ICON_WIDTH;
|
||||
dest_rectangle.bottom = dest_rectangle.top+ICON_HEIGHT;
|
||||
|
||||
/*
|
||||
** Clip the coordinates to the window
|
||||
*/
|
||||
if (dest_rectangle.left<window_left){
|
||||
source_rectangle.left += window_left-dest_rectangle.left;
|
||||
dest_rectangle.left=window_left;
|
||||
}
|
||||
|
||||
if (dest_rectangle.right>=window_left+window_width){
|
||||
clip = dest_rectangle.right-(window_left+window_width);
|
||||
source_rectangle.right -= clip;
|
||||
dest_rectangle.right -= clip;
|
||||
}
|
||||
|
||||
if (dest_rectangle.top<window_top){
|
||||
source_rectangle.top += window_top-dest_rectangle.top;
|
||||
dest_rectangle.top=window_top;
|
||||
}
|
||||
|
||||
if (dest_rectangle.bottom>=window_top+window_height){
|
||||
clip = dest_rectangle.bottom-(window_top+window_height);
|
||||
source_rectangle.bottom -= clip;
|
||||
dest_rectangle.bottom -= clip;
|
||||
}
|
||||
|
||||
if (source_rectangle.left>=source_rectangle.right){
|
||||
return;
|
||||
}
|
||||
|
||||
if (source_rectangle.top>=source_rectangle.bottom){
|
||||
return;
|
||||
}
|
||||
|
||||
/*
|
||||
** Do the blit
|
||||
*/
|
||||
return_code = dest_surface->Blt (&dest_rectangle ,
|
||||
CacheSurface ,
|
||||
&source_rectangle ,
|
||||
DDBLT_WAIT |
|
||||
DDBLT_ASYNC ,
|
||||
NULL);
|
||||
|
||||
if (return_code == DDERR_SURFACELOST && Gbuffer_Focus_Loss_Function){
|
||||
Gbuffer_Focus_Loss_Function();
|
||||
}
|
||||
|
||||
if ( return_code != DDERR_SURFACELOST && return_code != DD_OK ) {
|
||||
char temp[100];
|
||||
sprintf(temp,"DD Error code %d\n", return_code & 0xFFFF);
|
||||
OutputDebugString(temp);
|
||||
}
|
||||
|
||||
TimesDrawn++;
|
||||
|
||||
}
|
||||
|
153
WIN32LIB/DRAWBUFF/ICONCACH.H
Normal file
153
WIN32LIB/DRAWBUFF/ICONCACH.H
Normal file
@@ -0,0 +1,153 @@
|
||||
/*
|
||||
** 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 : Drawbuff - Westwood win95 library *
|
||||
* *
|
||||
* File Name : Iconcach.H *
|
||||
* *
|
||||
* Programmer : Steve Tall *
|
||||
* *
|
||||
* Start Date : November 8th, 1995 *
|
||||
* *
|
||||
* Last Update : November 16th, 1995 [ST] *
|
||||
* *
|
||||
*---------------------------------------------------------------------------------------------*
|
||||
* Overview: This file cantains definition of the IconCacheClass and associated non member *
|
||||
* function prototypes. *
|
||||
* *
|
||||
* Functions: *
|
||||
* IconCacheClass::Get_Is_Cached -- member to allow access to private IsCached flag *
|
||||
* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
|
||||
|
||||
|
||||
|
||||
|
||||
#ifndef ICONCACH_H
|
||||
#define ICONCACH_H
|
||||
|
||||
#include <tile.h>
|
||||
|
||||
#define ICON_WIDTH 24 // Icons must be this width to be cached
|
||||
#define ICON_HEIGHT 24 // Icons must be this height to be cached
|
||||
#define MAX_CACHED_ICONS 500 // Maximum number of icons that can be cached
|
||||
#define MAX_ICON_SETS 100 // Maximum number of icon sets that can be registered
|
||||
#define MAX_LOOKUP_ENTRIES 3000 // Size of icon index table
|
||||
|
||||
|
||||
/*
|
||||
** IconCacheClass for tracking individual icons cached into video memory
|
||||
**
|
||||
** Use Register_Icon_Set to identify a set of icons as cachable. Once registered, the icons
|
||||
** will be cached automatically when drawn.
|
||||
** Use Invalidate_Cached_Icons at the end of icon drawing to release the video memory used by the
|
||||
** caching system.
|
||||
** Restore_Cached_Icons may be used to reload the icons into video memory after a focus loss.
|
||||
**
|
||||
*/
|
||||
|
||||
class IconCacheClass {
|
||||
|
||||
public:
|
||||
|
||||
IconCacheClass (void); // class constructor
|
||||
~IconCacheClass (void); // class destructor
|
||||
|
||||
void Restore(void); // restore the surface
|
||||
BOOL Cache_It (void * icon_ptr); // Cache the icon to video memory
|
||||
void Uncache_It (void); // Restore the video memory and flag the icon as uncached
|
||||
void Draw_It (LPDIRECTDRAWSURFACE dest_surface , int x_pixel, int y_pixel, int window_left , int window_top , int window_width , int window_height);
|
||||
inline BOOL Get_Is_Cached(void); // Return the IsCached member
|
||||
|
||||
int TimesDrawn; // counter of times cached icon has been drawn
|
||||
int TimesFailed; // counter of times cached icon has failed to draw
|
||||
|
||||
|
||||
private:
|
||||
|
||||
LPDIRECTDRAWSURFACE CacheSurface; // Ptr to direct draw surface where icon resides
|
||||
BOOL IsCached; // Flag to say whether an icon is cached
|
||||
BOOL SurfaceLost; // Flag to indicate that our icons surface has been lost
|
||||
int DrawFrequency; // Number of times icon has been drawn
|
||||
void *IconSource; // Ptr to original icon data in system memory
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
/*
|
||||
** Structure to keep track of registered icon sets
|
||||
**
|
||||
*/
|
||||
|
||||
typedef struct tIconSetType{
|
||||
IControl_Type *IconSetPtr; // Ptr to icon set data
|
||||
int IconListOffset; // Offset into icon index table for this icon set
|
||||
}IconSetType;
|
||||
|
||||
|
||||
extern IconCacheClass CachedIcons[MAX_CACHED_ICONS];
|
||||
|
||||
extern void Invalidate_Cached_Icons (void);
|
||||
extern void Restore_Cached_Icons (void);
|
||||
extern void Register_Icon_Set (void *icon_data , BOOL pre_cache);
|
||||
|
||||
//
|
||||
// Prototypes for assembly language procedures in STMPCACH.ASM
|
||||
//
|
||||
extern "C" void Clear_Icon_Pointers (void);
|
||||
extern "C" void Cache_Copy_Icon (void const *icon_ptr ,void * , int);
|
||||
extern "C" int Is_Icon_Cached (void const *icon_data , int icon);
|
||||
extern "C" int Get_Icon_Index (void *icon_ptr);
|
||||
extern "C" int Get_Free_Index (void);
|
||||
extern "C" BOOL Cache_New_Icon (int icon_index, void *icon_ptr);
|
||||
extern "C" int Get_Free_Cache_Slot(void);
|
||||
|
||||
|
||||
extern int CachedIconsDrawn;
|
||||
extern int UnCachedIconsDrawn;
|
||||
|
||||
|
||||
/***********************************************************************************************
|
||||
* ICC::Get_Is_Cached -- member to allow access to the private IsCached flag *
|
||||
* *
|
||||
* *
|
||||
* *
|
||||
* INPUT: Nothing *
|
||||
* *
|
||||
* OUTPUT: IsCached *
|
||||
* *
|
||||
* WARNINGS: None *
|
||||
* *
|
||||
* HISTORY: *
|
||||
* 11/13/95 9:42AM ST : Created *
|
||||
*=============================================================================================*/
|
||||
inline BOOL IconCacheClass::Get_Is_Cached (void)
|
||||
{
|
||||
return (IsCached);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#endif //ICONCACH_H
|
||||
|
203
WIN32LIB/DRAWBUFF/MAKEFILE
Normal file
203
WIN32LIB/DRAWBUFF/MAKEFILE
Normal file
@@ -0,0 +1,203 @@
|
||||
#
|
||||
# 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 : Westwood Library .LIB makefile *
|
||||
#* *
|
||||
#* File Name : MAKEFILE *
|
||||
#* *
|
||||
#* Programmer : Julio R. Jerez *
|
||||
#* *
|
||||
#* Start Date : Jan 26, 1995 *
|
||||
#* *
|
||||
#* *
|
||||
#*-------------------------------------------------------------------------*
|
||||
#* *
|
||||
#* Required environment variables: *
|
||||
#* WIN32LIB = your root WIN32LIB path *
|
||||
#* WIN32VCS = root directory for wwlib version control archive *
|
||||
#* COMPILER = your Watcom installation path *
|
||||
#* *
|
||||
#* Required changes to makefile: *
|
||||
#* PROJ_NAME = name of the library you're building *
|
||||
#* OBJECTS = list of objects in your library *
|
||||
#* *
|
||||
#* Optional changes to makefile: *
|
||||
#* PROJ_DIR = full pathname of your working directory *
|
||||
#* .path.xxx = full pathname where various file types live *
|
||||
#* *
|
||||
#***************************************************************************
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
# Verify user's environment
|
||||
#---------------------------------------------------------------------------
|
||||
!ifndef %WIN32LIB
|
||||
!error WIN32LIB Environment var not configured.
|
||||
!endif
|
||||
|
||||
!ifndef %WIN32VCS
|
||||
!error WIN32VCS Environment var not configured.
|
||||
!endif
|
||||
|
||||
!ifndef %WATCOM
|
||||
!error COMPILER Environment var not configured.
|
||||
!endif
|
||||
|
||||
#===========================================================================
|
||||
# User-defined section: the user should tailor this section for each project
|
||||
#===========================================================================
|
||||
#===========================================================================
|
||||
# User-defined section: the user should tailor this section for each project
|
||||
#===========================================================================
|
||||
|
||||
PROJ_NAME = drawbuff
|
||||
PROJ_DIR = $(%WIN32LIB)\$(PROJ_NAME)
|
||||
LIB_DIR = $(%WIN32LIB)\lib
|
||||
|
||||
!include $(%WIN32LIB)\project.cfg
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
# Project-dependent variables
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
OBJECTS = &
|
||||
bitblit.obj &
|
||||
buffer.obj &
|
||||
buffglbl.obj &
|
||||
clear.obj &
|
||||
drawline.obj &
|
||||
drawrect.obj &
|
||||
fillquad.obj &
|
||||
fillrect.obj &
|
||||
gbuffer.obj &
|
||||
getclip.obj &
|
||||
getpix.obj &
|
||||
putpix.obj &
|
||||
regionsz.obj &
|
||||
remap.obj &
|
||||
scale.obj &
|
||||
stamp.obj &
|
||||
szregion.obj &
|
||||
tobuff.obj &
|
||||
topage.obj &
|
||||
txtprnt.obj &
|
||||
iconcach.obj &
|
||||
stmpcach.obj
|
||||
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
# Path macros: one path for each file type.
|
||||
# These paths are used to tell make where to find/put each file type.
|
||||
#---------------------------------------------------------------------------
|
||||
.asm: $(PROJ_DIR)
|
||||
.c: $(PROJ_DIR)
|
||||
.cpp: $(PROJ_DIR)
|
||||
.h: $(PROJ_DIR)
|
||||
.obj: $(PROJ_DIR)
|
||||
.lib: $(%WIN32LIB)\lib
|
||||
.exe: $(PROJ_DIR)
|
||||
|
||||
#===========================================================================
|
||||
# Pre-defined section: there should be little need to modify this section.
|
||||
#===========================================================================
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
# Tools/commands
|
||||
#---------------------------------------------------------------------------
|
||||
C_CMD = wcc386
|
||||
CPP_CMD = wpp386
|
||||
LIB_CMD = wlib
|
||||
LINK_CMD = wlink
|
||||
ASM_CMD = tasm
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
# Include & library paths
|
||||
# If LIB & INCLUDE are already defined, they are used in addition to the
|
||||
# WWLIB32 lib & include; otherwise, they're constructed from
|
||||
# BCDIR & TNTDIR
|
||||
#---------------------------------------------------------------------------
|
||||
LIBPATH = $(%WIN32LIB)\LIB;$(%WATCOM)\LIB
|
||||
INCLUDEPATH = $(%WIN32LIB)\INCLUDE;$(%WATCOM)\H
|
||||
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
# Implicit rules
|
||||
# Compiler:
|
||||
# ($< = full dependent with path)
|
||||
# Assembler:
|
||||
# output obj's are constructed from .obj: & the $& macro
|
||||
# ($< = full dependent with path)
|
||||
# tasm's cfg file is not invoked as a response file.
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
.c.obj: $(%WIN32LIB)\project.cfg .AUTODEPEND
|
||||
*$(C_CMD) $(CC_CFG) $<
|
||||
|
||||
.cpp.obj: $(%WIN32LIB)\project.cfg .AUTODEPEND
|
||||
*$(CPP_CMD) $(CC_CFG) $(PROJ_DIR)\$^*.cpp
|
||||
|
||||
.asm.obj: $(%WIN32LIB)\project.cfg
|
||||
$(ASM_CMD) $(ASM_CFG) $<
|
||||
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
# Default target: configuration files & library (in that order)
|
||||
#---------------------------------------------------------------------------
|
||||
all: $(LIB_DIR)\$(PROJ_NAME).lib .SYMBOLIC
|
||||
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
# Build the library
|
||||
# The original library is deleted by the librarian
|
||||
# Lib objects & -+ commands are constructed by substituting within the
|
||||
# $^@ macro (which expands to all target dependents, separated with
|
||||
# spaces)
|
||||
# Tlib's cfg file is not invoked as a response file.
|
||||
# All headers & source files are copied into WIN32LIB\SRCDEBUG, for debugging
|
||||
#---------------------------------------------------------------------------
|
||||
$(LIB_DIR)\$(PROJ_NAME).lib: $(OBJECTS) objects.lbc
|
||||
copy *.h $(%WIN32LIB)\include
|
||||
copy *.inc $(%WIN32LIB)\include
|
||||
copy *.cpp $(%WIN32LIB)\srcdebug
|
||||
copy *.asm $(%WIN32LIB)\srcdebug
|
||||
$(LIB_CMD) $(LIB_CFG) $^@ @objects.lbc
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
# Objects now have a link file which is NOT generated everytime. Instead
|
||||
# it just has its own dependacy rule.
|
||||
#---------------------------------------------------------------------------
|
||||
objects.lbc : $(OBJECTS)
|
||||
%create $^@
|
||||
for %index in ($(OBJECTS)) do %append $^@ +%index
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
# Create the test directory and make it.
|
||||
#---------------------------------------------------------------------------
|
||||
test:
|
||||
mkdir test
|
||||
cd test
|
||||
copy $(%WWVCS)\$(PROJ_NAME)\test\vcs.cfg
|
||||
update
|
||||
wmake
|
||||
cd ..
|
||||
|
||||
#**************************** End of makefile ******************************
|
||||
|
206
WIN32LIB/DRAWBUFF/MAKEFILE.BOR
Normal file
206
WIN32LIB/DRAWBUFF/MAKEFILE.BOR
Normal file
@@ -0,0 +1,206 @@
|
||||
#
|
||||
# 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 : Westwood Library .LIB makefile *
|
||||
#* *
|
||||
#* File Name : MAKEFILE *
|
||||
#* *
|
||||
#* Programmer : Julio R. Jerez *
|
||||
#* *
|
||||
#* Start Date : Jan 26, 1995 *
|
||||
#* *
|
||||
#* *
|
||||
#*-------------------------------------------------------------------------*
|
||||
#* *
|
||||
#* Required environment variables: *
|
||||
#* WIN32LIB = your root WWFLAT path *
|
||||
#* WIN32VCS = root directory for wwlib version control archive *
|
||||
#* COMPILER = your Watcom installation path *
|
||||
#* *
|
||||
#* Required changes to makefile: *
|
||||
#* PROJ_NAME = name of the library you're building *
|
||||
#* OBJECTS = list of objects in your library *
|
||||
#* *
|
||||
#* Optional changes to makefile: *
|
||||
#* PROJ_DIR = full pathname of your working directory *
|
||||
#* .path.xxx = full pathname where various file types live *
|
||||
#* *
|
||||
#***************************************************************************
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
# Verify user's environment
|
||||
#---------------------------------------------------------------------------
|
||||
!ifndef WIN32LIB
|
||||
!error WIN32LIB Environment var not configured.
|
||||
!endif
|
||||
|
||||
!ifndef WIN32VCS
|
||||
!error WIN32VCS Environment var not configured.
|
||||
!endif
|
||||
|
||||
!ifndef COMPILER
|
||||
!error COMPILER Environment var not configured.
|
||||
!endif
|
||||
|
||||
#===========================================================================
|
||||
# User-defined section: the user should tailor this section for each project
|
||||
#===========================================================================
|
||||
|
||||
PROJ_NAME = drawbuff
|
||||
PROJ_DIR = $(WIN32LIB)\$(PROJ_NAME)
|
||||
LIB_DIR = $(WIN32LIB)\lib
|
||||
|
||||
!include $(WIN32LIB)\\project.cfg
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
# Project-dependent variables
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
OBJECTS = \
|
||||
bitblit.obj \
|
||||
buffer.obj \
|
||||
buffglbl.obj \
|
||||
clear.obj \
|
||||
drawline.obj \
|
||||
drawrect.obj \
|
||||
fillquad.obj \
|
||||
fillrect.obj \
|
||||
gbuffer.obj \
|
||||
getclip.obj \
|
||||
getpix.obj \
|
||||
putpix.obj \
|
||||
regionsz.obj \
|
||||
remap.obj \
|
||||
scale.obj \
|
||||
stamp.obj \
|
||||
szregion.obj \
|
||||
tobuff.obj \
|
||||
topage.obj \
|
||||
txtprnt.obj
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
# Path macros: one path for each file type.
|
||||
# These paths are used to tell make where to find/put each file type.
|
||||
#---------------------------------------------------------------------------
|
||||
.path.asm = $(PROJ_DIR)
|
||||
.path.c = $(PROJ_DIR)
|
||||
.path.cpp = $(PROJ_DIR)
|
||||
.path.h = $(PROJ_DIR)
|
||||
.path.obj = $(PROJ_DIR)
|
||||
.path.lib = $(WIN32LIB)\lib
|
||||
.path.exe = $(PROJ_DIR)
|
||||
|
||||
#===========================================================================
|
||||
# Pre-defined section: there should be little need to modify this section.
|
||||
#===========================================================================
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
# Tools/commands
|
||||
#---------------------------------------------------------------------------
|
||||
C_CMD = bcc32
|
||||
CPP_CMD = bcc32
|
||||
LIB_CMD = tlib
|
||||
LINK_CMD = tlink32
|
||||
ASM_CMD = tasm32
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
# Include & library paths
|
||||
# If LIB & INCLUDE are already defined, they are used in addition to the
|
||||
# WWLIB32 lib & include; otherwise, they're constructed from
|
||||
# BCDIR & TNTDIR
|
||||
#---------------------------------------------------------------------------
|
||||
LIBPATH = $(WIN32LIB)\LIB;$(COMPILER)\LIB
|
||||
INCLUDEPATH = $(WIN32LIB)\INCLUDE;$(COMPILER)\INCLUDE
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
# Implicit rules
|
||||
# Compiler:
|
||||
# ($< = full dependent with path)
|
||||
# Assembler:
|
||||
# output obj's are constructed from .obj: & the $& macro
|
||||
# ($< = full dependent with path)
|
||||
# tasm's cfg file is not invoked as a response file.
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
.c.obj:
|
||||
$(C_CMD) $(CC_CFG) $<
|
||||
|
||||
.cpp.obj:
|
||||
$(CPP_CMD) $(CC_CFG) $<
|
||||
|
||||
.asm.obj:
|
||||
$(ASM_CMD) $(ASM_CFG) $<
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
# Default target: configuration files & library (in that order)
|
||||
#---------------------------------------------------------------------------
|
||||
all: $(LIB_DIR)\$(PROJ_NAME).lib
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
# Build the library
|
||||
# The original library is deleted by the librarian
|
||||
# Lib objects & -+ commands are constructed by substituting within the
|
||||
# $^@ macro (which expands to all target dependents, separated with
|
||||
# spaces)
|
||||
# Tlib's cfg file is not invoked as a response file.
|
||||
# All headers & source files are copied into WIN32LIB\SRCDEBUG, for debugging
|
||||
#---------------------------------------------------------------------------
|
||||
$(LIB_DIR)\\$(PROJ_NAME).lib: $(OBJECTS)
|
||||
copy *.h $(WIN32LIB)\\include
|
||||
copy *.inc $(WIN32LIB)\\include
|
||||
copy *.cpp $(WIN32LIB)\\srcdebug
|
||||
copy *.asm $(WIN32LIB)\\srcdebug
|
||||
$(LIB_CMD) $< $(LIB_CFG) @&&|
|
||||
-+bitblit.obj &
|
||||
-+buffer.obj &
|
||||
-+buffglbl.obj &
|
||||
-+clear.obj &
|
||||
-+drawline.obj &
|
||||
-+drawrect.obj &
|
||||
-+fillquad.obj &
|
||||
-+fillrect.obj &
|
||||
-+gbuffer.obj &
|
||||
-+getclip.obj &
|
||||
-+getpix.obj &
|
||||
-+putpix.obj &
|
||||
-+regionsz.obj &
|
||||
-+remap.obj &
|
||||
-+scale.obj &
|
||||
-+stamp.obj &
|
||||
-+szregion.obj &
|
||||
-+tobuff.obj &
|
||||
-+topage.obj &
|
||||
-+txtprnt.obj
|
||||
|
|
||||
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
# Create the test directory and make it.
|
||||
#---------------------------------------------------------------------------
|
||||
test:
|
||||
mkdir test
|
||||
cd test
|
||||
copy $(WWVCS)\\$(PROJ_NAME)\test\vcs.cfg
|
||||
update
|
||||
wmake
|
||||
cd ..
|
||||
|
110
WIN32LIB/DRAWBUFF/PUTPIX.ASM
Normal file
110
WIN32LIB/DRAWBUFF/PUTPIX.ASM
Normal file
@@ -0,0 +1,110 @@
|
||||
;
|
||||
; 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 : GraphicViewPortClass *
|
||||
;* *
|
||||
;* File Name : PUTPIXEL.ASM *
|
||||
;* *
|
||||
;* Programmer : Phil Gorrow *
|
||||
;* *
|
||||
;* Start Date : June 7, 1994 *
|
||||
;* *
|
||||
;* Last Update : June 8, 1994 [PWG] *
|
||||
;* *
|
||||
;*-------------------------------------------------------------------------*
|
||||
;* Functions: *
|
||||
;* VVPC::Put_Pixel -- Puts a pixel on a virtual viewport *
|
||||
;* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - *
|
||||
|
||||
IDEAL
|
||||
P386
|
||||
MODEL USE32 FLAT
|
||||
|
||||
INCLUDE ".\drawbuff.inc"
|
||||
INCLUDE ".\gbuffer.inc"
|
||||
|
||||
|
||||
CODESEG
|
||||
|
||||
;***************************************************************************
|
||||
;* VVPC::PUT_PIXEL -- Puts a pixel on a virtual viewport *
|
||||
;* *
|
||||
;* INPUT: WORD the x position for the pixel relative to the upper *
|
||||
;* left corner of the viewport *
|
||||
;* WORD the y pos for the pixel relative to the upper left *
|
||||
;* corner of the viewport *
|
||||
;* UBYTE the color of the pixel to write *
|
||||
;* *
|
||||
;* OUTPUT: none *
|
||||
;* *
|
||||
;* WARNING: If pixel is to be placed outside of the viewport then *
|
||||
;* this routine will abort. *
|
||||
;* *
|
||||
;* HISTORY: *
|
||||
;* 06/08/1994 PWG : Created. *
|
||||
;*=========================================================================*
|
||||
PROC Buffer_Put_Pixel C near
|
||||
USES eax,ebx,ecx,edx,edi
|
||||
|
||||
ARG this_object:DWORD ; this is a member function
|
||||
ARG x_pixel:DWORD ; x position of pixel to set
|
||||
ARG y_pixel:DWORD ; y position of pixel to set
|
||||
ARG color:BYTE ; what color should we clear to
|
||||
|
||||
;*===================================================================
|
||||
; Get the viewport information and put bytes per row in ecx
|
||||
;*===================================================================
|
||||
mov ebx,[this_object] ; get a pointer to viewport
|
||||
xor eax,eax
|
||||
mov edi,[(GraphicViewPort ebx).GVPOffset] ; get the correct offset
|
||||
mov ecx,[(GraphicViewPort ebx).GVPHeight] ; edx = height of viewport
|
||||
mov edx,[(GraphicViewPort ebx).GVPWidth] ; ecx = width of viewport
|
||||
|
||||
;*===================================================================
|
||||
; Verify that the X pixel offset if legal
|
||||
;*===================================================================
|
||||
mov eax,[x_pixel] ; find the x position
|
||||
cmp eax,edx ; is it out of bounds
|
||||
jae short ??exit ; if so then get out
|
||||
add edi,eax ; otherwise add in offset
|
||||
|
||||
;*===================================================================
|
||||
; Verify that the Y pixel offset if legal
|
||||
;*===================================================================
|
||||
mov eax,[y_pixel] ; get the y position
|
||||
cmp eax,ecx ; is it out of bounds
|
||||
jae ??exit ; if so then get out
|
||||
add edx,[(GraphicViewPort ebx).GVPXAdd] ; otherwise find bytes per row
|
||||
add edx,[(GraphicViewPort ebx).GVPPitch] ; add in direct draw pitch
|
||||
mul edx ; offset = bytes per row * y
|
||||
add edi,eax ; add it into the offset
|
||||
|
||||
;*===================================================================
|
||||
; Write the pixel to the screen
|
||||
;*===================================================================
|
||||
mov al,[color] ; read in color value
|
||||
mov [edi],al ; write it to the screen
|
||||
??exit:
|
||||
ret
|
||||
ENDP Buffer_Put_Pixel
|
||||
|
||||
END
|
60
WIN32LIB/DRAWBUFF/REGIONSZ.CPP
Normal file
60
WIN32LIB/DRAWBUFF/REGIONSZ.CPP
Normal file
@@ -0,0 +1,60 @@
|
||||
/*
|
||||
** 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 : WWLIB 32 *
|
||||
* *
|
||||
* File Name : REGIONSZ.CPP *
|
||||
* *
|
||||
* Programmer : Phil W. Gorrow *
|
||||
* *
|
||||
* Start Date : November 3, 1994 *
|
||||
* *
|
||||
* Last Update : November 3, 1994 [PWG] *
|
||||
* *
|
||||
*-------------------------------------------------------------------------*
|
||||
* Functions: *
|
||||
* Size_Of_Region -- Calculates the size of a given region *
|
||||
* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
|
||||
|
||||
/*=========================================================================*/
|
||||
/* The following PRIVATE functions are in this file: */
|
||||
/*=========================================================================*/
|
||||
|
||||
|
||||
/*= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =*/
|
||||
|
||||
|
||||
/***************************************************************************
|
||||
* SIZE_OF_REGION -- Calculates the size of a given region *
|
||||
* *
|
||||
* INPUT: int width - the width of the region *
|
||||
* int height - the height of the region *
|
||||
* *
|
||||
* OUTPUT: long - the size of the region *
|
||||
* *
|
||||
* HISTORY: *
|
||||
* 11/03/1994 PWG : Created. *
|
||||
*=========================================================================*/
|
||||
long Size_Of_Region(int width, int height)
|
||||
{
|
||||
return(width * height);
|
||||
}
|
175
WIN32LIB/DRAWBUFF/REMAP.ASM
Normal file
175
WIN32LIB/DRAWBUFF/REMAP.ASM
Normal file
@@ -0,0 +1,175 @@
|
||||
;
|
||||
; 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 A S S O C I A T E S **
|
||||
;***************************************************************************
|
||||
;* *
|
||||
;* Project Name : Westwood 32 bit Library *
|
||||
;* *
|
||||
;* File Name : REMAP.ASM *
|
||||
;* *
|
||||
;* Programmer : Phil W. Gorrow *
|
||||
;* *
|
||||
;* Start Date : July 1, 1994 *
|
||||
;* *
|
||||
;* Last Update : July 1, 1994 [PWG] *
|
||||
;* *
|
||||
;*-------------------------------------------------------------------------*
|
||||
;* Functions: *
|
||||
;* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - *
|
||||
|
||||
|
||||
IDEAL
|
||||
P386
|
||||
MODEL USE32 FLAT
|
||||
|
||||
INCLUDE ".\drawbuff.inc"
|
||||
INCLUDE ".\gbuffer.inc"
|
||||
|
||||
|
||||
CODESEG
|
||||
|
||||
PROC Buffer_Remap C NEAR
|
||||
USES eax,ebx,ecx,edx,esi,edi
|
||||
|
||||
;*===================================================================
|
||||
;* Define the arguements that our function takes.
|
||||
;*===================================================================
|
||||
ARG this_object:DWORD
|
||||
ARG x0_pixel:DWORD
|
||||
ARG y0_pixel:DWORD
|
||||
ARG region_width:DWORD
|
||||
ARG region_height:DWORD
|
||||
ARG remap :DWORD
|
||||
|
||||
;*===================================================================
|
||||
; Define some locals so that we can handle things quickly
|
||||
;*===================================================================
|
||||
local x1_pixel : DWORD
|
||||
local y1_pixel : DWORD
|
||||
local win_width : dword
|
||||
local counter_x : dword
|
||||
|
||||
|
||||
cmp [ remap ] , 0
|
||||
jz ??real_out
|
||||
|
||||
; Clip Source Rectangle against source Window boundaries.
|
||||
mov esi , [ this_object ] ; get ptr to src
|
||||
xor ecx , ecx
|
||||
xor edx , edx
|
||||
mov edi , [ (GraphicViewPort esi) . GVPWidth ] ; get width into register
|
||||
mov ebx , [ x0_pixel ]
|
||||
mov eax , [ x0_pixel ]
|
||||
add ebx , [ region_width ]
|
||||
shld ecx , eax , 1
|
||||
mov [ x1_pixel ] , ebx
|
||||
inc edi
|
||||
shld edx , ebx , 1
|
||||
sub eax , edi
|
||||
sub ebx , edi
|
||||
shld ecx , eax , 1
|
||||
shld edx , ebx , 1
|
||||
|
||||
mov edi,[ ( GraphicViewPort esi) . GVPHeight ] ; get height into register
|
||||
mov ebx , [ y0_pixel ]
|
||||
mov eax , [ y0_pixel ]
|
||||
add ebx , [ region_height ]
|
||||
shld ecx , eax , 1
|
||||
mov [ y1_pixel ] , ebx
|
||||
inc edi
|
||||
shld edx , ebx , 1
|
||||
sub eax , edi
|
||||
sub ebx , edi
|
||||
shld ecx , eax , 1
|
||||
shld edx , ebx , 1
|
||||
|
||||
xor cl , 5
|
||||
xor dl , 5
|
||||
mov al , cl
|
||||
test dl , cl
|
||||
jnz ??real_out
|
||||
or al , dl
|
||||
jz ??do_remap
|
||||
|
||||
test cl , 1000b
|
||||
jz ??scr_left_ok
|
||||
mov [ x0_pixel ] , 0
|
||||
|
||||
??scr_left_ok:
|
||||
test cl , 0010b
|
||||
jz ??scr_bottom_ok
|
||||
mov [ y0_pixel ] , 0
|
||||
|
||||
??scr_bottom_ok:
|
||||
test dl , 0100b
|
||||
jz ??scr_right_ok
|
||||
mov eax , [ (GraphicViewPort esi) . GVPWidth ] ; get width into register
|
||||
mov [ x1_pixel ] , eax
|
||||
??scr_right_ok:
|
||||
test dl , 0001b
|
||||
jz ??do_remap
|
||||
mov eax , [ (GraphicViewPort esi) . GVPHeight ] ; get width into register
|
||||
mov [ y1_pixel ] , eax
|
||||
|
||||
|
||||
??do_remap:
|
||||
cld
|
||||
mov edi , [ (GraphicViewPort esi) . GVPOffset ]
|
||||
mov eax , [ (GraphicViewPort esi) . GVPXAdd ]
|
||||
mov ebx , [ x1_pixel ]
|
||||
add eax , [ (GraphicViewPort esi) . GVPWidth ]
|
||||
add eax , [ (GraphicViewPort esi) . GVPPitch ]
|
||||
mov esi , eax
|
||||
mul [ y0_pixel ]
|
||||
add edi , [ x0_pixel ]
|
||||
sub ebx , [ x0_pixel ]
|
||||
jle ??real_out
|
||||
add edi , eax
|
||||
sub esi , ebx
|
||||
|
||||
mov ecx , [ y1_pixel ]
|
||||
sub ecx , [ y0_pixel ]
|
||||
jle ??real_out
|
||||
mov eax , [ remap ]
|
||||
mov [ counter_x ] , ebx
|
||||
xor edx , edx
|
||||
|
||||
??outer_loop:
|
||||
mov ebx , [ counter_x ]
|
||||
??inner_loop:
|
||||
mov dl , [ edi ]
|
||||
mov dl , [ eax + edx ]
|
||||
mov [ edi ] , dl
|
||||
inc edi
|
||||
dec ebx
|
||||
jnz ??inner_loop
|
||||
add edi , esi
|
||||
dec ecx
|
||||
jnz ??outer_loop
|
||||
|
||||
|
||||
|
||||
|
||||
??real_out:
|
||||
ret
|
||||
|
||||
ENDP Buffer_Remap
|
||||
|
||||
END
|
570
WIN32LIB/DRAWBUFF/SCALE.ASM
Normal file
570
WIN32LIB/DRAWBUFF/SCALE.ASM
Normal file
@@ -0,0 +1,570 @@
|
||||
;
|
||||
; 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 A S S O C I A T E S **
|
||||
;***************************************************************************
|
||||
;* *
|
||||
;* Project Name : Westwood 32 bit Library *
|
||||
;* *
|
||||
;* File Name : SCALE.ASM *
|
||||
;* *
|
||||
;* Programmer : Phil W. Gorrow *
|
||||
;* *
|
||||
;* Start Date : June 16, 1994 *
|
||||
;* *
|
||||
;* Last Update : June 21, 1994 [PWG] *
|
||||
;* New version : feb 12, 1995 [JRJ] *
|
||||
;* *
|
||||
;*-------------------------------------------------------------------------*
|
||||
;* Functions: *
|
||||
;* VVC::Scale -- Scales a virtual viewport to another virtual viewport *
|
||||
;* Normal_Draw -- jump loc for drawing scaled line of normal pixel *
|
||||
;* Normal_Remapped_Draw -- jump loc for draw scaled line of remap pixel *
|
||||
;* Transparent_Draw -- jump loc for scaled line of transparent pixels *
|
||||
;* Transparent_Remapped_Draw -- jump loc for scaled remap trans pixels *
|
||||
;* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - *
|
||||
|
||||
IDEAL
|
||||
P386
|
||||
MODEL USE32 FLAT
|
||||
|
||||
INCLUDE ".\drawbuff.inc"
|
||||
INCLUDE ".\gbuffer.inc"
|
||||
|
||||
|
||||
CODESEG
|
||||
|
||||
|
||||
;***************************************************************************
|
||||
;* VVC::SCALE -- Scales a virtual viewport to another virtual viewport *
|
||||
;* *
|
||||
;* INPUT: *
|
||||
;* *
|
||||
;* OUTPUT: *
|
||||
;* *
|
||||
;* WARNINGS: *
|
||||
;* *
|
||||
;* HISTORY: *
|
||||
;* 06/16/1994 PWG : Created. *
|
||||
;*=========================================================================*
|
||||
PROC Linear_Scale_To_Linear C NEAR
|
||||
USES eax,ebx,ecx,edx,esi,edi
|
||||
|
||||
;*===================================================================
|
||||
;* Define the arguements that our function takes.
|
||||
;*===================================================================
|
||||
ARG this_object:DWORD ; pointer to source view port
|
||||
ARG dest:DWORD ; pointer to destination view port
|
||||
ARG src_x:DWORD ; source x offset into view port
|
||||
ARG src_y:DWORD ; source y offset into view port
|
||||
ARG dst_x:DWORD ; dest x offset into view port
|
||||
ARG dst_y:DWORD ; dest y offset into view port
|
||||
ARG src_width:DWORD ; width of source rectangle
|
||||
ARG src_height:DWORD ; height of source rectangle
|
||||
ARG dst_width:DWORD ; width of dest rectangle
|
||||
ARG dst_height:DWORD ; width of dest height
|
||||
ARG trans:DWORD ; is this transparent?
|
||||
ARG remap:DWORD ; pointer to table to remap source
|
||||
|
||||
;*===================================================================
|
||||
;* Define local variables to hold the viewport characteristics
|
||||
;*===================================================================
|
||||
local src_x0 : dword
|
||||
local src_y0 : dword
|
||||
local src_x1 : dword
|
||||
local src_y1 : dword
|
||||
|
||||
local dst_x0 : dword
|
||||
local dst_y0 : dword
|
||||
local dst_x1 : dword
|
||||
local dst_y1 : dword
|
||||
|
||||
local src_win_width : dword
|
||||
local dst_win_width : dword
|
||||
local dy_intr : dword
|
||||
local dy_frac : dword
|
||||
local dy_acc : dword
|
||||
local dx_frac : dword
|
||||
|
||||
local counter_x : dword
|
||||
local counter_y : dword
|
||||
local remap_counter :dword
|
||||
local entry : dword
|
||||
|
||||
;*===================================================================
|
||||
;* Check for scale error when to or from size 0,0
|
||||
;*===================================================================
|
||||
cmp [dst_width],0
|
||||
je ??all_done
|
||||
cmp [dst_height],0
|
||||
je ??all_done
|
||||
cmp [src_width],0
|
||||
je ??all_done
|
||||
cmp [src_height],0
|
||||
je ??all_done
|
||||
|
||||
mov eax , [ src_x ]
|
||||
mov ebx , [ src_y ]
|
||||
mov [ src_x0 ] , eax
|
||||
mov [ src_y0 ] , ebx
|
||||
add eax , [ src_width ]
|
||||
add ebx , [ src_height ]
|
||||
mov [ src_x1 ] , eax
|
||||
mov [ src_y1 ] , ebx
|
||||
|
||||
mov eax , [ dst_x ]
|
||||
mov ebx , [ dst_y ]
|
||||
mov [ dst_x0 ] , eax
|
||||
mov [ dst_y0 ] , ebx
|
||||
add eax , [ dst_width ]
|
||||
add ebx , [ dst_height ]
|
||||
mov [ dst_x1 ] , eax
|
||||
mov [ dst_y1 ] , ebx
|
||||
|
||||
; Clip Source Rectangle against source Window boundaries.
|
||||
mov esi , [ this_object ] ; get ptr to src
|
||||
xor ecx , ecx
|
||||
xor edx , edx
|
||||
mov edi , [ (GraphicViewPort esi) . GVPWidth ] ; get width into register
|
||||
mov eax , [ src_x0 ]
|
||||
mov ebx , [ src_x1 ]
|
||||
shld ecx , eax , 1
|
||||
inc edi
|
||||
shld edx , ebx , 1
|
||||
sub eax , edi
|
||||
sub ebx , edi
|
||||
shld ecx , eax , 1
|
||||
shld edx , ebx , 1
|
||||
|
||||
mov edi,[ ( GraphicViewPort esi) . GVPHeight ] ; get height into register
|
||||
mov eax , [ src_y0 ]
|
||||
mov ebx , [ src_y1 ]
|
||||
shld ecx , eax , 1
|
||||
inc edi
|
||||
shld edx , ebx , 1
|
||||
sub eax , edi
|
||||
sub ebx , edi
|
||||
shld ecx , eax , 1
|
||||
shld edx , ebx , 1
|
||||
|
||||
xor cl , 5
|
||||
xor dl , 5
|
||||
mov al , cl
|
||||
test dl , cl
|
||||
jnz ??all_done
|
||||
or al , dl
|
||||
jz ??clip_against_dest
|
||||
mov bl , dl
|
||||
test cl , 1000b
|
||||
jz ??src_left_ok
|
||||
xor eax , eax
|
||||
mov [ src_x0 ] , eax
|
||||
sub eax , [ src_x ]
|
||||
imul [ dst_width ]
|
||||
idiv [ src_width ]
|
||||
add eax , [ dst_x ]
|
||||
mov [ dst_x0 ] , eax
|
||||
|
||||
??src_left_ok:
|
||||
test cl , 0010b
|
||||
jz ??src_bottom_ok
|
||||
xor eax , eax
|
||||
mov [ src_y0 ] , eax
|
||||
sub eax , [ src_y ]
|
||||
imul [ dst_height ]
|
||||
idiv [ src_height ]
|
||||
add eax , [ dst_y ]
|
||||
mov [ dst_y0 ] , eax
|
||||
|
||||
??src_bottom_ok:
|
||||
test bl , 0100b
|
||||
jz ??src_right_ok
|
||||
mov eax , [ (GraphicViewPort esi) . GVPWidth ] ; get width into register
|
||||
mov [ src_x1 ] , eax
|
||||
sub eax , [ src_x ]
|
||||
imul [ dst_width ]
|
||||
idiv [ src_width ]
|
||||
add eax , [ dst_x ]
|
||||
mov [ dst_x1 ] , eax
|
||||
|
||||
??src_right_ok:
|
||||
test bl , 0001b
|
||||
jz ??clip_against_dest
|
||||
mov eax , [ (GraphicViewPort esi) . GVPHeight ] ; get width into register
|
||||
mov [ src_y1 ] , eax
|
||||
sub eax , [ src_y ]
|
||||
imul [ dst_height ]
|
||||
idiv [ src_height ]
|
||||
add eax , [ dst_y ]
|
||||
mov [ dst_y1 ] , eax
|
||||
|
||||
; Clip destination Rectangle against source Window boundaries.
|
||||
??clip_against_dest:
|
||||
mov esi , [ dest ] ; get ptr to src
|
||||
xor ecx , ecx
|
||||
xor edx , edx
|
||||
mov edi , [ (GraphicViewPort esi) . GVPWidth ] ; get width into register
|
||||
mov eax , [ dst_x0 ]
|
||||
mov ebx , [ dst_x1 ]
|
||||
shld ecx , eax , 1
|
||||
inc edi
|
||||
shld edx , ebx , 1
|
||||
sub eax , edi
|
||||
sub ebx , edi
|
||||
shld ecx , eax , 1
|
||||
shld edx , ebx , 1
|
||||
|
||||
mov edi,[ ( GraphicViewPort esi) . GVPHeight ] ; get height into register
|
||||
mov eax , [ dst_y0 ]
|
||||
mov ebx , [ dst_y1 ]
|
||||
shld ecx , eax , 1
|
||||
inc edi
|
||||
shld edx , ebx , 1
|
||||
sub eax , edi
|
||||
sub ebx , edi
|
||||
shld ecx , eax , 1
|
||||
shld edx , ebx , 1
|
||||
|
||||
xor cl , 5
|
||||
xor dl , 5
|
||||
mov al , cl
|
||||
test dl , cl
|
||||
jnz ??all_done
|
||||
or al , dl
|
||||
jz ??do_scaling
|
||||
mov bl , dl
|
||||
test cl , 1000b
|
||||
jz ??dst_left_ok
|
||||
xor eax , eax
|
||||
mov [ dst_x0 ] , eax
|
||||
sub eax , [ dst_x ]
|
||||
imul [ src_width ]
|
||||
idiv [ dst_width ]
|
||||
add eax , [ src_x ]
|
||||
mov [ src_x0 ] , eax
|
||||
|
||||
??dst_left_ok:
|
||||
test cl , 0010b
|
||||
jz ??dst_bottom_ok
|
||||
xor eax , eax
|
||||
mov [ dst_y0 ] , eax
|
||||
sub eax , [ dst_y ]
|
||||
imul [ src_height ]
|
||||
idiv [ dst_height ]
|
||||
add eax , [ src_y ]
|
||||
mov [ src_y0 ] , eax
|
||||
|
||||
??dst_bottom_ok:
|
||||
test bl , 0100b
|
||||
jz ??dst_right_ok
|
||||
mov eax , [ (GraphicViewPort esi) . GVPWidth ] ; get width into register
|
||||
mov [ dst_x1 ] , eax
|
||||
sub eax , [ dst_x ]
|
||||
imul [ src_width ]
|
||||
idiv [ dst_width ]
|
||||
add eax , [ src_x ]
|
||||
mov [ src_x1 ] , eax
|
||||
|
||||
??dst_right_ok:
|
||||
test bl , 0001b
|
||||
jz ??do_scaling
|
||||
|
||||
mov eax , [ (GraphicViewPort esi) . GVPHeight ] ; get width into register
|
||||
mov [ dst_y1 ] , eax
|
||||
sub eax , [ dst_y ]
|
||||
imul [ src_height ]
|
||||
idiv [ dst_height ]
|
||||
add eax , [ src_y ]
|
||||
mov [ src_y1 ] , eax
|
||||
|
||||
??do_scaling:
|
||||
|
||||
cld
|
||||
mov ebx , [ this_object ]
|
||||
mov esi , [ (GraphicViewPort ebx) . GVPOffset ]
|
||||
mov eax , [ (GraphicViewPort ebx) . GVPXAdd ]
|
||||
add eax , [ (GraphicViewPort ebx) . GVPWidth ]
|
||||
add eax , [ (GraphicViewPort ebx) . GVPPitch ]
|
||||
mov [ src_win_width ] , eax
|
||||
mul [ src_y0 ]
|
||||
add esi , [ src_x0 ]
|
||||
add esi , eax
|
||||
|
||||
mov ebx , [ dest ]
|
||||
mov edi , [ (GraphicViewPort ebx) . GVPOffset ]
|
||||
mov eax , [ (GraphicViewPort ebx) . GVPXAdd ]
|
||||
add eax , [ (GraphicViewPort ebx) . GVPWidth ]
|
||||
add eax , [ (GraphicViewPort ebx) . GVPPitch ]
|
||||
mov [ dst_win_width ] , eax
|
||||
mul [ dst_y0 ]
|
||||
add edi , [ dst_x0 ]
|
||||
add edi , eax
|
||||
|
||||
mov eax , [ src_height ]
|
||||
xor edx , edx
|
||||
mov ebx , [ dst_height ]
|
||||
idiv [ dst_height ]
|
||||
imul eax , [ src_win_width ]
|
||||
neg ebx
|
||||
mov [ dy_intr ] , eax
|
||||
mov [ dy_frac ] , edx
|
||||
mov [ dy_acc ] , ebx
|
||||
|
||||
mov eax , [ src_width ]
|
||||
xor edx , edx
|
||||
shl eax , 16
|
||||
idiv [ dst_width ]
|
||||
xor edx , edx
|
||||
shld edx , eax , 16
|
||||
shl eax , 16
|
||||
|
||||
mov ecx , [ dst_y1 ]
|
||||
mov ebx , [ dst_x1 ]
|
||||
sub ecx , [ dst_y0 ]
|
||||
jle ??all_done
|
||||
sub ebx , [ dst_x0 ]
|
||||
jle ??all_done
|
||||
|
||||
mov [ counter_y ] , ecx
|
||||
|
||||
cmp [ trans ] , 0
|
||||
jnz ??transparency
|
||||
|
||||
cmp [ remap ] , 0
|
||||
jnz ??normal_remap
|
||||
|
||||
; *************************************************************************
|
||||
; normal scale
|
||||
mov ecx , ebx
|
||||
and ecx , 01fh
|
||||
lea ecx , [ ecx + ecx * 2 ]
|
||||
shr ebx , 5
|
||||
neg ecx
|
||||
mov [ counter_x ] , ebx
|
||||
lea ecx , [ ??ref_point + ecx + ecx * 2 ]
|
||||
mov [ entry ] , ecx
|
||||
|
||||
??outter_loop:
|
||||
push esi
|
||||
push edi
|
||||
xor ecx , ecx
|
||||
mov ebx , [ counter_x ]
|
||||
jmp [ entry ]
|
||||
??inner_loop:
|
||||
REPT 32
|
||||
mov cl , [ esi ]
|
||||
add ecx , eax
|
||||
adc esi , edx
|
||||
mov [ edi ] , cl
|
||||
inc edi
|
||||
ENDM
|
||||
??ref_point:
|
||||
dec ebx
|
||||
jge ??inner_loop
|
||||
|
||||
pop edi
|
||||
pop esi
|
||||
add edi , [ dst_win_width ]
|
||||
add esi , [ dy_intr ]
|
||||
|
||||
mov ebx , [ dy_acc ]
|
||||
add ebx , [ dy_frac ]
|
||||
jle ??skip_line
|
||||
add esi , [ src_win_width ]
|
||||
sub ebx , [ dst_height ]
|
||||
??skip_line:
|
||||
dec [ counter_y ]
|
||||
mov [ dy_acc ] , ebx
|
||||
jnz ??outter_loop
|
||||
ret
|
||||
|
||||
|
||||
; *************************************************************************
|
||||
; normal scale with remap
|
||||
|
||||
??normal_remap:
|
||||
mov ecx , ebx
|
||||
mov [ dx_frac ], eax
|
||||
and ecx , 01fh
|
||||
mov eax , [ remap ]
|
||||
shr ebx , 5
|
||||
imul ecx , - 13
|
||||
mov [ counter_x ] , ebx
|
||||
lea ecx , [ ??remapref_point + ecx ]
|
||||
mov [ entry ] , ecx
|
||||
|
||||
??remapoutter_loop:
|
||||
mov ebx , [ counter_x ]
|
||||
push esi
|
||||
mov [ remap_counter ] , ebx
|
||||
push edi
|
||||
xor ecx , ecx
|
||||
xor ebx , ebx
|
||||
jmp [ entry ]
|
||||
??remapinner_loop:
|
||||
REPT 32
|
||||
mov bl , [ esi ]
|
||||
add ecx , [ dx_frac ]
|
||||
adc esi , edx
|
||||
mov cl , [ eax + ebx ]
|
||||
mov [ edi ] , cl
|
||||
inc edi
|
||||
ENDM
|
||||
??remapref_point:
|
||||
dec [ remap_counter ]
|
||||
jge ??remapinner_loop
|
||||
|
||||
pop edi
|
||||
pop esi
|
||||
add edi , [ dst_win_width ]
|
||||
add esi , [ dy_intr ]
|
||||
|
||||
mov ebx , [ dy_acc ]
|
||||
add ebx , [ dy_frac ]
|
||||
jle ??remapskip_line
|
||||
add esi , [ src_win_width ]
|
||||
sub ebx , [ dst_height ]
|
||||
??remapskip_line:
|
||||
dec [ counter_y ]
|
||||
mov [ dy_acc ] , ebx
|
||||
jnz ??remapoutter_loop
|
||||
ret
|
||||
|
||||
|
||||
;****************************************************************************
|
||||
; scale with trnsparency
|
||||
|
||||
??transparency:
|
||||
cmp [ remap ] , 0
|
||||
jnz ??trans_remap
|
||||
|
||||
; *************************************************************************
|
||||
; normal scale with transparency
|
||||
mov ecx , ebx
|
||||
and ecx , 01fh
|
||||
imul ecx , -13
|
||||
shr ebx , 5
|
||||
mov [ counter_x ] , ebx
|
||||
lea ecx , [ ??trans_ref_point + ecx ]
|
||||
mov [ entry ] , ecx
|
||||
|
||||
??trans_outter_loop:
|
||||
xor ecx , ecx
|
||||
push esi
|
||||
push edi
|
||||
mov ebx , [ counter_x ]
|
||||
jmp [ entry ]
|
||||
??trans_inner_loop:
|
||||
REPT 32
|
||||
local trans_pixel
|
||||
mov cl , [ esi ]
|
||||
test cl , cl
|
||||
jz trans_pixel
|
||||
mov [ edi ] , cl
|
||||
trans_pixel:
|
||||
add ecx , eax
|
||||
adc esi , edx
|
||||
inc edi
|
||||
ENDM
|
||||
??trans_ref_point:
|
||||
dec ebx
|
||||
jge ??trans_inner_loop
|
||||
|
||||
pop edi
|
||||
pop esi
|
||||
add edi , [ dst_win_width ]
|
||||
add esi , [ dy_intr ]
|
||||
|
||||
mov ebx , [ dy_acc ]
|
||||
add ebx , [ dy_frac ]
|
||||
jle ??trans_skip_line
|
||||
add esi , [ src_win_width ]
|
||||
sub ebx , [ dst_height ]
|
||||
??trans_skip_line:
|
||||
dec [ counter_y ]
|
||||
mov [ dy_acc ] , ebx
|
||||
jnz ??trans_outter_loop
|
||||
ret
|
||||
|
||||
|
||||
; *************************************************************************
|
||||
; normal scale with remap
|
||||
|
||||
??trans_remap:
|
||||
mov ecx , ebx
|
||||
mov [ dx_frac ], eax
|
||||
and ecx , 01fh
|
||||
mov eax , [ remap ]
|
||||
shr ebx , 5
|
||||
imul ecx , - 17
|
||||
mov [ counter_x ] , ebx
|
||||
lea ecx , [ ??trans_remapref_point + ecx ]
|
||||
mov [ entry ] , ecx
|
||||
|
||||
??trans_remapoutter_loop:
|
||||
mov ebx , [ counter_x ]
|
||||
push esi
|
||||
mov [ remap_counter ] , ebx
|
||||
push edi
|
||||
xor ecx , ecx
|
||||
xor ebx , ebx
|
||||
jmp [ entry ]
|
||||
??trans_remapinner_loop:
|
||||
REPT 32
|
||||
local trans_pixel
|
||||
mov bl , [ esi ]
|
||||
test bl , bl
|
||||
jz trans_pixel
|
||||
mov cl , [ eax + ebx ]
|
||||
mov [ edi ] , cl
|
||||
trans_pixel:
|
||||
add ecx , [ dx_frac ]
|
||||
adc esi , edx
|
||||
inc edi
|
||||
ENDM
|
||||
??trans_remapref_point:
|
||||
dec [ remap_counter ]
|
||||
jge ??trans_remapinner_loop
|
||||
|
||||
pop edi
|
||||
pop esi
|
||||
add edi , [ dst_win_width ]
|
||||
add esi , [ dy_intr ]
|
||||
|
||||
mov ebx , [ dy_acc ]
|
||||
add ebx , [ dy_frac ]
|
||||
jle ??trans_remapskip_line
|
||||
add esi , [ src_win_width ]
|
||||
sub ebx , [ dst_height ]
|
||||
??trans_remapskip_line:
|
||||
dec [ counter_y ]
|
||||
mov [ dy_acc ] , ebx
|
||||
jnz ??trans_remapoutter_loop
|
||||
ret
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
??all_done:
|
||||
ret
|
||||
endp
|
||||
|
||||
|
||||
END
|
210
WIN32LIB/DRAWBUFF/SHADOW.ASM
Normal file
210
WIN32LIB/DRAWBUFF/SHADOW.ASM
Normal file
@@ -0,0 +1,210 @@
|
||||
;
|
||||
; 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/>.
|
||||
;
|
||||
|
||||
; $Header: g:/library/source/rcs/./shadow.asm 1.9 1994/05/20 15:30:49 joe_bostic Exp $
|
||||
;***************************************************************************
|
||||
;** 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 **
|
||||
;***************************************************************************
|
||||
;* *
|
||||
;* Project Name : LIBRARY *
|
||||
;* *
|
||||
;* File Name : SHADOW.ASM *
|
||||
;* *
|
||||
;* Programmer : Christopher Yates *
|
||||
;* *
|
||||
;* Last Update : February 28, 1995 [BG] *
|
||||
;* *
|
||||
;*-------------------------------------------------------------------------*
|
||||
;* Functions: *
|
||||
;* *
|
||||
;* void Shadow_Blit(int xpix, int ypix, int width, int height, GVPC src, GVPC dst, void *shadowbuff);
|
||||
;* *
|
||||
;* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - *
|
||||
|
||||
IDEAL
|
||||
P386
|
||||
MODEL USE32 FLAT
|
||||
|
||||
INCLUDE ".\drawbuff.inc"
|
||||
INCLUDE ".\gbuffer.inc"
|
||||
INCLUDE ".\keystruc.inc"
|
||||
|
||||
GLOBAL C Shadow_Blit : NEAR
|
||||
|
||||
GLOBAL C RealModePtr : DWORD
|
||||
GLOBAL C Hide_Mouse : NEAR
|
||||
GLOBAL C Show_Mouse : NEAR
|
||||
|
||||
CODESEG
|
||||
|
||||
; void Shadow_Blit(int xpix, int ypix, int width, int height, GVPC src, VBC dst, void *shadowbuff);
|
||||
; Warning: Shadow_Blit appears to be relatively stupid, in that while it is
|
||||
; optimized to perform word or dword blits, it only does so if the
|
||||
; entire region is word or dword-sized. In other words, if you blit
|
||||
; a region that is 200 pixels wide (clearly dword-sized), then it
|
||||
; will use the dword loop. However, if you blit a region that is
|
||||
; 201 pixels wide, the dumb thing will use the byte loop for the
|
||||
; entire blit.
|
||||
PROC Shadow_Blit C near
|
||||
USES eax,ebx,ecx,edx,esi,edi
|
||||
|
||||
ARG x:DWORD
|
||||
ARG y:DWORD
|
||||
ARG region_width:DWORD
|
||||
ARG region_height:DWORD
|
||||
ARG srcpage:DWORD
|
||||
ARG dstpage:DWORD
|
||||
ARG shadow:DWORD
|
||||
|
||||
LOCAL modulo:DWORD ; Row modulo
|
||||
LOCAL hidemouse:DWORD ; Was the mouse hidden?
|
||||
LOCAL dwordwidth:DWORD
|
||||
LOCAL bytewidth:DWORD
|
||||
|
||||
cld ; Always move forward.
|
||||
mov [hidemouse],0 ; Presume mouse hasn't been hidden.
|
||||
|
||||
; Fetch the segment of the seenpage.
|
||||
mov ebx,[dstpage]
|
||||
mov ebx,[(GraphicViewPort ebx).GVPOffset]
|
||||
|
||||
; Determine if the mouse needs to be hidden at all. If this happens to be
|
||||
; a shadow blit to non visible page (who knows why!?) then don't bother to
|
||||
; hide the mouse since it isn't necessary.
|
||||
; cmp ebx,0A0000h
|
||||
; setne [BYTE PTR hidemouse] ; Flag that mouse need not be hidden.
|
||||
; jne short ??itsok
|
||||
mov esi,[RealModePtr]
|
||||
cmp [(KeyboardType esi).MState],0
|
||||
je short ??itsok
|
||||
mov [hidemouse],1
|
||||
call Hide_Mouse C ; Hides mouse again (just to be sure).
|
||||
??itsok:
|
||||
mov edi,[srcpage]
|
||||
mov esi,[(GraphicViewPort edi).GVPOffset]
|
||||
|
||||
mov eax,[(GraphicViewPort edi).GVPWidth]
|
||||
add eax,[(GraphicViewPort edi).GVPXAdd]
|
||||
add eax,[(GraphicViewPort edi).GVPPitch]
|
||||
push eax ; save width+xadd for later calc
|
||||
mov edx,[y]
|
||||
mul edx
|
||||
add eax,[x]
|
||||
add esi,eax
|
||||
; At this point, esi points to the source page and ebx points to the dest page
|
||||
sub ebx,esi ; esi+ebx == dest page pointer
|
||||
|
||||
mov edi,[shadow] ; EDI points to shadow buffer.
|
||||
|
||||
mov ecx,[region_height] ; get the height of the window in cx
|
||||
|
||||
mov edx,[RealModePtr]
|
||||
|
||||
; Calculate the row add module.
|
||||
pop eax ; restore width+xadd
|
||||
sub eax,[region_width]
|
||||
mov [modulo],eax
|
||||
|
||||
mov eax,[region_width]
|
||||
shr eax,2
|
||||
mov [dwordwidth],eax
|
||||
mov eax,[region_width]
|
||||
and eax,3
|
||||
mov [bytewidth],eax
|
||||
|
||||
;---------------------------------------
|
||||
; DOUBLE WORD shadow blit if possible.
|
||||
;---------------------------------------
|
||||
??dloop_top:
|
||||
push ecx
|
||||
mov ecx,[dwordwidth]
|
||||
|
||||
??lcontinue:
|
||||
repe cmpsd ; check the entire row for changed longs
|
||||
je short ??loop_top
|
||||
|
||||
; If this row would interfere with the mouse image, then hide it.
|
||||
cmp [hidemouse],0
|
||||
jnz short ??dok
|
||||
mov eax,[(KeyboardType edx).MouseY]
|
||||
sub eax,[(KeyboardType edx).MouseYHot]
|
||||
cmp eax,[y]
|
||||
jg short ??dok
|
||||
add eax,[(KeyboardType edx).MouseHeight]
|
||||
cmp eax,[y]
|
||||
jb short ??dok
|
||||
mov [hidemouse],1 ; Manual hide of the mouse.
|
||||
call Hide_Mouse C
|
||||
??dok:
|
||||
|
||||
mov eax,[esi-4]
|
||||
mov [ebx+esi-4],eax ; Update destination page.
|
||||
mov [edi-4],eax ; Update shadow buffer.
|
||||
or ecx,ecx
|
||||
jne short ??lcontinue
|
||||
|
||||
;---------------------------------------
|
||||
; Row loop start for BYTES.
|
||||
;---------------------------------------
|
||||
??loop_top:
|
||||
mov ecx,[bytewidth]
|
||||
|
||||
; Column loop start -- by bytes.
|
||||
??continue:
|
||||
repe cmpsb ; check the entire row for changed longs
|
||||
je short ??done_x
|
||||
|
||||
; If this row would interfere with the mouse image, then hide it.
|
||||
cmp [hidemouse],0
|
||||
jnz short ??bok
|
||||
mov eax,[(KeyboardType edx).MouseY]
|
||||
sub eax,[(KeyboardType edx).MouseYHot]
|
||||
cmp eax,[y]
|
||||
jg short ??bok
|
||||
add eax,[(KeyboardType edx).MouseHeight]
|
||||
cmp eax,[y]
|
||||
jl short ??bok
|
||||
mov [hidemouse],1 ; Manual hide of the mouse.
|
||||
call Hide_Mouse C
|
||||
??bok:
|
||||
|
||||
mov al,[esi-1]
|
||||
mov [ebx+esi-1],al ; Update destination page.
|
||||
mov [edi-1],al ; Update shadow buffer.
|
||||
|
||||
or ecx,ecx
|
||||
jne short ??continue
|
||||
|
||||
??done_x:
|
||||
inc [y]
|
||||
add esi,[modulo]
|
||||
pop ecx
|
||||
dec ecx
|
||||
jnz ??dloop_top
|
||||
|
||||
??fini:
|
||||
; Re show the mouse if it was hidden by this routine.
|
||||
cmp [hidemouse],0
|
||||
je short ??reallyfini
|
||||
call Show_Mouse C
|
||||
??reallyfini:
|
||||
ret
|
||||
|
||||
ENDP Shadow_Blit
|
||||
|
||||
END
|
600
WIN32LIB/DRAWBUFF/STAMP.ASM
Normal file
600
WIN32LIB/DRAWBUFF/STAMP.ASM
Normal file
@@ -0,0 +1,600 @@
|
||||
;
|
||||
; 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 : Westwood Library *
|
||||
;* *
|
||||
;* File Name : STAMP.ASM *
|
||||
;* *
|
||||
;* Programmer : Joe L. Bostic *
|
||||
;* *
|
||||
;* Start Date : August 23, 1993 *
|
||||
;* *
|
||||
;* Last Update : August 23, 1993 [JLB] *
|
||||
;* *
|
||||
;*-------------------------------------------------------------------------*
|
||||
;* Functions: *
|
||||
;* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - *
|
||||
|
||||
IDEAL
|
||||
P386
|
||||
MODEL USE32 FLAT
|
||||
|
||||
INCLUDE ".\drawbuff.inc"
|
||||
INCLUDE ".\gbuffer.inc"
|
||||
|
||||
INCLUDE "stamp.inc"
|
||||
|
||||
global C Init_Stamps:near
|
||||
global LastIconset:dword
|
||||
global MapPtr:dword
|
||||
global IconCount:dword
|
||||
global IconSize:dword
|
||||
global StampPtr:dword
|
||||
|
||||
DATASEG
|
||||
|
||||
|
||||
LastIconset DD 0 ; Pointer to last iconset initialized.
|
||||
StampPtr DD 0 ; Pointer to icon data.
|
||||
|
||||
IsTrans DD 0 ; Pointer to transparent icon flag table.
|
||||
|
||||
MapPtr DD 0 ; Pointer to icon map.
|
||||
IconWidth DD 0 ; Width of icon in pixels.
|
||||
IconHeight DD 0 ; Height of icon in pixels.
|
||||
IconSize DD 0 ; Number of bytes for each icon data.
|
||||
IconCount DD 0 ; Number of icons in the set.
|
||||
|
||||
EVEN
|
||||
|
||||
CODESEG
|
||||
|
||||
|
||||
GLOBAL C Buffer_Draw_Stamp:near
|
||||
GLOBAL C Buffer_Draw_Stamp_Clip:near
|
||||
|
||||
; 256 color icon system.
|
||||
|
||||
;***********************************************************
|
||||
; INIT_STAMPS
|
||||
;
|
||||
; VOID cdecl Init_Stamps(VOID *icondata);
|
||||
;
|
||||
; This routine initializes the stamp data.
|
||||
; Bounds Checking: NONE
|
||||
;
|
||||
;*
|
||||
PROC Init_Stamps C near USES eax ebx edx edi
|
||||
ARG icondata:DWORD
|
||||
|
||||
; Verify legality of parameter.
|
||||
cmp [icondata],0
|
||||
je short ??fini
|
||||
|
||||
; Don't initialize if already initialized to this set (speed reasons).
|
||||
mov edi,[icondata]
|
||||
cmp [LastIconset],edi
|
||||
je short ??fini
|
||||
mov [LastIconset],edi
|
||||
|
||||
; Record number of icons in set.
|
||||
movzx eax,[(IControl_Type edi).Count]
|
||||
mov [IconCount],eax
|
||||
|
||||
; Record width of icon.
|
||||
movzx eax,[(IControl_Type edi).Width]
|
||||
mov [IconWidth],eax
|
||||
|
||||
; Record height of icon.
|
||||
movzx ebx,[(IControl_Type edi).Height]
|
||||
mov [IconHeight],ebx
|
||||
|
||||
; Record size of icon (in bytes).
|
||||
mul ebx
|
||||
mov [IconSize],eax
|
||||
|
||||
; Record hard pointer to icon map data.
|
||||
mov eax,[(IControl_Type edi).Map]
|
||||
add eax,edi
|
||||
mov [MapPtr],eax
|
||||
|
||||
??nomap:
|
||||
; Record hard pointer to icon data.
|
||||
mov eax,edi
|
||||
add eax,[(IControl_Type edi).Icons]
|
||||
mov [StampPtr],eax
|
||||
|
||||
; Record the transparent table.
|
||||
mov eax,edi
|
||||
add eax,[(IControl_Type edi).TransFlag]
|
||||
mov [IsTrans],eax
|
||||
|
||||
??fini:
|
||||
ret
|
||||
|
||||
ENDP Init_Stamps
|
||||
|
||||
|
||||
;***********************************************************
|
||||
|
||||
|
||||
;***********************************************************
|
||||
; DRAW_STAMP
|
||||
;
|
||||
; VOID cdecl Buffer_Draw_Stamp(VOID *icondata, WORD icon, WORD x_pixel, WORD y_pixel, VOID *remap);
|
||||
;
|
||||
; This routine renders the icon at the given coordinate.
|
||||
;
|
||||
; The remap table is a 256 byte simple pixel translation table to use when
|
||||
; drawing the icon. Transparency check is performed AFTER the remap so it is possible to
|
||||
; remap valid colors to be invisible (for special effect reasons).
|
||||
; This routine is fastest when no remap table is passed in.
|
||||
;*
|
||||
PROC Buffer_Draw_Stamp C near
|
||||
|
||||
ARG this_object:DWORD ; this is a member function
|
||||
ARG icondata:DWORD ; Pointer to icondata.
|
||||
ARG icon:DWORD ; Icon number to draw.
|
||||
ARG x_pixel:DWORD ; X coordinate of icon.
|
||||
ARG y_pixel:DWORD ; Y coordinate of icon.
|
||||
ARG remap:DWORD ; Remap table.
|
||||
|
||||
LOCAL modulo:DWORD ; Modulo to get to next row.
|
||||
LOCAL iwidth:DWORD ; Icon width (here for speedy access).
|
||||
LOCAL doremap:BYTE ; Should remapping occur?
|
||||
|
||||
pushad
|
||||
cmp [icondata],0
|
||||
je ??out
|
||||
|
||||
; Initialize the stamp data if necessary.
|
||||
mov eax,[icondata]
|
||||
cmp [LastIconset],eax
|
||||
je short ??noreset
|
||||
call Init_Stamps C,eax
|
||||
??noreset:
|
||||
|
||||
; Determine if the icon number requested is actually in the set.
|
||||
; Perform the logical icon to actual icon number remap if necessary.
|
||||
mov ebx,[icon]
|
||||
cmp [MapPtr],0
|
||||
je short ??notmap
|
||||
mov edi,[MapPtr]
|
||||
mov bl,[edi+ebx]
|
||||
??notmap:
|
||||
cmp ebx,[IconCount]
|
||||
jae ??out
|
||||
mov [icon],ebx ; Updated icon number.
|
||||
|
||||
; If the remap table pointer passed in is NULL, then flag this condition
|
||||
; so that the faster (non-remapping) icon draw loop will be used.
|
||||
cmp [remap],0
|
||||
setne [doremap]
|
||||
|
||||
; Get pointer to position to render icon. EDI = ptr to destination page.
|
||||
mov ebx,[this_object]
|
||||
mov edi,[(GraphicViewPort ebx).GVPOffset]
|
||||
mov eax,[(GraphicViewPort ebx).GVPWidth]
|
||||
add eax,[(GraphicViewPort ebx).GVPXAdd]
|
||||
add eax,[(GraphicViewPort ebx).GVPPitch]
|
||||
push eax ; save viewport full width for lower
|
||||
mul [y_pixel]
|
||||
add edi,eax
|
||||
add edi,[x_pixel]
|
||||
|
||||
; Determine row modulo for advancing to next line.
|
||||
pop eax ; retrieve viewport width
|
||||
sub eax,[IconWidth]
|
||||
mov [modulo],eax
|
||||
|
||||
; Setup some working variables.
|
||||
mov ecx,[IconHeight] ; Row counter.
|
||||
mov eax,[IconWidth]
|
||||
mov [iwidth],eax ; Stack copy of byte width for easy BP access.
|
||||
|
||||
; Fetch pointer to start of icon's data. ESI = ptr to icon data.
|
||||
mov eax,[icon]
|
||||
mul [IconSize]
|
||||
mov esi,[StampPtr]
|
||||
add esi,eax
|
||||
|
||||
; Determine whether simple icon draw is sufficient or whether the
|
||||
; extra remapping icon draw is needed.
|
||||
cmp [BYTE PTR doremap],0
|
||||
je short ??istranscheck
|
||||
|
||||
;************************************************************
|
||||
; Complex icon draw -- extended remap.
|
||||
; EBX = Palette pointer (ready for XLAT instruction).
|
||||
; EDI = Pointer to icon destination in page.
|
||||
; ESI = Pointer to icon data.
|
||||
; ECX = Number of pixel rows.
|
||||
;;; mov edx,[remap]
|
||||
mov ebx,[remap]
|
||||
xor eax,eax
|
||||
??xrowloop:
|
||||
push ecx
|
||||
mov ecx,[iwidth]
|
||||
|
||||
??xcolumnloop:
|
||||
lodsb
|
||||
;;; mov ebx,edx
|
||||
;;; add ebx,eax
|
||||
;;; mov al,[ebx] ; New real color to draw.
|
||||
xlatb
|
||||
or al,al
|
||||
jz short ??xskip1 ; Transparency skip check.
|
||||
mov [edi],al
|
||||
??xskip1:
|
||||
inc edi
|
||||
loop ??xcolumnloop
|
||||
|
||||
pop ecx
|
||||
add edi,[modulo]
|
||||
loop ??xrowloop
|
||||
jmp short ??out
|
||||
|
||||
|
||||
;************************************************************
|
||||
; Check to see if transparent or generic draw is necessary.
|
||||
??istranscheck:
|
||||
mov ebx,[IsTrans]
|
||||
add ebx,[icon]
|
||||
cmp [BYTE PTR ebx],0
|
||||
jne short ??rowloop
|
||||
|
||||
;************************************************************
|
||||
; Fast non-transparent icon draw routine.
|
||||
; ES:DI = Pointer to icon destination in page.
|
||||
; DS:SI = Pointer to icon data.
|
||||
; CX = Number of pixel rows.
|
||||
mov ebx,ecx
|
||||
shr ebx,2
|
||||
mov edx,[modulo]
|
||||
mov eax,[iwidth]
|
||||
shr eax,2
|
||||
??loop1:
|
||||
mov ecx,eax
|
||||
rep movsd
|
||||
add edi,edx
|
||||
|
||||
mov ecx,eax
|
||||
rep movsd
|
||||
add edi,edx
|
||||
|
||||
mov ecx,eax
|
||||
rep movsd
|
||||
add edi,edx
|
||||
|
||||
mov ecx,eax
|
||||
rep movsd
|
||||
add edi,edx
|
||||
|
||||
dec ebx
|
||||
jnz ??loop1
|
||||
jmp short ??out
|
||||
|
||||
;************************************************************
|
||||
; Transparent icon draw routine -- no extended remap.
|
||||
; ES:DI = Pointer to icon destination in page.
|
||||
; DS:SI = Pointer to icon data.
|
||||
; CX = Number of pixel rows.
|
||||
??rowloop:
|
||||
push ecx
|
||||
mov ecx,[iwidth]
|
||||
|
||||
??columnloop:
|
||||
lodsb
|
||||
or al,al
|
||||
jz short ??skip1 ; Transparency check.
|
||||
mov [edi],al
|
||||
??skip1:
|
||||
inc edi
|
||||
loop ??columnloop
|
||||
|
||||
pop ecx
|
||||
add edi,[modulo]
|
||||
loop ??rowloop
|
||||
|
||||
; Cleanup and exit icon drawing routine.
|
||||
??out:
|
||||
popad
|
||||
ret
|
||||
|
||||
ENDP Buffer_Draw_Stamp
|
||||
|
||||
|
||||
|
||||
|
||||
;***********************************************************
|
||||
; DRAW_STAMP_CLIP
|
||||
;
|
||||
; VOID cdecl MCGA_Draw_Stamp_Clip(VOID *icondata, WORD icon, WORD x_pixel, WORD y_pixel, VOID *remap, LONG min_x, LONG min_y, LONG max_x, LONG max_y);
|
||||
;
|
||||
; This routine renders the icon at the given coordinate.
|
||||
;
|
||||
; The remap table is a 256 byte simple pixel translation table to use when
|
||||
; drawing the icon. Transparency check is performed AFTER the remap so it is possible to
|
||||
; remap valid colors to be invisible (for special effect reasons).
|
||||
; This routine is fastest when no remap table is passed in.
|
||||
;*
|
||||
PROC Buffer_Draw_Stamp_Clip C near
|
||||
|
||||
ARG this_object:DWORD ; this is a member function
|
||||
ARG icondata:DWORD ; Pointer to icondata.
|
||||
ARG icon:DWORD ; Icon number to draw.
|
||||
ARG x_pixel:DWORD ; X coordinate of icon.
|
||||
ARG y_pixel:DWORD ; Y coordinate of icon.
|
||||
ARG remap:DWORD ; Remap table.
|
||||
ARG min_x:DWORD ; Clipping rectangle boundary
|
||||
ARG min_y:DWORD ; Clipping rectangle boundary
|
||||
ARG max_x:DWORD ; Clipping rectangle boundary
|
||||
ARG max_y:DWORD ; Clipping rectangle boundary
|
||||
|
||||
LOCAL modulo:DWORD ; Modulo to get to next row.
|
||||
LOCAL iwidth:DWORD ; Icon width (here for speedy access).
|
||||
LOCAL skip:DWORD ; amount to skip per row of icon data
|
||||
LOCAL doremap:BYTE ; Should remapping occur?
|
||||
|
||||
pushad
|
||||
cmp [icondata],0
|
||||
je ??out2
|
||||
|
||||
; Initialize the stamp data if necessary.
|
||||
mov eax,[icondata]
|
||||
cmp [LastIconset],eax
|
||||
je short ??noreset2
|
||||
call Init_Stamps C,eax
|
||||
??noreset2:
|
||||
|
||||
; Determine if the icon number requested is actually in the set.
|
||||
; Perform the logical icon to actual icon number remap if necessary.
|
||||
mov ebx,[icon]
|
||||
cmp [MapPtr],0
|
||||
je short ??notmap2
|
||||
mov edi,[MapPtr]
|
||||
mov bl,[edi+ebx]
|
||||
??notmap2:
|
||||
cmp ebx,[IconCount]
|
||||
jae ??out2
|
||||
mov [icon],ebx ; Updated icon number.
|
||||
|
||||
; Setup some working variables.
|
||||
mov ecx,[IconHeight] ; Row counter.
|
||||
mov eax,[IconWidth]
|
||||
mov [iwidth],eax ; Stack copy of byte width for easy BP access.
|
||||
|
||||
; Fetch pointer to start of icon's data. ESI = ptr to icon data.
|
||||
mov eax,[icon]
|
||||
mul [IconSize]
|
||||
mov esi,[StampPtr]
|
||||
add esi,eax
|
||||
|
||||
; Update the clipping window coordinates to be valid maxes instead of width & height
|
||||
; , and change the coordinates to be window-relative
|
||||
mov ebx,[min_x]
|
||||
add [max_x],ebx
|
||||
add [x_pixel],ebx ; make it window-relative
|
||||
mov ebx,[min_y]
|
||||
add [max_y],ebx
|
||||
add [y_pixel],ebx ; make it window-relative
|
||||
|
||||
; See if the icon is within the clipping window
|
||||
; First, verify that the icon position is less than the maximums
|
||||
mov ebx,[x_pixel]
|
||||
cmp ebx,[max_x]
|
||||
jge ??out2
|
||||
mov ebx,[y_pixel]
|
||||
cmp ebx,[max_y]
|
||||
jge ??out2
|
||||
; Now verify that the icon position is >= the minimums
|
||||
add ebx,[IconHeight]
|
||||
cmp ebx,[min_y]
|
||||
jle ??out2
|
||||
mov ebx,[x_pixel]
|
||||
add ebx,[IconWidth]
|
||||
cmp ebx,[min_x]
|
||||
jle ??out2
|
||||
|
||||
; Now, clip the x, y, width, and height variables to be within the
|
||||
; clipping rectangle
|
||||
mov ebx,[x_pixel]
|
||||
cmp ebx,[min_x]
|
||||
jge ??nominxclip
|
||||
; x < minx, so must clip
|
||||
mov ebx,[min_x]
|
||||
sub ebx,[x_pixel]
|
||||
add esi,ebx ; source ptr += (minx - x)
|
||||
sub [iwidth],ebx ; icon width -= (minx - x)
|
||||
mov ebx,[min_x]
|
||||
mov [x_pixel],ebx
|
||||
|
||||
??nominxclip:
|
||||
mov eax,[IconWidth]
|
||||
sub eax,[iwidth]
|
||||
mov [skip],eax
|
||||
|
||||
; Check for x+width > max_x
|
||||
mov eax,[x_pixel]
|
||||
add eax,[iwidth]
|
||||
cmp eax,[max_x]
|
||||
jle ??nomaxxclip
|
||||
; x+width is greater than max_x, so must clip width down
|
||||
mov eax,[iwidth] ; eax = old width
|
||||
mov ebx,[max_x]
|
||||
sub ebx,[x_pixel]
|
||||
mov [iwidth],ebx ; iwidth = max_x - xpixel
|
||||
sub eax,ebx
|
||||
add [skip],eax ; skip += (old width - iwidth)
|
||||
??nomaxxclip:
|
||||
; check if y < miny
|
||||
mov eax,[min_y]
|
||||
cmp eax,[y_pixel] ; if(miny <= y_pixel), no clip needed
|
||||
jle ??nominyclip
|
||||
sub eax,[y_pixel]
|
||||
sub ecx,eax ; height -= (miny - y)
|
||||
mul [IconWidth]
|
||||
add esi,eax ; icon source ptr += (width * (miny - y))
|
||||
mov eax,[min_y]
|
||||
mov [y_pixel],eax ; y = miny
|
||||
??nominyclip:
|
||||
; check if (y+height) > max y
|
||||
mov eax,[y_pixel]
|
||||
add eax,ecx
|
||||
cmp eax,[max_y] ; if (y + height <= max_y), no clip needed
|
||||
jle ??nomaxyclip
|
||||
mov ecx,[max_y] ; height = max_y - y_pixel
|
||||
sub ecx,[y_pixel]
|
||||
??nomaxyclip:
|
||||
|
||||
; If the remap table pointer passed in is NULL, then flag this condition
|
||||
; so that the faster (non-remapping) icon draw loop will be used.
|
||||
cmp [remap],0
|
||||
setne [doremap]
|
||||
|
||||
; Get pointer to position to render icon. EDI = ptr to destination page.
|
||||
mov ebx,[this_object]
|
||||
mov edi,[(GraphicViewPort ebx).GVPOffset]
|
||||
mov eax,[(GraphicViewPort ebx).GVPWidth]
|
||||
add eax,[(GraphicViewPort ebx).GVPXAdd]
|
||||
add eax,[(GraphicViewPort ebx).GVPPitch]
|
||||
push eax ; save viewport full width for lower
|
||||
mul [y_pixel]
|
||||
add edi,eax
|
||||
add edi,[x_pixel]
|
||||
|
||||
; Determine row modulo for advancing to next line.
|
||||
pop eax ; retrieve viewport width
|
||||
sub eax,[iwidth]
|
||||
mov [modulo],eax
|
||||
|
||||
; Determine whether simple icon draw is sufficient or whether the
|
||||
; extra remapping icon draw is needed.
|
||||
cmp [BYTE PTR doremap],0
|
||||
je short ??istranscheck2
|
||||
|
||||
;************************************************************
|
||||
; Complex icon draw -- extended remap.
|
||||
; EBX = Palette pointer (ready for XLAT instruction).
|
||||
; EDI = Pointer to icon destination in page.
|
||||
; ESI = Pointer to icon data.
|
||||
; ECX = Number of pixel rows.
|
||||
mov ebx,[remap]
|
||||
xor eax,eax
|
||||
??xrowloopc:
|
||||
push ecx
|
||||
mov ecx,[iwidth]
|
||||
|
||||
??xcolumnloopc:
|
||||
lodsb
|
||||
xlatb
|
||||
or al,al
|
||||
jz short ??xskip1c ; Transparency skip check.
|
||||
mov [edi],al
|
||||
??xskip1c:
|
||||
inc edi
|
||||
loop ??xcolumnloopc
|
||||
|
||||
pop ecx
|
||||
add edi,[modulo]
|
||||
add esi,[skip]
|
||||
loop ??xrowloopc
|
||||
jmp short ??out2
|
||||
|
||||
|
||||
;************************************************************
|
||||
; Check to see if transparent or generic draw is necessary.
|
||||
??istranscheck2:
|
||||
mov ebx,[IsTrans]
|
||||
add ebx,[icon]
|
||||
cmp [BYTE PTR ebx],0
|
||||
jne short ??rowloopc
|
||||
|
||||
;************************************************************
|
||||
; Fast non-transparent icon draw routine.
|
||||
; ES:DI = Pointer to icon destination in page.
|
||||
; DS:SI = Pointer to icon data.
|
||||
; CX = Number of pixel rows.
|
||||
mov ebx,ecx
|
||||
mov edx,[modulo]
|
||||
mov eax,[iwidth]
|
||||
|
||||
;
|
||||
; Optimise copy by dword aligning the destination
|
||||
;
|
||||
??loop1c:
|
||||
push eax
|
||||
rept 3
|
||||
test edi,3
|
||||
jz ??aligned
|
||||
movsb
|
||||
dec eax
|
||||
jz ??finishedit
|
||||
endm
|
||||
??aligned:
|
||||
mov ecx,eax
|
||||
shr ecx,2
|
||||
rep movsd
|
||||
mov ecx,eax
|
||||
and ecx,3
|
||||
rep movsb
|
||||
|
||||
??finishedit:
|
||||
add edi,edx
|
||||
add esi,[skip]
|
||||
pop eax
|
||||
|
||||
dec ebx
|
||||
jnz ??loop1c
|
||||
jmp short ??out2
|
||||
|
||||
;************************************************************
|
||||
; Transparent icon draw routine -- no extended remap.
|
||||
; ES:DI = Pointer to icon destination in page.
|
||||
; DS:SI = Pointer to icon data.
|
||||
; CX = Number of pixel rows.
|
||||
??rowloopc:
|
||||
push ecx
|
||||
mov ecx,[iwidth]
|
||||
|
||||
??columnloopc:
|
||||
lodsb
|
||||
or al,al
|
||||
jz short ??skip1c ; Transparency check.
|
||||
mov [edi],al
|
||||
??skip1c:
|
||||
inc edi
|
||||
loop ??columnloopc
|
||||
|
||||
pop ecx
|
||||
add edi,[modulo]
|
||||
add esi,[skip]
|
||||
loop ??rowloopc
|
||||
|
||||
; Cleanup and exit icon drawing routine.
|
||||
??out2:
|
||||
popad
|
||||
ret
|
||||
|
||||
ENDP Buffer_Draw_Stamp_Clip
|
||||
|
||||
END
|
59
WIN32LIB/DRAWBUFF/STAMP.INC
Normal file
59
WIN32LIB/DRAWBUFF/STAMP.INC
Normal file
@@ -0,0 +1,59 @@
|
||||
;
|
||||
; 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/>.
|
||||
;
|
||||
|
||||
; This is the control structure at the start of a loaded icon set. It must match
|
||||
; the structure in ICONSET.C! This structure MUST be a multiple of 16 bytes long.
|
||||
|
||||
ifdef NO_WAY_THIS_WILL_BE_DEFINED_HAHAHAHA
|
||||
|
||||
STRUC IControl_Type
|
||||
Width DW ? ; Width in pixels (per icon).
|
||||
Height DW ? ; Height in pixels (per icon).
|
||||
Count DW ? ; Number of icons in this set.
|
||||
Allocated DW ? ; Was this iconset allocated?
|
||||
Size DD ? ; Size of entire iconset memory block.
|
||||
Icons DD ? ; Offset from buffer start to icon data.
|
||||
Palettes DD ? ; Offset from buffer start to palette data.
|
||||
Remaps DD ? ; Offset from buffer start to remap index data.
|
||||
TransFlag DD ? ; Offset for transparency flag data.
|
||||
Map DD ? ; Icon map offset.
|
||||
ENDS
|
||||
|
||||
else
|
||||
|
||||
|
||||
STRUC IControl_Type
|
||||
|
||||
Width DW ? ; Width in pixels (per icon).
|
||||
Height DW ? ; Height in pixels (per icon).
|
||||
Count DW ? ; Number of icons in this set.
|
||||
Allocated DW ? ; Was this iconset allocated?
|
||||
MapWidth DW ?
|
||||
MapHeight DW ?
|
||||
Size DD ? ; Size of entire iconset memory block.
|
||||
Icons DD ? ; Offset from buffer start to icon data.
|
||||
Palettes DD ? ; Offset from buffer start to palette data.
|
||||
Remaps DD ? ; Offset from buffer start to remap index data.
|
||||
TransFlag DD ? ; Offset for transparency flag data.
|
||||
ColorMap DD ?
|
||||
Map DD ? ; Icon map offset.
|
||||
ENDS
|
||||
|
||||
endif
|
||||
|
||||
ICON256 EQU 1
|
284
WIN32LIB/DRAWBUFF/STMPCACH.ASM
Normal file
284
WIN32LIB/DRAWBUFF/STMPCACH.ASM
Normal file
@@ -0,0 +1,284 @@
|
||||
;
|
||||
; 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 : Westwood Library *
|
||||
;* *
|
||||
;* File Name : STAMP.ASM *
|
||||
;* *
|
||||
;* Programmer : Joe L. Bostic *
|
||||
;* *
|
||||
;* Start Date : August 23, 1993 *
|
||||
;* *
|
||||
;* Last Update : August 23, 1993 [JLB] *
|
||||
;* *
|
||||
;*-------------------------------------------------------------------------*
|
||||
;* Functions: *
|
||||
;* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - *
|
||||
|
||||
IDEAL
|
||||
P386
|
||||
MODEL USE32 FLAT
|
||||
JUMPS
|
||||
|
||||
MAX_CACHED_ICONS=300
|
||||
ICON_WIDTH =24
|
||||
ICON_HEIGHT =24
|
||||
MAX_ICON_SETS =100
|
||||
|
||||
|
||||
global C IconPointers:dword
|
||||
global C Init_Stamps:near
|
||||
global C IconCacheLookup:word
|
||||
global LastIconset:dword
|
||||
global MapPtr:dword
|
||||
global IconCount:dword
|
||||
global IconSize:dword
|
||||
global StampPtr:dword
|
||||
global IconEntry:dword
|
||||
global IconData:dword
|
||||
|
||||
global Clear_Icon_Pointers_:near
|
||||
global Cache_Copy_Icon_:near
|
||||
global Is_Icon_Cached_:near
|
||||
global Get_Icon_Index_:near
|
||||
global Get_Free_Index_:near
|
||||
global Cache_New_Icon_:near
|
||||
global Is_Stamp_Registered_:near
|
||||
global Get_Free_Cache_Slot_:near
|
||||
|
||||
|
||||
struc IconSetType
|
||||
|
||||
IconSetPtr dd ?
|
||||
IconListOffset dd ?
|
||||
|
||||
ends
|
||||
|
||||
global C IconSetList:IconSetType
|
||||
|
||||
codeseg
|
||||
|
||||
|
||||
|
||||
;************************************************************************************************
|
||||
;* Cache_Copy_Icon -- copy an icon to its video memory cache *
|
||||
;* *
|
||||
;* *
|
||||
;* INPUT: eax - ptr to icon_data *
|
||||
;* edx - ptr to video surface *
|
||||
;* ebx - pitch of video surface *
|
||||
;* *
|
||||
;* OUTPUT: none *
|
||||
;* *
|
||||
;* PROTO: extern "C" Cache_Copy_Icon (void const *icon_ptr , *
|
||||
;* VideoSurfaceDescription.lpSurface , *
|
||||
;* VideoSurfaceDescription.lPitch); *
|
||||
;* *
|
||||
;* HISTORY: *
|
||||
;* 11/8/95 3:16PM ST: Created *
|
||||
;*==============================================================================================*
|
||||
|
||||
proc Cache_Copy_Icon_ near
|
||||
pushad
|
||||
|
||||
mov esi,eax
|
||||
mov edi,edx
|
||||
sub ebx,ICON_WIDTH
|
||||
|
||||
mov dl,ICON_HEIGHT ;icon height
|
||||
|
||||
??each_line_lp: mov ecx,ICON_WIDTH/4
|
||||
rep movsd
|
||||
lea edi,[edi+ebx]
|
||||
dec dl
|
||||
jnz ??each_line_lp
|
||||
|
||||
popad
|
||||
ret
|
||||
|
||||
endp Cache_Copy_Icon_
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
;************************************************************************************************
|
||||
;* Is_Icon_Cached -- has an icon been cached? If not, is it cacheable? *
|
||||
;* *
|
||||
;* *
|
||||
;* INPUT: eax - ptr to icon_data *
|
||||
;* edx - icon number *
|
||||
;* *
|
||||
;* OUTPUT: eax - index of cached icon or -1 if not cached *
|
||||
;* *
|
||||
;* PROTO: extern "C" int Is_Icon_Cached (void const *icon_data , int icon); *
|
||||
;* *
|
||||
;* HISTORY: *
|
||||
;* 11/8/95 2:16PM ST: Created *
|
||||
;*==============================================================================================*
|
||||
|
||||
proc Is_Icon_Cached_ near
|
||||
|
||||
mov [IconData],eax ;save the icon data ptr for later
|
||||
push edx
|
||||
test eax,eax
|
||||
je ??out
|
||||
|
||||
; Initialize the stamp data if necessary.
|
||||
cmp [LastIconset],eax
|
||||
je short ??noreset
|
||||
call Init_Stamps C,eax
|
||||
|
||||
; Determine if the icon number requested is actually in the set.
|
||||
; Perform the logical icon to actual icon number remap if necessary.
|
||||
??noreset: cmp [MapPtr],0
|
||||
je short ??notmap
|
||||
push edi
|
||||
mov edi,[MapPtr]
|
||||
mov dl,[edi+edx]
|
||||
pop edi
|
||||
|
||||
??notmap: cmp edx,[IconCount]
|
||||
jl ??in_range
|
||||
pop edx
|
||||
mov eax,-1
|
||||
ret
|
||||
|
||||
; See if the stamp is registered - if not then it cant be cached
|
||||
??in_range: mov eax,[IconData]
|
||||
call Is_Stamp_Registered_
|
||||
cmp eax,-1
|
||||
jnz ??got_entry
|
||||
pop edx
|
||||
ret
|
||||
|
||||
; Stamp is registered - if its cached already then just return the index
|
||||
??got_entry: mov eax,[(IconSetType eax).IconListOffset]
|
||||
cmp [word eax+edx*2+IconCacheLookup],-1
|
||||
jz ??not_cached
|
||||
|
||||
; it is cached and [eax+edx] is the index
|
||||
movzx eax,[word eax+edx*2+IconCacheLookup]
|
||||
pop edx
|
||||
ret
|
||||
|
||||
|
||||
|
||||
;
|
||||
; The stamps set is registered but we havn't seen this stamp before
|
||||
; so try caching it
|
||||
;
|
||||
|
||||
??not_cached: mov [IconEntry],eax
|
||||
add [IconEntry],edx
|
||||
add [IconEntry],edx
|
||||
call Get_Free_Cache_Slot_
|
||||
test eax,eax
|
||||
jge ??got_free_slot
|
||||
pop edx ;eax is -1 here anyway
|
||||
ret
|
||||
|
||||
; We found a free caching slot so try caching the stamp into it
|
||||
??got_free_slot:imul edx,[IconSize]
|
||||
add edx,[StampPtr]
|
||||
push eax
|
||||
call Cache_New_Icon_ ;takes icon index in eax, ptr to icon in edx
|
||||
test eax,eax
|
||||
jz ??cache_failed
|
||||
|
||||
|
||||
; Success! Add the index into the table
|
||||
pop eax
|
||||
mov edx,[IconEntry]
|
||||
mov [edx+IconCacheLookup],ax
|
||||
and eax,0ffffh
|
||||
pop edx
|
||||
ret
|
||||
|
||||
; Couldnt cache the new Icon - return -1 to say icon isnt cached
|
||||
??cache_failed: pop eax
|
||||
??out: pop edx
|
||||
mov eax,-1
|
||||
ret
|
||||
|
||||
|
||||
endp Is_Icon_Cached_
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
;************************************************************************************************
|
||||
;* Is_Stamp_Registered -- has an icon's set been previously registered? *
|
||||
;* *
|
||||
;* *
|
||||
;* INPUT: eax - ptr to icon_data *
|
||||
;* *
|
||||
;* OUTPUT: eax - ptr to registration entry or -1 if not registered *
|
||||
;* *
|
||||
;* PROTO: extern "C" int Is_Stamp_Registered (void const *icon_data); *
|
||||
;* *
|
||||
;* HISTORY: *
|
||||
;* 11/10/95 10:00AM ST: Created *
|
||||
;*==============================================================================================*
|
||||
|
||||
proc Is_Stamp_Registered_
|
||||
|
||||
push edi
|
||||
push ecx
|
||||
mov edi,offset IconSetList
|
||||
mov ecx,MAX_ICON_SETS
|
||||
|
||||
??each_set_lp: cmp eax,[edi]
|
||||
jz ??got_icon_set
|
||||
add edi,size IconSetType
|
||||
dec ecx
|
||||
jnz ??each_set_lp
|
||||
mov eax,-1
|
||||
pop ecx
|
||||
pop edi
|
||||
ret
|
||||
|
||||
??got_icon_set: mov eax,edi
|
||||
pop ecx
|
||||
pop edi
|
||||
ret
|
||||
|
||||
endp Is_Stamp_Registered_
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
dataseg
|
||||
|
||||
|
||||
IconEntry dd 0 ;Temporary pointer to icon index entry in table
|
||||
IconData dd 0 ;Temporary ptr to icon set data
|
||||
|
||||
|
||||
|
||||
end
|
101
WIN32LIB/DRAWBUFF/SZREGION.ASM
Normal file
101
WIN32LIB/DRAWBUFF/SZREGION.ASM
Normal file
@@ -0,0 +1,101 @@
|
||||
;
|
||||
; 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 graphic buffer region size *
|
||||
;* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - *
|
||||
|
||||
IDEAL
|
||||
P386
|
||||
MODEL USE32 FLAT
|
||||
|
||||
INCLUDE ".\drawbuff.inc"
|
||||
INCLUDE ".\gbuffer.inc"
|
||||
|
||||
GLOBAL Buffer_Size_Of_Region : NEAR
|
||||
|
||||
CODESEG
|
||||
|
||||
;***************************************************************************
|
||||
;* VVPC::Size_Of_Region - calculate buffer region size *
|
||||
;* *
|
||||
;* INPUT: DWORD the width of the region *
|
||||
;* *
|
||||
;* DWORD the height of the region *
|
||||
;* *
|
||||
;* OUTPUT: calculated size of the region (size = width * height) *
|
||||
;* *
|
||||
;* *
|
||||
;* HISTORY: *
|
||||
;* 03/01/1995 BWG : Created. *
|
||||
;*=========================================================================*
|
||||
PROC Buffer_Size_Of_Region C near
|
||||
USES ebx,ecx,edx
|
||||
|
||||
ARG this_object:DWORD ; this is a member function
|
||||
ARG region_width:DWORD ; width of region
|
||||
ARG region_height:DWORD ; height of region
|
||||
|
||||
;*===================================================================
|
||||
; Get the viewport information
|
||||
;*===================================================================
|
||||
mov ebx,[this_object] ; 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,[region_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,[region_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 Buffer_Size_Of_Region
|
||||
|
||||
END
|
14
WIN32LIB/DRAWBUFF/TEST/HOLD.DEF
Normal file
14
WIN32LIB/DRAWBUFF/TEST/HOLD.DEF
Normal file
@@ -0,0 +1,14 @@
|
||||
IMPORTS
|
||||
DirectDrawCreate=DDRAW.DirectDrawCreate
|
||||
DirectSoundCreate=DSOUND.DirectSoundCreate
|
||||
DirectPlayEnumerate=DPLAY.DirectPlayEnumerate
|
||||
DirectPlayCreate=DPLAY.DirectPlayCreate
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
183
WIN32LIB/DRAWBUFF/TEST/MAKEFILE
Normal file
183
WIN32LIB/DRAWBUFF/TEST/MAKEFILE
Normal file
@@ -0,0 +1,183 @@
|
||||
#
|
||||
# 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 : Westwood Library .EXE makefile *
|
||||
#* *
|
||||
#* File Name : MAKEFILE *
|
||||
#* *
|
||||
#* Programmer : Julio R. Jerez *
|
||||
#* *
|
||||
#* Start Date : Jan 20, 1995 *
|
||||
#* *
|
||||
#* Last Update : *
|
||||
#* *
|
||||
#*-------------------------------------------------------------------------*
|
||||
#* *
|
||||
#* Required environment variables: *
|
||||
#* WIN32LIB = your root WWFLAT path *
|
||||
#* WIN32VCS = root directory for wwlib version control archive *
|
||||
#* COMPILER = your Watcom installation path *
|
||||
#* *
|
||||
#* *
|
||||
#* Required changes to makefile: *
|
||||
#* PROJ_NAME = name of the executable program you're building *
|
||||
#* PROJ_LIBS = Westwood libraries to link your EXE to *
|
||||
#* OBJECTS = list of objects in your current working directory *
|
||||
#* *
|
||||
#* Optional changes to makefile: *
|
||||
#* PROJ_DIR = full pathname of your working directory *
|
||||
#* .xxx: = full pathname where various file types live *
|
||||
#* *
|
||||
#***************************************************************************
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
# Verify user's environment
|
||||
#---------------------------------------------------------------------------
|
||||
!ifndef %WIN32LIB
|
||||
!error WIN32LIB Environment var not configured.
|
||||
!endif
|
||||
|
||||
!ifndef %WIN32VCS
|
||||
!error WIN32VCS Environment var not configured.
|
||||
!endif
|
||||
|
||||
!ifndef %WATCOM
|
||||
!error WATCOM Environment var not configured.
|
||||
!endif
|
||||
|
||||
|
||||
#===========================================================================
|
||||
# User-defined section: the user should tailor this section for each project
|
||||
#===========================================================================
|
||||
#---------------------------------------------------------------------------
|
||||
# PROJ_NAME = library name
|
||||
# PROJ_DIR = directory containing source & objects
|
||||
#---------------------------------------------------------------------------
|
||||
PROJ_NAME = TEST
|
||||
PROJ_DIR = $(%WIN32LIB)\drawbuff\TEST
|
||||
LIB_DIR = $(%WIN32LIB)\lib
|
||||
|
||||
!include $(%WIN32LIB)\project.cfg
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
# Project-dependent variables
|
||||
#---------------------------------------------------------------------------
|
||||
OBJECTS = &
|
||||
$(PROJ_NAME).obj &
|
||||
testasm.obj
|
||||
|
||||
CPS_FILES = &
|
||||
test1.cps &
|
||||
test2.cps
|
||||
|
||||
PROJ_LIBS = &
|
||||
drawbuff.lib &
|
||||
mem.lib &
|
||||
misc.lib &
|
||||
iff.lib &
|
||||
rawfile.lib &
|
||||
tile.lib &
|
||||
font.lib &
|
||||
profile.lib
|
||||
|
||||
#PROJ_LIBS = &
|
||||
# drawbuff.lib &
|
||||
# win32lib.lib
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
# Path macros: one path for each file type.
|
||||
# These paths are used to tell make where to find/put each file type.
|
||||
#---------------------------------------------------------------------------
|
||||
.asm: $(PROJ_DIR)
|
||||
.c: $(PROJ_DIR)
|
||||
.cpp: $(PROJ_DIR)
|
||||
.h: $(PROJ_DIR)
|
||||
.obj: $(PROJ_DIR)
|
||||
.lib: $(%WIN32LIB)\lib
|
||||
.exe: $(PROJ_DIR)
|
||||
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
# Tools/commands
|
||||
#---------------------------------------------------------------------------
|
||||
C_CMD = wcc386
|
||||
CPP_CMD = wpp386
|
||||
LIB_CMD = wlib
|
||||
LINK_CMD = wlink
|
||||
ASM_CMD = tasm
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
# Include & library paths
|
||||
# If LIB & INCLUDE are already defined, they are used in addition to the
|
||||
# WWLIB32 lib & include; otherwise, they're constructed from
|
||||
# BCDIR
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
LIBPATH = $(%WIN32LIB)\LIB;$(%WATCOM)\LIB386\NT
|
||||
INCLUDEPATH = $(%WIN32LIB)\INCLUDE;$(%WATCOM)\H
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
# Implicit rules
|
||||
# Compiler:
|
||||
# ($< = full dependent with path)
|
||||
# Assembler:
|
||||
# output obj's are constructed from .obj: & the $& macro
|
||||
# ($< = full dependent with path)
|
||||
# tasm's cfg file is not invoked as a response file.
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
.c.obj: $(%WIN32LIB)\project.cfg .AUTODEPEND
|
||||
$(C_CMD) $(CC_CFG) $<
|
||||
|
||||
.cpp.obj: $(%WIN32LIB)\project.cfg .AUTODEPEND
|
||||
$(CPP_CMD) $(CC_CFG) $(PROJ_DIR)\$^*.cpp
|
||||
|
||||
.asm.obj: $(%WIN32LIB)\project.cfg
|
||||
$(ASM_CMD) $(ASM_CFG) $<
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
# Default target
|
||||
#---------------------------------------------------------------------------
|
||||
all: $(PROJ_NAME).exe
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
# Build the EXE
|
||||
#---------------------------------------------------------------------------
|
||||
$(PROJ_NAME).exe: $(OBJECTS) $(PROJ_NAME).lnk $(PROJ_LIBS) $(CPS_FILES)
|
||||
$(LINK_CMD) $(LINK_CFG) name $^@ @$(PROJ_NAME).lnk
|
||||
|
||||
|
||||
$(PROJ_LIBS):
|
||||
echo updating base library $^@
|
||||
cd ..
|
||||
wmake
|
||||
cd $(PROJ_DIR)
|
||||
|
||||
|
||||
$(PROJ_NAME).lnk : $(OBJECTS)
|
||||
%create $^@
|
||||
for %index in ($(OBJECTS)) do %append $^@ file %index
|
||||
for %index in ($(PROJ_LIBS)) do %append $^@ library $(LIB_DIR)\%index
|
||||
%append $^@ library $(LIB_DIR)\ddraw.lib
|
||||
|
||||
#**************************** End of makefile ******************************
|
||||
|
187
WIN32LIB/DRAWBUFF/TEST/MAKEFILE.BOR
Normal file
187
WIN32LIB/DRAWBUFF/TEST/MAKEFILE.BOR
Normal file
@@ -0,0 +1,187 @@
|
||||
#
|
||||
# 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 : Westwood Library .EXE makefile *
|
||||
#* *
|
||||
#* File Name : MAKEFILE *
|
||||
#* *
|
||||
#* Programmer : Julio R. Jerez *
|
||||
#* *
|
||||
#* Start Date : Jan 20, 1995 *
|
||||
#* *
|
||||
#* Last Update : *
|
||||
#* *
|
||||
#*-------------------------------------------------------------------------*
|
||||
#* *
|
||||
#* Required environment variables: *
|
||||
#* WIN32LIB = your root WWFLAT path *
|
||||
#* WIN32VCS = root directory for wwlib version control archive *
|
||||
#* COMPILER = your Watcom installation path *
|
||||
#* *
|
||||
#* *
|
||||
#* Required changes to makefile: *
|
||||
#* PROJ_NAME = name of the executable program you're building *
|
||||
#* PROJ_LIBS = Westwood libraries to link your EXE to *
|
||||
#* OBJECTS = list of objects in your current working directory *
|
||||
#* *
|
||||
#* Optional changes to makefile: *
|
||||
#* PROJ_DIR = full pathname of your working directory *
|
||||
#* .xxx: = full pathname where various file types live *
|
||||
#* *
|
||||
#***************************************************************************
|
||||
|
||||
.AUTODEPEND
|
||||
#---------------------------------------------------------------------------
|
||||
# Verify user's environment
|
||||
#---------------------------------------------------------------------------
|
||||
!ifndef WIN32LIB
|
||||
!error WIN32LIB Environment var not configured.
|
||||
!endif
|
||||
|
||||
!ifndef WIN32VCS
|
||||
!error WIN32VCS Environment var not configured.
|
||||
!endif
|
||||
|
||||
!ifndef COMPILER
|
||||
!error COMPILER Environment var not configured.
|
||||
!endif
|
||||
|
||||
#===========================================================================
|
||||
# User-defined section: the user should tailor this section for each project
|
||||
#===========================================================================
|
||||
#---------------------------------------------------------------------------
|
||||
# PROJ_NAME = library name
|
||||
# PROJ_DIR = directory containing source & objects
|
||||
#---------------------------------------------------------------------------
|
||||
PROJ_NAME = test
|
||||
PROJ_DIR = $(WIN32LIB)\drawbuff\$(PROJ_NAME)
|
||||
LIB_DIR = $(WIN32LIB)\lib
|
||||
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
# Project-dependent variables
|
||||
#---------------------------------------------------------------------------
|
||||
OBJECTS = \
|
||||
$(PROJ_NAME).obj
|
||||
|
||||
CPS_FILES = \
|
||||
test1.cps \
|
||||
test2.cps
|
||||
!if 0
|
||||
PROJ_LIBS = \
|
||||
drawbuff.lib \
|
||||
win32lib.lib
|
||||
!else
|
||||
PROJ_LIBS = \
|
||||
drawbuff.lib \
|
||||
mem.lib \
|
||||
misc.lib \
|
||||
iff.lib \
|
||||
rawfile.lib \
|
||||
tile.lib \
|
||||
font.lib
|
||||
!endif
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
# Path macros: one path for each file type.
|
||||
# These paths are used to tell make where to find/put each file type.
|
||||
#---------------------------------------------------------------------------
|
||||
.path.asm = $(PROJ_DIR)
|
||||
.path.c = $(PROJ_DIR)
|
||||
.path.cpp = $(PROJ_DIR)
|
||||
.path.h = $(PROJ_DIR)
|
||||
.path.obj = $(PROJ_DIR)
|
||||
.path.lib = $(WIN32LIB)\lib
|
||||
.path.exe = $(PROJ_DIR)
|
||||
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
# Tools/commands
|
||||
#---------------------------------------------------------------------------
|
||||
C_CMD = bcc32
|
||||
CPP_CMD = bcc32
|
||||
LIB_CMD = tlib
|
||||
LINK_CMD = tlink32
|
||||
ASM_CMD = tasm32
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
# Include & library paths
|
||||
# If LIB & INCLUDE are already defined, they are used in addition to the
|
||||
# WWLIB32 lib & include; otherwise, they're constructed from
|
||||
# BCDIR
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
LIBPATH = $(WIN32LIB)\LIB;$(COMPILER)\LIB
|
||||
INCLUDEPATH = $(WIN32LIB)\INCLUDE;$(COMPILER)\INCLUDE
|
||||
|
||||
!include $(WIN32LIB)\\project.cfg
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
# Implicit rules
|
||||
# Compiler:
|
||||
# ($< = full dependent with path)
|
||||
# Assembler:
|
||||
# output obj's are constructed from .obj: & the $& macro
|
||||
# ($< = full dependent with path)
|
||||
# tasm's cfg file is not invoked as a response file.
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
.c.obj:
|
||||
$(C_CMD) $(CC_CFG) $<
|
||||
|
||||
.cpp.obj:
|
||||
$(CPP_CMD) $(CC_CFG) $<
|
||||
|
||||
.asm.obj:
|
||||
$(ASM_CMD) $(ASM_CFG) $<
|
||||
|
||||
.lbm.cps:
|
||||
$(WIN32LIB)\\TOOLS\WWCOMP $*.lbm $*.cps
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
# Default target
|
||||
#---------------------------------------------------------------------------
|
||||
all: $(PROJ_NAME).exe $(CPS_FILES)
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
# Build the EXE
|
||||
#---------------------------------------------------------------------------
|
||||
$(PROJ_NAME).exe: $(OBJECTS) $(PROJ_LIBS)
|
||||
$(LINK_CMD) @&&|
|
||||
$(LINK_CFG) +
|
||||
$(COMPILER)\\LIB\\c0w32.obj+
|
||||
$(OBJECTS)
|
||||
$<,$*
|
||||
$(PROJ_LIBS) +
|
||||
import32.lib +
|
||||
cw32i.lib
|
||||
$*.def
|
||||
|
|
||||
|
||||
$(PROJ_LIBS):
|
||||
echo updating base library $^@
|
||||
cd ..
|
||||
make
|
||||
cd $(PROJ_DIR)
|
||||
|
||||
#**************************** End of makefile ******************************
|
||||
|
180
WIN32LIB/DRAWBUFF/TEST/MAKEFILE.WAT
Normal file
180
WIN32LIB/DRAWBUFF/TEST/MAKEFILE.WAT
Normal file
@@ -0,0 +1,180 @@
|
||||
#
|
||||
# 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 : Westwood Library .EXE makefile *
|
||||
#* *
|
||||
#* File Name : MAKEFILE *
|
||||
#* *
|
||||
#* Programmer : Julio R. Jerez *
|
||||
#* *
|
||||
#* Start Date : Jan 20, 1995 *
|
||||
#* *
|
||||
#* Last Update : *
|
||||
#* *
|
||||
#*-------------------------------------------------------------------------*
|
||||
#* *
|
||||
#* Required environment variables: *
|
||||
#* WIN32LIB = your root WWFLAT path *
|
||||
#* WIN32VCS = root directory for wwlib version control archive *
|
||||
#* COMPILER = your Watcom installation path *
|
||||
#* *
|
||||
#* *
|
||||
#* Required changes to makefile: *
|
||||
#* PROJ_NAME = name of the executable program you're building *
|
||||
#* PROJ_LIBS = Westwood libraries to link your EXE to *
|
||||
#* OBJECTS = list of objects in your current working directory *
|
||||
#* *
|
||||
#* Optional changes to makefile: *
|
||||
#* PROJ_DIR = full pathname of your working directory *
|
||||
#* .xxx: = full pathname where various file types live *
|
||||
#* *
|
||||
#***************************************************************************
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
# Verify user's environment
|
||||
#---------------------------------------------------------------------------
|
||||
!ifndef %WIN32LIB
|
||||
!error WIN32LIB Environment var not configured.
|
||||
!endif
|
||||
|
||||
!ifndef %WIN32VCS
|
||||
!error WIN32VCS Environment var not configured.
|
||||
!endif
|
||||
|
||||
!ifndef %WATCOM
|
||||
!error WATCOM Environment var not configured.
|
||||
!endif
|
||||
|
||||
|
||||
#===========================================================================
|
||||
# User-defined section: the user should tailor this section for each project
|
||||
#===========================================================================
|
||||
#---------------------------------------------------------------------------
|
||||
# PROJ_NAME = library name
|
||||
# PROJ_DIR = directory containing source & objects
|
||||
#---------------------------------------------------------------------------
|
||||
PROJ_NAME = TEST
|
||||
PROJ_DIR = $(%WIN32LIB)\drawbuff\TEST
|
||||
LIB_DIR = $(%WIN32LIB)\lib
|
||||
|
||||
!include $(%WIN32LIB)\project.cfg
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
# Project-dependent variables
|
||||
#---------------------------------------------------------------------------
|
||||
OBJECTS = &
|
||||
$(PROJ_NAME).obj
|
||||
|
||||
CPS_FILES = &
|
||||
test1.cps &
|
||||
test2.cps
|
||||
|
||||
PROJ_LIBS = &
|
||||
drawbuff.lib &
|
||||
mem.lib &
|
||||
misc.lib &
|
||||
iff.lib &
|
||||
rawfile.lib &
|
||||
tile.lib &
|
||||
font.lib
|
||||
#PROJ_LIBS = &
|
||||
# drawbuff.lib &
|
||||
# win32lib.lib
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
# Path macros: one path for each file type.
|
||||
# These paths are used to tell make where to find/put each file type.
|
||||
#---------------------------------------------------------------------------
|
||||
.asm: $(PROJ_DIR)
|
||||
.c: $(PROJ_DIR)
|
||||
.cpp: $(PROJ_DIR)
|
||||
.h: $(PROJ_DIR)
|
||||
.obj: $(PROJ_DIR)
|
||||
.lib: $(%WIN32LIB)\lib
|
||||
.exe: $(PROJ_DIR)
|
||||
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
# Tools/commands
|
||||
#---------------------------------------------------------------------------
|
||||
C_CMD = wcc386
|
||||
CPP_CMD = wpp386
|
||||
LIB_CMD = wlib
|
||||
LINK_CMD = wlink
|
||||
ASM_CMD = tasm32
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
# Include & library paths
|
||||
# If LIB & INCLUDE are already defined, they are used in addition to the
|
||||
# WWLIB32 lib & include; otherwise, they're constructed from
|
||||
# BCDIR
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
LIBPATH = $(%WIN32LIB)\LIB;$(%WATCOM)\LIB386\NT
|
||||
INCLUDEPATH = $(%WIN32LIB)\INCLUDE;$(%WATCOM)\H
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
# Implicit rules
|
||||
# Compiler:
|
||||
# ($< = full dependent with path)
|
||||
# Assembler:
|
||||
# output obj's are constructed from .obj: & the $& macro
|
||||
# ($< = full dependent with path)
|
||||
# tasm's cfg file is not invoked as a response file.
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
.c.obj: $(%WIN32LIB)\project.cfg .AUTODEPEND
|
||||
$(C_CMD) $(CC_CFG) $<
|
||||
|
||||
.cpp.obj: $(%WIN32LIB)\project.cfg .AUTODEPEND
|
||||
$(CPP_CMD) $(CC_CFG) $<
|
||||
|
||||
.asm.obj: $(%WIN32LIB)\project.cfg
|
||||
$(ASM_CMD) $(ASM_CFG) $<
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
# Default target
|
||||
#---------------------------------------------------------------------------
|
||||
all: $(PROJ_NAME).exe
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
# Build the EXE
|
||||
#---------------------------------------------------------------------------
|
||||
$(PROJ_NAME).exe: $(OBJECTS) $(PROJ_NAME).lnk $(PROJ_LIBS) $(CPS_FILES)
|
||||
$(LINK_CMD) $(LINK_CFG) name $^@ @$(PROJ_NAME).lnk
|
||||
|
||||
|
||||
$(PROJ_LIBS):
|
||||
echo updating base library $^@
|
||||
cd ..
|
||||
wmake
|
||||
cd $(PROJ_DIR)
|
||||
|
||||
|
||||
$(PROJ_NAME).lnk : $(OBJECTS)
|
||||
%create $^@
|
||||
for %index in ($(OBJECTS)) do %append $^@ file %index
|
||||
for %index in ($(PROJ_LIBS)) do %append $^@ library $(LIB_DIR)\%index
|
||||
%append $^@ library $(LIB_DIR)\ddraw.lib
|
||||
|
||||
#**************************** End of makefile ******************************
|
||||
|
1087
WIN32LIB/DRAWBUFF/TEST/TEST.BAK
Normal file
1087
WIN32LIB/DRAWBUFF/TEST/TEST.BAK
Normal file
File diff suppressed because it is too large
Load Diff
1242
WIN32LIB/DRAWBUFF/TEST/TEST.CPP
Normal file
1242
WIN32LIB/DRAWBUFF/TEST/TEST.CPP
Normal file
File diff suppressed because it is too large
Load Diff
14
WIN32LIB/DRAWBUFF/TEST/TEST.DEF
Normal file
14
WIN32LIB/DRAWBUFF/TEST/TEST.DEF
Normal file
@@ -0,0 +1,14 @@
|
||||
IMPORTS
|
||||
DirectDrawCreate=DDRAW.DirectDrawCreate
|
||||
DirectSoundCreate=DSOUND.DirectSoundCreate
|
||||
DirectPlayEnumerate=DPLAY.DirectPlayEnumerate
|
||||
DirectPlayCreate=DPLAY.DirectPlayCreate
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
34
WIN32LIB/DRAWBUFF/TEST/TEST/TEST.CPP
Normal file
34
WIN32LIB/DRAWBUFF/TEST/TEST/TEST.CPP
Normal file
@@ -0,0 +1,34 @@
|
||||
/*
|
||||
** 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/>.
|
||||
*/
|
||||
|
||||
#include "stdio.h"
|
||||
|
||||
extern "C" {
|
||||
void func_1(void);
|
||||
}
|
||||
|
||||
void func_2(void)
|
||||
{
|
||||
printf("There\r");
|
||||
}
|
||||
|
||||
void main(void)
|
||||
{
|
||||
func_1();
|
||||
func_2();
|
||||
}
|
80
WIN32LIB/DRAWBUFF/TEST/TESTASM.ASM
Normal file
80
WIN32LIB/DRAWBUFF/TEST/TESTASM.ASM
Normal file
@@ -0,0 +1,80 @@
|
||||
;
|
||||
; 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/>.
|
||||
;
|
||||
|
||||
IDEAL
|
||||
P386
|
||||
MODEL USE32 FLAT
|
||||
jumps
|
||||
|
||||
codeseg
|
||||
|
||||
masm
|
||||
;
|
||||
; Change a DAC colour register directly
|
||||
;
|
||||
; register number in al
|
||||
;
|
||||
; bh=red bl=green cl=blue
|
||||
;
|
||||
|
||||
set_dac_col proc near
|
||||
pushad
|
||||
cli
|
||||
push eax
|
||||
mov dx,03dah
|
||||
in al,dx
|
||||
jmp @@1
|
||||
@@1: mov dx,03c8h
|
||||
pop eax
|
||||
out dx,al
|
||||
jmp @@2
|
||||
@@2: inc dl
|
||||
mov al,bh
|
||||
out dx,al
|
||||
jmp @@3
|
||||
@@3: mov al,bl
|
||||
out dx,al
|
||||
jmp @@4
|
||||
@@4: mov al,cl
|
||||
out dx,al
|
||||
jmp @@5
|
||||
@@5: sti
|
||||
popad
|
||||
ret
|
||||
set_dac_col endp
|
||||
|
||||
ideal
|
||||
|
||||
|
||||
global Set_Palette_Register_:near
|
||||
|
||||
|
||||
proc Set_Palette_Register_ near
|
||||
|
||||
pushad
|
||||
and cl,63
|
||||
mov bh,dl
|
||||
and bh,63
|
||||
and bl,63
|
||||
call set_dac_col
|
||||
popad
|
||||
ret
|
||||
|
||||
endp Set_Palette_Register_
|
||||
|
||||
end
|
292
WIN32LIB/DRAWBUFF/TOBUFF.ASM
Normal file
292
WIN32LIB/DRAWBUFF/TOBUFF.ASM
Normal file
@@ -0,0 +1,292 @@
|
||||
;
|
||||
; 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 A S S O C I A T E S **
|
||||
;***************************************************************************
|
||||
;* *
|
||||
;* Project Name : Westwood 32 bit Library *
|
||||
;* *
|
||||
;* File Name : TOBUFFER.ASM *
|
||||
;* *
|
||||
;* Programmer : Phil W. Gorrow *
|
||||
;* *
|
||||
;* Start Date : June 8, 1994 *
|
||||
;* Last Update : Feb 10, 1995 [jrj] *
|
||||
;* *
|
||||
;*-------------------------------------------------------------------------*
|
||||
;* Functions: *
|
||||
;* VVC::TOBUFFER -- Copies a virtual viewport to a linear buffer *
|
||||
;* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - *
|
||||
|
||||
IDEAL
|
||||
P386
|
||||
MODEL USE32 FLAT
|
||||
LOCALS ??
|
||||
|
||||
|
||||
TRANSP equ 0
|
||||
|
||||
|
||||
INCLUDE ".\drawbuff.inc"
|
||||
INCLUDE ".\gbuffer.inc"
|
||||
|
||||
|
||||
CODESEG
|
||||
|
||||
|
||||
;***************************************************************************
|
||||
;* VIVC::TOBUFFER -- Copies a virtual viewport to a linear buffer *
|
||||
;* *
|
||||
;* INPUT: BYTE * dest - buffer to copy to *
|
||||
;* size - size of the buffer to copy to *
|
||||
;* x_pixel - x pixel on viewport to copy from *
|
||||
;* y_pixel - y pixel on viewport to copy from *
|
||||
;* pixel_width - the width of copy region *
|
||||
;* pixel_height - the height of copy region *
|
||||
;* *
|
||||
;* OUTPUT: none *
|
||||
;* *
|
||||
;* WARNINGS: Coordinates and dimensions will be adjusted if they exceed *
|
||||
;* the boundaries. In the event that no adjustment is *
|
||||
;* possible this routine will abort. If the size of the *
|
||||
;* region to copy exceeds the size passed in for the buffer *
|
||||
;* the routine will automatically abort. *
|
||||
;* *
|
||||
;* HISTORY: *
|
||||
;* 06/15/1994 PWG : Created. *
|
||||
;*=========================================================================*
|
||||
PROC Buffer_To_Buffer C near
|
||||
USES ebx,ecx,edx,esi,edi
|
||||
|
||||
;*===================================================================
|
||||
;* define the arguements that our function takes.
|
||||
;*===================================================================
|
||||
ARG this_object:DWORD ; this is a class member function
|
||||
ARG x_pixel:DWORD ; Page X pixel coordinate.
|
||||
ARG y_pixel:DWORD ; Page Y pixel coordinate.
|
||||
ARG pixel_width:DWORD ; Width of region in pixels.
|
||||
ARG pixel_height:DWORD ; Height of region in pixels.
|
||||
ARG dest:DWORD ; the buffer to copy to
|
||||
ARG buffer_size:DWORD ; the size of the buffer
|
||||
|
||||
;*===================================================================
|
||||
; Define some locals so that we can handle things quickly
|
||||
;*===================================================================
|
||||
LOCAL x1_pixel :dword
|
||||
LOCAL y1_pixel :dword
|
||||
LOCAL dest_x1 : dword
|
||||
LOCAL dest_y1 : dword
|
||||
LOCAL dest_ajust_width:DWORD
|
||||
LOCAL scr_ajust_width:DWORD
|
||||
LOCAL dest_area : dword
|
||||
|
||||
; Clip dest Rectangle against source Window boundaries.
|
||||
|
||||
mov [ dest_x1 ] , 0
|
||||
mov [ dest_y1 ] , 0
|
||||
|
||||
mov esi , [ this_object ] ; get ptr to dest
|
||||
xor ecx , ecx
|
||||
xor edx , edx
|
||||
mov edi , [ (GraphicViewPort esi) . GVPWidth ] ; get width into register
|
||||
mov ebx , [ x_pixel ]
|
||||
mov eax , [ x_pixel ]
|
||||
add ebx , [ pixel_width ]
|
||||
shld ecx , eax , 1
|
||||
mov [ x1_pixel ] , ebx
|
||||
inc edi
|
||||
shld edx , ebx , 1
|
||||
sub eax , edi
|
||||
sub ebx , edi
|
||||
shld ecx , eax , 1
|
||||
shld edx , ebx , 1
|
||||
|
||||
mov edi,[ ( GraphicViewPort esi) . GVPHeight ] ; get height into register
|
||||
mov ebx , [ y_pixel ]
|
||||
mov eax , [ y_pixel ]
|
||||
add ebx , [ pixel_height ]
|
||||
shld ecx , eax , 1
|
||||
mov [ y1_pixel ] , ebx
|
||||
inc edi
|
||||
shld edx , ebx , 1
|
||||
sub eax , edi
|
||||
sub ebx , edi
|
||||
shld ecx , eax , 1
|
||||
shld edx , ebx , 1
|
||||
|
||||
xor cl , 5
|
||||
xor dl , 5
|
||||
mov al , cl
|
||||
test dl , cl
|
||||
jnz ??real_out
|
||||
or al , dl
|
||||
jz ??do_blit
|
||||
|
||||
test cl , 1000b
|
||||
jz ??scr_left_ok
|
||||
mov eax , [ x_pixel ]
|
||||
neg eax
|
||||
mov [ x_pixel ] , 0
|
||||
mov [ dest_x1 ] , eax
|
||||
|
||||
??scr_left_ok:
|
||||
test cl , 0010b
|
||||
jz ??scr_bottom_ok
|
||||
mov eax , [ y_pixel ]
|
||||
neg eax
|
||||
mov [ y_pixel ] , 0
|
||||
mov [ dest_y1 ] , eax
|
||||
|
||||
??scr_bottom_ok:
|
||||
test dl , 0100b
|
||||
jz ??scr_right_ok
|
||||
mov eax , [ (GraphicViewPort esi) . GVPWidth ] ; get width into register
|
||||
mov [ x1_pixel ] , eax
|
||||
??scr_right_ok:
|
||||
test dl , 0001b
|
||||
jz ??do_blit
|
||||
mov eax , [ (GraphicViewPort esi) . GVPHeight ] ; get width into register
|
||||
mov [ y1_pixel ] , eax
|
||||
|
||||
??do_blit:
|
||||
|
||||
cld
|
||||
|
||||
mov eax , [ (GraphicViewPort esi) . GVPXAdd ]
|
||||
add eax , [ (GraphicViewPort esi) . GVPWidth ]
|
||||
add eax , [ (GraphicViewPort esi) . GVPPitch ]
|
||||
mov esi , [ (GraphicViewPort esi) . GVPOffset ]
|
||||
|
||||
mov ecx , eax
|
||||
mul [ y_pixel ]
|
||||
add esi , [ x_pixel ]
|
||||
add esi , eax
|
||||
|
||||
add ecx , [ x_pixel ]
|
||||
sub ecx , [ x1_pixel ]
|
||||
mov [ scr_ajust_width ] , ecx
|
||||
|
||||
mov edi , [ dest ]
|
||||
mov eax , [ pixel_width ]
|
||||
sub eax , [ x1_pixel ]
|
||||
add eax , [ x_pixel ]
|
||||
mov [ dest_ajust_width ] , eax
|
||||
|
||||
mov eax , [ dest_y1 ]
|
||||
mul [ pixel_width ]
|
||||
add eax , [ dest_x1 ]
|
||||
add edi , eax
|
||||
|
||||
mov edx , [ y1_pixel ]
|
||||
mov eax , [ x1_pixel ]
|
||||
sub edx , [ y_pixel ]
|
||||
jle ??real_out
|
||||
sub eax , [ x_pixel ]
|
||||
jle ??real_out
|
||||
|
||||
mov ebx , [ pixel_width ]
|
||||
imul ebx , edx
|
||||
cmp ebx , [ buffer_size ]
|
||||
jg ??real_out
|
||||
|
||||
|
||||
; ********************************************************************
|
||||
; Forward bitblit only
|
||||
|
||||
IF TRANSP
|
||||
cmp [ transp ] , 0
|
||||
jnz ??forward_Blit_trans
|
||||
ENDIF
|
||||
|
||||
; the inner loop is so efficient that
|
||||
; the optimal consept no longer apply because
|
||||
; the optimal byte have to by a number greather than 9 bytes
|
||||
cmp eax , 10
|
||||
jl ??forward_loop_bytes
|
||||
|
||||
??forward_loop_dword:
|
||||
mov ecx , edi
|
||||
mov ebx , eax
|
||||
neg ecx
|
||||
and ecx , 3
|
||||
sub ebx , ecx
|
||||
rep movsb
|
||||
mov ecx , ebx
|
||||
shr ecx , 2
|
||||
rep movsd
|
||||
mov ecx , ebx
|
||||
and ecx , 3
|
||||
rep movsb
|
||||
add esi , [ scr_ajust_width ]
|
||||
add edi , [ dest_ajust_width ]
|
||||
dec edx
|
||||
jnz ??forward_loop_dword
|
||||
ret
|
||||
|
||||
??forward_loop_bytes:
|
||||
mov ecx , eax
|
||||
rep movsb
|
||||
add esi , [ scr_ajust_width ]
|
||||
add edi , [ dest_ajust_width ]
|
||||
dec edx ; decrement the height
|
||||
jnz ??forward_loop_bytes
|
||||
ret
|
||||
|
||||
|
||||
IF TRANSP
|
||||
|
||||
??forward_Blit_trans:
|
||||
mov ecx , eax
|
||||
and ecx , 01fh
|
||||
lea ecx , [ ecx + ecx * 4 ]
|
||||
neg ecx
|
||||
shr eax , 5
|
||||
lea ecx , [ ??transp_reference + ecx * 2 ]
|
||||
mov [ y1_pixel ] , ecx
|
||||
|
||||
??forward_loop_trans:
|
||||
mov ecx , eax
|
||||
jmp [ y1_pixel ]
|
||||
??forward_trans_line:
|
||||
REPT 32
|
||||
local transp_pixel
|
||||
mov bl , [ esi ]
|
||||
test bl , bl
|
||||
jz transp_pixel
|
||||
mov [ edi ] , bl
|
||||
transp_pixel:
|
||||
inc esi
|
||||
inc edi
|
||||
ENDM
|
||||
??transp_reference:
|
||||
dec ecx
|
||||
jge ??forward_trans_line
|
||||
add esi , [ scr_ajust_width ]
|
||||
add edi , [ dest_ajust_width ]
|
||||
dec edx
|
||||
jnz ??forward_loop_trans
|
||||
ret
|
||||
ENDIF
|
||||
|
||||
??real_out:
|
||||
ret
|
||||
|
||||
ENDP Buffer_To_Buffer
|
||||
|
||||
END
|
294
WIN32LIB/DRAWBUFF/TOPAGE.ASM
Normal file
294
WIN32LIB/DRAWBUFF/TOPAGE.ASM
Normal file
@@ -0,0 +1,294 @@
|
||||
;
|
||||
; 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 A S S O C I A T E S **
|
||||
;***************************************************************************
|
||||
;* *
|
||||
;* Project Name : Westwood 32 bit Library *
|
||||
;* *
|
||||
;* File Name : TOPAGE.ASM *
|
||||
;* *
|
||||
;* Programmer : Phil W. Gorrow *
|
||||
;* *
|
||||
;* Start Date : June 8, 1994 *
|
||||
;* *
|
||||
;* Last Update : June 15, 1994 [PWG] *
|
||||
;* *
|
||||
;*-------------------------------------------------------------------------*
|
||||
;* Functions: *
|
||||
;* Buffer_To_Page -- Copies a linear buffer to a virtual viewport *
|
||||
;* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - *
|
||||
|
||||
IDEAL
|
||||
P386
|
||||
MODEL USE32 FLAT
|
||||
|
||||
TRANSP equ 0
|
||||
|
||||
|
||||
INCLUDE ".\drawbuff.inc"
|
||||
INCLUDE ".\gbuffer.inc"
|
||||
|
||||
CODESEG
|
||||
|
||||
;***************************************************************************
|
||||
;* VVC::TOPAGE -- Copies a linear buffer to a virtual viewport *
|
||||
;* *
|
||||
;* INPUT: WORD x_pixel - x pixel on viewport to copy from *
|
||||
;* WORD y_pixel - y pixel on viewport to copy from *
|
||||
;* WORD pixel_width - the width of copy region *
|
||||
;* WORD pixel_height - the height of copy region *
|
||||
;* BYTE * src - buffer to copy from *
|
||||
;* VVPC * dest - virtual viewport to copy to *
|
||||
;* *
|
||||
;* OUTPUT: none *
|
||||
;* *
|
||||
;* WARNINGS: Coordinates and dimensions will be adjusted if they exceed *
|
||||
;* the boundaries. In the event that no adjustment is *
|
||||
;* possible this routine will abort. If the size of the *
|
||||
;* region to copy exceeds the size passed in for the buffer *
|
||||
;* the routine will automatically abort. *
|
||||
;* *
|
||||
;* HISTORY: *
|
||||
;* 06/15/1994 PWG : Created. *
|
||||
;*=========================================================================*
|
||||
PROC Buffer_To_Page C near
|
||||
USES eax,ebx,ecx,edx,esi,edi
|
||||
|
||||
;*===================================================================
|
||||
;* define the arguements that our function takes.
|
||||
;*===================================================================
|
||||
ARG x_pixel :DWORD ; x pixel position in source
|
||||
ARG y_pixel :DWORD ; y pixel position in source
|
||||
ARG pixel_width :DWORD ; width of rectangle to blit
|
||||
ARG pixel_height:DWORD ; height of rectangle to blit
|
||||
ARG src :DWORD ; this is a member function
|
||||
ARG dest :DWORD ; what are we blitting to
|
||||
|
||||
; ARG trans :DWORD ; do we deal with transparents?
|
||||
|
||||
;*===================================================================
|
||||
; Define some locals so that we can handle things quickly
|
||||
;*===================================================================
|
||||
LOCAL x1_pixel :dword
|
||||
LOCAL y1_pixel :dword
|
||||
local scr_x : dword
|
||||
local scr_y : dword
|
||||
LOCAL dest_ajust_width:DWORD
|
||||
LOCAL scr_ajust_width:DWORD
|
||||
LOCAL dest_area : dword
|
||||
|
||||
cmp [ src ] , 0
|
||||
jz ??real_out
|
||||
|
||||
|
||||
; Clip dest Rectangle against source Window boundaries.
|
||||
|
||||
mov [ scr_x ] , 0
|
||||
mov [ scr_y ] , 0
|
||||
mov esi , [ dest ] ; get ptr to dest
|
||||
xor ecx , ecx
|
||||
xor edx , edx
|
||||
mov edi , [ (GraphicViewPort esi) . GVPWidth ] ; get width into register
|
||||
mov ebx , [ x_pixel ]
|
||||
mov eax , [ x_pixel ]
|
||||
add ebx , [ pixel_width ]
|
||||
shld ecx , eax , 1
|
||||
mov [ x1_pixel ] , ebx
|
||||
inc edi
|
||||
shld edx , ebx , 1
|
||||
sub eax , edi
|
||||
sub ebx , edi
|
||||
shld ecx , eax , 1
|
||||
shld edx , ebx , 1
|
||||
|
||||
mov edi,[ ( GraphicViewPort esi) . GVPHeight ] ; get height into register
|
||||
mov ebx , [ y_pixel ]
|
||||
mov eax , [ y_pixel ]
|
||||
add ebx , [ pixel_height ]
|
||||
shld ecx , eax , 1
|
||||
mov [ y1_pixel ] , ebx
|
||||
inc edi
|
||||
shld edx , ebx , 1
|
||||
sub eax , edi
|
||||
sub ebx , edi
|
||||
shld ecx , eax , 1
|
||||
shld edx , ebx , 1
|
||||
|
||||
xor cl , 5
|
||||
xor dl , 5
|
||||
mov al , cl
|
||||
test dl , cl
|
||||
jnz ??real_out
|
||||
or al , dl
|
||||
jz ??do_blit
|
||||
|
||||
test cl , 1000b
|
||||
jz ??dest_left_ok
|
||||
mov eax , [ x_pixel ]
|
||||
neg eax
|
||||
mov [ x_pixel ] , 0
|
||||
mov [ scr_x ] , eax
|
||||
|
||||
??dest_left_ok:
|
||||
test cl , 0010b
|
||||
jz ??dest_bottom_ok
|
||||
mov eax , [ y_pixel ]
|
||||
neg eax
|
||||
mov [ y_pixel ] , 0
|
||||
mov [ scr_y ] , eax
|
||||
|
||||
??dest_bottom_ok:
|
||||
test dl , 0100b
|
||||
jz ??dest_right_ok
|
||||
mov eax , [ (GraphicViewPort esi) . GVPWidth ] ; get width into register
|
||||
mov [ x1_pixel ] , eax
|
||||
??dest_right_ok:
|
||||
test dl , 0001b
|
||||
jz ??do_blit
|
||||
mov eax , [ (GraphicViewPort esi) . GVPHeight ] ; get width into register
|
||||
mov [ y1_pixel ] , eax
|
||||
|
||||
??do_blit:
|
||||
|
||||
cld
|
||||
|
||||
mov eax , [ (GraphicViewPort esi) . GVPXAdd ]
|
||||
add eax , [ (GraphicViewPort esi) . GVPWidth ]
|
||||
add eax , [ (GraphicViewPort esi) . GVPPitch ]
|
||||
mov edi , [ (GraphicViewPort esi) . GVPOffset ]
|
||||
|
||||
mov ecx , eax
|
||||
mul [ y_pixel ]
|
||||
add edi , [ x_pixel ]
|
||||
add edi , eax
|
||||
|
||||
add ecx , [ x_pixel ]
|
||||
sub ecx , [ x1_pixel ]
|
||||
mov [ dest_ajust_width ] , ecx
|
||||
|
||||
|
||||
mov esi , [ src ]
|
||||
mov eax , [ pixel_width ]
|
||||
sub eax , [ x1_pixel ]
|
||||
add eax , [ x_pixel ]
|
||||
mov [ scr_ajust_width ] , eax
|
||||
|
||||
mov eax , [ scr_y ]
|
||||
mul [ pixel_width ]
|
||||
add eax , [ scr_x ]
|
||||
add esi , eax
|
||||
|
||||
mov edx , [ y1_pixel ]
|
||||
mov eax , [ x1_pixel ]
|
||||
|
||||
sub edx , [ y_pixel ]
|
||||
jle ??real_out
|
||||
sub eax , [ x_pixel ]
|
||||
jle ??real_out
|
||||
|
||||
|
||||
; ********************************************************************
|
||||
; Forward bitblit only
|
||||
|
||||
IF TRANSP
|
||||
test [ trans ] , 1
|
||||
jnz ??forward_Blit_trans
|
||||
ENDIF
|
||||
|
||||
|
||||
; the inner loop is so efficient that
|
||||
; the optimal consept no longer apply because
|
||||
; the optimal byte have to by a number greather than 9 bytes
|
||||
cmp eax , 10
|
||||
jl ??forward_loop_bytes
|
||||
|
||||
??forward_loop_dword:
|
||||
mov ecx , edi
|
||||
mov ebx , eax
|
||||
neg ecx
|
||||
and ecx , 3
|
||||
sub ebx , ecx
|
||||
rep movsb
|
||||
mov ecx , ebx
|
||||
shr ecx , 2
|
||||
rep movsd
|
||||
mov ecx , ebx
|
||||
and ecx , 3
|
||||
rep movsb
|
||||
add esi , [ scr_ajust_width ]
|
||||
add edi , [ dest_ajust_width ]
|
||||
dec edx
|
||||
jnz ??forward_loop_dword
|
||||
ret
|
||||
|
||||
??forward_loop_bytes:
|
||||
mov ecx , eax
|
||||
rep movsb
|
||||
add esi , [ scr_ajust_width ]
|
||||
add edi , [ dest_ajust_width ]
|
||||
dec edx ; decrement the height
|
||||
jnz ??forward_loop_bytes
|
||||
ret
|
||||
|
||||
IF TRANSP
|
||||
|
||||
|
||||
??forward_Blit_trans:
|
||||
|
||||
|
||||
mov ecx , eax
|
||||
and ecx , 01fh
|
||||
lea ecx , [ ecx + ecx * 4 ]
|
||||
neg ecx
|
||||
shr eax , 5
|
||||
lea ecx , [ ??transp_reference + ecx * 2 ]
|
||||
mov [ y1_pixel ] , ecx
|
||||
|
||||
|
||||
??forward_loop_trans:
|
||||
mov ecx , eax
|
||||
jmp [ y1_pixel ]
|
||||
??forward_trans_line:
|
||||
REPT 32
|
||||
local transp_pixel
|
||||
mov bl , [ esi ]
|
||||
inc esi
|
||||
test bl , bl
|
||||
jz transp_pixel
|
||||
mov [ edi ] , bl
|
||||
transp_pixel:
|
||||
inc edi
|
||||
ENDM
|
||||
??transp_reference:
|
||||
dec ecx
|
||||
jge ??forward_trans_line
|
||||
add esi , [ scr_ajust_width ]
|
||||
add edi , [ dest_ajust_width ]
|
||||
dec edx
|
||||
jnz ??forward_loop_trans
|
||||
ret
|
||||
ENDIF
|
||||
|
||||
??real_out:
|
||||
ret
|
||||
|
||||
|
||||
ENDP Buffer_To_Page
|
||||
END
|
502
WIN32LIB/DRAWBUFF/TXTPRNT.ASM
Normal file
502
WIN32LIB/DRAWBUFF/TXTPRNT.ASM
Normal file
@@ -0,0 +1,502 @@
|
||||
;
|
||||
; 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 : Westwood 32 bit Library *
|
||||
;* *
|
||||
;* File Name : TXTPRNT.ASM *
|
||||
;* *
|
||||
;* Programmer : Phil W. Gorrow *
|
||||
;* *
|
||||
;* Start Date : January 17, 1995 *
|
||||
;* *
|
||||
;* Last Update : January 17, 1995 [PWG] *
|
||||
;* *
|
||||
;*-------------------------------------------------------------------------*
|
||||
;* Functions: *
|
||||
;* Buffer_Print -- Assembly Buffer text print routine *
|
||||
;* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - *
|
||||
|
||||
IDEAL
|
||||
P386
|
||||
MODEL USE32 FLAT
|
||||
|
||||
INCLUDE ".\drawbuff.inc"
|
||||
INCLUDE ".\gbuffer.inc"
|
||||
|
||||
;*=========================================================================*
|
||||
;* Extern the font pointer which is defined by the font class *
|
||||
;*=========================================================================*
|
||||
GLOBAL C FontPtr:DWORD
|
||||
GLOBAL C FontXSpacing:DWORD
|
||||
GLOBAL C FontYSpacing:DWORD
|
||||
GLOBAL C ColorXlat:BYTE
|
||||
|
||||
;*=========================================================================*
|
||||
;* Define the necessary equates for structures and bounds checking *
|
||||
;*=========================================================================*
|
||||
; The header of the font file looks like object:
|
||||
; UWORD FontLength; 0
|
||||
; BYTE FontCompress; 2
|
||||
; BYTE FontDataBlocks; 3
|
||||
; UWORD InfoBlockOffset; 4
|
||||
; UWORD OffsetBlockOffset; 6
|
||||
; UWORD WidthBlockOffset; 8
|
||||
; UWORD DataBlockOffset; 10
|
||||
; UWORD HeightOffset; 12
|
||||
; For this reason the following equates have these values:
|
||||
FONTINFOBLOCK EQU 4
|
||||
FONTOFFSETBLOCK EQU 6
|
||||
FONTWIDTHBLOCK EQU 8
|
||||
FONTDATABLOCK EQU 10
|
||||
FONTHEIGHTBLOCK EQU 12
|
||||
|
||||
FONTINFOMAXHEIGHT EQU 4
|
||||
FONTINFOMAXWIDTH EQU 5
|
||||
|
||||
|
||||
LOCALS ??
|
||||
;*=========================================================================*
|
||||
;* Define the color xlate table in the data segment *
|
||||
;*=========================================================================*
|
||||
DATASEG
|
||||
|
||||
ColorXlat DB 000H,001H,002H,003H,004H,005H,006H,007H
|
||||
DB 008H,009H,00AH,00BH,00CH,00DH,00EH,00FH
|
||||
|
||||
DB 001H,000H,000H,000H,000H,000H,000H,000H
|
||||
DB 000H,000H,000H,000H,000H,000H,000H,000H
|
||||
|
||||
DB 002H,000H,000H,000H,000H,000H,000H,000H
|
||||
DB 000H,000H,000H,000H,000H,000H,000H,000H
|
||||
|
||||
DB 003H,000H,000H,000H,000H,000H,000H,000H
|
||||
DB 000H,000H,000H,000H,000H,000H,000H,000H
|
||||
|
||||
DB 004H,000H,000H,000H,000H,000H,000H,000H
|
||||
DB 000H,000H,000H,000H,000H,000H,000H,000H
|
||||
|
||||
DB 005H,000H,000H,000H,000H,000H,000H,000H
|
||||
DB 000H,000H,000H,000H,000H,000H,000H,000H
|
||||
|
||||
DB 006H,000H,000H,000H,000H,000H,000H,000H
|
||||
DB 000H,000H,000H,000H,000H,000H,000H,000H
|
||||
|
||||
DB 007H,000H,000H,000H,000H,000H,000H,000H
|
||||
DB 000H,000H,000H,000H,000H,000H,000H,000H
|
||||
|
||||
DB 008H,000H,000H,000H,000H,000H,000H,000H
|
||||
DB 000H,000H,000H,000H,000H,000H,000H,000H
|
||||
|
||||
DB 009H,000H,000H,000H,000H,000H,000H,000H
|
||||
DB 000H,000H,000H,000H,000H,000H,000H,000H
|
||||
|
||||
DB 00AH,000H,000H,000H,000H,000H,000H,000H
|
||||
DB 000H,000H,000H,000H,000H,000H,000H,000H
|
||||
|
||||
DB 00BH,000H,000H,000H,000H,000H,000H,000H
|
||||
DB 000H,000H,000H,000H,000H,000H,000H,000H
|
||||
|
||||
DB 00CH,000H,000H,000H,000H,000H,000H,000H
|
||||
DB 000H,000H,000H,000H,000H,000H,000H,000H
|
||||
|
||||
DB 00DH,000H,000H,000H,000H,000H,000H,000H
|
||||
DB 000H,000H,000H,000H,000H,000H,000H,000H
|
||||
|
||||
DB 00EH,000H,000H,000H,000H,000H,000H,000H
|
||||
DB 000H,000H,000H,000H,000H,000H,000H,000H
|
||||
|
||||
DB 00FH
|
||||
|
||||
CODESEG
|
||||
|
||||
|
||||
;***************************************************************************
|
||||
;* Buffer_PRINT -- Assembly buffer text print routine *
|
||||
;* *
|
||||
;* *
|
||||
;* *
|
||||
;* INPUT: *
|
||||
;* *
|
||||
;* OUTPUT: *
|
||||
;* *
|
||||
;* PROTO: *
|
||||
;* *
|
||||
;* WARNINGS: *
|
||||
;* *
|
||||
;* HISTORY: *
|
||||
;* 01/17/1995 PWG : Created. *
|
||||
;*=========================================================================*
|
||||
PROC Buffer_Print C near
|
||||
USES ebx,ecx,edx,esi,edi
|
||||
|
||||
ARG this_object:DWORD
|
||||
ARG string:DWORD
|
||||
ARG x_pixel:DWORD
|
||||
ARG y_pixel:DWORD
|
||||
ARG fcolor:DWORD
|
||||
ARG bcolor:DWORD
|
||||
|
||||
LOCAL infoblock:DWORD ; pointer to info block
|
||||
LOCAL offsetblock:DWORD ; pointer to offset block (UWORD *)
|
||||
LOCAL widthblock:DWORD ; pointer to width block (BYTE *)
|
||||
LOCAL heightblock:DWORD ; pointer to height block (UWORD *)
|
||||
|
||||
LOCAL curline:DWORD ; pointer to first column of current row.
|
||||
LOCAL bufferwidth:DWORD ; width of buffer (vpwidth + Xadd)
|
||||
LOCAL nextdraw:DWORD ; bufferwidth - width of cur character.
|
||||
LOCAL startdraw:DWORD ; where next character will start being drawn.
|
||||
|
||||
LOCAL char:DWORD ; current character value.
|
||||
local ptr_string:dword ; pointer to string
|
||||
LOCAL maxheight:BYTE ; max height of characters in font.
|
||||
LOCAL bottomblank:BYTE ; amount of empty space below current character.
|
||||
LOCAL charheight:BYTE ; true height of current character.
|
||||
LOCAL vpwidth:DWORD
|
||||
LOCAL vpheight:DWORD
|
||||
LOCAL original_x:DWORD ; Starting X position.
|
||||
|
||||
mov eax,[string] ; check that the string is not NULL
|
||||
mov [ptr_string],eax
|
||||
cmp eax,0
|
||||
jz ??done
|
||||
|
||||
;-------------------------------- Where to draw -----------------------------------------------
|
||||
; Set up memory location to start drawing.
|
||||
mov ebx,[this_object] ; get a pointer to dest
|
||||
mov eax,[(GraphicViewPort ebx).GVPHeight] ; get height of viewport
|
||||
mov [vpheight],eax ; save off height of viewport
|
||||
mov eax,[(GraphicViewPort ebx).GVPWidth] ; get width of viewport
|
||||
mov [vpwidth],eax ; save it off for later
|
||||
add eax,[(GraphicViewPort ebx).GVPXAdd] ; add in xadd for bytes_per_line
|
||||
add eax,[(GraphicViewPort ebx).GVPPitch] ; add in pitch of direct draw surface
|
||||
mov [bufferwidth],eax ; save it off for later use.
|
||||
|
||||
mul [y_pixel] ; multiply rowsize * y_pixel start.
|
||||
mov edi,[(GraphicViewPort ebx).GVPOffset] ; get start of the viewport
|
||||
add edi,eax ; add y position to start of vp
|
||||
mov [curline],edi ; save 0,y address for line feed stuff.
|
||||
add edi,[x_pixel] ; add to get starting column in starting row.
|
||||
mov [startdraw],edi ; save it off.
|
||||
|
||||
|
||||
mov eax,[x_pixel]
|
||||
mov [original_x],eax
|
||||
|
||||
;-------------------------------- Create block pointers ----------------------------------------
|
||||
; Get the pointer to the font.
|
||||
; We could check for NULL but why waste the time.
|
||||
; It is up to programmer to make sure it is set.
|
||||
mov esi,[FontPtr] ; Get the font pointer
|
||||
or esi,esi
|
||||
jz ??overflow
|
||||
|
||||
; Set up some pointers to the different memory blocks.
|
||||
; esi (FontPtr) is added to each to get the true address of each block.
|
||||
; Many registers are used for P5 optimizations.
|
||||
; ebx is used for InfoBlock which is then used in the next section.
|
||||
movzx eax,[WORD PTR esi+FONTOFFSETBLOCK] ; get offset to offset block
|
||||
movzx ebx,[WORD PTR esi+FONTINFOBLOCK] ; get offset to info block (must be ebx for height test)
|
||||
movzx ecx,[WORD PTR esi+FONTWIDTHBLOCK] ; get offset to width block
|
||||
movzx edx,[WORD PTR esi+FONTHEIGHTBLOCK] ; get offset to height block
|
||||
|
||||
add eax,esi ; add offset of FontPtr to offset block
|
||||
add ebx,esi ; add offset of FontPtr to info block
|
||||
add ecx,esi ; add offset of FontPtr to width block
|
||||
add edx,esi ; add offset of FontPtr to height block
|
||||
|
||||
mov [offsetblock],eax ; save offset to offset block
|
||||
mov [infoblock],ebx ; save offset to info block
|
||||
mov [widthblock],ecx ; save offset to width block
|
||||
mov [heightblock],edx ; save offset to height block
|
||||
|
||||
;------------------------------------------ Test for fit ----------------------------------------------
|
||||
; Test to make sure the height of the max character will fit on this line
|
||||
; and and not fall out of the viewport.
|
||||
; remember we set ebx to FONTINFOBLOCK above.
|
||||
movzx eax,[BYTE PTR ebx + FONTINFOMAXHEIGHT]; get the max height in font.
|
||||
mov [maxheight],al ; save it for later use.
|
||||
add eax,[y_pixel] ; add current y_value.
|
||||
cmp eax,[vpheight] ; are we over the edge?
|
||||
jg ??overflow ; if so, we're outa here.
|
||||
|
||||
mov [y_pixel],eax ; save for next line feed. y value for next line.
|
||||
|
||||
cld ; Make sure we are always forward copying.
|
||||
|
||||
;------------------------ Set palette foreground and background ----------------------------------
|
||||
mov eax,[fcolor] ; foreground color
|
||||
mov [ColorXlat+1],al
|
||||
mov [ColorXlat+16],al
|
||||
|
||||
mov eax,[bcolor] ; background color
|
||||
mov [ColorXlat],al
|
||||
|
||||
;-------------------------------------------------------------------------------------------------
|
||||
;----------------------------------------- Main loop ----------------------------------------------
|
||||
; Now we go into the main loop of reading each character in the string and doing
|
||||
; something with it.
|
||||
??next_char:
|
||||
; while (*string++)
|
||||
xor eax,eax ; zero out since we will just load al.
|
||||
mov esi,[string] ; get address on next character.
|
||||
lodsb ; load the character into al.
|
||||
test eax,0FFH ; test to see if character is a NULL
|
||||
jz ??done ; character is NULL, get outa here.
|
||||
|
||||
mov edi,[startdraw] ; Load the starting address.
|
||||
|
||||
mov [string],esi ; save index into string. (incremented by lodsb)
|
||||
|
||||
cmp al,10 ; is the character a carry return?
|
||||
je ??line_feed ; if so, go to special case.
|
||||
|
||||
cmp al,13 ; is the character a line feed?
|
||||
je ??line_feed ; if so, go to special case.
|
||||
|
||||
mov [char],eax ; save the character off for later reference.
|
||||
mov ebx,eax ; save it in ebx for later use also.
|
||||
|
||||
add eax,[widthblock] ; figure address of width of character.
|
||||
mov ecx,[x_pixel] ; get current x_pixel.
|
||||
movzx edx,[BYTE PTR eax] ; get the width of the character in dl.
|
||||
add ecx,edx ; add width of char to current x_pixel.
|
||||
mov eax,[FontXSpacing]
|
||||
add ecx,eax
|
||||
add [startdraw],edx ; save start draw for next character.
|
||||
add [startdraw],eax ; adjust for the font spacing value
|
||||
|
||||
cmp ecx,[vpwidth] ; is the pixel greater then the vp width?
|
||||
jg ??force_line_feed ; if so, force a line feed.
|
||||
|
||||
mov [x_pixel],ecx ; save value of start of next character.
|
||||
mov ecx,[bufferwidth] ; get amount to next y same x (one row down)
|
||||
sub ecx,edx ; take the current width off.
|
||||
mov [nextdraw],ecx ; save it to add to edi when done with a row.
|
||||
|
||||
; At this point we got the character. It is now time to find out specifics
|
||||
; about drawing the darn thing.
|
||||
; ebx = char so they can be used as an indexes.
|
||||
; edx = width of character for loop later.
|
||||
|
||||
; get offset of data for character into esi.
|
||||
shl ebx,1 ; mult by 2 to later use as a WORD index.
|
||||
mov esi,[offsetblock] ; get pointer to begining of offset block.
|
||||
add esi,ebx ; index into offset block.
|
||||
movzx esi,[WORD PTR esi] ; get true offset into data block from FontPtr.
|
||||
add esi,[FontPtr] ; Now add FontPtr address to get true address.
|
||||
|
||||
; Get top and bottom blank sizes and the true height of the character.
|
||||
add ebx,[heightblock] ; point ebx to element in height array.
|
||||
mov al,[ebx+1] ; load the data height into dl.
|
||||
mov cl,[ebx] ; load the first data row into cl.
|
||||
mov bl,[maxheight] ; get the max height of characters.
|
||||
mov [charheight],al ; get number of rows with data.
|
||||
add al,cl ; add the two heights.
|
||||
sub bl,al ; subract topblank + char height from maxheight.
|
||||
mov [bottomblank],bl ; save off the number of blank rows on the bottom.
|
||||
; leaving this section:
|
||||
; dl is still the width of the character.
|
||||
; cl is the height of the top blank area.
|
||||
|
||||
mov ebx,OFFSET ColorXlat ; setup ebx for xlat commands.
|
||||
mov dh,dl ; save the width of the character to restore each loop.
|
||||
|
||||
cmp cl,0 ; is there any blank rows on top?
|
||||
jz ??draw_char ; if not go and draw the real character.
|
||||
|
||||
xor eax,eax ; get color 0 for background.
|
||||
xlat [ebx] ; get translated color into al
|
||||
test al,al ; is it transparent black
|
||||
jnz ??loop_top ; if not go and write the color
|
||||
|
||||
;----------------------------------------- skip Top blank area ----------------------------------------
|
||||
; this case, the top is transparrent, but we need to increase our dest pointer to correct row.
|
||||
movzx eax,cl ; get number of rows into eax;
|
||||
mov ecx,edx ; save width since edx will be destroyed by mul.
|
||||
mul [bufferwidth] ; multiply that by the width of the buffer.
|
||||
mov edx,ecx ; restore the width
|
||||
add edi,eax ; update the pointer.
|
||||
jmp short ??draw_char ; now go draw the character.
|
||||
|
||||
;----------------------------------------- fill Top blank area ----------------------------------------
|
||||
; edi was set a long time ago.
|
||||
; al is the translated color
|
||||
??loop_top:
|
||||
stosb ; store the value
|
||||
dec dh ; decrement our width.
|
||||
jnz ??loop_top ; if more width, continue on.
|
||||
|
||||
add edi,[nextdraw] ; add amount for entire row.
|
||||
|
||||
dec cl ; decrement or row count
|
||||
mov dh,dl ; restore width in dh for loop.
|
||||
jz ??draw_char ; we are done here, go draw the character.
|
||||
jmp short ??loop_top ; go back to top of loop.
|
||||
|
||||
|
||||
;----------------------------------------- Draw character ----------------------------------------------
|
||||
??draw_char:
|
||||
movzx ecx,[charheight] ; get the height of character to count down rows.
|
||||
test ecx,ecx ; is there any data? (blank would not have any)
|
||||
jz ??next_char ; if no data, go on to next character.
|
||||
|
||||
??while_data:
|
||||
lodsb ; get byte value from font data
|
||||
mov ah,al ; save hinibble
|
||||
and eax,0F00FH ; mask of low nibble in al hi nibble in ah.
|
||||
xlat [ebx] ; get new color
|
||||
|
||||
test al,al ; is it a transparent?
|
||||
jz short ??skiplo ; skip over write
|
||||
mov [es:edi],al ; write it out
|
||||
??skiplo:
|
||||
inc edi
|
||||
dec dh ; decrement our width.
|
||||
jz short ??nextrow ; check if done with width of char
|
||||
|
||||
mov al,ah ; restore to get
|
||||
; test the time difference between looking up in a large table when shr al,4 is not done as
|
||||
; compared to using only a 16 byte table when using the shr al,4
|
||||
;shr al,4 ; shift the hi nibble down to low nibble
|
||||
xlat [ebx] ; get new color
|
||||
|
||||
test al,al ; is it a transparent?
|
||||
jz short ??skiphi ; skip over write
|
||||
mov [es:edi],al ; write it out
|
||||
??skiphi:
|
||||
|
||||
inc edi
|
||||
dec dh ; decrement our width.
|
||||
jnz short ??while_data ; check if done with width of char
|
||||
|
||||
??nextrow:
|
||||
add edi,[nextdraw] ; go to next line.
|
||||
dec ecx ; decrement the number of rows to go
|
||||
mov dh,dl ; restore our column count for row.
|
||||
jnz ??while_data ; more data for character.
|
||||
|
||||
; Now it is time to setup for clearing out the bottom of the character.
|
||||
movzx ecx,[bottomblank] ; get amount on bottom that is blank
|
||||
cmp ecx,0 ; if there is no blank bottom...
|
||||
jz ??next_char ; then skip to go to next character
|
||||
|
||||
xor eax,eax ; get color 0 for background.
|
||||
xlat [ebx] ; get translated color into al
|
||||
test al,al ; is it transparent black
|
||||
jz ??next_char ; skip the top black section to let the background through
|
||||
|
||||
mov dh,dl ; restore width in dh for loop.
|
||||
|
||||
;----------------------------------------- Blank below character -----------------------------------
|
||||
??loop_bottom:
|
||||
stosb ; store the value
|
||||
dec dh ; decrement our width.
|
||||
jnz ??loop_bottom ; if more width, continue on.
|
||||
|
||||
add edi,[nextdraw] ; add amount for entire row.
|
||||
|
||||
mov dh,dl ; restore width in dh for loop.
|
||||
dec cl ; decrement or row count
|
||||
jz ??next_char ; we are done here, go to the next character.
|
||||
jmp short ??loop_bottom ; go back to top of loop.
|
||||
|
||||
;----------------------------------- end of next_char (main) loop ------------------------------------
|
||||
;-------------------------------------------------------------------------------------------------
|
||||
|
||||
|
||||
;----------------------------------- special case line feeds ----------------------------------------
|
||||
|
||||
??force_line_feed:
|
||||
; decrement pointer *string so that it will be back at same character
|
||||
; when it goes through the loop.
|
||||
mov eax,[string] ; get string pointer.
|
||||
dec eax ; decrement it to point to previos char
|
||||
mov [string],eax ; save it back off.
|
||||
xor eax,eax
|
||||
; Now go into the line feed code.....
|
||||
|
||||
??line_feed:
|
||||
mov bl,al
|
||||
mov edx,[y_pixel] ; get the current y pixel value.
|
||||
movzx ecx,[maxheight] ; get max height for later use.
|
||||
add ecx,[FontYSpacing]
|
||||
add edx,ecx ; add max height to y_pixel
|
||||
cmp edx,[vpheight] ; are we over the edge?
|
||||
jg ??overflow ; if so, we are outa here.
|
||||
|
||||
mov eax,[bufferwidth] ; get bytes to next line.
|
||||
mov edi,[curline] ; get start of current line.
|
||||
mul ecx ; mult max height * next line.
|
||||
|
||||
add edi,eax ; add adjustment to current line.
|
||||
add [y_pixel],ecx ; increment to our next y position.
|
||||
;;; DRD
|
||||
mov [curline],edi ; save it off for next line_feed.
|
||||
|
||||
; Move the cursor to either the left edge of the screen
|
||||
; or the left margin of the print position depending
|
||||
; on whether <CR> or <LF> was specified. <CR> = left margin
|
||||
; <LF> = left edge of screen
|
||||
xor eax,eax
|
||||
cmp bl,10
|
||||
je ??lfeed
|
||||
mov eax,[original_x]
|
||||
??lfeed:
|
||||
mov [x_pixel],eax ; zero out x_pixel
|
||||
|
||||
add edi,eax
|
||||
;;; DRD mov [curline],edi ; save it off for next line_feed.
|
||||
mov [startdraw],edi ; save it off so we know where to draw next char.w
|
||||
|
||||
jmp ??next_char
|
||||
|
||||
??overflow:
|
||||
mov [startdraw],0 ; Indicate that there is no valid next pos.
|
||||
??done:
|
||||
mov eax,[startdraw] ; return this so calling routine
|
||||
ret ; can figure out where to draw next.
|
||||
|
||||
ENDP Buffer_Print
|
||||
|
||||
;***************************************************************************
|
||||
;* GET_FONT_PALETTE_PTR -- Returns a pointer to the 256 byte font palette *
|
||||
;* *
|
||||
;* INPUT: none *
|
||||
;* *
|
||||
;* OUTPUT: none *
|
||||
;* *
|
||||
;* PROTO: void *Get_Font_Palette_Ptr(void); *
|
||||
;* *
|
||||
;* HISTORY: *
|
||||
;* 08/18/1995 PWG : Created. *
|
||||
;*=========================================================================*
|
||||
|
||||
GLOBAL C Get_Font_Palette_Ptr:NEAR
|
||||
PROC Get_Font_Palette_Ptr C near
|
||||
mov eax, OFFSET ColorXlat
|
||||
ret
|
||||
ENDP Get_Font_Palette_Ptr
|
||||
|
||||
|
||||
END
|
||||
|
||||
END
|
Reference in New Issue
Block a user