Initial commit of Command & Conquer Red Alert source code.
This commit is contained in:
parent
b685cea758
commit
5e733d5dcc
2082 changed files with 797727 additions and 0 deletions
269
WIN32LIB/MISC/CLIPRECT.ASM
Normal file
269
WIN32LIB/MISC/CLIPRECT.ASM
Normal file
|
@ -0,0 +1,269 @@
|
|||
;
|
||||
; 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 : Support Library *
|
||||
;* *
|
||||
;* File Name : cliprect.asm *
|
||||
;* *
|
||||
;* Programmer : Julio R Jerez *
|
||||
;* *
|
||||
;* Start Date : Mar, 2 1995 *
|
||||
;* *
|
||||
;* *
|
||||
;*-------------------------------------------------------------------------*
|
||||
;* Functions: *
|
||||
;* int Clip_Rect ( int * x , int * y , int * dw , int * dh , *
|
||||
;* int width , int height ) ; *
|
||||
;* int Confine_Rect ( int * x , int * y , int * dw , int * dh , *
|
||||
;* int width , int height ) ; *
|
||||
;* *
|
||||
;* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - *
|
||||
|
||||
|
||||
IDEAL
|
||||
P386
|
||||
MODEL USE32 FLAT
|
||||
|
||||
GLOBAL C Clip_Rect :NEAR
|
||||
GLOBAL C Confine_Rect :NEAR
|
||||
|
||||
CODESEG
|
||||
|
||||
;***************************************************************************
|
||||
;* Clip_Rect -- clip a given rectangle against a given window *
|
||||
;* *
|
||||
;* INPUT: &x , &y , &w , &h -> Pointer to rectangle being clipped *
|
||||
;* width , height -> dimension of clipping window *
|
||||
;* *
|
||||
;* OUTPUT: a) Zero if the rectangle is totally contained by the *
|
||||
;* clipping window. *
|
||||
;* b) A negative value if the rectangle is totally outside the *
|
||||
;* the clipping window *
|
||||
;* c) A positive value if the rectangle was clipped against the *
|
||||
;* clipping window, also the values pointed by x, y, w, h will *
|
||||
;* be modified to new clipped values *
|
||||
;* *
|
||||
;* 05/03/1995 JRJ : added comment *
|
||||
;*=========================================================================*
|
||||
; int Clip_Rect (int* x, int* y, int* dw, int* dh, int width, int height); *
|
||||
|
||||
PROC Clip_Rect C near
|
||||
uses ebx,ecx,edx,esi,edi
|
||||
arg x:dword
|
||||
arg y:dword
|
||||
arg w:dword
|
||||
arg h:dword
|
||||
arg width:dword
|
||||
arg height: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, return the oroginal data)
|
||||
; - trivially rejected (return with no action, return error code)
|
||||
; - retangle must be iteratively clipped again edges of the clipping window
|
||||
; and return the clipped rectangle
|
||||
|
||||
; get all four pointer into regisnters
|
||||
mov esi,[x] ; esi = pointer to x
|
||||
mov edi,[y] ; edi = pointer to x
|
||||
mov eax,[w] ; eax = pointer to dw
|
||||
mov ebx,[h] ; ebx = pointer to dh
|
||||
|
||||
; load the actual data into reg
|
||||
mov esi,[esi] ; esi = x0
|
||||
mov edi,[edi] ; edi = y0
|
||||
mov eax,[eax] ; eax = dw
|
||||
mov ebx,[ebx] ; ebx = dh
|
||||
|
||||
; create a wire frame of the type [x0,y0] , [x1,y1]
|
||||
add eax,esi ; eax = x1 = x0 + dw
|
||||
add ebx,edi ; ebx = y1 = y0 + dh
|
||||
|
||||
; we start we suthenland code0 and code1 set to zero
|
||||
xor ecx,ecx ; cl = sutherland boolean code0
|
||||
xor edx,edx ; dl = sutherland boolean code0
|
||||
|
||||
; now we start computing the to suthenland boolean code for x0 , x1
|
||||
shld ecx,esi,1 ; bit3 of code0 = sign bit of (x0 - 0)
|
||||
shld edx,eax,1 ; bit3 of code1 = sign bit of (x1 - 0)
|
||||
sub esi,[width] ; get the difference (x0 - (width + 1))
|
||||
sub eax,[width] ; get the difference (x1 - (width + 1))
|
||||
dec esi
|
||||
dec eax
|
||||
shld ecx,esi,1 ; bit2 of code0 = sign bit of (x0 - (width + 1))
|
||||
shld edx,eax,1 ; bit2 of code1 = sign bit of (x0 - (width + 1))
|
||||
|
||||
; now we start computing the to suthenland boolean code for y0 , y1
|
||||
shld ecx,edi,1 ; bit1 of code0 = sign bit of (y0 - 0)
|
||||
shld edx,ebx,1 ; bit1 of code1 = sign bit of (y0 - 0)
|
||||
sub edi,[height] ; get the difference (y0 - (height + 1))
|
||||
sub ebx,[height] ; get the difference (y1 - (height + 1))
|
||||
dec edi
|
||||
dec ebx
|
||||
shld ecx,edi,1 ; bit0 of code0 = sign bit of (y0 - (height + 1))
|
||||
shld edx,ebx,1 ; bit0 of code1 = sign bit of (y1 - (height + 1))
|
||||
|
||||
; Bit 2 and 0 of cl and bl are complemented
|
||||
xor cl,5 ; reverse bit2 and bit0 in code0
|
||||
xor dl,5 ; reverse bit2 and bit0 in code1
|
||||
|
||||
; now perform the rejection test
|
||||
mov eax,-1 ; set return code to false
|
||||
mov bl,cl ; save code0 for future use
|
||||
test dl,cl ; if any two pair of bit in code0 and code1 is set
|
||||
jnz ??clip_out ; then rectangle is outside the window
|
||||
|
||||
; now perform the aceptance test
|
||||
xor eax,eax ; set return code to true
|
||||
or bl,dl ; if all pair of bits in code0 and code1 are reset
|
||||
jz ??clip_out ; then rectangle is insize the window. '
|
||||
|
||||
; we need to clip the rectangle iteratively
|
||||
mov eax,-1 ; set return code to false
|
||||
test cl,1000b ; if bit3 of code0 is set then the rectangle
|
||||
jz ??left_ok ; spill out the left edge of the window
|
||||
mov edi,[x] ; edi = a pointer to x0
|
||||
mov ebx,[w] ; ebx = a pointer to dw
|
||||
mov esi,[edi] ; esi = x0
|
||||
mov [dword ptr edi],0 ; set x0 to 0 "this the left edge value"
|
||||
add [ebx],esi ; adjust dw by x0, since x0 must be negative
|
||||
|
||||
??left_ok:
|
||||
test cl,0010b ; if bit1 of code0 is set then the rectangle
|
||||
jz ??bottom_ok ; spill out the bottom edge of the window
|
||||
mov edi,[y] ; edi = a pointer to y0
|
||||
mov ebx,[h] ; ebx = a pointer to dh
|
||||
mov esi,[edi] ; esi = y0
|
||||
mov [dword ptr edi],0 ; set y0 to 0 "this the bottom edge value"
|
||||
add [ebx],esi ; adjust dh by y0, since y0 must be negative
|
||||
|
||||
??bottom_ok:
|
||||
test dl,0100b ; if bit2 of code1 is set then the rectangle
|
||||
jz ??right_ok ; spill out the right edge of the window
|
||||
mov edi,[w] ; edi = a pointer to dw
|
||||
mov esi,[x] ; esi = a pointer to x
|
||||
mov ebx,[width] ; ebx = the width of the window
|
||||
sub ebx,[esi] ; the new dw is the difference (width-x0)
|
||||
mov [edi],ebx ; adjust dw to (width - x0)
|
||||
jle ??clip_out ; if (width-x0) = 0 then the clipped retangle
|
||||
; has no width we are done
|
||||
??right_ok:
|
||||
test dl,0001b ; if bit0 of code1 is set then the rectangle
|
||||
jz ??clip_ok ; spill out the top edge of the window
|
||||
mov edi,[h] ; edi = a pointer to dh
|
||||
mov esi,[y] ; esi = a pointer to y0
|
||||
mov ebx,[height] ; ebx = the height of the window
|
||||
sub ebx,[esi] ; the new dh is the difference (height-y0)
|
||||
mov [edi],ebx ; adjust dh to (height-y0)
|
||||
jle ??clip_out ; if (width-x0) = 0 then the clipped retangle
|
||||
; has no width we are done
|
||||
??clip_ok:
|
||||
mov eax,1 ; signal the calling program that the rectangle was modify
|
||||
??clip_out:
|
||||
ret
|
||||
ENDP Clip_Rect
|
||||
|
||||
|
||||
;***************************************************************************
|
||||
;* Confine_Rect -- clip a given rectangle against a given window *
|
||||
;* *
|
||||
;* INPUT: &x,&y,w,h -> Pointer to rectangle being clipped *
|
||||
;* width,height -> dimension of clipping window *
|
||||
;* *
|
||||
;* OUTPUT: a) Zero if the rectangle is totally contained by the *
|
||||
;* clipping window. *
|
||||
;* c) A positive value if the rectangle was shifted in position *
|
||||
;* to fix inside the clipping window, also the values pointed *
|
||||
;* by x, y, will adjusted to a new values *
|
||||
;* *
|
||||
;* NOTE: this function make not attempt to verify if the rectangle is *
|
||||
;* bigger than the clipping window and at the same time wrap around*
|
||||
;* it. If that is the case the result is meaningless *
|
||||
;*=========================================================================*
|
||||
; int Confine_Rect (int* x, int* y, int dw, int dh, int width, int height); *
|
||||
|
||||
PROC Confine_Rect C near
|
||||
uses ebx, esi,edi
|
||||
arg x:dword
|
||||
arg y:dword
|
||||
arg w:dword
|
||||
arg h:dword
|
||||
arg width :dword
|
||||
arg height:dword
|
||||
|
||||
xor eax,eax
|
||||
mov ebx,[x]
|
||||
mov edi,[w]
|
||||
|
||||
mov esi,[ebx]
|
||||
add edi,[ebx]
|
||||
|
||||
sub edi,[width]
|
||||
neg esi
|
||||
dec edi
|
||||
|
||||
test esi,edi
|
||||
jl ??x_axix_ok
|
||||
mov eax,1
|
||||
|
||||
test esi,esi
|
||||
jl ??shift_right
|
||||
mov [dword ptr ebx],0
|
||||
jmp ??x_axix_ok
|
||||
??shift_right:
|
||||
inc edi
|
||||
sub [ebx],edi
|
||||
??x_axix_ok:
|
||||
mov ebx,[y]
|
||||
mov edi,[h]
|
||||
|
||||
mov esi,[ebx]
|
||||
add edi,[ebx]
|
||||
|
||||
sub edi,[height]
|
||||
neg esi
|
||||
dec edi
|
||||
|
||||
test esi,edi
|
||||
jl ??confi_out
|
||||
mov eax,1
|
||||
|
||||
test esi,esi
|
||||
jl ??shift_top
|
||||
mov [dword ptr ebx],0
|
||||
ret
|
||||
??shift_top:
|
||||
inc edi
|
||||
sub [ebx],edi
|
||||
??confi_out:
|
||||
ret
|
||||
|
||||
ENDP Confine_Rect
|
||||
|
||||
END
|
114
WIN32LIB/MISC/CRC.ASM
Normal file
114
WIN32LIB/MISC/CRC.ASM
Normal file
|
@ -0,0 +1,114 @@
|
|||
;
|
||||
; 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 Library *
|
||||
;* *
|
||||
;* File Name : CRC.ASM *
|
||||
;* *
|
||||
;* Programmer : Joe L. Bostic *
|
||||
;* *
|
||||
;* Start Date : June 12, 1992 *
|
||||
;* *
|
||||
;* Last Update : February 10, 1995 [BWG] *
|
||||
;* *
|
||||
;*-------------------------------------------------------------------------*
|
||||
;* Functions: *
|
||||
;* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - *
|
||||
|
||||
IDEAL
|
||||
P386
|
||||
MODEL USE32 FLAT
|
||||
|
||||
GLOBAL C Calculate_CRC :NEAR
|
||||
|
||||
CODESEG
|
||||
|
||||
; LONG Calculate_CRC(VOID *buffer, LONG length);
|
||||
PROC Calculate_CRC C near
|
||||
USES esi
|
||||
|
||||
ARG buffer:DWORD
|
||||
ARG length:DWORD
|
||||
|
||||
LOCAL crc:DWORD
|
||||
|
||||
; Load pointer to data block.
|
||||
mov [crc],0
|
||||
pushad
|
||||
mov esi,[buffer]
|
||||
cld
|
||||
|
||||
; Clear CRC to default (NULL) value.
|
||||
xor ebx,ebx
|
||||
|
||||
; Fetch the length of the data block to CRC.
|
||||
mov ecx,[length]
|
||||
jecxz short ??fini
|
||||
|
||||
; Prepare the length counters.
|
||||
mov edx,ecx
|
||||
and dl,011b
|
||||
shr ecx,2
|
||||
|
||||
; Perform the bulk of the CRC scanning.
|
||||
jecxz short ??remainder
|
||||
??accumloop:
|
||||
lodsd
|
||||
rol ebx,1
|
||||
add ebx,eax
|
||||
loop ??accumloop
|
||||
|
||||
; Handle the remainder bytes.
|
||||
??remainder:
|
||||
or dl,dl
|
||||
jz short ??fini
|
||||
mov ecx,edx
|
||||
xor eax,eax
|
||||
|
||||
and ecx,0FFFFh
|
||||
push ecx
|
||||
??nextbyte:
|
||||
lodsb
|
||||
ror eax,8
|
||||
loop ??nextbyte
|
||||
pop ecx
|
||||
neg ecx
|
||||
add ecx,4
|
||||
shl ecx,3
|
||||
ror eax,cl
|
||||
|
||||
;??nextbyte:
|
||||
; shl eax,8
|
||||
; lodsb
|
||||
; loop ??nextbyte
|
||||
rol ebx,1
|
||||
add ebx,eax
|
||||
|
||||
??fini:
|
||||
mov [crc],ebx
|
||||
popad
|
||||
mov eax,[crc]
|
||||
ret
|
||||
|
||||
ENDP Calculate_CRC
|
||||
|
||||
END
|
1000
WIN32LIB/MISC/DDRAW.CPP
Normal file
1000
WIN32LIB/MISC/DDRAW.CPP
Normal file
File diff suppressed because it is too large
Load diff
62
WIN32LIB/MISC/DELAY.CPP
Normal file
62
WIN32LIB/MISC/DELAY.CPP
Normal file
|
@ -0,0 +1,62 @@
|
|||
/*
|
||||
** 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 : LIBRARY *
|
||||
* *
|
||||
* File Name : DELAY.C *
|
||||
* *
|
||||
* Programmer : Christopher Yates *
|
||||
* *
|
||||
* Last Update : 27 March, 1991 [CY] *
|
||||
* *
|
||||
*-------------------------------------------------------------------------*
|
||||
* Functions: *
|
||||
* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
|
||||
|
||||
#include "wwstd.h"
|
||||
#include <timer.h>
|
||||
|
||||
void Delay(int duration)
|
||||
{
|
||||
unsigned long count;
|
||||
TimerClass timer(BT_SYSTEM,TRUE);
|
||||
|
||||
while (duration--) {
|
||||
count = timer.Time() + 1L;
|
||||
while (count >= timer.Time()) {
|
||||
;
|
||||
}
|
||||
}
|
||||
|
||||
#if(FALSE)
|
||||
while (duration--)
|
||||
Wait_Vert_Blank(VertBlank);
|
||||
#endif
|
||||
}
|
||||
|
||||
#if(FALSE)
|
||||
void Vsync()
|
||||
{
|
||||
Wait_Vert_Blank(VertBlank);
|
||||
}
|
||||
#endif
|
||||
|
115
WIN32LIB/MISC/DETPROC.ASM
Normal file
115
WIN32LIB/MISC/DETPROC.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/>.
|
||||
;
|
||||
|
||||
; $Header: g:/library/wwlib32/system/rcs/detproc.asm 1.1 1994/04/18 09:13:53 jeff_wilson Exp $
|
||||
;***************************************************************************
|
||||
;** 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 : PROC.ASM *
|
||||
;* *
|
||||
;* Programmer : Joe L. Bostic *
|
||||
;* *
|
||||
;* Start Date : May 11, 1993 *
|
||||
;* *
|
||||
;* Last Update : May 11, 1993 [JLB] *
|
||||
;* *
|
||||
;* Converted to 32Bit -- JAW *
|
||||
;* *
|
||||
;*-------------------------------------------------------------------------*
|
||||
;* Functions: *
|
||||
;* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - *
|
||||
|
||||
IDEAL
|
||||
P386
|
||||
MODEL USE32 FLAT
|
||||
|
||||
GLOBAL C Processor :NEAR
|
||||
|
||||
|
||||
PROC_80386 equ 0
|
||||
PROC_80486 equ 1
|
||||
PROC_80586 equ 2
|
||||
|
||||
DATASEG
|
||||
cpu_id_586 dw 0
|
||||
|
||||
CODESEG
|
||||
|
||||
PROC Processor C near
|
||||
USES ebx
|
||||
LOCAL ptype:WORD
|
||||
|
||||
pushfd
|
||||
|
||||
; At least a 386 -- check for 486.
|
||||
mov [WORD PTR ptype],PROC_80386 ; 80386
|
||||
pushfd
|
||||
pop eax
|
||||
mov ebx,eax
|
||||
xor eax,40000h
|
||||
push eax
|
||||
popfd
|
||||
pushfd
|
||||
pop eax
|
||||
xor eax,ebx
|
||||
je short ??fini
|
||||
|
||||
; At least a 486 -- check for 586(Pentium)
|
||||
mov [ptype],PROC_80486 ; 80486
|
||||
|
||||
; Some machines have a problem with this fLAG
|
||||
; and thus make us think they are a 586 but they are
|
||||
; really a 486. A possible way around this is to
|
||||
; capture the Illegal instruction vector, then do
|
||||
; an instruction only available on the 586.
|
||||
|
||||
; for now this is just commented out
|
||||
pushfd
|
||||
pop eax
|
||||
mov ebx,eax
|
||||
xor eax,200000h
|
||||
push eax
|
||||
popfd
|
||||
pushfd
|
||||
pop eax
|
||||
xor eax,ebx
|
||||
je short ??fini
|
||||
|
||||
; At least a 586(Pentium) -- check for higher.
|
||||
mov [ptype],PROC_80586 ; 80486
|
||||
; mov eax,1
|
||||
; DW 0fA2h ; CPUID opcode.
|
||||
; shr ax,8
|
||||
; and ax,0fh
|
||||
; inc ax
|
||||
; inc ax
|
||||
; mov [cpu_id_586],ax
|
||||
|
||||
; Final cleanup and exit.
|
||||
??fini:
|
||||
popfd
|
||||
sub eax,eax
|
||||
mov ax,[ptype]
|
||||
ret
|
||||
|
||||
ENDP Processor
|
||||
|
||||
END
|
91
WIN32LIB/MISC/EXIT.CPP
Normal file
91
WIN32LIB/MISC/EXIT.CPP
Normal file
|
@ -0,0 +1,91 @@
|
|||
/*
|
||||
** 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 : WWLIB32 library source *
|
||||
* *
|
||||
* File Name : EXIT.CPP *
|
||||
* *
|
||||
* Programmer : Scott K. Bowen *
|
||||
* *
|
||||
* Start Date : August 3, 1994 *
|
||||
* *
|
||||
* Last Update : August 3, 1994 [SKB] *
|
||||
* *
|
||||
*-------------------------------------------------------------------------*
|
||||
* Functions: *
|
||||
* Exit -- Exit routine with message. *
|
||||
* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
|
||||
|
||||
#include "misc.h"
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdarg.h>
|
||||
#include <time.h>
|
||||
|
||||
|
||||
|
||||
|
||||
/***************************************************************************
|
||||
* EXIT -- Exit routine with message. *
|
||||
* *
|
||||
* *
|
||||
* *
|
||||
* INPUT: *
|
||||
* *
|
||||
* OUTPUT: *
|
||||
* *
|
||||
* WARNINGS: *
|
||||
* *
|
||||
* HISTORY: *
|
||||
* 08/03/1994 SKB : Created. *
|
||||
*=========================================================================*/
|
||||
void __cdecl Exit(INT errorval, const char *message, ...)
|
||||
{
|
||||
va_list argptr;
|
||||
char errstring[256];
|
||||
|
||||
Prog_End();
|
||||
|
||||
if (message && *message) {
|
||||
va_start (argptr, message);
|
||||
vsprintf ((char *)errstring, (const char *)message, argptr);
|
||||
va_end (argptr);
|
||||
printf(errstring);
|
||||
}
|
||||
|
||||
::exit(errorval);
|
||||
|
||||
}
|
||||
|
||||
void randomize ( void )
|
||||
{
|
||||
srand ( time ( NULL ) ) ;
|
||||
}
|
||||
|
||||
#if(0)
|
||||
unsigned long random ( unsigned long mod )
|
||||
{
|
||||
return rand () * mod / RAND_MAX ;
|
||||
}
|
||||
#endif
|
148
WIN32LIB/MISC/FACING16.ASM
Normal file
148
WIN32LIB/MISC/FACING16.ASM
Normal file
|
@ -0,0 +1,148 @@
|
|||
;
|
||||
; 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/./facing16.asm 1.10 1994/05/20 15:32:36 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 : Support Library *
|
||||
;* *
|
||||
;* File Name : FACING16.ASM *
|
||||
;* *
|
||||
;* Programmer : Joe L. Bostic *
|
||||
;* *
|
||||
;* Start Date : May 8, 1991 *
|
||||
;* *
|
||||
;* Last Update : February 6, 1995 [BWG] *
|
||||
;* *
|
||||
;*-------------------------------------------------------------------------*
|
||||
;* Functions: *
|
||||
;* Desired_Facing16 -- Converts coordinates into a facing number. *
|
||||
;* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - *
|
||||
|
||||
|
||||
IDEAL
|
||||
P386
|
||||
MODEL USE32 FLAT
|
||||
|
||||
GLOBAL C Desired_Facing16 :NEAR
|
||||
; INCLUDE "wwlib.i"
|
||||
|
||||
DATASEG
|
||||
|
||||
; 16 direction desired facing lookup table. Build the index according
|
||||
; to the following bits:
|
||||
;
|
||||
; bit 4 = Is y2 < y1?
|
||||
; bit 3 = Is x2 < x1?
|
||||
; bit 2 = Is the ABS(x2-x1) < ABS(y2-y1)?
|
||||
; bit 1 = Is the lesser absolute difference very close to zero?
|
||||
; bit 0 = Is the lesser absolute difference very close to the greater dist?
|
||||
NewFacing16 DB 3, 2, 4,-1, 1, 2,0,-1
|
||||
DB 13,14,12,-1,15,14,0,-1
|
||||
DB 5, 6, 4,-1, 7, 6,8,-1
|
||||
DB 11,10,12,-1, 9,10,8,-1
|
||||
|
||||
CODESEG
|
||||
|
||||
;***************************************************************************
|
||||
;* DESIRED_FACING16 -- Converts coordinates into a facing number. *
|
||||
;* *
|
||||
;* This converts coordinates into a desired facing number that ranges *
|
||||
;* from 0 to 15 (0 equals North and going clockwise). *
|
||||
;* *
|
||||
;* INPUT: x1,y1 -- Position of origin point. *
|
||||
;* *
|
||||
;* x2,y2 -- Position of target. *
|
||||
;* *
|
||||
;* OUTPUT: Returns desired facing as a number from 0 to 255 but *
|
||||
;* accurate to 22.5 degree increments. *
|
||||
;* *
|
||||
;* WARNINGS: If the two coordinates are the same, then -1 will be *
|
||||
;* returned. It is up to you to handle this case. *
|
||||
;* *
|
||||
;* HISTORY: *
|
||||
;* 08/14/1991 JLB : Created. *
|
||||
;*=========================================================================*
|
||||
; long Desired_Facing16(long x1, long y1, long x2, long y2);
|
||||
|
||||
PROC Desired_Facing16 C near
|
||||
USES ebx, ecx, edx
|
||||
|
||||
ARG x1:DWORD
|
||||
ARG y1:DWORD
|
||||
ARG x2:DWORD
|
||||
ARG y2:DWORD
|
||||
|
||||
xor ebx,ebx ; Index byte (built).
|
||||
|
||||
; Determine Y axis difference.
|
||||
mov edx,[y1]
|
||||
mov ecx,[y2]
|
||||
sub edx,ecx ; DX = Y axis (signed).
|
||||
jns short ??absy
|
||||
inc ebx ; Set the signed bit.
|
||||
neg edx ; ABS(y)
|
||||
??absy:
|
||||
|
||||
; Determine X axis difference.
|
||||
shl ebx,1
|
||||
mov eax,[x1]
|
||||
mov ecx,[x2]
|
||||
sub ecx,eax ; CX = X axis (signed).
|
||||
jns short ??absx
|
||||
inc ebx ; Set the signed bit.
|
||||
neg ecx ; ABS(x)
|
||||
??absx:
|
||||
|
||||
; Determine the greater axis.
|
||||
cmp ecx,edx
|
||||
jb short ??dxisbig
|
||||
xchg ecx,edx
|
||||
??dxisbig:
|
||||
rcl ebx,1 ; Y > X flag bit.
|
||||
|
||||
; Determine the closeness or farness of lesser axis.
|
||||
mov eax,edx
|
||||
inc eax ; Round up.
|
||||
shr eax,1
|
||||
inc eax ; Round up.
|
||||
shr eax,1 ; 1/4 of greater axis.
|
||||
|
||||
cmp ecx,eax
|
||||
rcl ebx,1 ; Very close to major axis bit.
|
||||
|
||||
sub edx,eax
|
||||
cmp edx,ecx
|
||||
rcl ebx,1 ; Very far from major axis bit.
|
||||
|
||||
xor eax,eax
|
||||
mov al,[NewFacing16+ebx]
|
||||
|
||||
; Normalize to 0..FF range.
|
||||
shl eax,4
|
||||
|
||||
ret
|
||||
|
||||
ENDP Desired_Facing16
|
||||
|
||||
END
|
||||
|
||||
|
||||
|
140
WIN32LIB/MISC/FACING8.ASM
Normal file
140
WIN32LIB/MISC/FACING8.ASM
Normal file
|
@ -0,0 +1,140 @@
|
|||
;
|
||||
; 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 : Support Library *
|
||||
;* *
|
||||
;* File Name : FACING8.ASM *
|
||||
;* *
|
||||
;* Programmer : Joe L. Bostic *
|
||||
;* *
|
||||
;* Start Date : May 8, 1991 *
|
||||
;* *
|
||||
;* Last Update : February 6, 1995 [BWG] *
|
||||
;* *
|
||||
;*-------------------------------------------------------------------------*
|
||||
;* Functions: *
|
||||
;* Desired_Facing8 -- Determines facing to reach a position. *
|
||||
;* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - *
|
||||
|
||||
|
||||
IDEAL
|
||||
P386
|
||||
MODEL USE32 FLAT
|
||||
|
||||
|
||||
GLOBAL C Desired_Facing8 :NEAR
|
||||
; INCLUDE "wwlib.i"
|
||||
|
||||
DATASEG
|
||||
|
||||
; 8 direction desired facing lookup table. Build the index according
|
||||
; to the following bits:
|
||||
;
|
||||
; bit 3 = Is y2 < y1?
|
||||
; bit 2 = Is x2 < x1?
|
||||
; bit 1 = Is the ABS(x2-x1) < ABS(y2-y1)?
|
||||
; bit 0 = Is the facing closer to a major axis?
|
||||
NewFacing8 DB 1,2,1,0,7,6,7,0,3,2,3,4,5,6,5,4
|
||||
|
||||
CODESEG
|
||||
|
||||
;***************************************************************************
|
||||
;* DESIRED_FACING8 -- Determines facing to reach a position. *
|
||||
;* *
|
||||
;* This routine will return with the most desirable facing to reach *
|
||||
;* one position from another. It is accurate to a resolution of 0 to *
|
||||
;* 7. *
|
||||
;* *
|
||||
;* INPUT: x1,y1 -- Position of origin point. *
|
||||
;* *
|
||||
;* x2,y2 -- Position of target. *
|
||||
;* *
|
||||
;* OUTPUT: Returns desired facing as a number from 0..255 with an *
|
||||
;* accuracy of 32 degree increments. *
|
||||
;* *
|
||||
;* WARNINGS: If the two coordinates are the same, then -1 will be *
|
||||
;* returned. It is up to you to handle this case. *
|
||||
;* *
|
||||
;* HISTORY: *
|
||||
;* 07/15/1991 JLB : Documented. *
|
||||
;* 08/08/1991 JLB : Same position check. *
|
||||
;* 08/14/1991 JLB : New algorithm *
|
||||
;* 02/06/1995 BWG : Convert to 32-bit *
|
||||
;*=========================================================================*
|
||||
; long Desired_Facing8(long x1, long y1, long x2, long y2);
|
||||
|
||||
PROC Desired_Facing8 C near
|
||||
USES ebx, ecx, edx
|
||||
|
||||
ARG x1:DWORD
|
||||
ARG y1:DWORD
|
||||
ARG x2:DWORD
|
||||
ARG y2:DWORD
|
||||
|
||||
xor ebx,ebx ; Index byte (built).
|
||||
|
||||
; Determine Y axis difference.
|
||||
mov edx,[y1]
|
||||
mov ecx,[y2]
|
||||
sub edx,ecx ; DX = Y axis (signed).
|
||||
jns short ??absy
|
||||
inc ebx ; Set the signed bit.
|
||||
neg edx ; ABS(y)
|
||||
??absy:
|
||||
|
||||
; Determine X axis difference.
|
||||
shl ebx,1
|
||||
mov eax,[x1]
|
||||
mov ecx,[x2]
|
||||
sub ecx,eax ; CX = X axis (signed).
|
||||
jns short ??absx
|
||||
inc ebx ; Set the signed bit.
|
||||
neg ecx ; ABS(x)
|
||||
??absx:
|
||||
|
||||
; Determine the greater axis.
|
||||
cmp ecx,edx
|
||||
jb short ??dxisbig
|
||||
xchg ecx,edx
|
||||
??dxisbig:
|
||||
rcl ebx,1 ; Y > X flag bit.
|
||||
|
||||
; Determine the closeness or farness of lesser axis.
|
||||
mov eax,edx
|
||||
inc eax ; Round up.
|
||||
shr eax,1
|
||||
|
||||
cmp ecx,eax
|
||||
rcl ebx,1 ; Close to major axis bit.
|
||||
|
||||
xor eax,eax
|
||||
mov al,[NewFacing8+ebx]
|
||||
|
||||
; Normalize to 0..FF range.
|
||||
shl eax,5
|
||||
|
||||
ret
|
||||
|
||||
ENDP Desired_Facing8
|
||||
|
||||
|
||||
END
|
165
WIN32LIB/MISC/FACINGFF.ASM
Normal file
165
WIN32LIB/MISC/FACINGFF.ASM
Normal file
|
@ -0,0 +1,165 @@
|
|||
;
|
||||
; 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 : Support Library *
|
||||
;* *
|
||||
;* File Name : FACINGFF.ASM *
|
||||
;* *
|
||||
;* Programmer : Joe L. Bostic *
|
||||
;* *
|
||||
;* Start Date : May 8, 1991 *
|
||||
;* *
|
||||
;* Last Update : February 6, 1995 [BWG] *
|
||||
;* *
|
||||
;*-------------------------------------------------------------------------*
|
||||
;* Functions: *
|
||||
;* Desired_Facing256 -- Determines facing to reach a position. *
|
||||
;* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - *
|
||||
|
||||
|
||||
IDEAL
|
||||
P386
|
||||
MODEL USE32 FLAT
|
||||
|
||||
GLOBAL C Desired_Facing256 :NEAR
|
||||
; INCLUDE "wwlib.i"
|
||||
INCLUDE "..\include\gbuffer.inc"
|
||||
|
||||
CODESEG
|
||||
|
||||
;***************************************************************************
|
||||
;* Desired_Facing256 -- Desired facing algorithm 0..255 resolution. *
|
||||
;* *
|
||||
;* This is a desired facing algorithm that has a resolution of 0 *
|
||||
;* through 255. *
|
||||
;* *
|
||||
;* INPUT: srcx,srcy -- Source coordinate. *
|
||||
;* *
|
||||
;* dstx,dsty -- Destination coordinate. *
|
||||
;* *
|
||||
;* OUTPUT: Returns with the desired facing to face the destination *
|
||||
;* coordinate from the position of the source coordinate. North *
|
||||
;* is 0, East is 64, etc. *
|
||||
;* *
|
||||
;* WARNINGS: This routine is slower than the other forms of desired *
|
||||
;* facing calculation. Use this routine when accuracy is *
|
||||
;* required. *
|
||||
;* *
|
||||
;* HISTORY: *
|
||||
;* 12/24/1991 JLB : Adapted. *
|
||||
;*=========================================================================*/
|
||||
; LONG cdecl Desired_Facing256(LONG srcx, LONG srcy, LONG dstx, LONG dsty)
|
||||
PROC Desired_Facing256 C near
|
||||
USES ebx, ecx, edx
|
||||
|
||||
ARG srcx:DWORD
|
||||
ARG srcy:DWORD
|
||||
ARG dstx:DWORD
|
||||
ARG dsty:DWORD
|
||||
|
||||
xor ebx,ebx ; Facing number.
|
||||
|
||||
; Determine absolute X delta and left/right direction.
|
||||
mov ecx,[dstx]
|
||||
sub ecx,[srcx]
|
||||
jge short ??xnotneg
|
||||
neg ecx
|
||||
mov ebx,11000000b ; Set bit 7 and 6 for leftward.
|
||||
??xnotneg:
|
||||
|
||||
; Determine absolute Y delta and top/bottom direction.
|
||||
mov eax,[srcy]
|
||||
sub eax,[dsty]
|
||||
jge short ??ynotneg
|
||||
xor ebx,01000000b ; Complement bit 6 for downward.
|
||||
neg eax
|
||||
??ynotneg:
|
||||
|
||||
; Set DX=64 for quadrants 0 and 2.
|
||||
mov edx,ebx
|
||||
and edx,01000000b
|
||||
xor edx,01000000b
|
||||
|
||||
; Determine if the direction is closer to the Y axis and make sure that
|
||||
; CX holds the larger of the two deltas. This is in preparation for the
|
||||
; divide.
|
||||
cmp eax,ecx
|
||||
jb short ??gotaxis
|
||||
xchg eax,ecx
|
||||
xor edx,01000000b ; Closer to Y axis so make DX=64 for quad 0 and 2.
|
||||
??gotaxis:
|
||||
|
||||
; If closer to the X axis then add 64 for quadrants 0 and 2. If
|
||||
; closer to the Y axis then add 64 for quadrants 1 and 3. Determined
|
||||
; add value is in DX and save on stack.
|
||||
push edx
|
||||
|
||||
; Make sure that the division won't overflow. Reduce precision until
|
||||
; the larger number is less than 256 if it appears that an overflow
|
||||
; will occur. If the high byte of the divisor is not zero, then this
|
||||
; guarantees no overflow, so just abort shift operation.
|
||||
test eax,0FFFFFF00h
|
||||
jnz short ??nooverflow
|
||||
??again:
|
||||
test ecx,0FFFFFF00h
|
||||
jz short ??nooverflow
|
||||
shr ecx,1
|
||||
shr eax,1
|
||||
jmp short ??again
|
||||
??nooverflow:
|
||||
|
||||
; Make sure that the division won't underflow (divide by zero). If
|
||||
; this would occur, then set the quotient to $FF and skip divide.
|
||||
or ecx,ecx
|
||||
jnz short ??nounderflow
|
||||
mov eax,0FFFFFFFFh
|
||||
jmp short ??divcomplete
|
||||
|
||||
; Derive a pseudo angle number for the octant. The angle is based
|
||||
; on $00 = angle matches long axis, $00 = angle matches $FF degrees.
|
||||
??nounderflow:
|
||||
xor edx,edx
|
||||
shld edx,eax,8 ; shift high byte of eax into dl
|
||||
shl eax,8
|
||||
div ecx
|
||||
??divcomplete:
|
||||
|
||||
; Integrate the 5 most significant bits into the angle index. If DX
|
||||
; is not zero, then it is 64. This means that the dividend must be negated
|
||||
; before it is added into the final angle value.
|
||||
shr eax,3
|
||||
pop edx
|
||||
or edx,edx
|
||||
je short ??noneg
|
||||
dec edx
|
||||
neg eax
|
||||
??noneg:
|
||||
add eax,edx
|
||||
add eax,ebx
|
||||
and eax,0FFH
|
||||
ret
|
||||
|
||||
ENDP Desired_Facing256
|
||||
|
||||
|
||||
|
||||
END
|
215
WIN32LIB/MISC/FADING.ASM
Normal file
215
WIN32LIB/MISC/FADING.ASM
Normal file
|
@ -0,0 +1,215 @@
|
|||
;
|
||||
; 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 : FADING.ASM *
|
||||
;* *
|
||||
;* Programmer : Joe L. Bostic *
|
||||
;* *
|
||||
;* Start Date : August 20, 1993 *
|
||||
;* *
|
||||
;* Last Update : August 20, 1993 [JLB] *
|
||||
;* *
|
||||
;*-------------------------------------------------------------------------*
|
||||
;* Functions: *
|
||||
;* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - *
|
||||
|
||||
IDEAL
|
||||
P386
|
||||
MODEL USE32 FLAT
|
||||
|
||||
GLOBAL C Build_Fading_Table :NEAR
|
||||
|
||||
CODESEG
|
||||
|
||||
;***********************************************************
|
||||
; BUILD_FADING_TABLE
|
||||
;
|
||||
; void *Build_Fading_Table(void *palette, void *dest, long int color, long int frac);
|
||||
;
|
||||
; This routine will create the fading effect table used to coerce colors
|
||||
; from toward a common value. This table is used when Fading_Effect is
|
||||
; active.
|
||||
;
|
||||
; Bounds Checking: None
|
||||
;*
|
||||
PROC Build_Fading_Table C near
|
||||
USES ebx, ecx, edi, esi
|
||||
ARG palette:DWORD
|
||||
ARG dest:DWORD
|
||||
ARG color:DWORD
|
||||
ARG frac:DWORD
|
||||
|
||||
LOCAL matchvalue:DWORD ; Last recorded match value.
|
||||
LOCAL targetred:BYTE ; Target gun red.
|
||||
LOCAL targetgreen:BYTE ; Target gun green.
|
||||
LOCAL targetblue:BYTE ; Target gun blue.
|
||||
LOCAL idealred:BYTE
|
||||
LOCAL idealgreen:BYTE
|
||||
LOCAL idealblue:BYTE
|
||||
LOCAL matchcolor:BYTE ; Tentative match color.
|
||||
|
||||
cld
|
||||
|
||||
; If the source palette is NULL, then just return with current fading table pointer.
|
||||
cmp [palette],0
|
||||
je ??fini
|
||||
cmp [dest],0
|
||||
je ??fini
|
||||
|
||||
; Fractions above 255 become 255.
|
||||
mov eax,[frac]
|
||||
cmp eax,0100h
|
||||
jb short ??ok
|
||||
mov [frac],0FFh
|
||||
??ok:
|
||||
|
||||
; Record the target gun values.
|
||||
mov esi,[palette]
|
||||
mov ebx,[color]
|
||||
add esi,ebx
|
||||
add esi,ebx
|
||||
add esi,ebx
|
||||
lodsb
|
||||
mov [targetred],al
|
||||
lodsb
|
||||
mov [targetgreen],al
|
||||
lodsb
|
||||
mov [targetblue],al
|
||||
|
||||
; Main loop.
|
||||
xor ebx,ebx ; Remap table index.
|
||||
|
||||
; Transparent black never gets remapped.
|
||||
mov edi,[dest]
|
||||
mov [edi],bl
|
||||
inc edi
|
||||
|
||||
; EBX = source palette logical number (1..255).
|
||||
; EDI = running pointer into dest remap table.
|
||||
??mainloop:
|
||||
inc ebx
|
||||
mov esi,[palette]
|
||||
add esi,ebx
|
||||
add esi,ebx
|
||||
add esi,ebx
|
||||
|
||||
mov edx,[frac]
|
||||
shr edx,1
|
||||
; new = orig - ((orig-target) * fraction);
|
||||
|
||||
lodsb ; orig
|
||||
mov dh,al ; preserve it for later.
|
||||
sub al,[targetred] ; al = (orig-target)
|
||||
imul dl ; ax = (orig-target)*fraction
|
||||
shl ax,1
|
||||
sub dh,ah ; dh = orig - ((orig-target) * fraction)
|
||||
mov [idealred],dh ; preserve ideal color gun value.
|
||||
|
||||
lodsb ; orig
|
||||
mov dh,al ; preserve it for later.
|
||||
sub al,[targetgreen] ; al = (orig-target)
|
||||
imul dl ; ax = (orig-target)*fraction
|
||||
shl ax,1
|
||||
sub dh,ah ; dh = orig - ((orig-target) * fraction)
|
||||
mov [idealgreen],dh ; preserve ideal color gun value.
|
||||
|
||||
lodsb ; orig
|
||||
mov dh,al ; preserve it for later.
|
||||
sub al,[targetblue] ; al = (orig-target)
|
||||
imul dl ; ax = (orig-target)*fraction
|
||||
shl ax,1
|
||||
sub dh,ah ; dh = orig - ((orig-target) * fraction)
|
||||
mov [idealblue],dh ; preserve ideal color gun value.
|
||||
|
||||
; Sweep through the entire existing palette to find the closest
|
||||
; matching color. Never matches with color 0.
|
||||
|
||||
mov eax,[color]
|
||||
mov [matchcolor],al ; Default color (self).
|
||||
mov [matchvalue],-1 ; Ridiculous match value init.
|
||||
mov ecx,255
|
||||
|
||||
mov esi,[palette] ; Pointer to original palette.
|
||||
add esi,3
|
||||
|
||||
; BH = color index.
|
||||
mov bh,1
|
||||
??innerloop:
|
||||
|
||||
; Recursion through the fading table won't work if a color is allowed
|
||||
; to remap to itself. Prevent this from occuring.
|
||||
add esi,3
|
||||
cmp bh,bl
|
||||
je short ??notclose
|
||||
sub esi,3
|
||||
|
||||
xor edx,edx ; Comparison value starts null.
|
||||
mov eax,edx
|
||||
; Build the comparison value based on the sum of the differences of the color
|
||||
; guns squared.
|
||||
lodsb
|
||||
sub al,[idealred]
|
||||
mov ah,al
|
||||
imul ah
|
||||
add edx,eax
|
||||
|
||||
lodsb
|
||||
sub al,[idealgreen]
|
||||
mov ah,al
|
||||
imul ah
|
||||
add edx,eax
|
||||
|
||||
lodsb
|
||||
sub al,[idealblue]
|
||||
mov ah,al
|
||||
imul ah
|
||||
add edx,eax
|
||||
jz short ??perfect ; If perfect match found then quit early.
|
||||
|
||||
cmp edx,[matchvalue]
|
||||
ja short ??notclose
|
||||
mov [matchvalue],edx ; Record new possible color.
|
||||
mov [matchcolor],bh
|
||||
??notclose:
|
||||
inc bh ; Checking color index.
|
||||
loop ??innerloop
|
||||
mov bh,[matchcolor]
|
||||
??perfect:
|
||||
mov [matchcolor],bh
|
||||
xor bh,bh ; Make BX valid main index again.
|
||||
|
||||
; When the loop exits, we have found the closest match.
|
||||
mov al,[matchcolor]
|
||||
stosb
|
||||
cmp ebx,255
|
||||
jne ??mainloop
|
||||
|
||||
??fini:
|
||||
mov eax,[dest]
|
||||
ret
|
||||
|
||||
ENDP Build_Fading_Table
|
||||
|
||||
|
||||
END
|
90
WIN32LIB/MISC/FINDARGV.CPP
Normal file
90
WIN32LIB/MISC/FINDARGV.CPP
Normal file
|
@ -0,0 +1,90 @@
|
|||
/*
|
||||
** 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/wwlib32/misc/rcs/findargv.cpp 1.2 1994/04/22 10:29:28 scott_bowen 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 : findargv *
|
||||
* *
|
||||
* File Name : findargv.C *
|
||||
* *
|
||||
* Programmer : Jeff Wilson *
|
||||
* *
|
||||
* Start Date : January 14, 1993 *
|
||||
* *
|
||||
* Last Update : May 20, 1993 [PWG] *
|
||||
* *
|
||||
*-------------------------------------------------------------------------*
|
||||
* Functions: *
|
||||
* Find_Argv -- Checks to see if string is in arguement *
|
||||
* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
|
||||
|
||||
|
||||
#include "wwstd.h"
|
||||
#include <dos.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <process.h>
|
||||
|
||||
|
||||
|
||||
|
||||
/***************************************************************************
|
||||
* Find_Argv -- Checks to see if string is in arguement *
|
||||
* *
|
||||
* INPUT: char *str - string to search for. *
|
||||
* *
|
||||
* OUTPUT: NULL if not found else pointer to string. *
|
||||
* *
|
||||
* WARNINGS: *
|
||||
* *
|
||||
* HISTORY: *
|
||||
* 01/14/1993 SB : Created. *
|
||||
*=========================================================================*/
|
||||
|
||||
//static char command [ 256 ] ;
|
||||
#pragma on (argsused)
|
||||
char * __cdecl Find_Argv(char const)
|
||||
{
|
||||
return (NULL);
|
||||
|
||||
|
||||
#ifdef NOT_FOR_WIN95
|
||||
char * __cdecl Find_Argv(char const *str)
|
||||
{
|
||||
char * ptr ;
|
||||
static startup_flag = 0 ;
|
||||
|
||||
if ( ! startup_flag )
|
||||
{
|
||||
startup_flag = 1 ;
|
||||
getcmd ( command ) ;
|
||||
}
|
||||
|
||||
if ( ! strlen(str) ) return NULL ;
|
||||
return strstr ( command , str ) ;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
69
WIN32LIB/MISC/IRANDOM.CPP
Normal file
69
WIN32LIB/MISC/IRANDOM.CPP
Normal file
|
@ -0,0 +1,69 @@
|
|||
/*
|
||||
** 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 : LIBRARY *
|
||||
* *
|
||||
* File Name : IRANDOM.C *
|
||||
* *
|
||||
* Programmer : Barry W. Green *
|
||||
* *
|
||||
* Last Update : 10 Feb, 1995 [BWG] *
|
||||
* *
|
||||
*-------------------------------------------------------------------------*
|
||||
* Functions: *
|
||||
* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <time.h>
|
||||
#include "misc.h"
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/* IRANDOM ----------------------------------------------------------
|
||||
|
||||
IRandom returns a random value between min and max inclusive.
|
||||
|
||||
INPUTS: int min and int max
|
||||
|
||||
RETURNS: int random number
|
||||
*/
|
||||
|
||||
int IRandom(int minval, int maxval)
|
||||
{
|
||||
int num,mask;
|
||||
|
||||
// Keep minval and maxval straight.
|
||||
if (minval > maxval) {
|
||||
minval ^= maxval;
|
||||
maxval ^= minval;
|
||||
minval ^= maxval;
|
||||
}
|
||||
|
||||
mask = Get_Random_Mask(maxval - minval);
|
||||
|
||||
while( (num = (rand() & mask) + minval) > maxval ) ;
|
||||
return(num);
|
||||
}
|
||||
|
217
WIN32LIB/MISC/LIB.CPP
Normal file
217
WIN32LIB/MISC/LIB.CPP
Normal file
|
@ -0,0 +1,217 @@
|
|||
/*
|
||||
** 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/./lib.c 1.16 1994/05/20 15:34:33 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 Routines *
|
||||
* *
|
||||
* File Name : LIB.C *
|
||||
* *
|
||||
* Programmer : Scott Bowen *
|
||||
* *
|
||||
* Start Date : January 14, 1993 *
|
||||
* *
|
||||
* Last Update : May 20, 1993 [PWG] *
|
||||
* *
|
||||
*-------------------------------------------------------------------------*
|
||||
* Functions: *
|
||||
* Add_Long_To_Pointer -- Pointer arithmatic when pointer could be XMS. *
|
||||
* Find_Argv -- Checks to see if string is in arguement *
|
||||
* Mono_Mem_Dump -- Dumps memory to mono monitor with hex and char. *
|
||||
* Convert_HSV_To_RGB -- Converts HSV cordinates to RGB values *
|
||||
* Convert_RGB_To_HSV -- Converts RGB to RSV coordinates. *
|
||||
* Set_Search_Drives -- Sets up the CDRom and HardDrive paths. *
|
||||
* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
|
||||
|
||||
|
||||
#include <dos.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include "misc.h"
|
||||
|
||||
//PRIVATE unsigned Divide_With_Round(unsigned num, unsigned den);
|
||||
|
||||
|
||||
/***************************************************************************
|
||||
* Divide_With_Round -- Divides integers and round to nearest integer. *
|
||||
* *
|
||||
* INPUT: int numberator. *
|
||||
* int denominator. *
|
||||
* *
|
||||
* OUTPUT: Returns value rounded. *
|
||||
* *
|
||||
* WARNINGS: *
|
||||
* *
|
||||
* HISTORY: *
|
||||
* 02/13/1992 SB : Created. *
|
||||
*=========================================================================*/
|
||||
static unsigned Divide_With_Round(unsigned num, unsigned den)
|
||||
{
|
||||
// return num/den + (0 ro 1). 1 if the remainder is more than half the denominator.
|
||||
return( (num / den) + (unsigned)((num % den) >= ((den + 1) >> 1)) );
|
||||
}
|
||||
|
||||
#define HSV_BASE 255 // This is used to get a little better persion on HSV conversion.
|
||||
#define RGB_BASE 63 // Not 64, this is really the max value.
|
||||
|
||||
|
||||
/***************************************************************************
|
||||
* Convert_RGB_To_HSV -- Converts RGB to RSV coordinates. *
|
||||
* *
|
||||
* INPUT: int r,g, and b values. *
|
||||
* int *h, *s, and *v pointers. *
|
||||
* *
|
||||
* OUTPUT: Assigns values to *h, *s, and *v. *
|
||||
* *
|
||||
* WARNINGS: The reason we use a different base for HSV then RGB is *
|
||||
* because we loose alot of persision by not using floating *
|
||||
* point. Using the same base value (63) made it so that *
|
||||
* about 50% of the time one RGB value would be one different *
|
||||
* then the original if you went from RGB to HSV to RGB. *
|
||||
* Using 255 drop it down to about 9% of the time we get an *
|
||||
* off value. To get it perfect, we would have to make the *
|
||||
* HSV base larger - but then you need to do all calculations *
|
||||
* in long instead of unsigned int. *
|
||||
* HISTORY: *
|
||||
* 02/11/1992 SB : Created. *
|
||||
*=========================================================================*/
|
||||
void Convert_RGB_To_HSV(unsigned int r, unsigned int g, unsigned int b, unsigned int *h, unsigned int *s, unsigned int *v)
|
||||
{
|
||||
unsigned int m, r1, g1, b1, tmp;
|
||||
|
||||
// Convert RGB base to HSV base.
|
||||
r = Divide_With_Round((r * HSV_BASE), RGB_BASE);
|
||||
g = Divide_With_Round((g * HSV_BASE), RGB_BASE);
|
||||
b = Divide_With_Round((b * HSV_BASE), RGB_BASE);
|
||||
|
||||
// Set hue to default.
|
||||
*h = 0;
|
||||
|
||||
// Set v = Max(r,g,b) to find dominant primary color.
|
||||
*v = (r > g) ? r : g;
|
||||
if (b > *v) *v = b;
|
||||
|
||||
// Set m = min(r,g,b) to find amount of white.
|
||||
m = (r < g) ? r : g;
|
||||
if (b < m) m = b;
|
||||
|
||||
// Determine the normalized saturation.
|
||||
if (*v != 0) {
|
||||
*s = Divide_With_Round( (*v - m) * HSV_BASE ,*v);
|
||||
} else {
|
||||
*s = 0;
|
||||
}
|
||||
|
||||
if (*s != 0) {
|
||||
tmp = *v - m;
|
||||
r1 = Divide_With_Round( (*v - r) * HSV_BASE, tmp);
|
||||
g1 = Divide_With_Round( (*v - g) * HSV_BASE, tmp);
|
||||
b1 = Divide_With_Round( (*v - b) * HSV_BASE, tmp);
|
||||
|
||||
// Find effect of second most predominant color.
|
||||
// In which section of the hexagon of colors does the color lie?
|
||||
if ((*v) == r) {
|
||||
if (m == g) {
|
||||
*h = 5 * HSV_BASE + b1;
|
||||
} else {
|
||||
*h = 1 * HSV_BASE - g1;
|
||||
}
|
||||
} else {
|
||||
if ((*v) == g) {
|
||||
if (m == b) {
|
||||
*h = 1 * HSV_BASE + r1;
|
||||
} else {
|
||||
*h = 3 * HSV_BASE - b1;
|
||||
}
|
||||
} else {
|
||||
// *v == b
|
||||
if (m == r) {
|
||||
*h = 3 * HSV_BASE + g1;
|
||||
} else {
|
||||
|
||||
*h = 5 * HSV_BASE - r1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Divide by six and round.
|
||||
*h = Divide_With_Round(*h, 6);
|
||||
}
|
||||
}
|
||||
|
||||
/***************************************************************************
|
||||
* Convert_HSV_To_RGB -- Converts HSV cordinates to RGB values *
|
||||
* *
|
||||
* INPUT: int h,s, and v coordinates *
|
||||
* int *r, *g, and *b pointers. *
|
||||
* *
|
||||
* OUTPUT: Assigns values to *r, *g, and *b. *
|
||||
* *
|
||||
* WARNINGS: *
|
||||
* *
|
||||
* HISTORY: *
|
||||
* 02/11/1992 SB : Created. *
|
||||
*=========================================================================*/
|
||||
void Convert_HSV_To_RGB(unsigned int h, unsigned int s, unsigned int v, unsigned int *r, unsigned int *g, unsigned int *b)
|
||||
{
|
||||
unsigned int i; // Integer part.
|
||||
unsigned int f; // Fractional or remainder part. f/HSV_BASE gives fraction.
|
||||
unsigned int tmp; // Tempary variable to help with calculations.
|
||||
unsigned int values[7]; // Possible rgb values. Don't use zero.
|
||||
|
||||
|
||||
h *= 6;
|
||||
f = h % HSV_BASE;
|
||||
|
||||
// Set up possible red, green and blue values.
|
||||
values[1] =
|
||||
values[2] = v;
|
||||
|
||||
//
|
||||
// The following lines of code change
|
||||
// values[3] = (v * (HSV_BASE - ( (s * f) / HSV_BASE) )) / HSV_BASE;
|
||||
// values[4] = values[5] = (v * (HSV_BASE - s)) / HSV_BASE;
|
||||
// values[6] = (v * (HSV_BASE - (s * (HSV_BASE - f)) / HSV_BASE)) / HSV_BASE;
|
||||
// so that the are rounded divides.
|
||||
//
|
||||
|
||||
tmp = Divide_With_Round(s * f, HSV_BASE);
|
||||
values[3] = Divide_With_Round(v * (HSV_BASE - tmp), HSV_BASE);
|
||||
|
||||
values[4] =
|
||||
values[5] = Divide_With_Round(v * (HSV_BASE - s), HSV_BASE);
|
||||
|
||||
tmp = HSV_BASE - Divide_With_Round(s * (HSV_BASE - f), HSV_BASE);
|
||||
values[6] = Divide_With_Round(v * tmp, HSV_BASE);
|
||||
|
||||
|
||||
// This should not be rounded.
|
||||
i = h / HSV_BASE;
|
||||
|
||||
i += (i > 4) ? -4 : 2;
|
||||
*r = Divide_With_Round(values[i] * RGB_BASE, HSV_BASE);
|
||||
|
||||
i += (i > 4) ? -4 : 2;
|
||||
*b = Divide_With_Round(values[i] * RGB_BASE, HSV_BASE);
|
||||
|
||||
i += (i > 4) ? -4 : 2;
|
||||
*g = Divide_With_Round(values[i] * RGB_BASE, HSV_BASE);
|
||||
}
|
196
WIN32LIB/MISC/MAKEFILE
Normal file
196
WIN32LIB/MISC/MAKEFILE
Normal file
|
@ -0,0 +1,196 @@
|
|||
#
|
||||
# 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 %WATCOM
|
||||
!error WATCOM Environment var not configured.
|
||||
!endif
|
||||
|
||||
|
||||
#===========================================================================
|
||||
# User-defined section: the user should tailor this section for each project
|
||||
#===========================================================================
|
||||
|
||||
PROJ_NAME = misc
|
||||
PROJ_DIR = $(%WIN32LIB)\$(PROJ_NAME)
|
||||
LIB_DIR = $(%WIN32LIB)\lib
|
||||
|
||||
!include $(%WIN32LIB)\project.cfg
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
# Project-dependent variables
|
||||
#---------------------------------------------------------------------------
|
||||
OBJECTS = &
|
||||
crc.obj &
|
||||
ddraw.obj &
|
||||
delay.obj &
|
||||
detproc.obj &
|
||||
facing8.obj &
|
||||
facing16.obj &
|
||||
facingFF.obj &
|
||||
fading.obj &
|
||||
findargv.obj &
|
||||
irandom.obj &
|
||||
lib.obj &
|
||||
opsys.obj &
|
||||
random.obj &
|
||||
reverse.obj &
|
||||
shakescr.obj &
|
||||
cliprect.obj &
|
||||
exit.obj &
|
||||
version.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
|
||||
make
|
||||
cd ..
|
||||
|
||||
#**************************** End of makefile ******************************
|
||||
|
||||
|
205
WIN32LIB/MISC/MAKEFILE.BOR
Normal file
205
WIN32LIB/MISC/MAKEFILE.BOR
Normal file
|
@ -0,0 +1,205 @@
|
|||
#
|
||||
# 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 *
|
||||
#* *
|
||||
#***************************************************************************
|
||||
|
||||
.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 = misc
|
||||
PROJ_DIR = $(WIN32LIB)\$(PROJ_NAME)
|
||||
LIB_DIR = $(WIN32LIB)\lib
|
||||
|
||||
!include $(WIN32LIB)\\project.cfg
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
# Project-dependent variables
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
OBJECTS = \
|
||||
crc.obj \
|
||||
ddraw.obj \
|
||||
delay.obj \
|
||||
detproc.obj \
|
||||
facing8.obj \
|
||||
facing16.obj \
|
||||
facingFF.obj \
|
||||
fading.obj \
|
||||
findargv.obj \
|
||||
irandom.obj \
|
||||
lib.obj \
|
||||
opsys.obj \
|
||||
random.obj \
|
||||
reverse.obj \
|
||||
shakescr.obj \
|
||||
exit.obj \
|
||||
cliprect.obj \
|
||||
version.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) wwlib32.h
|
||||
copy *.h $(WIN32LIB)\\include
|
||||
copy *.inc $(WIN32LIB)\\include
|
||||
copy *.cpp $(WIN32LIB)\\srcdebug
|
||||
copy *.asm $(WIN32LIB)\\srcdebug
|
||||
$(LIB_CMD) $< $(LIB_CFG) @&&|
|
||||
+-crc.obj &
|
||||
+-ddraw.obj &
|
||||
+-delay.obj &
|
||||
+-detproc.obj &
|
||||
+-exit.obj &
|
||||
+-facing8.obj &
|
||||
+-facing16.obj &
|
||||
+-facingFF.obj &
|
||||
+-fading.obj &
|
||||
+-findargv.obj &
|
||||
+-irandom.obj &
|
||||
+-lib.obj &
|
||||
+-opsys.obj &
|
||||
+-random.obj &
|
||||
+-reverse.obj &
|
||||
+-shakescr.obj &
|
||||
+-cliprect.obj &
|
||||
+-version.obj
|
||||
|
|
||||
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
# Create the test directory and make it.
|
||||
#---------------------------------------------------------------------------
|
||||
test:
|
||||
mkdir test
|
||||
cd test
|
||||
copy $(WWVCS)\\$(PROJ_NAME)\test\vcs.cfg
|
||||
update
|
||||
wmake
|
||||
cd ..
|
||||
|
196
WIN32LIB/MISC/MAKEFILE.WAT
Normal file
196
WIN32LIB/MISC/MAKEFILE.WAT
Normal file
|
@ -0,0 +1,196 @@
|
|||
#
|
||||
# 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 %WATCOM
|
||||
!error WATCOM Environment var not configured.
|
||||
!endif
|
||||
|
||||
|
||||
#===========================================================================
|
||||
# User-defined section: the user should tailor this section for each project
|
||||
#===========================================================================
|
||||
|
||||
PROJ_NAME = misc
|
||||
PROJ_DIR = $(%WIN32LIB)\$(PROJ_NAME)
|
||||
LIB_DIR = $(%WIN32LIB)\lib
|
||||
|
||||
!include $(%WIN32LIB)\project.cfg
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
# Project-dependent variables
|
||||
#---------------------------------------------------------------------------
|
||||
OBJECTS = &
|
||||
crc.obj &
|
||||
ddraw.obj &
|
||||
delay.obj &
|
||||
detproc.obj &
|
||||
facing8.obj &
|
||||
facing16.obj &
|
||||
facingFF.obj &
|
||||
fading.obj &
|
||||
findargv.obj &
|
||||
irandom.obj &
|
||||
lib.obj &
|
||||
opsys.obj &
|
||||
random.obj &
|
||||
reverse.obj &
|
||||
shakescr.obj &
|
||||
cliprect.obj &
|
||||
exit.obj &
|
||||
version.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 = 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;$(%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) $<
|
||||
|
||||
.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
|
||||
make
|
||||
cd ..
|
||||
|
||||
#**************************** End of makefile ******************************
|
||||
|
||||
|
272
WIN32LIB/MISC/MISC.H
Normal file
272
WIN32LIB/MISC/MISC.H
Normal file
|
@ -0,0 +1,272 @@
|
|||
/*
|
||||
** 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 : 32 bit library *
|
||||
* *
|
||||
* File Name : MISC.H *
|
||||
* *
|
||||
* Programmer : Scott K. Bowen *
|
||||
* *
|
||||
* Start Date : August 3, 1994 *
|
||||
* *
|
||||
* Last Update : August 3, 1994 [SKB] *
|
||||
* *
|
||||
*-------------------------------------------------------------------------*
|
||||
* Functions: *
|
||||
* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
|
||||
|
||||
#ifndef MISC_H
|
||||
#define MISC_H
|
||||
|
||||
#define WIN32_LEAN_AND_MEAN // eliminates unecessary definitions in windows.h
|
||||
#ifndef _WIN32 // Denzil 6/2/98 Watcom 11.0 complains without this check
|
||||
#define _WIN32
|
||||
#endif // _WIN32
|
||||
#include <windows.h>
|
||||
#include <windowsx.h>
|
||||
#include <ddraw.h>
|
||||
|
||||
extern LPDIRECTDRAWSURFACE PaletteSurface;
|
||||
|
||||
/*========================= C++ Routines ==================================*/
|
||||
|
||||
|
||||
/*=========================================================================*/
|
||||
/* The following prototypes are for the file: DDRAW.CPP */
|
||||
/*=========================================================================*/
|
||||
void Process_DD_Result(HRESULT result, int display_ok_msg);
|
||||
BOOL Set_Video_Mode(HWND hwnd, int w, int h, int bits_per_pixel);
|
||||
void Reset_Video_Mode(void);
|
||||
unsigned Get_Free_Video_Memory(void);
|
||||
void Wait_Blit(void);
|
||||
unsigned Get_Video_Hardware_Capabilities(void);
|
||||
|
||||
extern "C" void Wait_Vert_Blank(void);
|
||||
extern "C" void Set_DD_Palette (void *palette);
|
||||
|
||||
/*
|
||||
** Pointer to function to call if we detect a focus loss
|
||||
*/
|
||||
extern void (*Misc_Focus_Loss_Function)(void);
|
||||
/*
|
||||
** Pointer to function to call if we detect a surface restore
|
||||
*/
|
||||
extern void (*Misc_Focus_Restore_Function)(void);
|
||||
|
||||
|
||||
/*
|
||||
* Flags returned by Get_Video_Hardware_Capabilities
|
||||
*/
|
||||
/* Hardware blits supported? */
|
||||
#define VIDEO_BLITTER 1
|
||||
|
||||
/* Hardware blits asyncronous? */
|
||||
#define VIDEO_BLITTER_ASYNC 2
|
||||
|
||||
/* Can palette changes be synced to vertical refresh? */
|
||||
#define VIDEO_SYNC_PALETTE 4
|
||||
|
||||
/* Is the video cards memory bank switched? */
|
||||
#define VIDEO_BANK_SWITCHED 8
|
||||
|
||||
/* Can the blitter do filled rectangles? */
|
||||
#define VIDEO_COLOR_FILL 16
|
||||
|
||||
/* Is there no hardware assistance avaailable at all? */
|
||||
#define VIDEO_NO_HARDWARE_ASSIST 32
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* Definition of surface monitor class
|
||||
*
|
||||
* This class keeps track of all the graphic buffers we generate in video memory so they
|
||||
* can be restored after a focus switch.
|
||||
*/
|
||||
|
||||
#define MAX_SURFACES 20
|
||||
|
||||
class SurfaceMonitorClass {
|
||||
|
||||
public:
|
||||
|
||||
SurfaceMonitorClass();
|
||||
|
||||
void Add_DD_Surface (LPDIRECTDRAWSURFACE);
|
||||
void Remove_DD_Surface (LPDIRECTDRAWSURFACE);
|
||||
BOOL Got_Surface_Already (LPDIRECTDRAWSURFACE);
|
||||
void Restore_Surfaces (void);
|
||||
void Set_Surface_Focus ( BOOL in_focus );
|
||||
void Release(void);
|
||||
|
||||
BOOL SurfacesRestored;
|
||||
|
||||
private:
|
||||
|
||||
LPDIRECTDRAWSURFACE Surface[MAX_SURFACES];
|
||||
BOOL InFocus;
|
||||
|
||||
};
|
||||
|
||||
extern SurfaceMonitorClass AllSurfaces; //List of all direct draw surfaces
|
||||
|
||||
|
||||
/*=========================================================================*/
|
||||
/* The following variables are declared in: DDRAW.CPP */
|
||||
/*=========================================================================*/
|
||||
extern LPDIRECTDRAW DirectDrawObject;
|
||||
extern LPDIRECTDRAW2 DirectDraw2Interface;
|
||||
extern HWND MainWindow;
|
||||
extern BOOL SystemToVideoBlits;
|
||||
extern BOOL VideoToSystemBlits;
|
||||
extern BOOL SystemToSystemBlits;
|
||||
extern BOOL OverlappedVideoBlits; // Can video driver blit overlapped regions?
|
||||
|
||||
/*=========================================================================*/
|
||||
/* The following prototypes are for the file: EXIT.CPP */
|
||||
/* Prog_End Must be supplied by the user program in startup.cpp */
|
||||
/*=========================================================================*/
|
||||
VOID __cdecl Prog_End(VOID);
|
||||
VOID __cdecl Exit(INT errorval, const BYTE *message, ...);
|
||||
|
||||
/*=========================================================================*/
|
||||
/* The following prototypes are for the file: DELAY.CPP */
|
||||
/*=========================================================================*/
|
||||
void Delay(int duration);
|
||||
void Vsync(void);
|
||||
|
||||
|
||||
/*=========================================================================*/
|
||||
/* The following prototypes are for the file: FINDARGV.CPP */
|
||||
/*=========================================================================*/
|
||||
|
||||
BYTE __cdecl Find_Argv(BYTE const *str);
|
||||
|
||||
/*=========================================================================*/
|
||||
/* The following prototypes are for the file: LIB.CPP */
|
||||
/*=========================================================================*/
|
||||
char *Find_Argv(char const *str);
|
||||
void Mono_Mem_Dump(void const *databuf, int bytes, int y);
|
||||
void Convert_RGB_To_HSV(unsigned int r, unsigned int g, unsigned int b, unsigned int *h, unsigned int *s, unsigned int *v);
|
||||
void Convert_HSV_To_RGB(unsigned int h, unsigned int s, unsigned int v, unsigned int *r, unsigned int *g, unsigned int *b);
|
||||
|
||||
|
||||
/*=========================================================================*/
|
||||
/* The following prototypes are for the file: VERSION.CPP */
|
||||
/*=========================================================================*/
|
||||
|
||||
BYTE __cdecl Version(VOID);
|
||||
|
||||
|
||||
/*=========================================================================*/
|
||||
/* The following prototypes are for the file: IRANDOM.CPP */
|
||||
/*=========================================================================*/
|
||||
int IRandom(int minval, int maxval);
|
||||
|
||||
|
||||
/*========================= Assembly Routines ==============================*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*=========================================================================*/
|
||||
/* The following prototypes are for the file: RANDOM.ASM */
|
||||
/*=========================================================================*/
|
||||
|
||||
unsigned char __cdecl Random(void);
|
||||
int __cdecl Get_Random_Mask(int maxval);
|
||||
|
||||
/*=========================================================================*/
|
||||
/* The following prototype is for the file: SHAKESCR.ASM */
|
||||
/*=========================================================================*/
|
||||
|
||||
void __cdecl Shake_Screen(int shakes);
|
||||
|
||||
/*=========================================================================*/
|
||||
/* The following prototypes are for the file: REVERSE.ASM */
|
||||
/*=========================================================================*/
|
||||
|
||||
long __cdecl Reverse_Long(long number);
|
||||
short __cdecl Reverse_Short(short number);
|
||||
long __cdecl Swap_Long(long number);
|
||||
#if (0)
|
||||
/*=========================================================================*/
|
||||
/* The following prototype is for the file: FACING8.ASM */
|
||||
/*=========================================================================*/
|
||||
|
||||
int __cdecl Desired_Facing8(int x1, int y1, int x2, int y2);
|
||||
|
||||
/*=========================================================================*/
|
||||
/* The following prototype is for the file: FACING16.ASM */
|
||||
/*=========================================================================*/
|
||||
|
||||
int __cdecl Desired_Facing16(int x1, int y1, int x2, int y2);
|
||||
|
||||
/*=========================================================================*/
|
||||
/* The following prototype is for the file: FACINGFF.ASM */
|
||||
/*=========================================================================*/
|
||||
|
||||
int __cdecl Desired_Facing256(int x1, int y1, int x2, int y2);
|
||||
|
||||
/*=========================================================================*/
|
||||
/* The following prototype is for the file: FADING.ASM */
|
||||
/*=========================================================================*/
|
||||
#endif
|
||||
|
||||
void * __cdecl Build_Fading_Table(void const *palette, void const *dest, long int color, long int frac);
|
||||
/*=========================================================================*/
|
||||
/* The following prototype is for the file: CRC.ASM */
|
||||
/*=========================================================================*/
|
||||
|
||||
long __cdecl Calculate_CRC(void *buffer, long length);
|
||||
|
||||
/*=========================================================================*/
|
||||
/* The following prototypes are for the file: DETPROC.ASM */
|
||||
/*=========================================================================*/
|
||||
|
||||
extern WORD __cdecl Processor(void);
|
||||
extern WORD __cdecl Operating_System(void);
|
||||
extern unsigned long random ( unsigned long mod ) ;
|
||||
//extern void randomize ( void ) ;
|
||||
|
||||
extern int __cdecl Clip_Rect ( int * x , int * y , int * dw , int * dh ,
|
||||
int width , int height ) ;
|
||||
extern int __cdecl Confine_Rect ( int * x , int * y , int dw , int dh ,
|
||||
int width , int height ) ;
|
||||
|
||||
|
||||
|
||||
/*=========================================================================*/
|
||||
/* The following prototypes are for the file: OPSYS.ASM */
|
||||
/*=========================================================================*/
|
||||
|
||||
extern WORD OperationgSystem;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
/*=========================================================================*/
|
||||
|
||||
#endif // MISC_H
|
||||
|
150
WIN32LIB/MISC/OPSYS.ASM
Normal file
150
WIN32LIB/MISC/OPSYS.ASM
Normal file
|
@ -0,0 +1,150 @@
|
|||
;
|
||||
; 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/wwlib32/system/rcs/opsys.asm 1.1 1994/04/18 09:14:12 jeff_wilson 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 : Operating System Flags *
|
||||
;* *
|
||||
;* File Name : OPSYS.ASM *
|
||||
;* *
|
||||
;* Programmer : Scott Bowen *
|
||||
;* *
|
||||
;* Start Date : January 26, 1993 *
|
||||
;* *
|
||||
;* Last Update : January 26, 1993 [SB] *
|
||||
;* *
|
||||
;* Updated to 32bit protected mode JAW *
|
||||
;* *
|
||||
;*-------------------------------------------------------------------------*
|
||||
;* Functions: *
|
||||
;* Operating_System -- Determines what the operating system is. *
|
||||
;* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - *
|
||||
|
||||
|
||||
IDEAL
|
||||
P386
|
||||
MODEL USE32 FLAT
|
||||
|
||||
GLOBAL C Operating_System :NEAR
|
||||
GLOBAL C OperatingSystem :WORD
|
||||
|
||||
DOS equ 1
|
||||
WIN31STD equ 2
|
||||
WIN31ENH equ 3
|
||||
WIN30ENH equ 4
|
||||
WIN30STD equ 5
|
||||
WIN30REAL equ 6
|
||||
|
||||
DATASEG
|
||||
|
||||
OperatingSystem dw 0
|
||||
|
||||
|
||||
CODESEG
|
||||
|
||||
;***************************************************************************
|
||||
;* Operating_System -- Determines what the operating system is. *
|
||||
;* *
|
||||
;* INPUT: NONE. *
|
||||
;* *
|
||||
;* OUTPUT: *
|
||||
;* *
|
||||
;* WARNINGS: *
|
||||
;* *
|
||||
;* HISTORY: *
|
||||
;* 01/26/1993 SB : Created. *
|
||||
;*=========================================================================*
|
||||
PROC Operating_System C near
|
||||
USES ebx,ecx,edx,es,edi
|
||||
|
||||
|
||||
; Check for Windows 3.1
|
||||
mov eax,160Ah ; WIN31CHECK
|
||||
int 2fh
|
||||
or ax,ax
|
||||
jz short RunningUnderWin31
|
||||
|
||||
;check for Windows 3.0 enhanced mode
|
||||
mov eax,1600h ; WIN386CHECK
|
||||
int 2fh
|
||||
mov bl,al
|
||||
mov eax,WIN30ENH
|
||||
test bl,7fh
|
||||
jnz short Exit
|
||||
|
||||
;check for 3.0 WINOLDAP
|
||||
mov eax,4680h ; IS_WINOLDAP_ACTIVE
|
||||
int 2fh
|
||||
or eax,eax
|
||||
jnz short NotRunningUnderWin
|
||||
|
||||
; rule out MS-DOS 5.0 task switcher
|
||||
mov eax,4b02h ; detect switcher
|
||||
push ebx
|
||||
push es
|
||||
push edi
|
||||
xor ebx,ebx
|
||||
mov edi,ebx
|
||||
mov es,bx
|
||||
int 2fh
|
||||
pop edi
|
||||
pop es
|
||||
pop ebx
|
||||
or eax,eax
|
||||
jz short NotRunningUnderWin ; MS-DOS 5.0 task switcher found.
|
||||
|
||||
; check for standrd mode Windows 3.0
|
||||
mov eax,1605h ;PMODE_START
|
||||
int 2fh
|
||||
mov eax,WIN30STD
|
||||
cmp ecx,-1
|
||||
jz short Exit
|
||||
|
||||
;check for real mode Windows 3.0
|
||||
mov eax,1606h ; PMODE_STOP
|
||||
int 2fh
|
||||
mov eax,WIN30REAL
|
||||
jmp SHORT Exit
|
||||
|
||||
RunningUnderWin31:
|
||||
; At this point: CX == 3 means Windows 3.1 enhanced mode.
|
||||
; CX == 2 means Windows 3.1 standard mode.
|
||||
mov eax,WIN31STD
|
||||
cmp ecx,2
|
||||
je short Exit
|
||||
|
||||
mov eax,WIN31ENH
|
||||
jmp SHORT Exit
|
||||
|
||||
NotRunningUnderWin:
|
||||
mov eax,DOS
|
||||
|
||||
Exit:
|
||||
mov [WORD PTR OperatingSystem], ax
|
||||
ret
|
||||
|
||||
ENDP Operating_System
|
||||
|
||||
|
||||
|
||||
;----------------------------------------------------------------------------
|
||||
|
||||
END
|
118
WIN32LIB/MISC/RANDOM.ASM
Normal file
118
WIN32LIB/MISC/RANDOM.ASM
Normal file
|
@ -0,0 +1,118 @@
|
|||
;
|
||||
; 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 : Library routine *
|
||||
;* *
|
||||
;* File Name : RANDOM.ASM *
|
||||
;* *
|
||||
;* Programmer : Christopher Yates *
|
||||
;* *
|
||||
;* Last Update : 20 August, 1990 [CY] *
|
||||
;* *
|
||||
;*-------------------------------------------------------------------------*
|
||||
;* Functions: *
|
||||
;* *
|
||||
;* UBYTE Random(VOID); *
|
||||
;* *
|
||||
;* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - *
|
||||
|
||||
IDEAL
|
||||
P386
|
||||
MODEL USE32 FLAT
|
||||
|
||||
Global C Random :NEAR
|
||||
Global C Get_Random_Mask :NEAR
|
||||
Global C RandNumb :DWORD
|
||||
|
||||
DATASEG
|
||||
|
||||
RandNumb DD 12349876H
|
||||
|
||||
CODESEG
|
||||
|
||||
; ----------------------------------------------------------------
|
||||
;
|
||||
; Here are prototypes for the routines defined within this module:
|
||||
;
|
||||
; UBYTE Random(VOID);
|
||||
; int Get_Random_Mask(int maxval);
|
||||
;
|
||||
; ----------------------------------------------------------------
|
||||
|
||||
;-----------------------------------------------------------------
|
||||
; RANDOM
|
||||
;
|
||||
; UBYTE Random(VOID);
|
||||
;
|
||||
;*
|
||||
|
||||
PROC Random C near
|
||||
USES esi
|
||||
|
||||
lea esi, [RandNumb] ; get offset in segment of RandNumb
|
||||
xor eax,eax
|
||||
mov al,[esi]
|
||||
shr al,1 ; shift right 1 bit (bit0 in carry)
|
||||
shr al,1
|
||||
rcl [BYTE PTR esi+2],1 ; rcl byte 3 of RandNumb
|
||||
rcl [BYTE PTR esi+1],1 ; rcl byte 2 of RandNumb
|
||||
cmc ; complement carry
|
||||
sbb al,[esi] ; sbb byte 1 of RandNumb
|
||||
shr al,1 ; sets carry
|
||||
rcr [BYTE PTR esi],1 ; rcr byte 1 of RandNumb
|
||||
mov al,[esi] ; reload byte 1 of RandNumb
|
||||
xor al,[esi+1] ; xor with byte 2 of RandNumb
|
||||
|
||||
ret
|
||||
|
||||
ENDP Random
|
||||
|
||||
|
||||
;-----------------------------------------------------------------
|
||||
; GET_RANDOM_MASK - returns an AND value that is large enough that it
|
||||
; encloses the 'maxval' parameter.
|
||||
;
|
||||
; int Get_Random_Mask(int maxval);
|
||||
;
|
||||
;*
|
||||
|
||||
PROC Get_Random_Mask C near
|
||||
USES ecx
|
||||
ARG maxval:DWORD
|
||||
|
||||
; This function takes as a parameter a maximum value, for example, 61. It
|
||||
; then tries to create an AND mask that is big enough to enclose that number.
|
||||
; For our example case, that AND mask would be 0x3F. It does this by scanning
|
||||
; for the highest bit in the number, then making an all-1's mask from that
|
||||
; bit position down to bit 0.
|
||||
bsr ecx,[maxval] ; put bit position of highest bit in ecx
|
||||
mov eax,1 ; set one bit on in eax
|
||||
jz ??invalid ; if BSR shows maxval==0, return eax=1
|
||||
inc ecx ; get one bit higher than count showed
|
||||
shl eax,cl ; move our EAX bit into position
|
||||
dec eax ; dec it to create the mask.
|
||||
??invalid:
|
||||
ret
|
||||
ENDP Get_Random_Mask
|
||||
;----------------------------------------------------------------------------
|
||||
|
||||
END
|
139
WIN32LIB/MISC/REVERSE.ASM
Normal file
139
WIN32LIB/MISC/REVERSE.ASM
Normal file
|
@ -0,0 +1,139 @@
|
|||
;
|
||||
; 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/wwlib32/misc/rcs/reverse.asm 1.3 1994/04/25 12:22:45 scott_bowen 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 : REVERSE.ASM *
|
||||
;* *
|
||||
;* Programmer : Christopher Yates *
|
||||
;* *
|
||||
;* Last Update : April 20, 1994 [SKB] *
|
||||
;* *
|
||||
;*-------------------------------------------------------------------------*
|
||||
;* Functions: *
|
||||
;* *
|
||||
; LONG Reverse_Long(LONG number); *
|
||||
; WORD Reverse_Short(WORD number); *
|
||||
; LONG Swap_LONG(LONG number);
|
||||
;* *
|
||||
;* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - *
|
||||
|
||||
IDEAL
|
||||
P386
|
||||
MODEL USE32 FLAT
|
||||
|
||||
GLOBAL C Reverse_Short :NEAR
|
||||
GLOBAL C Swap_Long :NEAR
|
||||
GLOBAL C Reverse_Long :NEAR
|
||||
|
||||
CODESEG
|
||||
|
||||
|
||||
; ----------------------------------------------------------------
|
||||
;
|
||||
; Here are prototypes for the routines defined within this module:
|
||||
;
|
||||
; LONG Reverse_LONG(LONG number);
|
||||
; WORD Reverse_Short(WORD number);
|
||||
; LONG Swap_LONG(LONG number);
|
||||
;
|
||||
; ----------------------------------------------------------------
|
||||
|
||||
;-----------------------------------------------------------------
|
||||
;
|
||||
; REVERSE_LONG
|
||||
;
|
||||
; LONG Reverse_LONG(LONG number);
|
||||
;
|
||||
;*
|
||||
PROC Reverse_Long C near
|
||||
ARG number:DWORD
|
||||
|
||||
IF 1
|
||||
mov eax,[DWORD PTR number]
|
||||
xchg al,ah
|
||||
ror eax,16
|
||||
xchg al,ah
|
||||
ELSE
|
||||
|
||||
; This is old 16 bit code.
|
||||
mov ax,[WORD PTR number]
|
||||
mov dx,[WORD PTR number+2]
|
||||
xchg ah,dl
|
||||
xchg al,dh
|
||||
ENDIF
|
||||
|
||||
ret
|
||||
|
||||
ENDP Reverse_Long
|
||||
|
||||
;-----------------------------------------------------------------
|
||||
|
||||
;-----------------------------------------------------------------
|
||||
;
|
||||
; REVERSE_WORD
|
||||
;
|
||||
; WORD Reverse_Short(WORD number);
|
||||
;
|
||||
;*
|
||||
PROC Reverse_Short C near
|
||||
ARG number:WORD
|
||||
|
||||
mov ax,[number]
|
||||
xchg ah,al
|
||||
ret
|
||||
|
||||
ENDP Reverse_Short
|
||||
|
||||
;-----------------------------------------------------------------
|
||||
|
||||
|
||||
;-----------------------------------------------------------------
|
||||
;
|
||||
; SWAP_Long
|
||||
;
|
||||
; Long Swap_Long(Long number);
|
||||
;
|
||||
;*
|
||||
PROC Swap_Long C near
|
||||
ARG number:DWORD
|
||||
|
||||
IF 1
|
||||
; 32 bit code.
|
||||
mov eax,[DWORD PTR number]
|
||||
ror eax,16
|
||||
ELSE
|
||||
; 16 bit code.
|
||||
mov ax,[WORD PTR number+2]
|
||||
mov dx,[WORD PTR number]
|
||||
ENDIF
|
||||
|
||||
ret
|
||||
|
||||
|
||||
ENDP Swap_Long
|
||||
|
||||
;-----------------------------------------------------------------
|
||||
|
||||
END
|
||||
|
158
WIN32LIB/MISC/SHAKESCR.ASM
Normal file
158
WIN32LIB/MISC/SHAKESCR.ASM
Normal file
|
@ -0,0 +1,158 @@
|
|||
;
|
||||
; 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 : SHAKESCR.ASM *
|
||||
;* *
|
||||
;* Programmer : Joe L. Bostic *
|
||||
;* *
|
||||
;* Start Date : August 19, 1993 *
|
||||
;* *
|
||||
;* Last Update : February 10, 1995 [BWG] *
|
||||
;* *
|
||||
;*-------------------------------------------------------------------------*
|
||||
;* Functions: *
|
||||
;* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - *
|
||||
|
||||
IDEAL
|
||||
P386
|
||||
MODEL USE32 FLAT
|
||||
|
||||
GLOBAL C Shake_Screen :NEAR
|
||||
|
||||
CODESEG
|
||||
|
||||
;***********************************************************
|
||||
; SHAKE_SCREEN
|
||||
;
|
||||
; VOID Shake_Screen(int shakes);
|
||||
;
|
||||
; This routine shakes the screen the number of times indicated.
|
||||
;
|
||||
; Bounds Checking: None
|
||||
;
|
||||
;*
|
||||
PROC Shake_Screen C near
|
||||
USES ecx, edx
|
||||
|
||||
ARG shakes:DWORD
|
||||
ret
|
||||
|
||||
mov ecx,[shakes]
|
||||
|
||||
;;; push es
|
||||
;;; mov ax,40h
|
||||
;;; mov es,ax
|
||||
;;; mov dx,[es:63h]
|
||||
;;; pop es
|
||||
mov eax,[0463h] ; get CRTC I/O port
|
||||
mov dx,ax
|
||||
add dl,6 ; video status port
|
||||
|
||||
??top_loop:
|
||||
|
||||
??start_retrace:
|
||||
in al,dx
|
||||
test al,8
|
||||
jz ??start_retrace
|
||||
|
||||
??end_retrace:
|
||||
in al,dx
|
||||
test al,8
|
||||
jnz ??end_retrace
|
||||
|
||||
cli
|
||||
sub dl,6 ; dx = 3B4H or 3D4H
|
||||
|
||||
mov ah,01 ; top word of start address
|
||||
mov al,0Ch
|
||||
out dx,al
|
||||
xchg ah,al
|
||||
inc dx
|
||||
out dx,al
|
||||
xchg ah,al
|
||||
dec dx
|
||||
|
||||
mov ah,040h ; bottom word = 40 (140h)
|
||||
inc al
|
||||
out dx,al
|
||||
xchg ah,al
|
||||
inc dx
|
||||
out dx,al
|
||||
xchg ah,al
|
||||
|
||||
sti
|
||||
add dl,5
|
||||
|
||||
??start_retrace2:
|
||||
in al,dx
|
||||
test al,8
|
||||
jz ??start_retrace2
|
||||
|
||||
??end_retrace2:
|
||||
in al,dx
|
||||
test al,8
|
||||
jnz ??end_retrace2
|
||||
|
||||
??start_retrace3:
|
||||
in al,dx
|
||||
test al,8
|
||||
jz ??start_retrace3
|
||||
|
||||
??end_retrace3:
|
||||
in al,dx
|
||||
test al,8
|
||||
jnz ??end_retrace3
|
||||
|
||||
cli
|
||||
sub dl,6 ; dx = 3B4H or 3D4H
|
||||
|
||||
mov ah,0
|
||||
mov al,0Ch
|
||||
out dx,al
|
||||
xchg ah,al
|
||||
inc dx
|
||||
out dx,al
|
||||
xchg ah,al
|
||||
dec dx
|
||||
|
||||
mov ah,0
|
||||
inc al
|
||||
out dx,al
|
||||
xchg ah,al
|
||||
inc dx
|
||||
out dx,al
|
||||
xchg ah,al
|
||||
|
||||
sti
|
||||
add dl,5
|
||||
|
||||
loop ??top_loop
|
||||
|
||||
ret
|
||||
|
||||
ENDP Shake_Screen
|
||||
|
||||
;***********************************************************
|
||||
|
||||
END
|
62
WIN32LIB/MISC/VERSION.CPP
Normal file
62
WIN32LIB/MISC/VERSION.CPP
Normal file
|
@ -0,0 +1,62 @@
|
|||
/*
|
||||
** 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 : LIBRARY *
|
||||
* *
|
||||
* File Name : VERSION.C *
|
||||
* *
|
||||
* Programmer : Christopher Yates *
|
||||
* *
|
||||
* Last Update : July 26, 1991 [JLB] *
|
||||
* *
|
||||
*-------------------------------------------------------------------------*
|
||||
* Functions: *
|
||||
* Version -- Returns with current library version text. *
|
||||
* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
|
||||
|
||||
#include "wwstd.h"
|
||||
|
||||
|
||||
|
||||
PRIVATE char *version = "Westwood Studios - 32 Bit Library Version "
|
||||
__DATE__
|
||||
"\r\n";
|
||||
|
||||
/***************************************************************************
|
||||
* VERSION -- Returns with current library version text. *
|
||||
* *
|
||||
* Use this routine to determine the current library version. The *
|
||||
* version text contains the date that it was created. *
|
||||
* *
|
||||
* INPUT: none *
|
||||
* *
|
||||
* OUTPUT: Returns pointer to version text. *
|
||||
* *
|
||||
* WARNINGS: none *
|
||||
* *
|
||||
* HISTORY: *
|
||||
* 07/26/1991 JLB : Created. *
|
||||
*=========================================================================*/
|
||||
char * __cdecl Version(void)
|
||||
{
|
||||
return(version);
|
||||
}
|
68
WIN32LIB/MISC/WWLIB32.H
Normal file
68
WIN32LIB/MISC/WWLIB32.H
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 S T U D I O S **
|
||||
***************************************************************************
|
||||
* *
|
||||
* Project Name : WWLIB32 User include file *
|
||||
* *
|
||||
* File Name : WWLIB32.H *
|
||||
* *
|
||||
* Programmer : Scott K. Bowen *
|
||||
* *
|
||||
* Start Date : August 3, 1994 *
|
||||
* *
|
||||
* Last Update : August 3, 1994 [SKB] *
|
||||
* *
|
||||
*-------------------------------------------------------------------------*
|
||||
* Functions: *
|
||||
* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
|
||||
#ifndef WWLIB32_H
|
||||
#define WWLIB32_H
|
||||
|
||||
#include <gbuffer.h>
|
||||
#include <wwstd.h>
|
||||
#include <drawbuff.h>
|
||||
#include <buffer.h>
|
||||
#include <font.h>
|
||||
#include <iff.h>
|
||||
#include <misc.h>
|
||||
#include <mono.h>
|
||||
#include <tile.h>
|
||||
#include <wwmem.h>
|
||||
#include <keyboard.h>
|
||||
#include <mouse.h>
|
||||
#include <file.h>
|
||||
#include <rawfile.h>
|
||||
|
||||
#include <audio.h>
|
||||
#include <dipthong.h>
|
||||
#include <palette.h>
|
||||
#include <playcd.h>
|
||||
#include <shape.h>
|
||||
#include <timer.h>
|
||||
#include <ww_win.h>
|
||||
#include <wsa.h>
|
||||
#include <profile.h>
|
||||
|
||||
|
||||
|
||||
#endif // WWLIB32_H
|
||||
|
||||
|
338
WIN32LIB/MISC/WWSTD.H
Normal file
338
WIN32LIB/MISC/WWSTD.H
Normal file
|
@ -0,0 +1,338 @@
|
|||
/*
|
||||
** 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 : wwstd.h *
|
||||
* *
|
||||
* File Name : WWLIB.H *
|
||||
* *
|
||||
* Programmer : Jeff Wilson *
|
||||
* *
|
||||
* Start Date : March 1, 1994 *
|
||||
* *
|
||||
* Last Update : March 1, 1994 [] *
|
||||
* *
|
||||
*-------------------------------------------------------------------------*
|
||||
* Functions: *
|
||||
* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
|
||||
|
||||
#ifndef WWSTD_H
|
||||
#define WWSTD_H
|
||||
|
||||
|
||||
//
|
||||
// Win 95 includes
|
||||
//
|
||||
|
||||
#ifndef WIN32
|
||||
#ifndef _WIN32 // Denzil 6/2/98 Watcom 11.0 complains without this check
|
||||
#define _WIN32
|
||||
#endif // _WIN32
|
||||
#define WIN32 1
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
#include <windows.h>
|
||||
#include <windowsx.h>
|
||||
#endif
|
||||
|
||||
|
||||
// Note: SKB 4/11/94
|
||||
// Before this library is done, this needs to be able to be set to TRUE.
|
||||
// Once it is, the FALSE parts should be removed from the source code.
|
||||
#define LIB_EXTERNS_RESOLVED FALSE
|
||||
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <dos.h>
|
||||
#include <bios.h>
|
||||
|
||||
//================================
|
||||
|
||||
// TRUE and FALSE are defined in pltypes.h
|
||||
|
||||
#ifndef IBM
|
||||
#define IBM TRUE
|
||||
#endif
|
||||
|
||||
#ifndef AMIGA
|
||||
#define AMIGA FALSE
|
||||
#endif
|
||||
|
||||
#ifndef SEGA
|
||||
#define SEGA FALSE
|
||||
#endif
|
||||
|
||||
/*
|
||||
** Common constants used in normal code.
|
||||
*/
|
||||
#define WW_ERROR -1
|
||||
|
||||
#ifdef NULL
|
||||
#undef NULL
|
||||
#endif
|
||||
|
||||
#ifndef NULL
|
||||
#define NULL 0L
|
||||
#endif
|
||||
|
||||
#ifdef VOID
|
||||
#undef VOID
|
||||
#endif
|
||||
|
||||
#define PRIVATE static
|
||||
#define PUBLIC /* Routines & data don't have a specifier */
|
||||
|
||||
#ifdef __cplusplus
|
||||
#define __CPPARGS ...
|
||||
#else
|
||||
#define __CPPARGS
|
||||
#endif
|
||||
|
||||
// This macro will get the size (in elements) of the specified array.
|
||||
#ifdef GET_SIZE
|
||||
#undef GET_SIZE
|
||||
#endif
|
||||
#define GET_SIZE(a) ((sizeof(a) / sizeof(*a)))
|
||||
|
||||
#pragma option -Jg
|
||||
// Returns the absolute value of the number.
|
||||
#ifdef ABS
|
||||
#undef ABS
|
||||
#endif
|
||||
template<class T> T ABS(T a)
|
||||
{
|
||||
return (a < 0) ? -a : a;
|
||||
}
|
||||
int ABS(int);
|
||||
long ABS(long);
|
||||
|
||||
// Returns the minimum of the two numbers.
|
||||
#ifdef MIN
|
||||
#undef MIN
|
||||
#endif
|
||||
template<class T> T MIN(T a, T b)
|
||||
{
|
||||
return (b < a) ? b : a;
|
||||
};
|
||||
short MIN(short, short);
|
||||
int MIN(int, int);
|
||||
long MIN(long, long);
|
||||
|
||||
// Returns the maximum of the two numbers.
|
||||
#ifdef MAX
|
||||
#undef MAX
|
||||
#endif
|
||||
template<class T> T MAX(T a, T b)
|
||||
{
|
||||
return (b > a) ? b : a;
|
||||
};
|
||||
short MAX(short, short);
|
||||
int MAX(int, int);
|
||||
long MAX(long, long);
|
||||
#pragma option -Jgd
|
||||
|
||||
// Returns the low word of a long
|
||||
#define LOW_WORD(a) ((unsigned short)((long)(a) & 0x0000FFFFL))
|
||||
|
||||
// Returns the high word of a long
|
||||
#define HIGH_WORD(a) ((unsigned long)(a) >> 16)
|
||||
|
||||
// Merges to shorts to become a long
|
||||
#define MAKE_LONG(a,b) (((long)(a) << 16) | (long)((b)&0x0000FFFFL))
|
||||
|
||||
/*
|
||||
** Macro allows our routines to act like
|
||||
** sprintf etc..
|
||||
*/
|
||||
#ifdef AssembleTo
|
||||
#undef AssembleTo
|
||||
#endif
|
||||
|
||||
#define AssembleTo(dest,fmt)\
|
||||
{\
|
||||
va_list argptr;\
|
||||
if (fmt != (dest))\
|
||||
{\
|
||||
va_start (argptr, fmt);\
|
||||
vsprintf ((dest), fmt, argptr);\
|
||||
va_end (argptr);\
|
||||
}\
|
||||
}
|
||||
|
||||
// type definitions
|
||||
//=======================================
|
||||
typedef void VOID;
|
||||
|
||||
//==================================================
|
||||
// Pharlape defines these for use so we use their
|
||||
// typedefs!
|
||||
// typedef unsigned char BOOL;
|
||||
// typedef signed long LONG;
|
||||
// typedef unsigned long ULONG;
|
||||
//==================================================
|
||||
#ifndef PRIVATE
|
||||
#define PRIVATE static
|
||||
#endif
|
||||
|
||||
// The purpose of the INT and UINT is for efficiency. It says that while a short int (16 bit)
|
||||
// has enough precision, it is more efficient to pass in an int (32 bits). For efficiency, most
|
||||
// WORD and UWORD should be an INT or UINT, especially on the stack and structures that will
|
||||
// not be in large arrays. When size efficiency is more important then speed, use WORD UWORD.
|
||||
|
||||
#define VOID void
|
||||
|
||||
#pragma warn -eas
|
||||
#define TRUE 1
|
||||
#define FALSE 0
|
||||
|
||||
/*
|
||||
** The "bool" integral type was defined by the C++ comittee in
|
||||
** November of '94. Until the compiler supports this, use the following
|
||||
** definition.
|
||||
*/
|
||||
#ifndef __BORLANDC__
|
||||
#ifndef TRUE_FALSE_DEFINED
|
||||
#define TRUE_FALSE_DEFINED
|
||||
enum {false=0,true=1};
|
||||
typedef int bool;
|
||||
#endif
|
||||
#endif
|
||||
//#define true 1
|
||||
//#define false 0
|
||||
|
||||
#define BOOL int // 32 bits for speed. use CHAR for size optimizations.
|
||||
#if(0)
|
||||
#ifndef HMI_DRIVER
|
||||
#define INT int
|
||||
#define UINT unsigned int
|
||||
#define BYTE char
|
||||
#define UBYTE unsigned char
|
||||
#define UCHAR unsigned char
|
||||
#define WORD signed short
|
||||
#define UWORD unsigned short
|
||||
#define USHORT unsigned short
|
||||
|
||||
#define LONG signed long
|
||||
#define ULONG unsigned long
|
||||
#define REALPTR unsigned long
|
||||
|
||||
#define FARPTR char far *
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/*
|
||||
** The type of processor running on this system as
|
||||
** returned by Processor().
|
||||
*/
|
||||
#define PROC_80386 0
|
||||
#define PROC_80486 1
|
||||
#define PROC_PENTIUM 2
|
||||
|
||||
|
||||
// Inline Routines
|
||||
//ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ
|
||||
//
|
||||
// These Template functions are generally used
|
||||
// by classes when they havce over loaded > and <.
|
||||
//
|
||||
#ifdef __cplusplus
|
||||
template<class T> T Min(T a, T b)
|
||||
{
|
||||
return (a<b ? a : b);
|
||||
}
|
||||
|
||||
template<class T> inline T Max(T a, T b)
|
||||
{
|
||||
return (a>b ? a : b);
|
||||
}
|
||||
|
||||
template<class T> T Abs(T a)
|
||||
{
|
||||
return ((a<0) ? -(a) : a);
|
||||
}
|
||||
|
||||
template<class T> VOID minimize(T &a, T b)
|
||||
{
|
||||
if( b<a )
|
||||
a=b;
|
||||
}
|
||||
|
||||
template<class T> VOID maximize(T &a, T b)
|
||||
{
|
||||
if( b>a )
|
||||
a=b;
|
||||
}
|
||||
#endif
|
||||
|
||||
/*
|
||||
** Macros that control bit settings in a variable.
|
||||
*/
|
||||
#define Bit_Flags_On(a,b) a |= (b)
|
||||
#define Bit_Flags_Off(a,b) a &= (~(b))
|
||||
#define Bit_Flags_Value(a,b) (a & (b))
|
||||
#define Bit_Flags_Flip(a,b) a ^= (b)
|
||||
|
||||
// Template replacements for the user defines above
|
||||
#ifdef __cplusplus
|
||||
template<class T> VOID BitFlagsOn(T &a, T b)
|
||||
{
|
||||
a |= (b);
|
||||
}
|
||||
|
||||
template<class T> VOID BitFlagsOff(T &a, T b)
|
||||
{
|
||||
a &= (~(b));
|
||||
}
|
||||
|
||||
template<class T> T BitFlagsValue(T a, T b)
|
||||
{
|
||||
return (a & (b));
|
||||
}
|
||||
|
||||
template<class T> VOID BitFlagsFlip(T &a, T b)
|
||||
{
|
||||
a ^= (b);
|
||||
}
|
||||
#endif
|
||||
|
||||
typedef enum {
|
||||
TBLACK,
|
||||
PURPLE,
|
||||
CYAN,
|
||||
GREEN,
|
||||
LTGREEN,
|
||||
YELLOW,
|
||||
PINK,
|
||||
BROWN,
|
||||
RED,
|
||||
LTCYAN,
|
||||
LTBLUE,
|
||||
BLUE,
|
||||
BLACK,
|
||||
GREY,
|
||||
LTGREY,
|
||||
WHITE,
|
||||
COLOR_PADDING=0x1000
|
||||
} ColorType;
|
||||
|
||||
|
||||
#endif
|
Reference in a new issue