Initial commit of Command & Conquer Red Alert source code.

This commit is contained in:
LFeenanEA
2025-02-27 16:15:05 +00:00
parent b685cea758
commit 5e733d5dcc
2082 changed files with 797727 additions and 0 deletions

1128
WWFLAT32/SHAPE/DRAWSHP.ASM Normal file

File diff suppressed because it is too large Load Diff

257
WWFLAT32/SHAPE/DS_DN.ASM Normal file
View File

@@ -0,0 +1,257 @@
;
; 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 : Draw Shape Routines for library. *
;* *
;* File Name : DS_DN.ASM *
;* *
;* Programmer : Scott K. Bowen *
;* *
;* Start Date : August 24, 1993 *
;* *
;* Last Update : September 6, 1994 [IML] *
;* *
;*-------------------------------------------------------------------------*
;* Functions: *
;* Draw_Normal -- Draws a normal row of pixels to the viewport *
;* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - *
IDEAL
P386
MODEL USE32 FLAT
;******************************** Includes *********************************
INCLUDE "shape.inc"
;********************************* Code ************************************
CODESEG
;***************************************************************************
;* Draw_Normal -- Draws a normal row of pixels to the viewport *
;* *
;* INPUT: *
;* ECX = number of pixels (not bytes) to draw *
;* EDX = XTotal initializer value *
;* ESI = shape (source) buffer address *
;* EDI = viewport (destination) address *
;* [WidthCount] = remaining bytes on the line *
;* *
;* OUTPUT: *
;* ESI - updated to current location in the shape data *
;* EDI - incr/decr by # pixels (not bytes) drawn/skipped *
;* [WidthCount] - bytes remaining on the line *
;* *
;* WARNINGS: none *
;* *
;* HISTORY: *
;* 04/14/1992 PWG : Created. *
;* 08/19/1993 SKB : Split drawshp.asm into several modules. *
;* 06/02/1994 BR : Converted to 32-bit. *
;* 08/09/1994 IML : Optimized for 32-bit. *
;* 09/06/1994 IML : Integrated p_* and ds_* routines. *
;*=========================================================================*
PROC Draw_Normal NOLANGUAGE NEAR
mov [StashEDX],edx ; save edx
mov edx,[Flags]
mov eax,0 ; init to zero
sub [WidthCount],ecx ; decrement bytes remaining by pixels
; to draw
;--------------------------------------------------------------------
; Drawing Loop:
; - Get a data byte
; - If it's a 0, handle the run:
; - get repetition value
; - add it to EDI
; - subtract it from [WidthCount]
; - subtract it from ECX
; - if ECX>0, draw again, else exit
; - Otherwise:
; - draw the pixel
; - increment EDI to next pixel location
; - decrement [WidthCount]
; - loop until ECX is 0
;--------------------------------------------------------------------
test edx,SHAPE_EFFECTS ; are any effects flags set?
jnz short ??general_draw_continue ; if so use the general purpose loop
;--------------------------------------------------------------------
; Extra fast draw loop for shapes with no flags set.
;--------------------------------------------------------------------
??fast_draw_loop:
mov al,[esi] ; get a byte of the source
inc esi
or eax,eax ; is the byte a transparent run?
jz short ??fast_is_run ; if yes then handle the run
mov [edi],al ; store color value to viewport
inc edi ; point to next viewport pixel
dec ecx ; any source pixels left?
jnz short ??fast_draw_loop ; if not then go home
jmp ??out
??fast_is_run:
mov al,[esi]
inc esi
add edi,eax ; move the viewport pointer
sub ecx,eax ; chop down the width to do
jg short ??fast_draw_loop ; while more to do, loop back up
jmp ??out
;--------------------------------------------------------------------
; General purpose draw loop for shapes with one or more flags set.
;--------------------------------------------------------------------
??general_draw_loop:
test edx,SHAPE_FADING ; if fading is enabled test for
jz short ??no_fading_draw_loop ; transparency
or eax,eax
jz short ??is_transparent
??no_fading_draw_loop:
mov [edi],al ; store color value to viewport
??is_transparent:
inc edi ; point to next viewport pixel
dec ecx ; any source pixels left?
jz ??out ; if not then go home
??general_draw_continue:
mov al,[esi] ; get a byte of the source
inc esi
or eax,eax ; is the byte a transparent run?
jz ??general_is_run ; if yes then handle the run
??test_priority:
test edx,SHAPE_PRIORITY
jnz short ??priority
??test_predator:
test edx,SHAPE_PREDATOR
jnz short ??predator
??test_compact:
test edx,SHAPE_COMPACT
jnz ??compact
??test_shadow:
test edx,SHAPE_SHADOW
jnz ??shadow
??test_translucency:
test edx,SHAPE_GHOST
jz short ??test_fading
mov ebx,[IsTranslucent] ; is it a translucent color?
mov bh,[BYTE PTR ebx + eax]
or bh,bh
js short ??test_fading
and ebx,0FF00h ; clear all of ebx except bh
; we have the index to the translation table
; ((trans_colour * 256) + dest colour)
mov al,[edi] ; mov pixel at destination to al
add ebx,[Translucent] ; get the ptr to it!
; Add the (trans_color * 256) of the translation equ.
mov al,[BYTE PTR ebx + eax] ; get new pixel in al
jmp short ??test_fading
??test_fading:
test edx,SHAPE_FADING
jnz ??fading
jmp short ??general_draw_loop
??priority:
mov ebx,[MaskAdjust] ; get mask page offset
mov bl,[BYTE PTR ebx + edi] ; get mask value
and bl,CLEAR_UNUSED_BITS ; clear unused bits
cmp [PriLevel],bl ; are we in front of
jge short ??test_predator ; background?
mov ebx,[BackAdjust] ; get background page offset
mov al,[BYTE PTR ebx + edi] ; get background pixel
jmp ??general_draw_loop
??predator:
mov ebx,[PartialCount]
add ebx,[PartialPred]
or bh,bh
jnz short ??draw_pred ; is this a predator pixel?
mov [PartialCount],ebx
jmp short ??test_compact
??draw_pred:
xor bh,bh
mov [PartialCount],ebx
mov ebx,[PredValue] ; pick up a color offset a pseudo-
; random amount from the current
mov al,[edi + ebx] ; viewport address
jmp ??general_draw_loop
??compact:
mov ebx,[ColorTable] ; get the address of the color table
mov al,[BYTE PTR ebx + eax] ; convert it into the proper byte
jmp ??test_shadow
??shadow:
cmp al,SHADOW_COL
jne ??test_translucency ; is the table value a magic number?
mov al,[edi] ; get the destination color and
mov ebx,[ShadowingTable] ; index into the shadow table
mov al,[BYTE PTR ebx + eax]
jmp ??general_draw_loop
??fading:
mov [StashECX],ecx ; preserve ecx for later
mov ebx,[FadingTable] ; run color through fading table
mov ecx,[FadingNum]
??fade_loop:
mov al, [BYTE PTR ebx + eax]
dec ecx
jnz short ??fade_loop
mov ecx,[StashECX] ; restore ecx for main draw loop
jmp ??general_draw_loop
??general_is_run:
mov al,[esi]
inc esi
add edi,eax ; move the viewport pointer
sub ecx,eax ; chop down the width to do
jg ??general_draw_continue ; while more to do, loop back up
??out:
add [WidthCount],ecx ; adjust for source ending in a run
mov edx,[StashEDX]
ret
ENDP Draw_Normal
END
;**************************** End of ds_dn.asm *****************************

257
WWFLAT32/SHAPE/DS_DR.ASM Normal file
View File

@@ -0,0 +1,257 @@
;
; 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 : Draw Shape Routines for library. *
;* *
;* File Name : DS_DR.ASM *
;* *
;* Programmer : Scott K. Bowen *
;* *
;* Start Date : August 24, 1993 *
;* *
;* Last Update : September 6, 1994 [IML] *
;* *
;*-------------------------------------------------------------------------*
;* Functions: *
;* Draw_Reverse -- Draws a reversed row of pixels to the viewport *
;* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - *
IDEAL
P386
MODEL USE32 FLAT
;******************************** Includes *********************************
INCLUDE "shape.inc"
;********************************* Code ************************************
CODESEG
;***************************************************************************
;* Draw_Reverse -- Draws a reversed row of pixels to the viewport *
;* *
;* INPUT: *
;* ECX = number of pixels (not bytes) to draw *
;* EDX = XTotal initializer value *
;* ESI = shape (source) buffer address *
;* EDI = viewport (destination) address *
;* [WidthCount] = remaining bytes on the line *
;* *
;* OUTPUT: *
;* ESI - updated to current location in the shape data *
;* EDI - incr/decr by # pixels (not bytes) drawn/skipped *
;* [WidthCount] - bytes remaining on the line *
;* *
;* WARNINGS: none *
;* *
;* HISTORY: *
;* 04/14/1992 PWG : Created. *
;* 08/19/1993 SKB : Split drawshp.asm into several modules. *
;* 06/02/1994 BR : Converted to 32-bit. *
;* 08/09/1994 IML : Optimized for 32-bit. *
;* 09/06/1994 IML : Integrated p_* and ds_* routines. *
;*=========================================================================*
PROC Draw_Reverse NOLANGUAGE NEAR
mov [StashEDX],edx ; save edx
mov edx,[Flags]
mov eax,0 ; init to zero
sub [WidthCount],ecx ; decrement bytes remaining by pixels
; to draw
;--------------------------------------------------------------------
; Drawing Loop:
; - Get a data byte
; - If it's a 0, handle the run:
; - get repetition value
; - subtract it from EDI
; - subtract it from [WidthCount]
; - subtract it from ECX
; - if ECX>0, draw again, else exit
; - Otherwise:
; - draw the pixel
; - increment EDI to next pixel location
; - decrement [WidthCount]
; - loop until ECX is 0
;--------------------------------------------------------------------
test edx,SHAPE_EFFECTS ; are any effects flags set?
jnz short ??general_draw_continue ; if so use the general purpose loop
;--------------------------------------------------------------------
; Extra fast draw loop for shapes with no flags set.
;--------------------------------------------------------------------
??fast_draw_loop:
mov al,[esi] ; get a byte of the source
inc esi
or eax,eax ; is the byte a transparent run?
jz short ??fast_is_run ; if yes then handle the run
mov [edi],al ; store color value to viewport
dec edi ; point to next viewport pixel
dec ecx ; any source pixels left?
jnz short ??fast_draw_loop ; if not then go home
jmp ??out
??fast_is_run:
mov al,[esi]
inc esi
sub edi,eax ; move the viewport pointer
sub ecx,eax ; chop down the width to do
jg short ??fast_draw_loop ; while more to do, loop back up
jmp ??out
;--------------------------------------------------------------------
; General purpose draw loop for shapes with one or more flags set.
;--------------------------------------------------------------------
??general_draw_loop:
test edx,SHAPE_FADING ; if fading is enabled test for
jz short ??no_fading_draw_loop ; transparency
or eax,eax
jz short ??is_transparent
??no_fading_draw_loop:
mov [edi],al ; store color value to viewport
??is_transparent:
dec edi ; point to next viewport pixel
dec ecx ; any source pixels left?
jz ??out ; if not then go home
??general_draw_continue:
mov al,[esi] ; get a byte of the source
inc esi
or eax,eax ; is the byte a transparent run?
jz ??general_is_run ; if yes then handle the run
??test_priority:
test edx,SHAPE_PRIORITY
jnz short ??priority
??test_predator:
test edx,SHAPE_PREDATOR
jnz short ??predator
??test_compact:
test edx,SHAPE_COMPACT
jnz ??compact
??test_shadow:
test edx,SHAPE_SHADOW
jnz ??shadow
??test_translucency:
test edx,SHAPE_GHOST
jz short ??test_fading
mov ebx,[IsTranslucent] ; is it a translucent color?
mov bh,[BYTE PTR ebx + eax]
or bh,bh
js short ??test_fading
and ebx,0FF00h ; clear all of ebx except bh
; we have the index to the translation table
; ((trans_colour * 256) + dest colour)
mov al,[edi] ; mov pixel at destination to al
add ebx,[Translucent] ; get the ptr to it!
; Add the (trans_color * 256) of the translation equ.
mov al,[BYTE PTR ebx + eax] ; get new pixel in al
??test_fading:
test edx,SHAPE_FADING
jnz ??fading
jmp short ??general_draw_loop
??priority:
mov ebx,[MaskAdjust] ; get mask page offset
mov bl,[BYTE PTR ebx + edi] ; get mask value
and bl,CLEAR_UNUSED_BITS ; clear unused bits
cmp [PriLevel],bl ; are we in front of
jge short ??test_predator ; background?
mov ebx,[BackAdjust] ; get background page offset
mov al,[BYTE PTR ebx + edi] ; get background pixel
jmp ??general_draw_loop
??predator:
mov ebx,[PartialCount]
add ebx,[PartialPred]
or bh,bh
jnz short ??draw_pred ; is this a predator pixel?
mov [PartialCount],ebx
jmp short ??test_compact
??draw_pred:
xor bh,bh
mov [PartialCount],ebx
mov ebx,[PredValue] ; pick up a color offset a pseudo-
; random amount from the current
mov al,[edi + ebx] ; viewport address
jmp ??general_draw_loop
??compact:
mov ebx,[ColorTable] ; get the address of the color table
mov al,[BYTE PTR ebx + eax] ; convert it into the proper byte
jmp ??test_shadow
??shadow:
cmp al,SHADOW_COL
jne ??test_translucency ; is the table value a magic number?
mov al,[edi] ; get the destination color and
mov ebx,[ShadowingTable] ; index into the shadow table
mov al,[BYTE PTR ebx + eax]
jmp ??general_draw_loop
??fading:
mov [StashECX],ecx ; preserve ecx for later
mov ebx,[FadingTable] ; run color through fading table
mov ecx,[FadingNum]
??fade_loop:
mov al, [BYTE PTR ebx + eax]
dec ecx
jnz short ??fade_loop
mov ecx,[StashECX] ; restore ecx for main draw loop
jmp ??general_draw_loop
??general_is_run:
mov al,[esi]
inc esi
sub edi,eax ; move the viewport pointer
sub ecx,eax ; chop down the width to do
jg ??general_draw_continue ; while more to do, loop back up
??out:
add [WidthCount],ecx ; adjust for source ending in a run
mov edx,[StashEDX]
ret
ENDP Draw_Reverse
END
;**************************** End of ds_dr.asm *****************************

