From 26aae29987fdef16919d0b65408160acbaaa2467 Mon Sep 17 00:00:00 2001 From: Przemyslaw Czerpak Date: Fri, 3 Aug 2007 02:05:58 +0000 Subject: [PATCH] 2007-08-03 04:05 UTC+0200 Przemyslaw Czerpak (druzus/at/priv.onet.pl) * harbour/contrib/libct/screen2.c + added SCREENSTR(), STRSCREEN() * harbour/contrib/libct/keyset.c * casting to fix warnings in DOS builds * harbour/source/rtl/seconds.c * update timezone in BSD systems when clock is stored in UTC --- harbour/ChangeLog | 10 ++++ harbour/contrib/libct/keyset.c | 10 ++-- harbour/contrib/libct/screen2.c | 90 ++++++++++++++++++++++++++++++++- harbour/source/rtl/seconds.c | 2 +- 4 files changed, 105 insertions(+), 7 deletions(-) diff --git a/harbour/ChangeLog b/harbour/ChangeLog index 42b5e35ba4..ae53c1c103 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -8,6 +8,16 @@ 2002-12-01 13:30 UTC+0100 Foo Bar */ +2007-08-03 04:05 UTC+0200 Przemyslaw Czerpak (druzus/at/priv.onet.pl) + * harbour/contrib/libct/screen2.c + + added SCREENSTR(), STRSCREEN() + + * harbour/contrib/libct/keyset.c + * casting to fix warnings in DOS builds + + * harbour/source/rtl/seconds.c + * update timezone in BSD systems when clock is stored in UTC + 2007-08-02 18:03 UTC+0100 Viktor Szakats (harbour.01 syenar.hu) * harbour/contrib/libct/keyset.c ! Fixed gcc 4.1.2 warning in SetGet() (Win32 branch). diff --git a/harbour/contrib/libct/keyset.c b/harbour/contrib/libct/keyset.c index f8bd9087c4..e461630123 100644 --- a/harbour/contrib/libct/keyset.c +++ b/harbour/contrib/libct/keyset.c @@ -73,11 +73,11 @@ static void SetGet( unsigned char cKey ) { #if defined(__WATCOMC__) && defined(__386__) - hb_retl( *( ( char * ) 0x0417 ) & cKey ); + hb_retl( *( ( unsigned char * ) 0x0417 ) & cKey ); #elif defined(__DJGPP__) hb_retl( _farpeekb( 0x0040, 0x0017 ) & cKey ); #else - hb_retl( *( ( char FAR * ) MK_FP( 0x0040, 0x0017 ) ) & cKey ); + hb_retl( *( ( unsigned char FAR * ) MK_FP( 0x0040, 0x0017 ) ) & cKey ); #endif if( hb_pcount() >= 1 ) @@ -85,12 +85,12 @@ static void SetGet( unsigned char cKey ) cKey = hb_parl( 1 ) * cKey; #if defined(__WATCOMC__) && defined(__386__) - *( ( char * ) 0x0417 ) = ( *( ( char * ) 0x0417 ) & ( !cKey ) ) | cKey; + *( ( unsigned char * ) 0x0417 ) = ( *( ( unsigned char * ) 0x0417 ) & ( !cKey ) ) | cKey; #elif defined(__DJGPP__) _farpokeb( 0x0040, 0x0017, ( _farpeekb( 0x0040, 0x0017 ) & ( !cKey ) ) | cKey ); #else - *( ( char FAR * ) MK_FP( 0x0040, 0x0017 ) ) = - ( *( ( char FAR * ) MK_FP( 0x0040, 0x0017 ) ) & ( !cKey ) ) | cKey; + *( ( unsigned char FAR * ) MK_FP( 0x0040, 0x0017 ) ) = + ( *( ( unsigned char FAR * ) MK_FP( 0x0040, 0x0017 ) ) & ( !cKey ) ) | cKey; #endif } } diff --git a/harbour/contrib/libct/screen2.c b/harbour/contrib/libct/screen2.c index 07694a4538..661775c801 100644 --- a/harbour/contrib/libct/screen2.c +++ b/harbour/contrib/libct/screen2.c @@ -6,7 +6,7 @@ * Harbour Project source code: * CT3 video functions: * - * SAYDOWN(), SAYSPREAD(), SAYMOVEIN() + * SAYDOWN(), SAYSPREAD(), SAYMOVEIN(), SCREENSTR(), STRSCREEN() * * Copyright 2007 Przemyslaw Czerpak * @@ -224,3 +224,91 @@ HB_FUNC( SAYMOVEIN ) hb_retc( NULL ); } + +HB_FUNC( SCREENSTR ) +{ + SHORT sRow, sCol, sMaxRow, sMaxCol, sC; + char * pBuffer, * szText; + ULONG ulSize, ulCount = ULONG_MAX; + + hb_gtGetPos( &sRow, &sCol ); + if( ISNUM( 1 ) ) + sRow = ( SHORT ) hb_parni( 1 ); + if( ISNUM( 2 ) ) + sCol = ( SHORT ) hb_parni( 2 ); + if( ISNUM( 3 ) ) + ulCount = hb_parnl( 3 ); + sMaxRow = ( SHORT ) hb_gtMaxRow(); + sMaxCol = ( SHORT ) hb_gtMaxCol(); + + if( sRow >= 0 && sRow <= sMaxRow && sCol >= 0 && sCol <= sMaxCol && ulCount ) + { + ulSize = ( ULONG ) ( sMaxRow - sRow + 1 ) * ( sMaxCol - sCol + 1 ); + if( ulSize > ulCount ) + ulSize = ulCount; + ulCount = ulSize; + ulSize <<= 1; + szText = pBuffer = ( char * ) hb_xgrab( ulSize + 1 ); + do + { + sC = sCol; + do + { + BYTE bColor, bAttr; + USHORT usChar; + hb_gtGetChar( sRow, sC, &bColor, &bAttr, &usChar ); + *szText++ = ( char ) usChar; + *szText++ = ( char ) bColor; + } + while( ++sC <= sMaxCol && --ulCount ); + } + while( ++sRow <= sMaxRow && ulCount ); + + hb_retclen_buffer( pBuffer, ulSize ); + } + else + hb_retc( NULL ); +} + +HB_FUNC( STRSCREEN ) +{ + ULONG ulLen = hb_parclen( 1 ); + + if( ulLen & 1 ) + ulLen--; + + if( ulLen ) + { + UCHAR * szText = ( UCHAR * ) hb_parc( 1 ); + SHORT sRow, sCol, sMaxRow, sMaxCol, sC; + + hb_gtGetPos( &sRow, &sCol ); + if( ISNUM( 2 ) ) + sRow = ( SHORT ) hb_parni( 2 ); + if( ISNUM( 3 ) ) + sCol = ( SHORT ) hb_parni( 3 ); + sMaxRow = ( SHORT ) hb_gtMaxRow(); + sMaxCol = ( SHORT ) hb_gtMaxCol(); + + if( sRow >= 0 && sRow <= sMaxRow && sCol >= 0 && sCol <= sMaxCol ) + { + hb_gtBeginWrite(); + do + { + sC = sCol; + do + { + USHORT usChar = *szText++; + BYTE bColor = *szText++; + hb_gtPutChar( sRow, sC, bColor, 0, usChar ); + ulLen -= 2; + } + while( ulLen && ++sC <= sMaxCol ); + } + while( ulLen && ++sRow <= sMaxRow ); + hb_gtEndWrite(); + } + } + + hb_retc( NULL ); +} diff --git a/harbour/source/rtl/seconds.c b/harbour/source/rtl/seconds.c index b195f1da8f..1b90dde203 100644 --- a/harbour/source/rtl/seconds.c +++ b/harbour/source/rtl/seconds.c @@ -88,7 +88,7 @@ HB_EXPORT double hb_dateSeconds( void ) #if defined(HB_OS_BSD) gettimeofday( &tv, &tz ); - seconds = tv.tv_sec; + seconds = tv.tv_sec - tz.tz_minuteswest * 60; fraction = tv.tv_usec / 1000U; #else ftime( &tb );