Plan 9 from Bell Labs’s /usr/web/sources/extra/9hist/pc/vgaark2000pv.c

Copyright © 2021 Plan 9 Foundation.
Distributed under the MIT License.
Download the Plan 9 distribution.


## diffname pc/vgaark2000pv.c 1995/0512
## diff -e /dev/null /n/fornaxdump/1995/0512/sys/src/brazil/pc/vgaark2000pv.c
0a
#include "u.h"
#include "../port/lib.h"
#include "mem.h"
#include "dat.h"
#include "fns.h"
#include "../port/error.h"

#include <libg.h>
#include "screen.h"
#include "vga.h"

static void
ark2000pvpage(int page)
{
	vgaxo(Seqx, 0x15, page);
	vgaxo(Seqx, 0x16, page);
}

static Vgac ark2000pv = {
	"ark2000pv",
	ark2000pvpage,

	0,
};

void
vgaark2000pvlink(void)
{
	addvgaclink(&ark2000pv);
}
.
## diffname pc/vgaark2000pv.c 1995/0516
## diff -e /n/fornaxdump/1995/0512/sys/src/brazil/pc/vgaark2000pv.c /n/fornaxdump/1995/0516/sys/src/brazil/pc/vgaark2000pv.c
29a
	addhwgclink(&ark2000pvhwgc);
.
18a
static void
disable(void)
{
	uchar seq20;

	seq20 = vgaxi(Seqx, 0x20) & ~0x08;
	vgaxo(Seqx, 0x20, seq20);
}

static void
enable(void)
{
	uchar seq20;

	/*
	 * Disable the cursor then configure for X-Windows style,
	 * 64x64 and 4/8-bit colour depth.
	 * Set cursor colours for 4/8-bit.
	 */
	seq20 = vgaxi(Seqx, 0x20) & ~0x1F;
	vgaxo(Seqx, 0x20, seq20);
	seq20 |= 0x1C;

	vgaxo(Seqx, 0x26, Pwhite);
	vgaxo(Seqx, 0x27, Pwhite);
	vgaxo(Seqx, 0x28, Pwhite);
	vgaxo(Seqx, 0x29, Pblack);
	vgaxo(Seqx, 0x2A, Pblack);
	vgaxo(Seqx, 0x2B, Pblack);

	/*
	 * Cursor storage is a 1Kb block located in the last 16Kb
	 * of video memory. Crt25 is the index of which 1Kb block.
	 */
	storage = (vgaxi(Seqx, 0x10)>>6) & 0x03;
	storage = (1024*1024)<<storage;
	storage -= 1024;
	vgaxo(Seqx, 0x25, 0x3C);

	/*
	 * Enable the cursor.
	 */
	vgaxo(Seqx, 0x20, seq20);
}

static void
load(Cursor *c)
{
	uchar *p, seq20;
	int x, y;

	/*
	 * Lock the display memory so we can update the
	 * cursor bitmap if necessary.
	 * If it's the same as the last cursor we loaded,
	 * just make sure it's enabled.
	 */
	seq20 = vgaxi(Seqx, 0x20);
	lock(&ark2000pvlock);
	if(memcmp(c, &curcursor, sizeof(Cursor)) == 0){
		vgaxo(Seqx, 0x20, 0x80|seq20);
		unlock(&ark2000pvlock);
		return;
	}
	memmove(&curcursor, c, sizeof(Cursor));

	/*
	 * Is linear addressing turned on? This will determine
	 * how we access the cursor storage.
	 */
	if(vgaxi(Seqx, 0x10) & 0x10)
		p = ((uchar*)gscreen.base) + storage;
	else {
		setark2000pvpage(storage>>16);
		p = ((uchar*)gscreen.base) + (storage & 0xFFFF);
	}

	/*
	 * The cursor is set in X11 mode which gives the following
	 * truth table:
	 *	and xor	colour
	 *	 0   0	underlying pixel colour
	 *	 0   1	underlying pixel colour
	 *	 1   0	background colour
	 *	 1   1	foreground colour
	 * Put the cursor into the top-left of the 64x64 array.
	 * The manual doesn't say what the data layout in memory is -
	 * this worked out by trial and error.
	 */
	for(y = 0; y < 64; y++){
		for(x = 0; x < 64/8; x++){
			if(x < 16/8 && y < 16){
				*p++ = c->clr[2*y + x]|c->set[2*y + x];
				*p++ = c->set[2*y + x];
			}
			else {
				*p++ = 0x00;
				*p++ = 0x00;
			}
		}
	}

	/*
	 * Set the cursor hotpoint and enable the cursor.
	 */
	hotpoint = c->offset;
	vgaxo(Seqx, 0x20, 0x80|seq20);

	unlock(&ark2000pvlock);
}

