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

122
WWFLAT32/FONT/FONT.BAK Normal file
View File

@@ -0,0 +1,122 @@
/*
** 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 : Font and text print 32 bit library *
* *
* File Name : FONT.H *
* *
* Programmer : Scott K. Bowen *
* *
* Start Date : June 27, 1994 *
* *
* Last Update : June 29, 1994 [SKB] *
* *
*-------------------------------------------------------------------------*
* Functions: *
* VVPC::Text_Print -- Text print into a virtual viewport. *
* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
#ifndef FONT_H
#define FONT_H
#ifndef GBUFFER_H
#include <gbuffer.h>
#endif
#ifndef VBUFFER_H
#include <vbuffer.h>
#endif
//////////////////////////////////////// Defines //////////////////////////////////////////
// defines for font header, offsets to block offsets
#define FONTINFOBLOCK 4
#define FONTOFFSETBLOCK 6
#define FONTWIDTHBLOCK 8
#define FONTDATABLOCK 10
#define FONTHEIGHTBLOCK 12
// defines for font info block
#define FONTINFOMAXHEIGHT 4
#define FONTINFOMAXWIDTH 5
//////////////////////////////////////// Prototypes //////////////////////////////////////////
/*=========================================================================*/
/* The following prototypes are for the file: SET_FONT.CPP */
/*=========================================================================*/
VOID *cdecl Set_Font(VOID const *fontptr);
/*=========================================================================*/
/* The following prototypes are for the file: FONT.CPP */
/*=========================================================================*/
WORD cdecl Char_Pixel_Width(BYTE chr);
UWORD cdecl String_Pixel_Width(BYTE const *string);
VOID cdecl Get_Next_Text_Print_XY(GraphicViewPortClass& vp, ULONG offset, INT *x, INT *y);
VOID cdecl Get_Next_Text_Print_XY(VideoViewPortClass& vp, ULONG offset, INT *x, INT *y);
/*=========================================================================*/
/* The following prototypes are for the file: LOADFONT.CPP */
/*=========================================================================*/
VOID *cdecl Load_Font(BYTE const *name);
/*=========================================================================*/
/* The following prototypes are for the file: TEXTPRNT.ASM */
/*=========================================================================*/
#ifdef __cplusplus
extern "C" {
#endif
VOID Set_Font_Palette_Range(VOID const *palette, INT start_idx, INT end_idx);
#ifdef __cplusplus
}
#endif
/*=========================================================================*/
//////////////////////////////////////// External varables ///////////////////////////////////////
extern "C" int FontXSpacing;
extern "C" int FontYSpacing;
extern BYTE FontWidth ;
extern BYTE FontHeight;
extern BYTE *FontWidthBlockPtr;
extern "C" VOID const *FontPtr;
#endif // FONT_H

170
WWFLAT32/FONT/FONT.CPP Normal file
View File

@@ -0,0 +1,170 @@
/*
** Command & Conquer Red Alert(tm)
** Copyright 2025 Electronic Arts Inc.
**
** This program is free software: you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation, either version 3 of the License, or
** (at your option) any later version.
**
** This program is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/***************************************************************************
** C O N F I D E N T I A L --- W E S T W O O D A S S O C I A T E S **
***************************************************************************
* *
* Project Name : LIBRARY *
* *
* File Name : FONT.C *
* *
* Programmer : David Dettmer *
* *
* Last Update : July 20, 1994 [SKB] *
* *
*-------------------------------------------------------------------------*
* Functions: *
* Char_Pixel_Width -- Return pixel width of a character. *
* String_Pixel_Width -- Return pixel width of a string of characters. *
* Get_Next_Text_Print_XY -- Calculates X and Y given ret value from Text_P*
* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
#include <wwstd.h>
#include "font.h"
#include <malloc.h>
#include <dos.h>
#include <fcntl.h>
#include <io.h>
#include <sys\stat.h>
#include <string.h>
/***************************************************************************
* CHAR_PIXEL_WIDTH -- Return pixel width of a character. *
* *
* Retreives the pixel width of a character from the font width block. *
* *
* INPUT: Character. *
* *
* OUTPUT: Pixel width of a string of characters. *
* *
* WARNINGS: Set_Font must have been called first. *
* *
* HISTORY: *
* 01/31/1992 DRD : Created. *
* 06/30/1994 SKB : Converted to 32 bit library. *
*=========================================================================*/
WORD cdecl Char_Pixel_Width(BYTE chr)
{
WORD width;
width = (UBYTE)*(FontWidthBlockPtr + (UBYTE)chr) + FontXSpacing;
return(width);
}
/***************************************************************************
* STRING_PIXEL_WIDTH -- Return pixel width of a string of characters. *
* *
* Calculates the pixel width of a string of characters. This uses *
* the font width block for the widths. *
* *
* INPUT: Pointer to string of characters. *
* *
* OUTPUT: Pixel width of a string of characters. *
* *
* WARNINGS: Set_Font must have been called first. *
* *
* HISTORY: *
* 01/30/1992 DRD : Created. *
* 01/31/1992 DRD : Use Char_Pixel_Width. *
* 06/30/1994 SKB : Converted to 32 bit library. *
*=========================================================================*/
UWORD cdecl String_Pixel_Width(BYTE const *string)
{
WORD width; // Working accumulator of string width.
WORD largest = 0; // Largest recorded width of the string.
if (!string) return(0);
width = 0;
while (*string) {
if (*string == '\r') {
string++;
largest = MAX(largest, width);
width = 0;
} else {
width += Char_Pixel_Width(*string++); // add each char's width
}
}
largest = MAX(largest, width);
return(largest);
}
/***************************************************************************
* GET_NEXT_TEXT_PRINT_XY -- Calculates X and Y given ret value from Text_P*
* *
* *
* INPUT: VVPC& vp - viewport that was printed to. *
* ULONG offset - offset that Text_Print returned. *
* INT *x - x return value. *
* INT *y - y return value. *
* *
* OUTPUT: x and y are set. *
* *
* WARNINGS: *
* *
* HISTORY: *
* 07/20/1994 SKB : Created. *
*=========================================================================*/
VOID cdecl Get_Next_Text_Print_XY(VideoViewPortClass& vp, ULONG offset, INT *x, INT *y)
{
INT buffwidth;
if (offset) {
buffwidth = vp.Get_Width() + vp.Get_XAdd();
offset -= vp.Get_Offset();
*x = offset % buffwidth;
*y = offset / buffwidth;
} else {
*x = *y = 0;
}
}
/***************************************************************************
* GET_NEXT_TEXT_PRINT_XY -- Calculates X and Y given ret value from Text_P*
* *
* *
* INPUT: VVPC& vp - viewport that was printed to. *
* ULONG offset - offset that Text_Print returned. *
* INT *x - x return value. *
* INT *y - y return value. *
* *
* OUTPUT: x and y are set. *
* *
* WARNINGS: *
* *
* HISTORY: *
* 07/20/1994 SKB : Created. *
*=========================================================================*/
VOID cdecl Get_Next_Text_Print_XY(GraphicViewPortClass& vp, ULONG offset, INT *x, INT *y)
{
INT buffwidth;
if (offset) {
buffwidth = vp.Get_Width() + vp.Get_XAdd();
offset -= vp.Get_Offset();
*x = offset % buffwidth;
*y = offset / buffwidth;
} else {
*x = *y = 0;
}
}

