help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Plotting in Octave


From: Ludger Kunz
Subject: Re: Plotting in Octave
Date: Wed, 20 Jul 94 16:57:51 +0200

Hi,

here is my linux-svgalib driver i am using with gnuplot. I
hope it is the one you are looking for.

Ludger Kunz


----------------snip------------------------------------
/* GNUPLOT - linux.trm */
/*
 * Copyright (C) 1993
 *
 * Permission to use, copy, and distribute this software and its
 * documentation for any purpose with or without fee is hereby granted, 
 * provided that the above copyright notice appear in all copies and 
 * that both that copyright notice and this permission notice appear 
 * in supporting documentation.
 *
 * Permission to modify the software is granted, but not the right to
 * distribute the modified code.  Modifications are to be distributed 
 * as patches to released version.
 *
 * This software  is provided "as is" without express or implied warranty.
 *
 * This file is included by ../term.c.
 *
 * This terminal driver supports:
 *  SVGA 1024x768x256 for PC's running the Linux Operating System 
 *  (also VGA 640x480x16, and SVGA 800x600x256)
 *
 * AUTHOR
 *  Scott Heavner (address@hidden)
 *  based on original linux.trm by Tommy Frandsen (address@hidden)
 *
 * send your comments or suggestions to (address@hidden).
 *
 */

/* If SVGALIB is defined, it will compile with the Linux SVGAlib 
 * mainatained by Harm Hanemaayer (address@hidden).  SVGAlib 0.6
 * supports Tridents, Tseng, Cirrus, Oak (?), and generic vga.
 *
 * If SVGALIB is not defined, it will attempt to use the trident
 * tvgalib address@hidden
 */

#undef LINUX_SVGALIB
#define LINUX_SVGALIB

#define _STRING_H_
#ifdef LINUX_SVGALIB
#include <vga.h>
#else
#include "/term/new/tvgalib/src/tvga.h"

#define VGA 1

int vga_setchipset(x) 
int x;
{
return 0;
}

int vga_hasmode(x)
int x;
{
if (vga_setmode(x)) {
        vga_setmode(TEXT);
        return 1;
}
return 0;
}

#endif

#define LINUX_XMAX 1024
#define LINUX_YMAX 768

#define LINUX_XLAST (LINUX_XMAX - 1)
#define LINUX_YLAST (LINUX_YMAX - 1)

#define LINUX_VCHAR FNT5X9_VCHAR
#define LINUX_HCHAR FNT5X9_HCHAR

#define LINUX_VTIC 5
#define LINUX_HTIC 5

static int graphics_on = FALSE;

int startx, starty;
int linux_angle;

static int linux_vmode=G1024x768x256;
static int linux_xlast=LINUX_XLAST;
static int linux_ylast=LINUX_YLAST;

static int vgacolor[] = {7,8,2,3,4,5,9,14,12,15,13,10,11,1,6};