static int
move(Point p)
{
	int x, xo, y, yo;

	if(canlock(&ark2000pvlock) == 0)
		return 1;

	/*
	 * Mustn't position the cursor offscreen even partially,
	 * or it might disappear. Therefore, if x or y is -ve, adjust the
	 * cursor origins instead.
	 */
	if((x = p.x+hotpoint.x) < 0){
		xo = -x;
		x = 0;
	}
	else
		xo = 0;
	if((y = p.y+hotpoint.y) < 0){
		yo = -y;
		y = 0;
	}
	else
		yo = 0;

	/*
	 * Load the new values.
	 */
	vgaxo(Seqx, 0x2C, xo);
	vgaxo(Seqx, 0x2D, yo);
	vgaxo(Seqx, 0x21, (x>>8) & 0x0F);
	vgaxo(Seqx, 0x22, x & 0xFF);
	vgaxo(Seqx, 0x23, (y>>8) & 0x0F);
	vgaxo(Seqx, 0x24, y & 0xFF);

	unlock(&ark2000pvlock);
	return 0;
}

Hwgc ark2000pvhwgc = {
	"ark2000pvhwgc",
	enable,
	load,
	move,
	disable,

	0,
};

static void
ark2000pvpage(int page)
{
	/*
	 * Shouldn't need to lock if linear addressing
	 * is enabled.
	 */
	if((vgaxi(Seqx, 0x10) & 0x10) == 0 && hwgc == &ark2000pvhwgc){
		lock(&ark2000pvlock);
		setark2000pvpage(page);
		unlock(&ark2000pvlock);
	}
	else
		setark2000pvpage(page);
}

.
13c
setark2000pvpage(int page)
.
11a
extern Bitmap gscreen;
extern Cursor curcursor;

static Lock ark2000pvlock;
static ulong storage;
static Point hotpoint;

.
## diffname pc/vgaark2000pv.c 1995/0623
## diff -e /n/fornaxdump/1995/0516/sys/src/brazil/pc/vgaark2000pv.c /n/fornaxdump/1995/0623/sys/src/brazil/pc/vgaark2000pv.c
132c
	vgaxo(Seqx, 0x20, seq20|0x08);
.
91a
	vgaxo(Seqx, 0x20, seq20 & ~0x08);
.
86c
		vgaxo(Seqx, 0x20, seq20|0x08);
.
84a
	seq20 = vgaxi(Seqx, 0x20);
.
83d
## diffname pc/vgaark2000pv.c 1995/0624
## diff -e /n/fornaxdump/1995/0623/sys/src/brazil/pc/vgaark2000pv.c /n/fornaxdump/1995/0624/sys/src/brazil/pc/vgaark2000pv.c
123,124c
				*p++ = 0xAA;
				*p++ = 0x55;
.
## diffname pc/vgaark2000pv.c 1995/0808
## diff -e /n/fornaxdump/1995/0624/sys/src/brazil/pc/vgaark2000pv.c /n/fornaxdump/1995/0808/sys/src/brazil/pc/vgaark2000pv.c
133a
#endif
.
132a
#ifdef notdef
.
123,124c
				*p++ = 0x00;
				*p++ = 0x00;
.
92a
#endif
.
91a
#ifdef notdef
.
## diffname pc/vgaark2000pv.c 1995/0812
## diff -e /n/fornaxdump/1995/0808/sys/src/brazil/pc/vgaark2000pv.c /n/fornaxdump/1995/0812/sys/src/brazil/pc/vgaark2000pv.c
166c
		yo = 1;
.
163c
		y = 1;
.
160c
		xo = 1;
.
157c
		x = 1;
.
## diffname pc/vgaark2000pv.c 1995/0822
## diff -e /n/fornaxdump/1995/0812/sys/src/brazil/pc/vgaark2000pv.c /n/fornaxdump/1995/0822/sys/src/brazil/pc/vgaark2000pv.c
166c
		yo = 0;
.
163c
		y = 0;
.
160c
		xo = 0;
.
157c
		x = 0;