122
WWFLAT32/FONT/FONT.H Normal file
View File

@@ -0,0 +1,122 @@
/*
** 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 : Font and text print 32 bit library *
* *
* File Name : FONT.H *
* *
* Programmer : Scott K. Bowen *
* *
* Start Date : June 27, 1994 *
* *
* Last Update : June 29, 1994 [SKB] *
* *
*-------------------------------------------------------------------------*
* Functions: *
* VVPC::Text_Print -- Text print into a virtual viewport. *
* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
#ifndef FONT_H
#define FONT_H
#ifndef GBUFFER_H
#include <gbuffer.h>
#endif
#ifndef VBUFFER_H
#include <vbuffer.h>
#endif
//////////////////////////////////////// Defines //////////////////////////////////////////
// defines for font header, offsets to block offsets
#define FONTINFOBLOCK 4
#define FONTOFFSETBLOCK 6
#define FONTWIDTHBLOCK 8
#define FONTDATABLOCK 10
#define FONTHEIGHTBLOCK 12
// defines for font info block
#define FONTINFOMAXHEIGHT 4
#define FONTINFOMAXWIDTH 5
//////////////////////////////////////// Prototypes //////////////////////////////////////////
/*=========================================================================*/
/* The following prototypes are for the file: SET_FONT.CPP */
/*=========================================================================*/
VOID *cdecl Set_Font(VOID const *fontptr);
/*=========================================================================*/
/* The following prototypes are for the file: FONT.CPP */
/*=========================================================================*/
WORD cdecl Char_Pixel_Width(BYTE chr);
UWORD cdecl String_Pixel_Width(BYTE const *string);
VOID cdecl Get_Next_Text_Print_XY(GraphicViewPortClass& vp, ULONG offset, INT *x, INT *y);
VOID cdecl Get_Next_Text_Print_XY(VideoViewPortClass& vp, ULONG offset, INT *x, INT *y);
/*=========================================================================*/
/* The following prototypes are for the file: LOADFONT.CPP */
/*=========================================================================*/
VOID *cdecl Load_Font(BYTE const *name);
/*=========================================================================*/
/* The following prototypes are for the file: TEXTPRNT.ASM */
/*=========================================================================*/
#ifdef __cplusplus
extern "C" {
#endif
VOID Set_Font_Palette_Range(VOID const *palette, INT start_idx, INT end_idx);
#ifdef __cplusplus
}
#endif
/*=========================================================================*/
//////////////////////////////////////// External varables ///////////////////////////////////////
extern "C" int FontXSpacing;
extern "C" int FontYSpacing;
extern BYTE FontWidth ;
extern BYTE FontHeight;
extern BYTE *FontWidthBlockPtr;
extern "C" void const *FontPtr;
#endif // FONT_H

122
WWFLAT32/FONT/LOADFONT.BAK Normal file
View File

@@ -0,0 +1,122 @@
/*
** 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 : LOADFONT.C *
* *
* Programmer : Joe L. Bostic *
* *
* Start Date : September 6, 1991 *
* *
* Last Update : June 27, 1994 [SKB] *
* *
*-------------------------------------------------------------------------*
* Functions: *
* Load_Font -- Loads a font from disk. *
* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
#include <wwstd.h>
#include "font.h"
#include <file.h>
#include <wwmem.h>
#if(IBM)
#include <fcntl.h>
#include <io.h>
#endif
extern "C" {
int FontXSpacing = 0;
int FontYSpacing = 0;
void const *FontPtr = NULL;
}
BYTE FontWidth = 8;
BYTE FontHeight = 8;
// only font.c and set_font.c use the following
BYTE *FontWidthBlockPtr = NULL;
/***************************************************************************
* LOAD_FONT -- Loads a font from disk. *
* *
* This loads a font from disk. This function must be called as a *
* precursor to calling Set_Font(). You need only call this function *
* once per desired font at the beginning of your code, but AFTER *
* Prog_Init() is called. *
* *
* INPUT: name - Pointer to font name to use (eg. "topaz.font") *
* *
* fontsize - Size in points of the font loaded. *
* *
* OUTPUT: Pointer to font data or NULL if unable to load. *
* *
* WARNINGS: Some system memory is grabbed by this routine. *
* *
* HISTORY: *
* 4/10/91 BS : 2.0 compatibily *
* 6/09/91 JLB : IBM and Amiga compatability. *
* 11/27/1991 JLB : Uses file I/O routines for disk access. *
* 01/29/1992 DRD : Modified to use new font format. *
* 02/01/1992 DRD : Added font file verification. *
* 06/29/1994 SKB : modified for 32 bit library *
*=========================================================================*/
VOID *cdecl Load_Font(BYTE const *name)
{
BYTE valid;
WORD fh; // DOS file handle for font file.
UWORD size; // Size of the data in the file (-2);
BYTE *ptr = NULL; // Pointer to newly loaded font.
if (Find_File(name)) {
fh = Open_File(name, READ);
if (Read_File(fh, (BYTE *) &size, 2) != 2) return(NULL);
ptr = (BYTE *) Alloc(size, MEM_NORMAL);
*(WORD *)ptr = size;
Read_File(fh, ptr + 2, size - 2);
Close_File(fh);
} else {
return (NULL);
}
//
// verify that the file loaded is a valid font file.
//
valid = FALSE;
if (*(ptr + 2) == 0) { // no compression
if (*(ptr + 3) == 5) { // currently only 5 data blocks are used.
valid = TRUE;
}
}
if ( !valid ) {
return (NULL);
}
return(ptr);
}

120
WWFLAT32/FONT/LOADFONT.CPP Normal file
View File

