mirror of
https://github.com/jmarshall23/CnC_Remastered_Collection.git
synced 2026-08-17 08:50:29 +02:00
ASM files removed, functions replaced with bits from Chronoshift.
This commit is contained in:
@@ -28,6 +28,8 @@ class GraphicBufferClass;
|
||||
/* Define functions which have not under-gone name mangling */
|
||||
/*=========================================================================*/
|
||||
|
||||
long __cdecl Buffer_To_Buffer(GraphicViewPortClass* vp, int x, int y, int w, int h, void* buffer, int length);
|
||||
|
||||
extern "C" {
|
||||
/*======================================================================*/
|
||||
/* Externs for all of the common functions between the video buffer */
|
||||
@@ -38,7 +40,6 @@ extern "C" {
|
||||
void __cdecl Buffer_Put_Pixel(void * thisptr, int x, int y, unsigned char color);
|
||||
int __cdecl Buffer_Get_Pixel(void * thisptr, int x, int y);
|
||||
void __cdecl Buffer_Clear(void *thisptr, unsigned char color);
|
||||
long __cdecl Buffer_To_Buffer(void *thisptr, int x, int y, int w, int h, void *buff, long size);
|
||||
long __cdecl Buffer_To_Page(int x, int y, int w, int h, void *Buffer, void *view);
|
||||
BOOL __cdecl Linear_Blit_To_Linear( void *thisptr, void * dest, int x_pixel, int y_pixel, int dx_pixel,
|
||||
int dy_pixel, int pixel_width, int pixel_height, BOOL trans);
|
||||
|
||||
@@ -1,288 +0,0 @@
|
||||
;
|
||||
; Copyright 2020 Electronic Arts Inc.
|
||||
;
|
||||
; TiberianDawn.DLL and RedAlert.dll and corresponding source code 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.
|
||||
|
||||
; TiberianDawn.DLL and RedAlert.dll and corresponding source code is distributed
|
||||
; in the hope that it will be useful, but with permitted additional restrictions
|
||||
; under Section 7 of the GPL. See the GNU General Public License in LICENSE.TXT
|
||||
; distributed with this program. You should have received a copy of the
|
||||
; GNU General Public License along with permitted additional restrictions
|
||||
; with this program. If not, see [https://github.com/electronicarts/CnC_Remastered_Collection]>.
|
||||
|
||||
; $Header: g:/library/wwlib32/misc/rcs/lcwcomp.asm 1.1 1994/04/11 15:31:10 jeff_wilson Exp $
|
||||
;***************************************************************************
|
||||
;** C O N F I D E N T I A L --- W E S T W O O D A S S O C I A T E S **
|
||||
;***************************************************************************
|
||||
;* *
|
||||
;* Project Name : Library routine *
|
||||
;* *
|
||||
;* File Name : COMPRESS.ASM *
|
||||
;* *
|
||||
;* Programmer : Louis Castle *
|
||||
;* *
|
||||
;* Last Update : 20 August, 1990 [CY] *
|
||||
;* *
|
||||
;*-------------------------------------------------------------------------*
|
||||
;* Functions: *
|
||||
;* *
|
||||
; ULONG LCW_Compress(BYTE *source,BYTE *dest, ULONG length); *
|
||||
;* *
|
||||
;* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - *
|
||||
|
||||
;IDEAL
|
||||
;P386
|
||||
;MODEL USE32 FLAT
|
||||
|
||||
.MODEL FLAT
|
||||
|
||||
;GLOBAL LCW_Compress :NEAR
|
||||
externdef C LCW_Compress:near
|
||||
|
||||
;CODESEG
|
||||
.code
|
||||
|
||||
; ----------------------------------------------------------------
|
||||
;
|
||||
; Here are prototypes for the routines defined within this module:
|
||||
;
|
||||
; ULONG LCW_Compress(BYTE *source,BYTE *dest, ULONG length);
|
||||
;
|
||||
; ----------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
;***********************************************************
|
||||
;
|
||||
; ULONG LCW_Compress(BYTE *source, BYTE *dest, ULONG length)
|
||||
;
|
||||
; returns the size of the compressed data in bytes
|
||||
;
|
||||
;*
|
||||
LCW_Compress proc C source:DWORD, dest:DWORD, datasize:DWORD
|
||||
|
||||
;USES ebx,ecx,edx,edi,esi
|
||||
|
||||
;ARG source:DWORD
|
||||
;ARG dest:DWORD
|
||||
;ARG datasize:DWORD
|
||||
|
||||
LOCAL inlen:DWORD
|
||||
LOCAL a1stdest:DWORD
|
||||
LOCAL a1stsrc:DWORD
|
||||
LOCAL lenoff:DWORD
|
||||
LOCAL ndest:DWORD
|
||||
LOCAL count:DWORD
|
||||
LOCAL matchoff:DWORD
|
||||
LOCAL end_of_data:DWORD
|
||||
|
||||
pushad
|
||||
|
||||
cld
|
||||
mov edi,[dest]
|
||||
mov esi,[source]
|
||||
mov edx,[datasize] ; get length of data to compress
|
||||
|
||||
; mov ax,ds
|
||||
; mov es,ax
|
||||
|
||||
;
|
||||
; compress data to the following codes in the format b = byte, w = word
|
||||
; n = byte code pulled from compressed data
|
||||
; Bit field of n command description
|
||||
; n=0xxxyyyy,yyyyyyyy short run back y bytes and run x+3
|
||||
; n=10xxxxxx,n1,n2,...,nx+1 med length copy the next x+1 bytes
|
||||
; n=11xxxxxx,w1 med run run x+3 bytes from offset w1
|
||||
; n=11111111,w1,w2 long run run w1 bytes from offset w2
|
||||
; n=10000000 end end of data reached
|
||||
;
|
||||
cld ; make sure all string commands are forward
|
||||
mov ebx,esi
|
||||
add ebx,edx
|
||||
mov [end_of_data],ebx
|
||||
mov [inlen],1 ; set the in-length flag
|
||||
mov [a1stdest],edi ; save original dest offset for size calc
|
||||
mov [a1stsrc],esi ; save offset of first byte of data
|
||||
mov [lenoff],edi ; save the offset of the legth of this len
|
||||
sub eax,eax
|
||||
mov al,081h ; the first byte is always a len
|
||||
stosb ; write out a len of 1
|
||||
lodsb ; get the byte
|
||||
stosb ; save it
|
||||
_loop:
|
||||
mov [ndest],edi ; save offset of compressed data
|
||||
mov edi,[a1stsrc] ; get the offset to the first byte of data
|
||||
mov [count],1 ; set the count of run to 0
|
||||
searchloop:
|
||||
sub eax,eax
|
||||
mov al,[esi] ; get the current byte of data
|
||||
cmp al,[esi+64]
|
||||
jne short notrunlength
|
||||
|
||||
mov ebx,edi
|
||||
|
||||
mov edi,esi
|
||||
mov ecx,[end_of_data]
|
||||
sub ecx,edi
|
||||
repe scasb
|
||||
dec edi
|
||||
mov ecx,edi
|
||||
sub ecx,esi
|
||||
cmp ecx,65
|
||||
jb short notlongenough
|
||||
|
||||
mov [DWORD PTR inlen],0 ; clear the in-length flag
|
||||
mov esi,edi
|
||||
mov edi,[ndest] ; get the offset of our compressed data
|
||||
|
||||
mov ah,al
|
||||
mov al,0FEh
|
||||
stosb
|
||||
xchg ecx,eax
|
||||
stosw
|
||||
mov al,ch
|
||||
stosb
|
||||
|
||||
mov [ndest],edi ; save offset of compressed data
|
||||
mov edi,ebx
|
||||
jmp searchloop
|
||||
notlongenough:
|
||||
mov edi,ebx
|
||||
notrunlength:
|
||||
|
||||
oploop:
|
||||
mov ecx,esi ; get the address of the last byte +1
|
||||
sub ecx,edi ; get the total number of bytes left to comp
|
||||
jz short searchdone
|
||||
|
||||
repne scasb ; look for a match
|
||||
jne short searchdone ; if we don't find one we're done
|
||||
|
||||
mov ebx,[count]
|
||||
mov ah,[esi+ebx-1]
|
||||
cmp ah,[edi+ebx-2]
|
||||
|
||||
jne oploop
|
||||
|
||||
mov edx,esi ; save this spot for the next search
|
||||
mov ebx,edi ; save this spot for the length calc
|
||||
dec edi ; back up one for compare
|
||||
mov ecx,[end_of_data] ; get the end of data
|
||||
sub ecx,esi ; sub current source for max len
|
||||
|
||||
repe cmpsb ; see how many bytes match
|
||||
|
||||
; start of change MH 9-24-91
|
||||
jne short notend ; if found mismatch then di - bx = match count
|
||||
|
||||
inc edi ; else cx = 0 and di + 1 - bx = match count
|
||||
|
||||
notend:
|
||||
; end of change MH 9-24-91
|
||||
|
||||
mov esi,edx ; restore si
|
||||
mov eax,edi ; get the dest
|
||||
sub eax,ebx ; sub the start for total bytes that match
|
||||
mov edi,ebx ; restore dest
|
||||
cmp eax,[count] ; see if its better than before
|
||||
jb searchloop ; if not keep looking
|
||||
|
||||
mov [count],eax ; if so keep the count
|
||||
dec ebx ; back it up for the actual match offset
|
||||
mov [matchoff],ebx ; save the offset for later
|
||||
jmp searchloop ; loop until we searched it all
|
||||
|
||||
searchdone:
|
||||
|
||||
mov ecx,[count] ; get the count of the longest run
|
||||
mov edi,[ndest] ; get the offset of our compressed data
|
||||
cmp ecx,2 ; see if its not enough run to matter
|
||||
jbe short lenin ; if its 0,1, or 2 its too small
|
||||
|
||||
cmp ecx,10 ; if not, see if it would fit in a short
|
||||
ja short medrun ; if not, see if its a medium run
|
||||
|
||||
mov eax,esi ; if its short get the current address
|
||||
sub eax,[matchoff] ; sub the offset of the match
|
||||
cmp eax,0FFFh ; if its less than 12 bits its a short
|
||||
ja short medrun ; if its not, its a medium
|
||||
|
||||
shortrun:
|
||||
sub ebx,ebx
|
||||
mov bl,cl ; get the length (3-10)
|
||||
sub bl,3 ; sub 3 for a 3 bit number 0-7
|
||||
shl bl,4 ; shift it left 4
|
||||
add ah,bl ; add in the length for the high nibble
|
||||
xchg ah,al ; reverse the bytes for a word store
|
||||
jmp short srunnxt ; do the run fixup code
|
||||
|
||||
medrun:
|
||||
cmp ecx,64 ; see if its a short run
|
||||
ja short longrun ; if not, oh well at least its long
|
||||
|
||||
sub cl,3 ; back down 3 to keep it in 6 bits
|
||||
or cl,0C0h ; the highest bits are always on
|
||||
mov al,cl ; put it in al for the stosb
|
||||
stosb ; store it
|
||||
jmp short medrunnxt ; do the run fixup code
|
||||
|
||||
lenin:
|
||||
cmp [DWORD PTR inlen],0 ; is it doing a length?
|
||||
jnz short len ; if so, skip code
|
||||
|
||||
lenin1:
|
||||
mov [lenoff],edi ; save the length code offset
|
||||
mov al,80h ; set the length to 0
|
||||
stosb ; save it
|
||||
|
||||
len:
|
||||
mov ebx,[lenoff] ; get the offset of the length code
|
||||
cmp BYTE PTR [ebx],0BFh ; see if its maxed out
|
||||
je lenin1 ; if so put out a new len code
|
||||
|
||||
stolen:
|
||||
inc BYTE PTR [ebx] ; inc the count code
|
||||
lodsb ; get the byte
|
||||
stosb ; store it
|
||||
mov DWORD PTR [inlen],1 ; we are now in a length so save it
|
||||
jmp short nxt ; do the next code
|
||||
|
||||
longrun:
|
||||
mov al,0ffh ; its a long so set a code of FF
|
||||
stosb ; store it
|
||||
|
||||
mov eax,[count] ; send out the count
|
||||
stosw ; store it
|
||||
medrunnxt:
|
||||
mov eax,[matchoff] ; get the offset
|
||||
sub eax,[a1stsrc] ; make it relative tot he start of data
|
||||
srunnxt:
|
||||
stosw ; store it
|
||||
; this code common to all runs
|
||||
add esi,[count] ; add in the length of the run to the source
|
||||
mov DWORD PTR [inlen],0 ; set the in leght flag to false
|
||||
|
||||
;=======================================================================
|
||||
|
||||
nxt:
|
||||
cmp esi,[end_of_data] ; see if we did the whole pic
|
||||
jae short _out ; if so, cool! were done
|
||||
|
||||
jmp _loop
|
||||
|
||||
_out:
|
||||
mov ax,080h ; remember to send an end of data code
|
||||
stosb ; store it
|
||||
mov eax,edi ; get the last compressed address
|
||||
sub eax,[a1stdest] ; sub the first for the compressed size
|
||||
|
||||
popad
|
||||
ret
|
||||
|
||||
LCW_Compress endp
|
||||
|
||||
|
||||
END
|
||||
@@ -1,294 +0,0 @@
|
||||
;
|
||||
; Copyright 2020 Electronic Arts Inc.
|
||||
;
|
||||
; TiberianDawn.DLL and RedAlert.dll and corresponding source code 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.
|
||||
|
||||
; TiberianDawn.DLL and RedAlert.dll and corresponding source code is distributed
|
||||
; in the hope that it will be useful, but with permitted additional restrictions
|
||||
; under Section 7 of the GPL. See the GNU General Public License in LICENSE.TXT
|
||||
; distributed with this program. You should have received a copy of the
|
||||
; GNU General Public License along with permitted additional restrictions
|
||||
; with this program. If not, see [https://github.com/electronicarts/CnC_Remastered_Collection]>.
|
||||
|
||||
; $Header: g:/library/wwlib32/misc/rcs/lcwuncmp.asm 1.1 1994/04/11 15:31:21 jeff_wilson Exp $
|
||||
;***************************************************************************
|
||||
;** C O N F I D E N T I A L --- W E S T W O O D A S S O C I A T E S **
|
||||
;***************************************************************************
|
||||
;* *
|
||||
;* Project Name : Library routine *
|
||||
;* *
|
||||
;* File Name : UNCOMP.ASM *
|
||||
;* *
|
||||
;* Programmer : Christopher Yates *
|
||||
;* *
|
||||
;* Last Update : 20 August, 1990 [CY] *
|
||||
;* *
|
||||
;*-------------------------------------------------------------------------*
|
||||
;* Functions: *
|
||||
;* *
|
||||
; ULONG LCW_Uncompress(BYTE *source, BYTE *dest, ULONG length); *
|
||||
;* *
|
||||
;* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - *
|
||||
|
||||
;IDEAL
|
||||
;P386
|
||||
;MODEL USE32 FLAT
|
||||
.MODEL FLAT
|
||||
|
||||
;GLOBAL C LCW_Uncompress :NEAR
|
||||
externdef C LCW_Uncompress:NEAR
|
||||
|
||||
;CODESEG
|
||||
.code
|
||||
|
||||
; ----------------------------------------------------------------
|
||||
;
|
||||
; Here are prototypes for the routines defined within this module:
|
||||
;
|
||||
; ULONG LCW_Uncompress(BYTE *source, BYTE *dest, ULONG length);
|
||||
;
|
||||
; ----------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
LCW_Uncompress proc C source:DWORD, dest:DWORD, _length:DWORD
|
||||
|
||||
;USES ebx,ecx,edx,edi,esi
|
||||
|
||||
;ARG source:DWORD
|
||||
;ARG dest:DWORD
|
||||
;ARG length:DWORD
|
||||
;LOCALS
|
||||
LOCAL a1stdest:DWORD
|
||||
LOCAL maxlen:DWORD
|
||||
LOCAL lastbyte:DWORD
|
||||
;LOCAL lastcom:DWORD
|
||||
;LOCAL lastcom1:DWORD
|
||||
|
||||
|
||||
pushad
|
||||
|
||||
mov edi,[dest]
|
||||
mov esi,[source]
|
||||
mov edx,[_length]
|
||||
|
||||
;
|
||||
;
|
||||
; uncompress data to the following codes in the format b = byte, w = word
|
||||
; n = byte code pulled from compressed data
|
||||
; Bit field of n command description
|
||||
; n=0xxxyyyy,yyyyyyyy short run back y bytes and run x+3
|
||||
; n=10xxxxxx,n1,n2,...,nx+1 med length copy the next x+1 bytes
|
||||
; n=11xxxxxx,w1 med run run x+3 bytes from offset w1
|
||||
; n=11111111,w1,w2 long copy copy w1 bytes from offset w2
|
||||
; n=11111110,w1,b1 long run run byte b1 for w1 bytes
|
||||
; n=10000000 end end of data reached
|
||||
;
|
||||
|
||||
mov [a1stdest],edi
|
||||
add edx,edi
|
||||
mov [lastbyte],edx
|
||||
cld ; make sure all lod and sto are forward
|
||||
mov ebx,esi ; save the source offset
|
||||
|
||||
??loop:
|
||||
mov eax,[lastbyte]
|
||||
sub eax,edi ; get the remaining byte to uncomp
|
||||
jz short ??out ; were done
|
||||
|
||||
mov [maxlen],eax ; save for string commands
|
||||
mov esi,ebx ; mov in the source index
|
||||
|
||||
xor eax,eax
|
||||
mov al,[esi]
|
||||
inc esi
|
||||
test al,al ; see if its a short run
|
||||
js short ??notshort
|
||||
|
||||
mov ecx,eax ;put count nibble in cl
|
||||
|
||||
mov ah,al ; put rel offset high nibble in ah
|
||||
and ah,0Fh ; only 4 bits count
|
||||
|
||||
shr cl,4 ; get run -3
|
||||
add ecx,3 ; get actual run length
|
||||
|
||||
cmp ecx,[maxlen] ; is it too big to fit?
|
||||
jbe short ??rsok ; if not, its ok
|
||||
|
||||
mov ecx,[maxlen] ; if so, max it out so it dosen't overrun
|
||||
|
||||
??rsok:
|
||||
mov al,[esi] ; get rel offset low byte
|
||||
lea ebx,[esi+1] ; save the source offset
|
||||
mov esi,edi ; get the current dest
|
||||
sub esi,eax ; get relative offset
|
||||
|
||||
rep movsb
|
||||
|
||||
jmp ??loop
|
||||
|
||||
??notshort:
|
||||
test al,40h ; is it a length?
|
||||
jne short ??notlength ; if not it could be med or long run
|
||||
|
||||
cmp al,80h ; is it the end?
|
||||
je short ??out ; if so its over
|
||||
|
||||
mov cl,al ; put the byte in count register
|
||||
and ecx,3Fh ; and off the extra bits
|
||||
|
||||
cmp ecx,[maxlen] ; is it too big to fit?
|
||||
jbe short ??lenok ; if not, its ok
|
||||
|
||||
mov ecx,[maxlen] ; if so, max it out so it dosen't overrun
|
||||
|
||||
??lenok:
|
||||
rep movsb
|
||||
|
||||
mov ebx,esi ; save the source offset
|
||||
jmp ??loop
|
||||
|
||||
??out:
|
||||
mov eax,edi
|
||||
sub eax,[a1stdest]
|
||||
jmp ??exit
|
||||
|
||||
??notlength:
|
||||
mov cl,al ; get the entire code
|
||||
and ecx,3Fh ; and off all but the size -3
|
||||
add ecx,3 ; add 3 for byte count
|
||||
|
||||
cmp al,0FEh
|
||||
jne short ??notrunlength
|
||||
|
||||
xor ecx,ecx
|
||||
mov cx,[esi]
|
||||
|
||||
xor eax,eax
|
||||
mov al,[esi+2]
|
||||
lea ebx,[esi+3] ;save the source offset
|
||||
|
||||
cmp ecx,[maxlen] ; is it too big to fit?
|
||||
jbe short ??runlenok ; if not, its ok
|
||||
|
||||
mov ecx,[maxlen] ; if so, max it out so it dosen't overrun
|
||||
|
||||
??runlenok:
|
||||
test ecx,0ffe0h
|
||||
jnz ??dont_use_stosb
|
||||
rep stosb
|
||||
jmp ??loop
|
||||
|
||||
|
||||
??dont_use_stosb:
|
||||
mov ah,al
|
||||
mov edx,eax
|
||||
shl eax,16
|
||||
or eax,edx
|
||||
|
||||
test edi,3
|
||||
jz ??aligned
|
||||
|
||||
mov [edi],eax
|
||||
mov edx,edi
|
||||
and edi,0fffffffch
|
||||
lea edi,[edi+4]
|
||||
and edx,3
|
||||
dec dl
|
||||
xor dl,3
|
||||
sub ecx,edx
|
||||
|
||||
??aligned:
|
||||
mov edx,ecx
|
||||
shr ecx,2
|
||||
rep stosd
|
||||
|
||||
and edx,3
|
||||
jz ??loop
|
||||
mov ecx,edx
|
||||
rep stosb
|
||||
jmp ??loop
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
??notrunlength:
|
||||
cmp al,0FFh ; is it a long run?
|
||||
jne short ??notlong ; if not use the code as the size
|
||||
|
||||
xor ecx,ecx
|
||||
xor eax,eax
|
||||
mov cx,[esi] ; if so, get the size
|
||||
lea esi,[esi+2]
|
||||
|
||||
??notlong:
|
||||
mov ax,[esi] ;get the real index
|
||||
add eax,[a1stdest] ;add in the 1st index
|
||||
lea ebx,[esi+2] ;save the source offset
|
||||
cmp ecx,[maxlen] ;compare for overrun
|
||||
mov esi,eax ;use eax as new source
|
||||
jbe short ??runok ; if not, its ok
|
||||
|
||||
mov ecx,[maxlen] ; if so, max it out so it dosen't overrun
|
||||
|
||||
??runok:
|
||||
test ecx,0ffe0h
|
||||
jnz ??dont_use_movsb
|
||||
rep movsb
|
||||
jmp ??loop
|
||||
|
||||
|
||||
|
||||
|
||||
??dont_use_movsb:
|
||||
lea edx,[edi+0fffffffch]
|
||||
cmp esi,edx
|
||||
ja ??use_movsb
|
||||
|
||||
test edi,3
|
||||
jz ??aligned2
|
||||
|
||||
mov eax,[esi]
|
||||
mov [edi],eax
|
||||
mov edx,edi
|
||||
and edi,0fffffffch
|
||||
lea edi,[edi+4]
|
||||
and edx,3
|
||||
dec dl
|
||||
xor dl,3
|
||||
sub ecx,edx
|
||||
add esi,edx
|
||||
|
||||
??aligned2:
|
||||
mov edx,ecx
|
||||
shr ecx,2
|
||||
and edx,3
|
||||
rep movsd
|
||||
mov ecx,edx
|
||||
??use_movsb:
|
||||
rep movsb
|
||||
jmp ??loop
|
||||
|
||||
|
||||
|
||||
|
||||
??exit:
|
||||
mov eax,edi
|
||||
mov ebx,[dest]
|
||||
sub eax,ebx
|
||||
|
||||
popad
|
||||
ret
|
||||
|
||||
LCW_Uncompress endp
|
||||
|
||||
;***********************************************************
|
||||
|
||||
|
||||
END
|
||||
@@ -1,294 +0,0 @@
|
||||
;
|
||||
; Copyright 2020 Electronic Arts Inc.
|
||||
;
|
||||
; TiberianDawn.DLL and RedAlert.dll and corresponding source code 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.
|
||||
|
||||
; TiberianDawn.DLL and RedAlert.dll and corresponding source code is distributed
|
||||
; in the hope that it will be useful, but with permitted additional restrictions
|
||||
; under Section 7 of the GPL. See the GNU General Public License in LICENSE.TXT
|
||||
; distributed with this program. You should have received a copy of the
|
||||
; GNU General Public License along with permitted additional restrictions
|
||||
; with this program. If not, see [https://github.com/electronicarts/CnC_Remastered_Collection]>.
|
||||
|
||||
;***************************************************************************
|
||||
;** C O N F I D E N T I A L --- W E S T W O O D A S S O C I A T E S **
|
||||
;***************************************************************************
|
||||
;* *
|
||||
;* Project Name : Westwood 32 bit Library *
|
||||
;* *
|
||||
;* File Name : TOBUFFER.ASM *
|
||||
;* *
|
||||
;* Programmer : Phil W. Gorrow *
|
||||
;* *
|
||||
;* Start Date : June 8, 1994 *
|
||||
;* Last Update : Feb 10, 1995 [jrj] *
|
||||
;* *
|
||||
;*-------------------------------------------------------------------------*
|
||||
;* Functions: *
|
||||
;* VVC::TOBUFFER -- Copies a virtual viewport to a linear buffer *
|
||||
;* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - *
|
||||
|
||||
;IDEAL
|
||||
;P386
|
||||
;MODEL USE32 FLAT
|
||||
;LOCALS ??
|
||||
.model flat
|
||||
|
||||
|
||||
TRANSP equ 0
|
||||
|
||||
|
||||
;INCLUDE "drawbuff.inc"
|
||||
INCLUDE gbuffer.inc
|
||||
|
||||
|
||||
;CODESEG
|
||||
.code
|
||||
|
||||
|
||||
;***************************************************************************
|
||||
;* VIVC::TOBUFFER -- Copies a virtual viewport to a linear buffer *
|
||||
;* *
|
||||
;* INPUT: BYTE * dest - buffer to copy to *
|
||||
;* size - size of the buffer to copy to *
|
||||
;* x_pixel - x pixel on viewport to copy from *
|
||||
;* y_pixel - y pixel on viewport to copy from *
|
||||
;* pixel_width - the width of copy region *
|
||||
;* pixel_height - the height of copy region *
|
||||
;* *
|
||||
;* OUTPUT: none *
|
||||
;* *
|
||||
;* WARNINGS: Coordinates and dimensions will be adjusted if they exceed *
|
||||
;* the boundaries. In the event that no adjustment is *
|
||||
;* possible this routine will abort. If the size of the *
|
||||
;* region to copy exceeds the size passed in for the buffer *
|
||||
;* the routine will automatically abort. *
|
||||
;* *
|
||||
;* HISTORY: *
|
||||
;* 06/15/1994 PWG : Created. *
|
||||
;*=========================================================================*
|
||||
Buffer_To_Buffer proc C public USES ebx ecx edx esi edi this_object:DWORD, x_pixel:DWORD, y_pixel:DWORD, pixel_width:DWORD, pixel_height:DWORD, dest:DWORD, buffer_size:DWORD
|
||||
|
||||
;PROC Buffer_To_Buffer C near
|
||||
;USES ebx,ecx,edx,esi,edi
|
||||
|
||||
;*===================================================================
|
||||
;* define the arguements that our function takes.
|
||||
;*===================================================================
|
||||
;ARG this_object:DWORD ; this is a class member function
|
||||
;ARG x_pixel:DWORD ; Page X pixel coordinate.
|
||||
;ARG y_pixel:DWORD ; Page Y pixel coordinate.
|
||||
;ARG pixel_width:DWORD ; Width of region in pixels.
|
||||
;ARG pixel_height:DWORD ; Height of region in pixels.
|
||||
;ARG dest:DWORD ; the buffer to copy to
|
||||
;ARG buffer_size:DWORD ; the size of the buffer
|
||||
|
||||
;*===================================================================
|
||||
; Define some locals so that we can handle things quickly
|
||||
;*===================================================================
|
||||
LOCAL x1_pixel :dword
|
||||
LOCAL y1_pixel :dword
|
||||
LOCAL dest_x1 : dword
|
||||
LOCAL dest_y1 : dword
|
||||
LOCAL dest_ajust_width:DWORD
|
||||
LOCAL scr_ajust_width:DWORD
|
||||
;LOCAL dest_area : dword
|
||||
|
||||
; Clip dest Rectangle against source Window boundaries.
|
||||
|
||||
mov [ dest_x1 ] , 0
|
||||
mov [ dest_y1 ] , 0
|
||||
|
||||
mov esi , [ this_object ] ; get ptr to dest
|
||||
xor ecx , ecx
|
||||
xor edx , edx
|
||||
mov edi , [esi].GraphicViewPort.GVPWidth ; get width into register
|
||||
mov ebx , [ x_pixel ]
|
||||
mov eax , [ x_pixel ]
|
||||
add ebx , [ pixel_width ]
|
||||
shld ecx , eax , 1
|
||||
mov [ x1_pixel ] , ebx
|
||||
inc edi
|
||||
shld edx , ebx , 1
|
||||
sub eax , edi
|
||||
sub ebx , edi
|
||||
shld ecx , eax , 1
|
||||
shld edx , ebx , 1
|
||||
|
||||
mov edi,[esi].GraphicViewPort.GVPHeight ; get height into register
|
||||
mov ebx , [ y_pixel ]
|
||||
mov eax , [ y_pixel ]
|
||||
add ebx , [ pixel_height ]
|
||||
shld ecx , eax , 1
|
||||
mov [ y1_pixel ] , ebx
|
||||
inc edi
|
||||
shld edx , ebx , 1
|
||||
sub eax , edi
|
||||
sub ebx , edi
|
||||
shld ecx , eax , 1
|
||||
shld edx , ebx , 1
|
||||
|
||||
xor cl , 5
|
||||
xor dl , 5
|
||||
mov al , cl
|
||||
test dl , cl
|
||||
jnz real_out
|
||||
or al , dl
|
||||
jz do_blit
|
||||
|
||||
test cl , 1000b
|
||||
jz scr_left_ok
|
||||
mov eax , [ x_pixel ]
|
||||
neg eax
|
||||
mov [ x_pixel ] , 0
|
||||
mov [ dest_x1 ] , eax
|
||||
|
||||
scr_left_ok:
|
||||
test cl , 0010b
|
||||
jz scr_bottom_ok
|
||||
mov eax , [ y_pixel ]
|
||||
neg eax
|
||||
mov [ y_pixel ] , 0
|
||||
mov [ dest_y1 ] , eax
|
||||
|
||||
scr_bottom_ok:
|
||||
test dl , 0100b
|
||||
jz scr_right_ok
|
||||
mov eax , [esi].GraphicViewPort.GVPWidth ; get width into register
|
||||
mov [ x1_pixel ] , eax
|
||||
scr_right_ok:
|
||||
test dl , 0001b
|
||||
jz do_blit
|
||||
mov eax , [esi].GraphicViewPort.GVPHeight ; get width into register
|
||||
mov [ y1_pixel ] , eax
|
||||
|
||||
do_blit:
|
||||
|
||||
cld
|
||||
|
||||
mov eax , [esi].GraphicViewPort.GVPXAdd
|
||||
add eax , [esi].GraphicViewPort.GVPWidth
|
||||
add eax , [esi].GraphicViewPort.GVPPitch
|
||||
mov esi , [esi].GraphicViewPort.GVPOffset
|
||||
|
||||
mov ecx , eax
|
||||
mul [ y_pixel ]
|
||||
add esi , [ x_pixel ]
|
||||
add esi , eax
|
||||
|
||||
add ecx , [ x_pixel ]
|
||||
sub ecx , [ x1_pixel ]
|
||||
mov [ scr_ajust_width ] , ecx
|
||||
|
||||
mov edi , [ dest ]
|
||||
mov eax , [ pixel_width ]
|
||||
sub eax , [ x1_pixel ]
|
||||
add eax , [ x_pixel ]
|
||||
mov [ dest_ajust_width ] , eax
|
||||
|
||||
mov eax , [ dest_y1 ]
|
||||
mul [ pixel_width ]
|
||||
add eax , [ dest_x1 ]
|
||||
add edi , eax
|
||||
|
||||
mov edx , [ y1_pixel ]
|
||||
mov eax , [ x1_pixel ]
|
||||
sub edx , [ y_pixel ]
|
||||
jle real_out
|
||||
sub eax , [ x_pixel ]
|
||||
jle real_out
|
||||
|
||||
mov ebx , [ pixel_width ]
|
||||
imul ebx , edx
|
||||
cmp ebx , [ buffer_size ]
|
||||
jg real_out
|
||||
|
||||
|
||||
; ********************************************************************
|
||||
; Forward bitblit only
|
||||
|
||||
IF TRANSP
|
||||
cmp [ transp ] , 0
|
||||
jnz forward_Blit_trans
|
||||
ENDIF
|
||||
|
||||
; the inner loop is so efficient that
|
||||
; the optimal consept no longer apply because
|
||||
; the optimal byte have to by a number greather than 9 bytes
|
||||
cmp eax , 10
|
||||
jl forward_loop_bytes
|
||||
|
||||
forward_loop_dword:
|
||||
mov ecx , edi
|
||||
mov ebx , eax
|
||||
neg ecx
|
||||
and ecx , 3
|
||||
sub ebx , ecx
|
||||
rep movsb
|
||||
mov ecx , ebx
|
||||
shr ecx , 2
|
||||
rep movsd
|
||||
mov ecx , ebx
|
||||
and ecx , 3
|
||||
rep movsb
|
||||
add esi , [ scr_ajust_width ]
|
||||
add edi , [ dest_ajust_width ]
|
||||
dec edx
|
||||
jnz forward_loop_dword
|
||||
ret
|
||||
|
||||
forward_loop_bytes:
|
||||
mov ecx , eax
|
||||
rep movsb
|
||||
add esi , [ scr_ajust_width ]
|
||||
add edi , [ dest_ajust_width ]
|
||||
dec edx ; decrement the height
|
||||
jnz forward_loop_bytes
|
||||
ret
|
||||
|
||||
|
||||
IF TRANSP
|
||||
|
||||
forward_Blit_trans:
|
||||
mov ecx , eax
|
||||
and ecx , 01fh
|
||||
lea ecx , [ ecx + ecx * 4 ]
|
||||
neg ecx
|
||||
shr eax , 5
|
||||
lea ecx , [ transp_reference + ecx * 2 ]
|
||||
mov [ y1_pixel ] , ecx
|
||||
|
||||
forward_loop_trans:
|
||||
mov ecx , eax
|
||||
jmp [ y1_pixel ]
|
||||
forward_trans_line:
|
||||
REPT 32
|
||||
local transp_pixel
|
||||
mov bl , [ esi ]
|
||||
test bl , bl
|
||||
jz transp_pixel
|
||||
mov [ edi ] , bl
|
||||
transp_pixel:
|
||||
inc esi
|
||||
inc edi
|
||||
ENDM
|
||||
transp_reference:
|
||||
dec ecx
|
||||
jge forward_trans_line
|
||||
add esi , [ scr_ajust_width ]
|
||||
add edi , [ dest_ajust_width ]
|
||||
dec edx
|
||||
jnz forward_loop_trans
|
||||
ret
|
||||
ENDIF
|
||||
|
||||
real_out:
|
||||
ret
|
||||
|
||||
;ENDP Buffer_To_Buffer
|
||||
Buffer_To_Buffer endp
|
||||
|
||||
END
|
||||
@@ -0,0 +1,70 @@
|
||||
/**
|
||||
* @file
|
||||
*
|
||||
* @author CCHyper
|
||||
* @author OmniBlade
|
||||
*
|
||||
* @brief Low level software blitters.
|
||||
*
|
||||
* @copyright Chronoshift 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
|
||||
* 2 of the License, or (at your option) any later version.
|
||||
* A full copy of the GNU General Public License can be found in
|
||||
* LICENSE
|
||||
*/
|
||||
|
||||
#include <stdint.h>
|
||||
#include "gbuffer.h"
|
||||
#include "misc.h"
|
||||
|
||||
long __cdecl Buffer_To_Buffer(GraphicViewPortClass* vp, int x, int y, int w, int h, void* buffer, int length)
|
||||
{
|
||||
int xstart = x;
|
||||
int ystart = y;
|
||||
int xend = x + w - 1;
|
||||
int yend = y + h - 1;
|
||||
|
||||
int xoffset = 0;
|
||||
int yoffset = 0;
|
||||
|
||||
// If we aren't drawing within the viewport, return
|
||||
if (!buffer || length <= 0 || xstart >= vp->Get_Width() || ystart >= vp->Get_Height() || xend < 0 || yend < 0) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Clipping
|
||||
if (xstart < 0) {
|
||||
xoffset = -xstart;
|
||||
xstart = 0;
|
||||
}
|
||||
|
||||
if (ystart < 0) {
|
||||
yoffset += h * (-ystart);
|
||||
ystart = 0;
|
||||
}
|
||||
|
||||
xend = min(xend, (int)vp->Get_Width() - 1);
|
||||
yend = min(yend, (int)vp->Get_Height() - 1);
|
||||
|
||||
// Setup parameters for blit
|
||||
int pitch = vp->Get_Pitch() + vp->Get_Width() + vp->Get_XAdd();
|
||||
uint8_t* src = y * pitch + x + (uint8_t*)(vp->Get_Offset());
|
||||
uint8_t* dst = xoffset + w * yoffset + (uint8_t*)(buffer);
|
||||
// int src_pitch = x_pos + pitch - xend + 1;
|
||||
// int dst_pitch = x_pos + width - xend + 1;
|
||||
int lines = yend - ystart + 1;
|
||||
int blit_width = xend - xstart + 1;
|
||||
|
||||
// Is our buffer large enough?
|
||||
if (lines * w <= length) {
|
||||
// blit
|
||||
while (lines--) {
|
||||
memcpy(dst, src, blit_width);
|
||||
src += pitch;
|
||||
dst += w;
|
||||
}
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
Reference in New Issue
Block a user