.
## diffname pc/vgaark2000pv.c 1996/0215
## diff -e /n/fornaxdump/1995/0822/sys/src/brazil/pc/vgaark2000pv.c /n/fornaxdump/1996/0215/sys/src/brazil/pc/vgaark2000pv.c
182c
static Hwgc ark2000pvhwgc = {
.
## diffname pc/vgaark2000pv.c 1996/0216
## diff -e /n/fornaxdump/1996/0215/sys/src/brazil/pc/vgaark2000pv.c /n/fornaxdump/1996/0216/sys/src/brazil/pc/vgaark2000pv.c
135,137d
118,119c
	for(y = 0; y < 32; y++){
		for(x = 0; x < 32/8; x++){
.
114c
	 * Put the cursor into the top-left of the 32x32 array.
.
92,94d
86c
		vgaxo(Seqx, 0x20, vgaxi(Seqx, 0x20)|0x08);
.
84d
74c
	uchar *p;
.
62,63c
	storage -= 256;
	vgaxo(Seqx, 0x25, 0x3F);
.
57,58c
	 * Cursor storage is a 256 byte or 1Kb block located in the last
	 * 16Kb of video memory. Crt25 is the index of which block.
.
47c
	seq20 |= 0x18;
.
42c
	 * 32x32 and 4/8-bit colour depth.
.
## diffname pc/vgaark2000pv.c 1997/0327
## diff -e /n/fornaxdump/1996/0216/sys/src/brazil/pc/vgaark2000pv.c /n/emeliedump/1997/0327/sys/src/brazil/pc/vgaark2000pv.c
188,198c
	lock(&ark2000pvlock);
	setark2000pvpage(page);
	unlock(&ark2000pvlock);
.
68a

	unlock(&ark2000pvlock);
.
39a
	lock(&ark2000pvlock);

.
32a

	unlock(&ark2000pvlock);
.
30a
	lock(&ark2000pvlock);

.
## diffname pc/vgaark2000pv.c 1997/1101
## diff -e /n/emeliedump/1997/0327/sys/src/brazil/pc/vgaark2000pv.c /n/emeliedump/1997/1101/sys/src/brazil/pc/vgaark2000pv.c
208,213c
VGAcur vgaark2000pvcur = {
	"ark2000pvhwgc",

	ark2000pvenable,
	ark2000pvdisable,
	ark2000pvload,
	ark2000pvmove,
};
.
204d
191,202c
	0,
.
183,188c
VGAdev vgaark2000pvdev = {
	"ark2000pv",
.
179d
162c
	if((y = p.y+scr->offset.y) < 0){
.
156c
	if((x = p.x+scr->offset.x) < 0){
.
148,150d
144c
ark2000pvmove(VGAscr* scr, Point p)
.
138,140c
	scr->offset = curs->offset;
.
136c
	 * Save the cursor hotpoint.
.
134a
	if(!(seq10 & 0x10)){
		ark2000pvpageset(scr, opage);
		unlock(&scr->devlock);
	}

.
125,126c
				*p++ = curs->clr[2*y + x]|curs->set[2*y + x];
				*p++ = curs->set[2*y + x];
.
108a
	else
		p += scr->storage;
.
103,107c
	seq10 = vgaxi(Seqx, 0x10);
	opage = 0;
	p = KADDR(scr->aperture);
	if(!(seq10 & 0x10)){
		opage = ark2000pvpageset(scr, scr->storage>>16);
		p += (scr->storage & 0xFFFF);
.
86,99d
82,83c
	uchar *p, seq10;
	int opage, x, y;
.
80c
ark2000pvload(VGAscr* scr, Cursor* curs)
.
75,76d
68a
	scr->storage = storage;
.
44,45d
42a
	ulong storage;
.
40c
ark2000pvenable(VGAscr* scr)
.
35,36d
31,32d
27c
ark2000pvdisable(VGAscr*)
.
22,23c
	lock(&scr->devlock);
	ark2000pvpageset(scr, page);
	unlock(&scr->devlock);
.
20c
ark2000pvpage(VGAscr* scr, int page)
.
18a
	return seq15;
}

.
15,17c
	seq15 = vgaxi(Seqx, 0x15);
	vgaxo(Seqx, 0x15, page);
	vgaxo(Seqx, 0x16, page);
.
12,13c
static int
ark2000pvpageset(VGAscr*, int page)
{
	uchar seq15;
.
10d
8c
#define	Image	IMAGE
#include <draw.h>
#include <memdraw.h>
.
## diffname pc/vgaark2000pv.c 1998/0116
## diff -e /n/emeliedump/1997/1101/sys/src/brazil/pc/vgaark2000pv.c /n/emeliedump/1998/0116/sys/src/brazil/pc/vgaark2000pv.c
93a
		lock(&scr->devlock);
.
## diffname pc/vgaark2000pv.c 1999/0119
## diff -e /n/emeliedump/1998/0116/sys/src/brazil/pc/vgaark2000pv.c /n/emeliedump/1999/0119/sys/src/brazil/pc/vgaark2000pv.c
10a
#include <cursor.h>
.
## diffname pc/vgaark2000pv.c 1999/1005
## diff -e /n/emeliedump/1999/0119/sys/src/brazil/pc/vgaark2000pv.c /n/emeliedump/1999/1005/sys/src/brazil/pc/vgaark2000pv.c
58,63c
	vgaxo(Seqx, 0x26, 0x00);
	vgaxo(Seqx, 0x27, 0x00);
	vgaxo(Seqx, 0x28, 0x00);
	vgaxo(Seqx, 0x29, 0xFF);
	vgaxo(Seqx, 0x2A, 0xFF);
	vgaxo(Seqx, 0x2B, 0xFF);
.

Bell Labs OSI certified Powered by Plan 9

(Return to Plan 9 Home Page)

Copyright © 2021 Plan 9 Foundation. All Rights Reserved.
Comments to webmaster@9p.io.