@@ -0,0 +1,120 @@
/*
** 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 : LOADFONT.C *
* *
* Programmer : Joe L. Bostic *
* *
* Start Date : September 6, 1991 *
* *
* Last Update : June 27, 1994 [SKB] *
* *
*-------------------------------------------------------------------------*
* Functions: *
* Load_Font -- Loads a font from disk. *
* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
#include <wwstd.h>
#include "font.h"
#include <file.h>
#include <wwmem.h>
#if(IBM)
#include <fcntl.h>
#include <io.h>
#endif
int FontXSpacing = 0;
int FontYSpacing = 0;
void const *FontPtr = NULL;
BYTE FontWidth = 8;
BYTE FontHeight = 8;
// only font.c and set_font.c use the following
BYTE *FontWidthBlockPtr = NULL;
/***************************************************************************
* LOAD_FONT -- Loads a font from disk. *
* *
* This loads a font from disk. This function must be called as a *
* precursor to calling Set_Font(). You need only call this function *
* once per desired font at the beginning of your code, but AFTER *
* Prog_Init() is called. *
* *
* INPUT: name - Pointer to font name to use (eg. "topaz.font") *
* *
* fontsize - Size in points of the font loaded. *
* *
* OUTPUT: Pointer to font data or NULL if unable to load. *
* *
* WARNINGS: Some system memory is grabbed by this routine. *
* *
* HISTORY: *
* 4/10/91 BS : 2.0 compatibily *
* 6/09/91 JLB : IBM and Amiga compatability. *
* 11/27/1991 JLB : Uses file I/O routines for disk access. *
* 01/29/1992 DRD : Modified to use new font format. *
* 02/01/1992 DRD : Added font file verification. *
* 06/29/1994 SKB : modified for 32 bit library *
*=========================================================================*/
VOID *cdecl Load_Font(BYTE const *name)
{
BYTE valid;
WORD fh; // DOS file handle for font file.
UWORD size; // Size of the data in the file (-2);
BYTE *ptr = NULL; // Pointer to newly loaded font.
if (Find_File(name)) {
fh = Open_File(name, READ);
if (Read_File(fh, (BYTE *) &size, 2) != 2) return(NULL);
ptr = (BYTE *) Alloc(size, MEM_NORMAL);
*(WORD *)ptr = size;
Read_File(fh, ptr + 2, size - 2);
Close_File(fh);
} else {
return (NULL);
}
//
// verify that the file loaded is a valid font file.
//
valid = FALSE;
if (*(ptr + 2) == 0) { // no compression
if (*(ptr + 3) == 5) { // currently only 5 data blocks are used.
valid = TRUE;
}
}
if ( !valid ) {
return (NULL);
}
return(ptr);
}

195
WWFLAT32/FONT/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 24, 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 = font
PROJ_DIR = $(%WWFLAT)\$(PROJ_NAME)
LIB_DIR = $(%WWFLAT)\lib
!include $(%WWFLAT)\project.cfg
#---------------------------------------------------------------------------
# Project-dependent variables
#---------------------------------------------------------------------------
OBJECTS = &
font.obj &
loadfont.obj &
set_font.obj &
setfpal.obj &
textprnt.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
mkdir run
cd run
copy $(%WWVCS)\$(PROJ_NAME)\test\run\vcs.cfg
update
cd..
mkdir art
cd art
copy $(%WWVCS)\$(PROJ_NAME)\test\art\vcs.cfg
update
cd..
wmake
cd ..
#**************************** End of makefile ******************************

106
WWFLAT32/FONT/SETFPAL.ASM Normal file
View File

@@ -0,0 +1,106 @@
;
; Command & Conquer Red Alert(tm)
; Copyright 2025 Electronic Arts Inc.
;
; This program is free software: you can redistribute it and/or modify
; it under the terms of the GNU General Public License as published by
; the Free Software Foundation, either version 3 of the License, or
; (at your option) any later version.
;
; This program is distributed in the hope that it will be useful,
; but WITHOUT ANY WARRANTY; without even the implied warranty of
; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
; GNU General Public License for more details.
;
; You should have received a copy of the GNU General Public License
; along with this program. If not, see <http://www.gnu.org/licenses/>.
;
;***************************************************************************
;** C O N F I D E N T I A L --- W E S T W O O D S T U D I O S **
;***************************************************************************
;* *
;* Project Name : 32 bit library Text Print *
;* *
;* File Name : TEXTPRNT.ASM *
;* *
;* Programmer : Scott K. Bowen *
;* *
;* Start Date : July 2, 1994 *
;* *
;* Last Update : July 2, 1994 [SKB] *
;* *
;*-------------------------------------------------------------------------*
;* Functions: *
;* Text_Print -- Assembly text print routine. *
;* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - *
IDEAL
P386
MODEL USE32 FLAT
GLOBAL ColorXlat:BYTE
GLOBAL Set_Font_Palette_Range:NEAR
CODESEG
;***********************************************************
; SET_FONT_PALETTE_RANGE
;
; VOID Set_Font_Palette_Range(VOID *palette, WORD start, WORD end);
;
; This routine changes the local Draw_Char color translation table
; with the color numbers in palette.
;
; Bounds Checking: forces start and end to a range of 0-15
;*
PROC Set_Font_Palette_Range C near
USES eax, ebx, ecx,edi,esi
ARG palette:DWORD
ARG start:DWORD
ARG endval:DWORD
cld
mov esi,[palette]
mov ebx,[start]
and ebx,0FH ; value 0-15
mov ecx,[endval]
and ecx,0FH ; value 0-15
cmp ecx,ebx ; if end < start then exit
jl short ??exit
sub ecx,ebx ; number of colors = end - start + 1
inc ecx
mov edi,OFFSET ColorXlat ; get start of xlat table
add edi,ebx ; add starting offset
shl ebx,4 ; multiply start offset by 16
add ebx,OFFSET ColorXlat ; add start of xlat table
; updates 0-15 for lonibble xlat
; updates 0,16,32,...,240 for hinibble xlat
??setpal:
lodsb ; get color number
stosb ; save color number for lonibble xlat
mov [ebx],al ; save color number for hinibble xlat
add ebx,010H ; add 16 to index for hinibble offset
dec ecx
jnz ??setpal
??exit:
ret
ENDP Set_Font_Palette_Range
;***********************************************************
;***********************************************************
END

View File

