Files
harbour-core/harbour/contrib/hbct/video.c
Viktor Szakats 1dd4321de8 2010-02-22 15:06 UTC+0100 Viktor Szakats (harbour.01 syenar.hu)
* include/hbdefs.h
    ! Fixed to not #include <dos.h> unconditionally. This should
      be done by specific source code, if needed. INCOMPATIBLE,
      if source code relied on this behavior. From now on it,
      should include dos.h manually.

  * src/vm/thread.c
  * src/common/hbver.c
  * src/rtl/gtdos/gtdos.c
  * src/rtl/isprint.c
  * src/rtl/diskspac.c
  * src/rtl/disksphb.c
  * src/rtl/net.c
  * contrib/hbct/print.c
    ! Fixed to #include <dos.h> manually.

  * src/rtl/fstemp.c
    ! Fixed recent warning for dos targets.

  * contrib/hbct/video.c
    ! Fixed old unused variable warning for dos/watcom targets.

  * INSTALL
    + Documented that OS/2 Warp 4 is supported (instead of generic OS/2).
2010-02-22 14:07:26 +00:00

342 lines
8.5 KiB
C

/*
* $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 COPYING for licensing terms.
*
*/
#include "hbapi.h"
#include "hbapigt.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-Cl*pper 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 )
{
const char *color_string;
char red, green, blue;
int attr;
if( hb_pcount() < 4 )
{
/* Resetting palette registers to default values is not supported yet */
hb_retl( HB_FALSE );
return;
}
color_string = hb_parc( 1 );
if( color_string )
attr = hb_gtColorToN( color_string );
else if( HB_ISNUM( 1 ) )
attr = hb_parni( 1 );
else
attr = -1;
if( attr < 0 || attr >= 16 )
{
/* An invalid argument */
hb_retl( HB_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( HB_TRUE );
# else
hb_retl( HB_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 )
{
const char *font = hb_parcx( 1 );
unsigned len = ( unsigned ) hb_parclen( 1 );
int area = hb_parni( 2 );
int offset = 0;
int count = 256;
int height = 16;
if( !area )
area = 1;
if( HB_ISNUM( 3 ) )
offset = hb_parni( 3 );
if( HB_ISNUM( 4 ) )
count = hb_parni( 4 );
if( HB_ISLOG( 3 ) && 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, HB_MIN( len, __tb_size ), __tb );
__dpmi_int( 0x10, &r );
hb_retni( 0 );
}
# else
{
HB_SYMBOL_UNUSED( font );
hb_retni( -2 );
}
# endif
}
#endif /* HB_OS_DOS */