Subject: VS2000 Console Code, from Shag/OS
To: None <port-vax@NetBSD.ORG>
From: Karl Maftoum <k.maftoum@student.canberra.edu.au>
List: port-vax
Date: 01/31/1998 13:53:41
Since this is only 3k, i thought i'd post it :) I havn't had this working yet,
but I'm sure it'll help :)

Cheers
Karl

--------------------------------------------------------------------

/* vid_vs2000.c
 *  KIMS/AVSS video routines
 */

/* I got this from Shag/OS.. Hope it works! -- Karl */

static Cursor *cursor;
static char *video;
static short font_data[128][16];


#define SCRWID 1024
#define SCRHGT 864


#define VROM_FONT_INDEX 0x00b4
#define PROM_FONT_VECTOR 0x001d


short block_data[16] = {
 0x003f,0x003f,0x003f,0x003f,0x003f,0x003f,0x003f,0x003f,
 0x003f,0x003f,0x003f,0x003f,0x003f,0x003f,0x003f,0x003f};
short block_mask[16] = {
 0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0};


init_video()
{
 video = (char*)map_device("video",0x30000000,128*K);
 cursor = (Cursor*)map_device("cursor",0x200f0000,sizeof(Cursor));
 screen.nplanes = 1;
 screen.vis_wid = 1024;
 screen.max_wid = 1024;
 screen.vis_hgt = 864;
 screen.max_hgt = 1024; 
 screen.cur_minx = 0;
 screen.cur_miny = 0;
 screen.cur_maxx = 1023;
 screen.cur_maxy = 863;
 video_fill(0,0,screen.max_wid,screen.max_hgt,0x0000);
 avss_init();
 font_init();
 video_setclip(0,0,screen.vis_wid,screen.vis_hgt); 
 console_font = &font[1];
 console_wid = (screen.vis_wid) / (console_font->wid);
 console_hgt = (screen.vis_hgt) / (console_font->hgt);
 set_cursor_mode(3,0);
 set_cursor_sprite(block_data,block_mask);
 vtstate.wid = console_wid;
 vtstate.hgt = console_hgt;
 vtstate.xpos = 0;
 vtstate.ypos = 0;
 vtstate.y1 = 0;
 vtstate.y2 = console_hgt-1;
 vtstate.attr = 0;
 vtstate.fg = 7;
 vtstate.bg = 0;
 vtstate.atval = 7;
 vtstate.esc = 0;
 vtstate.pcount = 0;
}

short cursor_mode;

set_cursor_mode(mode,crosshair)
int mode, crosshair;
{
 if(crosshair)
 crosshair = 1;
 switch(mode) {
 case 0:
 cursor_mode = 0xe000;
 break;
 case 1:
 cursor_mode = 0xe001+(crosshair<<4);
 break;
 case 2:
 cursor_mode = 0xe004+(crosshair<<4);
 break;
 case 3:
 cursor_mode = 0xe005+(crosshair<<4);
 break;
 } 
 cursor->command = cursor_mode;
}


set_cursor_xy(x,y)
int x,y;
{
        cursor->xpos = x + 8;
        cursor->ypos = y + 40;
}


set_cursor_sprite(data,mask)

short *data;
short *mask;
{
int i;
 cursor->command = cursor_mode | bit(12);
 for(i=0; i<16; i++)
 cursor->load = data[i];
 for(i=0; i<16; i++)
 cursor->load = mask[i];
 cursor->command = cursor_mode;

}


void video_fill(dx,dy,wid,hgt,fill)
 int dx,dy,wid,hgt,fill;
{
int t, i;
char *vp;
 vp = (char*)((int)video+(dx/8)+(dy*128));
 for(i=0; i<hgt; i++) {
 bfill(vp,wid/8,fill);
 vp += 128;
 }
}


void video_clear(dx,dy,dfvx,dsvy)
 int dx,dy,dfvx,dsvy;
{
 video_fill(dx,dy,dfvx,dsvy,0);
}


void video_scroll_up(x1,y1,wid,hgt,ofs)
 int x1,y1,wid,hgt,ofs;
{
int t,i;
char *vp;
 vp = (char*)((int)video+(x1/8)+(y1*128));
 for(i=y1; i<y1+hgt-ofs; i++) {
 bcopy(vp+(ofs*128),vp,wid/8);
 vp += 128;
 }
 for(; i<y1+hgt; i++) {
 bzero(vp,wid/8);
 vp += 128;
 }
}



get_promchar(buf,ch)
        short *buf;
        int ch;
{
char *cp;
int i;
 cp = (char*)prom+(prom[PROM_FONT_VECTOR] - 0x20040000);
 ch = (ch+96)%128;
        for(i=0; i<15; i++)
                buf[i] = cp[ch*15+i];
}


font_init()
{
int i,n;
short buf[32];
 font[0].ypos = screen.vis_hgt;
 font[0].xpos = 0;
 font[0].rwid = 128;
 font[0].swid = 16;
 font[0].wid = 12;
 font[0].hgt = 22;
 font[1].wid = 8;
 font[1].hgt = 15;
        for(i = 0; i<128; i++) 
 get_promchar(font_data[i],i);
}


Font *video_getfont(num)
int num;
{
 return(&font[num]);
}


video_putchar(font,x,y,ch)
Font *font;
int ch;
{
int yp,xp,i;
char *vp;
 vp = (char*)((int)video+(x/8)+(y*128));
 for(i=0; i<15; i++) {
 *vp = font_data[ch][i];
 vp += 128;
 }
}


 


----------------------------------------------------------------------------
-----------------------------------------------

Karl Maftoum

Computer Engineering Student at the University of Canberra, Australia

Email: k.maftoum@student.canberra.edu.au