@@ -0,0 +1,89 @@
/*
** 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 : SET_FONT.C *
* *
* Programmer : Joe L. Bostic *
* *
* Start Date : September 6, 1991 *
* *
* Last Update : June 29, 1994 [SKB] *
* *
*-------------------------------------------------------------------------*
* Functions: *
* Set_Font -- Changes the default text printing font. *
* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
#include <wwstd.h>
#include "font.h"
/***************************************************************************
* SET_FONT -- Changes the default text printing font. *
* *
* This routine will change the default text printing font for all *
* text output. It handles updating the system where necessary. *
* *
* INPUT: fontptr -- Pointer to the font to change to. *
* *
* OUTPUT: Returns with a pointer to the previous font. *
* *
* WARNINGS: none *
* *
* HISTORY: *
* 09/06/1991 JLB : Created. *
* 09/17/1991 JLB : Fixed return value bug. *
* 01/31/1992 DRD : Modified to use new font format. *
* 06/29/1994 SKB : modified for 32 bit library *
*=========================================================================*/
VOID *cdecl Set_Font(VOID const *fontptr)
{
VOID *oldfont;
BYTE const *blockptr;
oldfont = (VOID *) FontPtr;
if (fontptr) {
FontPtr = (VOID *) fontptr;
/*
** Inform the system about the new font.
*/
FontWidthBlockPtr = (BYTE*)fontptr + *(UWORD *)((BYTE*)fontptr + FONTWIDTHBLOCK);
blockptr = (BYTE*)fontptr + *(UWORD *)((BYTE*)fontptr + FONTINFOBLOCK);
FontHeight = *(blockptr + FONTINFOMAXHEIGHT);
FontWidth = *(blockptr + FONTINFOMAXWIDTH);
//Draw_Char_Setup();
#if FALSE
WindowLines = WinH / FontHeight;
WindowWidth = WinW << 3;
WindowColumns = WindowWidth / FontWidth;
#endif
}
return(oldfont);
}

436
WWFLAT32/FONT/TEXTPRNT.ASM Normal file
View File

