Initial commit of Command & Conquer Red Alert source code.
This commit is contained in:
181
WWFLAT32/WSA/MAKEFILE
Normal file
181
WWFLAT32/WSA/MAKEFILE
Normal file
@@ -0,0 +1,181 @@
|
||||
#
|
||||
# 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 30, 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 = wsa
|
||||
PROJ_DIR = $(%WWFLAT)\$(PROJ_NAME)
|
||||
LIB_DIR = $(%WWFLAT)\lib
|
||||
|
||||
!include $(%WWFLAT)\project.cfg
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
# Project-dependent variables
|
||||
#---------------------------------------------------------------------------
|
||||
OBJECTS = &
|
||||
wsa.obj &
|
||||
xordelta.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: $(%WWFLAT32)\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 ******************************
|
||||
|
1150
WWFLAT32/WSA/WSA.CPP
Normal file
1150
WWFLAT32/WSA/WSA.CPP
Normal file
File diff suppressed because it is too large
Load Diff
166
WWFLAT32/WSA/WSA.H
Normal file
166
WWFLAT32/WSA/WSA.H
Normal file
@@ -0,0 +1,166 @@
|
||||
/*
|
||||
** 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 : WSA 32bit LIbrary *
|
||||
* *
|
||||
* File Name : WSA.H *
|
||||
* *
|
||||
* Programmer : Scott K. Bowen *
|
||||
* *
|
||||
* Start Date : May 23, 1994 *
|
||||
* *
|
||||
* Last Update : May 25, 1994 [SKB] *
|
||||
* *
|
||||
*-------------------------------------------------------------------------*
|
||||
* Functions: *
|
||||
* Open_Animation -- file name and flags, system allocates buffer. *
|
||||
* Open_Animation -- file name, flags, palette, system allocates buffer. *
|
||||
* Open_Animation -- file_name, graphic buffer, flags. *
|
||||
* Open_Animation -- file name, bufferclass, flags, palette. *
|
||||
* Open_Animation -- filename, ptr, size, flags, no palette. *
|
||||
* Animate_Frame -- Animate a frame to a page with magic colors. *
|
||||
* Animate_Frame -- Animate a frame to a viewport with magic colors. *
|
||||
* Animate_Frame -- Animate a frame to a page. *
|
||||
* Animate_Frame -- Animate a frame to a viewport. *
|
||||
* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
|
||||
|
||||
#ifndef WSA_H
|
||||
#define WSA_H
|
||||
|
||||
#ifndef WWSTD_H
|
||||
#include "wwstd.h"
|
||||
#endif
|
||||
|
||||
#ifndef GBUFFER_H
|
||||
#include "gbuffer.h"
|
||||
#endif
|
||||
|
||||
#ifndef VBUFFER_H
|
||||
#include "vbuffer.h"
|
||||
#endif
|
||||
|
||||
//lint -strong(AJX,WSAType)
|
||||
typedef enum {
|
||||
WSA_NORMAL, // Normal WSA animation
|
||||
WSA_GHOST = 0x1000, // Or'd with the above flags to get ghosting
|
||||
WSA_PRIORITY2 = 0x2000, // Copy using a priority (or in the priority)
|
||||
WSA_TRANS = 0x4000, // Copy frame, ignoring transparent colors
|
||||
WSA_PRIORITY = 0x8000 // Copy using a priority (or in the priority)
|
||||
} WSAType;
|
||||
|
||||
|
||||
//lint -strong(AJX,WSAOpenType)
|
||||
typedef enum {
|
||||
WSA_OPEN_FROM_MEM = 0x0000, // Try to load entire anim into memory.
|
||||
WSA_OPEN_INDIRECT = 0x0000, // First animate to internal buffer, then copy to page/viewport.
|
||||
WSA_OPEN_FROM_DISK = 0x0001, // Force the animation to be disk based.
|
||||
WSA_OPEN_DIRECT = 0x0002, // Animate directly to page or viewport.
|
||||
|
||||
// These next two have been added for the 32 bit library to give a better idea of what is
|
||||
// happening. You may want to animate directly to the destination or indirectly to the
|
||||
// destination by using the animations buffer. Indirecly is best if the dest is a seenpage
|
||||
// and the animation is not linear or if the destination is modified between frames.
|
||||
WSA_OPEN_TO_PAGE = WSA_OPEN_DIRECT ,
|
||||
WSA_OPEN_TO_BUFFER= WSA_OPEN_INDIRECT ,
|
||||
|
||||
} WSAOpenType;
|
||||
|
||||
/*=========================================================================*/
|
||||
/* The following prototypes are for the file: WSA.CPP */
|
||||
/*=========================================================================*/
|
||||
|
||||
VOID * cdecl Open_Animation(BYTE const *file_name, BYTE *user_buffer, LONG user_buffer_size, WSAOpenType user_flags, UBYTE *palette=NULL);
|
||||
VOID cdecl Close_Animation( VOID *handle );
|
||||
BOOL cdecl Animate_Frame(VOID *handle, GraphicViewPortClass& view,
|
||||
WORD frame_number, WORD x_pixel=0, WORD y_pixel=0,
|
||||
WSAType flags_and_prio = WSA_NORMAL, VOID *magic_cols=NULL, VOID *magic=NULL);
|
||||
WORD cdecl Get_Animation_Frame_Count(VOID *handle);
|
||||
BOOL cdecl Animate_Frame(VOID *handle, VideoViewPortClass& view,
|
||||
WORD frame_number, WORD x_pixel=0, WORD y_pixel=0,
|
||||
WSAType flags_and_prio = WSA_NORMAL, VOID *magic_cols=NULL, VOID *magic=NULL);
|
||||
WORD cdecl Get_Animation_Frame_Count(VOID *handle);
|
||||
WORD cdecl Get_Animation_X(VOID const *handle);
|
||||
WORD cdecl Get_Animation_Y(VOID const *handle);
|
||||
WORD cdecl Get_Animation_Width(VOID const *handle);
|
||||
WORD cdecl Get_Animation_Height(VOID const *handle);
|
||||
WORD cdecl Get_Animation_Palette(VOID const *handle);
|
||||
ULONG cdecl Get_Animation_Size(VOID const *handle);
|
||||
|
||||
|
||||
/***************************************************************************
|
||||
* OPEN_ANIMATION -- file name, flags, palette, system allocates buffer. *
|
||||
* *
|
||||
* *
|
||||
* INPUT: BYTE *file_name - name of file to open. *
|
||||
* WSAOpenType user_flags - flags on how to open. *
|
||||
* UBYTE *palette - pointer to a palette buffer to fill. *
|
||||
* *
|
||||
* OUTPUT: VOID *pointer to animation data. Must be used for all *
|
||||
* other WSA calls. *
|
||||
* *
|
||||
* WARNINGS: *
|
||||
* *
|
||||
* HISTORY: *
|
||||
* 05/24/1994 SKB : Created. *
|
||||
*=========================================================================*/
|
||||
inline VOID *cdecl Open_Animation(BYTE *file_name, WSAOpenType user_flags, UBYTE *palette=NULL)
|
||||
{
|
||||
return (Open_Animation(file_name, NULL, 0L, user_flags, palette));
|
||||
}
|
||||
|
||||
|
||||
/***************************************************************************
|
||||
* OPEN_ANIMATION -- file_name, bufferclass, flags. *
|
||||
* *
|
||||
* *
|
||||
* INPUT: BYTE *file_name - name of file to open. *
|
||||
* GraphicBufferClass - pointer to a buffer. *
|
||||
* WSAOpenType user_flags - flags on how to open. *
|
||||
* UBYTE *palette - pointer to a palette buffer to fill. *
|
||||
* *
|
||||
* OUTPUT: VOID *pointer to animation data. Must be used for all *
|
||||
* other WSA calls. *
|
||||
* *
|
||||
* WARNINGS: *
|
||||
* *
|
||||
* HISTORY: *
|
||||
* 05/24/1994 SKB : Created. *
|
||||
*=========================================================================*/
|
||||
inline VOID *cdecl Open_Animation(BYTE *file_name, BufferClass& buffer, WSAOpenType user_flags, UBYTE *palette=NULL)
|
||||
{
|
||||
return (Open_Animation(file_name, (BYTE *)buffer.Get_Buffer(), buffer.Get_Size(), user_flags, palette));
|
||||
}
|
||||
|
||||
|
||||
/*=========================================================================*/
|
||||
/* The following prototypes are for the file: LP_ASM.ASM */
|
||||
/*=========================================================================*/
|
||||
|
||||
|
||||
extern "C" {
|
||||
UWORD Apply_XOR_Delta(BYTE *source_ptr, BYTE *delta_ptr);
|
||||
VOID Apply_XOR_Delta_To_Page_Or_Viewport(VOID *target, VOID *delta, WORD width, WORD nextrow, WORD copy);
|
||||
}
|
||||
|
||||
|
||||
|
||||
#endif // WSA_H
|
657
WWFLAT32/WSA/XORDELTA.ASM
Normal file
657
WWFLAT32/WSA/XORDELTA.ASM
Normal file
@@ -0,0 +1,657 @@
|
||||
;
|
||||
; 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 : WSA Support routines *
|
||||
; * *
|
||||
; * File Name : XORDELTA.ASM *
|
||||
; * *
|
||||
; * Programmer : Scott K. Bowen *
|
||||
; * *
|
||||
; * Last Update :May 23, 1994 [SKB] *
|
||||
; * *
|
||||
; *------------------------------------------------------------------------*
|
||||
; * Functions: *
|
||||
;* Apply_XOR_Delta -- Apply XOR delta data to a buffer. *
|
||||
;* Apply_XOR_Delta_To_Page_Or_Viewport -- Calls the copy or the XOR funti*
|
||||
;* Copy_Delta_buffer -- Copies XOR Delta Data to a section of a page. *
|
||||
;* XOR_Delta_Buffer -- Xor's the data in a XOR Delta format to a page. *
|
||||
; * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*
|
||||
|
||||
IDEAL
|
||||
P386
|
||||
MODEL USE32 FLAT
|
||||
|
||||
|
||||
|
||||
|
||||
LOCALS ??
|
||||
|
||||
; These are used to call Apply_XOR_Delta_To_Page_Or_Viewport() to setup flags parameter. If
|
||||
; These change, make sure and change their values in wsa.cpp.
|
||||
DO_XOR equ 0
|
||||
DO_COPY equ 1
|
||||
TO_VIEWPORT equ 0
|
||||
TO_PAGE equ 2
|
||||
|
||||
;
|
||||
; Routines defined in this module
|
||||
;
|
||||
;
|
||||
; UWORD Apply_XOR_Delta(UWORD page_seg, BYTE *delta_ptr);
|
||||
; PUBLIC Apply_XOR_Delta_To_Page_Or_Viewport(UWORD page_seg, BYTE *delta_ptr, WORD width, WORD copy)
|
||||
;
|
||||
; PROC C XOR_Delta_Buffer
|
||||
; PROC C Copy_Delta_Buffer
|
||||
;
|
||||
|
||||
GLOBAL Apply_XOR_Delta:NEAR
|
||||
GLOBAL Apply_XOR_Delta_To_Page_Or_Viewport:NEAR
|
||||
|
||||
|
||||
|
||||
CODESEG
|
||||
|
||||
|
||||
|
||||
;***************************************************************************
|
||||
;* APPLY_XOR_DELTA -- Apply XOR delta data to a linear buffer. *
|
||||
;* AN example of this in C is at the botton of the file commented out. *
|
||||
;* *
|
||||
;* INPUT: BYTE *target - destination buffer. *
|
||||
;* BYTE *delta - xor data to be delta uncompress. *
|
||||
;* *
|
||||
;* OUTPUT: *
|
||||
;* *
|
||||
;* WARNINGS: *
|
||||
;* *
|
||||
;* HISTORY: *
|
||||
;* 05/23/1994 SKB : Created. *
|
||||
;*=========================================================================*
|
||||
PROC Apply_XOR_Delta C near
|
||||
USES ebx,ecx,edx,edi,esi
|
||||
ARG target:DWORD ; pointers.
|
||||
ARG delta:DWORD ; pointers.
|
||||
|
||||
; Optimized for 486/pentium by rearanging instructions.
|
||||
mov edi,[target] ; get our pointers into offset registers.
|
||||
mov esi,[delta]
|
||||
|
||||
cld ; make sure we go forward
|
||||
xor ecx,ecx ; use cx for loop
|
||||
|
||||
??top_loop:
|
||||
xor eax,eax ; clear out eax.
|
||||
lodsb ; get delta source byte
|
||||
|
||||
or al,al ; check for a SHORTDUMP ; check al incase of sign value.
|
||||
je ??short_run
|
||||
js ??check_others
|
||||
|
||||
;
|
||||
; SHORTDUMP
|
||||
;
|
||||
mov ecx,eax ; stick count in cx
|
||||
|
||||
??dump_loop:
|
||||
lodsb ; get delta XOR byte
|
||||
xor [edi],al ; xor that byte on the dest
|
||||
inc edi
|
||||
dec ecx
|
||||
jnz ??dump_loop
|
||||
jmp ??top_loop
|
||||
|
||||
;
|
||||
; SHORTRUN
|
||||
;
|
||||
|
||||
??short_run:
|
||||
mov cl,[esi] ; get count
|
||||
inc esi ; inc delta source
|
||||
|
||||
??do_run:
|
||||
lodsb ; get XOR byte
|
||||
|
||||
??run_loop:
|
||||
xor [edi],al ; xor that byte.
|
||||
|
||||
inc edi ; go to next dest pixel
|
||||
dec ecx ; one less to go.
|
||||
jnz ??run_loop
|
||||
jmp ??top_loop
|
||||
|
||||
;
|
||||
; By now, we know it must be a LONGDUMP, SHORTSKIP, LONGRUN, or LONGSKIP
|
||||
;
|
||||
|
||||
??check_others:
|
||||
sub eax,080h ; opcode -= 0x80
|
||||
jnz ??do_skip ; if zero then get next word, otherwise use remainder.
|
||||
|
||||
lodsw ; get word code in ax
|
||||
or ax,ax ; set flags. (not 32bit register so neg flag works)
|
||||
jle ??not_long_skip
|
||||
|
||||
;
|
||||
; SHORTSKIP AND LONGSKIP
|
||||
;
|
||||
??do_skip:
|
||||
add edi,eax ; do the skip.
|
||||
jmp ??top_loop
|
||||
|
||||
|
||||
??not_long_skip:
|
||||
jz ??stop ; long count of zero means stop
|
||||
sub eax,08000h ; opcode -= 0x8000
|
||||
test eax,04000h ; is it a LONGRUN (code & 0x4000)?
|
||||
je ??long_dump
|
||||
|
||||
;
|
||||
; LONGRUN
|
||||
;
|
||||
sub eax,04000h ; opcode -= 0x4000
|
||||
mov ecx,eax ; use cx as loop count
|
||||
jmp ??do_run ; jump to run code.
|
||||
|
||||
|
||||
;
|
||||
; LONGDUMP
|
||||
;
|
||||
|
||||
??long_dump:
|
||||
mov ecx,eax ; use cx as loop count
|
||||
jmp ??dump_loop ; go to the dump loop.
|
||||
|
||||
??stop:
|
||||
|
||||
ret
|
||||
|
||||
ENDP Apply_XOR_Delta
|
||||
|
||||
|
||||
;----------------------------------------------------------------------------
|
||||
|
||||
|
||||
;***************************************************************************
|
||||
;* APPLY_XOR_DELTA_To_Page_Or_Viewport -- Calls the copy or the XOR funtion. *
|
||||
;* *
|
||||
;* *
|
||||
;* This funtion is call to either xor or copy XOR_Delta data onto a *
|
||||
;* page instead of a buffer. The routine will set up the registers *
|
||||
;* need for the actual routines that will perform the copy or xor. *
|
||||
;* *
|
||||
;* The registers are setup as follows : *
|
||||
;* es:edi - destination segment:offset onto page. *
|
||||
;* ds:esi - source buffer segment:offset of delta data. *
|
||||
;* dx,cx,ax - are all zeroed out before entry. *
|
||||
;* *
|
||||
;* INPUT: *
|
||||
;* *
|
||||
;* OUTPUT: *
|
||||
;* *
|
||||
;* WARNINGS: *
|
||||
;* *
|
||||
;* HISTORY: *
|
||||
;* 03/09/1992 SB : Created. *
|
||||
;*=========================================================================*
|
||||
|
||||
;PUBLIC Apply_XOR_Delta_To_Page_Or_Viewport(UWORD page_seg, BYTE *delta_ptr, WORD width, WORD flags, WORD descriptor)
|
||||
PROC Apply_XOR_Delta_To_Page_Or_Viewport C near
|
||||
USES ebx,ecx,edx,edi,esi
|
||||
ARG target:DWORD ; pointer to the destination buffer.
|
||||
ARG delta:DWORD ; pointer to the delta buffer.
|
||||
ARG width:DWORD ; width of animation.
|
||||
ARG nextrow:DWORD ; Page/Buffer width - anim width.
|
||||
ARG copy:DWORD ; should it be copied or xor'd?
|
||||
|
||||
|
||||
mov edi,[target] ; Get the target pointer.
|
||||
mov esi,[delta] ; Get the destination pointer.
|
||||
|
||||
xor eax,eax ; clear eax, later put them into ecx and edx.
|
||||
|
||||
cld ; make sure we go forward
|
||||
|
||||
mov ebx,[nextrow] ; get the amount to add to get to next row from end. push it later...
|
||||
|
||||
mov ecx,eax ; use cx for loop
|
||||
mov edx,eax ; use dx to count the relative column.
|
||||
|
||||
push ebx ; push nextrow onto the stack for Copy/XOR_Delta_Buffer.
|
||||
mov ebx,[width] ; bx will hold the max column for speed compares
|
||||
|
||||
; At this point, all the registers have been set up. Now call the correct function
|
||||
; to either copy or xor the data.
|
||||
|
||||
cmp [copy],DO_XOR ; Do we want to copy or XOR
|
||||
je ??xorfunct ; Jump to XOR if not copy
|
||||
call Copy_Delta_Buffer ; Call the function to copy the delta buffer.
|
||||
jmp ??didcopy ; jump past XOR
|
||||
??xorfunct:
|
||||
call XOR_Delta_Buffer ; Call funtion to XOR the deltat buffer.
|
||||
??didcopy:
|
||||
pop ebx ; remove the push done to pass a value.
|
||||
|
||||
ret
|
||||
|
||||
ENDP Apply_XOR_Delta_To_Page_Or_Viewport
|
||||
;----------------------------------------------------------------------------
|
||||
|
||||
|
||||
;***************************************************************************
|
||||
;* XOR_DELTA_BUFFER -- Xor's the data in a XOR Delta format to a page. *
|
||||
;* This will only work right if the page has the previous data on it. *
|
||||
;* This function should only be called by XOR_Delta_Buffer_To_Page_Or_Viewport. *
|
||||
;* The registers must be setup as follows : *
|
||||
;* *
|
||||
;* INPUT: *
|
||||
;* es:edi - destination segment:offset onto page. *
|
||||
;* ds:esi - source buffer segment:offset of delta data. *
|
||||
;* edx,ecx,eax - are all zeroed out before entry. *
|
||||
;* *
|
||||
;* OUTPUT: *
|
||||
;* *
|
||||
;* WARNINGS: *
|
||||
;* *
|
||||
;* HISTORY: *
|
||||
;* 03/09/1992 SB : Created. *
|
||||
;*=========================================================================*
|
||||
|
||||
PROC XOR_Delta_Buffer C near
|
||||
ARG nextrow:DWORD
|
||||
|
||||
??top_loop:
|
||||
xor eax,eax ; clear out eax.
|
||||
lodsb ; get delta source byte
|
||||
|
||||
or al,al ; check for a SHORTDUMP ; check al incase of sign value.
|
||||
je ??short_run
|
||||
js ??check_others
|
||||
|
||||
;
|
||||
; SHORTDUMP
|
||||
;
|
||||
mov ecx,eax ; stick count in cx
|
||||
|
||||
??dump_loop:
|
||||
lodsb ; get delta XOR byte
|
||||
xor [edi],al ; xor that byte on the dest
|
||||
inc edx ; increment our count on current column
|
||||
inc edi
|
||||
cmp edx,ebx ; are we at the final column
|
||||
jne ??end_col1 ; if not the jmp over the code
|
||||
|
||||
sub edi,edx ; get our column back to the beginning.
|
||||
xor edx,edx ; zero out our column counter
|
||||
add edi,[nextrow] ; jump to start of next row
|
||||
??end_col1:
|
||||
|
||||
dec ecx
|
||||
jnz ??dump_loop
|
||||
jmp ??top_loop
|
||||
|
||||
;
|
||||
; SHORTRUN
|
||||
;
|
||||
|
||||
??short_run:
|
||||
mov cl,[esi] ; get count
|
||||
inc esi ; inc delta source
|
||||
|
||||
??do_run:
|
||||
lodsb ; get XOR byte
|
||||
|
||||
??run_loop:
|
||||
xor [edi],al ; xor that byte.
|
||||
|
||||
inc edx ; increment our count on current column
|
||||
inc edi ; go to next dest pixel
|
||||
cmp edx,ebx ; are we at the final column
|
||||
jne ??end_col2 ; if not the jmp over the code
|
||||
|
||||
sub edi,ebx ; get our column back to the beginning.
|
||||
xor edx,edx ; zero out our column counter
|
||||
add edi,[nextrow] ; jump to start of next row
|
||||
??end_col2:
|
||||
|
||||
|
||||
dec ecx
|
||||
jnz ??run_loop
|
||||
jmp ??top_loop
|
||||
|
||||
;
|
||||
; By now, we know it must be a LONGDUMP, SHORTSKIP, LONGRUN, or LONGSKIP
|
||||
;
|
||||
|
||||
??check_others:
|
||||
sub eax,080h ; opcode -= 0x80
|
||||
jnz ??do_skip ; if zero then get next word, otherwise use remainder.
|
||||
|
||||
lodsw ; get word code in ax
|
||||
or ax,ax ; set flags. (not 32bit register so neg flag works)
|
||||
jle ??not_long_skip
|
||||
|
||||
;
|
||||
; SHORTSKIP AND LONGSKIP
|
||||
;
|
||||
??do_skip:
|
||||
sub edi,edx ; go back to beginning or row.
|
||||
add edx,eax ; incriment our count on current row
|
||||
??recheck3:
|
||||
cmp edx,ebx ; are we past the end of the row
|
||||
jb ??end_col3 ; if not the jmp over the code
|
||||
|
||||
sub edx,ebx ; Subtract width from the col counter
|
||||
add edi,[nextrow] ; jump to start of next row
|
||||
jmp ??recheck3 ; jump up to see if we are at the right row
|
||||
??end_col3:
|
||||
add edi,edx ; get to correct position in row.
|
||||
jmp ??top_loop
|
||||
|
||||
|
||||
??not_long_skip:
|
||||
jz ??stop ; long count of zero means stop
|
||||
sub eax,08000h ; opcode -= 0x8000
|
||||
test eax,04000h ; is it a LONGRUN (code & 0x4000)?
|
||||
je ??long_dump
|
||||
|
||||
;
|
||||
; LONGRUN
|
||||
;
|
||||
sub eax,04000h ; opcode -= 0x4000
|
||||
mov ecx,eax ; use cx as loop count
|
||||
jmp ??do_run ; jump to run code.
|
||||
|
||||
|
||||
;
|
||||
; LONGDUMP
|
||||
;
|
||||
|
||||
??long_dump:
|
||||
mov ecx,eax ; use cx as loop count
|
||||
jmp ??dump_loop ; go to the dump loop.
|
||||
|
||||
??stop:
|
||||
|
||||
ret
|
||||
|
||||
|
||||
ENDP XOR_Delta_Buffer
|
||||
|
||||
;----------------------------------------------------------------------------
|
||||
|
||||
|
||||
;***************************************************************************
|
||||
;* COPY_DELTA_BUFFER -- Copies XOR Delta Data to a section of a page. *
|
||||
;* This function should only be called by XOR_Delta_Buffer_To_Page_Or_Viewport. *
|
||||
;* The registers must be setup as follows : *
|
||||
;* *
|
||||
;* INPUT: *
|
||||
;* es:edi - destination segment:offset onto page. *
|
||||
;* ds:esi - source buffer segment:offset of delta data. *
|
||||
;* dx,cx,ax - are all zeroed out before entry. *
|
||||
;* *
|
||||
;* OUTPUT: *
|
||||
;* *
|
||||
;* WARNINGS: *
|
||||
;* *
|
||||
;* HISTORY: *
|
||||
;* 03/09/1992 SB : Created. *
|
||||
;*=========================================================================*
|
||||
PROC Copy_Delta_Buffer C near
|
||||
ARG nextrow:DWORD
|
||||
|
||||
??top_loop:
|
||||
xor eax,eax ; clear out eax.
|
||||
lodsb ; get delta source byte
|
||||
|
||||
or al,al ; check for a SHORTDUMP ; check al incase of sign value.
|
||||
je ??short_run
|
||||
js ??check_others
|
||||
|
||||
;
|
||||
; SHORTDUMP
|
||||
;
|
||||
mov ecx,eax ; stick count in cx
|
||||
|
||||
??dump_loop:
|
||||
lodsb ; get delta XOR byte
|
||||
|
||||
mov [edi],al ; store that byte on the dest
|
||||
|
||||
inc edx ; increment our count on current column
|
||||
inc edi
|
||||
cmp edx,ebx ; are we at the final column
|
||||
jne ??end_col1 ; if not the jmp over the code
|
||||
|
||||
sub edi,edx ; get our column back to the beginning.
|
||||
xor edx,edx ; zero out our column counter
|
||||
add edi,[nextrow] ; jump to start of next row
|
||||
??end_col1:
|
||||
|
||||
dec ecx
|
||||
jnz ??dump_loop
|
||||
jmp ??top_loop
|
||||
|
||||
;
|
||||
; SHORTRUN
|
||||
;
|
||||
|
||||
??short_run:
|
||||
mov cl,[esi] ; get count
|
||||
inc esi ; inc delta source
|
||||
|
||||
??do_run:
|
||||
lodsb ; get XOR byte
|
||||
|
||||
??run_loop:
|
||||
mov [edi],al ; store the byte (instead of XOR against current color)
|
||||
|
||||
inc edx ; increment our count on current column
|
||||
inc edi ; go to next dest pixel
|
||||
cmp edx,ebx ; are we at the final column
|
||||
jne ??end_col2 ; if not the jmp over the code
|
||||
|
||||
sub edi,ebx ; get our column back to the beginning.
|
||||
xor edx,edx ; zero out our column counter
|
||||
add edi,[nextrow] ; jump to start of next row
|
||||
??end_col2:
|
||||
|
||||
|
||||
dec ecx
|
||||
jnz ??run_loop
|
||||
jmp ??top_loop
|
||||
|
||||
;
|
||||
; By now, we know it must be a LONGDUMP, SHORTSKIP, LONGRUN, or LONGSKIP
|
||||
;
|
||||
|
||||
??check_others:
|
||||
sub eax,080h ; opcode -= 0x80
|
||||
jnz ??do_skip ; if zero then get next word, otherwise use remainder.
|
||||
|
||||
lodsw ; get word code in ax
|
||||
or ax,ax ; set flags. (not 32bit register so neg flag works)
|
||||
jle ??not_long_skip
|
||||
|
||||
;
|
||||
; SHORTSKIP AND LONGSKIP
|
||||
;
|
||||
??do_skip:
|
||||
sub edi,edx ; go back to beginning or row.
|
||||
add edx,eax ; incriment our count on current row
|
||||
??recheck3:
|
||||
cmp edx,ebx ; are we past the end of the row
|
||||
jb ??end_col3 ; if not the jmp over the code
|
||||
|
||||
sub edx,ebx ; Subtract width from the col counter
|
||||
add edi,[nextrow] ; jump to start of next row
|
||||
jmp ??recheck3 ; jump up to see if we are at the right row
|
||||
??end_col3:
|
||||
add edi,edx ; get to correct position in row.
|
||||
jmp ??top_loop
|
||||
|
||||
|
||||
??not_long_skip:
|
||||
jz ??stop ; long count of zero means stop
|
||||
sub eax,08000h ; opcode -= 0x8000
|
||||
test eax,04000h ; is it a LONGRUN (code & 0x4000)?
|
||||
je ??long_dump
|
||||
|
||||
;
|
||||
; LONGRUN
|
||||
;
|
||||
sub eax,04000h ; opcode -= 0x4000
|
||||
mov ecx,eax ; use cx as loop count
|
||||
jmp ??do_run ; jump to run code.
|
||||
|
||||
|
||||
;
|
||||
; LONGDUMP
|
||||
;
|
||||
|
||||
??long_dump:
|
||||
mov ecx,eax ; use cx as loop count
|
||||
jmp ??dump_loop ; go to the dump loop.
|
||||
|
||||
??stop:
|
||||
|
||||
ret
|
||||
|
||||
ENDP Copy_Delta_Buffer
|
||||
|
||||
;----------------------------------------------------------------------------
|
||||
|
||||
END
|
||||
|
||||
|
||||
;----------------------------------------------------------------------------
|
||||
;
|
||||
;PUBLIC UWORD Apply_XOR_Delta(UWORD page_seg, BYTE *delta_ptr)
|
||||
;{
|
||||
;
|
||||
; register UWORD loop;
|
||||
; BYTE opcode, xor_byte;
|
||||
; UWORD bytes_to_uncompress = 64000U;
|
||||
;
|
||||
;
|
||||
; /* Make our buffer pointer */
|
||||
;
|
||||
; to = MK_FP(page_seg, 0);
|
||||
; delta = Normalize_Pointer(delta_ptr);
|
||||
;
|
||||
;
|
||||
; while (bytes_to_uncompress) {
|
||||
;
|
||||
; opcode = *delta++;
|
||||
;
|
||||
;
|
||||
; /* Check for SHORTDUMP */
|
||||
;
|
||||
; if (opcode > 0) {
|
||||
;
|
||||
;
|
||||
; bytes_to_uncompress -= opcode;
|
||||
;
|
||||
; for (loop = 0; loop < opcode; loop++) {
|
||||
; xor_byte = *delta++;
|
||||
; *to++ ^= xor_byte;
|
||||
; }
|
||||
; continue;
|
||||
; }
|
||||
;
|
||||
; /* Check for SHORTRUN */
|
||||
;
|
||||
; if (opcode == 0) {
|
||||
;
|
||||
; word_count = *delta++;
|
||||
; xor_byte = *delta++;
|
||||
;
|
||||
; bytes_to_uncompress -= word_count;
|
||||
;
|
||||
; for (loop = 0; loop < word_count; loop++) {
|
||||
; *to++ ^= xor_byte;
|
||||
; }
|
||||
; continue;
|
||||
; }
|
||||
;
|
||||
; /* By now, we know it must be a LONGDUMP, SHORTSKIP, or LONGSKIP */
|
||||
;
|
||||
; opcode -= 0x80;
|
||||
;
|
||||
;
|
||||
; /* Is it a SHORTSKIP? */
|
||||
;
|
||||
; if (opcode != 0) {
|
||||
;
|
||||
; to += opcode;
|
||||
; bytes_to_uncompress -= (WORD) opcode;
|
||||
; continue;
|
||||
; }
|
||||
;
|
||||
;
|
||||
; word_count = *((UWORD *) delta)++;
|
||||
;
|
||||
; /* Is it a LONGSKIP? */
|
||||
;
|
||||
; if ((WORD) word_count > 0) {
|
||||
;
|
||||
; to += word_count;
|
||||
; bytes_to_uncompress -= (WORD) word_count;
|
||||
; continue;
|
||||
; }
|
||||
;
|
||||
;
|
||||
; word_count -= 0x8000;
|
||||
;
|
||||
; /* Is it a LONGRUN? */
|
||||
;
|
||||
; if (word_count & 0x4000) {
|
||||
;
|
||||
; word_count -= 0x4000;
|
||||
;
|
||||
; bytes_to_uncompress -= word_count;
|
||||
;
|
||||
; xor_byte = *delta++;
|
||||
;
|
||||
; for (loop = 0; loop < word_count; loop++) {
|
||||
; *to++ ^= xor_byte;
|
||||
; }
|
||||
; continue;
|
||||
; }
|
||||
;
|
||||
;
|
||||
; /* It must be a LONGDUMP */
|
||||
;
|
||||
; bytes_to_uncompress -= word_count;
|
||||
;
|
||||
; for (loop = 0; loop < word_count; loop++) {
|
||||
; xor_byte = *delta++;
|
||||
; *to++ ^= xor_byte;
|
||||
; }
|
||||
; }
|
||||
;
|
||||
;
|
||||
; return(64000U);
|
||||
;}
|
||||
;
|
||||
|
||||
|
Reference in New Issue
Block a user