2007-07-20 18:40 UTC+0200 Przemyslaw Czerpak (druzus/at/priv.onet.pl)
* harbour/contrib/libct/Makefile
* harbour/contrib/libct/makefile.bc
* harbour/contrib/libct/makefile.vc
+ harbour/contrib/libct/ctvideo.ch
+ harbour/contrib/libct/video.c
+ added CHARPIX(), VGAPALETTE(), VIDEOTYPE(), SETFONT()
code by Phil Krylov borrowed from xHarbour
+ harbour/contrib/libct/dattime3.c
+ added WAITPERIOD(), TIMEVALID(), SETTIME(), SETDATE()
This commit is contained in:
@@ -8,6 +8,17 @@
|
||||
2002-12-01 13:30 UTC+0100 Foo Bar <foo.bar@foobar.org>
|
||||
*/
|
||||
|
||||
2007-07-20 18:40 UTC+0200 Przemyslaw Czerpak (druzus/at/priv.onet.pl)
|
||||
* harbour/contrib/libct/Makefile
|
||||
* harbour/contrib/libct/makefile.bc
|
||||
* harbour/contrib/libct/makefile.vc
|
||||
+ harbour/contrib/libct/ctvideo.ch
|
||||
+ harbour/contrib/libct/video.c
|
||||
+ added CHARPIX(), VGAPALETTE(), VIDEOTYPE(), SETFONT()
|
||||
code by Phil Krylov borrowed from xHarbour
|
||||
+ harbour/contrib/libct/dattime3.c
|
||||
+ added WAITPERIOD(), TIMEVALID(), SETTIME(), SETDATE()
|
||||
|
||||
2007-07-19 20:50 UTC+0200 Przemyslaw Czerpak (druzus/at/priv.onet.pl)
|
||||
* harbour/contrib/libct/Makefile
|
||||
+ harbour/contrib/libct/maxline.c
|
||||
|
||||
@@ -38,6 +38,7 @@ C_SOURCES = \
|
||||
ctwin.c \
|
||||
datetime.c \
|
||||
dattime2.c \
|
||||
dattime3.c \
|
||||
disk.c \
|
||||
exponent.c \
|
||||
files.c \
|
||||
@@ -72,6 +73,7 @@ C_SOURCES = \
|
||||
token1.c \
|
||||
token2.c \
|
||||
trig.c \
|
||||
video.c \
|
||||
wordrepl.c \
|
||||
wordtoch.c \
|
||||
|
||||
|
||||
67
harbour/contrib/libct/ctvideo.ch
Normal file
67
harbour/contrib/libct/ctvideo.ch
Normal file
@@ -0,0 +1,67 @@
|
||||
/*
|
||||
* $Id$
|
||||
*/
|
||||
|
||||
/*
|
||||
* Harbour Project source code:
|
||||
* Header file for CT video adapter definitions
|
||||
*
|
||||
* Copyright 2004 Phil Krylov <phil@newstar.rinet.ru>
|
||||
*
|
||||
* www - http://www.harbour-project.org
|
||||
*
|
||||
* 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 2, 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 software; see the file COPYING. If not, write to
|
||||
* the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
|
||||
* Boston, MA 02111-1307 USA (or visit the web site http://www.gnu.org/).
|
||||
*
|
||||
* As a special exception, the Harbour Project gives permission for
|
||||
* additional uses of the text contained in its release of Harbour.
|
||||
*
|
||||
* The exception is that, if you link the Harbour libraries with other
|
||||
* files to produce an executable, this does not by itself cause the
|
||||
* resulting executable to be covered by the GNU General Public License.
|
||||
* Your use of that executable is in no way restricted on account of
|
||||
* linking the Harbour library code into it.
|
||||
*
|
||||
* This exception does not however invalidate any other reasons why
|
||||
* the executable file might be covered by the GNU General Public License.
|
||||
*
|
||||
* This exception applies only to the code released by the Harbour
|
||||
* Project under the name Harbour. If you copy code from other
|
||||
* Harbour Project or Free Software Foundation releases into a copy of
|
||||
* Harbour, as the General Public License permits, the exception does
|
||||
* not apply to the code that you add in this way. To avoid misleading
|
||||
* anyone as to the status of such modified files, you must delete
|
||||
* this exception notice from them.
|
||||
*
|
||||
* If you write modifications of your own for Harbour, it is your choice
|
||||
* whether to permit this exception to apply to your modifications.
|
||||
* If you do not wish that, delete this exception notice.
|
||||
*
|
||||
*/
|
||||
|
||||
/* NOTE: This file is also used by C code. */
|
||||
|
||||
#ifndef _CTVIDEO_CH
|
||||
#define _CTVIDEO_CH
|
||||
|
||||
#define VCARD_MONOCHROME 1 /* Monochrome adapter */
|
||||
#define VCARD_CGA 2 /* CGA adapter */
|
||||
#define VCARD_HERCULES 5 /* Hercules, also emulates monochrome */
|
||||
#define VCARD_MCGA 10 /* MCGA, also emulates CGA */
|
||||
#define VCARD_PGA 19 /* PGA, also emulates CGA and monochrome */
|
||||
#define VCARD_EGA 55 /* EGA, emulates all of the above except MCGA */
|
||||
#define VCARD_VGA 127 /* VGA, emulates all of the above */
|
||||
|
||||
#endif /* _CTVIDEO_CH */
|
||||
402
harbour/contrib/libct/dattime3.c
Normal file
402
harbour/contrib/libct/dattime3.c
Normal file
@@ -0,0 +1,402 @@
|
||||
/*
|
||||
* $Id$
|
||||
*/
|
||||
|
||||
/*
|
||||
* Harbour Project source code:
|
||||
* CT3 Date & Time functions:
|
||||
* WAITPERIOD(), TIMEVALID(), SETTIME(), SETDATE()
|
||||
*
|
||||
* Copyright 2007 Przemyslaw Czerpak <druzus / at / priv.onet.pl>
|
||||
* www - http://www.harbour-project.org
|
||||
*
|
||||
* 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 2, 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 software; see the file COPYING. If not, write to
|
||||
* the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
|
||||
* Boston, MA 02111-1307 USA (or visit the web site http://www.gnu.org/).
|
||||
*
|
||||
* As a special exception, the Harbour Project gives permission for
|
||||
* additional uses of the text contained in its release of Harbour.
|
||||
*
|
||||
* The exception is that, if you link the Harbour libraries with other
|
||||
* files to produce an executable, this does not by itself cause the
|
||||
* resulting executable to be covered by the GNU General Public License.
|
||||
* Your use of that executable is in no way restricted on account of
|
||||
* linking the Harbour library code into it.
|
||||
*
|
||||
* This exception does not however invalidate any other reasons why
|
||||
* the executable file might be covered by the GNU General Public License.
|
||||
*
|
||||
* This exception applies only to the code released by the Harbour
|
||||
* Project under the name Harbour. If you copy code from other
|
||||
* Harbour Project or Free Software Foundation releases into a copy of
|
||||
* Harbour, as the General Public License permits, the exception does
|
||||
* not apply to the code that you add in this way. To avoid misleading
|
||||
* anyone as to the status of such modified files, you must delete
|
||||
* this exception notice from them.
|
||||
*
|
||||
* If you write modifications of your own for Harbour, it is your choice
|
||||
* whether to permit this exception to apply to your modifications.
|
||||
* If you do not wish that, delete this exception notice.
|
||||
*
|
||||
*/
|
||||
|
||||
#define HB_OS_WIN_32_USED
|
||||
|
||||
#include "hbapi.h"
|
||||
#include "hbdate.h"
|
||||
#if defined( HB_OS_WIN_32 )
|
||||
# include <windows.h>
|
||||
# include <winbase.h>
|
||||
#elif defined( HB_OS_LINUX )
|
||||
/* stime exists only in SVr4, SVID, X/OPEN and Linux */
|
||||
# ifndef _SVID_SOURCE
|
||||
# define _SVID_SOURCE
|
||||
# endif
|
||||
#endif
|
||||
#include <time.h>
|
||||
|
||||
|
||||
/* $DOC$
|
||||
* $FUNCNAME$
|
||||
* WAITPERIOD()
|
||||
* $CATEGORY$
|
||||
* HBCT date and time functions
|
||||
* $ONELINER$
|
||||
* Pauses a specified time in increments of 1/100 seconds
|
||||
* $SYNTAX$
|
||||
* WAITPERIOD([<nDelay>]) --> lNotElapsed
|
||||
* $ARGUMENTS$
|
||||
* <nDelay> Designates the waiting period at initialization in
|
||||
* 1/100ths of seconds. Values from 1 to 8, 640, 000 (one day) are
|
||||
* possible.
|
||||
* $RETURNS$
|
||||
* WAITPERIOD() returns .T. , if the time span designated at initialization
|
||||
* has not elapsed.
|
||||
* $DESCRIPTION$
|
||||
* This function sets a time span for a xHarbour DO WHILE loop to run.
|
||||
* The function must initialize prior to the loop, since you must specify
|
||||
* the <nDelay> parameter in 1/100th seconds. Subsequently, the function
|
||||
* can be implemented without a parameter for additional loop conditions.
|
||||
* It returns .T., as long as the designated time span has not yet run out.
|
||||
*
|
||||
* Note
|
||||
*
|
||||
* The function notes the status of the internal timer at
|
||||
* initialization. From that point on, the initialization should always
|
||||
* precede the respective DO WHILE; otherwise, the time delay is
|
||||
* incorrect. The passing of midnight (the time resets to the 0 value)
|
||||
* is taken into account.
|
||||
* $EXAMPLES$
|
||||
* Run a loop for 5 seconds:
|
||||
*
|
||||
* WAITPERIOD(500) // Initialization, 5 seconds
|
||||
* DO WHILE <cond1> .AND. <cond2> .AND. WAITPERIOD()
|
||||
* *...
|
||||
* ENDDO
|
||||
* $TESTS$
|
||||
* $STATUS$
|
||||
* Ready
|
||||
* $COMPLIANCE$
|
||||
* WAITPERIOD() is Clipper Tools compatible.
|
||||
* $PLATFORMS$
|
||||
* Windows
|
||||
* $FILES$
|
||||
* Source is dattime3.c, library is libct.
|
||||
* $SEEALSO$
|
||||
* $END$
|
||||
*/
|
||||
|
||||
/* TODO: make it MT safe */
|
||||
static double s_dTimeSet = 0;
|
||||
static double s_dTimeCounter = 0;
|
||||
|
||||
HB_FUNC( WAITPERIOD )
|
||||
{
|
||||
double d = hb_dateSeconds();
|
||||
|
||||
if( hb_pcount() > 0 )
|
||||
{
|
||||
s_dTimeSet = d;
|
||||
s_dTimeCounter = d + hb_parnd( 1 ) / 100.0;
|
||||
}
|
||||
|
||||
if( d < s_dTimeSet )
|
||||
d += 86400.0;
|
||||
|
||||
hb_retl( d < s_dTimeCounter );
|
||||
}
|
||||
|
||||
static BOOL _hb_timeValid( char * szTime, ULONG ulLen, int * piDecode )
|
||||
{
|
||||
BOOL fValid = FALSE;
|
||||
|
||||
if( ulLen == 2 || ulLen == 5 || ulLen == 8 || ulLen == 11 )
|
||||
{
|
||||
static const int s_iMax[] = { 23, 59, 59, 99 };
|
||||
int i, iVal;
|
||||
ULONG ul;
|
||||
|
||||
fValid = TRUE;
|
||||
for( ul = 0; fValid && ul < ulLen; ++ul )
|
||||
{
|
||||
fValid = ul % 3 == 2 ? szTime[ul] == ':' :
|
||||
( szTime[ul] >= '0' && szTime[ul] <= '9' );
|
||||
}
|
||||
for( ul = 0, i = 0; fValid && ul < ulLen; ul += 3, ++i )
|
||||
{
|
||||
iVal = 10 * ( szTime[ul] - '0' ) + ( szTime[ul + 1] - '0' );
|
||||
fValid = iVal <= s_iMax[i];
|
||||
if( piDecode )
|
||||
piDecode[i] = iVal;
|
||||
}
|
||||
}
|
||||
|
||||
return fValid;
|
||||
}
|
||||
|
||||
/* $DOC$
|
||||
* $FUNCNAME$
|
||||
* TIMEVALID()
|
||||
* $CATEGORY$
|
||||
* HBCT Date and Time Functions
|
||||
* $ONELINER$
|
||||
* Determines whether a specIFied time is valid
|
||||
* $SYNTAX$
|
||||
* TIMEVALID(<cTime>) --> lValid
|
||||
* $ARGUMENTS$
|
||||
* <cTime> Designates a character string that contains the time to
|
||||
* test.
|
||||
* $RETURNS$
|
||||
* TIMEVALID() RETURNs .T. when <cTime> is a valid time; or .F. when
|
||||
* <cTime> is an invalid time.
|
||||
* $DESCRIPTION$
|
||||
* With input that requires time manipulation, writing your own UDF to
|
||||
* check time inputs was unavoidable up to now. TIMEVALID() permits
|
||||
* Complete checking of a time designation. You can use this FUNCTION
|
||||
* effectively with a VALID clause within a READ mask.
|
||||
*
|
||||
* Note
|
||||
*
|
||||
* Note the format for time designations. There must always be
|
||||
* two digits for hours, minutes, seconds, and hundredths; otherwise,
|
||||
* the time it is regarded as invalid. Valid examples are "12",
|
||||
* "12:59", "12:59:59", and "12:59:59:99". By contrast, invalid
|
||||
* examples are "24", "12:60", or "12:1", and/or "12:". IF you work
|
||||
* with time strings that are not completely filled and that you need to
|
||||
* check with TIMEVALID(), then they must be TRIMmed prior to the use of
|
||||
* TIMEVALID() (see following Examples).
|
||||
* $EXAMPLES$
|
||||
* Using the VALID clause with TRIM, all valid times are
|
||||
* accepted, even IF no seconds or minutes are specIFied:
|
||||
*
|
||||
* cBegin := SPACE(11)
|
||||
* @ 5, 10 SAY "Please input time for beginning work:";
|
||||
* GET cBegin VALID TIMEVALID(TRIM(cBegin))
|
||||
* READ
|
||||
*
|
||||
* Using a VALID clause without TRIM, hours and minutes must be
|
||||
* specified, so that TIMEVALID() can confirm a valid time:
|
||||
*
|
||||
* cBegin := SPACE(5)
|
||||
* @ 5, 10 SAY "Please input time for beginning work:";
|
||||
* GET cBegin VALID TIMEVALID(cBegin)
|
||||
* READ
|
||||
* $TESTS$
|
||||
* $STATUS$
|
||||
* Ready
|
||||
* $COMPLIANCE$
|
||||
* This function is CA-Clipper Tools compatible.
|
||||
* $PLATFORMS$
|
||||
* Windows
|
||||
* $FILES$
|
||||
* Source is dattime3.c, library is libct.
|
||||
* $SEEALSO$
|
||||
* SETTIME()
|
||||
* $END$
|
||||
*/
|
||||
|
||||
HB_FUNC( TIMEVALID )
|
||||
{
|
||||
hb_retl( _hb_timeValid( hb_parc( 1 ), hb_parclen( 1 ), NULL ) );
|
||||
}
|
||||
|
||||
|
||||
/* $DOC$
|
||||
* $FUNCNAME$
|
||||
* SETTIME()
|
||||
* $CATEGORY$
|
||||
* HBCT Date and Time Functions
|
||||
* $ONELINER$
|
||||
* Sets the system clock
|
||||
* $SYNTAX$
|
||||
* SETTIME(<cTime>, [<lMode>]) --> lSet
|
||||
* $ARGUMENTS$
|
||||
* <cTime> Designates a character string that contains the time that
|
||||
* is to become the system time.
|
||||
*
|
||||
* <lMode> Designates whether the time should also be set in the
|
||||
* CMOS-RAM of an AT. The default is do not write to CMOS-RAM. Note that in
|
||||
* Windows plataform this adjust is automatic, therefore this parameter is
|
||||
* without efect.
|
||||
* $RETURNS$
|
||||
* The FUNCTION RETURNs .T. when the time is set successfully.
|
||||
* $DESCRIPTION$
|
||||
* When you use this FUNCTION to convert the time into the system time from
|
||||
* within your xHarbour application, all files acquire this time with
|
||||
* each write procedure.
|
||||
* $EXAMPLES$
|
||||
* Set the system time in each case; but the hardware clock only
|
||||
* on an AT:
|
||||
*
|
||||
* cNewTime := "10:20:00"
|
||||
* IF ISAT()
|
||||
* SETTIME(cNewTime, .T.)
|
||||
* ELSE
|
||||
* SETTIME(cNewTime)
|
||||
* ENDIF
|
||||
*
|
||||
* Or, more compactly:
|
||||
*
|
||||
* SETTIME(cNewTime, ISAT())
|
||||
* $TESTS$
|
||||
* $STATUS$
|
||||
* Ready
|
||||
* $COMPLIANCE$
|
||||
* This function is CA-Clipper Tools compatible.
|
||||
* $PLATFORMS$
|
||||
* Windows
|
||||
* $FILES$
|
||||
* Source is dattime3.c, library is libct.
|
||||
* $SEEALSO$
|
||||
* SETDATE(),TIMEVALID()
|
||||
* $END$
|
||||
*/
|
||||
|
||||
HB_FUNC( SETTIME )
|
||||
{
|
||||
BOOL fResult = FALSE;
|
||||
int iTime[4];
|
||||
|
||||
iTime[0] = iTime[1] = iTime[2] = iTime[3] = 0;
|
||||
if( _hb_timeValid( hb_parc( 1 ), hb_parclen( 1 ), iTime ) )
|
||||
{
|
||||
#if defined(HB_OS_WIN_32)
|
||||
SYSTEMTIME st;
|
||||
GetLocalTime( &st );
|
||||
st.wHour = iTime[0];
|
||||
st.wMinute = iTime[1];
|
||||
st.wSecond = iTime[2];
|
||||
st.wMilliseconds = iTime[3] * 10;
|
||||
fResult = SetLocalTime( &st );
|
||||
#elif defined( HB_OS_LINUX ) && !defined( __WATCOMC__ )
|
||||
/* stime exists only in SVr4, SVID, X/OPEN and Linux */
|
||||
ULONG lNewTime;
|
||||
time_t tm;
|
||||
|
||||
lNewTime = iTime[0] * 3600 + iTime[1] * 60 + iTime[2];
|
||||
tm = time( NULL );
|
||||
tm += lNewTime - ( tm % 86400 );
|
||||
fResult = stime( &tm ) == 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
hb_retl( fResult );
|
||||
}
|
||||
|
||||
|
||||
/* $DOC$
|
||||
* $FUNCNAME$
|
||||
* SETDATE()
|
||||
* $CATEGORY$
|
||||
* HBCT Date and Time Functions
|
||||
* $ONELINER$
|
||||
* Sets the system date
|
||||
* $SYNTAX$
|
||||
* SETDATE(<dDate>, [<lMode>]) --> lSet
|
||||
* $ARGUMENTS$
|
||||
* <dDate> Designates which date to use to set the system date.
|
||||
*
|
||||
* <lMode> Designates whether the date should also be set in the CMOS-
|
||||
* RAM of an AT. The default is do not write (.F.). Note that in Windows
|
||||
* plataform this adjust is automatic, therefore this parameter is without
|
||||
* efect.
|
||||
* $RETURNS$
|
||||
* SETDATE() RETURNs .T. when the date is successfully set.
|
||||
* $DESCRIPTION$
|
||||
* When you use this FUNCTION to set the system date from within your
|
||||
* xHarbour application, all files acquire this date with each write
|
||||
* procedure.
|
||||
* $EXAMPLES$
|
||||
* Set the system date in each case; but the hardware clock only
|
||||
* on an AT:
|
||||
*
|
||||
* dNewDate := CTOD("07/30/91")
|
||||
* IF ISAT()
|
||||
* SETDATE(dNewDate, .T.)
|
||||
* ELSE
|
||||
* SETDATE(dNewDate)
|
||||
* ENDIF
|
||||
*
|
||||
* Or, more compactly:
|
||||
*
|
||||
* SETDATE(dNewDate, ISAT())
|
||||
* $TESTS$
|
||||
* $STATUS$
|
||||
* Ready
|
||||
* $COMPLIANCE$
|
||||
* This function is CA-Clipper Tools compatible.
|
||||
* $PLATFORMS$
|
||||
* Windows
|
||||
* $FILES$
|
||||
* Source is dattime3.c, library is libct.
|
||||
* $SEEALSO$
|
||||
* SETTIME()
|
||||
* $END$
|
||||
*/
|
||||
|
||||
HB_FUNC( SETDATE )
|
||||
{
|
||||
BOOL fResult = FALSE;
|
||||
long lDate = hb_pardl( 1 );
|
||||
|
||||
if( lDate )
|
||||
{
|
||||
int iYear, iMonth, iDay;
|
||||
|
||||
hb_dateDecode( lDate, &iYear, &iMonth, &iDay );
|
||||
if( iYear >= 1970 )
|
||||
{
|
||||
#if defined(HB_OS_WIN_32)
|
||||
SYSTEMTIME st;
|
||||
GetLocalTime( &st );
|
||||
st.wYear = iYear;
|
||||
st.wMonth = iMonth;
|
||||
st.wDay = iDay;
|
||||
st.wDayOfWeek = hb_dateJulianDOW( lDate );
|
||||
fResult = SetLocalTime( &st );
|
||||
#elif defined( HB_OS_LINUX ) && !defined( __WATCOMC__ )
|
||||
/* stime exists only in SVr4, SVID, X/OPEN and Linux */
|
||||
long lNewDate;
|
||||
time_t tm;
|
||||
|
||||
lNewDate = lDate - hb_dateEncode( 1970, 1, 1 );
|
||||
tm = time( NULL );
|
||||
tm = lNewDate * 86400 + ( tm % 86400 );
|
||||
fResult = stime( &tm ) == 0;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
hb_retl( fResult );
|
||||
}
|
||||
@@ -121,6 +121,7 @@ TOOLS_LIB_OBJS = \
|
||||
$(OBJ_DIR)\ctwin.obj \
|
||||
$(OBJ_DIR)\datetime.obj \
|
||||
$(OBJ_DIR)\dattime2.obj \
|
||||
$(OBJ_DIR)\dattime3.obj \
|
||||
$(OBJ_DIR)\dbftools.obj \
|
||||
$(OBJ_DIR)\exponent.obj \
|
||||
$(OBJ_DIR)\files.obj \
|
||||
@@ -155,6 +156,7 @@ TOOLS_LIB_OBJS = \
|
||||
$(OBJ_DIR)\token1.obj \
|
||||
$(OBJ_DIR)\token2.obj \
|
||||
$(OBJ_DIR)\trig.obj \
|
||||
$(OBJ_DIR)\video.obj \
|
||||
$(OBJ_DIR)\wordrepl.obj \
|
||||
$(OBJ_DIR)\wordtoch.obj \
|
||||
\
|
||||
@@ -304,6 +306,10 @@ $(OBJ_DIR)\dattime2.obj : $(TOOLS_DIR)\dattime2.c
|
||||
$(CC) $(CLIBFLAGS) -o$@ $**
|
||||
tlib $(TOOLS_LIB) $(ARFLAGS) -+$@,,
|
||||
|
||||
$(OBJ_DIR)\dattime3.obj : $(TOOLS_DIR)\dattime3.c
|
||||
$(CC) $(CLIBFLAGS) -o$@ $**
|
||||
tlib $(TOOLS_LIB) $(ARFLAGS) -+$@,,
|
||||
|
||||
$(OBJ_DIR)\dbftools.obj : $(TOOLS_DIR)\dbftools.c
|
||||
$(CC) $(CLIBFLAGS) -o$@ $**
|
||||
tlib $(TOOLS_LIB) $(ARFLAGS) -+$@,,
|
||||
@@ -440,6 +446,10 @@ $(OBJ_DIR)\trig.obj : $(TOOLS_DIR)\trig.c
|
||||
$(CC) $(CLIBFLAGS) -o$@ $**
|
||||
tlib $(TOOLS_LIB) $(ARFLAGS) -+$@,,
|
||||
|
||||
$(OBJ_DIR)\video.obj : $(TOOLS_DIR)\video.c
|
||||
$(CC) $(CLIBFLAGS) -o$@ $**
|
||||
tlib $(TOOLS_LIB) $(ARFLAGS) -+$@,,
|
||||
|
||||
$(OBJ_DIR)\wordrepl.obj : $(TOOLS_DIR)\wordrepl.c
|
||||
$(CC) $(CLIBFLAGS) -o$@ $**
|
||||
tlib $(TOOLS_LIB) $(ARFLAGS) -+$@,,
|
||||
|
||||
@@ -140,6 +140,7 @@ TOOLS_LIB_OBJS = \
|
||||
$(OBJ_DIR)\cttime.obj \
|
||||
$(OBJ_DIR)\datetime.obj \
|
||||
$(OBJ_DIR)\dattime2.obj \
|
||||
$(OBJ_DIR)\dattime3.obj \
|
||||
$(OBJ_DIR)\dbftools.obj \
|
||||
$(OBJ_DIR)\exponent.obj \
|
||||
$(OBJ_DIR)\finan.obj \
|
||||
@@ -173,6 +174,7 @@ TOOLS_LIB_OBJS = \
|
||||
$(OBJ_DIR)\token1.obj \
|
||||
$(OBJ_DIR)\token2.obj \
|
||||
$(OBJ_DIR)\trig.obj \
|
||||
$(OBJ_DIR)\video.obj \
|
||||
$(OBJ_DIR)\wordrepl.obj \
|
||||
$(OBJ_DIR)\wordtoch.obj \
|
||||
\
|
||||
@@ -219,6 +221,7 @@ CLEAN:
|
||||
-@if exist $(OBJ_DIR)\ctpad.* del $(OBJ_DIR)\ctpad.*
|
||||
-@if exist $(OBJ_DIR)\datetime.* del $(OBJ_DIR)\datetime.*
|
||||
-@if exist $(OBJ_DIR)\dattime2.* del $(OBJ_DIR)\dattime2.*
|
||||
-@if exist $(OBJ_DIR)\dattime3.* del $(OBJ_DIR)\dattime3.*
|
||||
-@if exist $(OBJ_DIR)\dbftools.* del $(OBJ_DIR)\dbftools.*
|
||||
-@if exist $(OBJ_DIR)\exponent.* del $(OBJ_DIR)\exponent.*
|
||||
-@if exist $(OBJ_DIR)\finan.* del $(OBJ_DIR)\finan.*
|
||||
@@ -250,6 +253,7 @@ CLEAN:
|
||||
-@if exist $(OBJ_DIR)\token1.* del $(OBJ_DIR)\token1.*
|
||||
-@if exist $(OBJ_DIR)\token2.* del $(OBJ_DIR)\token2.*
|
||||
-@if exist $(OBJ_DIR)\trig.* del $(OBJ_DIR)\trig.*
|
||||
-@if exist $(OBJ_DIR)\video.* del $(OBJ_DIR)\video.*
|
||||
-@if exist $(OBJ_DIR)\wordrepl.* del $(OBJ_DIR)\wordrepl.*
|
||||
-@if exist $(OBJ_DIR)\wordtoch.* del $(OBJ_DIR)\wordtoch.*
|
||||
-@if exist $(OBJ_DIR)\ct.* del $(OBJ_DIR)\ct.*
|
||||
|
||||
376
harbour/contrib/libct/video.c
Normal file
376
harbour/contrib/libct/video.c
Normal file
@@ -0,0 +1,376 @@
|
||||
/*
|
||||
* $Id$
|
||||
*
|
||||
* xHarbour Project source code:
|
||||
*
|
||||
* CT3 video functions
|
||||
*
|
||||
* CHARPIX, VGAPALETTE, VIDEOTYPE, SETFONT
|
||||
* Copyright 2004 Phil Krylov <phil@newstar.rinet.ru>
|
||||
*
|
||||
* www - http://www.xharbour.org
|
||||
*
|
||||
* 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 2, 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 software; see the file COPYING. If not, write to
|
||||
* the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
|
||||
* Boston, MA 02111-1307 USA (or visit the web site http://www.gnu.org/).
|
||||
*
|
||||
* As a special exception, the Harbour Project gives permission for
|
||||
* additional uses of the text contained in its release of Harbour.
|
||||
*
|
||||
* The exception is that, if you link the Harbour libraries with other
|
||||
* files to produce an executable, this does not by itself cause the
|
||||
* resulting executable to be covered by the GNU General Public License.
|
||||
* Your use of that executable is in no way restricted on account of
|
||||
* linking the Harbour library code into it.
|
||||
*
|
||||
* This exception does not however invalidate any other reasons why
|
||||
* the executable file might be covered by the GNU General Public License.
|
||||
*
|
||||
* This exception applies only to the code released by the Harbour
|
||||
* Project under the name Harbour. If you copy code from other
|
||||
* Harbour Project or Free Software Foundation releases into a copy of
|
||||
* Harbour, as the General Public License permits, the exception does
|
||||
* not apply to the code that you add in this way. To avoid misleading
|
||||
* anyone as to the status of such modified files, you must delete
|
||||
* this exception notice from them.
|
||||
*
|
||||
* If you write modifications of your own for Harbour, it is your choice
|
||||
* whether to permit this exception to apply to your modifications.
|
||||
* If you do not wish that, delete this exception notice.
|
||||
*
|
||||
*
|
||||
* See doc/license.txt for licensing terms.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "hbapi.h"
|
||||
|
||||
#if defined( HB_OS_DOS )
|
||||
|
||||
# if defined( __DJGPP__ )
|
||||
# include <dpmi.h>
|
||||
# include <go32.h>
|
||||
# include <pc.h>
|
||||
# include <sys/farptr.h>
|
||||
# endif
|
||||
|
||||
# include "ctvideo.ch"
|
||||
|
||||
|
||||
/* $DOC$
|
||||
* $FUNCNAME$
|
||||
* CHARPIX()
|
||||
* $CATEGORY$
|
||||
* HBCT video functions
|
||||
* $ONELINER$
|
||||
* Gets the number of scan lines per character.
|
||||
* $SYNTAX$
|
||||
* CHARPIX() --> nHeight
|
||||
* $ARGUMENTS$
|
||||
* $RETURNS$
|
||||
* Returns the number of scan lines per character.
|
||||
* $DESCRIPTION$
|
||||
* Returns the number of scan lines per character.
|
||||
* $EXAMPLES$
|
||||
* $TESTS$
|
||||
* $STATUS$
|
||||
* Started
|
||||
* $COMPLIANCE$
|
||||
* This function is xHarbour libct contrib
|
||||
* $PLATFORMS$
|
||||
* DJGPP
|
||||
* $FILES$
|
||||
* Source is video.c, library is libct.
|
||||
* $SEEALSO$
|
||||
* $END$
|
||||
*/
|
||||
|
||||
HB_FUNC( CHARPIX )
|
||||
{
|
||||
# ifdef __DJGPP__
|
||||
hb_retni( _farpeekw( _dos_ds, 0x485 ) );
|
||||
# endif
|
||||
}
|
||||
|
||||
|
||||
/* $DOC$
|
||||
* $FUNCNAME$
|
||||
* VGAPALETTE()
|
||||
* $CATEGORY$
|
||||
* HBCT video functions
|
||||
* $ONELINER$
|
||||
* Changes VGA palette colors
|
||||
* $SYNTAX$
|
||||
* VGAPALETTE([<cColor|nColor>, [<nRedValue>, <nGreenValue>,
|
||||
* <nBlueValue]]) --> lValid
|
||||
* $ARGUMENTS$
|
||||
* <cColor|nColor> - the color to change in CA-Clipper color notation or
|
||||
* as a number from 0 to 15.
|
||||
* <nRedValue>, <nGreenValue>, and <nBlueValue> specify the palette
|
||||
* settings for the respective portions in the range from 0 to 63.
|
||||
* If no RGB value is specified, the palette register is reset to
|
||||
* its default value (currently unsupported).
|
||||
* If the function is called without parameters, the palette registers for
|
||||
* all colors are reset to their default values (currently unsupported).
|
||||
* $RETURNS$
|
||||
* Returns .T. on success.
|
||||
* $DESCRIPTION$
|
||||
* $EXAMPLES$
|
||||
* $TESTS$
|
||||
* $STATUS$
|
||||
* Started
|
||||
* $COMPLIANCE$
|
||||
* This function is xHarbour libct contrib
|
||||
* $PLATFORMS$
|
||||
* DJGPP
|
||||
* $FILES$
|
||||
* Source is video.c, library is libct.
|
||||
* $SEEALSO$
|
||||
* EGAPALETTE() FONTRESET()
|
||||
* $END$
|
||||
*/
|
||||
|
||||
HB_FUNC( VGAPALETTE )
|
||||
{
|
||||
char *color_string;
|
||||
char red, green, blue;
|
||||
char attr = 0;
|
||||
|
||||
if( hb_pcount() < 4 )
|
||||
{
|
||||
/* Resetting palette registers to default values is not supported yet */
|
||||
hb_retl( FALSE );
|
||||
return;
|
||||
}
|
||||
if( ISNUM( 1 ) && hb_parni( 1 ) < 16 )
|
||||
{
|
||||
attr = hb_parni( 1 );
|
||||
}
|
||||
else if( ISCHAR( 1 ) )
|
||||
{
|
||||
char *s;
|
||||
|
||||
color_string = hb_parcx( 1 );
|
||||
for( s = color_string; *s; s++ )
|
||||
{
|
||||
switch ( *s )
|
||||
{
|
||||
case 'N':
|
||||
case 'n':
|
||||
attr |= 0;
|
||||
break;
|
||||
case 'B':
|
||||
case 'b':
|
||||
attr |= 1;
|
||||
break;
|
||||
case 'G':
|
||||
case 'g':
|
||||
attr |= 2;
|
||||
break;
|
||||
case 'R':
|
||||
case 'r':
|
||||
attr |= 4;
|
||||
break;
|
||||
case 'W':
|
||||
case 'w':
|
||||
attr |= 7;
|
||||
break;
|
||||
case '+':
|
||||
attr |= 8;
|
||||
break;
|
||||
case 'U':
|
||||
case 'u':
|
||||
case 'I':
|
||||
case 'i':
|
||||
case 'X':
|
||||
case 'x':
|
||||
/* these seem to be used only in mono */
|
||||
break;
|
||||
default:
|
||||
hb_retl( FALSE );
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
/* An invalid argument */
|
||||
hb_retl( FALSE );
|
||||
return;
|
||||
}
|
||||
|
||||
red = hb_parni( 2 );
|
||||
green = hb_parni( 3 );
|
||||
blue = hb_parni( 4 );
|
||||
|
||||
# ifdef __DJGPP__
|
||||
{
|
||||
__dpmi_regs r;
|
||||
int iflag;
|
||||
|
||||
/* Get palette register for this attribute to BH using BIOS -
|
||||
* I couldn't manage to get it through ports */
|
||||
r.x.ax = 0x1007;
|
||||
r.h.bl = attr;
|
||||
__dpmi_int( 0x10, &r );
|
||||
|
||||
iflag = __dpmi_get_and_disable_virtual_interrupt_state();
|
||||
|
||||
/* Wait for vertical retrace (for old VGA cards) */
|
||||
while( inportb( 0x3DA ) & 8 ) ;
|
||||
while( !( inportb( 0x3DA ) & 8 ) ) ;
|
||||
|
||||
outportb( 0x3C8, r.h.bh );
|
||||
outportb( 0x3C9, red );
|
||||
outportb( 0x3C9, green );
|
||||
outportb( 0x3C9, blue );
|
||||
|
||||
if( iflag )
|
||||
__dpmi_get_and_enable_virtual_interrupt_state();
|
||||
}
|
||||
hb_retl( TRUE );
|
||||
# else
|
||||
hb_retl( FALSE );
|
||||
# endif
|
||||
}
|
||||
|
||||
|
||||
/* $DOC$
|
||||
* $FUNCNAME$
|
||||
* VIDEOTYPE()
|
||||
* $CATEGORY$
|
||||
* HBCT video functions
|
||||
* $ONELINER$
|
||||
* Detects supported video adapter modes
|
||||
* $SYNTAX$
|
||||
* VIDEOTYPE() --> nMask
|
||||
* $ARGUMENTS$
|
||||
* $RETURNS$
|
||||
* $DESCRIPTION$
|
||||
* TODO: Finish documentation
|
||||
* $EXAMPLES$
|
||||
* $TESTS$
|
||||
* $STATUS$
|
||||
* Started
|
||||
* $COMPLIANCE$
|
||||
* This function is xHarbour libct contrib
|
||||
* $PLATFORMS$
|
||||
* DJGPP
|
||||
* $FILES$
|
||||
* Source is video.c, library is libct.
|
||||
* $SEEALSO$
|
||||
* ISCGA(), ISEGA(), ISHERCULES(), ISMCGA(), ISMONO(), ISPGA(), ISVGA()
|
||||
* $END$
|
||||
*/
|
||||
|
||||
HB_FUNC( VIDEOTYPE )
|
||||
{
|
||||
# if defined( __DJGPP__ )
|
||||
__dpmi_regs r;
|
||||
|
||||
r.h.ah = 0x12; /* Alternate Select */
|
||||
r.h.bl = 0x10; /* Get EGA info */
|
||||
__dpmi_int( 0x10, &r );
|
||||
if( r.h.bl == 0x10 )
|
||||
{
|
||||
/* CGA/HGC/MDA */
|
||||
hb_retni( VCARD_MONOCHROME );
|
||||
}
|
||||
else
|
||||
{
|
||||
/* EGA/VGA */
|
||||
r.x.ax = 0x1A00;
|
||||
__dpmi_int( 0x10, &r );
|
||||
if( r.h.al == 0x1A )
|
||||
hb_retni( VCARD_VGA );
|
||||
else
|
||||
hb_retni( VCARD_EGA );
|
||||
}
|
||||
# endif
|
||||
}
|
||||
|
||||
|
||||
/* $DOC$
|
||||
* $FUNCNAME$
|
||||
* SETFONT()
|
||||
* $CATEGORY$
|
||||
* HBCT video functions
|
||||
* $ONELINER$
|
||||
* Loads font from a string.
|
||||
* $SYNTAX$
|
||||
* SETFONT(<cFontString>, [<nFontArea>], [<nOffset>], [<nCounter>]) --> nError
|
||||
* or:
|
||||
* SETFONT(<cFontString>, [<nFontArea>], [<lCompute>]) --> nError
|
||||
* $ARGUMENTS$
|
||||
* <cFontString> Binary string containing a valid font definition.
|
||||
* <nFontArea> Number of a font area where the font must be loaded.
|
||||
* <nOffset> First character code to be loaded.
|
||||
* <nCounter> Number of characters to load.
|
||||
* <lCompute> When .T., the function computes font height automatically.
|
||||
* $RETURNS$
|
||||
* $DESCRIPTION$
|
||||
* TODO: Finish documentation
|
||||
* $EXAMPLES$
|
||||
* $TESTS$
|
||||
* $STATUS$
|
||||
* Started
|
||||
* $COMPLIANCE$
|
||||
* This function is xHarbour libct contrib
|
||||
* $PLATFORMS$
|
||||
* DJGPP
|
||||
* $FILES$
|
||||
* Source is video.c, library is libct.
|
||||
* $SEEALSO$
|
||||
* $END$
|
||||
*/
|
||||
|
||||
HB_FUNC( SETFONT )
|
||||
{
|
||||
char *font = hb_parcx( 1 );
|
||||
int len = hb_parclen( 1 );
|
||||
int area = hb_parni( 2 );
|
||||
int offset = 0;
|
||||
int count = 256;
|
||||
int height = 16;
|
||||
|
||||
if( !area )
|
||||
area = 1;
|
||||
if( ISNUM( 3 ) )
|
||||
offset = hb_parni( 3 );
|
||||
if( ISNUM( 4 ) )
|
||||
count = hb_parni( 4 );
|
||||
if( ISLOG( 3 ) )
|
||||
if( hb_parl( 3 ) && count != 0 )
|
||||
height = len / count;
|
||||
|
||||
# ifdef __DJGPP__
|
||||
{
|
||||
__dpmi_regs r;
|
||||
|
||||
r.x.ax = 0x1110; /* Load user-defined text-mode display font */
|
||||
r.h.bl = area - 1;
|
||||
r.h.bh = height;
|
||||
r.x.cx = count;
|
||||
r.x.dx = offset;
|
||||
r.x.es = __tb >> 4;
|
||||
r.x.bp = __tb & 0xF;
|
||||
dosmemput( font, len, __tb );
|
||||
__dpmi_int( 0x10, &r );
|
||||
}
|
||||
# endif
|
||||
|
||||
hb_retni( 0 );
|
||||
}
|
||||
|
||||
#endif /* HB_OS_DOS */
|
||||
Reference in New Issue
Block a user