LINUX_options( )
{
#ifdef LINUX_SVGLIB
        if (!END_OF_COMMAND) {
                if (almost_equals(c_token,"T$VGA8900")||
                        almost_equals(c_token,"t$vga8900")) {
                        vga_setchipset(TVGA8900);
                        c_token++;
                }
                else if (almost_equals(c_token,"E$T4000")||
                        almost_equals(c_token,"e$t4000")) {
                        vga_setchipset(ET4000);
                        c_token++;
                }
                else if (almost_equals(c_token,"O$AK")||
                        almost_equals(c_token,"o$ak")) {
                        vga_setchipset(OAK);
                        c_token++;
                }
                else if (almost_equals(c_token,"C$IRRUS")||
                        almost_equals(c_token,"c$irrus")) {
                        vga_setchipset(CIRRUS);
                        c_token++;
                }
        }
#endif

        if (!END_OF_COMMAND) {
                if (almost_equals(c_token,"v$ga")||
                        almost_equals(c_token,"V$GA")) {
                        vga_setchipset(VGA);
                        linux_vmode = G640x480x16;
                        c_token++;
                }
                else if (almost_equals(c_token,"s$vga")||
                        almost_equals(c_token,"S$VGA")) {
                        vga_setchipset(UNDEFINED);
                        if ( vga_hasmode(G1024x768x256) ) {
                                linux_vmode = G1024x768x256;
                                term_tbl[term].xmax = 1024;
                                term_tbl[term].ymax = 768;
                                linux_xlast = 1023;
                                linux_ylast = 767;
                        }
                        else {
                                printf("Cannot use 1024x768 mode, using 
640x480x16\n");
                                linux_vmode = G640x480x16;
                        }
                        c_token++;
                }
                else if (almost_equals(c_token,"s8$00")||
                        almost_equals(c_token,"S8$00")) {
                        vga_setchipset(UNDEFINED);
                        if ( vga_hasmode(G800x600x256) ) {
                                linux_vmode = G800x600x256;
                                term_tbl[term].xmax = 800;
                                term_tbl[term].ymax = 600;
                                linux_xlast = 799;
                                linux_ylast = 599;
                        }
                        else {
                                printf("Cannot use 800x600 mode, using 
640x480x16\n");
                                linux_vmode = G640x480x16;
                        }
                        c_token++;
                }

                /********  SVGALIB doesn't support 16 color modes (yet?)
                else if (almost_equals(c_token,"s81$6")||
                        almost_equals(c_token,"S81$6")) {
                        vga_setchipset(UNDEFINED);
                        if ( vga_hasmode(G800x600x256) ) {
                                linux_vmode = G800x600x256;
                                term_tbl[term].xmax = 800;
                                term_tbl[term].ymax = 600;
                                linux_xlast = 799;
                                linux_ylast = 599;
                        }
                        else {
                                printf("Cannot use 800x600 mode, using 
640x480x16\n");
                                linux_vmode = G640x480x16;
                        }
                        c_token++;
                } 
                
***************************************************************************/

        }

        if ( linux_vmode == G640x480x16 ) {
                term_tbl[term].xmax = 640;
                term_tbl[term].ymax = 480;
                linux_xlast = 639;
                linux_ylast = 479;
        }

        sprintf(term_options,"%s" ,
                ( linux_vmode == G1024x768x256 ) ? "svga" : (
                        ( linux_vmode == G800x600x256) ?  "800x600x256" : (
                        ( linux_vmode == G320x240x256) ?  "800x600x16" :"vga" ) 
) );

}
LINUX_text()
{
        int c;

        if (graphics_on) {
                graphics_on = FALSE;
                vga_getch();
        }
        vga_setmode(TEXT);
}


LINUX_reset()
{
        vga_setmode(TEXT);
}


LINUX_putc(x,y,c,ang,line_func)
unsigned int x,y;
char c;
int ang;
FUNC_PTR line_func;
{
int i, j, k;
unsigned int pixelon;
        i = (int)(c) - 32;
        for (j=0; j<FNT5X9_VBITS; j++) {
                for (k=0; k<FNT5X9_HBITS; k++) {
                        pixelon = (((unsigned int)(fnt5x9[i][j])) >> k & 1);
                        if (pixelon) {
                                switch(ang) {
                                        case 0 : 
(*line_func)(x+k+1,y-j,x+k+1,y-j);
                                                        break;
                                        case 1 : 
(*line_func)(x-j,y-k-1,x-j,y-k-1);
                                                        break;
                                }
                        }
                }
        }
}


int LINUX_text_angle(ang)
int ang;
{
        linux_angle=ang;
        return TRUE;
}


LINUX_init()
{
        if ( ! vga_hasmode(linux_vmode) ) { 
                linux_vmode == G640x480x16;
                if ( ! vga_hasmode(linux_vmode) ) {
                        printf("Error, cannot find any valid display modes.\n");
                        return 1;
                }
                term_tbl[term].xmax = 640;
                term_tbl[term].ymax = 480;
                linux_xlast = 639;
                linux_ylast = 479;
        }
}


LINUX_graphics()
{
        graphics_on = TRUE;
        vga_setmode(linux_vmode);
}


LINUX_linetype(linetype)
{
        if (linetype >= 13)
                linetype %= 13;
        vga_setcolor(vgacolor[linetype+2]); 
}

LINUX_move(x,y)
{
        startx = x;
        starty = y;
}


LINUX_vector(x,y)
{
        vga_drawline(startx,linux_ylast-starty,x,linux_ylast-y); 
        startx = x;
        starty = y;
}


LINUX_put_text(x,y,str)
unsigned int x, y;
char *str;
{
int i;
        switch(linux_angle) {
                case 0 : y -= LINUX_VCHAR/2;
                                break;
                case 1 : x += LINUX_VCHAR/2;
                                break;
        }
        for (i=0;str[i];i++) {
                LINUX_putc(x,linux_ylast-y,str[i],linux_angle,vga_drawline); 
                switch(linux_angle) {
                        case 0 : x+=LINUX_HCHAR ;
                                        break;
                        case 1 : y+=LINUX_HCHAR ;
                                        break;
                }
        }
}

-- 
Ludger Kunz           |    ____________|Tel.: 02371/566-230
FernUniversitaet Hagen|   /| /   / \   |FAX:  02371/52212           
Lehrgebiet ES         |  / |/   /_  \  |EMAIL:                      
Frauenstuhlweg 31     | /  |\  /     \ |address@hidden
58644 Iserlohn        |/___|_\/_______\|


reply via email to

[Prev in Thread] Current Thread [Next in Thread]