@@ -0,0 +1,436 @@
;
; Command & Conquer Red Alert(tm)
; Copyright 2025 Electronic Arts Inc.
;
; This program is free software: you can redistribute it and/or modify
; it under the terms of the GNU General Public License as published by
; the Free Software Foundation, either version 3 of the License, or
; (at your option) any later version.
;
; This program is distributed in the hope that it will be useful,
; but WITHOUT ANY WARRANTY; without even the implied warranty of
; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
; GNU General Public License for more details.
;
; You should have received a copy of the GNU General Public License
; along with this program. If not, see <http://www.gnu.org/licenses/>.
;
;***************************************************************************
;** C O N F I D E N T I A L --- W E S T W O O D S T U D I O S **
;***************************************************************************
;* *
;* Project Name : 32 bit library Text Print *
;* *
;* File Name : TEXTPRNT.ASM *
;* *
;* Programmer : Scott K. Bowen *
;* *
;* Start Date : July 2, 1994 *
;* *
;* Last Update : July 2, 1994 [SKB] *
;* *
;*-------------------------------------------------------------------------*
;* Functions: *
;* Text_Print -- Assembly text print routine. *
;* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - *
IDEAL
P386
MODEL USE32 FLAT
GLOBAL C FontPtr:DWORD
GLOBAL Text_Print:NEAR
; The header of the font file looks like this:
; UWORD FontLength; 0
; BYTE FontCompress; 2
; BYTE FontDataBlocks; 3
; UWORD InfoBlockOffset; 4
; UWORD OffsetBlockOffset; 6
; UWORD WidthBlockOffset; 8
; UWORD DataBlockOffset; 10
; UWORD HeightOffset; 12
; For this reason the following equates have these values:
FONTINFOBLOCK EQU 4
FONTOFFSETBLOCK EQU 6
FONTWIDTHBLOCK EQU 8
FONTDATABLOCK EQU 10
FONTHEIGHTBLOCK EQU 12
FONTINFOMAXHEIGHT EQU 4
FONTINFOMAXWIDTH EQU 5
LOCALS ??
DATASEG
ColorXlat DB 000H,001H,002H,003H,004H,005H,006H,007H
DB 008H,009H,00AH,00BH,00CH,00DH,00EH,00FH
DB 001H,000H,000H,000H,000H,000H,000H,000H
DB 000H,000H,000H,000H,000H,000H,000H,000H
DB 002H,000H,000H,000H,000H,000H,000H,000H
DB 000H,000H,000H,000H,000H,000H,000H,000H
DB 003H,000H,000H,000H,000H,000H,000H,000H
DB 000H,000H,000H,000H,000H,000H,000H,000H
DB 004H,000H,000H,000H,000H,000H,000H,000H
DB 000H,000H,000H,000H,000H,000H,000H,000H
DB 005H,000H,000H,000H,000H,000H,000H,000H
DB 000H,000H,000H,000H,000H,000H,000H,000H
DB 006H,000H,000H,000H,000H,000H,000H,000H
DB 000H,000H,000H,000H,000H,000H,000H,000H
DB 007H,000H,000H,000H,000H,000H,000H,000H
DB 000H,000H,000H,000H,000H,000H,000H,000H
DB 008H,000H,000H,000H,000H,000H,000H,000H
DB 000H,000H,000H,000H,000H,000H,000H,000H
DB 009H,000H,000H,000H,000H,000H,000H,000H
DB 000H,000H,000H,000H,000H,000H,000H,000H
DB 00AH,000H,000H,000H,000H,000H,000H,000H
DB 000H,000H,000H,000H,000H,000H,000H,000H
DB 00BH,000H,000H,000H,000H,000H,000H,000H
DB 000H,000H,000H,000H,000H,000H,000H,000H
DB 00CH,000H,000H,000H,000H,000H,000H,000H
DB 000H,000H,000H,000H,000H,000H,000H,000H
DB 00DH,000H,000H,000H,000H,000H,000H,000H
DB 000H,000H,000H,000H,000H,000H,000H,000H
DB 00EH,000H,000H,000H,000H,000H,000H,000H
DB 000H,000H,000H,000H,000H,000H,000H,000H
DB 00FH
CODESEG
;***************************************************************************
;* TEXT_PRINT -- Assembly text print routine. *
;* *
;* *
;* INPUT: *
;* *
;* OUTPUT: *
;* *
;* WARNINGS: *
;* *
;* HISTORY: *
;* 06/28/1994 SKB : Created. *
;*=========================================================================*
PROC Text_Print C near
USES ebx,ecx,edx,esi,edi
ARG vpselector:WORD
ARG vpoffset:DWORD
ARG vpwidth:DWORD
ARG vpheight:DWORD
ARG vpxadd:DWORD
ARG string:DWORD
ARG x_pixel:DWORD
ARG y_pixel:DWORD
ARG fcolor:DWORD
ARG bcolor:DWORD
LOCAL infoblock:DWORD ; pointer to info block
LOCAL offsetblock:DWORD ; pointer to offset block (UWORD *)
LOCAL widthblock:DWORD ; pointer to width block (BYTE *)
LOCAL heightblock:DWORD ; pointer to height block (UWORD *)
LOCAL curline:DWORD ; pointer to first column of current row.
LOCAL bufferwidth:DWORD ; width of buffer (vpwidth + Xadd)
LOCAL nextdraw:DWORD ; bufferwidth - width of cur character.
LOCAL startdraw:DWORD ; where next character will start being drawn.
LOCAL char:DWORD ; current character value.
LOCAL maxheight:BYTE ; max height of characters in font.
LOCAL bottomblank:BYTE ; amount of empty space below current character.
LOCAL charheight:BYTE ; true height of current character.
;-------------------------------- Where to draw -----------------------------------------------
; Set up memory location to start drawing.
movzx eax,[vpselector]
mov es,ax ; Set up selector to write to.
mov eax,[vpwidth] ; get the width of the viewport
add eax,[vpxadd] ; add amount to add to get to left edge of next line.
mov [bufferwidth],eax ; save it off for later use.
mul [y_pixel] ; multiply rowsize * y_pixel start.
mov edi,[vpoffset] ; get start of the viewport
add edi,eax ; add x,y position to start of vp to get starting row address.
mov [curline],edi ; save 0,y address for line feed stuff.
add edi,[x_pixel] ; add to get starting column in starting row.
mov [startdraw],edi ; save it off.
;-------------------------------- Create block pointers ----------------------------------------
; Get the pointer to the font.
; We could check for NULL but why waste the time.
; It is up to programmer to make sure it is set.
mov esi,[FontPtr] ; Get the font pointer
; Set up some pointers to the different memory blocks.
; esi (FontPtr) is added to each to get the true address of each block.
; Many registers are used for P5 optimizations.
; ebx is used for InfoBlock which is then used in the next section.
movzx eax,[WORD PTR esi+FONTOFFSETBLOCK] ; get offset to offset block
movzx ebx,[WORD PTR esi+FONTINFOBLOCK] ; get offset to info block (must be ebx for height test)
movzx ecx,[WORD PTR esi+FONTWIDTHBLOCK] ; get offset to width block
movzx edx,[WORD PTR esi+FONTHEIGHTBLOCK] ; get offset to height block
add eax,esi ; add offset of FontPtr to offset block
add ebx,esi ; add offset of FontPtr to info block
add ecx,esi ; add offset of FontPtr to width block
add edx,esi ; add offset of FontPtr to height block
mov [offsetblock],eax ; save offset to offset block
mov [infoblock],ebx ; save offset to info block
mov [widthblock],ecx ; save offset to width block
mov [heightblock],edx ; save offset to height block
;------------------------------------------ Test for fit ----------------------------------------------
; Test to make sure the height of the max character will fit on this line
; and and not fall out of the viewport.
; remember we set ebx to FONTINFOBLOCK above.
movzx eax,[BYTE PTR ebx + FONTINFOMAXHEIGHT]; get the max height in font.
mov [maxheight],al ; save it for later use.
add eax,[y_pixel] ; add current y_value.
cmp eax,[vpheight] ; are we over the edge?
jg ??overflow ; if so, we're outa here.
mov [y_pixel],eax ; save for next line feed. y value for next line.
cld ; Make sure we are always forward copying.
;------------------------ Set palette foreground and background ----------------------------------
mov eax,[fcolor] ; foreground color
mov [ColorXlat+1],al
mov [ColorXlat+16],al
mov eax,[bcolor] ; background color
mov [ColorXlat],al
;-------------------------------------------------------------------------------------------------
;----------------------------------------- Main loop ----------------------------------------------
; Now we go into the main loop of reading each character in the string and doing
; something with it.
??next_char:
; while (*string++)
xor eax,eax ; zero out since we will just load al.
mov esi,[string] ; get address on next character.
lodsb ; load the character into al.
test eax,0FFH ; test to see if character is a NULL
jz ??done ; character is NULL, get outa here.
mov edi,[startdraw] ; Load the starting address.
mov [string],esi ; save index into string. (incremented by lodsb)
cmp eax,13 ; is the character a line feed?
je ??line_feed ; if so, go to special case.
mov [char],eax ; save the character off for later reference.
mov ebx,eax ; save it in ebx for later use also.
add eax,[widthblock] ; figure address of width of character.
mov ecx,[x_pixel] ; get current x_pixel.
movzx edx,[BYTE PTR eax] ; get the width of the character in dl.
add ecx,edx ; add width of char to current x_pixel.
add [startdraw],edx ; save start draw for next character.
cmp ecx,[vpwidth] ; is the pixel greater then the vp width?
jg ??force_line_feed ; if so, force a line feed.
mov [x_pixel],ecx ; save value of start of next character.
mov ecx,[bufferwidth] ; get amount to next y same x (one row down)
sub ecx,edx ; take the current width off.
mov [nextdraw],ecx ; save it to add to edi when done with a row.
; At this point we got the character. It is now time to find out specifics
; about drawing the darn thing.
; ebx = char so they can be used as an indexes.
; edx = width of character for loop later.
; get offset of data for character into esi.
shl ebx,1 ; mult by 2 to later use as a WORD index.
mov esi,[offsetblock] ; get pointer to begining of offset block.
add esi,ebx ; index into offset block.
movzx esi,[WORD PTR esi] ; get true offset into data block from FontPtr.
add esi,[FontPtr] ; Now add FontPtr address to get true address.
; Get top and bottom blank sizes and the true height of the character.
add ebx,[heightblock] ; point ebx to element in height array.
mov al,[ebx+1] ; load the data height into dl.
mov cl,[ebx] ; load the first data row into cl.
mov bl,[maxheight] ; get the max height of characters.
mov [charheight],al ; get number of rows with data.
add al,cl ; add the two heights.
sub bl,al ; subract topblank + char height from maxheight.
mov [bottomblank],bl ; save off the number of blank rows on the bottom.
; leaving this section:
; dl is still the width of the character.
; cl is the height of the top blank area.
mov ebx,OFFSET ColorXlat ; setup ebx for xlat commands.
mov dh,dl ; save the width of the character to restore each loop.
cmp cl,0 ; is there any blank rows on top?
jz ??draw_char ; if not go and draw the real character.
xor eax,eax ; get color 0 for background.
xlat [ebx] ; get translated color into al
test al,al ; is it transparent black
jnz ??loop_top ; if not go and write the color
;----------------------------------------- skip Top blank area ----------------------------------------
; this case, the top is transparrent, but we need to increase our dest pointer to correct row.
movzx eax,cl ; get number of rows into eax;
mov ecx,edx ; save width since edx will be destroyed by mul.
mul [bufferwidth] ; multiply that by the width of the buffer.
mov edx,ecx ; restore the width
add edi,eax ; update the pointer.
jmp short ??draw_char ; now go draw the character.
;----------------------------------------- fill Top blank area ----------------------------------------
; edi was set a long time ago.
; al is the translated color
??loop_top:
stosb ; store the value
dec dh ; decrement our width.
jnz ??loop_top ; if more width, continue on.
add edi,[nextdraw] ; add amount for entire row.
dec cl ; decrement or row count
mov dh,dl ; restore width in dh for loop.
jz ??draw_char ; we are done here, go draw the character.
jmp short ??loop_top ; go back to top of loop.
;----------------------------------------- Draw character ----------------------------------------------
??draw_char:
movzx ecx,[charheight] ; get the height of character to count down rows.
test ecx,ecx ; is there any data? (blank would not have any)
jz ??next_char ; if no data, go on to next character.
??while_data:
lodsb ; get byte value from font data
mov ah,al ; save hinibble
and eax,0F00FH ; mask of low nibble in al hi nibble in ah.
xlat [ebx] ; get new color
test al,al ; is it a transparent?
jz short ??skiplo ; skip over write
mov [es:edi],al ; write it out
??skiplo:
inc edi
dec dh ; decrement our width.
jz short ??nextrow ; check if done with width of char
mov al,ah ; restore to get
; test the time difference between looking up in a large table when shr al,4 is not done as
; compared to using only a 16 byte table when using the shr al,4
;shr al,4 ; shift the hi nibble down to low nibble
xlat [ebx] ; get new color
test al,al ; is it a transparent?
jz short ??skiphi ; skip over write
mov [es:edi],al ; write it out
??skiphi:
inc edi
dec dh ; decrement our width.
jnz short ??while_data ; check if done with width of char
??nextrow:
add edi,[nextdraw] ; go to next line.
dec ecx ; decrement the number of rows to go
mov dh,dl ; restore our column count for row.
jnz ??while_data ; more data for character.
; Now it is time to setup for clearing out the bottom of the character.
movzx ecx,[bottomblank] ; get amount on bottom that is blank
cmp ecx,0 ; if there is no blank bottom...
jz ??next_char ; then skip to go to next character
xor eax,eax ; get color 0 for background.
xlat [ebx] ; get translated color into al
test al,al ; is it transparent black
jz ??next_char ; skip the top black section to let the background through
mov dh,dl ; restore width in dh for loop.
;----------------------------------------- Blank below character -----------------------------------
??loop_bottom:
stosb ; store the value
dec dh ; decrement our width.
jnz ??loop_bottom ; if more width, continue on.
add edi,[nextdraw] ; add amount for entire row.
mov dh,dl ; restore width in dh for loop.
dec cl ; decrement or row count
jz ??next_char ; we are done here, go to the next character.
jmp short ??loop_bottom ; go back to top of loop.
;----------------------------------- end of next_char (main) loop ------------------------------------
;-------------------------------------------------------------------------------------------------
;----------------------------------- special case line feeds ----------------------------------------
??force_line_feed:
; decrement pointer *string so that it will be back at same character
; when it goes through the loop.
mov eax,[string] ; get string pointer.
dec eax ; decrement it to point to previos char
mov [string],eax ; save it back off.
; Now go into the line feed code.....
??line_feed:
mov edx,[y_pixel] ; get the current y pixel value.
movzx ecx,[maxheight] ; get max height for later use.
add edx,ecx ; add max height to y_pixel
cmp edx,[vpheight] ; are we over the edge?
jg ??overflow ; if so, we are outa here.
mov eax,[bufferwidth] ; get bytes to next line.
mov edi,[curline] ; get start of current line.
mul ecx ; mult max height * next line.
add edi,eax ; add adjustment to current line.
add [y_pixel],ecx ; increment to our next y position.
mov [curline],edi ; save it off for next line_feed.
mov [startdraw],edi ; save it off so we know where to draw next char.w
mov [x_pixel],0 ; zero out x_pixel
jmp ??next_char
??overflow:
mov [startdraw],0 ; Indicate that there is no valid next pos.
??done:
mov eax,[startdraw] ; return this so calling routine
ret ; can figure out where to draw next.
ENDP Text_Print
;***********************************************************
END