341
WWFLAT32/SHAPE/DS_DS.ASM Normal file
View File

@@ -0,0 +1,341 @@
;
; 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 : Draw Shape Routines for library. *
;* *
;* File Name : DS_DS.ASM *
;* *
;* Programmer : Scott K. Bowen *
;* *
;* Start Date : August 24, 1993 *
;* *
;* Last Update : September 6, 1994 [IML] *
;* *
;*-------------------------------------------------------------------------*
;* Functions: *
;* Draw_Scale -- Draws a scaled row of pixels to the viewport *
;* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - *
IDEAL
P386
MODEL USE32 FLAT
;******************************** Includes *********************************
INCLUDE "shape.inc"
;********************************* Code ************************************
CODESEG
;***************************************************************************
;* Draw_Scale -- Draws a scaled row of pixels to the viewport *
;* *
;* INPUT: *
;* ECX = number of pixels (not bytes) to draw *
;* EDX = XTotal initializer value *
;* ESI = shape (source) buffer address *
;* EDI = viewport (destination) address *
;* [WidthCount] = remaining bytes on the line *
;* *
;* OUTPUT: *
;* ESI - updated to current location in the shape data *
;* EDI - incr/decr by # pixels (not bytes) drawn/skipped *
;* [WidthCount] - bytes remaining on the line *
;* *
;* WARNINGS: none *
;* *
;* HISTORY: *
;* 04/14/1992 PWG : Created. *
;* 08/19/1993 SKB : Split drawshp.asm into several modules. *
;* 06/02/1994 BR : Converted to 32-bit. *
;* 08/09/1994 IML : Optimized for 32-bit. *
;* 09/06/1994 IML : Integrated p_* and ds_* routines. *
;*=========================================================================*
PROC Draw_Scale NOLANGUAGE NEAR
mov eax,0 ; init to 0
test [Flags],SHAPE_EFFECTS
jnz short ??general_draw_continue
jmp short ??fast_draw_continue
;--------------------------------------------------------------------
; Extra fast draw loop for shapes with no flags set.
;--------------------------------------------------------------------
;--------------------------------------------------------------------
; Load a new byte:
; - read the byte into AL
; - if it's a run, deal with it
; - otherwise,
; - decrement [WidthCount]
; - update EDX with [ScaleX]
; - see if it's drawable (upon proc entry, it won't be)
; - yes: draw a pixel
; - no : load a new byte
;--------------------------------------------------------------------
??fast_draw_loop:
mov al,[esi] ; get the next pixel from the source
inc esi
or eax,eax
jz short ??fast_is_run ; deal with a run
dec [WidthCount] ; count down # bytes processed
add edx,[ScaleX] ; add in the scale value
??fast_draw_continue:
or dh,dh ; are there any pixels to draw?
jz short ??fast_draw_loop
;--------------------------------------------------------------------
; Draw one pixel:
; - draw the pixel
; - increment destination pointer
; - decrement high byte of EDX (X-scale accumulator)
; - loop (while ECX>0) to see if it's drawable
;--------------------------------------------------------------------
mov [edi],al ; store color value to viewport
inc edi ; increment the destination index
dec dh ; decrement the pixels to write
dec ecx
jnz short ??fast_draw_continue
jmp ??out ; get the heck outta here
;--------------------------------------------------------------------
; Handle a run:
; - Get the run repetition value
; - subract it from [WidthCount]
; - multiply it by [ScaleX]
; - put high bytes from mul into EAX, low byte into DL (roundoff bits)
; - add high bytes (# pixels) to EDI
; - subtract them from ECX
; - clear EAX
; - if ECX>0, go get next byte
;--------------------------------------------------------------------
??fast_is_run:
mov al,[esi] ; get number of repeated values
inc esi
sub [WidthCount],eax ; adjust the remaining byte width
mov ebx,edx ; preserve dx for the multiply
mul [ScaleX] ; EDX:EAX = # pixels + roundoff bits
add eax,ebx ; add in the current x-total
mov edx,eax ; (assume EDX is empty)
shr eax,8 ; EAX = # pixels skipped
and edx,00FFh ; keep only low byte
add edi,eax ; add to EDI
sub ecx,eax ; subtract it from ECX
mov eax,0 ; clear EAX
or ecx,ecx
jg short ??fast_draw_loop ; if more to draw, process new byte
jmp ??out
;--------------------------------------------------------------------
; General purpose draw loop for shapes with one or more flags set.
;--------------------------------------------------------------------
;--------------------------------------------------------------------
; Load a new byte:
; - read the byte into AL
; - if it's a run, deal with it
; - otherwise,
; - decrement [WidthCount]
; - update EDX with [ScaleX]
; - see if it's drawable (upon proc entry, it won't be)
; - yes: draw a pixel
; - no : load a new byte
;--------------------------------------------------------------------
??general_draw_loop:
mov al,[esi] ; get the next pixel from the source
inc esi
or eax,eax
jz ??general_is_run ; deal with a run
dec [WidthCount] ; count down # bytes processed
add edx,[ScaleX] ; add in the scale value
??general_draw_continue:
or dh,dh ; are there any pixels to draw?
jz short ??general_draw_loop
;--------------------------------------------------------------------
; Draw one pixel:
; - draw the pixel
; - increment destination pointer
; - decrement high byte of EDX (X-scale accumulator)
; - loop (while ECX>0) to see if it's drawable
;--------------------------------------------------------------------
??draw:
mov [StashReg],eax ; save eax
mov [StashEDX],edx ; save edx
mov edx,[Flags]
??test_priority:
test edx,SHAPE_PRIORITY
jnz short ??priority
??test_predator:
test edx,SHAPE_PREDATOR
jnz short ??predator
??test_compact:
test edx,SHAPE_COMPACT
jnz ??compact
??test_shadow:
test edx,SHAPE_SHADOW
jnz ??shadow
??test_translucency:
test edx,SHAPE_GHOST
jnz ??translucency
??test_fading:
test edx,SHAPE_FADING
jnz ??fading
??test_transparency:
test edx,SHAPE_FADING ; if fading is enabled test for
jz short ??no_fading_draw_loop ; transparency
or eax,eax
jz short ??is_transparent
??no_fading_draw_loop:
mov [edi],al ; store color value to viewport
??is_transparent:
mov eax,[StashReg] ; restore eax
mov edx,[StashEDX] ; restore edx
inc edi ; increment the destination index
dec dh ; decrement the pixels to write
dec ecx
jnz ??general_draw_continue
jmp ??out ; get the heck outta here
??priority:
mov ebx,[MaskAdjust] ; get mask page offset
mov bl,[BYTE PTR ebx + edi] ; get mask value
and bl,CLEAR_UNUSED_BITS ; clear unused bits
cmp [PriLevel],bl ; are we in front of
jge short ??test_predator ; background?
mov ebx,[BackAdjust] ; get background page offset
mov al,[BYTE PTR ebx + edi] ; get background pixel
jmp short ??test_transparency
??predator:
mov ebx,[PartialCount]
add ebx,[PartialPred]
or bh,bh
jnz short ??draw_pred ; is this a predator pixel?
mov [PartialCount],ebx
jmp ??test_compact
??draw_pred:
xor bh,bh
mov [PartialCount],ebx
mov ebx,[PredValue] ; pick up a color offset a pseudo-
; random amount from the current
mov al,[edi + ebx] ; viewport address
jmp short ??test_transparency
??compact:
mov ebx,[ColorTable] ; get the address of the color table
mov al,[BYTE PTR ebx + eax] ; convert it into the proper byte
jmp ??test_shadow
??shadow:
cmp al,SHADOW_COL
jne ??test_translucency ; is the table value a magic number?
mov al,[edi] ; get the destination color and
mov ebx,[ShadowingTable] ; index into the shadow table
mov al,[BYTE PTR ebx + eax]
jmp ??test_transparency
??fading:
mov [StashECX],ecx ; preserve ecx for later
mov ebx,[FadingTable] ; run color through fading table
mov ecx,[FadingNum]
??fade_loop:
mov al, [BYTE PTR ebx + eax]
dec ecx
jnz short ??fade_loop
mov ecx,[StashECX] ; restore ecx for main draw loop
jmp ??test_transparency
??translucency:
mov ebx,[IsTranslucent] ; is it a translucent color?
mov bh,[BYTE PTR ebx + eax]
or bh,bh
js ??test_fading
and ebx,0FF00h ; clear all of ebx except bh
; we have the index to the translation table
; ((trans_colour * 256) + dest colour)
mov al,[edi] ; mov pixel at destination to al
add ebx,[Translucent] ; get the ptr to it!
; Add the (trans_color * 256) of the translation equ.
mov al,[BYTE PTR ebx + eax] ; get new pixel in al
jmp ??test_fading
;--------------------------------------------------------------------
; Handle a run:
; - Get the run repetition value
; - subract it from [WidthCount]
; - multiply it by [ScaleX]
; - put high bytes from mul into EAX, low byte into DL (roundoff bits)
; - add high bytes (# pixels) to EDI
; - subtract them from ECX
; - clear EAX
; - if ECX>0, go get next byte
;--------------------------------------------------------------------
??general_is_run:
mov al,[esi] ; get number of repeated values
inc esi
sub [WidthCount],eax ; adjust the remaining byte width
mov ebx,edx ; preserve dx for the multiply
mul [ScaleX] ; EDX:EAX = # pixels + roundoff bits
add eax,ebx ; add in the current x-total
mov edx,eax ; (assume EDX is empty)
shr eax,8 ; EAX = # pixels skipped
and edx,00FFh ; keep only low byte
add edi,eax ; add to EDI
sub ecx,eax ; subtract it from ECX
mov eax,0 ; clear EAX
or ecx,ecx
jg ??general_draw_loop ; if more to draw, process new byte
??out:
ret ; lets get out of here
ENDP Draw_Scale
END
;**************************** End of ds_ds.asm ******************************

341
WWFLAT32/SHAPE/DS_DSR.ASM Normal file
View File

@@ -0,0 +1,341 @@
;
; 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 : Draw Shape Routines for library. *
;* *
;* File Name : DS_DSR.ASM *
;* *
;* Programmer : Scott K. Bowen *
;* *
;* Start Date : August 24, 1993 *
;* *
;* Last Update : September 6, 1994 [IML] *
;* *
;*-------------------------------------------------------------------------*
;* Functions: *
;* Draw_Scale_Reverse -- Draws a scaled row of pixels to the viewport *
;* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - *
IDEAL
P386
MODEL USE32 FLAT
;******************************** Includes *********************************
INCLUDE "shape.inc"
;********************************* Code ************************************
CODESEG
;*******p********************************************************************
;* Draw_Scale_Reverse -- Draws a scaled row of pixels to the viewport *
;* *
;* INPUT: *
;* ECX = number of pixels (not bytes) to draw *
;* EDX = XTotal initializer value *
;* ESI = shape (source) buffer address *
;* EDI = viewport (destination) address *
;* [WidthCount] = remaining bytes on the line *
;* *
;* OUTPUT: *
;* ESI - updated to current location in the shape data *
;* EDI - incr/decr by # pixels (not bytes) drawn/skipped *
;* [WidthCount] - bytes remaining on the line *
;* *
;* WARNINGS: none *
;* *
;* HISTORY: *
;* 04/14/1992 PWG : Created. *
;* 08/19/1993 SKB : Split drawshp.asm into several modules. *
;* 06/02/1994 BR : Converted to 32-bit. *
;* 08/09/1994 IML : Optimized for 32-bit *
;* 09/06/1994 IML : Integrated p_* and ds_* routines. *
;*=========================================================================*
PROC Draw_Scale_Reverse NOLANGUAGE NEAR
mov eax,0 ; init to 0
test [Flags],SHAPE_EFFECTS
jnz short ??general_draw_continue
jmp short ??fast_draw_continue
;--------------------------------------------------------------------
; Extra fast draw loop for shapes with no flags set.
;--------------------------------------------------------------------
;--------------------------------------------------------------------
; Load a new byte:
; - read the byte into AL
; - if it's a run, deal with it
; - otherwise,
; - decrement [WidthCount]
; - update EDX with [ScaleX]
; - see if it's drawable (upon proc entry, it won't be)
; - yes: draw a pixel
; - no : load a new byte
;--------------------------------------------------------------------
??fast_draw_loop:
mov al,[esi] ; get the next pixel from the source
inc esi
or eax,eax
jz short ??fast_is_run ; deal with a run
dec [WidthCount] ; count down # bytes processed
add edx,[ScaleX] ; add in the scale value
??fast_draw_continue:
or dh,dh ; are there any pixels to draw?
jz short ??fast_draw_loop
;--------------------------------------------------------------------
; Draw one pixel:
; - draw the pixel
; - increment destination pointer
; - decrement high byte of EDX (X-scale accumulator)
; - loop (while ECX>0) to see if it's drawable
;--------------------------------------------------------------------
mov [edi],al ; store color value to viewport
dec edi ; decrement the destination index
dec dh ; decrement the pixels to write
dec ecx
jnz short ??fast_draw_continue
jmp ??out ; get the heck outta here
;--------------------------------------------------------------------
; Handle a run:
; - Get the run repetition value
; - subract it from [WidthCount]
; - multiply it by [ScaleX]
; - put high bytes from mul into EAX, low byte into DL (roundoff bits)
; - add high bytes (# pixels) to EDI
; - subtract them from ECX
; - clear EAX
; - if ECX>0, go get next byte
;--------------------------------------------------------------------
??fast_is_run:
mov al,[esi] ; get number of repeated values
inc esi
sub [WidthCount],eax ; adjust the remaining byte width
mov ebx,edx ; preserve dx for the multiply
mul [ScaleX] ; EDX:EAX = # pixels + roundoff bits
add eax,ebx ; add in the current x-total
mov edx,eax ; (assume EDX is empty)
shr eax,8 ; EAX = # pixels skipped
and edx,00FFh ; keep only low byte
sub edi,eax ; sub from EDI
sub ecx,eax ; subtract it from ECX
mov eax,0 ; clear EAX
or ecx,ecx
jg short ??fast_draw_loop ; if more to draw, process new byte
jmp ??out
;--------------------------------------------------------------------
; General purpose draw loop for shapes with one or more flags set.
;--------------------------------------------------------------------
;--------------------------------------------------------------------
; Load a new byte:
; - read the byte into AL
; - if it's a run, deal with it
; - otherwise,
; - decrement [WidthCount]
; - update EDX with [ScaleX]
; - see if it's drawable (upon proc entry, it won't be)
; - yes: draw a pixel
; - no : load a new byte
;--------------------------------------------------------------------
??general_draw_loop:
mov al,[esi] ; get the next pixel from the source
inc esi
or eax,eax
jz ??general_is_run ; deal with a run
dec [WidthCount] ; count down # bytes processed
add edx,[ScaleX] ; add in the scale value
??general_draw_continue:
or dh,dh ; are there any pixels to draw?
jz short ??general_draw_loop
;--------------------------------------------------------------------
; Draw one pixel:
; - draw the pixel
; - increment destination pointer
; - decrement high byte of EDX (X-scale accumulator)
; - loop (while ECX>0) to see if it's drawable
;--------------------------------------------------------------------
??draw:
mov [StashReg],eax ; save eax
mov [StashEDX],edx ; save edx
mov edx,[Flags]
??test_priority:
test edx,SHAPE_PRIORITY
jnz short ??priority
??test_predator:
test edx,SHAPE_PREDATOR
jnz short ??predator
??test_compact:
test edx,SHAPE_COMPACT
jnz ??compact
??test_shadow:
test edx,SHAPE_SHADOW
jnz ??shadow
??test_translucency:
test edx,SHAPE_GHOST
jnz ??translucency
??test_fading:
test edx,SHAPE_FADING
jnz ??fading
??test_transparency:
test edx,SHAPE_FADING ; if fading is enabled test for
jz short ??no_fading_draw_loop ; transparency
or eax,eax
jz short ??is_transparent
??no_fading_draw_loop:
mov [edi],al ; store color value to viewport
??is_transparent:
mov eax,[StashReg] ; restore eax
mov edx,[StashEDX] ; restore edx
dec edi ; decrement the destination index
dec dh ; decrement the pixels to write
dec ecx
jnz ??general_draw_continue
jmp ??out ; get the heck outta here
??priority:
mov ebx,[MaskAdjust] ; get mask page offset
mov bl,[BYTE PTR ebx + edi] ; get mask value
and bl,CLEAR_UNUSED_BITS ; clear unused bits
cmp [PriLevel],bl ; are we in front of
jge short ??test_predator ; background?
mov ebx,[BackAdjust] ; get background page offset
mov al,[BYTE PTR ebx + edi] ; get background pixel
jmp short ??test_transparency
??predator:
mov ebx,[PartialCount]
add ebx,[PartialPred]
or bh,bh
jnz short ??draw_pred ; is this a predator pixel?
mov [PartialCount],ebx
jmp ??test_compact
??draw_pred:
xor bh,bh
mov [PartialCount],ebx
mov ebx,[PredValue] ; pick up a color offset a pseudo-
; random amount from the current
mov al,[edi + ebx] ; viewport address
jmp short ??test_transparency
??compact:
mov ebx,[ColorTable] ; get the address of the color table
mov al,[BYTE PTR ebx + eax] ; convert it into the proper byte
jmp ??test_shadow
??shadow:
cmp al,SHADOW_COL
jne ??test_translucency ; is the table value a magic number?
mov al,[edi] ; get the destination color and
mov ebx,[ShadowingTable] ; index into the shadow table
mov al,[BYTE PTR ebx + eax]
jmp ??test_transparency
??fading:
mov [StashECX],ecx ; preserve ecx for later
mov ebx,[FadingTable] ; run color through fading table
mov ecx,[FadingNum]
??fade_loop:
mov al, [BYTE PTR ebx + eax]
dec ecx
jnz short ??fade_loop
mov ecx,[StashECX] ; restore ecx for main draw loop
jmp ??test_transparency
??translucency:
mov ebx,[IsTranslucent] ; is it a translucent color?
mov bh,[BYTE PTR ebx + eax]
or bh,bh
js ??test_fading
and ebx,0FF00h ; clear all of ebx except bh
; we have the index to the translation table
; ((trans_colour * 256) + dest colour)
mov al,[edi] ; mov pixel at destination to al
add ebx,[Translucent] ; get the ptr to it!
; Add the (trans_color * 256) of the translation equ.
mov al,[BYTE PTR ebx + eax] ; get new pixel in al
jmp ??test_fading
;--------------------------------------------------------------------
; Handle a run:
; - Get the run repetition value
; - subract it from [WidthCount]
; - multiply it by [ScaleX]
; - put high bytes from mul into EAX, low byte into DL (roundoff bits)
; - add high bytes (# pixels) to EDI
; - subtract them from ECX
; - clear EAX
; - if ECX>0, go get next byte
;--------------------------------------------------------------------
??general_is_run:
mov al,[esi] ; get number of repeated values
inc esi
sub [WidthCount],eax ; adjust the remaining byte width
mov ebx,edx ; preserve dx for the multiply
mul [ScaleX] ; EDX:EAX = # pixels + roundoff bits
add eax,ebx ; add in the current x-total
mov edx,eax ; (assume EDX is empty)
shr eax,8 ; EAX = # pixels skipped
and edx,00FFh ; keep only low byte
sub edi,eax ; sub from EDI
sub ecx,eax ; subtract it from ECX
mov eax,0 ; clear EAX
or ecx,ecx
jg ??general_draw_loop ; if more to draw, process new byte
??out:
ret ; lets get out of here
ENDP Draw_Scale_Reverse
END
;*************************** End of ds_dsr.asm ******************************

118
WWFLAT32/SHAPE/DS_LRS.ASM Normal file
View 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 : Draw Shape Routines for library. *
;* *
;* File Name : DS_LRS.ASM *
;* *
;* Programmer : Scott K. Bowen *
;* *
;* Start Date : August 24, 1993 *
;* *
;* Last Update : June 2, 1994 [BR] *
;* *
;*-------------------------------------------------------------------------*
;* Functions: *
;* Left_Reverse_Skip -- Skips bytes in a data stream *
;* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - *
;********************* Model & Processor Directives ************************
IDEAL
P386
MODEL USE32 FLAT
;******************************** Includes *********************************
INCLUDE "shape.inc"
;********************************* Code ************************************
CODESEG
;***************************************************************************
;* Left_Reverse_Skip -- Skips bytes in a data stream *
;* *
;* INPUT: *
;* ECX = number of uncompressed bytes to skip *
;* ESI = shape (source) buffer data address *
;* EDI = viewport (destination) address *
;* [WidthCount] = shape's width *
;* *
;* OUTPUT: *
;* ECX - negative # pixels overrun, or 0 *
;* EDX - XTotal initializer value (0 since there's no scaling)*
;* ESI - updated to the current location in the shape data *
;* EDI - decremented by # pixels overrun *
;* [WidthCount] - decremented by # bytes skipped *
;* *
;* WARNINGS: none *
;* *
;* HISTORY: *
;* 04/14/1992 PWG : Created. *
;* 08/19/1993 SKB : Split drawshp.asm into several modules. *
;* 05/28/1994 BR : Converted to 32-bit *
;*=========================================================================*
PROC Left_Reverse_Skip NOLANGUAGE NEAR
sub [WidthCount],ecx ; we process ECX bytes of real width
;--------------------------------------------------------------------
; Put shape data address in EDI so we can do a scasb on it
;--------------------------------------------------------------------
xchg esi,edi ; xchange ESI and EDI
jecxz ??out ; exit if ECX is 0 (no bytes to skip)
;--------------------------------------------------------------------
; Search through the string and count down the info we have handled.
; If we find a run (0 followed by a count byte), then handle it.
;--------------------------------------------------------------------
??cliptop:
mov eax,0 ; set al to 0 (we're scanning for 0)
repne scasb ; scan through source data
jz ??on_run ; if it is a run then deal with it
jecxz ??out ; if we're done then get outta here
;--------------------------------------------------------------------
; If we have a run then get the next byte which is the length.
;--------------------------------------------------------------------
??on_run:
mov al,[BYTE PTR edi] ; get the count of zeros to run
inc edi ; advance past the count
inc ecx ; the 0 found doesn't count
sub ecx,eax ; subtract the count from remaining
jg ??cliptop ; if more bytes left, scan again
;--------------------------------------------------------------------
; Put shape address back into ESI, adjust EDI
;--------------------------------------------------------------------
??out:
xchg esi,edi ; xchange ESI and EDI
add edi,ecx ; decrement EDI by overrun pixels
add [WidthCount],ecx ; adjust by # bytes overrun
mov edx,0 ; no scaling, so clear EDX
ret ; return back to the real function
ENDP Left_Reverse_Skip
END
;*************************** End of ds_lrs.asm *****************************


118
WWFLAT32/SHAPE/DS_LS.ASM Normal file
View 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 : Draw Shape Routines for library. *
;* *
;* File Name : DS_LS.ASM *
;* *
;* Programmer : Scott K. Bowen *
;* *
;* Start Date : August 24, 1993 *
;* *
;* Last Update : June 2, 1994 [BR] *
;* *
;*-------------------------------------------------------------------------*
;* Functions: *
;* Left_Skip -- Skips bytes in a data stream *
;* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - *
;********************* Model & Processor Directives ************************
IDEAL
P386
MODEL USE32 FLAT
;******************************** Includes *********************************
INCLUDE "shape.inc"
;********************************* Code ************************************
CODESEG
;***************************************************************************
;* Left_Skip -- Skips bytes in a data stream *
;* *
;* INPUT: *
;* ECX = number of uncompressed bytes to skip *
;* ESI = shape (source) buffer data address *
;* EDI = viewport (destination) address *
;* [WidthCount] = shape's width *
;* *
;* OUTPUT: *
;* ECX - negative # pixels overrun, or 0 *
;* EDX - XTotal initializer value (0 since there's no scaling)*
;* ESI - updated to the current location in the shape data *
;* EDI - incremented by # pixels overrun *
;* [WidthCount] - decremented by # bytes skipped *
;* *
;* WARNINGS: none *
;* *
;* HISTORY: *
;* 04/14/1992 PWG : Created. *
;* 08/19/1993 SKB : Split drawshp.asm into several modules. *
;* 06/02/1994 BR : Converted to 32-bit *
;*=========================================================================*
PROC Left_Skip NOLANGUAGE NEAR
sub [WidthCount],ecx ; we process ECX bytes of real width
;--------------------------------------------------------------------
; Put shape data address in EDI so we can do a scasb on it
;--------------------------------------------------------------------
xchg esi,edi ; xchange ESI and EDI
jecxz ??out ; exit if ECX is 0 (no bytes to skip)
;--------------------------------------------------------------------
; Search through the string and count down the info we have handled.
; If we find a run (0 followed by a count byte), then handle it.
;--------------------------------------------------------------------
??cliptop:
mov eax,0 ; set al to 0 (we're scanning for 0)
repne scasb ; scan through source data
jz ??on_run ; if it is a run then deal with it
jecxz ??out ; if we're done then get outta here
;--------------------------------------------------------------------
; If we have a run then get the next byte which is the length.
;--------------------------------------------------------------------
??on_run:
mov al,[BYTE PTR edi] ; get the count of zeros to run
inc edi ; advance past the count
inc ecx ; the 0 found doesn't count
sub ecx,eax ; subtract the count from remaining
jg ??cliptop ; if more bytes left, scan again
;--------------------------------------------------------------------
; Put shape address back into ESI, adjust EDI
;--------------------------------------------------------------------
??out:
xchg esi,edi ; xchange ESI and EDI
sub edi,ecx ; increment EDI by overrun pixels
add [WidthCount],ecx ; adjust by # bytes overrun
mov edx,0 ; no scaling, so clear EDX
ret ; return back to the real function
ENDP Left_Skip
END
;**************************** End of ds_ls.asm *****************************


159
WWFLAT32/SHAPE/DS_LSRS.ASM Normal file
View File

@@ -0,0 +1,159 @@
;
; 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 : Draw Shape Routines for library. *
;* *
;* File Name : DS_LSRS.ASM *
;* *
;* Programmer : Scott K. Bowen *
;* *
;* Start Date : August 24, 1993 *
;* *
;* Last Update : June 2, 1994 [BR] *
;* *
;*-------------------------------------------------------------------------*
;* Functions: *
;* Left_Scale_Reverse_Skip -- Skips past a scaled row of pixels *
;* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - *
;********************* Model & Processor Directives ************************
IDEAL
P386
MODEL USE32 FLAT
;******************************** Includes *********************************
INCLUDE "shape.inc"
;********************************* Code ************************************
CODESEG
;***************************************************************************
;* Left_Scale_Reverse_Skip -- Skips past a scaled row of pixels *
;* *
;* INPUT: *
;* ECX = number of uncompressed bytes to skip *
;* ESI = shape (source) buffer data address *
;* EDI = viewport (destination) address *
;* [WidthCount] = shape's width *
;* *
;* OUTPUT: *
;* ECX - negative # pixels (not bytes) overrun, or 0 *
;* EDX - XTotal initializer value *
;* ESI - updated to the current location in the shape data *
;* EDI - decremented by # pixels (not bytes) overrun *
;* [WidthCount] - decremented by # bytes skipped *
;* *
;* The value returned in EDX reflects what XTotal's accumulated value *
;* should be at the new pixel location. If no bytes are overrun, this *
;* will be whatever is stored in [XTotalInit] (which will be 0 if no *
;* pixels are left-clipped). *
;* *
;* WARNINGS: none *
;* *
;* HISTORY: *
;* 04/20/1992 PWG : Created. *
;* 08/19/1993 SKB : Split drawshp.asm into several modules. *
;* 06/02/1994 BR : Converted to 32-bit *
;*=========================================================================*
PROC Left_Scale_Reverse_Skip NOLANGUAGE NEAR
sub [WidthCount],ecx ; we process ECX bytes of real width
;--------------------------------------------------------------------
; Put shape data address in EDI so we can do a scasb on it
;--------------------------------------------------------------------
xchg esi,edi ; xchange ESI and EDI
jcxz ??getrem ; exit if no bytes to skip
;--------------------------------------------------------------------
; Search through the string and count down the info we have handled.
; If we find a run (0 followed by a count byte), then handle it.
;--------------------------------------------------------------------
??cliptop:
mov eax,0 ; set al to 0 (we're scanning for 0)
repne scasb ; scan through source data
jz short ??on_run ; if it is a run then deal with it
;--------------------------------------------------------------------
; Default exit point: store default x-scale bits & exit
;--------------------------------------------------------------------
??getrem:
mov edx,[XTotalInit] ; store out the remainder
jmp short ??out ; we're done, get outta here
;--------------------------------------------------------------------
; If we have a run then get the next byte which is the length.
;--------------------------------------------------------------------
??on_run:
mov al,[BYTE PTR edi] ; get the count of zeros to run
inc edi ; advance past the count
inc ecx ; the 0 found doesn't count
sub ecx,eax ; subtract the count from remaining
jg ??cliptop ; if more bytes left, scan again
jz ??getrem ; exactly enough bytes; exit
;--------------------------------------------------------------------
; Overrun exit point: ECX is negative by the # of bytes overrun.
; - adjust [WidthCount] by # of overrun bytes
; - compute the remainder at the new location (EDX)
; - compute the number of destination pixels to skip (ECX)
; - adjust EDI by # of overrun bytes
;--------------------------------------------------------------------
;
;............... adjust [WidthCount] by overrun bytes ...............
;
add [WidthCount],ecx ; adjust overrun in bytes
;
;................. put x-scale roundoff bits in EDX .................
;
mov eax,ecx ; get the number of bytes we overran
neg eax ; negate it since overun is negative
add eax,[LeftClipBytes] ; add the number of bytes we leftclip
mul [ScaleX] ; convert to pixels plus roundoff bits
mov edx,0 ; clear EDX
mov dl,al ; DL = x-scaling roundoff bits
;
;................ put negative overrun pixels in ECX ................
;
shr eax,8 ; EAX = total # left pixels
sub eax,[LeftClipPixels] ; EAX = # pixels overrun
mov ecx,eax ; store # overrun pixels
neg ecx ; make it negative
;
;................ adjust dest ptr by overrun pixels .................
;
sub esi,eax ; decrement ESI (EDI) by overrun pixels
;--------------------------------------------------------------------
; Put shape address back into ESI, adjust EDI
;--------------------------------------------------------------------
??out:
xchg esi,edi ; xchange ESI and EDI
ret ; return back to the real function
ENDP Left_Scale_Reverse_Skip
END
;**************************** End of ds_lsrs.asm ****************************


159
WWFLAT32/SHAPE/DS_LSS.ASM Normal file
View File

@@ -0,0 +1,159 @@
;
; 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 : Draw Shape Routines for library. *
;* *
;* File Name : DS_LSS.ASM *
;* *
;* Programmer : Scott K. Bowen *
;* *
;* Start Date : August 24, 1993 *
;* *
;* Last Update : June 2, 1994 [BR] *
;* *
;*-------------------------------------------------------------------------*
;* Functions: *
;* Left_Scale_Skip -- Skips past a scaled row of pixels on left side *
;* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - *
;********************* Model & Processor Directives ************************
IDEAL
P386
MODEL USE32 FLAT
;******************************** Includes *********************************
INCLUDE "shape.inc"
;********************************* Code ************************************
CODESEG
;***************************************************************************
;* Left_Scale_Skip -- Skips past a scaled row of pixels on left side *
;* *
;* INPUT: *
;* ECX = number of uncompressed bytes to skip *
;* ESI = shape (source) buffer data address *
;* EDI = viewport (destination) address *
;* [WidthCount] = shape's width *
;* *
;* OUTPUT: *
;* ECX - negative # pixels (not bytes) overrun, or 0 *
;* EDX - XTotal initializer value *
;* ESI - updated to the current location in the shape data *
;* EDI - incremented by # pixels (not bytes) overrun *
;* [WidthCount] - decremented by # bytes skipped *
;* *
;* The value returned in EDX reflects what XTotal's accumulated value *
;* should be at the new pixel location. If no bytes are overrun, this *
;* will be whatever is stored in [XTotalInit] (which will be 0 if no *
;* pixels are left-clipped). *
;* *
;* WARNINGS: none *
;* *
;* HISTORY: *
;* 09/08/1992 PWG : Created. *
;* 08/19/1993 SKB : Split drawshp.asm into several modules. *
;* 06/02/1994 BR : Converted to 32-bit *
;*=========================================================================*
PROC Left_Scale_Skip NOLANGUAGE NEAR
sub [WidthCount],ecx ; we process ECX bytes of real width
;--------------------------------------------------------------------
; Put shape data address in EDI so we can do a scasb on it
;--------------------------------------------------------------------
xchg esi,edi ; xchange ESI and EDI
jcxz ??getrem ; exit if no bytes to skip
;--------------------------------------------------------------------
; Search through the string and count down the info we have handled.
; If we find a run (0 followed by a count byte), then handle it.
;--------------------------------------------------------------------
??cliptop:
mov eax,0 ; set al to 0 (we're scanning for 0)
repne scasb ; scan through source data
jz short ??on_run ; if it is a run then deal with it
;--------------------------------------------------------------------
; Default exit point: store default x-scale bits & exit
;--------------------------------------------------------------------
??getrem:
mov edx,[XTotalInit] ; store out the remainder
jmp short ??out ; we're done, get outta here
;--------------------------------------------------------------------
; If we have a run then get the next byte which is the length.
;--------------------------------------------------------------------
??on_run:
mov al,[BYTE PTR edi] ; get the count of zeros to run
inc edi ; advance past the count
inc ecx ; the 0 found doesn't count
sub ecx,eax ; subtract the count from remaining
jg ??cliptop ; if more bytes left, scan again
jz ??getrem ; exactly enough bytes; exit
;--------------------------------------------------------------------
; Overrun exit point: ECX is negative by the # of bytes overrun.
; - adjust [WidthCount] by # of overrun bytes
; - compute the remainder at the new location (EDX)
; - compute the number of destination pixels to skip (ECX)
; - adjust EDI by # of overrun bytes
;--------------------------------------------------------------------
;
;............... adjust [WidthCount] by overrun bytes ...............
;
add [WidthCount],ecx ; adjust overrun in bytes
;
;................. put x-scale roundoff bits in EDX .................
;
mov eax,ecx ; get the number of bytes we overran
neg eax ; negate it since overun is negative
add eax,[LeftClipBytes] ; add the number of bytes we leftclip
mul [ScaleX] ; convert to pixels plus roundoff bits
mov edx,0 ; clear EDX
mov dl,al ; DL = x-scaling roundoff bits
;
;................ put negative overrun pixels in ECX ................
;
shr eax,8 ; EAX = total # left pixels
sub eax,[LeftClipPixels] ; EAX = # pixels overrun
mov ecx,eax ; store # overrun pixels
neg ecx ; make it negative
;
;................ adjust dest ptr by overrun pixels .................
;
add esi,eax ; increment ESI (EDI) by overrun pixels
;--------------------------------------------------------------------
; Put shape address back into ESI, adjust EDI
;--------------------------------------------------------------------
??out:
xchg esi,edi ; xchange ESI and EDI
ret ; return back to the real function
ENDP Left_Scale_Skip
END
;**************************** End of ds_lss.asm *****************************


110
WWFLAT32/SHAPE/DS_RRS.ASM Normal file
View File

@@ -0,0 +1,110 @@
;
; Command & Conquer Red Alert(tm)
; Copyright 2025 Electronic Arts Inc.
;
; This program is free software: you can redistribute it and/or modify
; it under the terms of the GNU General Public License as published by
; the Free Software Foundation, either version 3 of the License, or
; (at your option) any later version.
;
; This program is distributed in the hope that it will be useful,
; but WITHOUT ANY WARRANTY; without even the implied warranty of
; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
; GNU General Public License for more details.
;
; You should have received a copy of the GNU General Public License
; along with this program. If not, see <http://www.gnu.org/licenses/>.
;
;***************************************************************************
;** C O N F I D E N T I A L --- W E S T W O O D A S S O C I A T E S **
;***************************************************************************
;* *
;* Project Name : Draw Shape Routines for library. *
;* *
;* File Name : DS_RRS.ASM *
;* *
;* Programmer : Scott K. Bowen *
;* *
;* Start Date : August 24, 1993 *
;* *
;* Last Update : May 28, 1994 [BR] *
;* *
;*-------------------------------------------------------------------------*
;* Functions: *
;* Right_Reverse_Skip -- Skips bytes in a data stream *
;* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - *
;********************* Model & Processor Directives ************************
IDEAL
P386
MODEL USE32 FLAT
;******************************** Includes *********************************
INCLUDE "shape.inc"
;********************************* Code ************************************
CODESEG
;***************************************************************************
;* Right_Reverse_Skip -- Skips bytes in a data stream *
;* *
;* INPUT: *
;* ECX = number of uncompressed bytes to skip *
;* ESI = shape buffer data address *
;* *
;* OUTPUT: *
;* ESI - updated to the current location in the shape data *
;* *
;* WARNINGS: This routine may overrun the number of requested bytes *
;* if it encounters a run of 0's; however, it's assumed that *
;* the shape data will never contain a run that goes past the *
;* right-hand edge of the shape. *
;* *
;* HISTORY: *
;* 04/14/1992 PWG : Created. *
;* 08/19/1993 SKB : Split drawshp.asm into several modules. *
;* 05/28/1994 BR : Converted to 32-bit *
;*=========================================================================*
PROC Right_Reverse_Skip NOLANGUAGE NEAR
;--------------------------------------------------------------------
; Put shape data address in EDI so we can do a scasb on it
;--------------------------------------------------------------------
xchg esi,edi ; xchange ESI and EDI
jecxz ??out ; exit if ECX is 0 (no bytes to skip)
;--------------------------------------------------------------------
; Search through the string and count down the info we have handled.
; If we find a run (0 followed by a count byte), then handle it.
;--------------------------------------------------------------------
??cliptop:
mov eax,0 ; set al to 0 (we're scanning for 0)
repne scasb ; scan through source data
jz ??on_run ; if it is a run then deal with it
jecxz ??out ; if we're done then get outta here
;--------------------------------------------------------------------
; If we have a run then get the next byte which is the length.
;--------------------------------------------------------------------
??on_run:
mov al,[BYTE PTR edi] ; get the count of zeros to run
inc edi ; advance past the count
inc ecx ; the 0 found doesn't count
sub ecx,eax ; subtract the count from remaining
jg ??cliptop ; if more bytes left, scan again
;--------------------------------------------------------------------
; Put shape address back into ESI, adjust EDI
;--------------------------------------------------------------------
??out:
xchg esi,edi ; xchange ESI and EDI
ret ; return back to the real function
ENDP Right_Reverse_Skip
END
;**************************** End of ds_rrs.asm ****************************


110
WWFLAT32/SHAPE/DS_RS.ASM Normal file
View File

@@ -0,0 +1,110 @@
;
; Command & Conquer Red Alert(tm)
; Copyright 2025 Electronic Arts Inc.
;
; This program is free software: you can redistribute it and/or modify
; it under the terms of the GNU General Public License as published by
; the Free Software Foundation, either version 3 of the License, or
; (at your option) any later version.
;
; This program is distributed in the hope that it will be useful,
; but WITHOUT ANY WARRANTY; without even the implied warranty of
; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
; GNU General Public License for more details.
;
; You should have received a copy of the GNU General Public License
; along with this program. If not, see <http://www.gnu.org/licenses/>.
;
;***************************************************************************
;** C O N F I D E N T I A L --- W E S T W O O D A S S O C I A T E S **
;***************************************************************************
;* *
;* Project Name : Draw Shape Routines for library. *
;* *
;* File Name : DS_RS.ASM *
;* *
;* Programmer : Scott K. Bowen *
;* *
;* Start Date : August 24, 1993 *
;* *
;* Last Update : May 28, 1994 [BR] *
;* *
;*-------------------------------------------------------------------------*
;* Functions: *
;* Right_Skip -- Skips bytes in a data stream *
;* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - *
;********************* Model & Processor Directives ************************
IDEAL
P386
MODEL USE32 FLAT
;******************************** Includes *********************************
INCLUDE "shape.inc"
;********************************* Code ************************************
CODESEG
;***************************************************************************
;* Right_Skip -- Skips bytes in a data stream *
;* *
;* INPUT: *
;* ECX = number of uncompressed bytes to skip *
;* ESI = shape buffer data address *
;* *
;* OUTPUT: *
;* ESI - updated to the current location in the shape data *
;* *
;* WARNINGS: This routine may overrun the number of requested bytes *
;* if it encounters a run of 0's; however, it's assumed that *
;* the shape data will never contain a run that goes past the *
;* right-hand edge of the shape. *
;* *
;* HISTORY: *
;* 04/14/1992 PWG : Created. *
;* 08/19/1993 SKB : Split drawshp.asm into several modules. *
;* 05/28/1994 BR : Converted to 32-bit *
;*=========================================================================*
PROC Right_Skip NOLANGUAGE NEAR
;--------------------------------------------------------------------
; Put shape data address in EDI so we can do a scasb on it
;--------------------------------------------------------------------
xchg esi,edi ; xchange ESI and EDI
jecxz ??out ; exit if ECX is 0 (no bytes to skip)
;--------------------------------------------------------------------
; Search through the string and count down the info we have handled.
; If we find a run (0 followed by a count byte), then handle it.
;--------------------------------------------------------------------
??cliptop:
mov eax,0 ; set al to 0 (we're scanning for 0)
repne scasb ; scan through source data
jz ??on_run ; if it is a run then deal with it
jecxz ??out ; if we're done then get outta here
;--------------------------------------------------------------------
; If we have a run then get the next byte which is the length.
;--------------------------------------------------------------------
??on_run:
mov al,[BYTE PTR edi] ; get the count of zeros to run
inc edi ; advance past the count
inc ecx ; the 0 found doesn't count
sub ecx,eax ; subtract the count from remaining
jg ??cliptop ; if more bytes left, scan again
;--------------------------------------------------------------------
; Put shape address back into ESI, adjust EDI
;--------------------------------------------------------------------
??out:
xchg esi,edi ; xchange ESI and EDI
ret ; return back to the real function
ENDP Right_Skip
END
;**************************** End of ds_rs.asm ******************************


110
WWFLAT32/SHAPE/DS_RSRS.ASM Normal file
View File

@@ -0,0 +1,110 @@
;
; Command & Conquer Red Alert(tm)
; Copyright 2025 Electronic Arts Inc.
;
; This program is free software: you can redistribute it and/or modify
; it under the terms of the GNU General Public License as published by
; the Free Software Foundation, either version 3 of the License, or
; (at your option) any later version.
;
; This program is distributed in the hope that it will be useful,
; but WITHOUT ANY WARRANTY; without even the implied warranty of
; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
; GNU General Public License for more details.
;
; You should have received a copy of the GNU General Public License
; along with this program. If not, see <http://www.gnu.org/licenses/>.
;
;***************************************************************************
;** C O N F I D E N T I A L --- W E S T W O O D A S S O C I A T E S **
;***************************************************************************
;* *
;* Project Name : Draw Shape Routines for library. *
;* *
;* File Name : DS_RSRS.ASM *
;* *
;* Programmer : Scott K. Bowen *
;* *
;* Start Date : August 24, 1993 *
;* *
;* Last Update : June 1, 1994 [BR] *
;* *
;*-------------------------------------------------------------------------*
;* Functions: *
;* Right_Scale_Reverse_Skip -- Skips past a scaled row of pixels *
;* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - *
;********************* Model & Processor Directives ************************
IDEAL
P386
MODEL USE32 FLAT
;******************************** Includes *********************************
INCLUDE "shape.inc"
;********************************* Code ************************************
CODESEG
;***************************************************************************
;* Right_Scale_Reverse_Skip -- Skips past a scaled row of pixels *
;* *
;* INPUT: *
;* ECX = number of uncompressed bytes to skip *
;* ESI = shape buffer data address *
;* *
;* OUTPUT: *
;* ESI - updated to the current location in the shape data *
;* *
;* WARNINGS: This routine may overrun the number of requested bytes *
;* if it encounters a run of 0's; however, it's assumed that *
;* the shape data will never contain a run that goes past the *
;* right-hand edge of the shape. *
;* *
;* HISTORY: *
;* 04/20/1992 PWG : Created. *
;* 08/19/1993 SKB : Split drawshp.asm into several modules. *
;* 06/01/1994 BR : Converted to 32-bit *
;*=========================================================================*
PROC Right_Scale_Reverse_Skip NOLANGUAGE NEAR
;--------------------------------------------------------------------
; Put shape data address in EDI so we can do a scasb on it
;--------------------------------------------------------------------
xchg esi,edi ; xchange ESI and EDI
jecxz ??out ; exit if ECX is 0 (no bytes to skip)
;--------------------------------------------------------------------
; Search through the string and count down the info we have handled.
; If we find a run (0 followed by a count byte), then handle it.
;--------------------------------------------------------------------
??cliptop:
mov eax,0 ; set al to 0 (we're scanning for 0)
repne scasb ; scan through source data
jz ??on_run ; if it is a run then deal with it
jecxz ??out ; if we're done then get outta here
;--------------------------------------------------------------------
; If we have a run then get the next byte which is the length.
;--------------------------------------------------------------------
??on_run:
mov al,[BYTE PTR edi] ; get the count of zeros to run
inc edi ; advance past the count
inc ecx ; the 0 found doesn't count
sub ecx,eax ; subtract the count from remaining
jg ??cliptop ; if more bytes left, scan again
;--------------------------------------------------------------------
; Put shape address back into ESI, adjust EDI
;--------------------------------------------------------------------
??out:
xchg esi,edi ; xchange ESI and EDI
ret ; return back to the real function
ENDP Right_Scale_Reverse_Skip
END
;*************************** End of ds_rsrs.asm ****************************


110
WWFLAT32/SHAPE/DS_RSS.ASM Normal file
View File

@@ -0,0 +1,110 @@
;
; Command & Conquer Red Alert(tm)
; Copyright 2025 Electronic Arts Inc.
;
; This program is free software: you can redistribute it and/or modify
; it under the terms of the GNU General Public License as published by
; the Free Software Foundation, either version 3 of the License, or
; (at your option) any later version.
;
; This program is distributed in the hope that it will be useful,
; but WITHOUT ANY WARRANTY; without even the implied warranty of
; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
; GNU General Public License for more details.
;
; You should have received a copy of the GNU General Public License
; along with this program. If not, see <http://www.gnu.org/licenses/>.
;
;***************************************************************************
;** C O N F I D E N T I A L --- W E S T W O O D A S S O C I A T E S **
;***************************************************************************
;* *
;* Project Name : Draw Shape Routines for library. *
;* *
;* File Name : DS_RSS.ASM *
;* *
;* Programmer : Scott K. Bowen *
;* *
;* Start Date : August 24, 1993 *
;* *
;* Last Update : June 1, 1994 [BR] *
;* *
;*-------------------------------------------------------------------------*
;* Functions: *
;* Right_Scale_Skip -- Skips past a scaled row of pixels on right side *
;* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - *
;********************* Model & Processor Directives ************************
IDEAL
P386
MODEL USE32 FLAT
;******************************** Includes *********************************
INCLUDE "shape.inc"
;********************************* Code ************************************
CODESEG
;***************************************************************************
;* Right_Scale_Skip -- Skips past a scaled row of pixels on the right side *
;* *
;* INPUT: *
;* ECX = number of uncompressed bytes to skip *
;* ESI = shape buffer data address *
;* *
;* OUTPUT: *
;* ESI - updated to the current location in the shape data *
;* *
;* WARNINGS: This routine may overrun the number of requested bytes *
;* if it encounters a run of 0's; however, it's assumed that *
;* the shape data will never contain a run that goes past the *
;* right-hand edge of the shape. *
;* *
;* HISTORY: *
;* 04/20/1992 PWG : Created. *
;* 08/19/1993 SKB : Split drawshp.asm into several modules. *
;* 06/01/1994 BR : Converted to 32-bit *
;*=========================================================================*
PROC Right_Scale_Skip NOLANGUAGE NEAR
;--------------------------------------------------------------------
; Put shape data address in EDI so we can do a scasb on it
;--------------------------------------------------------------------
xchg esi,edi ; xchange ESI and EDI
jecxz ??out ; exit if ECX is 0 (no bytes to skip)
;--------------------------------------------------------------------
; Search through the string and count down the info we have handled.
; If we find a run (0 followed by a count byte), then handle it.
;--------------------------------------------------------------------
??cliptop:
mov eax,0 ; set al to 0 (we're scanning for 0)
repne scasb ; scan through source data
jz ??on_run ; if it is a run then deal with it
jecxz ??out ; if we're done then get outta here
;--------------------------------------------------------------------
; If we have a run then get the next byte which is the length.
;--------------------------------------------------------------------
??on_run:
mov al,[BYTE PTR edi] ; get the count of zeros to run
inc edi ; advance past the count
inc ecx ; the 0 found doesn't count
sub ecx,eax ; subtract the count from remaining
jg ??cliptop ; if more bytes left, scan again
;--------------------------------------------------------------------
; Put shape address back into ESI, adjust EDI
;--------------------------------------------------------------------
??out:
xchg esi,edi ; xchange ESI and EDI
ret ; return back to the real function
ENDP Right_Scale_Skip
END
;*************************** End of ds_rss.asm *****************************


187
WWFLAT32/SHAPE/DS_TABLE.ASM Normal file
View File

@@ -0,0 +1,187 @@
;
; Command & Conquer Red Alert(tm)
; Copyright 2025 Electronic Arts Inc.
;
; This program is free software: you can redistribute it and/or modify
; it under the terms of the GNU General Public License as published by
; the Free Software Foundation, either version 3 of the License, or
; (at your option) any later version.
;
; This program is distributed in the hope that it will be useful,
; but WITHOUT ANY WARRANTY; without even the implied warranty of
; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
; GNU General Public License for more details.
;
; You should have received a copy of the GNU General Public License
; along with this program. If not, see <http://www.gnu.org/licenses/>.
;
;***************************************************************************
;** C O N F I D E N T I A L --- W E S T W O O D A S S O C I A T E S **
;***************************************************************************
;* *
;* Project Name : Draw Shape Routines for library. *
;* *
;* File Name : DS_TABLE.ASM *
;* *
;* Programmer : Scott K. Bowen *
;* *
;* Start Date : August 20, 1993 *
;* *
;* Last Update : September 6, 1994 [IML] *
;* *
;* This module sets up a table of procedure addresses for combinations of *
;* NORMAL, HORZ_REV and SCALING flags. *
;*-------------------------------------------------------------------------*
;* Functions: *
;* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - *
;********************** Model & Processor Directives ************************
IDEAL
P386
MODEL USE32 FLAT
;******************************** Includes *********************************
INCLUDE "shape.inc"
;******************************** Equates **********************************
;*=========================================================================*/
;* The following are defines used to control what functions are linked *
;* in for Draw_Shape. *
;*=========================================================================*/
USE_NORMAL EQU TRUE
USE_HORZ_REV EQU TRUE
USE_VERT_REV EQU TRUE
USE_SCALING EQU TRUE
;---------------------------------------------------------------------------
;
; Use a macro to make code a little cleaner.
; The parameter varname is optional.
; Syntax to use macro is :
; WANT equ expression
; USE func [,varname]
; If the 'varname' is defined, a table declaration is created like:
; GLOBAL TableName:DWORD
; Then, the table entry is created:
; If WANT is true, the table entry is created for the given function:
; varname DD func
; If WANT is not TRUE, a Not_Supported entry is put in the table:
; varname DD Not_Supported
; The resulting tables look like:
;
; GLOBAL ExampTable:DWORD
; ExampTable DD routine1
; DD routine2
; DD routine3
; ...
; Thus, each table is an array of function pointers.
;
;---------------------------------------------------------------------------
MACRO USE func, varname
IFNB <varname>
GLOBAL varname:DWORD
ENDIF
IF WANT
varname DD func
ELSE
varname DD Not_Supported
ENDIF
ENDM
;---------------------------------------------------------------------------
; Data Segment Tables:
; This code uses the USE macro to set up tables of function addresses.
; The tables have the following format:
; Tables defined are:
; LSkipTable
; RSkipTable
; DrawTable
;---------------------------------------------------------------------------
DATASEG
;---------------------------------------------------------------------------
WANT equ <TRUE>
USE Left_Skip, LSkipTable
WANT equ <TRUE>
USE Left_Reverse_Skip
WANT equ <TRUE>
USE Left_Skip
WANT equ <TRUE>
USE Left_Reverse_Skip
WANT equ <USE_SCALING>
USE Left_Scale_Skip
WANT equ <USE_SCALING>
USE Left_Scale_Reverse_Skip
WANT equ <USE_SCALING>
USE Left_Scale_Skip
WANT equ <USE_SCALING>
USE Left_Scale_Reverse_Skip
;---------------------------------------------------------------------------
WANT equ <TRUE>
USE Right_Skip, RSkipTable
WANT equ <TRUE>
USE Right_Reverse_Skip
WANT equ <TRUE>
USE Right_Skip
WANT equ <TRUE>
USE Right_Reverse_Skip
WANT equ <USE_SCALING>
USE Right_Scale_Skip
WANT equ <USE_SCALING>
USE Right_Scale_Reverse_Skip
WANT equ <USE_SCALING>
USE Right_Scale_Skip
WANT equ <USE_SCALING>
USE Right_Scale_Reverse_Skip
;---------------------------------------------------------------------------
WANT equ <TRUE>
USE Draw_Normal, DrawTable
WANT equ <TRUE>
USE Draw_Reverse
WANT equ <TRUE>
USE Draw_Normal
WANT equ <TRUE>
USE Draw_Reverse
WANT equ <USE_SCALING>
USE Draw_Scale
WANT equ <USE_SCALING>
USE Draw_Scale_Reverse
WANT equ <USE_SCALING>
USE Draw_Scale
WANT equ <USE_SCALING>
USE Draw_Scale_Reverse
;---------------------------------------------------------------------------
;---------------------------------------------------------------------------
END
;************************** End of ds_table.asm ****************************

362
WWFLAT32/SHAPE/GETSHAPE.CPP Normal file
View File

@@ -0,0 +1,362 @@
/*
** 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 : GETSHAPE.CPP *
* *
* Programmer : Joe L. Bostic *
* *
* Start Date : April 5, 1992 *
* *
* Last Update : May 25, 1994 [BR] *
* *
*-------------------------------------------------------------------------*
* Functions: *
* Get_Shape_Size -- Fetch the size of the shape in memory. *
* Get_Shape_Uncomp_Size -- gets shape's uncompressed size in bytes *
* Get_Shape_Data -- retrieves a shape's special prefix data *
* Extract_Shape_Count -- returns # of shapes in the given shape block *
* Extract_Shape -- Gets pointer to shape in given shape block *
* Get_Shape_Width -- gets shape width in pixels *
* Get_Shape_Height -- gets shape height in pixels *
* Set_Shape_Height -- modifies shape's height *
* Restore_Shape_Height -- restores a shape to its original height *
* Get_Shape_Original_Height -- gets shape's unmodified height *
* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
/*
********************************* Includes **********************************
*/
#include "wwstd.h"
#include "shape.h"
/***************************************************************************
* Get_Shape_Size -- Fetch the size of the shape in memory. *
* *
* The shape size returned includes both the shape header & its data. *
* *
* INPUT: *
* shape pointer to shape *
* *
* OUTPUT: *
* shape's size in memory *
* *
* WARNINGS: *
* none *
* *
* HISTORY: *
* 06/09/1992 JLB : Created. *
* 08/19/1993 SKB : Split drawshp.asm into several modules. *
* 05/25/1994 BR : Converted to 32-bit *
*=========================================================================*/
int cdecl Get_Shape_Size(VOID const *shape)
{
Shape_Type *shp = (Shape_Type *)shape;
/*
------------------------- Return if NULL pointer -------------------------
*/
if (!shape)
return(0);
/*
-------------------------- Returns shape's size --------------------------
*/
return (shp->ShapeSize);
} /* end of Get_Shape_Size */
/***************************************************************************
* Get_Shape_Uncomp_Size -- gets shape's uncompressed size in bytes *
* *
* INPUT: *
* shape pointer to shape *
* *
* OUTPUT: *
* shape's size in bytes when uncompressed *
* *
* WARNINGS: *
* none *
* *
* HISTORY: *
* 06/09/1992 JLB : Created. *
* 08/19/1993 SKB : Split drawshp.asm into several modules. *
* 05/25/1994 BR : Converted to 32-bit *
*=========================================================================*/
int Get_Shape_Uncomp_Size(VOID const *shape)
{
Shape_Type *shp = (Shape_Type *)shape;
return (shp->DataLength);
} /* end of Get_Shape_Uncomp_Size */
/***************************************************************************
* Get_Shape_Data -- retrieves a shape's special prefix data *
* *
* MAKESHPS.EXE can store special data values along with a shape. These *
* values are inserted in the shape table >before< the shape's header. *
* So, this routine uses the 'data' parameter as a negative index from *
* the given shape pointer. *
* *
* INPUT: *
* shape pointer to shape *
* data index of WORD data value to get *
* *
* OUTPUT: *
* data value *
* *
* WARNINGS: *
* The shape pointer must be a pointer into a shape table created by *
* MAKESHPS.EXE; it >cannot< be a pointer to shape returned by Make_Shape! *
* *
* HISTORY: *
* 06/09/1992 JLB : Created. *
* 08/19/1993 SKB : Split drawshp.asm into several modules. *
* 05/25/1994 BR : Converted to 32-bit *
*=========================================================================*/
WORD cdecl Get_Shape_Data(VOID const *shape, WORD data)
{
WORD *word_ptr = (WORD *)shape;
WORD retval;
retval = *(word_ptr - (data+1));
return (retval);
} /* end of Get_Shape_Data */
/***************************************************************************
* Extract_Shape_Count -- returns # of shapes in the given shape block *
* *
* The # of shapes in a shape block is the first WORD in the block, so *
* this is the value returned. *
* *
* INPUT: *
* buffer pointer to shape block, created with MAKESHPS.EXE *
* *
* OUTPUT: *
* # shapes in the block *
* *
* WARNINGS: *
* none *
* *
* HISTORY: *
* 06/09/1992 JLB : Created. *
* 08/19/1993 SKB : Split drawshp.asm into several modules. *
* 05/25/1994 BR : Converted to 32-bit *
*=========================================================================*/
int cdecl Extract_Shape_Count(VOID const *buffer)
{
ShapeBlock_Type *block = (ShapeBlock_Type *)buffer;
return (block->NumShapes);
} /* end of Extract_Shape_Count */
/***************************************************************************
* Extract_Shape -- Gets pointer to shape in given shape block *
* *
* INPUT: *
* buffer pointer to shape block, created with MAKESHPS.EXE *
* shape index of shape to get *
* *
* OUTPUT: *
* pointer to shape in the shape block *
* *
* WARNINGS: *
* none *
* *
* HISTORY: *
* 06/09/1992 JLB : Created. *
* 08/19/1993 SKB : Split drawshp.asm into several modules. *
* 05/25/1994 BR : Converted to 32-bit *
*=========================================================================*/
VOID * cdecl Extract_Shape(VOID const *buffer, int shape)
{
ShapeBlock_Type *block = (ShapeBlock_Type*) buffer;
int numshapes; // Number of shapes
long offset; // Offset of shape data, from start of block
char *bytebuf = (char*) buffer;
/*
----------------------- Return if invalid argument -----------------------
*/
if (!buffer || shape < 0 || shape >= block->NumShapes)
return(NULL);
offset = block->Offsets[shape];
return(bytebuf + 2 + offset);
} /* end of Extract_Shape */
/***************************************************************************
* Get_Shape_Width -- gets shape width in pixels *
* *
* INPUT: *
* shape pointer to a shape *
* *
* OUTPUT: *
* shape width in pixels *
* *
* WARNINGS: *
* none *
* *
* HISTORY: *
* 06/09/1992 JLB : Created. *
* 08/19/1993 SKB : Split drawshp.asm into several modules. *
* 05/25/1994 BR : Converted to 32-bit *
*=========================================================================*/
int Get_Shape_Width(VOID const *shape)
{
Shape_Type *shp = (Shape_Type *)shape;
return (shp->Width);
} /* end of Get_Shape_Width */
/***************************************************************************
* Get_Shape_Height -- gets shape height in pixels *
* *
* INPUT: *
* shape pointer to a shape *
* *
* OUTPUT: *
* shape height in pixels *
* *
* WARNINGS: *
* none *
* *
* HISTORY: *
* 06/09/1992 JLB : Created. *
* 08/19/1993 SKB : Split drawshp.asm into several modules. *
* 05/25/1994 BR : Converted to 32-bit *
*=========================================================================*/
int Get_Shape_Height(VOID const *shape)
{
Shape_Type *shp = (Shape_Type *)shape;
return (shp->Height);
} /* end of Get_Shape_Height */
/***************************************************************************
* Set_Shape_Height -- modifies shape's height *
* *
* The new height must be shorter than the original height. This effect *
* chops off the lower portion of the shape, like it's sinking into the *
* ground. *
* *
* INPUT: *
* shape pointer to a shape *
* newheight new shape height *
* *
* OUTPUT: *
* old shape height *
* *
* WARNINGS: *
* none *
* *
* HISTORY: *
* 06/09/1992 JLB : Created. *
* 08/19/1993 SKB : Split drawshp.asm into several modules. *
* 05/25/1994 BR : Converted to 32-bit *
*=========================================================================*/
int cdecl Set_Shape_Height(VOID const *shape, WORD newheight)
{
Shape_Type *shp = (Shape_Type *)shape;
WORD oldheight;
oldheight = shp->Height;
shp->Height = newheight;
return(oldheight);
} /* end of Set_Shape_Height */
/***************************************************************************
* Restore_Shape_Height -- restores a shape to its original height *
* *
* INPUT: *
* shape pointer to a shape *
* *
* OUTPUT: *
* old shape height *
* *
* WARNINGS: *
* *
* HISTORY: *
* 06/09/1992 JLB : Created. *
* 08/19/1993 SKB : Split drawshp.asm into several modules. *
* 05/25/1994 BR : Converted to 32-bit *
*=========================================================================*/
int cdecl Restore_Shape_Height(VOID *shape)
{
Shape_Type *shp = (Shape_Type *)shape;
WORD oldheight;
oldheight = shp->Height;
shp->Height = shp->OriginalHeight;
return(oldheight);
} /* end of Restore_Shape_Height */
/***************************************************************************
* Get_Shape_Original_Height -- gets shape's unmodified height *
* *
* INPUT: *
* shape pointer to a shape *
* *
* OUTPUT: *
* shape's unmodified height *
* *
* WARNINGS: *
* none *
* *
* HISTORY: *
* 06/09/1992 JLB : Created. *
* 08/19/1993 SKB : Split drawshp.asm into several modules. *
* 05/25/1994 BR : Converted to 32-bit *
*=========================================================================*/
int Get_Shape_Original_Height(VOID const *shape)
{
Shape_Type *shp = (Shape_Type *)shape;
return (shp->OriginalHeight);
} /* end of Get_Shape_Original_Height */
/************************* end of getshape.cpp *****************************/

195
WWFLAT32/SHAPE/MAKEFILE Normal file
View File

@@ -0,0 +1,195 @@
#
# 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 25, 1995 *
#* *
#* *
#*-------------------------------------------------------------------------*
#* *
#* Required environment variables: *
#* WWFLAT = your root WWFLAT path *
#* WWVCS = root directory for wwlib version control archive *
#* WATCOM = 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 %WWFLAT
!error WWFLAT Environment var not configured.
!endif
!ifndef %WWVCS
!error WWVCS 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 = shape
PROJ_DIR = $(%WWFLAT)\$(PROJ_NAME)
LIB_DIR = $(%WWFLAT)\lib
!include $(%WWFLAT)\project.cfg
#---------------------------------------------------------------------------
# Project-dependent variables
#---------------------------------------------------------------------------
OBJECTS = &
getshape.obj &
prioinit.obj &
drawshp.obj &
ds_dn.obj &
ds_dr.obj &
ds_ds.obj &
ds_dsr.obj &
ds_lrs.obj &
ds_ls.obj &
ds_lsrs.obj &
ds_lss.obj &
ds_rrs.obj &
ds_rs.obj &
ds_rsrs.obj &
ds_rss.obj &
ds_table.obj &
setshape.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: $(%WWFLAT)\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 = $(%WWFLAT)\LIB;$(%WATCOM)\LIB
INCLUDEPATH = $(%WWFLAT)\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: $(%WWFLAT)\project.cfg .AUTODEPEND
$(C_CMD) $(CC_CFG) $<
.cpp.obj: $(%WWFLAT)\project.cfg .AUTODEPEND
$(CPP_CMD) $(CC_CFG) $<
.asm.obj: $(%WWFLAT)\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 WWFLAT\SRCDEBUG, for debugging
#---------------------------------------------------------------------------
$(LIB_DIR)\$(PROJ_NAME).lib: $(OBJECTS) objects.lbc
copy *.h $(%WWFLAT)\include
copy *.inc $(%WWFLAT)\include
copy *.cpp $(%WWFLAT)\srcdebug
copy *.asm $(%WWFLAT)\srcdebug
$(LIB_CMD) $(LIB_CFG) $^@ @objects.lbc
#---------------------------------------------------------------------------
# Objects now have a link file which is NOT generated everytime. Instead
# it just has its own dependacy rule.
#---------------------------------------------------------------------------
objects.lbc : $(OBJECTS)
%create $^@
for %index in ($(OBJECTS)) do %append $^@ +%index
#---------------------------------------------------------------------------
# Create the test directory and make it.
#---------------------------------------------------------------------------
test:
mkdir test
cd test
copy $(%WWVCS)\$(PROJ_NAME)\test\vcs.cfg
update
wmake
cd ..
#**************************** End of makefile ******************************

View File

@@ -0,0 +1,72 @@
/*
** 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 : Memory system. *
* *
* File Name : PRIOINIT.CPP *
* *
* Programmer : Ian M. Leslie *
* *
* Start Date : August 9, 1993 *
* *
* Last Update : August 9, 1994 [IML] *
* *
*-------------------------------------------------------------------------*
* Functions: *
* INIT_PRIORITY_SYSTEM -- Sets the buffer addresses for the priority *
* system. *
* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
#include "shape.h"
/*=========================================================================*/
/* The following PRIVATE functions are in this file: */
/*=========================================================================*/
/*= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =*/
/***************************************************************************
* Init_Priority_System -- set the buffer addresses for the priority *
* system. *
* *
* INPUT: *
* mask - pointer to priority buffer class *
* back - pointer to background buffer class *
* *
* OUTPUT: *
* none *
* *
* HISTORY: *
* 08/09/1994 IML : Created. *
*=========================================================================*/
VOID cdecl Init_Priority_System (GraphicBufferClass *mask,
GraphicBufferClass *back)
{
MaskPage = mask->Get_Buffer();
BackGroundPage = back->Get_Buffer();
}
/************************** end of prioinit.cpp ****************************/

View File

@@ -0,0 +1,81 @@
;
; 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 *
;* *
;* File Name : SETSHAPE.ASM *
;* *
;* Programmer : Phil W. Gorrow *
;* *
;* Start Date : October 26, 1994 *
;* *
;* Last Update : October 26, 1994 [PWG] *
;* *
;*-------------------------------------------------------------------------*
;* Functions: *
;* Set_Shape_Buffer -- Sets the shape buffer to the given pointer *
;* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - *
IDEAL
P386
MODEL USE32 FLAT
;******************************** Includes *********************************
INCLUDE "shape.inc"
CODESEG
;***************************************************************************
;* SET_SHAPE_BUFFER -- Sets the shape buffer to the given pointer *
;* *
;* This routine will set the shape buffer to the given value and make sure *
;* that the system does not try to compress any shapes that will be larger *
;* than the shape buffer. *
;* *
;* INPUT: void * - pointer to the shape buffer *
;* int - size of the buffer which has been passed in *
;* *
;* OUTPUT: none *
;* *
;* PROTO: VOID *Set_Shape_Bufer(void *buffer, int size); *
;* *
;* HISTORY: *
;* 10/26/1994 PWG : Created. *
;*=========================================================================*
GLOBAL Set_Shape_Buffer:NEAR
PROC Set_Shape_Buffer C near
USES eax
ARG buff:DWORD
ARG size:DWORD
mov eax,[size]
mov [_ShapeBufferSize],eax
mov eax,[buff]
mov [_ShapeBuffer],eax
ret
ENDP Set_Shape_Buffer
END


167
WWFLAT32/SHAPE/SHAPE.H Normal file
View File

@@ -0,0 +1,167 @@
/*
** 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 *
* *
* File Name : SHAPE.H *
* *
* Programmer : Bill Randolph *
* *
* Start Date : May 25, 1994 *
* *
* Last Update : September 14, 1994 [IML] *
* *
* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
#ifndef SHAPE_H
#define SHAPE_H
#ifndef GBUFFER_H
#include "gbuffer.h"
#endif
/*
*********************************** Types ***********************************
*/
/*
--------------------------- Shape creation flags ----------------------------
*/
typedef enum {
MAKESHAPE_NORMAL = 0x0000, // 256-color compressed shape
MAKESHAPE_COMPACT = 0x0001, // 16-color shape (with built-in color table)
MAKESHAPE_NOCOMP = 0x0002, // Uncompressed shape
MAKESHAPE_VARIABLE = 0x0004 // <16-color shape
} MakeShapeFlags_Type;
/*---------------------------------------------------------------------------
Shape drawing flags:
- The low byte is for coordinate transformations.
- The high byte is for drawing effects.
---------------------------------------------------------------------------*/
typedef enum {
SHAPE_NORMAL = 0x0000, // Standard shape
SHAPE_HORZ_REV = 0x0001, // Flipped horizontally
SHAPE_VERT_REV = 0x0002, // Flipped vertically
SHAPE_SCALING = 0x0004, // Scaled (WORD scale_x, WORD scale_y)
SHAPE_VIEWPORT_REL = 0x0010, // Coords are window-relative
SHAPE_WIN_REL = 0x0010, // Coordinates are window relative instead of absolute.
SHAPE_CENTER = 0x0020, // Coords are based on shape's center pt
SHAPE_FADING = 0x0100, // Fading effect (VOID * fading_table,
// WORD fading_num)
SHAPE_PREDATOR = 0x0200, // Transparent warping effect
SHAPE_COMPACT = 0x0400, // Never use this bit
SHAPE_PRIORITY = 0x0800, // Use priority system when drawing
SHAPE_GHOST = 0x1000, // Shape is drawn ghosted
SHAPE_SHADOW = 0x2000,
SHAPE_PARTIAL = 0x4000,
SHAPE_COLOR = 0x8000 // Remap the shape's colors
// (VOID * color_table)
} ShapeFlags_Type;
/*
------------------------------- Shape header --------------------------------
*/
typedef struct {
UWORD ShapeType; // 0 = normal, 1 = 16 colors,
// 2 = uncompressed, 4 = <16 colors
UBYTE Height; // Height of the shape in scan lines
UWORD Width; // Width of the shape in bytes
UBYTE OriginalHeight; // Original height of shape in scan lines
UWORD ShapeSize; // Size of the shape, including header
UWORD DataLength; // Size of the uncompressed shape (just data)
UBYTE Colortable[16]; // Optional color table for compact shape
} Shape_Type;
/*
------------------------------- Shape block ---------------------------------
*/
typedef struct {
UWORD NumShapes; // number of shapes in the block
LONG Offsets[]; // array of offsets to shape data
// (offsets within the shape block, with
// 0 being the first offset value, not the
// start of the shape block)
} ShapeBlock_Type;
/*
******************************** Prototypes *********************************
*/
/*
-------------------------------- prioinit.c ---------------------------------
*/
extern "C" {
extern VOID *MaskPage;
extern VOID *BackGroundPage;
extern LONG _ShapeBufferSize;
extern BYTE *_ShapeBuffer;
}
VOID cdecl Init_Priority_System (GraphicBufferClass *mask,
GraphicBufferClass *back);
/*
-------------------------------- drawshp.asm --------------------------------
*/
extern "C" {
WORD Draw_Shape(GraphicViewPortClass *gvp, VOID const *shape, LONG x, LONG y, LONG flags, ...);
}
/*
---------------------------------- shape.c ----------------------------------
*/
short cdecl Get_Shape_Data(VOID const *shape, WORD data);
int cdecl Extract_Shape_Count(VOID const *buffer);
void * cdecl Extract_Shape(VOID const *buffer, int shape);
int cdecl Restore_Shape_Height(VOID *shape);
int cdecl Set_Shape_Height(VOID const *shape, WORD newheight);
extern "C" {
int Get_Shape_Width(VOID const *shape);
int Get_Shape_Height(VOID const *shape);
int Get_Shape_Original_Height(VOID const *shape);
int Get_Shape_Uncomp_Size(VOID const *shape);
}
/*
------------------------------- setshape.asm --------------------------------
*/
extern "C" {
VOID Set_Shape_Buffer(void const *buffer, int size);
}
/*
------------------------------- shapeinf.asm --------------------------------
*/
WORD cdecl Get_Shape_Flags(VOID const *shape);
int cdecl Get_Shape_Size(VOID const *shape);
int cdecl Get_Shape_Scaled_Width(VOID const *shape, WORD scale);
int cdecl Get_Shape_Scaled_Height(VOID const *shape, WORD scale);
#endif // SHAPE_H
/****************************** End of shape.h *****************************/



214
WWFLAT32/SHAPE/SHAPE.INC Normal file
View File

@@ -0,0 +1,214 @@
;
; 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 *
;* *
;* File Name : SHAPE.INC *
;* *
;* Programmer : Scott Bowen *
;* *
;* Start Date : May 25, 1994 *
;* *
;* Last Update : September 14, 1994 [IML] *
;* *
;* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - *
;****************************** Equates ************************************
;
;............................ Shape Types ..................................
;
TRUE equ 1 ; Boolean 'true' value
FALSE equ 0 ; Boolean 'false' value
MAKESHAPE_NORMAL EQU 0 ; 256-color compressed shape
MAKESHAPE_COMPACT EQU 1 ; 16-color shape (built-in color table)
MAKESHAPE_NOCOMP EQU 2 ; non-wwcomped shape
MAKESHAPE_VARIABLE EQU 4 ; <16-color shape with variable #
; of colors (ColorTable[0] = # of colors)
; old names:
;COLOR_SHAPE EQU 1 ; flag which determines a color shape
;NORM_SHAPE EQU 2 ; flag that indicates non wwcomped shp
;NORM_SHAPE_16 EQU 4 ; flag that tells us if we have a variable sized table
; variable sized table
;
;...........................................................................
; Drawing flags:
; The low byte is for coordinate transformations.
; The high byte is for drawing effects.
;...........................................................................
;
SHAPE_NORMAL EQU 0000h ; no options; just a copy
SHAPE_HORZ_REV EQU 0001h ; reverse horizontally
SHAPE_VERT_REV EQU 0002h ; reverse vertically
SHAPE_SCALING EQU 0004h ; scale
SHAPE_VIEWPORT_REL EQU 0010h ; viewport-relative coordinates
SHAPE_CENTER EQU 0020h ; use centered coordinates
SHAPE_FADING EQU 0100h ; fading effect shape
SHAPE_PREDATOR EQU 0200h ; predator effect shape
SHAPE_COMPACT EQU 0400h ; shape is in 16 colors
SHAPE_PRIORITY EQU 0800h ; priority draw shape
SHAPE_GHOST EQU 1000h ; ghosting effect
SHAPE_SHADOW EQU 2000h ; shadow effect
SHAPE_PARTIAL EQU 4000h ; partial predator effect
SHAPE_COLOR EQU 8000h ; use alternative color table effect
SHAPE_EFFECTS EQU 03F00h ; shape effect flags
;
;.......................... Shadow Effect ..................................
;
SHADOW_COL EQU 00FFh ; magic number for shadows
;......................... Priority System .................................
;
CLEAR_UNUSED_BITS EQU 0007h ; and with 0000-0111 to clear
; non-walkable high bit and
; scaling id bits
NON_WALKABLE_BIT EQU 0080h ; and with 1000-0000 to clear all
; but non-walkable bit
;
;......................... Predator Effect .................................
;
PRED_MASK EQU 0007h ; mask used for predator pixel puts
;---------------------------------------------------------------------------
; This table is a list of the local stack variables in the function
; Draw_Shape. Many other functions in other modules access these variables
; on the stack. Since the BP is not changed when these other functions are
; called by Draw_Shape (possibly indirectly), they can also access these
; stack varibles. When adding or removing from the table, one must be very
; careful to change the offsets.
;---------------------------------------------------------------------------
;.......................... proc addresses .................................
LSkipRout EQU DWORD PTR ebp - 04h ;DWORD pointer to the skip routine
RSkipRout EQU DWORD PTR ebp - 08h ;DWORD pointer to the skip routine
DrawRout EQU DWORD PTR ebp - 0Ch ;DWORD pointer to the draw routine
;........................ optional arguments ...............................
ColorTable EQU DWORD PTR ebp - 10h ;DWORD ptr to the shapes color table
FadingTable EQU DWORD PTR ebp - 14h ;DWORD ptr to the fading table
FadingNum EQU DWORD PTR ebp - 18h ;DWORD number of times to fade
IsTranslucent EQU DWORD PTR ebp - 1Ch ;DWORD ptr to is_translucent table
Translucent EQU DWORD PTR ebp - 20h ;DWORD ptr to actual translucent tbl
PriLevel EQU BYTE PTR ebp - 24h ;BYTE priority level of the object
ScaleX EQU DWORD PTR ebp - 28h ;DWORD the x increment to scale by
ScaleY EQU DWORD PTR ebp - 2Ch ;DWORD the y increment to scale by
ShadowingTable EQU DWORD PTR ebp - 30h ;DWORD ptr to the shadowing table
;........................ Shape header values ..............................
ShapeType EQU DWORD PTR ebp - 34h ;DWORD shape type
ShapeWidth EQU DWORD PTR ebp - 38h ;DWORD shape's unscaled width
ShapeHeight EQU DWORD PTR ebp - 3Ch ;DWORD shape's unscaled height
UncompDataLen EQU DWORD PTR ebp - 40h ;DWORD uncompressed data length
ShapeData EQU DWORD PTR ebp - 44h ;DWORD pointer to shape data
;...................... Scaled shape dimensions ............................
ScaledWidth EQU DWORD PTR ebp - 48h ;DWORD shape's scaled width
ScaledHeight EQU DWORD PTR ebp - 4Ch ;DWORD shape's scaled height
;...................... Pixel clipping variables ...........................
LeftClipPixels EQU DWORD PTR ebp - 50h ;DWORD # left-clipped pixels
RightClipPixels EQU DWORD PTR ebp - 54h ;DWORD # right-clipped pixels
TopClipPixels EQU DWORD PTR ebp - 58h ;DWORD # top-clipped pixels
BotClipPixels EQU DWORD PTR ebp - 5Ch ;DWORD # bottom-clipped pixels
PixelWidth EQU DWORD PTR ebp - 60h ;DWORD drawable area in pixels
PixelHeight EQU DWORD PTR ebp - 64h ;DWORD drawable area in pixels
;......................... Drawing variables ...............................
NumColors EQU DWORD PTR ebp - 68h ;DWORD # colors for 16-color shapes
StartDraw EQU DWORD PTR ebp - 6Ch ;DWORD offset of drawing start pos
NextLine EQU DWORD PTR ebp - 70h ;DWORD offset of next drawing line
LeftClipBytes EQU DWORD PTR ebp - 74h ;DWORD # left-clipped bytes
XTotal EQU DWORD PTR ebp - 78h ;DWORD accumulated x-pixels
XTotalInit EQU DWORD PTR ebp - 7Ch ;DWORD initial roundoff for XTotal
YTotal EQU DWORD PTR ebp - 80h ;DWORD accumulated y-pixels
HeightCount EQU DWORD PTR ebp - 84h ;DWORD ht counter for drawing lines
LineStart EQU DWORD PTR ebp - 88h ;DWORD address of start of line
WidthCount EQU DWORD PTR ebp - 8Ch ;DWORD counts down # bytes skipped
StashReg EQU DWORD PTR ebp - 90h ;DWORD temp variable for draw routines
MaskAdjust EQU DWORD PTR ebp - 94h ;DWORD priority buffer offset
BackAdjust EQU DWORD PTR ebp - 98h ;DWORD background buffer offset
StashECX EQU DWORD PTR ebp - 9Ch ;DWORD temp variable for ECX register
StashEDX EQU DWORD PTR ebp -0A0h ;DWORD temp variable for EDX register
Local_Size EQU 00A4h ; Amt of data on stack: 4+last offset
;****************************** Declarations *******************************
;---------------------------------------------------------------------------
; Global variables used by the shape routines, defined in drawshp.asm
;---------------------------------------------------------------------------
GLOBAL _ShapeBuffer:DWORD
GLOBAL _ShapeBufferSize:DWORD
GLOBAL _MaskPage:DWORD
GLOBAL _BackGroundPage:DWORD
GLOBAL PredCount:DWORD
GLOBAL PredTable:BYTE
GLOBAL PredValue:DWORD
GLOBAL PartialPred:DWORD
GLOBAL PartialCount:DWORD
GLOBAL Flags:DWORD
;---------------------------------------------------------------------------
; External tables that are defined in ds_table.asm.
;---------------------------------------------------------------------------
GLOBAL LSkipTable:DWORD
GLOBAL RSkipTable:DWORD
GLOBAL DrawTable:DWORD
;------------------------------------------------------------------------------
; Public functions, declared in the order they appear in the function tables.
;--------------------------------------------------------------------------------
GLOBAL C Not_Supported:NEAR
; LSkipTable:
GLOBAL Left_Skip:NEAR ; ds_ls
GLOBAL Left_Reverse_Skip:NEAR ; ds_lrs
GLOBAL Left_Skip:NEAR ; ds_ls
GLOBAL Left_Reverse_Skip:NEAR ; ds_lrs
GLOBAL Left_Scale_Skip:NEAR ; ds_lss
GLOBAL Left_Scale_Reverse_Skip:NEAR ; ds_lsrs
GLOBAL Left_Scale_Skip:NEAR ; ds_lss
GLOBAL Left_Scale_Reverse_Skip:NEAR ; ds_lsrs
; RSkipTable:
GLOBAL Right_Skip:NEAR ; ds_rs
GLOBAL Right_Reverse_Skip:NEAR ; ds_rrs
GLOBAL Right_Skip:NEAR ; ds_rs
GLOBAL Right_Reverse_Skip:NEAR ; ds_rrs
GLOBAL Right_Scale_Skip:NEAR ; ds_rss
GLOBAL Right_Scale_Reverse_Skip:NEAR ; ds_rsrs
GLOBAL Right_Scale_Skip:NEAR ; ds_rss
GLOBAL Right_Scale_Reverse_Skip:NEAR ; ds_rsrs
; DrawTable:
GLOBAL Draw_Normal:NEAR ; ds_dn
GLOBAL Draw_Reverse:NEAR ; ds_dr
GLOBAL Draw_Normal:NEAR ; ds_dn
GLOBAL Draw_Reverse:NEAR ; ds_dr
GLOBAL Draw_Scale:NEAR ; ds_ds
GLOBAL Draw_Scale_Reverse:NEAR ; ds_dsr
GLOBAL Draw_Scale:NEAR ; ds_ds
GLOBAL Draw_Scale_Reverse:NEAR ; ds_dsr
;************************* End of shape.inc ********************************