Initial commit of Command & Conquer Red Alert source code.
This commit is contained in:
180
WIN32LIB/MONO/MAKEFILE
Normal file
180
WIN32LIB/MONO/MAKEFILE
Normal file
@@ -0,0 +1,180 @@
|
||||
#
|
||||
# Command & Conquer Red Alert(tm)
|
||||
# Copyright 2025 Electronic Arts Inc.
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
|
||||
#***************************************************************************
|
||||
#** C O N F I D E N T I A L --- W E S T W O O D S T U D I O S **
|
||||
#***************************************************************************
|
||||
#* *
|
||||
#* Project Name : Westwood Library .LIB makefile *
|
||||
#* *
|
||||
#* File Name : MAKEFILE *
|
||||
#* *
|
||||
#* Programmer : Julio R. Jerez *
|
||||
#* *
|
||||
#* Start Date : Jan 26, 1995 *
|
||||
#* *
|
||||
#* *
|
||||
#*-------------------------------------------------------------------------*
|
||||
#* *
|
||||
#* Required environment variables: *
|
||||
#* WIN32LIB = your root WIN32LIB path *
|
||||
#* WIN32VCS = root directory for wwlib version control archive *
|
||||
#* COMPILER = your Watcom installation path *
|
||||
#* *
|
||||
#* Required changes to makefile: *
|
||||
#* PROJ_NAME = name of the library you're building *
|
||||
#* OBJECTS = list of objects in your library *
|
||||
#* *
|
||||
#* Optional changes to makefile: *
|
||||
#* PROJ_DIR = full pathname of your working directory *
|
||||
#* .path.xxx = full pathname where various file types live *
|
||||
#* *
|
||||
#***************************************************************************
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
# Verify user's environment
|
||||
#---------------------------------------------------------------------------
|
||||
!ifndef %WIN32LIB
|
||||
!error WIN32LIB Environment var not configured.
|
||||
!endif
|
||||
|
||||
!ifndef %WIN32VCS
|
||||
!error WIN32VCS Environment var not configured.
|
||||
!endif
|
||||
|
||||
!ifndef %WATCOM
|
||||
!error WATCOM Environment var not configured.
|
||||
!endif
|
||||
|
||||
|
||||
#===========================================================================
|
||||
# User-defined section: the user should tailor this section for each project
|
||||
#===========================================================================
|
||||
|
||||
PROJ_NAME = mono
|
||||
PROJ_DIR = $(%WIN32LIB)\$(PROJ_NAME)
|
||||
LIB_DIR = $(%WIN32LIB)\lib
|
||||
|
||||
!include $(%WIN32LIB)\project.cfg
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
# Project-dependent variables
|
||||
#---------------------------------------------------------------------------
|
||||
OBJECTS = &
|
||||
mono.obj
|
||||
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
# Path macros: one path for each file type.
|
||||
# These paths are used to tell make where to find/put each file type.
|
||||
#---------------------------------------------------------------------------
|
||||
.asm: $(PROJ_DIR)
|
||||
.c: $(PROJ_DIR)
|
||||
.cpp: $(PROJ_DIR)
|
||||
.h: $(PROJ_DIR)
|
||||
.obj: $(PROJ_DIR)
|
||||
.lib: $(%WIN32LIB)\lib
|
||||
.exe: $(PROJ_DIR)
|
||||
|
||||
#===========================================================================
|
||||
# Pre-defined section: there should be little need to modify this section.
|
||||
#===========================================================================
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
# Tools/commands
|
||||
#---------------------------------------------------------------------------
|
||||
C_CMD = wcc386
|
||||
CPP_CMD = wpp386
|
||||
LIB_CMD = wlib
|
||||
LINK_CMD = wlink
|
||||
ASM_CMD = tasm
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
# Include & library paths
|
||||
# If LIB & INCLUDE are already defined, they are used in addition to the
|
||||
# WWLIB32 lib & include; otherwise, they're constructed from
|
||||
# BCDIR & TNTDIR
|
||||
#---------------------------------------------------------------------------
|
||||
LIBPATH = $(%WIN32LIB)\LIB;$(%WATCOM)\LIB
|
||||
INCLUDEPATH = $(%WIN32LIB)\INCLUDE;$(%WATCOM)\H
|
||||
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
# Implicit rules
|
||||
# Compiler:
|
||||
# ($< = full dependent with path)
|
||||
# Assembler:
|
||||
# output obj's are constructed from .obj: & the $& macro
|
||||
# ($< = full dependent with path)
|
||||
# tasm's cfg file is not invoked as a response file.
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
.c.obj: $(%WIN32LIB)\project.cfg .AUTODEPEND
|
||||
$(C_CMD) $(CC_CFG) $<
|
||||
|
||||
.cpp.obj: $(%WIN32LIB)\project.cfg .AUTODEPEND
|
||||
$(CPP_CMD) $(CC_CFG) $(PROJ_DIR)\$^*.cpp
|
||||
$(CPP_CMD) $(CC_CFG) $(PROJ_DIR)\$^*.cpp
|
||||
.asm.obj: $(%WIN32LIB)\project.cfg
|
||||
$(ASM_CMD) $(ASM_CFG) $<
|
||||
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
# Default target: configuration files & library (in that order)
|
||||
#---------------------------------------------------------------------------
|
||||
all: $(LIB_DIR)\$(PROJ_NAME).lib .SYMBOLIC
|
||||
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
# Build the library
|
||||
# The original library is deleted by the librarian
|
||||
# Lib objects & -+ commands are constructed by substituting within the
|
||||
# $^@ macro (which expands to all target dependents, separated with
|
||||
# spaces)
|
||||
# Tlib's cfg file is not invoked as a response file.
|
||||
# All headers & source files are copied into WIN32LIB\SRCDEBUG, for debugging
|
||||
#---------------------------------------------------------------------------
|
||||
$(LIB_DIR)\$(PROJ_NAME).lib: $(OBJECTS) objects.lbc
|
||||
copy *.h $(%WIN32LIB)\include
|
||||
copy *.inc $(%WIN32LIB)\include
|
||||
copy *.cpp $(%WIN32LIB)\srcdebug
|
||||
copy *.asm $(%WIN32LIB)\srcdebug
|
||||
$(LIB_CMD) $(LIB_CFG) $^@ @objects.lbc
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
# Objects now have a link file which is NOT generated everytime. Instead
|
||||
# it just has its own dependacy rule.
|
||||
#---------------------------------------------------------------------------
|
||||
objects.lbc : $(OBJECTS)
|
||||
%create $^@
|
||||
for %index in ($(OBJECTS)) do %append $^@ +%index
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
# Create the test directory and make it.
|
||||
#---------------------------------------------------------------------------
|
||||
test:
|
||||
mkdir test
|
||||
cd test
|
||||
copy $(%WWVCS)\$(PROJ_NAME)\test\vcs.cfg
|
||||
update
|
||||
wmake
|
||||
cd ..
|
||||
|
||||
#**************************** End of makefile ******************************
|
||||
|
||||
|
169
WIN32LIB/MONO/MAKEFILE.BOR
Normal file
169
WIN32LIB/MONO/MAKEFILE.BOR
Normal file
@@ -0,0 +1,169 @@
|
||||
#
|
||||
# Command & Conquer Red Alert(tm)
|
||||
# Copyright 2025 Electronic Arts Inc.
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
|
||||
#***************************************************************************
|
||||
#** C O N F I D E N T I A L --- W E S T W O O D S T U D I O S **
|
||||
#***************************************************************************
|
||||
#* *
|
||||
#* Project Name : Westwood Library .LIB makefile *
|
||||
#* *
|
||||
#* File Name : MAKEFILE *
|
||||
#* *
|
||||
#* Programmer : Julio R. Jerez *
|
||||
#* *
|
||||
#* Start Date : Jan 26, 1995 *
|
||||
#* *
|
||||
#* *
|
||||
#*-------------------------------------------------------------------------*
|
||||
#* *
|
||||
#* Required environment variables: *
|
||||
#* WIN32LIB = your root WWFLAT path *
|
||||
#* WIN32VCS = root directory for wwlib version control archive *
|
||||
#* COMPILER = your Watcom installation path *
|
||||
#* *
|
||||
#* Required changes to makefile: *
|
||||
#* PROJ_NAME = name of the library you're building *
|
||||
#* OBJECTS = list of objects in your library *
|
||||
#* *
|
||||
#* Optional changes to makefile: *
|
||||
#* PROJ_DIR = full pathname of your working directory *
|
||||
#* .path.xxx = full pathname where various file types live *
|
||||
#* *
|
||||
#***************************************************************************
|
||||
|
||||
.AUTODEPEND
|
||||
#---------------------------------------------------------------------------
|
||||
# Verify user's environment
|
||||
#---------------------------------------------------------------------------
|
||||
!ifndef WIN32LIB
|
||||
!error WIN32LIB Environment var not configured.
|
||||
!endif
|
||||
|
||||
!ifndef WIN32VCS
|
||||
!error WIN32VCS Environment var not configured.
|
||||
!endif
|
||||
|
||||
!ifndef COMPILER
|
||||
!error COMPILER Environment var not configured.
|
||||
!endif
|
||||
|
||||
#===========================================================================
|
||||
# User-defined section: the user should tailor this section for each project
|
||||
#===========================================================================
|
||||
|
||||
PROJ_NAME = mono
|
||||
PROJ_DIR = $(WIN32LIB)\$(PROJ_NAME)
|
||||
LIB_DIR = $(WIN32LIB)\lib
|
||||
|
||||
!include $(WIN32LIB)\\project.cfg
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
# Project-dependent variables
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
OBJECTS = \
|
||||
mono.obj
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
# Path macros: one path for each file type.
|
||||
# These paths are used to tell make where to find/put each file type.
|
||||
#---------------------------------------------------------------------------
|
||||
.path.asm = $(PROJ_DIR)
|
||||
.path.c = $(PROJ_DIR)
|
||||
.path.cpp = $(PROJ_DIR)
|
||||
.path.h = $(PROJ_DIR)
|
||||
.path.obj = $(PROJ_DIR)
|
||||
.path.lib = $(WIN32LIB)\lib
|
||||
.path.exe = $(PROJ_DIR)
|
||||
|
||||
#===========================================================================
|
||||
# Pre-defined section: there should be little need to modify this section.
|
||||
#===========================================================================
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
# Tools/commands
|
||||
#---------------------------------------------------------------------------
|
||||
C_CMD = bcc32
|
||||
CPP_CMD = bcc32
|
||||
LIB_CMD = tlib
|
||||
LINK_CMD = tlink32
|
||||
ASM_CMD = tasm32
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
# Include & library paths
|
||||
# If LIB & INCLUDE are already defined, they are used in addition to the
|
||||
# WWLIB32 lib & include; otherwise, they're constructed from
|
||||
# BCDIR & TNTDIR
|
||||
#---------------------------------------------------------------------------
|
||||
LIBPATH = $(WIN32LIB)\LIB;$(COMPILER)\LIB
|
||||
INCLUDEPATH = $(WIN32LIB)\INCLUDE;$(COMPILER)\INCLUDE
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
# Implicit rules
|
||||
# Compiler:
|
||||
# ($< = full dependent with path)
|
||||
# Assembler:
|
||||
# output obj's are constructed from .obj: & the $& macro
|
||||
# ($< = full dependent with path)
|
||||
# tasm's cfg file is not invoked as a response file.
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
.c.obj:
|
||||
$(C_CMD) $(CC_CFG) $<
|
||||
|
||||
.cpp.obj:
|
||||
$(CPP_CMD) $(CC_CFG) $<
|
||||
|
||||
.asm.obj:
|
||||
$(ASM_CMD) $(ASM_CFG) $<
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
# Default target: configuration files & library (in that order)
|
||||
#---------------------------------------------------------------------------
|
||||
all: $(LIB_DIR)\$(PROJ_NAME).lib
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
# Build the library
|
||||
# The original library is deleted by the librarian
|
||||
# Lib objects & -+ commands are constructed by substituting within the
|
||||
# $^@ macro (which expands to all target dependents, separated with
|
||||
# spaces)
|
||||
# Tlib's cfg file is not invoked as a response file.
|
||||
# All headers & source files are copied into WIN32LIB\SRCDEBUG, for debugging
|
||||
#---------------------------------------------------------------------------
|
||||
$(LIB_DIR)\\$(PROJ_NAME).lib: $(OBJECTS)
|
||||
copy *.h $(WIN32LIB)\\include
|
||||
copy *.inc $(WIN32LIB)\\include
|
||||
copy *.cpp $(WIN32LIB)\\srcdebug
|
||||
copy *.asm $(WIN32LIB)\\srcdebug
|
||||
$(LIB_CMD) $< $(LIB_CFG) @&&|
|
||||
-+mono.obj
|
||||
|
|
||||
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
# Create the test directory and make it.
|
||||
#---------------------------------------------------------------------------
|
||||
test:
|
||||
mkdir test
|
||||
cd test
|
||||
copy $(WWVCS)\\$(PROJ_NAME)\test\vcs.cfg
|
||||
update
|
||||
wmake
|
||||
cd ..
|
||||
|
180
WIN32LIB/MONO/MAKEFILE.WAT
Normal file
180
WIN32LIB/MONO/MAKEFILE.WAT
Normal file
@@ -0,0 +1,180 @@
|
||||
#
|
||||
# Command & Conquer Red Alert(tm)
|
||||
# Copyright 2025 Electronic Arts Inc.
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
|
||||
#***************************************************************************
|
||||
#** C O N F I D E N T I A L --- W E S T W O O D S T U D I O S **
|
||||
#***************************************************************************
|
||||
#* *
|
||||
#* Project Name : Westwood Library .LIB makefile *
|
||||
#* *
|
||||
#* File Name : MAKEFILE *
|
||||
#* *
|
||||
#* Programmer : Julio R. Jerez *
|
||||
#* *
|
||||
#* Start Date : Jan 26, 1995 *
|
||||
#* *
|
||||
#* *
|
||||
#*-------------------------------------------------------------------------*
|
||||
#* *
|
||||
#* Required environment variables: *
|
||||
#* WIN32LIB = your root WIN32LIB path *
|
||||
#* WIN32VCS = root directory for wwlib version control archive *
|
||||
#* COMPILER = your Watcom installation path *
|
||||
#* *
|
||||
#* Required changes to makefile: *
|
||||
#* PROJ_NAME = name of the library you're building *
|
||||
#* OBJECTS = list of objects in your library *
|
||||
#* *
|
||||
#* Optional changes to makefile: *
|
||||
#* PROJ_DIR = full pathname of your working directory *
|
||||
#* .path.xxx = full pathname where various file types live *
|
||||
#* *
|
||||
#***************************************************************************
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
# Verify user's environment
|
||||
#---------------------------------------------------------------------------
|
||||
!ifndef %WIN32LIB
|
||||
!error WIN32LIB Environment var not configured.
|
||||
!endif
|
||||
|
||||
!ifndef %WIN32VCS
|
||||
!error WIN32VCS Environment var not configured.
|
||||
!endif
|
||||
|
||||
!ifndef %WATCOM
|
||||
!error WATCOM Environment var not configured.
|
||||
!endif
|
||||
|
||||
|
||||
#===========================================================================
|
||||
# User-defined section: the user should tailor this section for each project
|
||||
#===========================================================================
|
||||
|
||||
PROJ_NAME = mono
|
||||
PROJ_DIR = $(%WIN32LIB)\$(PROJ_NAME)
|
||||
LIB_DIR = $(%WIN32LIB)\lib
|
||||
|
||||
!include $(%WIN32LIB)\project.cfg
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
# Project-dependent variables
|
||||
#---------------------------------------------------------------------------
|
||||
OBJECTS = &
|
||||
mono.obj
|
||||
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
# Path macros: one path for each file type.
|
||||
# These paths are used to tell make where to find/put each file type.
|
||||
#---------------------------------------------------------------------------
|
||||
.asm: $(PROJ_DIR)
|
||||
.c: $(PROJ_DIR)
|
||||
.cpp: $(PROJ_DIR)
|
||||
.h: $(PROJ_DIR)
|
||||
.obj: $(PROJ_DIR)
|
||||
.lib: $(%WIN32LIB)\lib
|
||||
.exe: $(PROJ_DIR)
|
||||
|
||||
#===========================================================================
|
||||
# Pre-defined section: there should be little need to modify this section.
|
||||
#===========================================================================
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
# Tools/commands
|
||||
#---------------------------------------------------------------------------
|
||||
C_CMD = wcc386
|
||||
CPP_CMD = wpp386
|
||||
LIB_CMD = wlib
|
||||
LINK_CMD = wlink
|
||||
ASM_CMD = tasm32
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
# Include & library paths
|
||||
# If LIB & INCLUDE are already defined, they are used in addition to the
|
||||
# WWLIB32 lib & include; otherwise, they're constructed from
|
||||
# BCDIR & TNTDIR
|
||||
#---------------------------------------------------------------------------
|
||||
LIBPATH = $(%WIN32LIB)\LIB;$(%WATCOM)\LIB
|
||||
INCLUDEPATH = $(%WIN32LIB)\INCLUDE;$(%WATCOM)\H
|
||||
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
# Implicit rules
|
||||
# Compiler:
|
||||
# ($< = full dependent with path)
|
||||
# Assembler:
|
||||
# output obj's are constructed from .obj: & the $& macro
|
||||
# ($< = full dependent with path)
|
||||
# tasm's cfg file is not invoked as a response file.
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
.c.obj: $(%WIN32LIB)\project.cfg .AUTODEPEND
|
||||
$(C_CMD) $(CC_CFG) $<
|
||||
|
||||
.cpp.obj: $(%WIN32LIB)\project.cfg .AUTODEPEND
|
||||
$(CPP_CMD) $(CC_CFG) $<
|
||||
|
||||
.asm.obj: $(%WIN32LIB)\project.cfg
|
||||
$(ASM_CMD) $(ASM_CFG) $<
|
||||
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
# Default target: configuration files & library (in that order)
|
||||
#---------------------------------------------------------------------------
|
||||
all: $(LIB_DIR)\$(PROJ_NAME).lib .SYMBOLIC
|
||||
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
# Build the library
|
||||
# The original library is deleted by the librarian
|
||||
# Lib objects & -+ commands are constructed by substituting within the
|
||||
# $^@ macro (which expands to all target dependents, separated with
|
||||
# spaces)
|
||||
# Tlib's cfg file is not invoked as a response file.
|
||||
# All headers & source files are copied into WIN32LIB\SRCDEBUG, for debugging
|
||||
#---------------------------------------------------------------------------
|
||||
$(LIB_DIR)\$(PROJ_NAME).lib: $(OBJECTS) objects.lbc
|
||||
copy *.h $(%WIN32LIB)\include
|
||||
copy *.inc $(%WIN32LIB)\include
|
||||
copy *.cpp $(%WIN32LIB)\srcdebug
|
||||
copy *.asm $(%WIN32LIB)\srcdebug
|
||||
$(LIB_CMD) $(LIB_CFG) $^@ @objects.lbc
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
# Objects now have a link file which is NOT generated everytime. Instead
|
||||
# it just has its own dependacy rule.
|
||||
#---------------------------------------------------------------------------
|
||||
objects.lbc : $(OBJECTS)
|
||||
%create $^@
|
||||
for %index in ($(OBJECTS)) do %append $^@ +%index
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
# Create the test directory and make it.
|
||||
#---------------------------------------------------------------------------
|
||||
test:
|
||||
mkdir test
|
||||
cd test
|
||||
copy $(%WWVCS)\$(PROJ_NAME)\test\vcs.cfg
|
||||
update
|
||||
wmake
|
||||
cd ..
|
||||
|
||||
#**************************** End of makefile ******************************
|
||||
|
||||
|
789
WIN32LIB/MONO/MONO.CPP
Normal file
789
WIN32LIB/MONO/MONO.CPP
Normal file
@@ -0,0 +1,789 @@
|
||||
/*
|
||||
** Command & Conquer Red Alert(tm)
|
||||
** Copyright 2025 Electronic Arts Inc.
|
||||
**
|
||||
** This program is free software: you can redistribute it and/or modify
|
||||
** it under the terms of the GNU General Public License as published by
|
||||
** the Free Software Foundation, either version 3 of the License, or
|
||||
** (at your option) any later version.
|
||||
**
|
||||
** This program is distributed in the hope that it will be useful,
|
||||
** but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
** GNU General Public License for more details.
|
||||
**
|
||||
** You should have received a copy of the GNU General Public License
|
||||
** along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/* $Header: F:\projects\c&c\vcs\code\monoc.cpv 2.12 06 Sep 1995 16:37:54 JOE_BOSTIC $ */
|
||||
/***********************************************************************************************
|
||||
*** 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 : Command & Conquer *
|
||||
* *
|
||||
* File Name : MONO.CPP *
|
||||
* *
|
||||
* Programmer : Joe L. Bostic *
|
||||
* *
|
||||
* Start Date : July 2, 1994 *
|
||||
* *
|
||||
* Last Update : October 17, 1994 [JLB] *
|
||||
* *
|
||||
*---------------------------------------------------------------------------------------------*
|
||||
* Functions: *
|
||||
* MonoClass::Clear -- Clears the monochrome screen object. *
|
||||
* MonoClass::Draw_Box -- Draws a box using the IBM linedraw characters. *
|
||||
* MonoClass::MonoClass -- The default constructor for monochrome screen object. *
|
||||
* MonoClass::operator = -- Handles making one mono object have the same imagery as another. *
|
||||
* MonoClass::Print -- Prints the text string at the current cursor coordinates. *
|
||||
* MonoClass::Printf -- Prints a formatted string to the monochrome screen. *
|
||||
* MonoClass::Scroll -- Scroll the monochrome screen up by the specified lines. *
|
||||
* MonoClass::Set_Cursor -- Sets the monochrome cursor to the coordinates specified. *
|
||||
* MonoClass::Text_Print -- Prints text to the monochrome object at coordinates indicated. *
|
||||
* MonoClass::View -- Brings the mono object to the main display. *
|
||||
* MonoClass::~MonoClass -- The default destructor for a monochrome screen object. *
|
||||
* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
|
||||
|
||||
//#pragma inline
|
||||
#include "mono.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <dos.h>
|
||||
#include <mem.h>
|
||||
#include <stdarg.h>
|
||||
#include <string.h>
|
||||
|
||||
|
||||
extern void output(short port, short data);
|
||||
#pragma aux output parm [dx] [ax] = \
|
||||
"out dx,al" \
|
||||
"inc dx" \
|
||||
"mov al,ah" \
|
||||
"out dx,al"
|
||||
|
||||
int MonoClass::Enabled = 0;
|
||||
MonoClass * MonoClass::PageUsage[MonoClass::MAX_MONO_PAGES] = {0,0,0,0,0,0,0,0};
|
||||
void * MonoClass::MonoSegment = (void*)0x000b0000;
|
||||
|
||||
/*
|
||||
** These are the IBM linedraw characters.
|
||||
*/
|
||||
MonoClass::BoxDataType const MonoClass::CharData[MonoClass::COUNT] = {
|
||||
{0xDA,0xC4,0xBF,0xB3,0xD9,0xC4,0xC0,0xB3}, // Single line
|
||||
{0xD5,0xCD,0xB8,0xB3,0xBE,0xCD,0xD4,0xB3}, // Double horz.
|
||||
{0xD6,0xC4,0xB7,0xBA,0xBD,0xC4,0xD3,0xBA}, // Double vert.
|
||||
{0xC9,0xCD,0xBB,0xBA,0xBC,0xCD,0xC8,0xBA} // Double horz and vert.
|
||||
};
|
||||
|
||||
|
||||
/***********************************************************************************************
|
||||
* MonoClass::MonoClass -- The default constructor for monochrome screen object. *
|
||||
* *
|
||||
* This is the constructor for monochrome screen objects. It handles allocating a free *
|
||||
* monochrome page. If there are no more pages available, then this is a big error. The *
|
||||
* page allocated may not be the visible one. Call the View function in order to bring *
|
||||
* it to the displayed page. *
|
||||
* *
|
||||
* INPUT: none *
|
||||
* *
|
||||
* OUTPUT: none *
|
||||
* *
|
||||
* WARNINGS: none *
|
||||
* *
|
||||
* HISTORY: *
|
||||
* 10/17/1994 JLB : Created. *
|
||||
*=============================================================================================*/
|
||||
MonoClass::MonoClass(void)
|
||||
{
|
||||
int index;
|
||||
|
||||
Attrib = DEFAULT_ATTRIBUTE; // Normal text color.
|
||||
X = Y = 0;
|
||||
for (index = 0; index < MAX_MONO_PAGES; index++) {
|
||||
if (!PageUsage[index]) {
|
||||
PageUsage[index] = this;
|
||||
Page = (char)index;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (index == MAX_MONO_PAGES) {
|
||||
// Major error message should pop up here!
|
||||
delete this;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/***********************************************************************************************
|
||||
* MonoClass::~MonoClass -- The default destructor for a monochrome screen object. *
|
||||
* *
|
||||
* This is the default destructor for a monochrome screen object. *
|
||||
* *
|
||||
* INPUT: none *
|
||||
* *
|
||||
* OUTPUT: none *
|
||||
* *
|
||||
* WARNINGS: none *
|
||||
* *
|
||||
* HISTORY: *
|
||||
* 10/17/1994 JLB : Created. *
|
||||
*=============================================================================================*/
|
||||
MonoClass::~MonoClass(void)
|
||||
{
|
||||
PageUsage[Page] = 0;
|
||||
}
|
||||
|
||||
|
||||
/***********************************************************************************************
|
||||
* MonoClass::Draw_Box -- Draws a box using the IBM linedraw characters. *
|
||||
* *
|
||||
* Use this routine to draw a box to the monochrome screen. The IBM line draw characters *
|
||||
* are used to give the it a fancy appearance. There are several line draw modes supported. *
|
||||
* *
|
||||
* INPUT: x,y -- The coordinates of the upper left corner of the box. *
|
||||
* *
|
||||
* w,y -- The width and height (respectively) to make the box. *
|
||||
* *
|
||||
* attrib -- The text attribute to use when drawing the box outline characters. *
|
||||
* *
|
||||
* thick -- The thickness style to use. Examine the BoxStyleType enum for *
|
||||
* elaboration on the supported styles. *
|
||||
* *
|
||||
* OUTPUT: none *
|
||||
* *
|
||||
* WARNINGS: The interior of the box is NOT cleared by this routine. It is advised that this *
|
||||
* area be cleared before the box is drawn. *
|
||||
* *
|
||||
* HISTORY: *
|
||||
* 10/17/1994 JLB : Created. *
|
||||
*=============================================================================================*/
|
||||
void MonoClass::Draw_Box(int x, int y, int w, int h, char attrib, BoxStyleType thick)
|
||||
{
|
||||
CellType cell;
|
||||
char oldattrib = Attrib;
|
||||
|
||||
if (!Enabled || !w || !h) return;
|
||||
|
||||
cell.Attribute = attrib;
|
||||
|
||||
/*
|
||||
** Draw the horizontal lines.
|
||||
*/
|
||||
for (int xpos = 0; xpos < w-2; xpos++) {
|
||||
cell.Character = CharData[thick].TopEdge;
|
||||
Store_Cell(cell, x+xpos+1, y);
|
||||
cell.Character = CharData[thick].BottomEdge;
|
||||
Store_Cell(cell, x+xpos+1, y+h-1);
|
||||
}
|
||||
|
||||
/*
|
||||
** Draw the vertical lines.
|
||||
*/
|
||||
for (int ypos = 0; ypos < h-2; ypos++) {
|
||||
cell.Character = CharData[thick].LeftEdge;
|
||||
Store_Cell(cell, x, y+ypos+1);
|
||||
cell.Character = CharData[thick].RightEdge;
|
||||
Store_Cell(cell, x+w-1, y+ypos+1);
|
||||
}
|
||||
|
||||
/*
|
||||
** Draw the four corners.
|
||||
*/
|
||||
if (w > 1 && h > 1) {
|
||||
cell.Character = CharData[thick].UpperLeft;
|
||||
Store_Cell(cell, x, y);
|
||||
cell.Character = CharData[thick].UpperRight;
|
||||
Store_Cell(cell, x+w-1, y);
|
||||
cell.Character = CharData[thick].BottomRight;
|
||||
Store_Cell(cell, x+w-1, y+h-1);
|
||||
cell.Character = CharData[thick].BottomLeft;
|
||||
Store_Cell(cell, x, y+h-1);
|
||||
}
|
||||
|
||||
Attrib = oldattrib;
|
||||
}
|
||||
|
||||
|
||||
/***********************************************************************************************
|
||||
* MonoClass::Set_Cursor -- Sets the monochrome cursor to the coordinates specified. *
|
||||
* *
|
||||
* Use this routine to set the monochrome's cursor position to the coordinates specified. *
|
||||
* This is the normal way of controlling where the next Print or Printf will output the *
|
||||
* text to. *
|
||||
* *
|
||||
* INPUT: x,y -- The coordinate to position the monochrome cursor. 0,0 is the upper left *
|
||||
* corner. *
|
||||
* *
|
||||
* OUTPUT: none *
|
||||
* *
|
||||
* WARNINGS: none *
|
||||
* *
|
||||
* HISTORY: *
|
||||
* 10/17/1994 JLB : Created. *
|
||||
*=============================================================================================*/
|
||||
void MonoClass::Set_Cursor(int x, int y)
|
||||
{
|
||||
#if(0)
|
||||
int pos = (y*COLUMNS)+x;
|
||||
|
||||
if (!Enabled) return;
|
||||
|
||||
X = (char)(x%COLUMNS);
|
||||
Y = (char)(y%LINES);
|
||||
|
||||
if (Page == 0) {
|
||||
_DX = CONTROL_PORT;
|
||||
_AX = (short)(0x0E|(pos&0xFF00));
|
||||
asm {
|
||||
out dx,al
|
||||
inc dx
|
||||
mov al,ah
|
||||
out dx,al
|
||||
}
|
||||
|
||||
_DX = CONTROL_PORT;
|
||||
_AX = (short)(0x0F|(pos<<8));
|
||||
asm {
|
||||
out dx,al
|
||||
inc dx
|
||||
mov al,ah
|
||||
out dx,al
|
||||
}
|
||||
|
||||
}
|
||||
#else
|
||||
int pos = (y*COLUMNS)+x;
|
||||
|
||||
if (!Enabled) return;
|
||||
|
||||
X = (char)(x%COLUMNS);
|
||||
Y = (char)(y%LINES);
|
||||
|
||||
if (Page == 0) {
|
||||
output(CONTROL_PORT,
|
||||
(short)0x0E|(short)(pos&0xFF00));
|
||||
output(CONTROL_PORT,
|
||||
(short)0x0F|(short)(pos<<8));
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
/***********************************************************************************************
|
||||
* MonoClass::Clear -- Clears the monochrome screen object. *
|
||||
* *
|
||||
* This routine will fill the monochrome screen object with spaces. It is clearing the *
|
||||
* screen of data, making it free for output. The cursor is positioned at the upper left *
|
||||
* corner of the screen by this routine. *
|
||||
* *
|
||||
* INPUT: none *
|
||||
* *
|
||||
* OUTPUT: none *
|
||||
* *
|
||||
* WARNINGS: none *
|
||||
* *
|
||||
* HISTORY: *
|
||||
* 10/17/1994 JLB : Created. *
|
||||
*=============================================================================================*/
|
||||
void MonoClass::Clear(void)
|
||||
{
|
||||
CellType cell;
|
||||
|
||||
if (!Enabled) return;
|
||||
|
||||
Set_Cursor(0, 0);
|
||||
|
||||
cell.Attribute = Attrib;
|
||||
cell.Character = ' ';
|
||||
|
||||
for (int y = 0; y < LINES; y++) {
|
||||
for (int x = 0; x < COLUMNS; x++) {
|
||||
Store_Cell(cell, x, y);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/***********************************************************************************************
|
||||
* MonoClass::Scroll -- Scroll the monochrome screen up by the specified lines. *
|
||||
* *
|
||||
* Use this routine to scroll the monochrome screen up by the number of lines specified. *
|
||||
* This routine is typically called by the printing functions so that the monochrome screen *
|
||||
* behaves in the expected manner -- printing at the bottom of the screen scrolls it up *
|
||||
* to make room for new text. *
|
||||
* *
|
||||
* INPUT: lines -- The number of lines to scroll the monochrome screen. *
|
||||
* *
|
||||
* OUTPUT: none *
|
||||
* *
|
||||
* WARNINGS: none *
|
||||
* *
|
||||
* HISTORY: *
|
||||
* 10/17/1994 JLB : Created. *
|
||||
*=============================================================================================*/
|
||||
void MonoClass::Scroll(int lines)
|
||||
{
|
||||
CellType cell;
|
||||
|
||||
if (!Enabled || lines <= 0) return;
|
||||
|
||||
memmove( (void*)((long)MonoSegment + Offset(0, 0)),
|
||||
(void*)((long)MonoSegment + Offset(0, lines)),
|
||||
(LINES-lines)*COLUMNS*sizeof(CellType));
|
||||
|
||||
|
||||
Y--;
|
||||
cell.Attribute = Attrib;
|
||||
cell.Character = ' ';
|
||||
|
||||
for (int l = LINES-lines; l < LINES; l++) {
|
||||
for (int index = 0; index < COLUMNS; index++) {
|
||||
Store_Cell(cell, index, l);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/***********************************************************************************************
|
||||
* MonoClass::Printf -- Prints a formatted string to the monochrome screen. *
|
||||
* *
|
||||
* Use this routine to output a formatted string, using the standard formatting options, *
|
||||
* to the monochrome screen object's current cursor position. *
|
||||
* *
|
||||
* INPUT: text -- Pointer to the text to print. *
|
||||
* *
|
||||
* ... -- Any optional parameters to supply in formatting the text. *
|
||||
* *
|
||||
* OUTPUT: none *
|
||||
* *
|
||||
* WARNINGS: The total formatted text length must not exceed 255 characters. *
|
||||
* *
|
||||
* HISTORY: *
|
||||
* 10/17/1994 JLB : Created. *
|
||||
*=============================================================================================*/
|
||||
void MonoClass::Printf(char const *text, ...)
|
||||
{
|
||||
va_list va;
|
||||
/*
|
||||
** The buffer object is placed at the end of the local variable list
|
||||
** so that if the sprintf happens to spill past the end, it isn't likely
|
||||
** to trash anything (important). The buffer is then manually truncated
|
||||
** to maximum allowed size before being printed.
|
||||
*/
|
||||
char buffer[256];
|
||||
|
||||
if (!Enabled) return;
|
||||
|
||||
va_start(va, text);
|
||||
vsprintf(buffer, text, va);
|
||||
buffer[sizeof(buffer)-1] = '\0';
|
||||
|
||||
Print(buffer);
|
||||
va_end(va);
|
||||
}
|
||||
|
||||
|
||||
#ifdef NEVER
|
||||
void MonoClass::Printf(int text, ...)
|
||||
{
|
||||
va_list va;
|
||||
/*
|
||||
** The buffer object is placed at the end of the local variable list
|
||||
** so that if the sprintf happens to spill past the end, it isn't likely
|
||||
** to trash anything (important). The buffer is then manually truncated
|
||||
** to maximum allowed size before being printed.
|
||||
*/
|
||||
char buffer[256];
|
||||
|
||||
if (!Enabled) return;
|
||||
|
||||
va_start(va, text);
|
||||
vsprintf(buffer, Text_String(text), va);
|
||||
buffer[sizeof(buffer)-1] = '\0';
|
||||
|
||||
Print(buffer);
|
||||
va_end(va);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
/***********************************************************************************************
|
||||
* MonoClass::Print -- Prints the text string at the current cursor coordinates. *
|
||||
* *
|
||||
* Use this routine to output the specified text string at the monochrome object's current *
|
||||
* text coordinate position. *
|
||||
* *
|
||||
* INPUT: ptr -- Pointer to the string to print. *
|
||||
* *
|
||||
* OUTPUT: none *
|
||||
* *
|
||||
* WARNINGS: none *
|
||||
* *
|
||||
* HISTORY: *
|
||||
* 10/17/1994 JLB : Created. *
|
||||
*=============================================================================================*/
|
||||
void MonoClass::Print(char const *ptr)
|
||||
{
|
||||
char startcol = X;
|
||||
char const * text;
|
||||
CellType cell;
|
||||
|
||||
if (!ptr || !Enabled) return;
|
||||
|
||||
text = ptr;
|
||||
cell.Attribute = Attrib;
|
||||
while (*text) {
|
||||
|
||||
/*
|
||||
** Sometimes the character string is used for cursor control instead
|
||||
** of plain text output. Check for this case.
|
||||
*/
|
||||
switch (*text) {
|
||||
|
||||
/*
|
||||
** The "return" code behaves as it did in the old C library
|
||||
** mono system. That is, it returns the cursor position to
|
||||
** the next line but at the starting column of the print.
|
||||
*/
|
||||
case '\r':
|
||||
X = startcol;
|
||||
Y++;
|
||||
Scroll(Y-(LINES-1));
|
||||
break;
|
||||
|
||||
/*
|
||||
** The "newline" code behaves like the console newline character.
|
||||
** That is, it moves the cursor down one line and at the first
|
||||
** column.
|
||||
*/
|
||||
case '\n':
|
||||
X = 0;
|
||||
Y++;
|
||||
Scroll(Y-(LINES-1));
|
||||
break;
|
||||
|
||||
/*
|
||||
** All other characters are output directly and the cursor moves
|
||||
** rightward to match. If the cursor wraps past the right
|
||||
** edge is it moved to the next now down at left margin. If the
|
||||
** cursor goes off the bottom of the display, the display is scrolled
|
||||
** upward a line.
|
||||
*/
|
||||
default:
|
||||
cell.Character = *text;
|
||||
Store_Cell(cell, X, Y);
|
||||
|
||||
X++;
|
||||
if (X >= COLUMNS) {
|
||||
X = 0;
|
||||
Y++;
|
||||
|
||||
if (Y > (LINES-1)) {
|
||||
Scroll(Y-(LINES-1));
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
}
|
||||
text++;
|
||||
}
|
||||
|
||||
Set_Cursor(X, Y);
|
||||
}
|
||||
|
||||
|
||||
/***********************************************************************************************
|
||||
* MonoClass::Text_Print -- Prints text to the monochrome object at coordinates indicated. *
|
||||
* *
|
||||
* Use this routine to output text to the monochrome object at the X and Y coordinates *
|
||||
* specified. *
|
||||
* *
|
||||
* INPUT: text -- Pointer to the text string to display. *
|
||||
* *
|
||||
* x,y -- The X and Y character coordinates to start the printing at. *
|
||||
* *
|
||||
* attrib-- Optional parameter that specifies what text attribute code to use. *
|
||||
* *
|
||||
* OUTPUT: none *
|
||||
* *
|
||||
* WARNINGS: none *
|
||||
* *
|
||||
* HISTORY: *
|
||||
* 10/17/1994 JLB : Created. *
|
||||
*=============================================================================================*/
|
||||
void MonoClass::Text_Print(char const *text, int x, int y, char attrib)
|
||||
{
|
||||
char oldx = X;
|
||||
char oldy = Y;
|
||||
char oldattrib = Attrib;
|
||||
|
||||
X = (char)x;
|
||||
Y = (char)y;
|
||||
Attrib = attrib;
|
||||
Print(text);
|
||||
Attrib = oldattrib;
|
||||
Set_Cursor(oldx, oldy);
|
||||
}
|
||||
|
||||
#ifdef NEVER
|
||||
void MonoClass::Text_Print(int text, int x, int y, char attrib)
|
||||
{
|
||||
char oldx = X;
|
||||
char oldy = Y;
|
||||
char oldattrib = Attrib;
|
||||
|
||||
if (text != TXT_NONE) {
|
||||
X = (char)x;
|
||||
Y = (char)y;
|
||||
Attrib = attrib;
|
||||
Print(Text_String(text));
|
||||
Attrib = oldattrib;
|
||||
Set_Cursor(oldx, oldy);
|
||||
}
|
||||
}
|
||||
|
||||
void MonoClass::Print(int text)
|
||||
{
|
||||
Print(Text_String(text));
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
/***********************************************************************************************
|
||||
* MonoClass::operator = -- Handles making one mono object have the same imagery as another. *
|
||||
* *
|
||||
* The assignment operator will handle copying the imagery from one monochrome object to *
|
||||
* another. Use this routine in to make two monochrome class objects visually identical. *
|
||||
* *
|
||||
* INPUT: src -- A reference to the source (right side) monochrome object. *
|
||||
* *
|
||||
* OUTPUT: none *
|
||||
* *
|
||||
* WARNINGS: none *
|
||||
* *
|
||||
* HISTORY: *
|
||||
* 10/17/1994 JLB : Created. *
|
||||
*=============================================================================================*/
|
||||
MonoClass & MonoClass::operator = (MonoClass const & src)
|
||||
{
|
||||
memcpy((void*)((long)MonoSegment + src.Offset(0, 0)), (void*)((long)MonoSegment + Offset(0, 0)), SIZE_OF_PAGE);
|
||||
Set_Cursor(src.X, src.Y);
|
||||
return(*this);
|
||||
}
|
||||
|
||||
|
||||
/***********************************************************************************************
|
||||
* MonoClass::View -- Brings the mono object to the main display. *
|
||||
* *
|
||||
* Use this routine to display the mono object on the monochrome screen. It is possible *
|
||||
* that the mono object exists on some background screen memory. Calling this routine will *
|
||||
* perform the necessary memory swapping to bring the data to the front. The mono object *
|
||||
* that was currently being viewed is not destroyed by this function. It is merely moved *
|
||||
* off to some background page. It can be treated normally, except that is just isn't *
|
||||
* visible. *
|
||||
* *
|
||||
* INPUT: none *
|
||||
* *
|
||||
* OUTPUT: none *
|
||||
* *
|
||||
* WARNINGS: none *
|
||||
* *
|
||||
* HISTORY: *
|
||||
* 10/17/1994 JLB : Created. *
|
||||
*=============================================================================================*/
|
||||
void MonoClass::View(void)
|
||||
{
|
||||
MonoClass *displace; // The page that is being displaced.
|
||||
|
||||
if (Get_Current() == this) return;
|
||||
|
||||
/*
|
||||
** If the visible page is already assigned to a real monochrome page
|
||||
** object, then it must be swapped with the new one.
|
||||
*/
|
||||
displace = Get_Current();
|
||||
if (displace) {
|
||||
char temp[SIZE_OF_PAGE];
|
||||
|
||||
memcpy(&temp[0], MonoSegment, SIZE_OF_PAGE);
|
||||
memcpy(MonoSegment, (void*)((long)MonoSegment + Offset(0, 0)), SIZE_OF_PAGE);
|
||||
memcpy((void*)((long)MonoSegment + Offset(0, 0)), &temp[0], SIZE_OF_PAGE);
|
||||
|
||||
displace->Page = Page;
|
||||
|
||||
} else {
|
||||
|
||||
/*
|
||||
** Just copy the new page over since the display page is not assigned
|
||||
** to a real monochrome page object.
|
||||
*/
|
||||
memcpy(MonoSegment, (void*)((long)MonoSegment + Offset(0, 0)), SIZE_OF_PAGE);
|
||||
}
|
||||
PageUsage[Page] = displace;
|
||||
PageUsage[0] = this;
|
||||
Page = 0;
|
||||
|
||||
Set_Cursor(X, Y);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/************************************************************************************
|
||||
** This is the set of C wrapper functions that access the MonoClass support routines.
|
||||
** Since the C interface doesn't have the ability to write to non-visible pages, it
|
||||
** will just blast the output to whichever mono page is currently visible. If there is
|
||||
** no mono class object that is visible, then one will be created -- BUT NOT FREED.
|
||||
** Typically, this is ok, since the C interface will create only one MonoClass object
|
||||
** and the system supports up to 8.
|
||||
*/
|
||||
void Mono_Set_Cursor(int x, int y)
|
||||
{
|
||||
if (MonoClass::Is_Enabled()) {
|
||||
MonoClass *mono = MonoClass::Get_Current();
|
||||
if (!mono) {
|
||||
mono = new MonoClass();
|
||||
mono->View();
|
||||
}
|
||||
mono->Set_Cursor(x, y);
|
||||
}
|
||||
}
|
||||
|
||||
int Mono_Printf(char const *string, ...)
|
||||
{
|
||||
va_list va;
|
||||
char buffer[256];
|
||||
|
||||
buffer[0] = '\0';
|
||||
if (MonoClass::Is_Enabled()) {
|
||||
MonoClass *mono = MonoClass::Get_Current();
|
||||
if (!mono) {
|
||||
mono = new MonoClass();
|
||||
mono->View();
|
||||
}
|
||||
|
||||
va_start(va, string);
|
||||
vsprintf(buffer, string, va);
|
||||
|
||||
mono->Print(buffer);
|
||||
|
||||
va_end(va);
|
||||
}
|
||||
return((short)strlen(buffer));
|
||||
}
|
||||
|
||||
|
||||
void Mono_Clear_Screen(void)
|
||||
{
|
||||
if (MonoClass::Is_Enabled()) {
|
||||
MonoClass *mono = MonoClass::Get_Current();
|
||||
if (!mono) {
|
||||
mono = new MonoClass();
|
||||
mono->View();
|
||||
}
|
||||
mono->Clear();
|
||||
}
|
||||
}
|
||||
|
||||
void Mono_Text_Print(void const *text, int x, int y, int attrib)
|
||||
{
|
||||
if (MonoClass::Is_Enabled()) {
|
||||
MonoClass *mono = MonoClass::Get_Current();
|
||||
if (!mono) {
|
||||
mono = new MonoClass();
|
||||
mono->View();
|
||||
}
|
||||
mono->Text_Print((const char*)text, x, y, (char)attrib);
|
||||
}
|
||||
}
|
||||
|
||||
void Mono_Draw_Rect(int x, int y, int w, int h, int attrib, int thick)
|
||||
{
|
||||
if (MonoClass::Is_Enabled()) {
|
||||
MonoClass *mono = MonoClass::Get_Current();
|
||||
if (!mono) {
|
||||
mono = new MonoClass();
|
||||
mono->View();
|
||||
}
|
||||
mono->Draw_Box(x, y, w, h, (char)attrib, (MonoClass::BoxStyleType)thick);
|
||||
}
|
||||
}
|
||||
|
||||
void Mono_Print(void const *text)
|
||||
{
|
||||
if (MonoClass::Is_Enabled()) {
|
||||
MonoClass *mono = MonoClass::Get_Current();
|
||||
if (!mono) {
|
||||
mono = new MonoClass();
|
||||
mono->View();
|
||||
}
|
||||
mono->Print((const char*)text);
|
||||
}
|
||||
}
|
||||
|
||||
int Mono_X(void)
|
||||
{
|
||||
if (MonoClass::Is_Enabled()) {
|
||||
MonoClass *mono = MonoClass::Get_Current();
|
||||
if (!mono) {
|
||||
mono = new MonoClass();
|
||||
mono->View();
|
||||
}
|
||||
return(short)mono->Get_X();
|
||||
}
|
||||
return(0);
|
||||
}
|
||||
|
||||
int Mono_Y(void)
|
||||
{
|
||||
if (MonoClass::Is_Enabled()) {
|
||||
MonoClass *mono = MonoClass::Get_Current();
|
||||
if (!mono) {
|
||||
mono = new MonoClass();
|
||||
mono->View();
|
||||
}
|
||||
return(short)mono->Get_X();
|
||||
}
|
||||
return(0);
|
||||
}
|
||||
|
||||
|
||||
void Mono_Put_Char(char , int )
|
||||
{
|
||||
}
|
||||
|
||||
void Mono_Scroll(int )
|
||||
{
|
||||
}
|
||||
|
||||
void Mono_View_Page(int )
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
#ifdef NEVER
|
||||
int Mono_Printf(int string, ...)
|
||||
{
|
||||
va_list va;
|
||||
char buffer[256];
|
||||
|
||||
buffer[0] = '\0';
|
||||
if (MonoClass::Is_Enabled()) {
|
||||
MonoClass *mono = MonoClass::Get_Current();
|
||||
if (!mono) {
|
||||
mono = new MonoClass();
|
||||
mono->View();
|
||||
}
|
||||
|
||||
va_start(va, string);
|
||||
vsprintf(buffer, Text_String(string), va);
|
||||
|
||||
mono->Print(buffer);
|
||||
|
||||
va_end(va);
|
||||
}
|
||||
return((short)strlen(buffer));
|
||||
}
|
||||
#endif
|
||||
|
185
WIN32LIB/MONO/MONO.H
Normal file
185
WIN32LIB/MONO/MONO.H
Normal file
@@ -0,0 +1,185 @@
|
||||
/*
|
||||
** Command & Conquer Red Alert(tm)
|
||||
** Copyright 2025 Electronic Arts Inc.
|
||||
**
|
||||
** This program is free software: you can redistribute it and/or modify
|
||||
** it under the terms of the GNU General Public License as published by
|
||||
** the Free Software Foundation, either version 3 of the License, or
|
||||
** (at your option) any later version.
|
||||
**
|
||||
** This program is distributed in the hope that it will be useful,
|
||||
** but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
** GNU General Public License for more details.
|
||||
**
|
||||
** You should have received a copy of the GNU General Public License
|
||||
** along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/* $Header: F:\projects\c&c\vcs\code\monoc.h_v 2.16 06 Sep 1995 16:29:02 JOE_BOSTIC $ */
|
||||
/***********************************************************************************************
|
||||
*** 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 : Command & Conquer *
|
||||
* *
|
||||
* File Name : MONO.H *
|
||||
* *
|
||||
* Programmer : Joe L. Bostic *
|
||||
* *
|
||||
* Start Date : July 2, 1994 *
|
||||
* *
|
||||
* Last Update : July 2, 1994 [JLB] *
|
||||
* *
|
||||
*---------------------------------------------------------------------------------------------*
|
||||
* Functions: *
|
||||
* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
|
||||
|
||||
#ifndef MONOC_H
|
||||
#define MONOC_H
|
||||
|
||||
|
||||
class MonoClass {
|
||||
/*
|
||||
** This is a private structure that is used to control which characters
|
||||
** are used when a box is drawn. Line drawing on the monochrome screen is
|
||||
** really made up of characters. This specifies which characters to use.
|
||||
*/
|
||||
typedef struct {
|
||||
char UpperLeft;
|
||||
char TopEdge;
|
||||
char UpperRight;
|
||||
char RightEdge;
|
||||
char BottomRight;
|
||||
char BottomEdge;
|
||||
char BottomLeft;
|
||||
char LeftEdge;
|
||||
} BoxDataType;
|
||||
|
||||
/*
|
||||
** Each cell is constructed of the actual character that is displayed and the
|
||||
** attribute to use. This character pair is located at every position on the
|
||||
** display (80 x 25). Since this cell pair can be represented by a "short"
|
||||
** integer, certain speed optimizations are taken in the monochrome drawing
|
||||
** code.
|
||||
*/
|
||||
typedef struct {
|
||||
char Character; // Character to display.
|
||||
char Attribute; // Attribute.
|
||||
} CellType;
|
||||
|
||||
/*
|
||||
** These private constants are used in the various monochrome operations.
|
||||
*/
|
||||
enum MonoClassPortEnums {
|
||||
CONTROL_PORT=0x03B4, // CRTC control register.
|
||||
DATA_PORT=0x03B5, // CRTC data register.
|
||||
COLUMNS=80, // Number of columns.
|
||||
LINES=25, // Number of lines.
|
||||
SIZE_OF_PAGE=LINES*COLUMNS*sizeof(CellType), // Entire page size.
|
||||
DEFAULT_ATTRIBUTE=0x02 // Normal white on black color attribute.
|
||||
};
|
||||
|
||||
public:
|
||||
enum MonoClassPageEnums {
|
||||
MAX_MONO_PAGES=16, // Maximum RAM pages on mono card.
|
||||
SEGMENT=0xB000 // Monochrome screen segment.
|
||||
};
|
||||
|
||||
/*
|
||||
** These are the various box styles that may be used.
|
||||
*/
|
||||
typedef enum BoxStyleType {
|
||||
SINGLE, // Single thickness.
|
||||
DOUBLE_HORZ, // Double thick on the horizontal axis.
|
||||
DOUBLE_VERT, // Double thick on the vertical axis.
|
||||
DOUBLE, // Double thickness.
|
||||
|
||||
COUNT
|
||||
} BoxStyleType;
|
||||
|
||||
MonoClass(void);
|
||||
~MonoClass(void);
|
||||
|
||||
static void Enable(void) {Enabled = 1;};
|
||||
static void Disable(void) {Enabled = 0;};
|
||||
static int Is_Enabled(void) {return Enabled;};
|
||||
static MonoClass * Get_Current(void) {return PageUsage[0];};
|
||||
|
||||
void Draw_Box(int x, int y, int w, int h, char attrib=DEFAULT_ATTRIBUTE, BoxStyleType thick=SINGLE);
|
||||
void Set_Default_Attribute(char attrib) {Attrib = attrib;};
|
||||
void Clear(void);
|
||||
void Set_Cursor(int x, int y);
|
||||
void Print(char const *text);
|
||||
void Print(int text);
|
||||
void Printf(char const *text, ...);
|
||||
void Printf(int text, ...);
|
||||
void Text_Print(char const *text, int x, int y, char attrib=DEFAULT_ATTRIBUTE);
|
||||
void Text_Print(int text, int x, int y, char attrib=DEFAULT_ATTRIBUTE);
|
||||
void View(void);
|
||||
int Get_X(void) const {return X;};
|
||||
int Get_Y(void) const {return Y;};
|
||||
|
||||
/*
|
||||
** Handles deep copies for the mono class objects. This performs what is essentially
|
||||
** a screen copy.
|
||||
*/
|
||||
MonoClass & operator = (MonoClass const & );
|
||||
|
||||
/*
|
||||
** This merely makes a duplicate of the mono object into a newly created mono
|
||||
** object.
|
||||
*/
|
||||
MonoClass (MonoClass const &);
|
||||
|
||||
private:
|
||||
char X; // Cursor X position.
|
||||
char Y; // Cursor Y position.
|
||||
char Attrib; // Normal attribute to use if none specified.
|
||||
char Page; // The current page to write to.
|
||||
|
||||
/*
|
||||
** Helper functions to help with display operations.
|
||||
*/
|
||||
int Offset(int x=0, int y=0) const {return (SIZE_OF_PAGE*Page) + sizeof(CellType)*(x + (y*COLUMNS));};
|
||||
void Scroll(int lines);
|
||||
void Store_Cell(CellType &cell, int x, int y) {
|
||||
*(CellType *)((long)MonoSegment + Offset(x, y)) = cell;
|
||||
};
|
||||
|
||||
/*
|
||||
** This is the segment/selector of the monochrome screen.
|
||||
*/
|
||||
static void * MonoSegment;
|
||||
|
||||
/*
|
||||
** This the the arrays of characters used for drawing boxes.
|
||||
*/
|
||||
static BoxDataType const CharData[4];
|
||||
|
||||
/*
|
||||
** This array contains pointers to the monochrome objects that are assigned
|
||||
** to each of the monochrome pages. As the monochrome pages are made visible,
|
||||
** they can be shuffled around between the actual locations. The first entry
|
||||
** in this table is the one that is visible.
|
||||
*/
|
||||
static MonoClass * PageUsage[MAX_MONO_PAGES];
|
||||
|
||||
/*
|
||||
** If this is true, then monochrome output is allowed. It defaults to false
|
||||
** so that monochrome output must be explicitly enabled.
|
||||
*/
|
||||
static int Enabled;
|
||||
};
|
||||
|
||||
void Mono_Set_Cursor(int x, int y);
|
||||
int Mono_Printf(char const *string, ...);
|
||||
void Mono_Clear_Screen(void);
|
||||
void Mono_Text_Print(void const *text, int x, int y, int attrib);
|
||||
void Mono_Draw_Rect(int x, int y, int w, int h, int attrib, int thick);
|
||||
void Mono_Print(void const *text);
|
||||
int Mono_X(void);
|
||||
int Mono_Y(void);
|
||||
|
||||
#endif
|
||||
|
Reference in New Issue
Block a user