head 1.8; access ; symbols ; locks ; comment @@; 1.8 date 89.06.19.17.16.54; author pkern; state Exp; branches ; next 1.7; 1.7 date 89.06.13.12.22.19; author pkern; state Exp; branches ; next 1.6; 1.6 date 89.06.07.10.59.36; author pkern; state Exp; branches ; next 1.5; 1.5 date 89.05.16.11.53.07; author pkern; state Exp; branches ; next 1.4; 1.4 date 89.04.13.16.10.11; author pkern; state Exp; branches ; next 1.3; 1.3 date 89.02.06.16.40.42; author pkern; state Exp; branches ; next 1.2; 1.2 date 89.02.03.15.54.35; author pkern; state Exp; branches ; next 1.1; 1.1 date 89.02.03.13.35.49; author pkern; state Exp; branches ; next ; desc @@ 1.8 log @memcpy() calls replace with movmem() @ text @/* * screen.pc: * IBM PC screen handling * * Copyright (c) 1989 University of Toronto. All rights reserved. * Anyone may use or copy this software, except that it may not be * sold for profit, that this copyright notice remain intact, and that * credit is given where it is due. The University of Toronto and the * author make no warranty and accept no liability for this software. */ static char rcsid[] = "$Header: screen.pc,v 1.7 89/06/13 12:22:19 pkern Exp $"; #include #include "cterm.h" #include "pc.h" #ifdef BGI #include #include #include #endif static union REGS r; static struct SREGS sr; static struct REGPACK rp; static int o_scrn[132 * 24]; /* screen memory storage */ static int o_xy=0; /* cursor position memory */ static int far *scrn; /* screen position memory */ static int ncols=0, vmode=-1, pgnum=0; /* see init_scr() */ static int o_ncols=0; static unsigned int vaddr=0xb000; /* cursor types */ static unsigned int crsr_blk=0x000c, crsr_ul=0x0b0c; #define sPOS(a, b) ((b)*ncols+(a)) static int *scp; /* general purpose screen pointer */ /* macros for frequently used code */ #define crtint int86(CRT_INT, &r, &r) #ifdef BIOS #define BLANK 0x20 #define NORM 0x07 #define GO_HOME r.h.ah=2; r.h.bh=pgnum; r.x.dx=0; crtint; #define GO_XY(a,b) \ r.h.ah=2; r.h.bh=pgnum; r.h.dh=(b); r.h.dl=(a); crtint; #define GO_CURS #else #define BLANK 0x0720 #define NORM 0x07 #define CX_POSN *((char far *)(0x00450+(pgnum<<1))) #define CY_POSN *((char far *)(0x00451+(pgnum<<1))) #define CURS_POS *((int far *)(0x00450+(pgnum<<1))) #define GO_HOME CURS_POS = r.x.dx = 0; #define GO_XY(a,b) r.h.dh=(b); r.h.dl=(a); CURS_POS = r.x.dx; #define GO_CURS r.h.ah=2; r.h.bh=pgnum; crtint; #endif /* BIOS */ #define CLEAN(a) \ r.x.ax=0x0920; r.x.bx=(pgnum<<8)|NORM; r.x.cx=(a); crtint; static uchar xattr=NORM; /* attribute storage */ /* * init_scr: * try to figure out where the display is * and set our internal variables to reflect it. */ init_scr() { #ifdef BGI if (gfx_driver == DETECT) { detectgraph(&gfx_driver, &gfx_mode); switch (gfx_driver) { case CGA: case MCGA: txt_mode = BW80; txt_addr = 0xb800; break; case EGA: case EGA64: case EGAMONO: txt_mode = BW80; txt_addr = 0xa000; break; default: txt_mode = MONO; txt_addr = 0xb000; } } #endif if (vmode < 0) { r.h.al = txt_mode; vaddr = txt_addr; } else r.h.al = vmode; r.h.ah = 0; crtint; r.h.ah = 0x0f; /* get video mode */ crtint; ncols = r.h.ah; /* num of cols */ vmode = r.h.al; /* video mode */ pgnum = r.h.bh; /* page number */ r.h.ah = 0x03; /* get cursor mode */ r.h.bh = pgnum; crtint; crsr_blk = (r.h.cl < 7) ? 7 : r.h.cl; crsr_ul = ((r.h.cl-1) << 8) | r.h.cl; segread(&sr); scrn = (int far *) MK_FP(vaddr, 0); return(vmode == txt_mode); } reset_scr() { #ifdef BGI if (gfx_driver > 0) { restorecrtmode(); closegraph(); } gfx_driver = DETECT; #endif } curs_xy(x, y) uchar x, y; { GO_XY(x-1, y-1) GO_CURS } xypos(xp, yp) uchar *xp, *yp; { #ifdef BIOS r.h.ah = 3; r.h.bh = pgnum; crtint; #else r.x.dx = CURS_POS; #endif *xp = r.h.dl+1; *yp = r.h.dh+1; } columns(n) int n; { if (!avm_mode) /* can't do 132 columns */ return(ncols); if (n > 80) { vmode = avm_mode; vaddr = avm_addr; } else { vmode = txt_mode; vaddr = txt_addr; } init_scr(); if (o_ncols) o_xy = o_ncols = 0; return(ncols); } bkgnd(sw) int sw; { /* nothing yet */ } #ifndef BIOS clean(n) register int n; { register int *scp; r.x.dx = CURS_POS; scp = &scrn[sPOS(r.h.dl, r.h.dh)]; while (n--) *scp++ = BLANK; } #endif /* !BIOS */ /* scroll up n lines between min_y and max_y */ scrl_up(n, min_y, max_y, x, y) uchar n, min_y, max_y, x, y; { if (n > max_y-min_y+1) n = max_y-min_y+1; /* #ifdef BIOS */ r.h.ah = 6; r.h.al = n; r.h.bh = NORM; r.h.cl = 0; r.h.ch = min_y-1; r.h.dl = ncols-1; r.h.dh = max_y-1; crtint; /* #else */ #ifdef notdef if (n < max_y-min_y+1) { char *dst, *src; dst = &scrn[sPOS(0, min_y-1)]; src = &scrn[sPOS(0, min_y+n-1)]; movmem(src, dst, (max_y-min_y-n+1) * ncols * 2); } /* scp = &scrn[sPOS(0, max_y-n)]; memset(scp, '\0', n * ncols * 2); */ GO_XY(0, max_y-n) CLEAN(n * ncols) GO_XY(x-1, y-1) GO_CURS #endif } /* scroll down n lines between min_y and max_y */ scrl_down(n, min_y, max_y, x, y) uchar n, min_y, max_y, x, y; { if (n > max_y-min_y+1) n = max_y-min_y+1; /* #ifdef BIOS */ r.h.ah = 7; r.h.al = n; r.h.bh = NORM; r.h.cl = 0; r.h.ch = min_y-1; r.h.dl = ncols-1; r.h.dh = max_y-1; crtint; /* #else */ #ifdef notdef if (n < max_y-min_y+1) { char *dst, *src; dst = &scrn[sPOS(0, min_y+n-1)]; src = &scrn[sPOS(0, min_y-1)]; movmem(src, dst, (max_y-min_y-n+1) * ncols * 2); } /* scp = &scrn[sPOS(0, min_y-1)]; memset(scp, '\0', n * ncols * 2); */ GO_XY(0, min_y-1) CLEAN(n * ncols) GO_XY(x-1, y-1) GO_CURS #endif } /* eol : erase to end of line */ eol_erase(x, y) uchar x, y; { if (x > ncols) return; CLEAN(ncols-(x-1)) } /* * bol : erase from beginning of line to cursor pos. * ie. goto head of line, erase chars, return to original pos */ bol_erase(x, y) uchar x, y; { GO_XY(0, y-1) CLEAN(x) GO_XY(x-1, y-1) GO_CURS } /* eos : erase to end of line and to end of screen */ eos_erase(x, y) uchar x, y; { CLEAN((24-y)*ncols + ncols-x+1) } /* * bos : erase from beginning of screen (home) to cursor pos. */ bos_erase(x, y) uchar x, y; { GO_HOME CLEAN(ncols*(y-1)+x) GO_XY(x-1, y-1) GO_CURS } /* goto head of line, erase line, return to original pos */ line_erase(x, y) uchar x, y; { GO_XY(0, y-1) CLEAN(ncols) GO_XY(x-1, y-1) GO_CURS } /* erase entire screen (not including status line) */ all_erase(x, y) uchar x, y; { GO_HOME CLEAN(ncols*24) GO_XY(x-1, y-1) GO_CURS } /* * insert line(s) : * scroll down n lines, goto head of original line, erase empty space */ line_ins(n, x, y, max_y) uchar n, x, y, max_y; { scrl_down(n, y, max_y, x, y); GO_XY(0, y-1) GO_CURS } /* * delete line(s) : * scroll up n lines, goto new empty line, erase lines, * return to head of original line */ line_del(n, x, y, max_y) uchar n, x, y, max_y; { scrl_up(n, y, max_y, x, y); GO_XY(0, y-1) GO_CURS } /* * delete char(s) : * ie. copy rest of line to the left, goto line-end, erase n chars * and return to original cursor pos */ char_del(n, x, y) uchar n, x, y; { int *p; register uchar yn = y-1; if (x > ncols) return; if (x+n-1 > ncols) n = ncols-x+1; scp = &scrn[sPOS(x-1, yn)]; p = &scrn[sPOS(x+n-1, yn)]; movmem(p, scp, (ncols-(x+n-1)) * 2); /* scp = &scrn[sPOS(ncols-n, yn)]; memset(scp, '\0', n * 2); */ GO_XY(ncols-n, yn) CLEAN(n) GO_XY(x-1, y-1) GO_CURS } /* * insert char(s) : * ie. copy rest of line to right and clean out new space(s) */ char_ins(n, x, y) uchar n, x, y; { int *p; register uchar yn = y-1; if (x > ncols) return; if (x+n-1 > ncols) n = ncols-x+1; scp = &scrn[sPOS(x-1, yn)]; p = &scrn[sPOS(x+n-1, yn)]; movmem(scp, p, (ncols-(x+n-1)) * 2); /* scp = &scrn[sPOS(x-1, yn)]; memset(scp, '\0', n * 2); */ GO_XY(x-1, yn) CLEAN(n) GO_XY(x-1, y-1) GO_CURS } /* * set attributes */ uchar c_norm=7, c_rev=7, c_bold=7; attribs(attr) uchar attr; { xattr = NORM; if (attr & AT_UL) xattr = 0x01; if (attr & AT_BOLD) xattr |= 0x08; if (attr & AT_BLINK) xattr |= 0x80; if (attr & AT_REV) xattr = (xattr & 0x88) | 0x70; } /* * screen alignment test : * home cursor and write a screen of E's in normal attrib mode. * previous attribs are not forgotten. */ e_screen() { GO_HOME GO_CURS r.h.ah = 0x09; r.h.al = 'E'; r.h.bh = pgnum; r.h.bl = NORM; r.x.cx = ncols * 24; crtint; /* screen of E's */ } /* basic single-char output */ burpc(c, x, y) int c, x, y; { #ifdef BIOS r.h.ah = 0x09; r.h.al = c; r.h.bh = pgnum; r.h.bl = xattr; r.x.cx = 1; crtint; #else r.h.dl = c; r.h.dh = xattr; scrn[sPOS(x-1, y-1)] = r.x.dx; #endif GO_XY(x, y-1) GO_CURS } /* sound bell/horn/whistle/whatever */ beep(x, y) int x, y; { /* r.x.ax = 0x0e07; r.x.bx = (pgnum << 8); crtint; */ /* honk(0x533, 64); /* normal 1000 Hz bell */ /* mildly fancy honk(0x333, 32); honk(0x533, 32); honk(0x733, 32); */ #ifdef PLAY /* getting fancier ... */ play("g3.24,d3.24,g3.24,d3.24,g3.24"); #else /* default */ honk(2915, 64); /* middle C (approx. 440 Hz) */ #endif } /* insert mode burpc() */ /* move line right, deposit char */ insurpc(c, x, y) int c, x, y; { char_ins(1, x, y); burpc(c, x, y); } /* output string at x,y with attr */ burps(s, x, y, at) char *s; uchar x, y, at; { int c; uchar xn = x, yn = y; c = xattr; attribs(at); #ifdef BIOS GO_XY(xn-1, yn-1) while (*s) { burpc(*s++, xn++, yn); if (xn == ncols) { xn = 1; if (yn < 24) yn++; } } #else scp = &scrn[sPOS(x-1, y-1)]; r.h.dh = xattr; while (*s) { r.h.dl = *s++; *scp++ = r.x.dx; } #endif GO_XY(x-1, y-1) GO_CURS xattr = c; } /* set cursor type */ curs_type(sw) uchar sw; { r.h.ah = 1; r.x.cx = (sw) ? crsr_blk : crsr_ul; if (sw & 0x80) r.h.ch = 0x20 | (r.h.ch & 0x1f); crtint; } /* save screen image & cursor position */ save_scr() { register int n; register int *os, *s; r.h.ah = 3; r.h.bh = pgnum; crtint; o_xy = r.x.dx; n = ncols * 24; s = scrn; os = o_scrn; /* while (n--) *os++ = *s++; */ movmem(s, os, n * 2); o_ncols = ncols; save_gfx(); } /* restore screen image & cursor position */ restore_scr() { register int n; register int *os, *s; restore_gfx(); n = ncols * 24; s = scrn; os = o_scrn; /* while (n--) *s++ = *os++; */ if (o_ncols) movmem(os, s, n * 2); else { GO_HOME CLEAN(n) } r.h.ah = 2; r.h.bh = pgnum; r.x.dx = o_xy; crtint; o_ncols = 0; } /* save text in line lnum from o_scrn to buf */ scgets(buf, siz, lnum) char buf[]; int siz, lnum; { char c; int i, j, n; if (lnum > 24) return(-1); j = sPOS(0, lnum-1); /* first column */ n = sPOS(o_ncols-1, lnum-1); /* last column */ /* find last non-blank char in line */ for (; j < n; n--) if ((c = o_scrn[n] & 0x7f) != NUL && c != ' ') { n++; break; } /* save text to buf */ for (i=0; i < siz && j < n; i++, j++) buf[i] = o_scrn[j] & 0x7f; buf[i] = NUL; return(i); } /* write string to status line */ uchar c_stat = 3; sturp(s, x, y) char *s; int x, y; { int i=0, c; #ifdef BIOS if (c_stat) burps(s, 1, 25, AT_REV); #else c = (c_stat) ? 0x70 : 0; /* reverse video or blank */ scp = &scrn[sPOS(0, 24)]; r.h.dh = c; while (*s && i++ < ncols) { r.h.dl = *s++; *scp++ = r.x.dx; } r.h.dl = ' '; while (i++ < ncols) *scp++ = r.x.dx; #endif GO_XY(x-1, y-1) GO_CURS } /* delay for n milliseconds */ dsleep(n) unsigned int n; { #ifdef notdef /* #ifdef PCAT */ unsigned long m; m = n * 1000; r.h.ah = 86; r.x.cx = m >> 16; r.x.dx = m & 0xffff; int86(0x15, &r, &r); #else unsigned int x; while(n--) for (x=0x400; x; x--) ; /* ... just a guess */ #endif } /* clear screen & home cursor */ clr_home() { GO_HOME GO_CURS CLEAN(ncols * 25) } /* dburp -- put debug message on status line */ dburp(s) char *s; { uchar x, y; xypos(&x, &y); sturp(s, x, y); } /* * honk: sound the horn */ #define TimerCtl 0x43 #define Timer2Cnt 0x42 #define BPort 0x61 honk(tdiv, n) unsigned int tdiv, n; { unsigned char bsav; register unsigned int i; register unsigned char c, x; c = tdiv >> 8; x = tdiv & 0xff; outportb(TimerCtl, 0xb6); /* select timer 2 */ outportb(Timer2Cnt, x); /* timer 2 counter lsb */ outportb(Timer2Cnt, c); /* timer 2 counter msb */ c = inportb(BPort); /* save 8255 port b setting */ bsav = c; c |= 3; outportb(BPort, c); /* turn speaker on */ while (n--) for(x=1; x; x++) ; outportb(BPort, bsav); /* restore 8255 port */ } #ifdef PLAY #define sqrt_2 1.059463994 /* 12th root of 2 */ /* * 12 notes : c d# d e# e f g# g a# a b# b * per octave : 0 1 2 3 4 5 6 7 8 9 10 11 */ static int notes[7] = { 9, 11, 0, 2, 4, 5, 7}; /* a b c d e f g */ play(p) char *p; { int note, octv, tlen; float freq; long clk; tlen = 10; /* expecting: n[#]o.l{,n[#]o.l} * n == note [a-g], * [#] == optional sharp, * o == octave [0-..], * l == duration [1-..] */ while (*p) { freq = 55.0; /* low "C" == 55 Hz */ clk = 1283000; /* PC/AT speaker clock speed */ octv = 0; note = notes[*p - 'a']; if (*++p == '#') { p++; if (note) note--; else { /* c# */ octv = 1; note = notes['g']; } } octv += atoi(p); while (*++p != '.') ; tlen = atoi(++p); while (*p && *p++ != ',') ; for (; octv; octv--) freq *= 2; for (; note; note--) freq *= sqrt_2; note = clk/freq; honk(note, tlen); } } #endif /* PLAY */ /* IBM PC graphics nitty-gritty */ static uchar o_gclr=7; save_gfx() { extern uchar gcolour; o_gclr = gcolour; } restore_gfx() { extern uchar gcolour; gcolour = o_gclr; } #ifdef BGI #include "scr_gfx.bgi" #else /* for now, use bios calls until someone can * tell me how to handle graphics directly */ #ifndef BIOS #define BIOS 1 #endif #include "scr_gfx.h" #endif /* BGI */ @ 1.7 log @BGI code added. minor bug fixe. @ text @d11 1 a11 1 static char rcsid[] = "$Header: screen.pc,v 1.6 89/06/07 10:59:36 pkern Exp $"; d19 1 d207 1 a207 1 memcpy(dst, src, (max_y-min_y-n+1) * ncols * 2); d236 1 a236 1 memcpy(dst, src, (max_y-min_y-n+1) * ncols * 2); d350 1 a350 1 memcpy(scp, p, (ncols-(x+n-1)) * 2); d376 1 a376 1 memcpy(p, scp, (ncols-(x+n-1)) * 2); d524 1 a524 1 memcpy(os, s, n * 2); d540 1 a540 1 memcpy(s, os, n * 2); @ 1.6 log @*** empty log message *** @ text @d11 1 a11 1 static char rcsid[] = "$Header: screen.pc,v 1.5 89/05/16 11:53:07 pkern Exp $"; d17 5 d76 18 d107 1 d114 1 a114 1 scrn = (char far *) MK_FP(vaddr, 0); d121 7 d142 1 d194 1 a194 1 #ifdef BIOS d199 2 a200 1 #else d223 1 a223 1 #ifdef BIOS d228 2 a229 1 #else d353 1 d378 2 a379 1 memset(scp , '\0', n * 2); */ d409 1 d518 1 a518 1 r.h.ah = 3; crtint; o_xy = r.x.dx; d525 1 d534 1 d545 1 a545 1 r.h.ah = 2; r.x.dx = o_xy; crtint; d729 24 a752 2 /* for now, use bios calls until someone * can tell me how to do direct graphics */ d756 1 d758 1 a758 1 #include "scr_gfx.h" @ 1.5 log @*** empty log message *** @ text @d11 1 a11 1 static char rcsid[] = "$Header: screen.pc,v 1.4 89/04/13 16:10:11 pkern Exp $"; a16 3 #define BLANK 0x00 #define NORM 0x07 a19 1 static uchar xattr=NORM; /* attribute storage */ d21 1 a21 1 static char o_scrn[132 * 24 * 2]; /* screen memory storage */ d23 1 a23 1 static char far *scrn; /* screen position memory */ d32 2 a33 2 #define sPOS(a, b) (((b)*ncols+(a))*2) static char *scp; /* general purpose screen pointer */ d37 6 a42 1 #define GO_HOME r.h.ah=2; r.x.dx=0; crtint; d44 5 a48 3 r.h.ah=2; r.h.dh=(b); r.h.dl=(a); crtint; #define CLEAN(n) \ r.x.ax=0x0920; r.x.bx=(pgnum<<8)|NORM; r.x.cx=(n); crtint; d50 14 d103 1 d109 1 d112 3 d144 12 d160 2 d168 1 a168 3 if (n > max_y-min_y+1) n = max_y-min_y+1; else { d175 6 a180 2 scp = &scrn[sPOS(0, max_y-n)]; memset(scp, '\0', n * ncols * 2); d188 2 d193 1 a193 1 r.h.dh = ncols-1; r.h.dl = max_y-1; d196 1 a196 3 if (n > max_y-min_y+1) n = max_y-min_y+1; else { d203 6 a208 2 scp = &scrn[sPOS(0, min_y-1)]; memset(scp, '\0', n * ncols * 2); a217 1 #ifdef BIOS a218 4 #else scp = &scrn[sPOS(x-1, y-1)]; memset(scp, '\0', (ncols-x+1) * 2); #endif a227 1 #ifdef BIOS d231 1 a231 4 #else scp = &scrn[sPOS(0, y-1)]; memset(scp, '\0', x * 2); #endif a237 1 #ifdef BIOS a238 4 #else scp = &scrn[sPOS(x-1, y-1)]; memset(scp, '\0', ((24-y)*ncols + ncols-x+1) * 2); #endif a246 1 #ifdef BIOS d250 1 a250 4 #else scp = scrn; memset(scp, '\0', (ncols*(y-1)+x) * 2); #endif a256 1 #ifdef BIOS d260 1 a260 4 #else scp = &scrn[sPOS(0, y-1)]; memset(scp, '\0', ncols * 2); #endif a266 1 #ifdef BIOS d270 1 a270 4 #else scp = scrn; memset(scp, '\0', ncols * 24 * 2); #endif d283 1 d296 1 d307 1 a307 1 char *p; d312 1 d316 7 a322 2 scp = &scrn[sPOS(ncols-n, yn)]; memset(scp, '\0', n * 2); d332 1 a332 1 char *p; d337 1 d341 7 a347 2 scp = &scrn[sPOS(x-1, yn)]; memset(scp , '\0', n * 2); d393 2 a394 5 scp = &scrn[sPOS(x-1, y-1)]; *scp++ = c; *scp++ = xattr; if (!*++scp) *scp = NORM; d397 1 d454 1 d456 2 a457 2 *scp++ = *s++; *scp++ = xattr; d460 2 a461 1 GO_XY(x-1, y-1); d471 1 d479 1 a479 1 register char *os, *s; d483 1 a483 1 n = ncols * 24 * 2; d486 1 a486 1 memcpy(os, s, n); d494 1 a494 1 register char *os, *s; d496 1 a496 1 n = ncols * 24 * 2; d500 5 a504 3 memcpy(s, os, n); else memset(s, '\0', n); d515 1 d525 3 a527 5 for (; j < n; n-=2) if (o_scrn[n] != NUL && o_scrn[n] != ' ') { n += 2; break; } d530 2 a531 2 for (i=0; i < siz && j < n; i++, j+=2) buf[i] = o_scrn[j]; a545 1 c = (c_stat) ? 0x70 : 0; /* reverse video or blank */ d547 2 a548 1 burps(s, 1, 25, c); d550 1 d552 1 d554 2 a555 2 *scp++ = *s++; *scp++ = c; d557 3 a559 5 while (i < ncols) { *scp++ = ' '; *scp++ = c; i++; } a560 10 /* PC/AT * rp.r_ax = 0x1300; * rp.r_bx = (pgnum << 8) | c; * i = strlen(s); * rp.r_cx = (i > ncols-1) ? ncols-1 : i; * rp.r_dx = 0x1800; * rp.r_es = sr.ds; * rp.r_si = (unsigned int)s; * intr(CRT_INT, &rp); */ d562 1 d593 1 a593 1 #ifdef BIOS a594 4 #else scp = scrn; memset(scp, '\0', ncols * 25 * 2); #endif d689 6 @ 1.4 log @*** empty log message *** @ text @d11 1 a11 1 static char rcsid[] = "$Header: screen.pc,v 1.3 89/02/06 16:40:42 pkern Exp $"; a19 9 /* video mode parameters (see scr_gfx.h) */ /* text mode */ extern unsigned int txt_mode, txt_addr; /* advanced video mode (132 columns) */ extern unsigned int avm_mode, avm_addr; /* graphics mode */ extern unsigned int gfx_mode, gfx_addr; extern unsigned int gfx_xres, gfx_yres, gfx_numclr; d68 1 a68 1 crsr_blk = r.h.cl; @ 1.3 log @scgets() added screen memory segment choice and cursor size added @ text @d5 5 a9 1 * copyright (c) University of Toronto, 1988. d11 1 a11 1 static char rcsid[] = "$Header: screen.pc,v 1.2 89/02/03 15:54:35 pkern Exp $"; d20 8 a27 3 #define SCR_SEG (0xb000) /* screen location segment */ #define CRSR_BLK 0x000c /* block cursor (0-13) */ #define CRSR_UL 0x0b0c /* underline cursor (12-13) */ a28 4 /* #define SCR_SEG (0xb800) /* colour screen location segment */ /* #define CRSR_BLK 0x0007 /* block cursor */ /* #define CRSR_UL 0x0607 /* underline cursor */ d34 2 a35 2 /* static */ char o_scrn[SCRSIZE * 2]; /* screen memory storage */ static int o_xy; /* cursor position memory */ d38 3 a40 2 static int ncols, vmode, pgnum; /* see init_scr() */ static unsigned int crsr_blk, crsr_ul; /* cursor types */ d42 2 a43 2 #define sPOS(a, b) (((b)*80+(a))*2) static char *scp; /* general usage screen pointer */ d45 3 d63 5 a67 1 unsigned int sc_seg = SCR_SEG; d77 2 a78 8 /* CH: start line, CL: end line */ /* CH | 0x40: slow blink, CH | 0x60: fast blink */ crsr_blk = 0x4000 | r.h.cl; crsr_ul= 0x4000 | ((r.h.cl-1) << 8) | r.h.cl; /* crsr_blk = CRSR_BLK; crsr_ul = CRSR_UL; */ a79 9 /* */ if (vmode == 0x07) sc_seg = 0xb000; else if (vmode >= 0x0d) sc_seg = 0xa000; else sc_seg = 0xb800; /* */ scrn = (char far *) MK_FP(sc_seg, 0); d81 4 d106 5 d112 19 d135 6 d148 1 a148 1 memcpy(dst, src, (max_y-min_y-n+1) * 80 * 2); d151 2 a152 7 memset(scp, '\0', n * 80 * 2); /* r.h.ah = 6; r.h.al = n; r.h.bh = NORM; r.h.cl = 0; r.h.ch = min_y-1; r.h.dl = 79; r.h.dh = max_y-1; crtint; */ d159 6 d172 1 a172 1 memcpy(dst, src, (max_y-min_y-n+1) * 80 * 2); d175 2 a176 7 memset(scp, '\0', n * 80 * 2); /* r.h.ah = 7; r.h.al = n; r.h.bh = NORM; r.h.cl = 0; r.h.ch = min_y-1; r.h.dh = 79; r.h.dl = max_y-1; crtint; */ d184 4 a187 4 if (x > 80) return; /* CLEAN(80-(x-1)) */ d189 2 a190 1 memset(scp, '\0', (80-x+1) * 2); d200 1 a200 1 /* d204 1 a204 1 */ d207 1 d214 3 d218 2 a219 1 memset(scp, '\0', ((24-y)*80 + 80-x+1) * 2); d228 5 d234 2 a235 1 memset(scp, '\0', (80*(y-1)+x) * 2); d242 5 d248 2 a249 1 memset(scp, '\0', 80 * 2); d256 5 d262 2 a263 1 memset(scp, '\0', 80 * 24 * 2); d299 1 d301 6 a306 6 if (x > 80) return; if (x+n-1 > 80) n = 80-x+1; scp = &scrn[sPOS(x-1, y-1)]; p = &scrn[sPOS(x+n-1, y-1)]; memcpy(scp, p, (80-(x+n-1)) * 2); scp = &scrn[sPOS(80-n, y-1)]; d318 1 d320 6 a325 6 if (x > 80) return; if (x+n-1 > 80) n = 80-x+1; scp = &scrn[sPOS(x-1, y-1)]; p = &scrn[sPOS(x+n-1, y-1)]; memcpy(p, scp, (80-(x+n-1)) * 2); scp = &scrn[sPOS(x-1, y-1)]; d332 2 d356 1 a356 1 r.x.cx = 80 * 24; d364 1 a364 1 /* d371 1 a371 1 */ d377 2 a378 1 GO_XY(x, y-1); d400 1 d420 1 d424 10 d439 1 d457 1 a457 2 register char *os; register char far *s; d459 1 a459 3 r.h.ah = 3; crtint; o_xy = r.x.dx; d461 1 a461 1 n = SCRSIZE * 2; d465 1 d472 1 a472 2 register char *os; register char far *s; d474 1 a474 1 n = SCRSIZE * 2; d477 4 a480 1 memcpy(s, os, n); d482 2 a483 3 r.h.ah = 2; r.x.dx = o_xy; crtint; d497 1 a497 1 n = sPOS(ncols-1, lnum-1); /* last column */ d515 1 a515 1 uchar stcolour = 3; d521 1 a521 1 int i, c; d523 4 a526 1 c = (stcolour) ? 0x70 : 0; /* reverse video or blank */ d528 1 a528 1 while (*s) { d532 6 d542 1 a542 1 * rp.r_cx = (i > 79) ? 79 : i; d579 3 d583 2 a584 1 memset(scp, '\0', 80 * 25 * 2); d629 2 a630 2 * 12 notes/octave; c d# d e# e f g# g a# a b# b * 0 1 2 3 4 5 6 7 8 9 10 11 a631 1 d644 5 a648 5 /* expecting: n[#]o.l{,n[#]o.l} n == note [a-g], [#] == optional sharp, o == octave [0-..], l == duration [1-..] d678 1 a678 1 /* graphics nitty-gritty */ d680 1 a680 93 #define GMAX_X 2 #define GMAX_Y 2 init_gfx() { extern int gmax_x, gmax_y; extern uchar interlace, gcolour; gmax_x = GMAX_X; gmax_y = GMAX_Y; if (interlace) { gcolour = 7; } } /* gfx_erase -- clear or hide the graphics screen */ gfx_erase() { /* nothing yet */ } /* gpeek -- get a pixel's colour */ gpeek(x, y) int x, y; { uchar c = 0; return(c); } /* boink -- light a pixel */ boink(x,y,c) int x, y; uchar c; { /* nothing yet */ } /* * hline -- only does horizontal lines (union regulations :-) * (called from bline(), should be optimized for speed). */ hline(x,y,n,c) int x,y,n; uchar c; { if (n < 0) { n = -n; x -= n; if (x < 0) { n += x; x = 0; } } /* nothing yet */ } /* * vline -- vertical lines only * (again, called from bline(), should be optimized for speed). */ vline(x,y,n,c) int x,y,n; uchar c; { if (n < 0) { n = -n; y -= n; if (y < 0) { n += y; y = 0; } } /* nothing yet */ } /* * xrun -- optimize search for runs to colour c in x direction * (called from dofill(), should be quicker that gpeek()-ing each pixel). */ xrun(x, y, c, dir) int x, y, dir; uchar c; { uchar cx; while (0 <= x && x < GMAX_X) { cx = gpeek(x, y); /* optimize this! */ if (c == cx) break; x += dir; } if (c == cx) x -= dir; if (x < 0) return(0); if (x >= GMAX_X) return(GMAX_X-1); return(x); } @ 1.2 log @*** empty log message *** @ text @d7 1 a7 1 static char rcsid[] = "$Header: screen.pc,v 1.1 89/02/03 13:35:49 pkern Exp $"; d16 1 a16 1 #define SCR_MEM (0xb000) /* screen location segment */ d20 1 a20 1 /* #define SCR_MEM (0xb800) /* colour screen location segment */ d34 1 d47 5 d54 3 a56 1 r.h.ah = 0x0f; d58 3 a60 3 ncols = r.h.ah; vmode = r.h.al; pgnum = r.h.bh; d62 20 a81 1 scrn = (char far *) MK_FP(SCR_MEM, 0); d379 1 a379 1 r.x.cx = (sw) ? CRSR_BLK : CRSR_UL; d415 28 @ 1.1 log @Initial revision @ text @d7 1 a7 1 static char rcsid[] = "$Header$"; d297 3 a299 1 beep() @