436
WWFLAT32/FONT/TEXTPRNT.BAK Normal file
View File

@@ -0,0 +1,436 @@
;
; Command & Conquer Red Alert(tm)
; Copyright 2025 Electronic Arts Inc.
;
; This program is free software: you can redistribute it and/or modify
; it under the terms of the GNU General Public License as published by
; the Free Software Foundation, either version 3 of the License, or
; (at your option) any later version.
;
; This program is distributed in the hope that it will be useful,
; but WITHOUT ANY WARRANTY; without even the implied warranty of
; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
; GNU General Public License for more details.
;
; You should have received a copy of the GNU General Public License
; along with this program. If not, see <http://www.gnu.org/licenses/>.
;
;***************************************************************************
;** C O N F I D E N T I A L --- W E S T W O O D S T U D I O S **
;***************************************************************************
;* *
;* Project Name : 32 bit library Text Print *
;* *
;* File Name : TEXTPRNT.ASM *
;* *
;* Programmer : Scott K. Bowen *
;* *
;* Start Date : July 2, 1994 *
;* *
;* Last Update : July 2, 1994 [SKB] *
;* *
;*-------------------------------------------------------------------------*
;* Functions: *
;* Text_Print -- Assembly text print routine. *
;* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - *
IDEAL
P386
MODEL USE32 FLAT
GLOBAL FontPtr:DWORD
GLOBAL Text_Print:NEAR
; The header of the font file looks like this:
; UWORD FontLength; 0
; BYTE FontCompress; 2
; BYTE FontDataBlocks; 3
; UWORD InfoBlockOffset; 4
; UWORD OffsetBlockOffset; 6
; UWORD WidthBlockOffset; 8
; UWORD DataBlockOffset; 10
; UWORD HeightOffset; 12
; For this reason the following equates have these values:
FONTINFOBLOCK EQU 4
FONTOFFSETBLOCK EQU 6
FONTWIDTHBLOCK EQU 8
FONTDATABLOCK EQU 10
FONTHEIGHTBLOCK EQU 12
FONTINFOMAXHEIGHT EQU 4
FONTINFOMAXWIDTH EQU 5
LOCALS ??
DATASEG
ColorXlat DB 000H,001H,002H,003H,004H,005H,006H,007H
DB 008H,009H,00AH,00BH,00CH,00DH,00EH,00FH
DB 001H,000H,000H,000H,000H,000H,000H,000H
DB 000H,000H,000H,000H,000H,000H,000H,000H
DB 002H,000H,000H,000H,000H,000H,000H,000H
DB 000H,000H,000H,000H,000H,000H,000H,000H
DB 003H,000H,000H,000H,000H,000H,000H,000H
DB 000H,000H,000H,000H,000H,000H,000H,000H
DB 004H,000H,000H,000H,000H,000H,000H,000H
DB 000H,000H,000H,000H,000H,000H,000H,000H
DB 005H,000H,000H,000H,000H,000H,000H,000H
DB 000H,000H,000H,000H,000H,000H,000H,000H
DB 006H,000H,000H,000H,000H,000H,000H,000H
DB 000H,000H,000H,000H,000H,000H,000H,000H
DB 007H,000H,000H,000H,000H,000H,000H,000H
DB 000H,000H,000H,000H,000H,000H,000H,000H
DB 008H,000H,000H,000H,000H,000H,000H,000H
DB 000H,000H,000H,000H,000H,000H,000H,000H
DB 009H,000H,000H,000H,000H,000H,000H,000H
DB 000H,000H,000H,000H,000H,000H,000H,000H
DB 00AH,000H,000H,000H,000H,000H,000H,000H
DB 000H,000H,000H,000H,000H,000H,000H,000H
DB 00BH,000H,000H,000H,000H,000H,000H,000H
DB 000H,000H,000H,000H,000H,000H,000H,000H
DB 00CH,000H,000H,000H,000H,000H,000H,000H
DB 000H,000H,000H,000H,000H,000H,000H,000H
DB 00DH,000H,000H,000H,000H,000H,000H,000H
DB 000H,000H,000H,000H,000H,000H,000H,000H
DB 00EH,000H,000H,000H,000H,000H,000H,000H
DB 000H,000H,000H,000H,000H,000H,000H,000H
DB 00FH
CODESEG
;***************************************************************************
;* TEXT_PRINT -- Assembly text print routine. *
;* *
;* *
;* INPUT: *
;* *
;* OUTPUT: *
;* *
;* WARNINGS: *
;* *
;* HISTORY: *
;* 06/28/1994 SKB : Created. *
;*=========================================================================*
PROC Text_Print C near
USES ebx,ecx,edx,esi,edi
ARG vpselector:WORD
ARG vpoffset:DWORD
ARG vpwidth:DWORD
ARG vpheight:DWORD
ARG vpxadd:DWORD
ARG string:DWORD
ARG x_pixel:DWORD
ARG y_pixel:DWORD
ARG fcolor:DWORD
ARG bcolor:DWORD
LOCAL infoblock:DWORD ; pointer to info block
LOCAL offsetblock:DWORD ; pointer to offset block (UWORD *)
LOCAL widthblock:DWORD ; pointer to width block (BYTE *)
LOCAL heightblock:DWORD ; pointer to height block (UWORD *)
LOCAL curline:DWORD ; pointer to first column of current row.
LOCAL bufferwidth:DWORD ; width of buffer (vpwidth + Xadd)
LOCAL nextdraw:DWORD ; bufferwidth - width of cur character.
LOCAL startdraw:DWORD ; where next character will start being drawn.
LOCAL char:DWORD ; current character value.
LOCAL maxheight:BYTE ; max height of characters in font.
LOCAL bottomblank:BYTE ; amount of empty space below current character.
LOCAL charheight:BYTE ; true height of current character.
;-------------------------------- Where to draw -----------------------------------------------
; Set up memory location to start drawing.
movzx eax,[vpselector]
mov es,ax ; Set up selector to write to.
mov eax,[vpwidth] ; get the width of the viewport
add eax,[vpxadd] ; add amount to add to get to left edge of next line.
mov [bufferwidth],eax ; save it off for later use.
mul [y_pixel] ; multiply rowsize * y_pixel start.
mov edi,[vpoffset] ; get start of the viewport
add edi,eax ; add x,y position to start of vp to get starting row address.
mov [curline],edi ; save 0,y address for line feed stuff.
add edi,[x_pixel] ; add to get starting column in starting row.
mov [startdraw],edi ; save it off.
;-------------------------------- Create block pointers ----------------------------------------
; Get the pointer to the font.
; We could check for NULL but why waste the time.
; It is up to programmer to make sure it is set.
mov esi,[FontPtr] ; Get the font pointer
; Set up some pointers to the different memory blocks.
; esi (FontPtr) is added to each to get the true address of each block.
; Many registers are used for P5 optimizations.
; ebx is used for InfoBlock which is then used in the next section.
movzx eax,[WORD PTR esi+FONTOFFSETBLOCK] ; get offset to offset block
movzx ebx,[WORD PTR esi+FONTINFOBLOCK] ; get offset to info block (must be ebx for height test)
movzx ecx,[WORD PTR esi+FONTWIDTHBLOCK] ; get offset to width block
movzx edx,[WORD PTR esi+FONTHEIGHTBLOCK] ; get offset to height block
add eax,esi ; add offset of FontPtr to offset block
add ebx,esi ; add offset of FontPtr to info block
add ecx,esi ; add offset of FontPtr to width block
add edx,esi ; add offset of FontPtr to height block
mov [offsetblock],eax ; save offset to offset block
mov [infoblock],ebx ; save offset to info block
mov [widthblock],ecx ; save offset to width block
mov [heightblock],edx ; save offset to height block
;------------------------------------------ Test for fit ----------------------------------------------
; Test to make sure the height of the max character will fit on this line
; and and not fall out of the viewport.
; remember we set ebx to FONTINFOBLOCK above.
movzx eax,[BYTE PTR ebx + FONTINFOMAXHEIGHT]; get the max height in font.
mov [maxheight],al ; save it for later use.
add eax,[y_pixel] ; add current y_value.
cmp eax,[vpheight] ; are we over the edge?
jg ??overflow ; if so, we're outa here.
mov [y_pixel],eax ; save for next line feed. y value for next line.
cld ; Make sure we are always forward copying.
;------------------------ Set palette foreground and background ----------------------------------
mov eax,[fcolor] ; foreground color
mov [ColorXlat+1],al
mov [ColorXlat+16],al
mov eax,[bcolor] ; background color
mov [ColorXlat],al
;-------------------------------------------------------------------------------------------------
;----------------------------------------- Main loop ----------------------------------------------
; Now we go into the main loop of reading each character in the string and doing
; something with it.
??next_char:
; while (*string++)
xor eax,eax ; zero out since we will just load al.
mov esi,[string] ; get address on next character.
lodsb ; load the character into al.
test eax,0FFH ; test to see if character is a NULL
jz ??done ; character is NULL, get outa here.
mov edi,[startdraw] ; Load the starting address.
mov [string],esi ; save index into string. (incremented by lodsb)
cmp eax,13 ; is the character a line feed?
je ??line_feed ; if so, go to special case.
mov [char],eax ; save the character off for later reference.
mov ebx,eax ; save it in ebx for later use also.
add eax,[widthblock] ; figure address of width of character.
mov ecx,[x_pixel] ; get current x_pixel.
movzx edx,[BYTE PTR eax] ; get the width of the character in dl.
add ecx,edx ; add width of char to current x_pixel.
add [startdraw],edx ; save start draw for next character.
cmp ecx,[vpwidth] ; is the pixel greater then the vp width?
jg ??force_line_feed ; if so, force a line feed.
mov [x_pixel],ecx ; save value of start of next character.
mov ecx,[bufferwidth] ; get amount to next y same x (one row down)
sub ecx,edx ; take the current width off.
mov [nextdraw],ecx ; save it to add to edi when done with a row.
; At this point we got the character. It is now time to find out specifics
; about drawing the darn thing.
; ebx = char so they can be used as an indexes.
; edx = width of character for loop later.
; get offset of data for character into esi.
shl ebx,1 ; mult by 2 to later use as a WORD index.
mov esi,[offsetblock] ; get pointer to begining of offset block.
add esi,ebx ; index into offset block.
movzx esi,[WORD PTR esi] ; get true offset into data block from FontPtr.
add esi,[FontPtr] ; Now add FontPtr address to get true address.
; Get top and bottom blank sizes and the true height of the character.
add ebx,[heightblock] ; point ebx to element in height array.
mov al,[ebx+1] ; load the data height into dl.
mov cl,[ebx] ; load the first data row into cl.
mov bl,[maxheight] ; get the max height of characters.
mov [charheight],al ; get number of rows with data.
add al,cl ; add the two heights.
sub bl,al ; subract topblank + char height from maxheight.
mov [bottomblank],bl ; save off the number of blank rows on the bottom.
; leaving this section:
; dl is still the width of the character.
; cl is the height of the top blank area.
mov ebx,OFFSET ColorXlat ; setup ebx for xlat commands.
mov dh,dl ; save the width of the character to restore each loop.
cmp cl,0 ; is there any blank rows on top?
jz ??draw_char ; if not go and draw the real character.
xor eax,eax ; get color 0 for background.
xlat [ebx] ; get translated color into al
test al,al ; is it transparent black
jnz ??loop_top ; if not go and write the color
;----------------------------------------- skip Top blank area ----------------------------------------
; this case, the top is transparrent, but we need to increase our dest pointer to correct row.
movzx eax,cl ; get number of rows into eax;
mov ecx,edx ; save width since edx will be destroyed by mul.
mul [bufferwidth] ; multiply that by the width of the buffer.
mov edx,ecx ; restore the width
add edi,eax ; update the pointer.
jmp short ??draw_char ; now go draw the character.
;----------------------------------------- fill Top blank area ----------------------------------------
; edi was set a long time ago.
; al is the translated color
??loop_top:
stosb ; store the value
dec dh ; decrement our width.
jnz ??loop_top ; if more width, continue on.
add edi,[nextdraw] ; add amount for entire row.
dec cl ; decrement or row count
mov dh,dl ; restore width in dh for loop.
jz ??draw_char ; we are done here, go draw the character.
jmp short ??loop_top ; go back to top of loop.
;----------------------------------------- Draw character ----------------------------------------------
??draw_char:
movzx ecx,[charheight] ; get the height of character to count down rows.
test ecx,ecx ; is there any data? (blank would not have any)
jz ??next_char ; if no data, go on to next character.
??while_data:
lodsb ; get byte value from font data
mov ah,al ; save hinibble
and eax,0F00FH ; mask of low nibble in al hi nibble in ah.
xlat [ebx] ; get new color
test al,al ; is it a transparent?
jz short ??skiplo ; skip over write
mov [es:edi],al ; write it out
??skiplo:
inc edi
dec dh ; decrement our width.
jz short ??nextrow ; check if done with width of char
mov al,ah ; restore to get
; test the time difference between looking up in a large table when shr al,4 is not done as
; compared to using only a 16 byte table when using the shr al,4
;shr al,4 ; shift the hi nibble down to low nibble
xlat [ebx] ; get new color
test al,al ; is it a transparent?
jz short ??skiphi ; skip over write
mov [es:edi],al ; write it out
??skiphi:
inc edi
dec dh ; decrement our width.
jnz short ??while_data ; check if done with width of char
??nextrow:
add edi,[nextdraw] ; go to next line.
dec ecx ; decrement the number of rows to go
mov dh,dl ; restore our column count for row.
jnz ??while_data ; more data for character.
; Now it is time to setup for clearing out the bottom of the character.
movzx ecx,[bottomblank] ; get amount on bottom that is blank
cmp ecx,0 ; if there is no blank bottom...
jz ??next_char ; then skip to go to next character
xor eax,eax ; get color 0 for background.
xlat [ebx] ; get translated color into al
test al,al ; is it transparent black
jz ??next_char ; skip the top black section to let the background through
mov dh,dl ; restore width in dh for loop.
;----------------------------------------- Blank below character -----------------------------------
??loop_bottom:
stosb ; store the value
dec dh ; decrement our width.
jnz ??loop_bottom ; if more width, continue on.
add edi,[nextdraw] ; add amount for entire row.
mov dh,dl ; restore width in dh for loop.
dec cl ; decrement or row count
jz ??next_char ; we are done here, go to the next character.
jmp short ??loop_bottom ; go back to top of loop.
;----------------------------------- end of next_char (main) loop ------------------------------------
;-------------------------------------------------------------------------------------------------
;----------------------------------- special case line feeds ----------------------------------------
??force_line_feed:
; decrement pointer *string so that it will be back at same character
; when it goes through the loop.
mov eax,[string] ; get string pointer.
dec eax ; decrement it to point to previos char
mov [string],eax ; save it back off.
; Now go into the line feed code.....
??line_feed:
mov edx,[y_pixel] ; get the current y pixel value.
movzx ecx,[maxheight] ; get max height for later use.
add edx,ecx ; add max height to y_pixel
cmp edx,[vpheight] ; are we over the edge?
jg ??overflow ; if so, we are outa here.
mov eax,[bufferwidth] ; get bytes to next line.
mov edi,[curline] ; get start of current line.
mul ecx ; mult max height * next line.
add edi,eax ; add adjustment to current line.
add [y_pixel],ecx ; increment to our next y position.
mov [curline],edi ; save it off for next line_feed.
mov [startdraw],edi ; save it off so we know where to draw next char.w
mov [x_pixel],0 ; zero out x_pixel
jmp ??next_char
??overflow:
mov [startdraw],0 ; Indicate that there is no valid next pos.
??done:
mov eax,[startdraw] ; return this so calling routine
ret ; can figure out where to draw next.
ENDP Text_Print
;***********************************************************
END