BIOS graphics for MINIX part 1/4

10 views
Skip to first unread message

ma...@levels.unisa.edu.au

unread,
Feb 13, 1992, 10:59:07 PM2/13/92
to
#!/bin/sh
# This is a shell archive (produced by shar 3.49)
# To extract the files from this archive, save it to a file, remove
# everything above the "!/bin/sh" line above, and type "sh file_name".
#
# made 02/14/1992 03:42 UTC by mareb@lux
# Source directory /home/lux/c/ma/reb/tmp
#
# existing files will NOT be overwritten unless -c is specified
#
# This shar contains:
# length mode name
# ------ ---------- ------------------------------------------
# 1099 -rwx------ grafx10/Readme
# 2574 -rw------- grafx10/include/ggtty.h
# 379 -rw------- grafx10/include/minix/com.h.cdiff
# 625 -rw------- grafx10/kernel/console.c.cdif
# 9759 -rw------- grafx10/kernel/memory.c.cdiff
# 760 -rw------- grafx10/kernel/wini.c.cdiff
# 818 -rw------- grafx10/kernel/const.h.cdiff
# 2335 -rw------- grafx10/kernel/klib88.x.cdiff
# 3302 -rw------- grafx10/lib/ioctl.c.cdiff
# 644 -rw------- grafx10/libplot/Makefile
# 606 -rw------- grafx10/libplot/arc.c
# 389 -rw------- grafx10/libplot/closepl.c
# 501 -rw------- grafx10/libplot/colour.c
# 636 -rw------- grafx10/libplot/cont.c
# 443 -rw------- grafx10/libplot/erase.c
# 526 -rw------- grafx10/libplot/label.c
# 359 -rw------- grafx10/libplot/libplot.h
# 699 -rw------- grafx10/libplot/line.c
# 597 -rw------- grafx10/libplot/move.c
# 839 -rw------- grafx10/libplot/openpl.c
# 596 -rw------- grafx10/libplot/point.c
# 571 -rw------- grafx10/libplot/space.c
# 955 -rw------- grafx10/libplot/tst_lib.c
# 521 -rw------- grafx10/libplot/circle.c
# 570 -rw------- grafx10/libplot/linemod.c
# 171 -rw------- grafx10/plot/Makefile
# 4167 -rw------- grafx10/plot/plot.c
# 28207 -rwx------ grafx10/sysdoc.txt
# 465 -rw------- grafx10/tst/tst_plt.c
# 19184 -rwx------ grafx10/usrdoc.txt
# 1099 -rwx------ grafx10/Readme
# 2574 -rw------- grafx10/include/ggtty.h
# 379 -rw------- grafx10/include/minix/com.h.cdiff
# 2574 -rw------- grafx10/include/ggtty.h
# 379 -rw------- grafx10/include/minix/com.h.cdiff
# 379 -rw------- grafx10/include/minix/com.h.cdiff
# 625 -rw------- grafx10/kernel/console.c.cdif
# 9759 -rw------- grafx10/kernel/memory.c.cdiff
# 760 -rw------- grafx10/kernel/wini.c.cdiff
# 818 -rw------- grafx10/kernel/const.h.cdiff
# 2335 -rw------- grafx10/kernel/klib88.x.cdiff
# 625 -rw------- grafx10/kernel/console.c.cdif
# 9759 -rw------- grafx10/kernel/memory.c.cdiff
# 760 -rw------- grafx10/kernel/wini.c.cdiff
# 818 -rw------- grafx10/kernel/const.h.cdiff
# 2335 -rw------- grafx10/kernel/klib88.x.cdiff
# 3302 -rw------- grafx10/lib/ioctl.c.cdiff
# 3302 -rw------- grafx10/lib/ioctl.c.cdiff
# 644 -rw------- grafx10/libplot/Makefile
# 606 -rw------- grafx10/libplot/arc.c
# 389 -rw------- grafx10/libplot/closepl.c
# 501 -rw------- grafx10/libplot/colour.c
# 636 -rw------- grafx10/libplot/cont.c
# 443 -rw------- grafx10/libplot/erase.c
# 526 -rw------- grafx10/libplot/label.c
# 359 -rw------- grafx10/libplot/libplot.h
# 699 -rw------- grafx10/libplot/line.c
# 597 -rw------- grafx10/libplot/move.c
# 839 -rw------- grafx10/libplot/openpl.c
# 596 -rw------- grafx10/libplot/point.c
# 571 -rw------- grafx10/libplot/space.c
# 955 -rw------- grafx10/libplot/tst_lib.c
# 521 -rw------- grafx10/libplot/circle.c
# 570 -rw------- grafx10/libplot/linemod.c
# 644 -rw------- grafx10/libplot/Makefile
# 606 -rw------- grafx10/libplot/arc.c
# 389 -rw------- grafx10/libplot/closepl.c
# 501 -rw------- grafx10/libplot/colour.c
# 636 -rw------- grafx10/libplot/cont.c
# 443 -rw------- grafx10/libplot/erase.c
# 526 -rw------- grafx10/libplot/label.c
# 359 -rw------- grafx10/libplot/libplot.h
# 699 -rw------- grafx10/libplot/line.c
# 597 -rw------- grafx10/libplot/move.c
# 839 -rw------- grafx10/libplot/openpl.c
# 596 -rw------- grafx10/libplot/point.c
# 571 -rw------- grafx10/libplot/space.c
# 955 -rw------- grafx10/libplot/tst_lib.c
# 521 -rw------- grafx10/libplot/circle.c
# 570 -rw------- grafx10/libplot/linemod.c
# 171 -rw------- grafx10/plot/Makefile
# 4167 -rw------- grafx10/plot/plot.c
# 171 -rw------- grafx10/plot/Makefile
# 4167 -rw------- grafx10/plot/plot.c
# 28207 -rwx------ grafx10/sysdoc.txt
# 465 -rw------- grafx10/tst/tst_plt.c
# 465 -rw------- grafx10/tst/tst_plt.c
# 19184 -rwx------ grafx10/usrdoc.txt
#
# ============= grafx10/Readme ==============
if test ! -d 'grafx10'; then
echo 'x - creating directory grafx10'
mkdir 'grafx10'
fi
if test -f 'grafx10/Readme' -a X"$1" != X"-c"; then
echo 'x - skipping grafx10/Readme (File already exists)'
else
echo 'x - extracting grafx10/Readme (Text)'
sed 's/^X//' << 'SHAR_EOF' > 'grafx10/Readme' &&
X GRAFX 1.0 for MINIX
X ===================
X
The Grafx package gives MINIX the ability to display graphical output.
It also partially implements the UNIX plot(3X) library.
Graphics is driven through the BIOS (with all the associated implications).
X
Hardware Requirements:
X IBM-PC or BIOS compatible
X Graphics Adaptor - CGA,EGA,VGA,(Hercules Untested)
X
X Other platforms eg. 68K should be able to use this package
X with a small amount of work.
X
The documentation is distributed in the following files:
X
usrdoc.txt - User documentation - ASCII text
sysdoc.txt - System documentation - ASCII text
X
These are wordperfect output - so bold and underline may look odd
on your screen, but should print OK. Mail a request for the WP
files if you want to print with different fonts, etc.
X
I would welcome your feedback on this package. It was my 3rd year
project, as part of the Computer Studies Degree course at the
University of South Australia.
X
- Dave Gardiner, 14/2/92
Internet: ma89...@lux.levels.unisa.edu.au
X
SHAR_EOF
chmod 0700 grafx10/Readme ||
echo 'restore of grafx10/Readme failed'
Wc_c="`wc -c < 'grafx10/Readme'`"
test 1099 -eq "$Wc_c" ||
echo 'grafx10/Readme: original size 1099, current size' "$Wc_c"
fi
# ============= grafx10/include/ggtty.h ==============
if test ! -d 'grafx10/include'; then
echo 'x - creating directory grafx10/include'
mkdir 'grafx10/include'
fi
if test -f 'grafx10/include/ggtty.h' -a X"$1" != X"-c"; then
echo 'x - skipping grafx10/include/ggtty.h (File already exists)'
else
echo 'x - extracting grafx10/include/ggtty.h (Text)'
sed 's/^X//' << 'SHAR_EOF' > 'grafx10/include/ggtty.h' &&
/* The <ggtty.h> header contains data structures for ioctl(). */
/* for use with /dev/grafx device */
X
#ifndef _GGTTY_H
#define _GGTTY_H
X
typedef unsigned int coord;
typedef unsigned char spectrum;
X
typedef struct { long gm0l1, gm0l2; char * gm0p1;} g_mess0;
typedef struct { int gm1i2, gm1i1, gm1i4, gm1i3; } g_mess1;
typedef struct { char gm2b4, gm2b3, gm2b2, gm2b1, gm2b8, gm2b7, gm2b6, gm2b5; } g_mess2;
X
typedef union {
X g_mess0 gm0;
X g_mess1 gm1;
X g_mess2 gm2;
} gmess;
X
#define gm0_l1 gm0.gm0l1
#define gm0_l2 gm0.gm0l2
#define gm0_p1 gm0.gm0p1
X
#define gm1_i1 gm1.gm1i1
#define gm1_i2 gm1.gm1i2
#define gm1_i3 gm1.gm1i3
#define gm1_i4 gm1.gm1i4
X
#define gm2_b1 gm2.gm2b1
#define gm2_b2 gm2.gm2b2
#define gm2_b3 gm2.gm2b3
#define gm2_b4 gm2.gm2b4
#define gm2_b5 gm2.gm2b5
#define gm2_b6 gm2.gm2b6
#define gm2_b7 gm2.gm2b7
#define gm2_b8 gm2.gm2b8
X
#define GRAFX_X gm1_i1
#define GRAFX_Y gm1_i2
#define GRAFX_X2 gm1_i3
#define GRAFX_Y2 gm1_i4
#define GRAFX_COLOUR gm2_b1
#define GRAFX_CHAR gm2_b1
#define GRAFX_ADDRESS gm0_p1
#define GRAFX_SPEK gm0_l1
#define GRAFX_FLAGS gm0_l2
X
typedef struct {
X coord gg_x; /* x position */
X coord gg_y; /* y position */
X char f1,f2;
} gm_xy;
X
typedef struct {
X spectrum gg_colour; /* colour */
X char x1,x2,x3,x4,x5;
} gm_colour;
X
struct vid_stats {
X long base;
X unsigned colours;
X unsigned x,y;
};
X
#define base1 0xb8000L
#define base2 0xa0000L
X
/*
X base, 0..col, X, Y, Mode
X ====================================
X base1, 15, 320, 200, 0
X base1, 15, 320, 200, 1
X base1, 15, 640, 200, 2
X base1, 15, 640, 200, 3
X base1, 3, 320, 200, 4
X base1, 3, 320, 200, 5
X base1, 1, 640, 200, 6
X base1, 3, 720, 350, 7
X 0, 0, 0, 0, 8
X 0, 0, 0, 0, 9
X 0, 0, 0, 0, A
X 0, 0, 0, 0, B
X 0, 0, 0, 0, C
X base2, 15, 320, 200, D
X base2, 15, 640, 200, E
X base2, 3, 640, 350, F
X base2, 15, 640, 350, 10
X base2, 1, 640, 480, 11
X base2, 15, 640, 480, 12
X base2, 255, 320, 200, 13
*/
X
#define TEXT_MODE 3
#define CGA 4
#define EGA 0xD
#define VGA 0x12
#define SVGA 0x38
X
#define G_MODE VGA
#define G_BASE base2
#define G_COLOURS 15
/* The size in pixels of the graphics mode */
#define G_MAX_X 640
#define G_MAX_Y 480
X
/* The size of a character cell in this graphics mode */
#define G_CX_DIV 8
#define G_CY_DIV 16
X
/* IOCTL functions */
#define GIOCENTER (('g'<<8) | 1)
#define GIOCRETURN (('g'<<8) | 2)
#define GIOCTEST (('g'<<8) | 3)
#define GIOCPLOT (('g'<<8) | 4)
#define GIOCCOLOUR (('g'<<8) | 5)
#define GIOCTEXT (('g'<<8) | 6)
#define GIOCMOVE (('g'<<8) | 7)
#define GIOCLINE (('g'<<8) | 8)
X
#endif /* _GGTTY_H */
SHAR_EOF
chmod 0600 grafx10/include/ggtty.h ||
echo 'restore of grafx10/include/ggtty.h failed'
Wc_c="`wc -c < 'grafx10/include/ggtty.h'`"
test 2574 -eq "$Wc_c" ||
echo 'grafx10/include/ggtty.h: original size 2574, current size' "$Wc_c"
fi
# ============= grafx10/include/minix/com.h.cdiff ==============
if test ! -d 'grafx10/include/minix'; then
echo 'x - creating directory grafx10/include/minix'
mkdir 'grafx10/include/minix'
fi
if test -f 'grafx10/include/minix/com.h.cdiff' -a X"$1" != X"-c"; then
echo 'x - skipping grafx10/include/minix/com.h.cdiff (File already exists)'
else
echo 'x - extracting grafx10/include/minix/com.h.cdiff (Text)'
sed 's/^X//' << 'SHAR_EOF' > 'grafx10/include/minix/com.h.cdiff' &&
*** com.h Thu Nov 14 13:49:21 1991
--- new-com.h Thu Nov 14 13:48:23 1991
***************
*** 68,73 ****
--- 68,74 ----
X # define NULL_DEV 3 /* minor device for /dev/null */
X #if (CHIP == INTEL)
X # define PORT_DEV 4 /* minor device for /dev/port */
+ # define GRAFX_DEV 5 /* minor device for /dev/grafx */
X #endif
X
X #define CLOCK -3 /* clock class */
SHAR_EOF
chmod 0600 grafx10/include/minix/com.h.cdiff ||
echo 'restore of grafx10/include/minix/com.h.cdiff failed'
Wc_c="`wc -c < 'grafx10/include/minix/com.h.cdiff'`"
test 379 -eq "$Wc_c" ||
echo 'grafx10/include/minix/com.h.cdiff: original size 379, current size' "$Wc_c"
fi
# ============= grafx10/kernel/console.c.cdif ==============
if test ! -d 'grafx10/kernel'; then
echo 'x - creating directory grafx10/kernel'
mkdir 'grafx10/kernel'
fi
if test -f 'grafx10/kernel/console.c.cdif' -a X"$1" != X"-c"; then
echo 'x - skipping grafx10/kernel/console.c.cdif (File already exists)'
else
echo 'x - extracting grafx10/kernel/console.c.cdif (Text)'
sed 's/^X//' << 'SHAR_EOF' > 'grafx10/kernel/console.c.cdif' &&
*** /usr/src/kernel/console.c Mon Jun 17 11:40:48 1991
--- console.c Fri Aug 9 13:36:05 1991
***************
*** 745,751 ****
X /* Initialize the screen driver. */
X
X one_con_attribute = BLANK;
! if (ps) softscroll = TRUE;
X
X /* Tell the EGA card, if any, to simulate a 16K CGA card. */
X out_byte(EGA + INDEX, 4); /* register select */
--- 745,751 ----
X /* Initialize the screen driver. */
X
X one_con_attribute = BLANK;
! softscroll = TRUE; /* Need software scroll for /dev/grafx */
X
X /* Tell the EGA card, if any, to simulate a 16K CGA card. */
X out_byte(EGA + INDEX, 4); /* register select */
SHAR_EOF
chmod 0600 grafx10/kernel/console.c.cdif ||
echo 'restore of grafx10/kernel/console.c.cdif failed'
Wc_c="`wc -c < 'grafx10/kernel/console.c.cdif'`"
test 625 -eq "$Wc_c" ||
echo 'grafx10/kernel/console.c.cdif: original size 625, current size' "$Wc_c"
fi
# ============= grafx10/kernel/memory.c.cdiff ==============
if test -f 'grafx10/kernel/memory.c.cdiff' -a X"$1" != X"-c"; then
echo 'x - skipping grafx10/kernel/memory.c.cdiff (File already exists)'
else
echo 'x - extracting grafx10/kernel/memory.c.cdiff (Text)'
sed 's/^X//' << 'SHAR_EOF' > 'grafx10/kernel/memory.c.cdiff' &&
*** /usr/src/kernel/memory.c Mon Jun 17 11:40:50 1991
--- memory.c Mon Oct 7 14:41:30 1991
***************
*** 4,9 ****
--- 4,16 ----
X * /dev/kmem - kernel virtual memory
X * /dev/ram - RAM disk
X * /dev/port - i/o ports ((CHIP == INTEL) only)
+ * /dev/grafx - graphics device
+
+ * /dev/grafix Additions
+ * Stage 1: Get character device working
+ * Stage 2: Get ioctl working
+ * Stage 3: Implement ioctl functions
+
X *
X * The driver supports the following operations (using message format m2):
X *
***************
*** 26,47 ****
X */
X
X #include "kernel.h"
X #include <minix/callnr.h>
X #include <minix/com.h>
X
X #ifdef PORT_DEV
! #define NR_RAMS 5 /* number of RAM-type devices */
! #else
! #define NR_RAMS 4
! #endif
X PRIVATE message mess; /* message buffer */
X PRIVATE phys_bytes ram_origin[NR_RAMS]; /* origin of each RAM disk */
X PRIVATE phys_bytes ram_limit[NR_RAMS]; /* limit of RAM disk per minor dev. */
X
X FORWARD int do_mem();
X FORWARD int do_setup();
X
X /*===========================================================================*
X * mem_task *
X *===========================================================================*/
X PUBLIC void mem_task()
--- 33,96 ----
X */
X
X #include "kernel.h"
+ #include <ggtty.h>
X #include <minix/callnr.h>
X #include <minix/com.h>
X
X #ifdef PORT_DEV
! #define NR_RAMS 6 /* number of RAM-type devices */
! #else
! #define NR_RAMS 5
! #endif
!
!
X PRIVATE message mess; /* message buffer */
X PRIVATE phys_bytes ram_origin[NR_RAMS]; /* origin of each RAM disk */
X PRIVATE phys_bytes ram_limit[NR_RAMS]; /* limit of RAM disk per minor dev. */
X
+ PRIVATE int in_graphics = FALSE;
+ PRIVATE spectrum vir_colour = 7; /* Virtual stuff */
+ PRIVATE coord vir_x = 0;
+ PRIVATE coord vir_y = 0;
+
X FORWARD int do_mem();
X FORWARD int do_setup();
X
X /*===========================================================================*
+ * replace *
+ *===========================================================================*/
+ PRIVATE void replace(from, to)
+ int from; /* vector to get replacement from */
+ int to; /* vector to replace */
+ {
+ /* Replace the vector 'to' in the interrupt table with its original BIOS
+ * vector 'from' in vec_table (they differ since the 8259 was reprogrammed).
+ * On the first call only, also restore all software interrupt vectors from
+ * vec_table except the trap vectors and SYS_VECTOR.
+ * (Doing it only on the first call is redundant, since this is only called
+ * once! We ought to swap our vectors back just before bios_wini replies.
+ * Then this routine should be made more efficient.)
+ */
+
+ phys_bytes phys_b;
+ static int repl_called = FALSE; /* set on first call of replace */
+ int vec;
+
+ phys_b = umap(proc_ptr, D, (vir_bytes) vec_table, VECTOR_BYTES);
+ if (!repl_called) {
+ for (vec = 16; vec < VECTOR_BYTES / 4; ++vec)
+ if (vec != SYS_VECTOR &&
+ !(vec >= IRQ0_VECTOR && vec < IRQ0_VECTOR + 8) &&
+ !(vec >= IRQ8_VECTOR && vec < IRQ8_VECTOR + 8))
+ phys_copy(phys_b + 4L * vec, 4L * vec, 4L);
+ repl_called = TRUE;
+ }
+ lock();
+ phys_copy(phys_b + 4L * from, 4L * to, 4L);
+ unlock();
+ }
+
+ /*===========================================================================*
X * mem_task *
X *===========================================================================*/
X PUBLIC void mem_task()
***************
*** 60,65 ****
--- 109,118 ----
X else
X ram_limit[MEM_DEV] = 0x1000000; /* above 16M not mapped on 386 */
X ram_limit[PORT_DEV] = 0x10000;
+
+ /* Set up for graphics device map */
+ ram_origin[GRAFX_DEV] = G_BASE;
+ ram_limit[GRAFX_DEV] = ((phys_bytes) 0x100000) + ram_origin[GRAFX_DEV];
X #else
X #if (CHIP == M68000)
X ram_limit[MEM_DEV] = MEM_BYTES;
***************
*** 68,73 ****
--- 121,130 ----
X #endif
X #endif
X
+ /* set up int 010 */
+ if (pc_at)
+ replace( (DISPLAY_IRQ & 0x07) + BIOS_IRQ8_VEC, DISPLAY_VECTOR);
+
X /* Here is the main loop of the memory task. It waits for a message, carries
X * it out, and sends a reply.
X */
***************
*** 88,98 ****
X default: r = EINVAL; break;
X }
X
! /* Finally, prepare and send the reply message. */
! mess.m_type = TASK_REPLY;
! mess.REP_PROC_NR = proc_nr;
! mess.REP_STATUS = r;
! send(caller, &mess);
X }
X }
X
--- 145,157 ----
X default: r = EINVAL; break;
X }
X
! if (mess.DEVICE != GRAFX_DEV) {
! /* Finally, prepare and send the reply message. */
! mess.m_type = TASK_REPLY;
! mess.REP_PROC_NR = proc_nr;
! mess.REP_STATUS = r;
! send(caller, &mess);
! }
X }
X }
X
***************
*** 103,109 ****
X PRIVATE int do_mem(m_ptr)
X register message *m_ptr; /* pointer to read or write message */
X {
! /* Read or write /dev/null, /dev/mem, /dev/kmem, /dev/ram or /dev/port. */
X
X int device, count, endport, port, portval;
X phys_bytes mem_phys, user_phys;
--- 162,169 ----
X PRIVATE int do_mem(m_ptr)
X register message *m_ptr; /* pointer to read or write message */
X {
! /* Read or write
! /dev/null, /dev/mem, /dev/kmem, /dev/ram, /dev/port and /dev/grafx. */
X
X int device, count, endport, port, portval;
X phys_bytes mem_phys, user_phys;
***************
*** 151,156 ****
--- 211,329 ----
X return(count);
X }
X
+ PRIVATE void swap(a,b)
+ int *a,*b;
+ {
+ int i;
+ i = *b;
+ *b = *a;
+ *a = i;
+ }
+
+ PRIVATE void putpixel(x,y)
+ coord x,y;
+ {
+ Ax = 0x0C00 + (spectrum) vir_colour;
+ Bx = 0;
+ Cx = x;
+ Dx = y;
+ bios10();
+ }
+
+ PRIVATE void bres_x(xa,ya,xb,dx,dy,change)
+ int xa,ya,xb,dx,dy;
+ char change;
+ {
+ int x;
+ int y = ya;
+ int e_noinc = dy + dy;
+ int e = e_noinc - dx;
+ int e_inc = e - dx;
+
+ for (x = xa; x <= xb; x++) {
+ putpixel(x,y);
+ if (e < 0)
+ e += e_noinc;
+ else {
+ y += change;
+ e += e_inc;
+ }
+ }
+ return;
+ }
+
+ bres_y(xa,ya,yb,dx,dy,change)
+ int xa,ya,yb,dx,dy;
+ char change;
+ {
+ int x = xa;
+ int y;
+ int e_noinc = dx + dx;
+ int e = e_noinc - dy;
+ int e_inc = e - dy;
+
+ for (y = ya; y <= yb; y++) {
+ putpixel(x,y);
+ if (e < 0)
+ e += e_noinc;
+ else {
+ x += change;
+ e += e_inc;
+ }
+ }
+ return;
+ }
+
+
+ PRIVATE void myline(x1, y1, x2, y2)
+ int x1,y1,x2,y2;
+ {
+ int i;
+ int dx;
+ int dy;
+
+ /* swap values so we go from low to high */
+ if (x1 > x2) {
+ swap(&x1,&x2);
+ swap(&y1,&y2);
+ }
+
+ dy = y2 - y1;
+ dx = x2 - x1;
+
+ /* Cater for tricky situations */
+ if (dx == 0) {
+ if (y1 > y2)
+ swap(&y2,&y1);
+ for (i = y1; i <= y2; i++) /* vertical line */
+ putpixel(x1,i);
+ return;
+ }
+ else if (dy == 0) {
+ for (i = x1; i <= x2; i++) /* horizontal line */
+ putpixel(i,y1);
+ return;
+ }
+ else if (dy > 0 ) {
+ if ((dy/dx) < 1)
+ bres_x(x1,y1,x2,dx,dy,1);
+ else
+ bres_y(x1,y1,y2,dx,dy,1);
+ }
+ else {
+ if ((dy/dx) > -1)
+ bres_x(x1,y1,x2,dx,-dy,-1);
+ else {
+ swap(&x1,&x2);
+ swap(&y1,&y2);
+ dx = x2 - x1;
+ dy = y2 - y1;
+ bres_y(x1,y1,y2,-dx,dy,-1);
+ }
+ }
+ return;
+ }
+
X
X /*===========================================================================*
X * do_setup *
***************
*** 161,170 ****
X /* Set parameters for one of the disk RAMs. */
X
X int device;
!
! device = m_ptr->DEVICE;
! if (device != RAM_DEV) return(ENXIO); /* bad minor device */
! ram_origin[device] = m_ptr->POSITION;
! ram_limit[device] = m_ptr->POSITION + (long) m_ptr->COUNT * BLOCK_SIZE;
! return(OK);
! }
--- 334,428 ----
X /* Set parameters for one of the disk RAMs. */
X
X int device;
! long flags, erki;
! int r;
! int speed;
! message ioctl_mess;
!
! device = m_ptr->DEVICE;
!
! switch(device) {
! case GRAFX_DEV: {
! switch (m_ptr->TTY_REQUEST) {
! case GIOCENTER: {
! Ax = G_MODE;
! bios10();
! in_graphics = TRUE;
! break;
! }
! case GIOCRETURN: {
! if (in_graphics) {
! Ax = TEXT_MODE;
! bios10();
! in_graphics = FALSE;
! }
! break;
! }
! case GIOCTEST: {
! int i;
!
! for (i = 0; i < G_COLOURS; i++) {
! Ax = 0x0e00 + '*';
! Bx = i;
! bios10();
! }
! myline(0,0,G_MAX_X,G_MAX_Y);
! break;
! }
! case GIOCPLOT:
! vir_x = (m_ptr->TTY_SPEK >> 16);
! vir_y = ((m_ptr->TTY_SPEK << 16)>> 16);
! putpixel(vir_x,vir_y);
! break;
! case GIOCCOLOUR:
! vir_colour = (m_ptr->TTY_SPEK >> 24) & BYTE;
! break;
!
! case GIOCTEXT:
! Ax = 0x0e00 + ((m_ptr->TTY_SPEK >> 24) & BYTE);
! Bx = vir_colour;
! bios10();
! break;
! case GIOCMOVE:
! /* Set virtual x and y */
! vir_x = (m_ptr->TTY_SPEK >> 16);
! vir_y = (m_ptr->TTY_SPEK >> 0) & 0xffff;
! /* Now set text cursor, for printing text (really!) */
! Ax = 0x0200;
! Bx = 0;
! Dx = ((vir_y / G_CY_DIV) << 8) + (vir_x / G_CX_DIV);
! bios10();
! break;
!
! case GIOCLINE: {
! coord x1 = (m_ptr->TTY_SPEK >>16);
! coord y1 = ((m_ptr->TTY_SPEK <<16) >> 16);
! coord x2 = (m_ptr->TTY_FLAGS >>16);
! coord y2 = ((m_ptr->TTY_FLAGS <<16) >> 16);
! myline(x1,y1,x2,y2);
! break;
! }
! }
!
! ioctl_mess.m_type = TASK_REPLY;
! ioctl_mess.REP_PROC_NR = m_ptr->PROC_NR;
! ioctl_mess.REP_STATUS = r;
! ioctl_mess.TTY_FLAGS = flags;
! ioctl_mess.TTY_SPEK = erki;
!
! send(m_ptr->m_source, &ioctl_mess);
!
! break;
! }
!
! case RAM_DEV: {
! ram_origin[device] = m_ptr->POSITION;
! ram_limit[device] = m_ptr->POSITION + (long) m_ptr->COUNT * BLOCK_SIZE;
! break;
! }
! default:
! return(ENXIO); /* bad minor device */
! }
! return(OK);
! }
!
SHAR_EOF
chmod 0600 grafx10/kernel/memory.c.cdiff ||
echo 'restore of grafx10/kernel/memory.c.cdiff failed'
Wc_c="`wc -c < 'grafx10/kernel/memory.c.cdiff'`"
test 9759 -eq "$Wc_c" ||
echo 'grafx10/kernel/memory.c.cdiff: original size 9759, current size' "$Wc_c"
fi
# ============= grafx10/kernel/wini.c.cdiff ==============
if test -f 'grafx10/kernel/wini.c.cdiff' -a X"$1" != X"-c"; then
echo 'x - skipping grafx10/kernel/wini.c.cdiff (File already exists)'
else
echo 'x - extracting grafx10/kernel/wini.c.cdiff (Text)'
sed 's/^X//' << 'SHAR_EOF' > 'grafx10/kernel/wini.c.cdiff' &&
*** /usr/src/kernel/wini.c Mon Aug 5 13:52:48 1991
--- wini.c Fri Aug 9 13:27:45 1991
***************
*** 120,126 ****
X vir_bytes wn_address; /* user virtual address */
X } wini[NR_DEVICES];
X
! PUBLIC int using_bios = FALSE; /* this disk driver does not use the BIOS */
X
X PRIVATE int w_need_reset = FALSE; /* set to 1 when controller must be reset */
X PRIVATE int nr_drives; /* Number of drives */
--- 120,127 ----
X vir_bytes wn_address; /* user virtual address */
X } wini[NR_DEVICES];
X
! PUBLIC int using_bios = TRUE; /* this disk driver does not use the BIOS */
! /* BUT the /dev/grafx DOES!!!!*/
X
X PRIVATE int w_need_reset = FALSE; /* set to 1 when controller must be reset */
X PRIVATE int nr_drives; /* Number of drives */
SHAR_EOF
chmod 0600 grafx10/kernel/wini.c.cdiff ||
echo 'restore of grafx10/kernel/wini.c.cdiff failed'
Wc_c="`wc -c < 'grafx10/kernel/wini.c.cdiff'`"
test 760 -eq "$Wc_c" ||
echo 'grafx10/kernel/wini.c.cdiff: original size 760, current size' "$Wc_c"
fi
# ============= grafx10/kernel/const.h.cdiff ==============
if test -f 'grafx10/kernel/const.h.cdiff' -a X"$1" != X"-c"; then
echo 'x - skipping grafx10/kernel/const.h.cdiff (File already exists)'
else
echo 'x - extracting grafx10/kernel/const.h.cdiff (Text)'
sed 's/^X//' << 'SHAR_EOF' > 'grafx10/kernel/const.h.cdiff' &&
*** /usr/src/kernel/const.h Mon Jun 17 11:41:07 1991
--- const.h Mon Aug 26 14:26:39 1991
***************
*** 67,72 ****
--- 67,73 ----
X #define PRINTER_IRQ 7
X #define AT_WINI_IRQ 14 /* at winchester */
X #define PS_KEYB_IRQ 9 /* keyboard interrupt vector for PS/2 */
+ #define DISPLAY_IRQ 16 /* display interrupt vector */
X
X /* Hardware vector numbers. */
X #define CLOCK_VECTOR ((CLOCK_IRQ & 0x07) + IRQ0_VECTOR)
***************
*** 79,84 ****
--- 80,86 ----
X #define PRINTER_VECTOR ((PRINTER_IRQ & 0x07) + IRQ0_VECTOR)
X #define AT_WINI_VECTOR ((AT_WINI_IRQ & 0x07) + IRQ8_VECTOR)
X #define PS_KEYB_VECTOR ((PS_KEYB_IRQ & 0x07) + IRQ8_VECTOR)
+ #define DISPLAY_VECTOR ((DISPLAY_IRQ & 0x07) + IRQ8_VECTOR)
X
X /* BIOS parameter vectors. */
X #define WINI_0_PARM_VEC 0x41
SHAR_EOF
chmod 0600 grafx10/kernel/const.h.cdiff ||
echo 'restore of grafx10/kernel/const.h.cdiff failed'
Wc_c="`wc -c < 'grafx10/kernel/const.h.cdiff'`"
test 818 -eq "$Wc_c" ||
echo 'grafx10/kernel/const.h.cdiff: original size 818, current size' "$Wc_c"
fi
# ============= grafx10/kernel/klib88.x.cdiff ==============
if test -f 'grafx10/kernel/klib88.x.cdiff' -a X"$1" != X"-c"; then
echo 'x - skipping grafx10/kernel/klib88.x.cdiff (File already exists)'
else
echo 'x - extracting grafx10/kernel/klib88.x.cdiff (Text)'
sed 's/^X//' << 'SHAR_EOF' > 'grafx10/kernel/klib88.x.cdiff' &&
*** /usr/src/kernel/klib88.x Mon Jun 17 11:41:09 1991
--- klib88.x Fri Aug 9 12:44:53 1991
***************
*** 1,6 ****
--- 1,7 ----
X | This file contains a number of assembly code utility routines needed by the
X | kernel. They are:
X
+ .define _bios10 | make BIOS 10 call for display (real mode only)
X .define _bios13 | make BIOS 13 call for disk I/O (real mode only)
X .define _build_sig | build 4 word structure pushed onto stack for signals
X .define _check_mem | check a block of memory, return the valid size
***************
*** 78,88 ****
X
X .text
X |*===========================================================================*
! |* bios13 *
! |*===========================================================================*
! | PUBLIC void bios13();
!
! _bios13: | make a BIOS 0x13 call for disk I/O
X push ax | save the registers
X push bx
X push cx
--- 79,89 ----
X
X .text
X |*===========================================================================*
! |* bios10 *
! |*===========================================================================*
! | PUBLIC void bios10();
!
! _bios10: | make a BIOS 0x10 call for display
X push ax | save the registers
X push bx
X push cx
***************
*** 93,99 ****
X mov cx,_Cx
X mov dx,_Dx
X mov es,_Es
! int 0x13 | make the BIOS call
X mov _Ax,ax | save results
X mov _Bx,bx
X mov _Cx,cx
--- 94,100 ----
X mov cx,_Cx
X mov dx,_Dx
X mov es,_Es
! int 0x10 | make the BIOS call
X mov _Ax,ax | save results
X mov _Bx,bx
X mov _Cx,cx
***************
*** 105,110 ****
--- 106,139 ----
X pop ax
X ret
X
+ |*===========================================================================*
+ |* bios13 *
+ |*===========================================================================*
+ | PUBLIC void bios13();
+
+ _bios13: | make a BIOS 0x13 call for disk I/O
+ push ax | save the registers
+ push bx
+ push cx
+ push dx
+ push es
+ mov ax,_Ax | load parameters
+ mov bx,_Bx
+ mov cx,_Cx
+ mov dx,_Dx
+ mov es,_Es
+ int 0x13 | make the BIOS call
+ mov _Ax,ax | save results
+ mov _Bx,bx
+ mov _Cx,cx
+ mov _Dx,dx
+ pop es
+ pop dx
+ pop cx
+ pop bx
+ pop ax
+ ret
+
X
X |*===========================================================================*
X |* build_sig *
SHAR_EOF
chmod 0600 grafx10/kernel/klib88.x.cdiff ||
echo 'restore of grafx10/kernel/klib88.x.cdiff failed'
Wc_c="`wc -c < 'grafx10/kernel/klib88.x.cdiff'`"
test 2335 -eq "$Wc_c" ||
echo 'grafx10/kernel/klib88.x.cdiff: original size 2335, current size' "$Wc_c"
fi
# ============= grafx10/lib/ioctl.c.cdiff ==============
if test ! -d 'grafx10/lib'; then
echo 'x - creating directory grafx10/lib'
mkdir 'grafx10/lib'
fi
if test -f 'grafx10/lib/ioctl.c.cdiff' -a X"$1" != X"-c"; then
echo 'x - skipping grafx10/lib/ioctl.c.cdiff (File already exists)'
else
echo 'x - extracting grafx10/lib/ioctl.c.cdiff (Text)'
sed 's/^X//' << 'SHAR_EOF' > 'grafx10/lib/ioctl.c.cdiff' &&
*** ioctl.cc Wed Sep 11 16:09:15 1991
--- ioctl.c Wed Sep 25 15:19:52 1991
***************
*** 1,21 ****
X #include <lib.h>
X #include <minix/com.h>
X #include <sgtty.h>
!
! PUBLIC int ioctl(fd, request, argp)
! int fd;
! int request;
! struct sgttyb *argp;
X {
X int n;
X long erase, kill, intr, quit, xon, xoff, eof, brk, speed;
X struct tchars *argt;
X
X _M.TTY_REQUEST = request;
X _M.TTY_LINE = fd;
X
X switch(request) {
X case TIOCSETP:
X erase = argp->sg_erase & BYTE;
X kill = argp->sg_kill & BYTE;
X speed = ((argp->sg_ospeed & BYTE) << 8) | (argp->sg_ispeed & BYTE);
--- 1,26 ----
X #include <lib.h>
X #include <minix/com.h>
X #include <sgtty.h>
! #include <ggtty.h>
!
! PUBLIC int ioctl(fd, request, argm)
! int fd;
! int request;
! char *argm;
!
X {
X int n;
X long erase, kill, intr, quit, xon, xoff, eof, brk, speed;
X struct tchars *argt;
+ struct sgttyb *argp;
+ gmess *argg;
X
X _M.TTY_REQUEST = request;
X _M.TTY_LINE = fd;
X
X switch(request) {
X case TIOCSETP:
+ argp = (struct sgttyb * /* kludge */) argm;
X erase = argp->sg_erase & BYTE;
X kill = argp->sg_kill & BYTE;
X speed = ((argp->sg_ospeed & BYTE) << 8) | (argp->sg_ispeed & BYTE);
***************
*** 25,31 ****
X return(n);
X
X case TIOCSETC:
! argt = (struct tchars * /* kludge */) argp;
X intr = argt->t_intrc & BYTE;
X quit = argt->t_quitc & BYTE;
X xon = argt->t_startc & BYTE;
--- 30,36 ----
X return(n);
X
X case TIOCSETC:
! argt = (struct tchars * /* kludge */) argm;
X intr = argt->t_intrc & BYTE;
X quit = argt->t_quitc & BYTE;
X xon = argt->t_startc & BYTE;
***************
*** 39,44 ****
--- 44,50 ----
X
X case TIOCGETP:
X n = callx(FS, IOCTL);
+ argp = (struct sgttyb * /* kludge */) argm;
X argp->sg_erase = (_M.TTY_SPEK >> 8) & BYTE;
X argp->sg_kill = (_M.TTY_SPEK >> 0) & BYTE;
X argp->sg_flags = _M.TTY_FLAGS & 0xFFFFL;
***************
*** 49,55 ****
X
X case TIOCGETC:
X n = callx(FS, IOCTL);
! argt = (struct tchars *) argp;
X argt->t_intrc = (_M.TTY_SPEK >> 24) & BYTE;
X argt->t_quitc = (_M.TTY_SPEK >> 16) & BYTE;
X argt->t_startc = (_M.TTY_SPEK >> 8) & BYTE;
--- 55,61 ----
X
X case TIOCGETC:
X n = callx(FS, IOCTL);
! argt = (struct tchars *) argm;
X argt->t_intrc = (_M.TTY_SPEK >> 24) & BYTE;
X argt->t_quitc = (_M.TTY_SPEK >> 16) & BYTE;
X argt->t_startc = (_M.TTY_SPEK >> 8) & BYTE;
***************
*** 63,74 ****
X */
X
X case TIOCFLUSH:
! _M.TTY_FLAGS = (int /* kludge */) argp;
X return callx(FS, IOCTL);
X
X default:
! n = -1;
! errno = -(EINVAL);
X return(n);
X }
X }
--- 69,94 ----
X */
X
X case TIOCFLUSH:
! _M.TTY_FLAGS = (int /* kludge */) argm;
X return callx(FS, IOCTL);
X
X default:
! /* Patched by Dave Gardiner, to allow more fn calls to ioctl */
! /* passes arguments like they almost should */
!
! argg = (gmess *) argm;
!
! _M.TTY_SPEK = (argg->GRAFX_SPEK);
! _M.TTY_FLAGS = (argg->GRAFX_FLAGS);
! _M.ADDRESS = (argg->GRAFX_ADDRESS);
! /*
! printf("SPEK %lx\n",argg->GRAFX_SPEK);
! printf("FLAG %lx\n",argg->GRAFX_FLAGS);
! printf("ADDR %lx\n",argg->GRAFX_ADDRESS);
! printf("s %s\n",argg->GRAFX_ADDRESS);
! */
! n = callx(FS, IOCTL);
!
X return(n);
X }
X }
SHAR_EOF
chmod 0600 grafx10/lib/ioctl.c.cdiff ||
echo 'restore of grafx10/lib/ioctl.c.cdiff failed'
Wc_c="`wc -c < 'grafx10/lib/ioctl.c.cdiff'`"
test 3302 -eq "$Wc_c" ||
echo 'grafx10/lib/ioctl.c.cdiff: original size 3302, current size' "$Wc_c"
fi
# ============= grafx10/libplot/Makefile ==============
if test ! -d 'grafx10/libplot'; then
echo 'x - creating directory grafx10/libplot'
mkdir 'grafx10/libplot'
fi
if test -f 'grafx10/libplot/Makefile' -a X"$1" != X"-c"; then
echo 'x - skipping grafx10/libplot/Makefile (File already exists)'
else
echo 'x - extracting grafx10/libplot/Makefile (Text)'
sed 's/^X//' << 'SHAR_EOF' > 'grafx10/libplot/Makefile' &&
# Makefile for libplot
# by David Gardiner
#
# Takes parameter of object file - file to make
#
# examples:
# make libplotibm.a - Make ibm library
# make libplot.a - Make independent library
X
CFLAGS = -c -LIB -F
LIBOBJS = openpl.s closepl.s line.s move.s point.s label.s cont.s erase.s \
X space.s arc.s colour.s linemod.s circle.s
X
libplotibm.a:
X $(MAKE) tmp.a DFLAGS=
X mv tmp.a libplotibm.a
X
libplot.a:
X $(MAKE) tmp.a DFLAGS=-DINDEP
X mv tmp.a libplot.a
X
tmp.a: $(LIBOBJS)
X ar cr tmp.a $(LIBOBJS)
X
.c.s:
X # If L is null, then we generate a device-independant library
X cc $(CFLAGS) $(DFLAGS) $(*).c
X
clean:
X @rm -r *.s
X
#End of makefile
SHAR_EOF
chmod 0600 grafx10/libplot/Makefile ||
echo 'restore of grafx10/libplot/Makefile failed'
Wc_c="`wc -c < 'grafx10/libplot/Makefile'`"
test 644 -eq "$Wc_c" ||
echo 'grafx10/libplot/Makefile: original size 644, current size' "$Wc_c"
fi
# ============= grafx10/libplot/arc.c ==============
if test -f 'grafx10/libplot/arc.c' -a X"$1" != X"-c"; then
echo 'x - skipping grafx10/libplot/arc.c (File already exists)'
else
echo 'x - extracting grafx10/libplot/arc.c (Text)'
sed 's/^X//' << 'SHAR_EOF' > 'grafx10/libplot/arc.c' &&
/* plot(3X) library function */
/* By David Gardiner */
/* University of South Australia, Levels Campus */
X
/* Draw an arc, centre (x,y), start (x0,y0), end (x1,y1), anti-clockwise*/
X
#include "libplot.h"
X
void arc(x,y,x0,y0,x1,y1)
coord x,y,x0,y0,x1,y1;
{
#ifdef INDEP
X
X static struct {
X int a,b,c,d,e,f;
X } s;
X
X s.a = x;
X s.b = y;
X s.c = x0;
X s.d = y0;
X s.e = x1;
X s.f = y1;
X
X (void) printf("a");
X (void) fwrite(&s, sizeof(s), 1, stdout);
#else
X
#endif
}
X
SHAR_EOF
chmod 0600 grafx10/libplot/arc.c ||
echo 'restore of grafx10/libplot/arc.c failed'
Wc_c="`wc -c < 'grafx10/libplot/arc.c'`"
test 606 -eq "$Wc_c" ||
echo 'grafx10/libplot/arc.c: original size 606, current size' "$Wc_c"
fi
# ============= grafx10/libplot/closepl.c ==============
if test -f 'grafx10/libplot/closepl.c' -a X"$1" != X"-c"; then
echo 'x - skipping grafx10/libplot/closepl.c (File already exists)'
else
echo 'x - extracting grafx10/libplot/closepl.c (Text)'
sed 's/^X//' << 'SHAR_EOF' > 'grafx10/libplot/closepl.c' &&
/* plot(3X) library function */
/* By David Gardiner */
/* University of South Australia, Levels Campus */
X
/* Close graphics device */
X
#include "libplot.h"
X
void closepl()
{
#ifdef INDEP
X
#else
X
X ioctl(_plot_fd,GIOCRETURN,_plot_args);
X close(_plot_fd);
X
#endif
}
SHAR_EOF
chmod 0600 grafx10/libplot/closepl.c ||
echo 'restore of grafx10/libplot/closepl.c failed'
Wc_c="`wc -c < 'grafx10/libplot/closepl.c'`"
test 389 -eq "$Wc_c" ||
echo 'grafx10/libplot/closepl.c: original size 389, current size' "$Wc_c"
fi
# ============= grafx10/libplot/colour.c ==============
if test -f 'grafx10/libplot/colour.c' -a X"$1" != X"-c"; then
echo 'x - skipping grafx10/libplot/colour.c (File already exists)'
else
echo 'x - extracting grafx10/libplot/colour.c (Text)'
sed 's/^X//' << 'SHAR_EOF' > 'grafx10/libplot/colour.c' &&
/* plot(3X) library function */
/* By David Gardiner */
/* University of South Australia, Levels Campus */
X
/* Set the current drawing colour to (c) */
X
#include "libplot.h"
X
void colour(c)
spectrum c;
{
#ifdef INDEP
X
X (void) printf("k");
X (void) fwrite(&c, sizeof(c), 1, stdout);
X
#else
X
X _plot_args->GRAFX_COLOUR = c;
X ioctl(_plot_fd,GIOCCOLOUR, _plot_args);
X
#endif
}
SHAR_EOF
chmod 0600 grafx10/libplot/colour.c ||
echo 'restore of grafx10/libplot/colour.c failed'
Wc_c="`wc -c < 'grafx10/libplot/colour.c'`"
test 501 -eq "$Wc_c" ||
echo 'grafx10/libplot/colour.c: original size 501, current size' "$Wc_c"
fi
# ============= grafx10/libplot/cont.c ==============
if test -f 'grafx10/libplot/cont.c' -a X"$1" != X"-c"; then
echo 'x - skipping grafx10/libplot/cont.c (File already exists)'
else
echo 'x - extracting grafx10/libplot/cont.c (Text)'
sed 's/^X//' << 'SHAR_EOF' > 'grafx10/libplot/cont.c' &&
/* plot(3X) library function */
/* By David Gardiner */
/* University of South Australia, Levels Campus */
X
/* Draw a line from the current position, to (x,y).
X Update current position
*/
X
#include "libplot.h"
X
void cont(x,y)
coord x,y;
{
#ifdef INDEP
X
X static struct {
X int a,b;
X } s;
X
X s.a = x;
X s.b = y;
X
X (void) printf("n");
X (void) fwrite(&s, sizeof(s), 1, stdout);
X
#else
X
X _plot_args->GRAFX_X = x;
X _plot_args->GRAFX_Y = y;
X ioctl(_plot_fd, GIOCCONT, _plot_args);
X
#endif
}
X
SHAR_EOF
chmod 0600 grafx10/libplot/cont.c ||
echo 'restore of grafx10/libplot/cont.c failed'
Wc_c="`wc -c < 'grafx10/libplot/cont.c'`"
test 636 -eq "$Wc_c" ||
echo 'grafx10/libplot/cont.c: original size 636, current size' "$Wc_c"
fi
# ============= grafx10/libplot/erase.c ==============
if test -f 'grafx10/libplot/erase.c' -a X"$1" != X"-c"; then
echo 'x - skipping grafx10/libplot/erase.c (File already exists)'
else
echo 'x - extracting grafx10/libplot/erase.c (Text)'
sed 's/^X//' << 'SHAR_EOF' > 'grafx10/libplot/erase.c' &&
/* plot(3X) library function */
/* By David Gardiner */
/* University of South Australia, Levels Campus */
X
/* Erase the display */
X
#include "libplot.h"
X
void erase()
{
#ifdef INDEP
X
X printf("e");
X
#else
X
X /* Rely on BIOS to clear screen when mode is switched */
X ioctl(_plot_fd, GIOCENTER, _plot_args);
X
#endif
}
X
SHAR_EOF
chmod 0600 grafx10/libplot/erase.c ||
echo 'restore of grafx10/libplot/erase.c failed'
Wc_c="`wc -c < 'grafx10/libplot/erase.c'`"
test 443 -eq "$Wc_c" ||
echo 'grafx10/libplot/erase.c: original size 443, current size' "$Wc_c"
fi
# ============= grafx10/libplot/label.c ==============
if test -f 'grafx10/libplot/label.c' -a X"$1" != X"-c"; then
echo 'x - skipping grafx10/libplot/label.c (File already exists)'
else
echo 'x - extracting grafx10/libplot/label.c (Text)'
sed 's/^X//' << 'SHAR_EOF' > 'grafx10/libplot/label.c' &&
/* plot(3X) library function */
/* By David Gardiner */
/* University of South Australia, Levels Campus */
X
/* Write text at the current position */
X
#include "libplot.h"
X
void label(s)
char s[];
{
#ifdef INDEP
X
X (void) printf("t%s\n",s); /* String, with newline at end */
X
#else
X int i;
X for (i = 0; s[i] != 0; i++) {
X _plot_args->GRAFX_CHAR = s[i];
X ioctl(_plot_fd, GIOCTEXT, _plot_args);
X }
#endif
}
SHAR_EOF
chmod 0600 grafx10/libplot/label.c ||
echo 'restore of grafx10/libplot/label.c failed'
Wc_c="`wc -c < 'grafx10/libplot/label.c'`"
test 526 -eq "$Wc_c" ||
echo 'grafx10/libplot/label.c: original size 526, current size' "$Wc_c"
fi
# ============= grafx10/libplot/libplot.h ==============
if test -f 'grafx10/libplot/libplot.h' -a X"$1" != X"-c"; then
echo 'x - skipping grafx10/libplot/libplot.h (File already exists)'
else
echo 'x - extracting grafx10/libplot/libplot.h (Text)'
sed 's/^X//' << 'SHAR_EOF' > 'grafx10/libplot/libplot.h' &&
/* plot(3X) library header */
/* By David Gardiner */
/* University of South Australia, Levels Campus */
X
#ifndef _libplot_h
#define _libplot_h
X
#include <stdio.h>
#include <ggtty.h>
X
extern int _plot_fd;
extern gmess *_plot_args;
X
#endif
SHAR_EOF
chmod 0600 grafx10/libplot/libplot.h ||
echo 'restore of grafx10/libplot/libplot.h failed'
Wc_c="`wc -c < 'grafx10/libplot/libplot.h'`"
test 359 -eq "$Wc_c" ||
echo 'grafx10/libplot/libplot.h: original size 359, current size' "$Wc_c"
fi
# ============= grafx10/libplot/line.c ==============
if test -f 'grafx10/libplot/line.c' -a X"$1" != X"-c"; then
echo 'x - skipping grafx10/libplot/line.c (File already exists)'
else
echo 'x - extracting grafx10/libplot/line.c (Text)'
sed 's/^X//' << 'SHAR_EOF' > 'grafx10/libplot/line.c' &&
/* plot(3X) library function */
/* By David Gardiner */
/* University of South Australia, Levels Campus */
X
/* Draw a line from (x1,y1) to (x2,y2) */
X
#include "libplot.h"
X
void line(x1, y1, x2, y2)
coord x1,y1,x2,y2;
{
#ifdef INDEP
X
X static struct {
X int a,b,c,d;
X } s;
X
X s.a = x1;
X s.b = y1;
X s.c = x2;
X s.d = y2;
X
X printf("l");
X (void) fwrite(&s, sizeof(s), 1, stdout);
X
#else
X
X _plot_args->GRAFX_X = x1;
X _plot_args->GRAFX_Y = y1;
X _plot_args->GRAFX_X2 = x2;
X _plot_args->GRAFX_Y2 = y2;
X ioctl(_plot_fd,GIOCLINE,_plot_args);
X
#endif
}
SHAR_EOF
chmod 0600 grafx10/libplot/line.c ||
echo 'restore of grafx10/libplot/line.c failed'
Wc_c="`wc -c < 'grafx10/libplot/line.c'`"
test 699 -eq "$Wc_c" ||
echo 'grafx10/libplot/line.c: original size 699, current size' "$Wc_c"
fi
# ============= grafx10/libplot/move.c ==============
if test -f 'grafx10/libplot/move.c' -a X"$1" != X"-c"; then
echo 'x - skipping grafx10/libplot/move.c (File already exists)'
else
echo 'x - extracting grafx10/libplot/move.c (Text)'
sed 's/^X//' << 'SHAR_EOF' > 'grafx10/libplot/move.c' &&
/* plot(3X) library function */
/* By David Gardiner */
/* University of South Australia, Levels Campus */
X
/* Move current position to that of (x,y) */
X
#include "libplot.h"
X
void move(x, y)
coord x,y;
{
#ifdef INDEP
X
X static struct {
X int a,b;
X } s;
X
X s.a = x;
X s.b = y;
X
X (void) printf("m");
X (void) fwrite(&s, sizeof(s), 1, stdout);
X
#else
X
X _plot_args->GRAFX_X = x;
X _plot_args->GRAFX_Y = y;
X ioctl(_plot_fd,GIOCMOVE,_plot_args);
X
#endif
}
SHAR_EOF
chmod 0600 grafx10/libplot/move.c ||
echo 'restore of grafx10/libplot/move.c failed'
Wc_c="`wc -c < 'grafx10/libplot/move.c'`"
test 597 -eq "$Wc_c" ||
echo 'grafx10/libplot/move.c: original size 597, current size' "$Wc_c"
fi
# ============= grafx10/libplot/openpl.c ==============
if test -f 'grafx10/libplot/openpl.c' -a X"$1" != X"-c"; then
echo 'x - skipping grafx10/libplot/openpl.c (File already exists)'
else
echo 'x - extracting grafx10/libplot/openpl.c (Text)'
sed 's/^X//' << 'SHAR_EOF' > 'grafx10/libplot/openpl.c' &&
/* plot(3X) library function */
/* By David Gardiner */
/* University of South Australia, Levels Campus */
X
/* Open graphics device */
X
#include "libplot.h"
#include <fcntl.h>
X
/* The only place these are actually defined, elsewhere they are external */
int _plot_fd;
gmess *_plot_args;
X
void openpl()
{
#ifdef INDEP
X
#else
X
X if ((_plot_fd = open("/dev/grafx",O_RDWR)) == -1) {
X fprintf(stderr,"plot error: Could not open graphics device\n");
X exit(1);
X }
X
X _plot_args = (gmess *) malloc(sizeof(gmess));
X ioctl(_plot_fd, GIOCENTER, _plot_args);
X
X /* Set default colour to maximum colour - hopefully white */
X _plot_args->GRAFX_COLOUR = G_COLOURS;
X ioctl(_plot_fd, GIOCCOLOUR, _plot_args);
X
#endif
}
SHAR_EOF
chmod 0600 grafx10/libplot/openpl.c ||
echo 'restore of grafx10/libplot/openpl.c failed'
Wc_c="`wc -c < 'grafx10/libplot/openpl.c'`"
test 839 -eq "$Wc_c" ||
echo 'grafx10/libplot/openpl.c: original size 839, current size' "$Wc_c"
fi
# ============= grafx10/libplot/point.c ==============
if test -f 'grafx10/libplot/point.c' -a X"$1" != X"-c"; then
echo 'x - skipping grafx10/libplot/point.c (File already exists)'
else
echo 'x - extracting grafx10/libplot/point.c (Text)'
sed 's/^X//' << 'SHAR_EOF' > 'grafx10/libplot/point.c' &&
/* plot(3X) library function */
/* By David Gardiner */
/* University of South Australia, Levels Campus */
X
/* Set pixel to current colour at (x,y) */
X
#include "libplot.h"
X
void point(x, y)
coord x,y;
{
#ifdef INDEP
X
X static struct {
X int a,b;
X } s;
X
X s.a = x;
X s.b = y;
X
X (void) printf("p");
X (void) fwrite(&s, sizeof(s), 1, stdout);
X
#else
X
X _plot_args->GRAFX_X = x;
X _plot_args->GRAFX_Y = y;
X ioctl(_plot_fd,GIOCPLOT,_plot_args);
X
#endif
}
SHAR_EOF
chmod 0600 grafx10/libplot/point.c ||
echo 'restore of grafx10/libplot/point.c failed'
Wc_c="`wc -c < 'grafx10/libplot/point.c'`"
test 596 -eq "$Wc_c" ||
echo 'grafx10/libplot/point.c: original size 596, current size' "$Wc_c"
fi
# ============= grafx10/libplot/space.c ==============
if test -f 'grafx10/libplot/space.c' -a X"$1" != X"-c"; then
echo 'x - skipping grafx10/libplot/space.c (File already exists)'
else
echo 'x - extracting grafx10/libplot/space.c (Text)'
sed 's/^X//' << 'SHAR_EOF' > 'grafx10/libplot/space.c' &&
/* plot(3X) library function */
/* By David Gardiner */
/* University of South Australia, Levels Campus */
X
/* Magnify or reduce the rectangle (x0,y0)-(x1,y1) to fit the screen */
X
#include "libplot.h"
X
void space(x0,y0,x1,y1)
coord x0,y0,x1,y1;
{
#ifdef INDEP
X
X static struct {
X int a,b,c,d;
X } s;
X
X s.a = x0;
X s.b = y0;
X s.c = x1;
X s.d = y1;
X
X (void) printf("s");
X (void) fwrite(&s, sizeof(s), 1, stdout);
X
#else
X
#endif
}
X
SHAR_EOF
chmod 0600 grafx10/libplot/space.c ||
echo 'restore of grafx10/libplot/space.c failed'
Wc_c="`wc -c < 'grafx10/libplot/space.c'`"
test 571 -eq "$Wc_c" ||
echo 'grafx10/libplot/space.c: original size 571, current size' "$Wc_c"
fi
# ============= grafx10/libplot/tst_lib.c ==============
if test -f 'grafx10/libplot/tst_lib.c' -a X"$1" != X"-c"; then
echo 'x - skipping grafx10/libplot/tst_lib.c (File already exists)'
else
echo 'x - extracting grafx10/libplot/tst_lib.c (Text)'
sed 's/^X//' << 'SHAR_EOF' > 'grafx10/libplot/tst_lib.c' &&
/* Plot(3X) test 1 */
/* By David Gardiner */
/* University of South Australia, Levels Campus */
X
/* This file must be linked to one of the plot libraries
X
examples:
X
cc tst_lib.c -o tst_lib -lplot -For device independence
cc tst_lib.c -o tst_lib -lplotibm -For use with IBM-PC
X
*/
X
#include <stdio.h>
#include <ggtty.h>
X
void main()
{
X coord x,y;
X int i;
X unsigned seed;
X
X srand(seed);
X
X openpl();
X
X colour(4);
X
X /* Test plotting - draw line */
X for (x = 0; x < G_MAX_X; x++)
X point(x,x);
X
X label("Neato dorito!");
X
X move(10,10);
X cont(150,50);
X
X erase();
X
#ifdef INFINITE
X while (1) {
#else
X for (i = 0; i < 100; i++) {
#endif
X colour(rand(G_COLOURS));
X line(rand(seed) % G_MAX_X, rand(seed) % G_MAX_Y,
X rand(seed) % G_MAX_X, rand(seed) % G_MAX_Y);
X }
X
X move(100,200);
X label("Press <Enter> to exit...");
X closepl();
}
SHAR_EOF
chmod 0600 grafx10/libplot/tst_lib.c ||
echo 'restore of grafx10/libplot/tst_lib.c failed'
Wc_c="`wc -c < 'grafx10/libplot/tst_lib.c'`"
test 955 -eq "$Wc_c" ||
echo 'grafx10/libplot/tst_lib.c: original size 955, current size' "$Wc_c"
fi
# ============= grafx10/libplot/circle.c ==============
if test -f 'grafx10/libplot/circle.c' -a X"$1" != X"-c"; then
echo 'x - skipping grafx10/libplot/circle.c (File already exists)'
else
echo 'x - extracting grafx10/libplot/circle.c (Text)'
sed 's/^X//' << 'SHAR_EOF' > 'grafx10/libplot/circle.c' &&
/* plot(3X) library function */
/* By David Gardiner */
/* University of South Australia, Levels Campus */
X
/* Draw a circle with centre (x,y) and radius r */
X
#include "libplot.h"
X
void circle(x, y, r)
coord x,y,r;
{
#ifdef INDEP
X
X static struct {
X int a,b,c;
X } s;
X
X s.a = x;
X s.b = y;
X s.c = r;
X
X (void) printf("c");
X (void) fwrite(&s, sizeof(s), 1, stdout);
X
#else
X
#endif
}
SHAR_EOF
chmod 0600 grafx10/libplot/circle.c ||
echo 'restore of grafx10/libplot/circle.c failed'
Wc_c="`wc -c < 'grafx10/libplot/circle.c'`"
test 521 -eq "$Wc_c" ||
echo 'grafx10/libplot/circle.c: original size 521, current size' "$Wc_c"
fi
# ============= grafx10/libplot/linemod.c ==============
if test -f 'grafx10/libplot/linemod.c' -a X"$1" != X"-c"; then
echo 'x - skipping grafx10/libplot/linemod.c (File already exists)'
else
echo 'x - extracting grafx10/libplot/linemod.c (Text)'
sed 's/^X//' << 'SHAR_EOF' > 'grafx10/libplot/linemod.c' &&
/* plot(3X) library function */
/* By David Gardiner */
/* University of South Australia, Levels Campus */
X
/* The string (s) contains a text command as to how lines will be displayed.
X (s) can be one of (in lowercase):
X
X dotted
X solid
X longdashed
X shortdashed
X dotdashed
X
*/
X
#include "libplot.h"
X
void linemod(s)
char s[];
{
#ifdef INDEP
X
X printf("%s\n",s); /* string followed by newline */
X
#else
X
#endif
}
X
SHAR_EOF
chmod 0600 grafx10/libplot/linemod.c ||
echo 'restore of grafx10/libplot/linemod.c failed'
Wc_c="`wc -c < 'grafx10/libplot/linemod.c'`"
test 570 -eq "$Wc_c" ||
echo 'grafx10/libplot/linemod.c: original size 570, current size' "$Wc_c"
fi
# ============= grafx10/plot/Makefile ==============
if test ! -d 'grafx10/plot'; then
echo 'x - creating directory grafx10/plot'
mkdir 'grafx10/plot'
fi
if test -f 'grafx10/plot/Makefile' -a X"$1" != X"-c"; then
echo 'x - skipping grafx10/plot/Makefile (File already exists)'
else
echo 'x - extracting grafx10/plot/Makefile (Text)'
sed 's/^X//' << 'SHAR_EOF' > 'grafx10/plot/Makefile' &&
# Makefile for plot(1G)
# by David Gardiner
X
# Set this to the plot library that drives the device for plot(1G)
GLIB = plotibm
X
plot: plot.c
X cc -o plot plot.c -l$(GLIB)
SHAR_EOF
chmod 0600 grafx10/plot/Makefile ||
echo 'restore of grafx10/plot/Makefile failed'
Wc_c="`wc -c < 'grafx10/plot/Makefile'`"
test 171 -eq "$Wc_c" ||
echo 'grafx10/plot/Makefile: original size 171, current size' "$Wc_c"
fi
# ============= grafx10/plot/plot.c ==============
if test -f 'grafx10/plot/plot.c' -a X"$1" != X"-c"; then
echo 'x - skipping grafx10/plot/plot.c (File already exists)'
else
echo 'x - extracting grafx10/plot/plot.c (Text)'
sed 's/^X//' << 'SHAR_EOF' > 'grafx10/plot/plot.c' &&
/* plot(1G) generic source */
/* By David Gardiner */
/* */
/* ma89...@lux.levels.unisa.edu.au */
/* University of South Australia, Levels Campus */
/* */
/* Version 1.0 */
/* History: */
/* 16/10/1991 - Prototyped with Turbo-C++ (C Mode) on MS-DOS */
/* 19/10/1991 - Added comments, colour, and formatting */
/* 5/11/1991 - Ported to Minix */
/* 14/11/1991 - Final fixes */
X
/* Notes:
X This file should be linked with the appropriate graphics library
X to allow it to process plot(5) files for that specific device.
X
X eg. for executable "ibm", link with "/lib/libplotibm.a"
*/
X
#include <stdio.h>
#include <ggtty.h>
X
int result = 0; /* result of execution of program */
int j;
X
int getline(s, lim)
char s[];
int lim;
{
X int c,i;
X for (i=0; i<lim-1 && (c=getchar())!=EOF && c!='\n'; ++i)
X s[i] = c;
X if (c == '\n') {
X s[i] = 0;
X i++;
X }
X if (c == EOF)
X result = 1;
X
X return i;
}
X
X
int main()
{
X int c;
X
X /* Initialise plot device */
X openpl();
X
X /* Process until nothing more to do */
X while ( (result == 0) && (feof(stdin) == 0) ) {
X
X /* Get graphics code */
X if ((c = getchar()) != EOF) {
X
X /* Find what code we got */
X switch (c) {
X
X /* Move */
X case 'm' : {
X struct {
X int x,y;
X } s;
X
X (void) fread(&s,sizeof(s),1,stdin);
X move(s.x,s.y);
X break;
X }
X
X /* Cont */
X case 'n' : {
X struct {
X int x,y;
X } s;
X
X (void) fread(&s,sizeof(s),1,stdin);
X cont(s.x,s.y);
X break;
X }
X
X /* Point */
X case 'p' : {
X
X struct {
X int px,py;
X } s;
X
X j = fread(&s,sizeof(s),1,stdin);
X
X point(s.px,s.py);
X break;
X }
X
X /* Line */
X case 'l' : {
X
X struct {
X int xt,yt,xb,yb;
X } s;
X
X (void) fread(&s,sizeof(s),1,stdin);
X line(s.xt,s.yt,s.xb,s.yb);
X break;
X }
X
X /* Label */
X case 't' : {
X char s[255];
X char *t;
X int i;
X
X i = getline(s, sizeof(s));
X t = (char *) malloc(i);
X t = s;
X
X label(t);
X
X break;
X }
X
X /* Arc */
X case 'a' : {
X
X struct {
X int x,y,x0,y0,x1,y1;
X } s;
X
X (void) fread(&s,sizeof(s),1,stdin);
X arc(s.x, s.y, s.x0, s.y0, s.x1, s.y1);
X break;
X }
X
X /* Circle */
X case 'c' : {
X
X struct {
X int x,y,r;
X } s;
X
X (void) fread(&s,sizeof(s),1,stdin);
X circle(s.x,s.y,s.r);
X break;
X }
X
X /* Erase */
X case 'e' :
X
X erase();
X break;
X
X /* Linemod */
X case 'f' : {
X char *s;
X
X if (scanf("%s\n",s) != EOF)
X linemod(s);
X break;
X }
X
X /* Space */
X case 's' : {
X
X struct {
X int xt,yt,xb,yb;
X } s;
X
X (void) fread(&s,sizeof(s),1,stdin);
X space(s.xt,s.yt,s.xb,s.yb);
X
X break;
X }
X
X /* Colour */
X case 'k' : {
X spectrum shade;
X
X (void) fread(&shade,sizeof(shade),1,stdin);
X colour(shade);
X break;
X }
X
X default:
X result = 2;
X }
X }
X else
X result = 1;
X
X } /* while */
X
X sleep(2);
X
X /* Tell plot device that we are done */
X closepl();
X
X if (result == 2)
X printf("plot: unknown command code %c (%d)\n",c,c);
X
X return (result);
}
X
/* End of plot.c */
SHAR_EOF
chmod 0600 grafx10/plot/plot.c ||
echo 'restore of grafx10/plot/plot.c failed'
Wc_c="`wc -c < 'grafx10/plot/plot.c'`"
test 4167 -eq "$Wc_c" ||
echo 'grafx10/plot/plot.c: original size 4167, current size' "$Wc_c"
fi
true || echo 'restore of grafx10/sysdoc.txt failed'
echo End of part 1, continue with part 2
exit 0
Reply all
Reply to author
Forward
0 new messages