diff options
author | tg <tg@FreeBSD.org> | 2001-07-24 11:44:20 +0000 |
---|---|---|
committer | tg <tg@FreeBSD.org> | 2001-07-24 11:44:20 +0000 |
commit | 97507091ff20d3dc72113dfbd0c9532423d3acb4 (patch) | |
tree | f37909a1b76ac49ce96e941e94a62649b7210a4e /usr.bin/doscmd | |
parent | dfb5f5d5892585bd43bea7a627c21456e0ff9687 (diff) | |
download | FreeBSD-src-97507091ff20d3dc72113dfbd0c9532423d3acb4.zip FreeBSD-src-97507091ff20d3dc72113dfbd0c9532423d3acb4.tar.gz |
Rewrite video emulation. Features:
- slightly more accurate VGA hardware emulation;
- more int 10 functions, especially wrt to palette handling;
- first shot at graphics support;
- mode switching.
Bugs:
- graphics too slow;
- only 16 color modes work for now;
- works only under X, and only with 16 bit TrueColor visuals;
- far from being genuinely useful (I can play an old EGA game now, though
(mahjongg.exe)).
Also, the code has been cleaned up a bit (more to come in a separate commit).
Diffstat (limited to 'usr.bin/doscmd')
-rw-r--r-- | usr.bin/doscmd/Makefile | 37 | ||||
-rw-r--r-- | usr.bin/doscmd/cp437-8x14.pcf.gz.uu | 113 | ||||
-rw-r--r-- | usr.bin/doscmd/cp437-8x8.pcf.gz.uu | 104 | ||||
-rw-r--r-- | usr.bin/doscmd/cpu.c | 279 | ||||
-rw-r--r-- | usr.bin/doscmd/doscmd.1 | 7 | ||||
-rw-r--r-- | usr.bin/doscmd/doscmd.c | 54 | ||||
-rw-r--r-- | usr.bin/doscmd/doscmd.h | 202 | ||||
-rw-r--r-- | usr.bin/doscmd/font.h | 407 | ||||
-rw-r--r-- | usr.bin/doscmd/fonts.dir | 6 | ||||
-rw-r--r-- | usr.bin/doscmd/int10.c | 321 | ||||
-rw-r--r-- | usr.bin/doscmd/trap.c | 28 | ||||
-rw-r--r-- | usr.bin/doscmd/tty.c | 1181 | ||||
-rw-r--r-- | usr.bin/doscmd/tty.h | 68 | ||||
-rw-r--r-- | usr.bin/doscmd/video.c | 713 | ||||
-rw-r--r-- | usr.bin/doscmd/video.h | 448 | ||||
-rw-r--r-- | usr.bin/doscmd/vparams.h | 751 |
16 files changed, 3136 insertions, 1583 deletions
diff --git a/usr.bin/doscmd/Makefile b/usr.bin/doscmd/Makefile index 714b1eb..2400384 100644 --- a/usr.bin/doscmd/Makefile +++ b/usr.bin/doscmd/Makefile @@ -7,10 +7,10 @@ SRCS= AsyncIO.c ParseBuffer.c bios.c callback.c cpu.c dos.c cmos.c config.c \ cwd.c debug.c disktab.c doscmd.c ems.c emuint.c exe.c i386-pinsn.c \ int.c int10.c int13.c int14.c int16.c int17.c int1a.c int2f.c intff.c \ mem.c mouse.c net.c port.c setver.c signal.c timer.c trace.c trap.c \ - tty.c xms.c + tty.c video.c xms.c -CFLAGS+= -I. -DDISASSEMBLER -CLEANFILES= cp437-8x16.pcf.gz emsdriv.sys redir.com +CFLAGS+= -DDISASSEMBLER +CLEANFILES= ${FONTFILES} ${FONTHDRS} emsdriv.sys redir.com .if ${OBJFORMAT} == "aout" CLEANFILES+= doscmd.kernel crt0.o doscmd_loader.o @@ -35,6 +35,11 @@ DPADD+= ${XLIBDIR}/libX11.a CFLAGS+= -DNO_X .endif +FONTFILES= cp437-8x8.pcf.gz cp437-8x14.pcf.gz cp437-8x16.pcf.gz +FONTHDRS= font8x8.h font8x14.h font8x16.h + +beforedepend: ${FONTHDRS} + beforeinstall: .if ${OBJFORMAT} == "aout" ${INSTALL} ${COPY} -o ${BINOWN} -g ${EXEGRP} -m ${EXEMODE} \ @@ -43,10 +48,10 @@ beforeinstall: ${INSTALL} ${COPY} -o ${BINOWN} -g ${EXEGRP} -m ${EXEMODE} \ emsdriv.sys redir.com ${DESTDIR}/usr/libdata/doscmd/ ${INSTALL} ${COPY} -o ${BINOWN} -g ${EXEGRP} -m ${SHAREMODE} \ - cp437-8x16.pcf.gz ${DESTDIR}/usr/libdata/doscmd/fonts + ${FONTFILES} ${DESTDIR}/usr/libdata/doscmd/fonts cd ${.CURDIR} && \ ${INSTALL} ${COPY} -o ${BINOWN} -g ${EXEGRP} -m ${SHAREMODE} \ - fonts.dir ${DESTDIR}/usr/libdata/doscmd/fonts + fonts.alias fonts.dir ${DESTDIR}/usr/libdata/doscmd/fonts .if ${OBJFORMAT} == "aout" doscmd: ${LIBCRT0} doscmd_loader.o ${LIBGCC} ${LIBC} @@ -57,14 +62,32 @@ doscmd: ${LIBCRT0} doscmd_loader.o ${LIBGCC} ${LIBC} .depend: doscmd_loader.c # Bogus dependencies to get more than one binary created by `make all'. -doscmd: cp437-8x16.pcf.gz doscmd.kernel emsdriv.sys redir.com +doscmd: ${FONTFILES} ${FONTHDRS} doscmd.kernel emsdriv.sys redir.com .else -doscmd: cp437-8x16.pcf.gz emsdriv.sys redir.com +doscmd: ${FONTFILES} ${FONTHDRS} emsdriv.sys redir.com .endif +cp437-8x8.pcf.gz: cp437-8x8.pcf.gz.uu + uudecode ${.CURDIR}/cp437-8x8.pcf.gz.uu + +cp437-8x14.pcf.gz: cp437-8x14.pcf.gz.uu + uudecode ${.CURDIR}/cp437-8x14.pcf.gz.uu + cp437-8x16.pcf.gz: cp437-8x16.pcf.gz.uu uudecode ${.CURDIR}/cp437-8x16.pcf.gz.uu +font8x8.h: + uudecode -p /usr/src/share/syscons/fonts/cp437-8x8.fnt | \ + file2c 'u_int8_t font8x8[] = {' '};' > ${.TARGET} + +font8x14.h: + uudecode -p /usr/src/share/syscons/fonts/cp437-8x14.fnt | \ + file2c 'u_int8_t font8x14[] = {' '};' > ${.TARGET} + +font8x16.h: + uudecode -p /usr/src/share/syscons/fonts/cp437-8x16.fnt | \ + file2c 'u_int8_t font8x16[] = {' '};' > ${.TARGET} + emsdriv.sys: emsdriv.sys.uu uudecode ${.CURDIR}/emsdriv.sys.uu diff --git a/usr.bin/doscmd/cp437-8x14.pcf.gz.uu b/usr.bin/doscmd/cp437-8x14.pcf.gz.uu new file mode 100644 index 0000000..cd2f122 --- /dev/null +++ b/usr.bin/doscmd/cp437-8x14.pcf.gz.uu @@ -0,0 +1,113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G4ZETZET.I5.Z1^GTNE4.IU*IU/I<BI=3J7+J70YE2ZGTN54NJ2; +MG4J74^ER*EFGDG4J6:>2=2I9IY)U*EFGDA5O<2I9I]+M5+J=2K=3Z78JW4ZE +MVZET.Y5NI](M3J=>)V[7)G[7)H[7)I[7)J[7)K[7)L[7)M[7)N[7)GH3;BQZ +MZLCJR>K*ZLOJS.K-ZL[BST8<VD0:%Z(G/FW$J8UXM1&W-N+71AS;B&<;<6TC +MOFTR&FBB)^YMQ+^-.+@1#S?BXD9\W(B3&_%R(VYNVC5R14\\W8BK&_%U(\YN +MQ-N-N+L1?S?B\$8\WG3H4"!ZXO1&O-Z(VQOQ>R..;\3SC;B^$=\WXORF4\<6 +MT1/_-Q(`1B+`2`@8B0$C06`D"HR$@9$X,%TZ6(F>A(*16#`2#$:BP4@X&(D' +M(P%A)"*,A(3)ZN@G>A(51L+"2%P8"0PCD6$D-(S$AI'@,!(=IEN'4QU/94"5 +M^(@D/B*)CTCB(Y+XB"0^(HF/2.(CDOB(C`[0HB?Q$4E\1!(?D<1')/$127Q$ +M$A^1CO<ZX$^,^**G8[X.^CKJZ["OX[X._!(?D<1')/$1970*$3V)CTCB(Y+X +MB"0^(HF/2.(CDOB()#XBB8^H7><DT9/XB"0^(HF/2.(CDOB()#XBB8](XB.2 +6^(@Z=)+K`/[7_A\"WP<A_#T,0$(``)/X +` +end diff --git a/usr.bin/doscmd/cpu.c b/usr.bin/doscmd/cpu.c index c273084..e0d58a7 100644 --- a/usr.bin/doscmd/cpu.c +++ b/usr.bin/doscmd/cpu.c @@ -1,9 +1,42 @@ /* -** No copyright ?! -** -** $FreeBSD$ -*/ + * Copyright (c) 2001 The FreeBSD Project, Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY The FreeBSD Project, Inc. AND CONTRIBUTORS + * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL The FreeBSD Project, Inc. OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; + * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * $FreeBSD$ + */ + #include "doscmd.h" +#include "video.h" + +static u_int32_t decode_modrm(u_int8_t *, u_int16_t, regcontext_t *, int *); +static u_int8_t reg8(u_int8_t c, regcontext_t *); +static u_int16_t reg16(u_int8_t c, regcontext_t *); +#if 0 +static u_int32_t reg32(u_int8_t c, regcontext_t *); +#endif +static void write_byte(u_int32_t, u_int8_t); +static void write_word(u_int32_t, u_int16_t); /* ** Hardware /0 interrupt @@ -68,3 +101,241 @@ cpu_init(void) ivec[0x3e] = vec; /* floating point emulator */ ivec[0x3f] = vec; /* floating point emulator */ } + +/* + * Emulate CPU instructions. We need this for VGA graphics, at least in the 16 + * color modes. + * + * The emulator is far from complete. We are adding the instructions as we + * encounter them, so this function is likely to change over time. There are + * no optimizations and we only emulate a single instruction at a time. + * + * As long as there is no support for DPMI or the Operand Size Override prefix + * we won't need the 32-bit registers. This also means that the default + * operand size is 16 bit. + */ +int +emu_instr(regcontext_t *REGS) +{ + int prefix = 1; + u_int8_t *cs = (u_int8_t *)(R_CS << 4); + int ip = R_IP; + int instrlen; + int dir; + u_int16_t value; + u_int16_t seg = R_DS; + u_int32_t addr, endaddr; + + while (prefix) { + prefix = 0; + switch (cs[ip]) { + case 0x26: /* Segment Override ES */ + seg = R_ES; + prefix = 1; + ip++; + break; + case 0x2e: /* Segment Override CS */ + seg = R_CS; + prefix = 1; + ip++; + break; + case 0x36: /* Segment Override SS */ + seg = R_SS; + prefix = 1; + ip++; + break; + case 0x3e: /* Segment Override DS */ + seg = R_DS; + prefix = 1; + ip++; + break; + case 0x64: /* Segment Override FS */ + seg = R_FS; + prefix = 1; + ip++; + break; + case 0x65: /* Segment Override GS */ + seg = R_GS; + prefix = 1; + ip++; + break; + case 0x88: /* mov r/m8, r8 */ + addr = decode_modrm(cs + ip, seg, REGS, &instrlen); + write_byte(addr, reg8(cs[ip + 1], REGS)); + ip += 2 + instrlen; + break; + case 0xc6: /* mov r/m8, imm8 */ + addr = decode_modrm(cs + ip, seg, REGS, &instrlen); + write_byte(addr, cs[ip + 2 + instrlen]); + ip += 2 + instrlen + 1; + break; + case 0xc7: /* mov r/m32/16, imm32/16 */ + addr = decode_modrm(cs + ip, seg, REGS, &instrlen); + value = *(u_int16_t *)&cs[ip + 2 + instrlen]; + write_word(addr, value); + ip += 2 + instrlen + 2; + break; + case 0xab: /* stos m32/16*/ + break; + case 0xf3: /* rep */ + switch (cs[++ip]) { + case 0xab: /* stos m32/16 */ + value = R_AX; + /* direction */ + dir = (R_EFLAGS & PSL_D) ? -1 : 1; + addr = MAKEPTR(R_ES, R_DI); + endaddr = MAKEPTR(R_ES, R_DI) + dir * R_CX; + if (addr <= endaddr) + while (addr <= endaddr) { + write_word(addr, value); + addr += 2; + } + else + while (addr >= endaddr) { + write_word(addr, value); + addr -= 2; + } + ip += 2; + break; + default: + R_IP = ip--; /* Move IP back to the 'rep' instruction */ + return -1; + } + break; + default: + /* unknown instruction, get out of here and let trap.c:sigbus() + catch it. */ + return -1; + } + R_IP = ip; + } + + return 0; +} + +/* Decode the ModR/M byte. Returns the memory address of the operand. 'c' + points to the current instruction, 'seg' contains the value for the current + base segment; this is usually 'DS', but may have been changed by a segment + override prefix. We return the length of the current instruction in + 'instrlen' so we can adjust 'IP' on return. + + XXX We will probably need a second function for 32-bit instructions. + + XXX We do not check for undefined combinations, like Mod=01, R/M=001. */ +static u_int32_t +decode_modrm(u_int8_t *c, u_int16_t seg, regcontext_t *REGS, int *instrlen) +{ + u_int32_t addr = 0; /* absolute address */ + int16_t dspl = 0; /* displacement, signed */ + *instrlen = 0; + + switch (c[1] & 0xc0) { /* decode Mod */ + case 0x00: /* DS:[reg] */ + /* 'reg' is selected in the R/M bits */ + break; + case 0x40: /* 8 bit displacement */ + dspl = (int16_t)(int8_t)c[2]; + *instrlen = 1; + break; + case 0x80: /* 16 bit displacement */ + dspl = *(int16_t *)&c[2]; + *instrlen = 2; + break; + case 0xc0: /* reg in R/M */ + if (c[0] & 1) /* 16-bit reg */ + return reg16(c[1], REGS); + else /* 8-bit reg */ + return reg8(c[1], REGS); + break; + } + + switch (c[1] & 0x07) { /* decode R/M */ + case 0x00: + addr = MAKEPTR(seg, R_BX + R_SI); + break; + case 0x01: + addr = MAKEPTR(seg, R_BX + R_DI); + break; + case 0x02: + addr = MAKEPTR(seg, R_BP + R_SI); + break; + case 0x03: + addr = MAKEPTR(seg, R_BP + R_DI); + break; + case 0x04: + addr = MAKEPTR(seg, R_SI); + break; + case 0x05: + addr = MAKEPTR(seg, R_DI); + break; + case 0x06: + if ((c[1] & 0xc0) >= 0x40) + addr += R_BP; + else { + addr = MAKEPTR(seg, *(int16_t *)&c[2]); + *instrlen = 2; + } + break; + case 0x07: + addr = MAKEPTR(seg, R_BX + dspl); + break; + } + + return addr; +} + +static u_int8_t +reg8(u_int8_t c, regcontext_t *REGS) +{ + u_int8_t r8[] = {R_AL, R_CL, R_DL, R_BL, R_AH, R_CH, R_DH, R_BH}; + + /* select 'rrr' bits in ModR/M */ + return r8[(c & 0x34) >> 3]; +} + +static u_int16_t +reg16(u_int8_t c, regcontext_t *REGS) +{ + u_int16_t r16[] = {R_AX, R_CX, R_DX, R_BX, R_SP, R_BP, R_SI, R_DI}; + + return r16[(c & 0x34) >> 3]; +} + +#if 0 +/* not yet */ +static u_int32_t +reg32(u_int8_t c, regcontext_t *REGS) +{ + u_int32_t r32[] = {R_EAX, R_ECX, R_EDX, R_EBX, + R_ESP, R_EBP, R_ESI, R_EDI}; + + return r32[(c & 0x34) >> 3]; +} +#endif + +/* Write an 8-bit value to the location specified by 'addr'. If 'addr' lies + within the video memory region, we call video.c:vga_write(). */ +static void +write_byte(u_int32_t addr, u_int8_t val) +{ + if (addr >= 0xa0000 && addr < 0xb0000) { + vga_write(addr, val); + } else + *(u_int8_t *)addr = val; + + return; +} + +/* Write a 16-bit value to the location specified by 'addr'. If 'addr' lies + within the video memory region, we call video.c:vga_write(). */ +static void +write_word(u_int32_t addr, u_int16_t val) +{ + if (addr >= 0xa0000 && addr < 0xb0000) { + vga_write(addr, (u_int8_t)(val & 0xff)); + vga_write(addr + 1, (u_int8_t)((val & 0xff00) >> 8)); + } else + *(u_int16_t *)addr = val; + + return; +} diff --git a/usr.bin/doscmd/doscmd.1 b/usr.bin/doscmd/doscmd.1 index e9253bd..34f0215 100644 --- a/usr.bin/doscmd/doscmd.1 +++ b/usr.bin/doscmd/doscmd.1 @@ -38,7 +38,7 @@ .Nd run a subset of real-mode DOS programs .Sh SYNOPSIS .Nm -.Fl 23AbDEfHIMOPRrtVvXxYz +.Fl 23AbDEfGHIMOPRrtVvXxYz .Fl c Ar file .Fl d Ar file .Fl i Ar port Ns Xo @@ -138,6 +138,11 @@ Enable debugging of the exec routines. .\" .\" .\" +.It Fl G +Enable debugging of the video (graphics) routines. +.\" +.\" +.\" .It Fl H Enable tracing of half implemented calls. .\" diff --git a/usr.bin/doscmd/doscmd.c b/usr.bin/doscmd/doscmd.c index 9aaf730..864a647 100644 --- a/usr.bin/doscmd/doscmd.c +++ b/usr.bin/doscmd/doscmd.c @@ -37,6 +37,8 @@ #include <sys/mman.h> #include <sys/time.h> +#include <ctype.h> +#include <err.h> #include <errno.h> #include <limits.h> #include <paths.h> @@ -52,6 +54,10 @@ #include <machine/vm86.h> #include "doscmd.h" +#include "cwd.h" +#include "trap.h" +#include "tty.h" +#include "video.h" /* exports */ int capture_fd = -1; @@ -61,7 +67,7 @@ int booting = 0; int raw_kbd = 0; int timer_disable = 0; struct timeval boot_time; -unsigned long *ivec = (unsigned long *)0; +unsigned long *ivec = (unsigned long *)0; u_long pending[256]; /* pending interrupts */ int n_pending; @@ -85,7 +91,6 @@ static FILE *find_doscmdrc(void); static int do_args(int argc, char *argv[]); static void usage(void); static int open_name(char *name, char *ext); -static void init_iomap(void); /* Local option flags &c. */ static int zflag = 0; @@ -113,9 +118,6 @@ main(int argc, char **argv) regcontext_t *REGS = (regcontext_t *)&uc.uc_mcontext; int fd; int i; - char buffer[4096]; - FILE *fp; - /* XXX should only be for tty mode */ fd = open (_PATH_DEVNULL, O_RDWR); @@ -202,16 +204,16 @@ main(int argc, char **argv) } /* install signal handlers */ - setsignal (SIGFPE, sigfpe); /* */ - setsignal (SIGALRM, sigalrm); /* */ - setsignal (SIGILL, sigill); /* */ - setsignal (SIGTRAP, sigtrap); /* */ - setsignal (SIGUSR2, sigtrace); /* */ - setsignal (SIGINFO, sigtrace); /* */ + setsignal(SIGFPE, sigfpe); /* */ + setsignal(SIGALRM, sigalrm); /* */ + setsignal(SIGILL, sigill); /* */ + setsignal(SIGTRAP, sigtrap); /* */ + setsignal(SIGUSR2, sigtrace); /* */ + setsignal(SIGINFO, sigtrace); /* */ #ifdef USE_VM86 - setsignal (SIGURG, sigurg); /* entry from NetBSD vm86 */ + setsignal(SIGURG, sigurg); /* entry from NetBSD vm86 */ #else - setsignal (SIGBUS, sigbus); /* entry from FreeBSD, BSD/OS vm86 */ + setsignal(SIGBUS, sigbus); /* entry from FreeBSD, BSD/OS vm86 */ #endif /* Call init functions */ @@ -220,6 +222,8 @@ main(int argc, char **argv) init_io_port_handlers(); bios_init(); cpu_init(); + kbd_init(); + kbd_bios_init(); video_init(); if (xmode) mouse_init(); @@ -285,6 +289,8 @@ main(int argc, char **argv) if (vflag) dump_regs(REGS); fatal ("vm86 returned (no kernel support?)\n"); #undef sc + /* quiet -Wall */ + return 0; } /* @@ -342,19 +348,19 @@ setup_boot(regcontext_t *REGS) ** try to read the boot sector from the specified disk */ static int -try_boot(int booting) +try_boot(int bootdrv) { int fd; - fd = disk_fd(booting); + fd = disk_fd(bootdrv); if (fd < 0) { /* can we boot it? */ - debug(D_DISK, "Cannot boot from %c\n", drntol(booting)); + debug(D_DISK, "Cannot boot from %c\n", drntol(bootdrv)); return -1; } /* read bootblock */ if (read(fd, (char *)0x7c00, 512) != 512) { - debug(D_DISK, "Short read on boot block from %c:\n", drntol(booting)); + debug(D_DISK, "Short read on boot block from %c:\n", drntol(bootdrv)); return -1; } @@ -472,7 +478,6 @@ find_doscmdrc(void) { FILE *fp; char buffer[4096]; - int fd; if ((fp = fopen(".doscmdrc", "r")) == NULL) { struct passwd *pwd = getpwuid(geteuid()); @@ -505,10 +510,10 @@ do_args(int argc, char *argv[]) FILE *fp; char *col; - while ((c = getopt (argc, argv, "234Oc:TkCIEMPRLAU:S:HDtzvVxXYfbri:o:p:d:")) != -1) { + while ((c = getopt (argc, argv, "234Oc:TkCIEGMPRLAU:S:HDtzvVxXYfbri:o:p:d:")) != -1) { switch (c) { case 'd': - if (fp = fopen(optarg, "w")) { + if ((fp = fopen(optarg, "w")) != 0) { debugf = fp; setbuf (fp, NULL); } else @@ -535,7 +540,7 @@ do_args(int argc, char *argv[]) break; case 'i': i = 1; - if (col = strchr(optarg, ':')) { + if ((col = strchr(optarg, ':')) != 0) { *col++ = 0; i = strtol(col, 0, 0); } @@ -547,7 +552,7 @@ do_args(int argc, char *argv[]) break; case 'o': i = 1; - if (col = strchr(optarg, ':')) { + if ((col = strchr(optarg, ':')) != 0) { *col++ = 0; i = strtol(col, 0, 0); } @@ -559,7 +564,7 @@ do_args(int argc, char *argv[]) break; case 'p': i = 1; - if (col = strchr(optarg, ':')) { + if ((col = strchr(optarg, ':')) != 0) { *col++ = 0; i = strtol(col, 0, 0); } @@ -589,6 +594,9 @@ do_args(int argc, char *argv[]) case 'E': debug_flags |= D_EXEC; break; + case 'G': + debug_flags |= D_VIDEO; + break; case 'C': debug_flags |= D_DOSCALL; break; diff --git a/usr.bin/doscmd/doscmd.h b/usr.bin/doscmd/doscmd.h index 8d5af631..d2cfc47 100644 --- a/usr.bin/doscmd/doscmd.h +++ b/usr.bin/doscmd/doscmd.h @@ -63,7 +63,6 @@ #include "register.h" #include "dos.h" #include "callback.h" -#include "cwd.h" #define drlton(a) ((islower((a)) ? toupper((a)) : (a)) - 'A') #define drntol(a) ((a) + 'A') @@ -88,6 +87,34 @@ struct vconnect_area { extern struct vconnect_area vconnect_area; #define IntState vconnect_area.int_state +/* ParseBuffer.c */ +extern int ParseBuffer(char *, char **, int); + +/* bios.c */ +#define BIOSDATA ((u_char *)0x400) +extern unsigned long rom_config; +extern int nfloppies; +extern int ndisks; +extern int nserial; +extern int nparallel; + +extern volatile int poll_cnt; +extern void bios_init(void); +extern void wakeup_poll(void); +extern void reset_poll(void); +extern void sleep_poll(void); + +/* cmos.c */ +extern time_t delta_clock; + +extern void cmos_init(void); + +/* config.c */ +extern int read_config(FILE *fp); + +/* cpu.c */ +extern void cpu_init(void); +extern int emu_instr(regcontext_t *); /* debug.c */ extern int vflag; @@ -100,7 +127,7 @@ extern int debug_flags; #define D_TRAPS 0x0000200 /* trap-related activity */ #define D_FILE_OPS 0x0000400 /* file-related activity */ #define D_MEMORY 0x0000800 /* memory-related activity */ -#define D_HALF 0x0001000 /* for "half-implemented" system calls */ +#define D_HALF 0x0001000 /* "half-implemented" system calls */ #define D_FLOAT 0x0002000 /* ??? */ #define D_DISK 0x0004000 /* disk (not file) operations */ #define D_TRAPS2 0x0008000 @@ -114,6 +141,7 @@ extern int debug_flags; #define D_DOSCALL 0x0800000 /* MS-DOS function results */ #define D_XMS 0x1000000 /* XMS calls */ #define D_EMS 0x2000000 /* EMS calls */ +#define D_VIDEO 0x4000000 /* video-related activity */ #define TTYF_ECHO 0x00000001 #define TTYF_ECHONL 0x00000003 @@ -135,7 +163,12 @@ extern void debug_set(int x); extern void debug_unset(int x); extern u_long debug_isset(int x); +/* disktab.c */ +extern int map_type(int, int *, int *, int *); + /* doscmd.c */ +extern int squirrel_fd(int); + extern int capture_fd; extern int dead; extern int xmode; @@ -151,58 +184,18 @@ extern void done(regcontext_t *REGS, int val); extern void quit(int); extern void call_on_quit(void (*)(void *), void *); extern void iomap_port(int port, int count); - -/* signal.c */ -extern struct sigframe *saved_sigframe; -extern regcontext_t *saved_regcontext; -extern int saved_valid; -extern void setsignal(int s, void (*h)(struct sigframe *)); -/* cmos.c */ -extern time_t delta_clock; - -extern void cmos_init(void); - -/* config.c */ -extern int read_config(FILE *fp); - -/* tty.c */ -extern char *xfont; - -/* setver.c */ -extern void setver(char *, short); -extern short getver(char *); - -/* mem.c */ -extern char *dosmem; - -extern void mem_init(void); -extern int mem_alloc(int size, int owner, int *biggestp); -extern int mem_adjust(int addr, int size, int *availp); -extern void mem_free_owner(int owner); -extern void mem_change_owner(int addr, int owner); - - -/* intff.c */ -extern int int2f_11(regcontext_t *REGS); -extern void intff(regcontext_t *REGS); +/* ems.c */ +extern int ems_init(); +extern void ems_entry(regcontext_t *REGS); +extern u_long ems_frame_addr; /* emuint.c */ extern void emuint(regcontext_t *REGS); -/* trap.c */ -extern void fake_int(regcontext_t *REGS, int); -extern void sigtrap(struct sigframe *sf); -extern void sigtrace(struct sigframe *sf); -extern void sigalrm(struct sigframe *sf); -extern void sigill(struct sigframe *sf); -extern void sigfpe(struct sigframe *sf); -extern void breakpoint(struct sigframe *sf); -#ifdef USE_VM86 -extern void sigurg(struct sigframe *sf); -#else -extern void sigbus(struct sigframe *sf); -#endif +/* i386-pinsn.c */ +extern int i386dis(unsigned short, unsigned short, + unsigned char *, char *, int); /* int.c */ extern void softint(int intnum); @@ -211,19 +204,8 @@ extern void hardint(int intnum); extern void delay_interrupt(int intnum, void (*func)(int)); extern void resume_interrupt(void); - -/* bios.c */ -#define BIOSDATA ((u_char *)0x400) -extern unsigned long rom_config; -extern int nfloppies; -extern int ndisks; -extern int nserial; -extern int nparallel; - -extern volatile int poll_cnt; -extern void wakeup_poll(void); -extern void reset_poll(void); -extern void sleep_poll(void); +/* int10.c */ +extern void int10(regcontext_t *); /* int13.c */ extern int init_hdisk(int drive, int cyl, int head, int tracksize, @@ -240,55 +222,71 @@ extern void printer_direct(int printer); extern void printer_spool(int printer, char *print_queue); extern void printer_timeout(int printer, char *time_out); -/* xms.c */ -extern int int2f_43(regcontext_t *REGS); -extern void get_raw_extmemory_info(regcontext_t *REGS); -extern void initHMA(void); -extern u_long xms_maxsize; +/* int2f.c */ +extern void int2f(regcontext_t *); -/* ems.c */ -extern int ems_init(); -extern void ems_entry(regcontext_t *REGS); -extern u_long ems_frame_addr; +/* intff.c */ +extern int int2f_11(regcontext_t *REGS); +extern void intff(regcontext_t *REGS); -/****************************** dirty below here ******************************/ +/* mem.c */ +extern char *dosmem; -extern u_long pending[]; /* pending interrupts */ -extern int n_pending; +extern void mem_init(void); +extern int mem_alloc(int size, int owner, int *biggestp); +extern int mem_adjust(int addr, int size, int *availp); +extern void mem_free_owner(int owner); +extern void mem_change_owner(int addr, int owner); -u_char *VREG; +/* mouse.c */ +extern void mouse_init(void); + +/* net.c */ +extern void net_init(void); + +/* port.c */ +extern void define_input_port_handler(int, unsigned char (*)(int)); +extern void define_output_port_handler(int, void (*)(int, unsigned char)); +extern void inb(regcontext_t *, int); +extern void init_io_port_handlers(void); +extern void inx(regcontext_t *, int); +extern void outb(regcontext_t *, int); +extern void outx(regcontext_t *, int); +extern void speaker_init(void); +extern void outb_traceport(int, unsigned char); +extern unsigned char inb_traceport(int); +extern void outb_port(int, unsigned char); +extern unsigned char inb_port(int); -extern int nmice; +/* setver.c */ +extern void setver(char *, short); +extern short getver(char *); + +/* signal.c */ +extern struct sigframe *saved_sigframe; +extern regcontext_t *saved_regcontext; +extern int saved_valid; +extern void setsignal(int s, void (*h)(struct sigframe *)); -extern int redirect0; -extern int redirect1; -extern int redirect2; -extern int kbd_fd; -extern int jmp_okay; +/* timer.c */ +extern void timer_init(void); +/* trace.c */ +extern int resettrace(regcontext_t *); +extern void tracetrap(regcontext_t *); +/* xms.c */ +extern void get_raw_extmemory_info(regcontext_t *REGS); +extern int int2f_43(regcontext_t *REGS); +extern void initHMA(void); +extern void xms_init(void); +extern u_long xms_maxsize; -void put_dosenv(char *value); +/****************************** dirty below here *****************************/ +extern u_long pending[]; /* pending interrupts */ +extern int n_pending; -/* TTY subsystem XXX rewrite! */ -int tty_eread(REGISTERS, int, int); -void tty_write(int, int); -void tty_rwrite(int, int, int); -void tty_move(int, int); -void tty_report(int *, int *); -void tty_flush(); -void tty_index(); -void tty_pause(); -int tty_peek(REGISTERS, int); -int tty_state(); -void tty_scroll(int, int, int, int, int, int); -void tty_rscroll(int, int, int, int, int, int); -int tty_char(int, int); -void video_setborder(int); - -void outb_traceport(int, unsigned char); -unsigned char inb_traceport(int); -void outb_port(int, unsigned char); -unsigned char inb_port(int); +extern int nmice; +void put_dosenv(char *value); diff --git a/usr.bin/doscmd/font.h b/usr.bin/doscmd/font.h deleted file mode 100644 index dc1478a..0000000 --- a/usr.bin/doscmd/font.h +++ /dev/null @@ -1,407 +0,0 @@ -/* - * Copyright (c) 1992, 1993, 1996 - * Berkeley Software Design, Inc. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by Berkeley Software - * Design, Inc. - * - * THIS SOFTWARE IS PROVIDED BY Berkeley Software Design, Inc. ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL Berkeley Software Design, Inc. BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * BSDI font.h,v 2.2 1996/04/08 19:32:35 bostic Exp - */ - -unsigned char ascii_font[] = { - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7e, 0x81, 0xa5, 0x81, - 0x81, 0xbd, 0x99, 0x81, 0x81, 0x7e, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x7e, 0xff, 0xdb, 0xff, 0xff, 0xc3, 0xe7, 0xff, 0xff, 0x7e, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x6c, 0xfe, 0xfe, - 0xfe, 0xfe, 0x7c, 0x38, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x10, 0x38, 0x7c, 0xfe, 0x7c, 0x38, 0x10, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x3c, 0x3c, 0xe7, 0xe7, - 0xe7, 0x99, 0x18, 0x3c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x18, 0x3c, 0x7e, 0xff, 0xff, 0x7e, 0x18, 0x18, 0x3c, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x3c, 0x3c, - 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xe7, 0xc3, 0xc3, 0xe7, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3c, 0x66, 0x42, 0x42, 0x66, - 0x3c, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xc3, 0x99, 0xbd, 0xbd, 0x99, 0xc3, 0xff, 0xff, 0xff, 0xff, 0xff, - 0x00, 0x00, 0x1e, 0x0e, 0x1a, 0x32, 0x78, 0xcc, 0xcc, 0xcc, 0xcc, - 0x78, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3c, 0x66, 0x66, 0x66, - 0x66, 0x3c, 0x18, 0x7e, 0x18, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x3f, 0x33, 0x3f, 0x30, 0x30, 0x30, 0x30, 0x70, 0xf0, 0xe0, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7f, 0x63, 0x7f, 0x63, 0x63, - 0x63, 0x63, 0x67, 0xe7, 0xe6, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x18, 0x18, 0xdb, 0x3c, 0xe7, 0x3c, 0xdb, 0x18, 0x18, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x80, 0xc0, 0xe0, 0xf0, 0xf8, 0xfe, 0xf8, - 0xf0, 0xe0, 0xc0, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x06, - 0x0e, 0x1e, 0x3e, 0xfe, 0x3e, 0x1e, 0x0e, 0x06, 0x02, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x18, 0x3c, 0x7e, 0x18, 0x18, 0x18, 0x18, - 0x7e, 0x3c, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x66, 0x66, - 0x66, 0x66, 0x66, 0x66, 0x66, 0x00, 0x66, 0x66, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x7f, 0xdb, 0xdb, 0xdb, 0x7b, 0x1b, 0x1b, 0x1b, - 0x1b, 0x1b, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7c, 0xc6, 0x60, 0x38, - 0x6c, 0xc6, 0xc6, 0x6c, 0x38, 0x0c, 0xc6, 0x7c, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfe, 0xfe, 0xfe, - 0xfe, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x3c, 0x7e, 0x18, - 0x18, 0x18, 0x18, 0x7e, 0x3c, 0x18, 0x7e, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x18, 0x3c, 0x7e, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x18, 0x18, 0x18, 0x18, - 0x18, 0x18, 0x7e, 0x3c, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x18, 0x0c, 0xfe, 0x0c, 0x18, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x60, 0xfe, - 0x60, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0xc0, 0xc0, 0xc0, 0xc0, 0xfe, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x28, 0x6c, 0xfe, 0x6c, - 0x28, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x10, 0x38, 0x38, 0x7c, 0x7c, 0xfe, 0xfe, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0xfe, 0xfe, 0x7c, 0x7c, 0x38, 0x38, - 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x18, 0x3c, 0x3c, 0x3c, 0x18, 0x18, 0x18, 0x00, 0x18, - 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x66, 0x66, 0x66, 0x24, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x6c, 0x6c, 0xfe, 0x6c, 0x6c, 0x6c, 0xfe, 0x6c, 0x6c, - 0x00, 0x00, 0x00, 0x00, 0x18, 0x18, 0x7c, 0xc6, 0xc2, 0xc0, 0x7c, - 0x06, 0x86, 0xc6, 0x7c, 0x18, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0xc2, 0xc6, 0x0c, 0x18, 0x30, 0x60, 0xc6, 0x86, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x38, 0x6c, 0x6c, 0x38, 0x76, 0xdc, - 0xcc, 0xcc, 0xcc, 0x76, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x30, - 0x30, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x0c, 0x18, 0x30, 0x30, 0x30, 0x30, 0x30, - 0x30, 0x18, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x18, - 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x18, 0x30, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x66, 0x3c, 0xff, 0x3c, 0x66, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x18, 0x18, 0x7e, 0x18, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x18, - 0x18, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0xfe, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x18, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x06, 0x0c, - 0x18, 0x30, 0x60, 0xc0, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x7c, 0xc6, 0xc6, 0xce, 0xd6, 0xd6, 0xe6, 0xc6, 0xc6, 0x7c, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x38, 0x78, 0x18, 0x18, 0x18, - 0x18, 0x18, 0x18, 0x7e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7c, - 0xc6, 0x06, 0x0c, 0x18, 0x30, 0x60, 0xc0, 0xc6, 0xfe, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x7c, 0xc6, 0x06, 0x06, 0x3c, 0x06, 0x06, - 0x06, 0xc6, 0x7c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0c, 0x1c, - 0x3c, 0x6c, 0xcc, 0xfe, 0x0c, 0x0c, 0x0c, 0x1e, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0xfe, 0xc0, 0xc0, 0xc0, 0xfc, 0x0e, 0x06, 0x06, - 0xc6, 0x7c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x38, 0x60, 0xc0, - 0xc0, 0xfc, 0xc6, 0xc6, 0xc6, 0xc6, 0x7c, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0xfe, 0xc6, 0x06, 0x06, 0x0c, 0x18, 0x30, 0x30, 0x30, - 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7c, 0xc6, 0xc6, 0xc6, - 0x7c, 0xc6, 0xc6, 0xc6, 0xc6, 0x7c, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x7c, 0xc6, 0xc6, 0xc6, 0x7e, 0x06, 0x06, 0x06, 0x0c, 0x78, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x18, 0x00, - 0x00, 0x00, 0x18, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x18, 0x18, 0x00, 0x00, 0x00, 0x18, 0x18, 0x30, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x0c, 0x18, 0x30, 0x60, - 0x30, 0x18, 0x0c, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0xfe, 0x00, 0x00, 0xfe, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x60, 0x30, 0x18, 0x0c, 0x06, 0x0c, - 0x18, 0x30, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7c, 0xc6, - 0xc6, 0x0c, 0x18, 0x18, 0x18, 0x00, 0x18, 0x18, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x7c, 0xc6, 0xc6, 0xde, 0xde, 0xde, 0xdc, - 0xc0, 0x7c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x38, 0x6c, - 0xc6, 0xc6, 0xfe, 0xc6, 0xc6, 0xc6, 0xc6, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0xfc, 0x66, 0x66, 0x66, 0x7c, 0x66, 0x66, 0x66, 0x66, - 0xfc, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3c, 0x66, 0xc2, 0xc0, - 0xc0, 0xc0, 0xc0, 0xc2, 0x66, 0x3c, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0xf8, 0x6c, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x6c, 0xf8, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfe, 0x66, 0x62, 0x68, 0x78, - 0x68, 0x60, 0x62, 0x66, 0xfe, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0xfe, 0x66, 0x62, 0x68, 0x78, 0x68, 0x60, 0x60, 0x60, 0xf0, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x3c, 0x66, 0xc2, 0xc0, 0xc0, 0xde, - 0xc6, 0xc6, 0x66, 0x3a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc6, - 0xc6, 0xc6, 0xc6, 0xfe, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x3c, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, - 0x18, 0x18, 0x3c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1e, 0x0c, - 0x0c, 0x0c, 0x0c, 0x0c, 0xcc, 0xcc, 0xcc, 0x78, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0xe6, 0x66, 0x6c, 0x6c, 0x78, 0x78, 0x6c, 0x66, - 0x66, 0xe6, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf0, 0x60, 0x60, - 0x60, 0x60, 0x60, 0x60, 0x62, 0x66, 0xfe, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0xc6, 0xee, 0xfe, 0xfe, 0xd6, 0xc6, 0xc6, 0xc6, 0xc6, - 0xc6, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc6, 0xe6, 0xf6, 0xfe, - 0xde, 0xce, 0xc6, 0xc6, 0xc6, 0xc6, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x38, 0x6c, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0x6c, 0x38, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfc, 0x66, 0x66, 0x66, 0x7c, - 0x60, 0x60, 0x60, 0x60, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x7c, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xd6, 0xde, 0x7c, 0x0c, - 0x0e, 0x00, 0x00, 0x00, 0x00, 0xfc, 0x66, 0x66, 0x66, 0x7c, 0x6c, - 0x66, 0x66, 0x66, 0xe6, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7c, - 0xc6, 0xc6, 0x60, 0x38, 0x0c, 0x06, 0xc6, 0xc6, 0x7c, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x7e, 0x7e, 0x5a, 0x18, 0x18, 0x18, 0x18, - 0x18, 0x18, 0x3c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc6, 0xc6, - 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0x7c, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0x6c, - 0x38, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc6, 0xc6, 0xc6, - 0xc6, 0xc6, 0xd6, 0xd6, 0xfe, 0x6c, 0x6c, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0xc6, 0xc6, 0x6c, 0x6c, 0x38, 0x38, 0x6c, 0x6c, 0xc6, - 0xc6, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x66, 0x66, 0x66, 0x66, - 0x3c, 0x18, 0x18, 0x18, 0x18, 0x3c, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0xfe, 0xc6, 0x86, 0x0c, 0x18, 0x30, 0x60, 0xc2, 0xc6, 0xfe, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3c, 0x30, 0x30, 0x30, 0x30, - 0x30, 0x30, 0x30, 0x30, 0x3c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x80, 0xc0, 0xe0, 0x70, 0x38, 0x1c, 0x0e, 0x06, 0x02, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x3c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, - 0x0c, 0x0c, 0x0c, 0x3c, 0x00, 0x00, 0x00, 0x00, 0x10, 0x38, 0x6c, - 0xc6, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x30, 0x30, 0x18, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x78, 0x0c, 0x7c, 0xcc, 0xcc, - 0xcc, 0x76, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe0, 0x60, 0x60, - 0x78, 0x6c, 0x66, 0x66, 0x66, 0x66, 0xdc, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x7c, 0xc6, 0xc0, 0xc0, 0xc0, 0xc6, - 0x7c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1c, 0x0c, 0x0c, 0x3c, - 0x6c, 0xcc, 0xcc, 0xcc, 0xcc, 0x76, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x7c, 0xc6, 0xfe, 0xc0, 0xc0, 0xc6, 0x7c, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x38, 0x6c, 0x64, 0x60, 0xf0, - 0x60, 0x60, 0x60, 0x60, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x76, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0x7c, 0x0c, - 0xcc, 0x78, 0x00, 0x00, 0x00, 0xe0, 0x60, 0x60, 0x6c, 0x76, 0x66, - 0x66, 0x66, 0x66, 0xe6, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, - 0x18, 0x00, 0x38, 0x18, 0x18, 0x18, 0x18, 0x18, 0x3c, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x06, 0x06, 0x00, 0x0e, 0x06, 0x06, 0x06, - 0x06, 0x06, 0x06, 0x66, 0x66, 0x3c, 0x00, 0x00, 0x00, 0xe0, 0x60, - 0x60, 0x66, 0x6c, 0x78, 0x78, 0x6c, 0x66, 0xe6, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x38, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, - 0x18, 0x3c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0xec, 0xfe, 0xd6, 0xd6, 0xd6, 0xd6, 0xd6, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0xdc, 0x66, 0x66, 0x66, 0x66, 0x66, - 0x66, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7c, - 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0x7c, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0xdc, 0x66, 0x66, 0x66, 0x66, 0x66, 0x7c, - 0x60, 0x60, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x76, 0xcc, - 0xcc, 0xcc, 0xcc, 0xcc, 0x7c, 0x0c, 0x0c, 0x1e, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0xdc, 0x76, 0x62, 0x60, 0x60, 0x60, 0xf0, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7c, 0xc6, 0x60, - 0x38, 0x0c, 0xc6, 0x7c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, - 0x30, 0x30, 0xfc, 0x30, 0x30, 0x30, 0x30, 0x36, 0x1c, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc, 0xcc, - 0xcc, 0xcc, 0x76, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x66, 0x66, 0x66, 0x66, 0x66, 0x3c, 0x18, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc6, 0xc6, 0xc6, 0xd6, 0xd6, - 0xfe, 0x6c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0xc6, 0x6c, 0x38, 0x38, 0x38, 0x6c, 0xc6, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, - 0x7e, 0x06, 0x0c, 0xf8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfe, - 0xcc, 0x18, 0x30, 0x60, 0xc6, 0xfe, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x0e, 0x18, 0x18, 0x18, 0x70, 0x18, 0x18, 0x18, 0x18, 0x0e, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x18, 0x18, 0x18, 0x00, - 0x18, 0x18, 0x18, 0x18, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x70, 0x18, 0x18, 0x18, 0x0e, 0x18, 0x18, 0x18, 0x18, 0x70, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x76, 0xdc, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x10, 0x38, 0x6c, 0xc6, 0xc6, 0xc6, 0xfe, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x3c, 0x66, 0xc2, 0xc0, 0xc0, 0xc0, 0xc2, - 0x66, 0x3c, 0x0c, 0x06, 0x7c, 0x00, 0x00, 0x00, 0x00, 0xcc, 0xcc, - 0x00, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0x76, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x0c, 0x18, 0x30, 0x00, 0x7c, 0xc6, 0xfe, 0xc0, 0xc0, - 0xc6, 0x7c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x38, 0x6c, 0x00, - 0x78, 0x0c, 0x7c, 0xcc, 0xcc, 0xcc, 0x76, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0xcc, 0xcc, 0x00, 0x78, 0x0c, 0x7c, 0xcc, 0xcc, 0xcc, - 0x76, 0x00, 0x00, 0x00, 0x00, 0x00, 0x60, 0x30, 0x18, 0x00, 0x78, - 0x0c, 0x7c, 0xcc, 0xcc, 0xcc, 0x76, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x38, 0x6c, 0x38, 0x00, 0x78, 0x0c, 0x7c, 0xcc, 0xcc, 0xcc, 0x76, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3c, 0x66, 0x60, - 0x60, 0x66, 0x3c, 0x0c, 0x06, 0x3c, 0x00, 0x00, 0x00, 0x00, 0x10, - 0x38, 0x6c, 0x00, 0x7c, 0xc6, 0xfe, 0xc0, 0xc0, 0xc6, 0x7c, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0xc6, 0xc6, 0x00, 0x7c, 0xc6, 0xfe, - 0xc0, 0xc0, 0xc6, 0x7c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x60, 0x30, - 0x18, 0x00, 0x7c, 0xc6, 0xfe, 0xc0, 0xc0, 0xc6, 0x7c, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x66, 0x66, 0x00, 0x38, 0x18, 0x18, 0x18, - 0x18, 0x18, 0x3c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x3c, 0x66, - 0x00, 0x38, 0x18, 0x18, 0x18, 0x18, 0x18, 0x3c, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x60, 0x30, 0x18, 0x00, 0x38, 0x18, 0x18, 0x18, 0x18, - 0x18, 0x3c, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc6, 0xc6, 0x10, 0x38, - 0x6c, 0xc6, 0xc6, 0xfe, 0xc6, 0xc6, 0xc6, 0x00, 0x00, 0x00, 0x00, - 0x38, 0x6c, 0x38, 0x00, 0x38, 0x6c, 0xc6, 0xc6, 0xfe, 0xc6, 0xc6, - 0xc6, 0x00, 0x00, 0x00, 0x00, 0x18, 0x30, 0x60, 0x00, 0xfe, 0x66, - 0x60, 0x7c, 0x60, 0x60, 0x66, 0xfe, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0xcc, 0x76, 0x36, 0x7e, 0xd8, 0xd8, 0x6e, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3e, 0x6c, 0xcc, 0xcc, 0xfe, - 0xcc, 0xcc, 0xcc, 0xcc, 0xce, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, - 0x38, 0x6c, 0x00, 0x7c, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0x7c, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0xc6, 0xc6, 0x00, 0x7c, 0xc6, 0xc6, - 0xc6, 0xc6, 0xc6, 0x7c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x60, 0x30, - 0x18, 0x00, 0x7c, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0x7c, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x30, 0x78, 0xcc, 0x00, 0xcc, 0xcc, 0xcc, 0xcc, - 0xcc, 0xcc, 0x76, 0x00, 0x00, 0x00, 0x00, 0x00, 0x60, 0x30, 0x18, - 0x00, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0x76, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0xc6, 0xc6, 0x00, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, - 0xc6, 0x7e, 0x06, 0x0c, 0x78, 0x00, 0x00, 0xc6, 0xc6, 0x00, 0x38, - 0x6c, 0xc6, 0xc6, 0xc6, 0xc6, 0x6c, 0x38, 0x00, 0x00, 0x00, 0x00, - 0x00, 0xc6, 0xc6, 0x00, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, - 0x7c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x18, 0x3c, 0x66, 0x60, - 0x60, 0x60, 0x66, 0x3c, 0x18, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x38, 0x6c, 0x64, 0x60, 0xf0, 0x60, 0x60, 0x60, 0x60, 0xe6, 0xfc, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x66, 0x66, 0x3c, 0x18, 0x7e, - 0x18, 0x7e, 0x18, 0x18, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf8, - 0xcc, 0xcc, 0xf8, 0xc4, 0xcc, 0xde, 0xcc, 0xcc, 0xcc, 0xc6, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x0e, 0x1b, 0x18, 0x18, 0x18, 0x7e, 0x18, - 0x18, 0x18, 0x18, 0x18, 0xd8, 0x70, 0x00, 0x00, 0x00, 0x18, 0x30, - 0x60, 0x00, 0x78, 0x0c, 0x7c, 0xcc, 0xcc, 0xcc, 0x76, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x0c, 0x18, 0x30, 0x00, 0x38, 0x18, 0x18, 0x18, - 0x18, 0x18, 0x3c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x30, 0x60, - 0x00, 0x7c, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0x7c, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x18, 0x30, 0x60, 0x00, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, - 0xcc, 0x76, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x76, 0xdc, 0x00, - 0xdc, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x00, 0x00, 0x00, 0x00, - 0x76, 0xdc, 0x00, 0xc6, 0xe6, 0xf6, 0xfe, 0xde, 0xce, 0xc6, 0xc6, - 0xc6, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3c, 0x6c, 0x6c, 0x3e, 0x00, - 0x7e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x38, 0x6c, 0x6c, 0x38, 0x00, 0x7c, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x30, 0x00, 0x30, 0x30, - 0x60, 0xc0, 0xc6, 0xc6, 0x7c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0xfe, 0xc0, 0xc0, 0xc0, 0xc0, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfe, 0x06, - 0x06, 0x06, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0xc0, - 0xc2, 0xc6, 0xcc, 0x18, 0x30, 0x60, 0xce, 0x93, 0x06, 0x0c, 0x1f, - 0x00, 0x00, 0x00, 0xc0, 0xc0, 0xc2, 0xc6, 0xcc, 0x18, 0x30, 0x66, - 0xce, 0x9a, 0x3f, 0x06, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x18, 0x18, - 0x00, 0x18, 0x18, 0x18, 0x3c, 0x3c, 0x3c, 0x18, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x33, 0x66, 0xcc, 0x66, 0x33, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0xcc, 0x66, 0x33, 0x66, 0xcc, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x11, 0x44, 0x11, 0x44, 0x11, 0x44, 0x11, 0x44, 0x11, 0x44, 0x11, - 0x44, 0x11, 0x44, 0x11, 0x44, 0x55, 0xaa, 0x55, 0xaa, 0x55, 0xaa, - 0x55, 0xaa, 0x55, 0xaa, 0x55, 0xaa, 0x55, 0xaa, 0x55, 0xaa, 0xdd, - 0x77, 0xdd, 0x77, 0xdd, 0x77, 0xdd, 0x77, 0xdd, 0x77, 0xdd, 0x77, - 0xdd, 0x77, 0xdd, 0x77, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, - 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, - 0x18, 0x18, 0x18, 0x18, 0x18, 0xf8, 0x18, 0x18, 0x18, 0x18, 0x18, - 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0xf8, 0x18, 0xf8, - 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x36, 0x36, 0x36, - 0x36, 0x36, 0x36, 0x36, 0xf6, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, - 0x36, 0x36, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfe, 0x36, - 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x00, 0x00, 0x00, 0x00, - 0x00, 0xf8, 0x18, 0xf8, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, - 0x18, 0x36, 0x36, 0x36, 0x36, 0x36, 0xf6, 0x06, 0xf6, 0x36, 0x36, - 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, - 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, - 0x00, 0x00, 0x00, 0x00, 0x00, 0xfe, 0x06, 0xf6, 0x36, 0x36, 0x36, - 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0xf6, - 0x06, 0xfe, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x36, - 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0xfe, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x18, 0x18, 0x18, 0x18, 0x18, 0xf8, 0x18, - 0xf8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0xf8, 0x18, 0x18, 0x18, 0x18, 0x18, - 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x1f, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x18, 0x18, - 0x18, 0x18, 0x18, 0x18, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x18, - 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, - 0x18, 0x18, 0x18, 0x1f, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, - 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x18, 0x18, 0x18, 0x18, - 0x18, 0x18, 0xff, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, - 0x18, 0x18, 0x18, 0x18, 0x18, 0x1f, 0x18, 0x1f, 0x18, 0x18, 0x18, - 0x18, 0x18, 0x18, 0x18, 0x18, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, - 0x36, 0x37, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, - 0x36, 0x36, 0x36, 0x36, 0x37, 0x30, 0x3f, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3f, 0x30, - 0x37, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, - 0x36, 0x36, 0x36, 0xf7, 0x00, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x00, 0xf7, - 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, - 0x36, 0x36, 0x37, 0x30, 0x37, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, - 0x36, 0x36, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x00, 0xff, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x36, 0x36, 0x36, 0x36, - 0x36, 0xf7, 0x00, 0xf7, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, - 0x36, 0x18, 0x18, 0x18, 0x18, 0x18, 0xff, 0x00, 0xff, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x36, 0x36, 0x36, 0x36, 0x36, - 0x36, 0x36, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x00, 0xff, 0x18, 0x18, 0x18, - 0x18, 0x18, 0x18, 0x18, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0xff, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, - 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x3f, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x18, 0x18, 0x18, 0x18, 0x18, 0x1f, 0x18, - 0x1f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x1f, 0x18, 0x1f, 0x18, 0x18, 0x18, 0x18, 0x18, - 0x18, 0x18, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3f, - 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, - 0x36, 0x36, 0x36, 0x36, 0xff, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, - 0x36, 0x36, 0x18, 0x18, 0x18, 0x18, 0x18, 0xff, 0x18, 0xff, 0x18, - 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, - 0x18, 0x18, 0x18, 0xf8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1f, 0x18, 0x18, - 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, - 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0x0f, - 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, - 0x0f, 0x0f, 0x0f, 0x0f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x76, 0xdc, 0xd8, 0xd8, 0xd8, 0xdc, 0x76, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfc, 0xc6, 0xfc, - 0xc6, 0xc6, 0xfc, 0xc0, 0xc0, 0xc0, 0x00, 0x00, 0x00, 0x00, 0xfe, - 0xc6, 0xc6, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xfe, 0x6c, 0x6c, 0x6c, - 0x6c, 0x6c, 0x6c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfe, - 0xc6, 0x60, 0x30, 0x18, 0x30, 0x60, 0xc6, 0xfe, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7e, 0xd8, 0xd8, 0xd8, 0xd8, - 0xd8, 0x70, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x66, - 0x66, 0x66, 0x66, 0x66, 0x7c, 0x60, 0x60, 0xc0, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x76, 0xdc, 0x18, 0x18, 0x18, 0x18, 0x18, - 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7e, 0x18, 0x3c, - 0x66, 0x66, 0x66, 0x3c, 0x18, 0x7e, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x38, 0x6c, 0xc6, 0xc6, 0xfe, 0xc6, 0xc6, 0x6c, 0x38, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x38, 0x6c, 0xc6, 0xc6, 0xc6, - 0x6c, 0x6c, 0x6c, 0x6c, 0xee, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x1e, 0x30, 0x18, 0x0c, 0x3e, 0x66, 0x66, 0x66, 0x66, 0x3c, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7e, 0xdb, 0xdb, - 0xdb, 0x7e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x03, 0x06, 0x7e, 0xcf, 0xdb, 0xf3, 0x7e, 0x60, 0xc0, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x1c, 0x30, 0x60, 0x60, 0x7c, 0x60, 0x60, - 0x60, 0x30, 0x1c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7c, - 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0xfe, 0x00, 0x00, 0xfe, 0x00, 0x00, - 0xfe, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, - 0x18, 0x7e, 0x18, 0x18, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x30, 0x18, 0x0c, 0x06, 0x0c, 0x18, 0x30, 0x00, - 0x7e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0c, 0x18, 0x30, - 0x60, 0x30, 0x18, 0x0c, 0x00, 0x7e, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x0e, 0x1b, 0x1b, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, - 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, - 0x18, 0xd8, 0xd8, 0xd8, 0x70, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x18, 0x18, 0x00, 0x7e, 0x00, 0x18, 0x18, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x76, 0xdc, 0x00, - 0x76, 0xdc, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x38, 0x6c, - 0x6c, 0x38, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x18, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x0f, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0xec, 0x6c, 0x6c, - 0x3c, 0x1c, 0x00, 0x00, 0x00, 0x00, 0x00, 0xd8, 0x6c, 0x6c, 0x6c, - 0x6c, 0x6c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x70, 0x98, 0x30, 0x60, 0xc8, 0xf8, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7c, 0x7c, - 0x7c, 0x7c, 0x7c, 0x7c, 0x7c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, -}; diff --git a/usr.bin/doscmd/fonts.dir b/usr.bin/doscmd/fonts.dir index e23f58c..de15d37 100644 --- a/usr.bin/doscmd/fonts.dir +++ b/usr.bin/doscmd/fonts.dir @@ -1,2 +1,4 @@ -1 -cp437-8x16.pcf.gz vga +3 +cp437-8x8.pcf.gz cp437-8x8 +cp437-8x14.pcf.gz cp437-8x14 +cp437-8x16.pcf.gz cp437-8x16 diff --git a/usr.bin/doscmd/int10.c b/usr.bin/doscmd/int10.c index f79f96f..b8d7906 100644 --- a/usr.bin/doscmd/int10.c +++ b/usr.bin/doscmd/int10.c @@ -32,17 +32,17 @@ * $FreeBSD$ */ +#include <unistd.h> + #include "doscmd.h" #include "mouse.h" +#include "tty.h" +#include "video.h" -/* - * 0040:0060 contains the start and end of the cursor - */ -#define curs_end BIOSDATA[0x60] -#define curs_start BIOSDATA[0x61] +static int cursoremu = 1; void -int10(REGISTERS) +int10(regcontext_t *REGS) { char *addr; int i, j; @@ -55,113 +55,256 @@ int10(REGISTERS) reset_poll(); switch (R_AH) { - case 0x00: /* Set display mode */ - debug(D_HALF, "Set video mode to %02x\n", R_AL); + case 0x00: /* Set display mode */ + init_mode(R_AL); break; - case 0x01: /* Define cursor */ - curs_start = R_CH; - curs_end = R_CL; + case 0x01: /* Define cursor */ + { + int start, end; + + start = R_CH; + end = R_CL; + if (cursoremu == 0) + goto out; + /* Cursor emulation */ + if (start <= 3 && end <= 3) + goto out; + if (start + 2 >= end) { + /* underline cursor */ + start = CharHeight - 3; + end = CharHeight - 2; + goto out; + } + if (start <= 2 || end < start) { + /* block cursor */ + start = 0; + end = CharHeight - 2; + goto out; + } + if (start > CharHeight / 2) { + /* half block cursor */ + start = CharHeight / 2; + end = 0; + } + out: CursStart = start; + CursEnd = end; break; - case 0x02: /* Position cursor */ + } + case 0x02: /* Position cursor */ if (!xmode) goto unsupported; tty_move(R_DH, R_DL); break; - case 0x03: /* Read cursor position */ + case 0x03: /* Read cursor position */ if (!xmode) goto unsupported; tty_report(&i, &j); R_DH = i; R_DL = j; - R_CH = curs_start; - R_CL = curs_end; + R_CH = CursStart; + R_CL = CursEnd; break; case 0x05: - debug(D_HALF, "Select current display page %d\n", R_AL); + debug(D_VIDEO, "Select current display page %d\n", R_AL); break; - case 0x06: /* initialize window/scroll text upward */ + case 0x06: /* initialize window/scroll text upward */ if (!xmode) goto unsupported; + if (R_AL == 0) /* clear screen */ + R_AL = DpyRows + 1; tty_scroll(R_CH, R_CL, - R_DH, R_DL, - R_AL, R_BH << 8); + R_DH, R_DL, + R_AL, R_BH << 8); break; - case 0x07: /* initialize window/scroll text downward */ + case 0x07: /* initialize window/scroll text downward */ if (!xmode) goto unsupported; + if (R_AL == 0) /* clear screen */ + R_AL = DpyRows + 1; tty_rscroll(R_CH, R_CL, - R_DH, R_DL, - R_AL, R_BH << 8); + R_DH, R_DL, + R_AL, R_BH << 8); break; - case 0x08: /* read character/attribute */ + case 0x08: /* read character/attribute */ if (!xmode) goto unsupported; i = tty_char(-1, -1); R_AX = i; break; - case 0x09: /* write character/attribute */ + case 0x09: /* write character/attribute */ if (!xmode) goto unsupported; tty_rwrite(R_CX, R_AL, R_BL << 8); break; - case 0x0a: /* write character */ + case 0x0a: /* write character */ if (!xmode) goto unsupported; + debug(D_HALF, "Int 10:0a: Write char: %02x\n", R_AL); tty_rwrite(R_CX, R_AL, -1); break; - case 0x0b: /* set border color */ + case 0x0b: /* set border color */ if (!xmode) goto unsupported; video_setborder(R_BL); break; - case 0x0e: /* write character */ + case 0x0c: /* write graphics pixel */ + debug(D_VIDEO, "Write graphics pixel at %d, %d\n", R_CX, R_DX); + break; + case 0x0d: /* read graphics pixel */ + debug(D_VIDEO, "Read graphics pixel at %d, %d\n", R_CX, R_DX); + break; + case 0x0e: /* write character */ tty_write(R_AL, -1); break; - case 0x0f: /* get display mode */ - R_AH = 80; /* number of columns */ - R_AL = 3; /* color */ - R_BH = 0; /* display page */ + case 0x0f: /* get current video mode */ + R_AH = DpyCols; /* number of columns */ + R_AL = VideoMode; /* active mode */ + R_BH = 0;/*ActivePage *//* display page */ break; case 0x10: + if (!xmode) + goto unsupported; switch (R_AL) { - case 0x01: - video_setborder(R_BH & 0x0f); + case 0x00: /* Set single palette register */ + palette[R_BL] = R_BH; + update_pixels(); + break; + case 0x01: /* Set overscan register */ + VGA_ATC[ATC_OverscanColor] = R_BH; break; - case 0x02: /* Set pallete registers */ - debug(D_HALF, "INT 10 10:02 Set all palette registers\n"); + case 0x02: /* Set all palette registers */ + addr = (char *)MAKEPTR(R_ES, R_DX); + for (i = 0; i < 16; i++) + palette[i] = *addr++; + VGA_ATC[ATC_OverscanColor] = *addr; + update_pixels(); break; case 0x03: /* Enable/Disable blinking mode */ - video_blink(R_BL ? 1 : 0); + video_blink((R_BL & 1) ? 1 : 0); + break; + case 0x07: /* Get individual palette register */ + R_BH = palette[R_BL]; + break; + case 0x08: /* Read overscan register */ + R_BH = VGA_ATC[ATC_OverscanColor]; + break; + case 0x09: /* Read all palette registers */ + addr = (char *)MAKEPTR(R_ES, R_DX); + for (i = 0; i < 16; i++) + *addr++ = palette[i]; + *addr = VGA_ATC[ATC_OverscanColor]; break; - case 0x13: + case 0x10: /* Set individual DAC register */ + dac_rgb[R_BX].red = R_DH & 0x3f; + dac_rgb[R_BX].green = R_CH & 0x3f; + dac_rgb[R_BX].blue = R_CL & 0x3f; + update_pixels(); + break; + case 0x12: /* Set block of DAC registers */ + addr = (char *)MAKEPTR(R_ES, R_DX); + for (i = R_BX; i < R_BX + R_CX; i++) { + dac_rgb[i].red = *addr++; + dac_rgb[i].green = *addr++; + dac_rgb[i].blue = *addr++; + } + update_pixels(); + break; + case 0x13: /* Select video DAC color page */ + switch (R_BL) { + case 0: + VGA_ATC[ATC_ModeCtrl] |= (R_BH & 0x01) << 7; + break; + case 1: + VGA_ATC[ATC_ColorSelect] = R_BH & 0x0f; + break; + default: + debug(D_VIDEO, "INT 10 10:13 " + "Bad value for BL: 0x%02x\n", R_BL); + break; + } + case 0x15: /* Read individual DAC register */ + R_DH = dac_rgb[R_BX].red; + R_CH = dac_rgb[R_BX].green; + R_CL = dac_rgb[R_BX].blue; + break; + case 0x17: /* Read block of DAC registers */ + addr = (char *)MAKEPTR(R_ES, R_DX); + for (i = R_BX; i < R_BX + R_CX; i++) { + *addr++ = dac_rgb[i].red; + *addr++ = dac_rgb[i].green; + *addr++ = dac_rgb[i].blue; + } + break; + case 0x18: /* Set PEL mask */ debug(D_HALF, - "INT 10 10:13 Select color or DAC (%02x, %02x)\n", - R_BL, R_BH); + "INT 10 10:18 Set PEL mask (%02x)\n", R_BL); + break; + case 0x19: /* Read PEL mask */ + debug(D_HALF, "INT 10 10:19 Read PEL mask\n"); + break; + case 0x1a: /* Get video dac color-page state */ + R_BH = (VGA_ATC[ATC_ModeCtrl] & 0x80) >> 7; + R_BL = VGA_ATC[ATC_ColorSelect]; break; - case 0x1a: /* get video dac color-page state */ - R_BH = 0; /* Current page */ - R_BL = 0; /* four pages of 64... */ + case 0x1b: /* Perform gray-scale summing */ + debug(D_HALF, "Perform gray-scale summing\n"); break; default: unknown_int3(0x10, 0x10, R_AL, REGS); break; } break; -#if 1 case 0x11: switch (R_AL) { - case 0x00: printf("Tried to load user defined font.\n"); break; - case 0x01: printf("Tried to load 8x14 font.\n"); break; - case 0x02: printf("Tried to load 8x8 font.\n"); break; - case 0x03: printf("Tried to activate character set\n"); break; - case 0x04: printf("Tried to load 8x16 font.\n"); break; - case 0x10: printf("Tried to load and activate user defined font\n"); break; - case 0x11: printf("Tried to load and activate 8x14 font.\n"); break; - case 0x12: printf("Tried to load and activate 8x8 font.\n"); break; - case 0x14: printf("Tried to load and activate 8x16 font.\n"); break; + case 0x00: + debug(D_VIDEO, "Tried to load user defined font.\n"); + break; + case 0x01: + debug(D_VIDEO, "Tried to load 8x14 font.\n"); + break; + case 0x02: + debug(D_VIDEO, "Tried to load 8x8 font.\n"); + break; + case 0x03: + debug(D_VIDEO, "Tried to activate character set\n"); + break; + case 0x04: + debug(D_VIDEO, "Tried to load 8x16 font.\n"); + break; + case 0x10: + debug(D_VIDEO, + "Tried to load and activate user defined font\n"); + break; + case 0x11: + debug(D_VIDEO, + "Tried to load and activate 8x14 font.\n"); + break; + case 0x12: + debug(D_VIDEO, + "Tried to load and activate 8x8 font.\n"); + break; + case 0x14: + debug(D_VIDEO, + "Tried to load and activate 8x16 font.\n"); + break; + case 0x20: + debug(D_VIDEO, "Load second half of 8x8 char set\n"); + break; + case 0x21: + debug(D_VIDEO, "Install user defined char set\n"); + break; + case 0x22: + debug(D_VIDEO, "Install 8x14 char set\n"); + break; + case 0x23: + debug(D_VIDEO, "Install 8x8 char set\n"); + break; + case 0x24: + debug(D_VIDEO, "Install 8x16 char set\n"); + break; case 0x30: - R_CX = 14; - R_DL = 24; + R_CX = CharHeight; + R_DL = DpyRows; switch(R_BH) { case 0: PUTVEC(R_ES, R_BP, ivec[0x1f]); @@ -177,9 +320,9 @@ int10(REGISTERS) case 7: R_ES = 0; R_BP = 0; - debug(D_HALF, - "INT 10 11:30 Request font address %02x", - R_BH); + debug(D_VIDEO, + "INT 10 11:30 Request font address %02x", + R_BH); break; default: unknown_int4(0x10, 0x11, 0x30, R_BH, REGS); @@ -191,16 +334,24 @@ int10(REGISTERS) break; } break; -#endif case 0x12: /* Load multiple DAC color register */ if (!xmode) goto unsupported; switch (R_BL) { case 0x10: /* Read EGA/VGA config */ - R_BH = 0; /* Color */ - R_BL = 0; /* 64K */ + R_BH = NumColors > 1 ? 0 : 1; /* Color */ + R_BL = 3; /* 256 K */ + break; + case 0x34: /* Cursor emulation */ + if (R_AL == 0) + cursoremu = 1; + else + cursoremu = 0; + R_AL = 0x12; break; default: + if (vflag) + dump_regs(REGS); unknown_int3(0x10, 0x12, R_BL, REGS); break; } @@ -243,29 +394,34 @@ int10(REGISTERS) case 0x1a: if (!xmode) goto unsupported; - R_AL = 0x1a; /* I am VGA */ + R_AL = 0x1a; /* I am VGA */ R_BL = 8; /* Color VGA */ R_BH = 0; /* No other card */ break; - + case 0x1b: /* Video Functionality/State information */ + if (R_BX == 0) { + addr = (char *)MAKEPTR(R_ES, R_DI); + memcpy(addr, vga_status, 64); + R_AL = 0x1b; + } + break; + case 0x1c: /* Save/Restore video state */ + debug(D_VIDEO, "Save/restore video state\n"); + R_AL = 0; + break; case 0x4f: /* get VESA information */ - R_AH = 0x01; /* no VESA support */ - break; - - case 0x1b: /* Functionality state information */ - break; - - case 0x6f: - switch (R_AL) { - case 0x00: /* HP-Vectra or Video7 installation check */ - R_BX = 0; /* nope, none of that */ + R_AH = 0x01; /* no VESA support */ break; - default: - unknown_int3(0x10, 0x6f, R_AL, REGS); + case 0x6f: + switch (R_AL) { + case 0x00: /* HP-Vectra or Video7 installation check */ + R_BX = 0; /* nope, none of that */ + break; + default: + unknown_int3(0x10, 0x6f, R_AL, REGS); + break; + } break; - } - break; - case 0xef: case 0xfe: /* Get video buffer */ break; @@ -277,13 +433,14 @@ int10(REGISTERS) /* XXX - we should allow secondary buffer here and then update it as the user requests. */ break; - unsupported: - if (vflag) dump_regs(REGS); - fatal ("int10 function 0x%02x:%02x only available in X mode\n", - R_AH, R_AL); - unknown: + if (vflag) + dump_regs(REGS); + fatal("int10 function 0x%02x:%02x only available in X mode\n", + R_AH, R_AL); default: + if (vflag) + dump_regs(REGS); unknown_int3(0x10, R_AH, R_AL, REGS); break; } diff --git a/usr.bin/doscmd/trap.c b/usr.bin/doscmd/trap.c index f0bfc85..f4b579a 100644 --- a/usr.bin/doscmd/trap.c +++ b/usr.bin/doscmd/trap.c @@ -32,8 +32,12 @@ * $FreeBSD$ */ +#include <machine/trap.h> + #include "doscmd.h" #include "trap.h" +#include "tty.h" +#include "video.h" /* ** When the emulator is very busy, it's often common for @@ -60,7 +64,7 @@ fake_int(regcontext_t *REGS, int intnum) intnum, R_AH, R_CS, R_IP, ivec[intnum]); switch (intnum) { case 0x2f: /* multiplex interrupt */ - int2f(®S->sc); + int2f((regcontext_t *)®S->sc); break; case 0xff: /* doscmd special */ emuint(REGS); @@ -73,7 +77,7 @@ fake_int(regcontext_t *REGS, int intnum) return; } -user_int: + /* user_int: */ debug (D_TRAPS|intnum, "INT %02x:%02x [%04x:%04x] %04x %04x %04x %04x from %04x:%04x\n", intnum, R_AH, ivec[intnum] >> 16, ivec[intnum] & 0xffff, @@ -295,9 +299,21 @@ sigbus(struct sigframe *sf) fatal("SIGBUS in the emulator\n"); if ((int)sf->sf_siginfo != 0) { - fatal("SIGBUS code %d, trapno: %d, err: %d\n", - (int)sf->sf_siginfo, sf->sf_uc.uc_mcontext.mc_trapno, - sf->sf_uc.uc_mcontext.mc_err); + switch (sf->sf_uc.uc_mcontext.mc_trapno) { + case T_PAGEFLT: + debug(D_TRAPS2, "Page fault, trying to access 0x%x\n", + sf->sf_addr); + /* nothing but accesses to video memory can fault for now */ + if (vmem_pageflt(sf) == 0) + goto out; + /* FALLTHRU */ + default: + dump_regs(REGS); + fatal("SIGBUS code %d, trapno: %d, err: %d\n", + (int)sf->sf_siginfo, sf->sf_uc.uc_mcontext.mc_trapno, + sf->sf_uc.uc_mcontext.mc_err); + /* NOTREACHED */ + } } addr = (u_char *)MAKEPTR(R_CS, R_IP); @@ -588,7 +604,7 @@ sigalrm(struct sigframe *sf) /* debug(D_ALWAYS,"tick %d", update_counter); */ update_counter = 0; /* remember we've updated */ - video_update(®S->sc); + video_update((regcontext_t *)®S->sc); hardint(0x08); /* debug(D_ALWAYS,"\n"); */ diff --git a/usr.bin/doscmd/tty.c b/usr.bin/doscmd/tty.c index a078812..76c527f 100644 --- a/usr.bin/doscmd/tty.c +++ b/usr.bin/doscmd/tty.c @@ -32,21 +32,19 @@ * $FreeBSD$ */ -#ifndef NO_X -#include <X11/Xlib.h> -#include <X11/Xutil.h> -#include <X11/keysym.h> -#endif - -#include <stdio.h> -#include <termios.h> -#include <limits.h> -#include <unistd.h> #include <sys/ioctl.h> +#include <sys/time.h> +#include <sys/types.h> +#include <sys/mman.h> +#include <ctype.h> +#include <err.h> #include <fcntl.h> +#include <limits.h> #include <paths.h> #include <signal.h> -#include <sys/time.h> +#include <stdio.h> +#include <termios.h> +#include <unistd.h> #ifdef __FreeBSD__ # include <sys/kbio.h> #else @@ -56,109 +54,99 @@ # include "/sys/i386/isa/pcconsioctl.h" # endif #endif -#include <sys/mman.h> -#include <ctype.h> + +#ifndef NO_X +#include <X11/Xlib.h> +#include <X11/Xutil.h> +#include <X11/keysym.h> +#endif + #include "doscmd.h" +#include "AsyncIO.h" +#include "font8x8.h" +#include "font8x14.h" +#include "font8x16.h" #include "mouse.h" +#include "trap.h" +#include "tty.h" #include "video.h" -#include "font.h" -static struct termios save = { 0 }; -static struct termios raw = { 0 }; -static int flags = 0; -static int mode = -1; -#define vmem ((u_short *)0xB8000) +#ifndef NO_X +static int show = 1; +#endif static int blink = 1; int flipdelete = 0; /* Flip meaning of delete and backspace */ extern int capture_fd; static u_short break_code = 0x00; static u_short scan_code = 0x00; +int height; +int width; +int vattr; +char *xfont = 0; #ifndef NO_X -static Display *dpy = 0; -static Window win; -static XFontStruct *font; -static unsigned long black; -static unsigned long white; -static unsigned long pixels[16]; -static char *color_names[16] = { - "black", - "medium blue", - "olive drab", - "turquoise3", - "red1", - "maroon", - "goldenrod4", - "gray80", - "gray50", - "sky blue", - "spring green", - "PaleTurquoise2", - "pink", - "violet red", - "yellow1", - "white", -}; - -static int FW, FH, FD; -static GC gc; -static GC cgc; -static int xfd; +Display *dpy; +Window win; +XFontStruct *font; +XImage *xi = 0; +Visual *visual; +unsigned int depth; +unsigned long black; +unsigned long white; +int FW, FH, FD; +GC gc; +GC cgc; +int xfd; + +/* LUT for the vram -> XImage conversion */ +u_int8_t lut[4][256][8]; + +/* X pixel values for the RGB triples */ +unsigned long pixels[16]; #endif +typedef struct TextLine { + u_short *data; + u_char max_length; /* Not used, but here for future use */ + u_char changed:1; +} TextLine; +TextLine *lines; + int kbd_fd = -1; int kbd_read = 0; -static int vattr = 0x0700; -static int width = 80; -static int height = 25; static struct termios tty_cook, tty_raw; -typedef struct TextLine { - u_short *data; - u_char max_length; /* Not used, but here for future use */ - u_char changed:1; -} TextLine; -static TextLine *lines; - -/* - * 0040:0050 is a list of 16 bytes, 2 for each page, which contains - * the column and row of each page - */ -#define row BIOSDATA[0x51] -#define col BIOSDATA[0x50] - -u_char *VREG; +#define row (CursRow0) +#define col (CursCol0) -inline SetVREGCur() +inline void +SetVREGCur() { - int cp = row * width + col; - VREG[MVC_CurHigh] = cp >> 8; - VREG[MVC_CurLow] = cp & 0xff; + int cp = row * width + col; + VGA_CRTC[CRTC_CurLocHi] = cp >> 8; + VGA_CRTC[CRTC_CurLocLo] = cp & 0xff; } -/* - * 0040:0060 contains the start and end of the cursor - */ -#define curs_end BIOSDATA[0x60] -#define curs_start BIOSDATA[0x61] - -#define video_pate BISODATA[0x62] - -#define IBMFONT "vga" /* font supplied */ - -char *xfont = 0; - -void video_async_event(); -void debug_event(); -int video_event(); -void tty_cooked(); -void video_update(); -unsigned char video_inb(int); +void _kbd_event(void *); +void debug_event(void *); +int video_event(); +void video_async_event(void *); +void tty_cooked(); unsigned char inb_port60(int); -void video_outb(int, unsigned char); -void kbd_event(int fd, REGISTERS); -u_short read_raw_kbd(int fd, u_short *code); +void kbd_event(int fd, REGISTERS); +u_short read_raw_kbd(int fd, u_short *code); + +/* Local functions */ +#ifndef NO_X +static void dac2rgb(XColor *, int); +static void prepare_lut(void); +static void putchar_graphics(int, int, int); +static void tty_rwrite_graphics(int, int, int); +static void video_update_graphics(void); +static void video_update_text(void); +static void vram2ximage(void); +#endif #define PEEKSZ 16 @@ -210,45 +198,19 @@ u_short read_raw_kbd(int fd, u_short *code); #define K4_LED 0x40 /* LED update in progress */ #define K4_ERROR 0x80 -struct VideoSavePointerTable { - u_short video_parameter_tabel[2]; - u_short parameter_dynamic_save_area[2]; /* Not used */ - u_short alphanumeric_character_set_override[2]; /* Not used */ - u_short graphics_character_set_override[2]; /* Not used */ - u_short secondary_save_pointer_table[2]; /* Not used */ - u_short mbz[4]; -}; - -struct SecondaryVideoSavePointerTable { - u_short length; - u_short display_combination_code_table[2]; - u_short alphanumeric_character_set_override[2]; /* Not used */ - u_short user_palette_profile_table[2]; /* Not used */ - u_short mbz[6]; -}; - int KbdEmpty(); void KbdWrite(u_short code); void KbdRepl(u_short code); u_short KbdRead(); u_short KbdPeek(); -int redirect0; -int redirect1; -int redirect2; - -static void +void Failure() { fprintf(stderr, "X Connection shutdown\n"); quit(1); } -struct VideoSavePointerTable *vsp; -struct SecondaryVideoSavePointerTable *svsp; - -#include "vparams.h" - static void console_denit(void *arg) { @@ -271,10 +233,12 @@ console_denit(void *arg) } void -_kbd_event(int fd, REGISTERS) +_kbd_event(void *pfd) { - printf("_kbd_event: fd=%d\n", fd); - kbd_read = 1; + int fd = *(int *)pfd; + + printf("_kbd_event: fd=%d\n", fd); + kbd_read = 1; } void @@ -355,7 +319,7 @@ console_init() _RegisterIO(0, debug_event, 0, Failure); _RegisterIO(fd, kbd_event, fd, Failure); #endif - _RegisterIO(fd, _kbd_event, fd, Failure); + _RegisterIO(fd, _kbd_event, &fd, Failure); } void @@ -373,8 +337,7 @@ video_blink(int mode) blink = mode; } -static int show = 1; - +void setgc(u_short attr) { #ifndef NO_X @@ -385,155 +348,199 @@ setgc(u_short attr) v.foreground = pixels[(attr >> 8) & 0x0f]; v.background = pixels[(attr >> 12) & (blink ? 0x07 : 0x0f)]; -#if 0 - if (v.foreground == v.background) { - v.foreground = pixels[15]; - v.background = pixels[0]; - } -#endif XChangeGC(dpy, gc, GCForeground|GCBackground, &v); #endif } void -video_update(REGISTERS) +video_update(regcontext_t *REGS) { #ifndef NO_X - static int or = -1; - static int oc = -1; - - static int icnt = 4; - - static char buf[256]; - int r, c; - int attr = vmem[0] & 0xff00; - XGCValues v; + static int icnt = 3; if (kbd_read) kbd_event(kbd_fd, REGS); if (--icnt == 0) { - - icnt = 4; + icnt = 3; lpt_poll(); /* Handle timeout on lpt code */ - if (xmode) { - wakeup_poll(); /* Wake up anyone waiting on kbd poll */ - - show ^= 1; - - setgc(attr); - - for (r = 0; r < height; ++r) { - int cc = 0; - - if (!lines[r].changed) { - if ((r == or || r == row) && (or != row || oc != col)) - lines[r].changed = 1; - else { - for (c = 0; c < width; ++c) { - if (lines[r].data[c] != vmem[r * width + c]) { - lines[r].changed = 1; - break; - } - if (blink && lines[r].data[c] & 0x8000) { - lines[r].changed = 1; - break; - } - } - } - } + /* quick and dirty */ + if (VGA_ATC[ATC_ModeCtrl] & 1) + video_update_graphics(); + else + video_update_text(); + } - if (!lines[r].changed) - continue; - - reset_poll(); - lines[r].changed = 0; - memcpy(lines[r].data, - &vmem[r * width], sizeof(u_short) * width); - - for (c = 0; c < width; ++c) { - int cv = vmem[r * width + c]; - if ((cv & 0xff00) != attr) { - if (cc < c) - XDrawImageString(dpy, win, gc, - 2 + cc * FW, - 2 + (r + 1) * FH, - buf + cc, c - cc); - cc = c; - attr = cv & 0xff00; - setgc(attr); - } - buf[c] = (cv & 0xff) ? cv & 0xff : ' '; + if (!booting) { + *(u_long *)&BIOSDATA[0x6c] += 1; /* ticks since midnight */ + while (*(u_long *)&BIOSDATA[0x6c] >= 24*60*6*182) { + *(u_long *)&BIOSDATA[0x6c] -= 24*60*6*182; + BIOSDATA[0x70]++; /* # times past mn */ + } + } +#endif +} + +#ifndef NO_X +static void +video_update_graphics() +{ + vram2ximage(); + + XPutImage(dpy, win, DefaultGC(dpy, DefaultScreen(dpy)), + xi, 0, 0, 0, 0, width, height); + XFlush(dpy); + + return; +} + +static void +video_update_text() +{ + static int or = -1; + static int oc = -1; + + + static char buf[256]; + int r, c; + int attr = vmem[0] & 0xff00; + XGCValues v; + + if (xmode) { + wakeup_poll(); /* Wake up anyone waiting on kbd poll */ + + show ^= 1; + + setgc(attr); + + for (r = 0; r < height; ++r) { + int cc = 0; + + if (!lines[r].changed) { + if ((r == or || r == row) && (or != row || oc != col)) + lines[r].changed = 1; + else { + for (c = 0; c < width; ++c) { + if (lines[r].data[c] != vmem[r * width + c]) { + lines[r].changed = 1; + break; } - if (cc < c) { - XDrawImageString(dpy, win, gc, - 2 + cc * FW, - 2 + (r + 1) * FH, - buf + cc, c - cc); + if (blink && lines[r].data[c] & 0x8000) { + lines[r].changed = 1; + break; } + } } - or = row; - oc = col; - - if (curs_start <= curs_end && curs_end <= FH && - show && row < height && col < width) { - int start, end; - - attr = vmem[row * width + col] & 0xff00; - v.foreground = pixels[(attr >> 8) & 0x0f] ^ - pixels[(attr >> 12) & (blink ? 0x07 : 0x0f)]; - if (v.foreground) { - v.function = GXxor; - } else { - v.foreground = pixels[7]; - v.function = GXcopy; - } - XChangeGC(dpy, cgc, GCForeground | GCFunction, &v); - start = curs_start * FH / 8; - end = curs_end * FH / 8; - XFillRectangle(dpy, win, cgc, - 2 + col * FW, - 2 + row * FH + start + FD, - FW, end + 1 - start); + } + + if (!lines[r].changed) + continue; + + reset_poll(); + lines[r].changed = 0; + memcpy(lines[r].data, + &vmem[r * width], sizeof(u_short) * width); + + for (c = 0; c < width; ++c) { + int cv = vmem[r * width + c]; + if ((cv & 0xff00) != attr) { + if (cc < c) + XDrawImageString(dpy, win, gc, + 2 + cc * FW, + 2 + (r + 1) * FH, + buf + cc, c - cc); + cc = c; + attr = cv & 0xff00; + setgc(attr); } + buf[c] = (cv & 0xff) ? cv & 0xff : ' '; + } + if (cc < c) { + XDrawImageString(dpy, win, gc, + 2 + cc * FW, + 2 + (r + 1) * FH, + buf + cc, c - cc); + } + } + or = row; + oc = col; - if (mouse_status.installed && mouse_status.show) { - c = mouse_status.x / mouse_status.hmickey; - r = mouse_status.y / mouse_status.vmickey; + if (CursStart <= CursEnd && CursEnd <= FH && + show && row < height && col < width) { - lines[r].changed = 1; - attr = vmem[r * width + c] & 0xff00; - v.foreground = pixels[(attr >> 8) & 0x0f] ^ - pixels[(attr >> 12) & 0x0f]; - if (v.foreground) { - v.function = GXxor; - } else { - v.foreground = pixels[7]; - v.function = GXcopy; - } - XChangeGC(dpy, cgc, GCForeground | GCFunction, &v); - XFillRectangle(dpy, win, cgc, - 2 + c * FW, - 2 + r * FH + 2, - FW, FH); - } - - XFlush(dpy); + attr = vmem[row * width + col] & 0xff00; + v.foreground = pixels[(attr >> 8) & 0x0f] ^ + pixels[(attr >> 12) & (blink ? 0x07 : 0x0f)]; + if (v.foreground) { + v.function = GXxor; + } else { + v.foreground = pixels[7]; + v.function = GXcopy; } - } + XChangeGC(dpy, cgc, GCForeground | GCFunction, &v); + XFillRectangle(dpy, win, cgc, + 2 + col * FW, + 2 + row * FH + CursStart + FD, + FW, CursEnd + 1 - CursStart); + } - if (!booting) { - *(u_long *)&BIOSDATA[0x6c] += 1; /* Timer ticks since midnight... */ - while (*(u_long *)&BIOSDATA[0x6c] >= 24*60*6*182) { - *(u_long *)&BIOSDATA[0x6c] -= 24*60*6*182; - BIOSDATA[0x70]++; /* BIOSDATA[0x70] # times past mn */ + if (mouse_status.installed && mouse_status.show) { + c = mouse_status.x / mouse_status.hmickey; + r = mouse_status.y / mouse_status.vmickey; + + lines[r].changed = 1; + attr = vmem[r * width + c] & 0xff00; + v.foreground = pixels[(attr >> 8) & 0x0f] ^ + pixels[(attr >> 12) & 0x0f]; + if (v.foreground) { + v.function = GXxor; + } else { + v.foreground = pixels[7]; + v.function = GXcopy; } - } -#endif + XChangeGC(dpy, cgc, GCForeground | GCFunction, &v); + XFillRectangle(dpy, win, cgc, + 2 + c * FW, + 2 + r * FH + 2, + FW, FH); + } + + XFlush(dpy); + } } +/* Convert the contents of the video RAM into an XImage. + + Bugs: - The function is way too slow. + - It only works for the 16 color modes. + - It only works on 15/16-bit TrueColor visuals. */ +static void +vram2ximage() +{ + int i, x, y, yoffset; + u_int16_t *image = (u_int16_t *)xi->data; + + yoffset = 0; + for (y = 0; y < height; y++) { + yoffset += width / 8; + for (x = 0; x < width; x += 8) { + int offset = yoffset + x / 8; + for (i = 0; i < 8; i++) { + int color = lut[0][vplane0[offset]][i] | + lut[1][vplane1[offset]][i] | + lut[2][vplane2[offset]][i] | + lut[3][vplane3[offset]][i]; + *image++ = (u_int16_t)pixels[color]; + } + } + } + + return; +} +#endif + static u_short Ascii2Scan[] = { 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0x000e, 0x000f, 0xffff, 0xffff, 0xffff, 0x001c, 0xffff, 0xffff, @@ -651,15 +658,14 @@ struct { }; void -debug_event(int fd, REGISTERS) +debug_event(void *pfd) { static char ibuf[1024]; - static char icnt = 0; + static int icnt = 0; static u_short ds = 0; static u_short di = 0; static u_short cnt = 16 * 8; char *ep; - int r; r = read(0, ibuf + icnt, sizeof(ibuf) - icnt); @@ -669,7 +675,7 @@ debug_event(int fd, REGISTERS) icnt += r; ibuf[icnt] = 0; - while (ep = strchr(ibuf, '\n')) { + while ((ep = strchr(ibuf, '\n')) != 0) { int ac; char *_av[16]; char **av; @@ -681,7 +687,7 @@ debug_event(int fd, REGISTERS) if (!strcasecmp(av[0], "dump")) { if (ac > 1) { char *c; - if (c = strchr(av[1], ':')) { + if ((c = strchr(av[1], ':')) != 0) { ds = strtol(av[1], 0, 16); di = strtol(c+1, 0, 16); } else @@ -713,12 +719,11 @@ debug_event(int fd, REGISTERS) printf("\n"); } } else if (!strcasecmp(av[0], "dis")) { - int r; u_char *ap = (u_char *)(((u_long)ds << 4) + di); if (ac > 1) { char *c; - if (c = strchr(av[1], ':')) { + if ((c = strchr(av[1], ':')) != 0) { ds = strtol(av[1], 0, 16); di = strtol(c+1, 0, 16); } else @@ -734,15 +739,17 @@ debug_event(int fd, REGISTERS) di += c; ap += c; } +#if 0 /* Huh?? */ } else if (!strcasecmp(av[0], "regs")) { dump_regs(REGS); +#endif } else if (!strcasecmp(av[0], "force")) { char *p = av[1]; - while (p = *++av) { + while ((p = *++av) != 0) { while (*p) { if (*p >= ' ' && *p <= '~') - KbdWrite(ScanCodes[Ascii2Scan[*p] & 0xff].base); + KbdWrite(ScanCodes[Ascii2Scan[(int)*p] & 0xff].base); ++p; } } @@ -807,7 +814,6 @@ u_short read_raw_kbd(int fd, u_short *code) { unsigned char c; - unsigned char oldled = K4_STATUS & 0x7; *code = 0xffff; @@ -963,7 +969,8 @@ printf("FORCED REDRAW\n"); case 0x14: /* T */ tmode ^= 1; if (!tmode) - resettrace(&saved_sigframe->sf_uc.uc_mcontext); + resettrace((regcontext_t *)&saved_sigframe-> + sf_uc.uc_mcontext); return(0xffff); case 0x53: /* DEL */ quit(0); @@ -976,10 +983,11 @@ printf("FORCED REDRAW\n"); } void -video_async_event(int fd, regcontext_t *REGS) +video_async_event(void *pfd) { #ifndef NO_X - int int09 = 0; + int int9 = 0; + int fd = *(int *)pfd; for (;;) { int x; @@ -993,7 +1001,7 @@ video_async_event(int fd, regcontext_t *REGS) XFlush(dpy); while (QLength(dpy) > 0) { XNextEvent(dpy, &ev); - int09 |= video_event(&ev); + int9 |= video_event(&ev); } FD_ZERO(&fdset); @@ -1012,14 +1020,14 @@ video_async_event(int fd, regcontext_t *REGS) return; case 0: XFlush(dpy); - if (int09) + if (int9) hardint(0x09); return; default: if (FD_ISSET(fd, &fdset)) { do { XNextEvent(dpy, &ev); - int09 |= video_event(&ev); + int9 |= video_event(&ev); } while (QLength(dpy)); } break; @@ -1033,8 +1041,6 @@ kbd_async_event(int fd, REGISTERS) { unsigned char c; - unsigned char oldled = K4_STATUS & 0x7; - while (read(fd, &c, 1) == 1) { switch (c) { case 29: /* Control */ @@ -1194,7 +1200,6 @@ video_event(XEvent *ev) case KeyRelease: { static char buf[128]; KeySym ks; - int n; break_code |= 0x80; @@ -1456,7 +1461,7 @@ video_event(XEvent *ev) if (ks == 'T' || ks == 't') { tmode ^= 1; if (!tmode) - resettrace(&saved_sigframe-> + resettrace((regcontext_t *)&saved_sigframe-> sf_uc.uc_mcontext); break; } @@ -1501,70 +1506,6 @@ video_event(XEvent *ev) } #endif -#define R03D4 BIOSDATA[0x65] -static u_char R03BA = 0; -static u_char R03DA = 0; - -unsigned char -video_inb(int port) -{ - switch(port) { - case CGA_Status: - R03DA += 1; /* Just cylce throught the values */ - return(R03DA &= 0x0f); - case 0x03c2: /* Misc */ - case 0x03cc: /* Misc */ - return(0xc3); - case CVC_Data: - if (R03D4 < 0x10) { - return(VREG[R03D4]); - } - break; - } -} - -void -video_outb(int port, unsigned char value) -{ - int cp; - - switch(port) { - case 0x03cc: - case 0x03c2: - if ((value & 0x1) == 0) /* Trying to request monochrome */ - break; - return; - case CGA_Control: - if (value & 0x22) /* Trying to select graphics */ - break; - return; - case CVC_Address: - R03D4 = value & 0x1f; - return; - case CVC_Data: - if (R03D4 > 0x0f) - break; - VREG[R03D4] = value; - switch (R03D4) { - case MVC_CurHigh: - cp = row * width + col; - cp &= 0xff; - cp |= (value << 8) & 0xff00; - row = cp / width; - col = cp % width; - break; - case MVC_CurLow: - cp = row * width + col; - cp &= 0xff00; - cp |= value & 0xff; - row = cp / width; - col = cp % width; - break; - } - return; - } -} - void tty_move(int r, int c) { @@ -1607,7 +1548,6 @@ tty_write(int c, int attr) { if (attr == TTYF_REDIRECT) { if (redirect1) { - char tc = c; write(1, &c, 1); return; } @@ -1669,38 +1609,110 @@ tty_write(int c, int attr) void tty_rwrite(int n, int c, int attr) { - u_char srow, scol; - c &= 0xff; + u_char srow, scol; + c &= 0xff; - srow = row; - scol = col; - while (n--) { - if (col >= width) { - col = 0; - tty_index(); - } - if (row > (height - 1)) - row = 0; - if (attr >= 0) - vmem[row * width + col] = attr & 0xff00; +#ifndef NO_X + if (VGA_ATC[ATC_ModeCtrl] & 1) { + tty_rwrite_graphics(n, c, attr); + return; + } +#endif + + srow = row; + scol = col; + while (n--) { + if (col >= width) { + col = 0; + tty_index(); + } + if (row > (height - 1)) + row = 0; + if (attr >= 0) + vmem[row * width + col] = attr & 0xff00; + else + vmem[row * width + col] &= 0xff00; + vmem[row * width + col++] |= c; + } + row = srow; + col = scol; + SetVREGCur(); +} + +#ifndef NO_X +/* Write a character in graphics mode. Note that the text is put at *text* + coordinates. */ +static void +tty_rwrite_graphics(int n, int c, int attr) +{ + u_int8_t srow, scol; + int ht = height / CharHeight; + int wd = width / 8; + + srow = row; + scol = col; + + while (n--) { + if (col >= wd) { + col = 0; + /* tty_index(); *//* scroll up if last line is filled */ + } + if (row > (ht - 1)) + row = 0; + putchar_graphics(row * wd * CharHeight + col, c, attr); + col++; + } + row = srow; + col = scol; + SetVREGCur(); + + return; +} + +/* Put the character together from its pixel representation in 'font8xXX[]' + and write it to 'vram'. The attribute byte gives the desired color; if bit + 7 is set, the pixels are XOR'd with the underlying color(s). + + XXX This must be updated for the 256 color modes. */ +static void +putchar_graphics(int xy, int c, int attr) +{ + int i, j; + u_int8_t cline; + u_int8_t *cpos; + + /* get char position in the pixel representation */ + cpos = (u_int8_t *)(0xC3000 + c * CharHeight); + + for (i = 0; i < CharHeight; i++) { + cline = cpos[i]; + for (j = 0; j < 4; j++) { + if (attr & 0x8000) { + /* XOR */ + if (attr & (0x0100 << j)) + vram[xy + i * width / 8 + j * 0x10000] ^= cline; + } else { + /* replace */ + if (attr & (0x0100 << j)) + vram[xy + i * width / 8 + j * 0x10000] &= ~cline; else - vmem[row * width + col] &= 0xff00; - vmem[row * width + col++] |= c; + vram[xy + i * width / 8 + j * 0x10000] |= cline; + } } - row = srow; - col = scol; - SetVREGCur(); + } + + return; } +#endif -void -tty_pause() +void tty_pause() { - sigset_t set; + sigset_t set; - sigprocmask(0, 0, &set); - sigdelset(&set, SIGIO); - sigdelset(&set, SIGALRM); - sigsuspend(&set); + sigprocmask(0, 0, &set); + sigdelset(&set, SIGIO); + sigdelset(&set, SIGALRM); + sigsuspend(&set); } static int nextchar = 0; @@ -1710,7 +1722,7 @@ tty_read(REGISTERS, int flag) { int r; - if (r = nextchar) { + if ((r = nextchar) != 0) { nextchar = 0; return(r & 0xff); } @@ -1800,6 +1812,7 @@ tty_state() return(K1_STATUS); } +int tty_estate() { int state = 0; @@ -1955,76 +1968,80 @@ KbdPeek() return(K_BUF(K_NEXT)); } -void int10(REGISTERS); - void -video_init() +kbd_init() { - u_long vec; -#ifndef NO_X - XSizeHints sh; - XGCValues gcv; - XColor ccd, rgb; -#endif - unsigned long mask; - int level; - int i, j; + u_long vec; + + define_input_port_handler(0x60, inb_port60); - VREG = (u_char *)malloc(32); - - /* - * Define all known I/O port handlers - */ - define_input_port_handler(0x60, inb_port60); - - if (!raw_kbd) { - define_input_port_handler(CGA_Status, video_inb); - define_input_port_handler(0x03c2, video_inb); - define_input_port_handler(0x03cc, video_inb); - define_input_port_handler(CVC_Data, video_inb); - define_output_port_handler(CGA_Control, video_outb); - define_output_port_handler(0x03c2, video_outb); - define_output_port_handler(0x03cc, video_outb); - define_output_port_handler(CVC_Address, video_outb); - define_output_port_handler(CVC_Data, video_outb); - } + K_BUFSTARTP = 0x1e; /* Start of keyboard buffer */ + K_BUFENDP = 0x3e; /* End of keyboard buffer */ + K_NEXT = K_FREE = K_BUFSTARTP; + + vec = insert_hardint_trampoline(); + ivec[0x09] = vec; + register_callback(vec, int09, "int 09"); - redirect0 = isatty(0) == 0 || !xmode ; - redirect1 = isatty(1) == 0 || !xmode ; - redirect2 = isatty(2) == 0 || !xmode ; + return; +} - K_BUFSTARTP = 0x1e; /* Start of keyboard buffer */ - K_BUFENDP = 0x3e; /* End of keyboard buffer */ - K_NEXT = K_FREE = K_BUFSTARTP; +void +kbd_bios_init() +{ + BIOSDATA[0x96] = 0x10; /* MF II kbd, 101 keys */ + K1_STATUS = 0; + K2_STATUS = 0; + K3_STATUS = 0; + K4_STATUS = 0; +} - vec = insert_hardint_trampoline(); - ivec[0x09] = vec; - register_callback(vec, int09, "int 09"); +#ifndef NO_X +/* Calculate 16 bit RGB values for X from the 6 bit DAC values and the + palette. This works for 16 and 256 color modes, although we don't really + support the latter yet. */ +static void +dac2rgb(XColor *color, int i) +{ + int n, m; - /* - * Initialize video memory with black background, white foreground - */ - for (i = 0; i < height * width; ++i) - vmem[i] = vattr; + /* 256 colors are easy; just take the RGB values from the DAC and + shift left. For the pedants: multiplication with 65535./63. and + rounding makes a difference of less than two percent. */ + if (VGA_ATC[ATC_ModeCtrl] & 0x40) { + color->red = dac_rgb[i].red << 10; + color->green = dac_rgb[i].green << 10; + color->blue = dac_rgb[i].blue << 10; - if (!xmode) return; - -#ifndef NO_X - if (!(lines = (TextLine *)malloc(sizeof(TextLine) * height))) { - fprintf(stderr, "Could not allocate data structure for text lines\n"); - quit(1); } - for (i = 0; i < height; ++i) { - lines[i].max_length = width; - if (!(lines[i].data = (u_short *)malloc(width * sizeof(u_short)))) { - fprintf(stderr, - "Could not allocate data structure for text lines\n"); - quit(1); - } - lines[i].changed = 1; + + /* For the 16 color modes, check bit 7 of the Mode Control register in + the ATC. If set, we take bits 0-3 of the Color Select register and + bits 0-3 of the palette register 'i' to build the index into the + DAC table; otherwise, bits 2 and 3 of the CS reg and bits 0-5 of + the palette register are used. Note that the entries in 'palette[]' + are supposed to be already masked to 6 bits. */ + if (VGA_ATC[ATC_ModeCtrl] & 0x80) { + n = VGA_ATC[ATC_ColorSelect] & 0x0f; + m = palette[i] & 0x0f; + } else { + n = VGA_ATC[ATC_ColorSelect] & 0x0c; + m = palette[i]; } + color->red = dac_rgb[16*n + m].red << 10; + color->green = dac_rgb[16*n + m].green << 10; + color->blue = dac_rgb[16*n + m].blue << 10; +} +#endif +/* Get a connection to the X server and create the window. */ +void +init_window() +{ +#ifndef NO_X + XGCValues gcv; + int i; { /* @@ -2032,185 +2049,255 @@ video_init() * Open up all the available fd's, leave 3 behind for X * to play with, open X and then release all the other fds */ - int nfds = sysconf(_SC_OPEN_MAX); - int *fds = malloc(sizeof(int) * nfds); + int nfds = sysconf(_SC_OPEN_MAX); + int *fds = malloc(sizeof(int) * nfds); i = 0; - if (fds) + if (fds) for (i = 0; i < nfds && (i == 0 || fds[i-1] < 63); ++i) if ((fds[i] = open(_PATH_DEVNULL, 0)) < 0) break; /* * Leave 3 fds behind for X to play with */ - if (i > 0) close(fds[--i]); - if (i > 0) close(fds[--i]); - if (i > 0) close(fds[--i]); - + if (i > 0) close(fds[--i]); + if (i > 0) close(fds[--i]); + if (i > 0) close(fds[--i]); + dpy = XOpenDisplay(NULL); - - while (i > 0) + + while (i > 0) close(fds[--i]); } - - if (dpy == NULL) { - fprintf(stderr, "Could not open display ``%s''\n", - XDisplayName(NULL)); - quit(1); - } + if (dpy == NULL) + err(1, "Could not open display ``%s''\n", XDisplayName(NULL)); xfd = ConnectionNumber(dpy); - _RegisterIO(xfd, video_async_event, xfd, Failure); + _RegisterIO(xfd, video_async_event, &xfd, Failure); if (debug_flags & D_DEBUGIN) - _RegisterIO(0, debug_event, 0, Failure); + _RegisterIO(0, debug_event, 0, Failure); _BlockIO(); - pixels[0] = BlackPixel(dpy, DefaultScreen(dpy)); - pixels[15] = WhitePixel(dpy, DefaultScreen(dpy)); - for (i = 0; i < 15; ++i) { - if (XAllocNamedColor(dpy, - DefaultColormap(dpy, DefaultScreen(dpy)), - color_names[i], &ccd, &rgb)) { - pixels[i] = ccd.pixel; - } else if (i < 7) - pixels[i] = pixels[0]; - else - pixels[i] = pixels[15]; + /* Create window, but defer setting a size and GC. */ + win = XCreateSimpleWindow(dpy, DefaultRootWindow(dpy), 0, 0, + 1, 1, 2, black, black); + + gcv.foreground = white; + gcv.background = black; + gc = XCreateGC(dpy, win, GCForeground | GCBackground, &gcv); + + gcv.foreground = 1; + gcv.background = 0; + gcv.function = GXxor; + cgc = XCreateGC(dpy, win, GCForeground|GCBackground|GCFunction, &gcv); + + if (raw_kbd) { + XSelectInput(dpy, win, ExposureMask | ButtonPressMask + | ButtonReleaseMask | PointerMotionMask ); + } else { + XSelectInput(dpy, win, KeyReleaseMask | KeyPressMask | + ExposureMask | ButtonPressMask + | ButtonReleaseMask | PointerMotionMask ); } + XStoreName(dpy, win, "DOS"); + + _UnblockIO(); + + /* Get the default visual and depth for later use. */ + depth = DefaultDepth(dpy, DefaultScreen(dpy)); + visual = DefaultVisual(dpy, DefaultScreen(dpy)); + + prepare_lut(); + + /* While we are developing the graphics code ... */ + call_on_quit(write_vram, NULL); +#endif +} + +void +load_font() +{ +#ifndef NO_X + XGCValues gcv; + if (!xfont) - xfont = IBMFONT; + xfont = FONTVGA; font = XLoadQueryFont(dpy, xfont); if (font == NULL) - font = XLoadQueryFont(dpy, IBMFONT); + font = XLoadQueryFont(dpy, FONTVGA); - if (font == NULL) { - fprintf(stderr, "Could not open font ``%s''\n", xfont); - quit(1); - } + if (font == NULL) + err(1, "Could not open font ``%s''\n", xfont); + gcv.font = font->fid; + XChangeGC(dpy, gc, GCFont, &gcv); + FW = font->max_bounds.width; FH = font->max_bounds.ascent + font->max_bounds.descent; FD = font->max_bounds.descent; - curs_start = 6; - curs_end = 7; - - sh.width = FW * width + 4; - sh.height = FH * height + 4; - - sh.width += 4; - sh.height += 4; + /* Put the pixel representation at c000:3000. */ + switch (CharHeight) { + case 8: + memcpy((void *)0xc3000, font8x8, sizeof(font8x8)); + break; + case 14: + memcpy((void *)0xc3000, font8x14, sizeof(font8x14)); + break; + case 16: + memcpy((void *)0xc3000, font8x16, sizeof(font8x16)); + break; + default: + err(1, "load_font: CharHeight = %d?", CharHeight); + } + + return; +#endif +} - sh.min_width = sh.max_width = sh.width; - sh.min_height = sh.max_height = sh.height; +/* Get a new, or resize an old XImage as canvas for the graphics display. */ +void +get_ximage() +{ +#ifndef NO_X + if (xi != NULL) + XFree(xi); + + xi = XCreateImage(dpy, visual, depth, ZPixmap, 0, NULL, + width, height, 32, 0); + if (xi == NULL) + err(1, "Could not get ximage"); + + xi->data = malloc(width * height * depth / 8); + if (xi->data == NULL) { + XDestroyImage(xi); + err(1, "Could not get memory for ximage data"); + } + + return; +#endif +} - sh.flags = USSize | PMinSize | PMaxSize | PSize; +/* Get memory for the text line buffer. */ +void +get_lines() +{ + int i; + + if (!(lines = (TextLine *)malloc(sizeof(TextLine) * height))) + err(1, "Could not allocate data structure for text lines\n"); - win = XCreateSimpleWindow(dpy, DefaultRootWindow(dpy), 0, 0, - sh.width, sh.height, 2, black, black); - if (win == NULL) { - fprintf(stderr, "Could not create window\n"); - quit(1); + for (i = 0; i < height; ++i) { + lines[i].max_length = width; + if (!(lines[i].data = (u_short *)malloc(width * sizeof(u_short)))) + err(1, "Could not allocate data structure for text lines\n"); + lines[i].changed = 1; } +} - gcv.foreground = white; - gcv.background = black; - gcv.font = font->fid; +#ifndef NO_X +/* Prepare the LUT for the VRAM -> XImage conversion. */ +static void +prepare_lut() +{ + int i, j, k; - mask = GCForeground | GCBackground | GCFont; + for (i = 0; i < 4; i++) { + for (j = 0; j < 256; j++) { + for (k = 0; k < 8; k++) { + lut[i][j][7 - k] = ((j & (1 << k)) ? (1 << i) : 0); + } + } + } - gc = XCreateGC(dpy, win, mask, &gcv); + return; +} +#endif - gcv.foreground = 1; - gcv.background = 0; - gcv.function = GXxor; - cgc = XCreateGC(dpy, win, GCForeground|GCBackground|GCFunction, &gcv); +/* Resize the window, using information from 'vga_status[]'. This function is + called after a mode change. */ +void +resize_window() +{ +#ifndef NO_X + XSizeHints *sh; + vmode_t vmode; + + sh = XAllocSizeHints(); + if (sh == NULL) + err(1, "Could not get XSizeHints structure"); +#endif + + width = DpyCols; + height = DpyRows + 1; - XSetNormalHints(dpy, win, &sh); - if (raw_kbd) { - XSelectInput(dpy, win, ExposureMask | ButtonPressMask - | ButtonReleaseMask | PointerMotionMask ); +#ifndef NO_X + vmode = vmodelist[find_vmode(VideoMode)]; + if (vmode.type == TEXT) { + sh->base_width = FW * width + 4; + sh->base_height = FH * height + 4; + sh->base_width += 4; + sh->base_height += 4; } else { - XSelectInput(dpy, win, KeyReleaseMask | KeyPressMask | - ExposureMask | ButtonPressMask - | ButtonReleaseMask | PointerMotionMask ); + width *= 8; + height *= CharHeight; + sh->base_width = width; + sh->base_height = height; } - - XStoreName(dpy, win, "DOS"); + + sh->min_width = sh->max_width = sh->base_width; + sh->min_height = sh->max_height = sh->base_height; + sh->flags = USSize | PMinSize | PMaxSize | PSize; + + debug(D_VIDEO, "window size %dx%d\n", sh->base_width, sh->base_height); + + XSetWMNormalHints(dpy, win, sh); + XResizeWindow(dpy, win, sh->base_width, sh->base_height); XMapWindow(dpy, win); XFlush(dpy); - - _UnblockIO(); + + XFree(sh); + + return; #endif } +/* Calculate 'pixels[]' from the current DAC table and palette. + + To do: do not use 'pixels[]', use an array of 'XColor's which we can + allocate and free on demand. Install a private colormap if necessary. */ void -video_bios_init() +update_pixels() { - u_char *p; - u_long vec; +#ifndef NO_X + int i; + + /* We support only 16 colors for now. */ + for (i = 0; i < 16; i++) { + XColor color; + + dac2rgb(&color, i); + if (XAllocColor(dpy, + DefaultColormap(dpy, DefaultScreen(dpy)), &color)) { + pixels[i] = color.pixel; + } else if (i < 7) + pixels[i] = BlackPixel(dpy, DefaultScreen(dpy)); + else + pixels[i] = WhitePixel(dpy, DefaultScreen(dpy)); + } +#endif +} - if (raw_kbd) - return; +void +write_vram(void *arg) +{ + int fd; - /* - * Put the Video Save Pointer table @ C000:0000 - * Put the Secondary Video Save Pointer table @ C000:0020 - * Put the Display Combination code table @ C000:0040 - * Put the Video Parameter table @ C000:1000 - C000:2FFF - * Put the default Font @ C000:3000 - C000:3FFF - */ - - *(u_long *)&BIOSDATA[0xA8] = 0xC0000000; /* 0040:00A8 points to us */ - - vsp = (struct VideoSavePointerTable *)0xC0000L; - memset(vsp, 0, sizeof(struct VideoSavePointerTable)); - svsp = (struct SecondaryVideoSavePointerTable *)0xC0020L; - - vsp->video_parameter_tabel[0] = 0x1000; - vsp->video_parameter_tabel[1] = 0xC000; - - vsp->secondary_save_pointer_table[0] = 0x0020; - vsp->secondary_save_pointer_table[1] = 0xC000; - - svsp->display_combination_code_table[0] = 0x0040; - svsp->display_combination_code_table[1] = 0xC000; - - p = (u_char *)0xC0040; - *p++ = 2; /* Only support 2 combinations currently */ - *p++ = 1; /* Version # */ - *p++ = 8; /* We wont use more than type 8 */ - *p++ = 0; /* Resereved */ - *p++ = 0; *p++ = 0; /* No Display No Display */ - *p++ = 0; *p++ = 8; /* No Display VGA Color */ - - memcpy((void *)0xC1000, videoparams, sizeof(videoparams)); - - ivec[0x1d] = 0xC0001000L; /* Video Parameter Table */ - ivec[0x1e] = 0xC0003000L; - ivec[0x42] = ivec[0x10]; /* Copy of video interrupt */ - memcpy((void *)0xC3000L, ascii_font, sizeof(ascii_font)); - - BIOSDATA[0x49] = 3; /* Video Mode */ - *(u_short *)&BIOSDATA[0x4a] = 80; /* Columns on Screen */ - *(u_short *)&BIOSDATA[0x4c] = 0; /* Page */ - *(u_short *)&BIOSDATA[0x4e] = 0; /* Offset into video memory */ - *(u_short *)&BIOSDATA[0x63] = 0x03d4; /* controller base reg */ - BIOSDATA[0x84] = 24; /* Rows on screen */ - *(u_short *)&BIOSDATA[0x85] = 16; /* font height */ - BIOSDATA[0x87] = 0; /* video ram etc. */ - BIOSDATA[0x88] = 0xf9; /* video switches */ - BIOSDATA[0x89] = 0x11; /* video stats */ - BIOSDATA[0x8a] = 1; /* Index into DCC table */ - BIOSDATA[0x96] = 0x10; - K1_STATUS = 0; - K2_STATUS = 0; - K3_STATUS = 0; - K4_STATUS = 0; + if ((fd = open("vram", O_WRONLY | O_CREAT, 0644)) == -1) + err(1, "Can't open vram file"); + (void)write(fd, (void *)vram, 256 * 1024); - vec = insert_softint_trampoline(); - ivec[0x10] = vec; - register_callback(vec, int10, "int 10"); + return; } diff --git a/usr.bin/doscmd/tty.h b/usr.bin/doscmd/tty.h new file mode 100644 index 0000000..2c4b4c1 --- /dev/null +++ b/usr.bin/doscmd/tty.h @@ -0,0 +1,68 @@ +/* + * Copyright (c) 2001 The FreeBSD Project, Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY The FreeBSD Project, Inc. AND CONTRIBUTORS + * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL The FreeBSD Project, Inc. OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; + * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * $FreeBSD$ + */ + +/* TTY subsystem XXX rewrite! */ +int redirect0; +int redirect1; +int redirect2; +extern int kbd_fd; +extern char *xfont; + +u_short KbdRead(void); +u_short KbdPeek(void); +void KbdWrite(u_short); + +void Failure(); +void get_lines(void); +void get_ximage(void); +void init_window(void); +void init_ximage(int, int); +void load_font(void); +void resize_window(void); +int tty_eread(REGISTERS, int, int); +int tty_estate(void); +void tty_write(int, int); +void tty_rwrite(int, int, int); +void tty_move(int, int); +int tty_read(regcontext_t *, int); +void tty_report(int *, int *); +void tty_flush(); +void tty_index(); +void tty_pause(); +int tty_peek(REGISTERS, int); +int tty_state(); +void tty_scroll(int, int, int, int, int, int); +void tty_rscroll(int, int, int, int, int, int); +int tty_char(int, int); +void video_blink(int); +void video_setborder(int); +void video_update(regcontext_t *); +void console_init(void); +void kbd_init(void); +void kbd_bios_init(void); +void update_pixels(void); diff --git a/usr.bin/doscmd/video.c b/usr.bin/doscmd/video.c new file mode 100644 index 0000000..6c5fabc3 --- /dev/null +++ b/usr.bin/doscmd/video.c @@ -0,0 +1,713 @@ +/* + * Copyright (c) 2001 The FreeBSD Project, Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY The FreeBSD Project, Inc. AND CONTRIBUTORS + * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL The FreeBSD Project, Inc. OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; + * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * $FreeBSD$ + */ + +#include <sys/types.h> +#include <sys/mman.h> +#include <err.h> +#include <paths.h> +#include <unistd.h> + +#include "doscmd.h" +#include "AsyncIO.h" +#include "tty.h" +#include "video.h" +#include "vparams.h" + +/* + * Global variables + */ + +/* VGA registers */ +u_int8_t VGA_CRTC[CRTC_Size]; +u_int8_t VGA_ATC[ATC_Size]; +u_int8_t VGA_TSC[TSC_Size]; +u_int8_t VGA_GDC[GDC_Size]; + +/* VGA status information */ +u_int8_t vga_status[64]; + +/* Table of supported video modes. */ +vmode_t vmodelist[] = { + {0x00, 0x17, TEXT, 16, 8, 2, 0xb8000, FONT8x16}, + {0x01, 0x17, TEXT, 16, 8, 2, 0xb8000, FONT8x16}, + {0x02, 0x18, TEXT, 16, 8, 2, 0xb8000, FONT8x16}, + {0x03, 0x18, TEXT, 16, 8, 2, 0xb8000, FONT8x16}, + {0x04, 0x04, GRAPHICS, 4, 1, 0, 0xb8000, FONT8x8}, + {0x05, 0x05, GRAPHICS, 4, 1, 0, 0xb8000, FONT8x8}, + {0x06, 0x06, GRAPHICS, 2, 1, 0, 0xb8000, FONT8x8}, + {0x07, 0x19, TEXT, 1, 8, 2, 0xb0000, FONT8x16}, + {0x08, 0x08, NOMODE, 0, 0, 0, 0, 0}, + {0x09, 0x09, NOMODE, 0, 0, 0, 0, 0}, + {0x0a, 0x0a, NOMODE, 0, 0, 0, 0, 0}, + {0x0b, 0x0b, NOMODE, 0, 0, 0, 0, 0}, + {0x0c, 0x0c, NOMODE, 0, 0, 0, 0, 0}, + {0x0d, 0x0d, GRAPHICS, 16, 8, 0, 0xa0000, FONT8x8}, + {0x0e, 0x0e, GRAPHICS, 16, 4, 0, 0xa0000, FONT8x8}, + {0x0f, 0x11, GRAPHICS, 1, 2, 1, 0xa0000, FONT8x14}, + {0x10, 0x12, GRAPHICS, 16, 2, 1, 0xa0000, FONT8x14}, + {0x11, 0x1a, GRAPHICS, 2, 1, 3, 0xa0000, FONT8x16}, + {0x12, 0x1b, GRAPHICS, 16, 1, 3, 0xa0000, FONT8x16}, + /* {0x13, 0x1c, GRAPHICS, 256, 1, 0, 0xa0000, FONT8x8}, */ +}; + +#define NUMMODES (sizeof(vmodelist) / sizeof(vmode_t)) + +/* + * Local functions + */ +static void init_vga(void); +static u_int8_t video_inb(int); +static void video_outb(int, u_int8_t); + +/* + * Local types and variables + */ + +/* Save Table and assorted variables */ +struct VideoSaveTable { + u_short video_parameter_table[2]; + u_short parameter_dynamic_save_area[2]; /* Not used */ + u_short alphanumeric_character_set_override[2]; /* Not used */ + u_short graphics_character_set_override[2]; /* Not used */ + u_short secondary_save_table[2]; /* Not used */ + u_short mbz[4]; +}; + +struct SecondaryVideoSaveTable { + u_short length; + u_short display_combination_code_table[2]; + u_short alphanumeric_character_set_override[2]; /* Not used */ + u_short user_palette_profile_table[2]; /* Not used */ + u_short mbz[6]; +}; + +struct VideoSaveTable *vsp; +struct SecondaryVideoSaveTable *svsp; + +/* + * Read and write the VGA port + */ + +/* Save the selected index register */ +static u_int8_t crtc_index, atc_index, tsc_index, gdc_index; +/* Toggle between index and data on port ATC_WritePort */ +static u_int8_t set_atc_index = 1; + +static u_int8_t +video_inb(int port) +{ + switch(port) { + case CRTC_DataPortColor: + return VGA_CRTC[crtc_index]; + case CRTC_IndexPortColor: + return crtc_index; + case ATC_ReadPort: + return VGA_ATC[atc_index]; + case TSC_DataPort: + return VGA_TSC[tsc_index]; + case TSC_IndexPort: + return tsc_index; + case GDC_DataPort: + return VGA_GDC[gdc_index]; + case GDC_IndexPort: + return gdc_index; + case VGA_InputStatus1Port: + set_atc_index = 1; + return VGA_InputStatus1; + default: + return 0; + } +} + +static void +video_outb(int port, u_int8_t value) +{ +/* XXX */ +#define row (CursRow0) +#define col (CursCol0) + + int cp; + + switch (port) { + case CRTC_IndexPortColor: + crtc_index = value; + break; + case CRTC_DataPortColor: + VGA_CRTC[crtc_index] = value; + switch (crtc_index) { + case CRTC_CurLocHi: /* Update cursor position in BIOS */ + cp = row * DpyCols + col; + cp &= 0xff; + cp |= value << 8; + row = cp / DpyCols; + col = cp % DpyCols; + break; + case CRTC_CurLocLo: /* Update cursor position in BIOS */ + cp = row * DpyCols + col; + cp &= 0xff00; + cp |= value; + row = cp / DpyCols; + col = cp % DpyCols; + break; + default: + debug(D_VIDEO, "outb 0x%04x, 0x%02x at index 0x%02x\n", + port, value, crtc_index); + break; + } + case CRTC_IndexPortMono: /* Not used */ + break; + case CRTC_DataPortMono: /* Not used */ + break; + case ATC_WritePort: + if (set_atc_index) + atc_index = value; + else { + VGA_ATC[atc_index] = value; + switch (atc_index) { + default: + debug(D_VIDEO, "outb 0x%04x, 0x%02x at index 0x%02x\n", + port, value, crtc_index); + break; + } + } + set_atc_index = 1 - set_atc_index; + break; + case TSC_IndexPort: + tsc_index = value; + break; + case TSC_DataPort: + VGA_TSC[tsc_index] = value; + switch (tsc_index) { + default: + debug(D_VIDEO, "outb 0x%04x, 0x%02x at index 0x%02x\n", + port, value, crtc_index); + break; + } + break; + case GDC_IndexPort: + gdc_index = value; + break; + case GDC_DataPort: + VGA_GDC[gdc_index] = value; +#if 0 + switch (gdc_index) { + default: + debug(D_VIDEO, "outb 0x%04x, 0x%02x at index 0x%02x\n", + port, value, crtc_index); + + break; + } +#endif + break; + default: + debug(D_ALWAYS, "Unknown port 0x%4x\n", port); + break; + } + + return; +#undef row +#undef col +} + +void +video_init() +{ + /* If we are running under X, get a connection to the X server and create + an empty window of size (1, 1). It makes a couple of init functions a + lot easier. */ + if (xmode) { + init_window(); + + /* Set VGA emulator to a sane state */ + init_vga(); + + /* Initialize mode 3 (text, 80x25, 16 colors) */ + init_mode(3); + } + + /* Define all known I/O port handlers */ + if (!raw_kbd) { + define_input_port_handler(CRTC_IndexPortColor, video_inb); + define_input_port_handler(CRTC_DataPortColor, video_inb); + define_input_port_handler(ATC_ReadPort, video_inb); + define_input_port_handler(TSC_IndexPort, video_inb); + define_input_port_handler(TSC_DataPort, video_inb); + define_input_port_handler(GDC_IndexPort, video_inb); + define_input_port_handler(GDC_DataPort, video_inb); + + define_output_port_handler(CRTC_IndexPortColor, video_outb); + define_output_port_handler(CRTC_DataPortColor, video_outb); + define_output_port_handler(ATC_WritePort, video_outb); + define_output_port_handler(TSC_IndexPort, video_outb); + define_output_port_handler(TSC_DataPort, video_outb); + define_output_port_handler(GDC_IndexPort, video_outb); + define_output_port_handler(GDC_DataPort, video_outb); + } + + redirect0 = isatty(0) == 0 || !xmode ; + redirect1 = isatty(1) == 0 || !xmode ; + redirect2 = isatty(2) == 0 || !xmode ; + + return; +} + +void +video_bios_init() +{ + u_char *p; + u_long vec; + + if (raw_kbd) + return; + + /* + * Put the Video Save Table Pointer @ C000:0000 + * Put the Secondary Video Save Table Pointer @ C000:0020 + * Put the Display Combination Code table @ C000:0040 + * Put the Video Parameter table @ C000:1000 - C000:2FFF + */ + BIOS_SaveTablePointer = 0xC0000000; + + vsp = (struct VideoSaveTable *)0xC0000L; + memset(vsp, 0, sizeof(struct VideoSaveTable)); + svsp = (struct SecondaryVideoSaveTable *)0xC0020L; + + vsp->video_parameter_table[0] = 0x1000; + vsp->video_parameter_table[1] = 0xC000; + + vsp->secondary_save_table[0] = 0x0020; + vsp->secondary_save_table[1] = 0xC000; + + svsp->display_combination_code_table[0] = 0x0040; + svsp->display_combination_code_table[1] = 0xC000; + + p = (u_char *)0xC0040; + *p++ = 2; /* Only support 2 combinations currently */ + *p++ = 1; /* Version # */ + *p++ = 8; /* We won't use more than type 8 */ + *p++ = 0; /* Reserved */ + *p++ = 0; *p++ = 0; /* No Display No Display */ + *p++ = 0; *p++ = 8; /* No Display VGA Color */ + + memcpy((void *)0xC1000, videoparams, sizeof(videoparams)); + ivec[0x1d] = 0xC0001000L; /* Video Parameter Table */ + + ivec[0x42] = ivec[0x10]; /* Copy of video interrupt */ + + /* Put the current font at C000:3000; the pixels are copied in + 'tty.c:load_font()'. */ + ivec[0x1f] = 0xC0003000L; + ivec[0x43] = 0xC0003000L; + + BIOSDATA[0x8a] = 1; /* Index into DCC table */ + + vec = insert_softint_trampoline(); + ivec[0x10] = vec; + register_callback(vec, int10, "int 10"); +} + +/* Initialize the VGA emulator + + XXX This is not nearly finished right now. +*/ +static void +init_vga(void) +{ + int i; + + /* Zero-fill 'dac_rgb' on allocation; the default (EGA) table has only + 64 entries. */ + dac_rgb = (struct dac_colors *)calloc(256, sizeof(struct dac_colors)); + if (dac_rgb == NULL) + err(1, "Get memory for dac_rgb"); + + /* Copy the default DAC table to a working copy we can trash. */ + for (i = 0; i < 64; i++) + dac_rgb[i] = dac_default64[i]; /* Structure copy */ + + /* Point 'palette[]' to the Attribute Controller space. We will only use + the first 16 slots. */ + palette = VGA_ATC; + + /* Get memory for the video RAM and adjust the plane pointers. */ + vram = calloc(256 * 1024, 1); /* XXX */ + if (vram == NULL) + warn("Could not get video memory; graphics modes not available."); + + /* XXX There is probably a more efficient memory layout... */ + vplane0 = vram; + vplane1 = vram + 0x10000; + vplane2 = vram + 0x20000; + vplane3 = vram + 0x30000; +} + +/* + * Initialize the requested video mode. + */ + +/* Indices into the video parameter table. We will use that array to + initialize the registers on startup and when the video mode changes. */ +#define CRTC_Ofs 10 +#define ATC_Ofs 35 +#define TSC_Ofs 5 +#define GDC_Ofs 55 +#define MiscOutput_Ofs 9 + +void +init_mode(int mode) +{ + vmode_t vmode; + int idx; /* Index into vmode */ + int pidx; /* Index into videoparams */ + + debug(D_VIDEO, "Set video mode to 0x%02x\n", mode); + + idx = find_vmode(mode & 0x7f); + if (idx == -1 || vmodelist[idx].type == NOMODE) + err(1, "Mode 0x%02x is not supported", mode); + vmode = vmodelist[idx]; + pidx = vmode.paramindex; + + /* Preset VGA registers. */ + memcpy(VGA_CRTC, (u_int8_t *)&videoparams[pidx][CRTC_Ofs], + sizeof(VGA_CRTC)); + memcpy(VGA_ATC, (u_int8_t *)&videoparams[pidx][ATC_Ofs], + sizeof(VGA_ATC)); + /* Warning: the video parameter table does not contain the Sequencer's + Reset register. Its default value is 0x03.*/ + VGA_TSC[TSC_Reset] = 0x03; + memcpy(VGA_TSC + 1, (u_int8_t *)&videoparams[pidx][TSC_Ofs], + sizeof(VGA_TSC) - 1); + memcpy(VGA_GDC, (u_int8_t *)&videoparams[pidx][GDC_Ofs], + sizeof(VGA_GDC)); + VGA_MiscOutput = videoparams[pidx][MiscOutput_Ofs]; + + /* Paranoia */ + if ((VGA_ATC[ATC_ModeCtrl] & 1) == 1 && vmode.type == TEXT) + err(1, "Text mode requested, but ATC switched to graphics mode!"); + if ((VGA_ATC[ATC_ModeCtrl] & 1) == 0 && vmode.type == GRAPHICS) + err(1, "Graphics mode requested, but ATC switched to text mode!"); + + VideoMode = mode & 0x7f; + DpyCols = (u_int16_t)videoparams[pidx][0]; + DpyPageSize = *(u_int16_t *)&videoparams[pidx][3]; + ActivePageOfs = 0; + CursCol0 = 0; + CursRow0 = 0; + CursCol1 = 0; + CursRow1 = 0; + CursCol2 = 0; + CursRow2 = 0; + CursCol3 = 0; + CursRow3 = 0; + CursCol4 = 0; + CursRow4 = 0; + CursCol5 = 0; + CursRow5 = 0; + CursCol6 = 0; + CursRow6 = 0; + CursCol7 = 0; + CursRow7 = 0; + CursStart = VGA_CRTC[CRTC_CursStart]; + CursEnd = VGA_CRTC[CRTC_CursEnd]; + ActivePage = 0; + DpyRows = videoparams[pidx][1]; + CharHeight = videoparams[pidx][2]; + + CRTCPort = vmode.numcolors > 1 ? CRTC_IndexPortColor : CRTC_IndexPortMono; + NumColors = vmode.numcolors; + NumPages = vmode.numpages; + VertResolution = vmode.vrescode; + vmem = (u_int16_t *)vmode.vmemaddr; + + /* Copy VGA related BIOS variables from 'vga_status'. */ + memcpy(&BIOS_VideoMode, &VideoMode, 33); + BIOS_DpyRows = DpyRows; + BIOS_CharHeight = CharHeight; + + _BlockIO(); + /* Load 'pixels[]' from default DAC values. */ + update_pixels(); + + /* Update font. */ + xfont = vmode.fontname; + load_font(); + + /* Resize window if necessary. */ + resize_window(); + _UnblockIO(); + + /* Mmap video memory for the graphics modes. Write access to 0xa0000 - + 0xaffff will generate a T_PAGEFAULT trap in VM86 mode (aside: why not a + SIGSEGV?), which is handled in 'trap.c:sigbus()'. */ + if (vmode.type == GRAPHICS) { + vmem = mmap((void *)0xa0000, 64 * 1024, PROT_READ, + MAP_ANON | MAP_FIXED | MAP_INHERIT | MAP_SHARED, -1, 0); + if (vmem == NULL) + fatal("Could not mmap() video memory"); + + /* Create an XImage to display the graphics screen. */ + get_ximage(); + } else { + int i; + + get_lines(); + if (mode & 0x80) + return; + /* Initialize video memory with black background, white foreground */ + vattr = 0x0700; + for (i = 0; i < DpyPageSize / 2; ++i) + vmem[i] = vattr; + } + + return; +} + +/* Find the requested mode in the 'vmodelist' table. This function returns the + index into this table; we will also use the index for accessing the + 'videoparams' array. */ +int find_vmode(int mode) +{ + int i; + + for (i = 0; i < NUMMODES; i++) + if (vmodelist[i].modenumber == mode) + return i; + + return -1; +} + + + +/* Handle access to the graphics memory. + + Simply changing the protection for the memory is not enough, unfortunately. + It would only work for the 256 color modes, where a memory byte contains + the color value of one pixel. The 16 color modes (and 4 color modes) make + use of four bit planes which overlay the first 64K of video memory. The + bits are distributed into these bit planes according to the GDC state, so + we will have to emulate the CPU instructions (see 'cpu.c:emu_instr()'). + + Handling the 256 color modes will be a bit easier, once we support those at + all. */ +int +vmem_pageflt(struct sigframe *sf) +{ + regcontext_t *REGS = (regcontext_t *)(&sf->sf_uc.uc_mcontext); + + /* The ATC's Mode Control register tells us whether 4 or 8 color bits are + used */ + if (VGA_ATC[ATC_ModeCtrl] & (1 << 6)) { + /* 256 colors, allow writes; the protection will be set back to + PROT_READ at the next display update */ + mprotect(vmem, 64 * 1024, PROT_READ | PROT_WRITE); + return 0; + } + + /* There's no need to change the protection in the 16 color modes, we will + write to 'vram'. Just emulate the next instruction. */ + return emu_instr(REGS); +} + +/* Write a byte to the video memory. 'vga_write()' is called from + 'cpu.c:write_word()' and will emulate the VGA write modes. Not all four + modes are implemented yet, nor are the addressing modes (odd/even, chain4). + (NB: I think the latter will have to be done in 'tty_graphics_update()'). + */ +void +vga_write(u_int32_t addr, u_int8_t val) +{ + u_int32_t dst; + u_int8_t *latch0, *latch1, *latch2, *latch3; + u_int8_t c0, c1, c2, c3; + u_int8_t m0, m1, m2, m3; + u_int8_t mask; +#if 0 + int i; + + debug(D_VIDEO, "Write 0x%02x to 0x%x\n", val, addr); + debug(D_VIDEO, "GDC: "); + for (i = 0; i < sizeof(VGA_GDC); i++) + debug(D_VIDEO, "%02x ", VGA_GDC[i]); + debug(D_VIDEO, "\n"); + debug(D_VIDEO, "TSC: "); + for (i = 0; i < sizeof(VGA_TSC); i++) + debug(D_VIDEO, "%02x ", VGA_TSC[i]); + debug(D_VIDEO, "\n"); +#endif + + /* 'addr' lies between 0xa0000 and 0xaffff */ + dst = addr - 0xa0000; + + /* fill latches */ + latch0 = vplane0 + dst; + latch1 = vplane1 + dst; + latch2 = vplane2 + dst; + latch3 = vplane3 + dst; + + c0 = *latch0; + c1 = *latch1; + c2 = *latch2; + c3 = *latch3; + + /* select write mode */ + switch (VGA_GDC[GDC_Mode] & 3) { + case 0: + /* XXX to do: Enable Set Reset register */ + + mask = VGA_GDC[GDC_BitMask]; + + /* select function */ + switch (VGA_GDC[GDC_DataRotate] & 0x18) { + case 0x00: /* replace */ + m0 = VGA_GDC[GDC_SetReset] & 1 ? mask : 0x00; + m1 = VGA_GDC[GDC_SetReset] & 2 ? mask : 0x00; + m2 = VGA_GDC[GDC_SetReset] & 4 ? mask : 0x00; + m3 = VGA_GDC[GDC_SetReset] & 8 ? mask : 0x00; + + c0 &= ~mask; + c1 &= ~mask; + c2 &= ~mask; + c3 &= ~mask; + + c0 |= m0; + c1 |= m1; + c2 |= m2; + c3 |= m3; + break; + case 0x08: /* and */ + m0 = VGA_GDC[GDC_SetReset] & 1 ? 0xff : ~mask; + m1 = VGA_GDC[GDC_SetReset] & 2 ? 0xff : ~mask; + m2 = VGA_GDC[GDC_SetReset] & 4 ? 0xff : ~mask; + m3 = VGA_GDC[GDC_SetReset] & 8 ? 0xff : ~mask; + + c0 &= m0; + c1 &= m1; + c2 &= m2; + c3 &= m3; + break; + case 0x10: /* or */ + m0 = VGA_GDC[GDC_SetReset] & 1 ? mask : 0x00; + m1 = VGA_GDC[GDC_SetReset] & 2 ? mask : 0x00; + m2 = VGA_GDC[GDC_SetReset] & 4 ? mask : 0x00; + m3 = VGA_GDC[GDC_SetReset] & 8 ? mask : 0x00; + + c0 |= m0; + c1 |= m1; + c2 |= m2; + c3 |= m3; + break; + case 0x18: /* xor */ + m0 = VGA_GDC[GDC_SetReset] & 1 ? mask : 0x00; + m1 = VGA_GDC[GDC_SetReset] & 2 ? mask : 0x00; + m2 = VGA_GDC[GDC_SetReset] & 4 ? mask : 0x00; + m3 = VGA_GDC[GDC_SetReset] & 8 ? mask : 0x00; + + c0 ^= m0; + c1 ^= m1; + c2 ^= m2; + c3 ^= m3; + break; + } + break; + case 1: + /* not yet */ + break; + case 2: + mask = VGA_GDC[GDC_BitMask]; + + /* select function */ + switch (VGA_GDC[GDC_DataRotate] & 0x18) { + case 0x00: /* replace */ + m0 = (val & 1 ? 0xff : 0x00) & mask; + m1 = (val & 2 ? 0xff : 0x00) & mask; + m2 = (val & 4 ? 0xff : 0x00) & mask; + m3 = (val & 8 ? 0xff : 0x00) & mask; + + c0 &= ~mask; + c1 &= ~mask; + c2 &= ~mask; + c3 &= ~mask; + + c0 |= m0; + c1 |= m1; + c2 |= m2; + c3 |= m3; + break; + case 0x08: /* AND */ + m0 = (val & 1 ? 0xff : 0x00) | ~mask; + m1 = (val & 2 ? 0xff : 0x00) | ~mask; + m2 = (val & 4 ? 0xff : 0x00) | ~mask; + m3 = (val & 8 ? 0xff : 0x00) | ~mask; + + c0 &= m0; + c1 &= m1; + c2 &= m2; + c3 &= m3; + break; + case 0x10: /* OR */ + m0 = (val & 1 ? 0xff : 0x00) & mask; + m1 = (val & 2 ? 0xff : 0x00) & mask; + m2 = (val & 4 ? 0xff : 0x00) & mask; + m3 = (val & 8 ? 0xff : 0x00) & mask; + + c0 |= m0; + c1 |= m1; + c2 |= m2; + c3 |= m3; + break; + case 0x18: /* XOR */ + m0 = (val & 1 ? 0xff : 0x00) & mask; + m1 = (val & 2 ? 0xff : 0x00) & mask; + m2 = (val & 4 ? 0xff : 0x00) & mask; + m3 = (val & 8 ? 0xff : 0x00) & mask; + + c0 ^= m0; + c1 ^= m1; + c2 ^= m2; + c3 ^= m3; + break; + } + break; + case 3: + /* not yet */ + break; + } + + /* write back changed byte, depending on Map Mask register */ + if (VGA_TSC[TSC_MapMask] & 1) + *latch0 = c0; + if (VGA_TSC[TSC_MapMask] & 2) + *latch1 = c1; + if (VGA_TSC[TSC_MapMask] & 4) + *latch2 = c2; + if (VGA_TSC[TSC_MapMask] & 8) + *latch3 = c3; + + return; +} diff --git a/usr.bin/doscmd/video.h b/usr.bin/doscmd/video.h index 7b36eb7..32daebb 100644 --- a/usr.bin/doscmd/video.h +++ b/usr.bin/doscmd/video.h @@ -33,122 +33,344 @@ */ /* - * Motorola 6845 Video Controller registers + * The VGA CRT Controller + */ +extern u_int8_t VGA_CRTC[]; + +/* CRTC registers + + We use the VGA register functions and don't care about the MDA. We also + leave out the undocumented registers at 0x22, 0x24, 0x3?. */ +#define CRTC_HorzTotal 0x00 +#define CRTC_HorzDispEnd 0x01 +#define CRTC_StartHorzBlank 0x02 +#define CRTC_EndHorzBlank 0x03 +#define CRTC_StartHorzRetrace 0x04 +#define CRTC_EndHorzRetrace 0x05 +#define CRTC_VertTotal 0x06 +#define CRTC_Overflow 0x07 +#define CRTC_ResetRowScan 0x08 +#define CRTC_MaxScanLine 0x09 +#define CRTC_CursStart 0x0a +#define CRTC_CursEnd 0x0b +#define CRTC_StartAddrHi 0x0c +#define CRTC_StartAddrLo 0x0d +#define CRTC_CurLocHi 0x0e +#define CRTC_CurLocLo 0x0f +#define CRTC_StartVertRetrace 0x10 +#define CRTC_EndVertRetrace 0x11 +#define CRTC_VertDispEnd 0x12 +#define CRTC_Offset 0x13 +#define CRTC_UnderlineLoc 0x14 +#define CRTC_StartVertBlank 0x15 +#define CRTC_EndVertBlank 0x16 +#define CRTC_ModeCtrl 0x17 +#define CRTC_LineCompare 0x18 + +#define CRTC_Size 0x19 + +/* Port addresses for the CRTC + + The registers are read by + OUT index_port, reg_nr + IN data_port, res + + They are written by + OUT index_port, reg_nr + OUT data_port, value +*/ + +#define CRTC_IndexPortColor 0x03d4 /* CRTC Address Register (Color) */ +#define CRTC_DataPortColor 0x03d5 /* CRTC Data Register (Color) */ +#define CRTC_IndexPortMono 0x03b4 /* CRTC Address Register (Mono) */ +#define CRTC_DataPortMono 0x03b5 /* CRTC Data Register (Mono) */ + +/* + * VGA Attribute Controller + */ +extern u_int8_t VGA_ATC[]; + +/* ATC registers + + The palette registers are here for completeness. We'll always use a + separate array 'palette[]' to access them in our code. */ +#define ATC_Palette0 0x00 +#define ATC_Palette1 0x01 +#define ATC_Palette2 0x02 +#define ATC_Palette3 0x03 +#define ATC_Palette4 0x04 +#define ATC_Palette5 0x05 +#define ATC_Palette6 0x06 +#define ATC_Palette7 0x07 +#define ATC_Palette8 0x08 +#define ATC_Palette9 0x09 +#define ATC_PaletteA 0x0a +#define ATC_PaletteB 0x0b +#define ATC_PaletteC 0x0c +#define ATC_PaletteD 0x0d +#define ATC_PaletteE 0x0e +#define ATC_PaletteF 0x0f +#define ATC_ModeCtrl 0x10 +#define ATC_OverscanColor 0x11 +#define ATC_ColorPlaneEnable 0x12 +#define ATC_HorzPixelPanning 0x13 +#define ATC_ColorSelect 0x14 + +#define ATC_Size 0x15 + +/* Port addresses for the ATC + + The ATC has a combined index/data port at 0x03c0. To quote from Ralf + Brown's ports list: ``Every write access to this register will toggle an + internal index/data selection flipflop, so that consecutive writes to index + & data is possible through this port. To get a defined start condition, + each read access to the input status register #1 (3BAh in mono / 3DAh in + color) resets the flipflop to load index.'' */ +#define ATC_WritePort 0x03c0 +#define ATC_ReadPort 0x03c1 + +/* + * VGA Sequencer Controller + */ +extern u_int8_t VGA_TSC[]; + +/* TSC registers + + We leave out the undocumented register at 0x07. */ +#define TSC_Reset 0x00 +#define TSC_ClockingMode 0x01 +#define TSC_MapMask 0x02 +#define TSC_CharMapSelect 0x03 +#define TSC_MemoryMode 0x04 + +#define TSC_Size 0x05 + +/* Port addresses for the TSC */ +#define TSC_IndexPort 0x03c4 +#define TSC_DataPort 0x03c5 + +/* + * VGA Graphics Controller + */ +extern u_int8_t VGA_GDC[]; + +/* GDC registers */ +#define GDC_SetReset 0x00 +#define GDC_EnableSetReset 0x01 +#define GDC_ColorCompare 0x02 +#define GDC_DataRotate 0x03 +#define GDC_ReadMapSelect 0x04 +#define GDC_Mode 0x05 +#define GDC_Misc 0x06 +#define GDC_ColorDontCare 0x07 +#define GDC_BitMask 0x08 + +#define GDC_Size 0x09 + +/* Port addresses for the GDC */ +#define GDC_IndexPort 0x03ce +#define GDC_DataPort 0x03cf + +/* + * Miscellaneous VGA registers + */ +u_int8_t VGA_InputStatus0; +u_int8_t VGA_InputStatus1; +u_int8_t VGA_MiscOutput; + +u_int8_t VGA_DAC_PELData; +u_int8_t VGA_DAC_PELMask; +u_int8_t VGA_DAC_PELReadAddr; +u_int8_t VGA_DAC_PELWriteAddr; +u_int8_t VGA_DAC_State; + +/* Port addresses for miscellaneous VGA registers */ +#define VGA_InputStatus0Port 0x03c2 /* Read-only */ +#define VGA_InputStatus1Port 0x03da /* Read-only */ +#define VGA_MiscOutputPortW 0x03c2 /* Write-only */ +#define VGA_MiscOutputPortR 0x03cc /* Read-only */ + +/* Port addresses for VGA DAC registers */ +#define VGA_DAC_PELDataPort 0x03c9 /* Read/Write */ +#define VGA_DAC_PELMaskPort 0x03c6 /* Read/Write */ +#define VGA_DAC_PELReadAddrPort 0x03c7 /* Write-only */ +#define VGA_DAC_PELWriteAddrPort 0x03c8 /* Read/Write */ +#define VGA_DAC_StatePortOut 0x03c7 /* Read-only */ + +/* + * Additional variables and type definitions + */ + +/* To ease access to the palette registers, 'palette[]' will overlay the + Attribute Controller space. */ +u_int8_t *palette; + +/* Entry type for the DAC table. Each value is actually 6 bits wide. */ +struct dac_colors { + u_int8_t red; + u_int8_t green; + u_int8_t blue; +}; + +/* We need a working copy of the default DAC table. This is filled from + 'dac_default{64,256}[]' in 'video.c:init_vga()'. */ +struct dac_colors *dac_rgb; + +/* + * Video memory * - * They are read by - * OUT port,code - * IN port+1,res + * The video memory of a standard VGA card is 256K. For the standard modes, + * this is divided into four planes of 64K which are accessed according to the + * GDC state. Mode 0x13 will also fit within 64K. The higher resolution modes + * (VESA) require a bit more sophistication; we leave that for later + * implementation. + */ + +/* Video RAM */ +u_int8_t *vram; + +/* Pointers to the four bit planes */ +u_int8_t *vplane0; +u_int8_t *vplane1; +u_int8_t *vplane2; +u_int8_t *vplane3; + +/* Pointer to the video memory. The base address varies with the video mode. + 'vmem' is used directly only in the text modes; in the graphics modes, all + writes go to 'vram'. */ +u_int16_t *vmem; + +/* + * VGA status information * - * They are written by - * OUT port,code - * OUT port+1,value + * Int 10:1b returns a 64 byte block of status info for the VGA card. This + * block also contains a couple of BIOS variables, so we will use it for + * general housekeeping. */ -#define MVC_TotHorzChar 0x00 /* Total Horizontal Character */ -#define MVC_DispHorzChar 0x01 /* Display Horizontal Character */ -#define MVC_HorzSyncChar 0x02 /* Horizontal sync signal after ...char */ -#define MVC_HorzSyncDur 0x03 /* Duration of horizontal sync signal in char */ -#define MVC_TotVertChar 0x04 /* Total Vertical Character */ -#define MVC_AdjVertChar 0x05 /* Adjust Veritcal Character */ -#define MVC_DispVertChar 0x06 /* Display Vertical Charcter */ -#define MVC_VertSyncChar 0x07 /* Vertical sync signal after .. char */ -#define MVC_InterlaceMode 0x08 /* Interlace Mode */ -#define MVC_ScanLines 0x09 /* Number of scan lines per screen line */ -#define MVC_CurStartLine 0x0a /* Starting line of screen cursor */ -#define MVC_CurEndLine 0x0b /* Ending line of screen cursor */ - -#define MVC_CurHigh 0x0e /* High byte of cursor position */ -#define MVC_CurLow 0x0f /* High byte of cursor position */ +extern u_int8_t vga_status[]; + +/* Access to the VGA status fields. */ +#define StaticFuncTbl *(u_int32_t *)&vga_status[0] +#define VideoMode *(u_int8_t *)&vga_status[4] +#define DpyCols *(u_int16_t *)&vga_status[5] +#define DpyPageSize *(u_int16_t *)&vga_status[7] +#define ActivePageOfs *(u_int16_t *)&vga_status[9] +#define CursCol0 *(u_int8_t *)&vga_status[11] +#define CursRow0 *(u_int8_t *)&vga_status[12] +#define CursCol1 *(u_int8_t *)&vga_status[13] +#define CursRow1 *(u_int8_t *)&vga_status[14] +#define CursCol2 *(u_int8_t *)&vga_status[15] +#define CursRow2 *(u_int8_t *)&vga_status[16] +#define CursCol3 *(u_int8_t *)&vga_status[17] +#define CursRow3 *(u_int8_t *)&vga_status[18] +#define CursCol4 *(u_int8_t *)&vga_status[19] +#define CursRow4 *(u_int8_t *)&vga_status[20] +#define CursCol5 *(u_int8_t *)&vga_status[21] +#define CursRow5 *(u_int8_t *)&vga_status[22] +#define CursCol6 *(u_int8_t *)&vga_status[23] +#define CursRow6 *(u_int8_t *)&vga_status[24] +#define CursCol7 *(u_int8_t *)&vga_status[25] +#define CursRow7 *(u_int8_t *)&vga_status[26] +#define CursStart *(u_int8_t *)&vga_status[27] +#define CursEnd *(u_int8_t *)&vga_status[28] +#define ActivePage *(u_int8_t *)&vga_status[29] +#define CRTCPort *(u_int16_t *)&vga_status[30] +#define CGA_ModeCtrl *(u_int8_t *)&vga_status[32] +#define CGA_ColorSelect *(u_int8_t *)&vga_status[33] +#define DpyRows *(u_int8_t *)&vga_status[34] +#define CharHeight *(u_int16_t *)&vga_status[35] +#define ActiveDCC *(u_int8_t *)&vga_status[37] +#define SecondDCC *(u_int8_t *)&vga_status[38] +#define NumColors *(u_int16_t *)&vga_status[39] +#define NumPages *(u_int8_t *)&vga_status[41] +#define VertResolution *(u_int8_t *)&vga_status[42] +#define PrimaryCharset *(u_int8_t *)&vga_status[43] +#define SecondaryCharset *(u_int8_t *)&vga_status[44] +#define MiscStatus *(u_int8_t *)&vga_status[45] +/* +#define Reserved1 *(u_int16_t *)&vga_status[46] +#define Reserved2 *(u_int8_t *)&vga_status[48] +*/ +#define VMemSize *(u_int8_t *)&vga_status[49] +#define SavePointerStatus *(u_int8_t *)&vga_status[50] + +/* VGA Static Functionality Table + + This table contains mode-independent VGA status information. It is actually + defined in 'vparam.h'; the declaration here is just for completeness. */ +extern u_int8_t static_functionality_tbl[]; + +/* Add some names for the VGA related BIOS variables. */ +#define BIOS_VideoMode *(u_int8_t *)&BIOSDATA[0x49] +#define BIOS_DpyCols *(u_int16_t *)&BIOSDATA[0x4a] +#define BIOS_DpyPageSize *(u_int16_t *)&BIOSDATA[0x4c] +#define BIOS_ActivePageOfs *(u_int16_t *)&BIOSDATA[0x4e] +#define BIOS_CursCol0 *(u_int8_t *)&BIOSDATA[0x50] +#define BIOS_CursRow0 *(u_int8_t *)&BIOSDATA[0x51] +#define BIOS_CursCol1 *(u_int8_t *)&BIOSDATA[0x52] +#define BIOS_CursRow1 *(u_int8_t *)&BIOSDATA[0x53] +#define BIOS_CursCol2 *(u_int8_t *)&BIOSDATA[0x54] +#define BIOS_CursRow2 *(u_int8_t *)&BIOSDATA[0x55] +#define BIOS_CursCol3 *(u_int8_t *)&BIOSDATA[0x56] +#define BIOS_CursRow3 *(u_int8_t *)&BIOSDATA[0x57] +#define BIOS_CursCol4 *(u_int8_t *)&BIOSDATA[0x58] +#define BIOS_CursRow4 *(u_int8_t *)&BIOSDATA[0x59] +#define BIOS_CursCol5 *(u_int8_t *)&BIOSDATA[0x5a] +#define BIOS_CursRow5 *(u_int8_t *)&BIOSDATA[0x5b] +#define BIOS_CursCol6 *(u_int8_t *)&BIOSDATA[0x5c] +#define BIOS_CursRow6 *(u_int8_t *)&BIOSDATA[0x5d] +#define BIOS_CursCol7 *(u_int8_t *)&BIOSDATA[0x5e] +#define BIOS_CursRow7 *(u_int8_t *)&BIOSDATA[0x5f] +#define BIOS_CursStart *(u_int8_t *)&BIOSDATA[0x60] +#define BIOS_CursEnd *(u_int8_t *)&BIOSDATA[0x61] +#define BIOS_ActivePage *(u_int8_t *)&BIOSDATA[0x62] +#define BIOS_CRTCPort *(u_int16_t *)&BIOSDATA[0x63] +#define BIOS_CGA_ModeCtrl *(u_int8_t *)&BIOSDATA[0x65] +#define BIOS_CGA_ColorSelect *(u_int8_t *)&BIOSDATA[0x66] +#define BIOS_DpyRows *(u_int8_t *)&BIOSDATA[0x84] +#define BIOS_CharHeight *(u_int16_t *)&BIOSDATA[0x85] +#define BIOS_SaveTablePointer *(u_int32_t *)&BIOSDATA[0xa8] /* - * Additional MDA register + * Video modes + * + * This started as a big 'switch' statement in 'video.c:init_mode()' which + * soon became too ugly and unmanagable. So, we collect all mode related + * information in one table and define a couple of helper function to access + * it. This will also benefit the VESA support, whenever we get to that. */ -#define MDA_StartDispPageLo 0x0c /* Starting address of displayed screen page (lo byte) */ -#define MDA_StartDispPageHi 0x0d /* Starting address of displayed screen page (hi byte) */ -#define MDA_BlinkCurAddrHi 0x0e /* Character address of blinking screen cursor (hi byte) */ -#define MDA_BlinkCurAddrLo 0x0f /* Character address of blinking screen cursor (lo byte) */ -#define MDA_LightPenHi 0x10 /* Light Pen Position (hi byte) */ -#define MDA_LightPenLo 0x11 /* Light Pen Position (lo byte) */ - -#define MDA_Control 0x03b8 /* MDA Control Register Port */ -#define MVC_Address 0x03b4 /* MVC Address Register */ -#define MVC_Data 0x03b5 /* MVC Data Register */ -#define MDA_VideoSeg 0xb800 /* Segmet address of video ram */ - -#define CGA_Control 0x03d8 /* CGA Control Register Port */ -#define CGA_Status 0x03da /* CGA Control Register Port */ -#define CVC_Address 0x03d4 /* CVC Address Register */ -#define CVC_Data 0x03d5 /* CVC Data Register */ - -#define CGA_Black 0x0 -#define CGA_Blue 0x1 -#define CGA_Green 0x2 -#define CGA_Cyan 0x3 -#define CGA_Red 0x4 -#define CGA_Magenta 0x5 -#define CGA_Brown 0x6 -#define CGA_LightGray 0x7 -#define CGA_DarkGray 0x8 -#define CGA_LightBlue 0x9 -#define CGA_LightGreen 0xa -#define CGA_LightCyan 0xb -#define CGA_LightRed 0xc -#define CGA_LightMagenta 0xd -#define CGA_Yellow 0xe -#define CGA_White 0xf - -#define VGA_Segment 0xa000 /* Starting Segment of VGA Memory */ -#define V_int 0x10 /* interrupt for dealing with screen */ -#define V_mode 0 /* code for setting new screen mode */ -#define V_curtype 1 /* code for setting new cursor type */ -#define V_setcur 2 /* code for addressing cursor */ -#define V_readcur 3 /* code for reading cursor location */ -#define V_readlp 4 /* code for reading light pen position */ -#define V_setpage 5 /* code to select active page */ -#define V_scrollup 6 /* code to scroll screen up */ -#define V_scrolldn 7 /* code to scroll screen nown */ -#define V_readch 8 /* code to read a character from screen */ -#define V_writeach 9 /* code to write char and attributes */ -#define V_writech 10 /* code to write character only */ -#define V_setpal 11 /* code to set new setpal or border */ -#define V_wdot 12 /* code to write a dot */ -#define V_rdot 13 /* code to read a dot */ -#define V_wtty 14 /* code to write as if teletype */ -#define V_state 15 /* code to find current screen status */ - -#define VM_40x25 0x00 -#define VM_80x25 0x02 -#define VM_320x200x4 0x04 -#define VM_640x200x2 0x06 -#define VM_80x25mono 0x07 -#define VM_320x200x16 0x0d -#define VM_640x200x16 0x0e -#define VM_640x350mono 0x0f -#define VM_640x350x16 0x10 -#define VM_640x480x2 0x11 -#define VM_640x480x16 0x12 -#define VM_320x200x256 0x13 -#define VM_80x30 0x50 -#define VM_80x43 0x51 -#define VM_80x60 0x52 -#define VM_132x25 0x53 -#define VM_132x30 0x54 -#define VM_132x43 0x55 -#define VM_132x60 0x56 -#define VM_132x25h 0x57 -#define VM_132x30h 0x58 -#define VM_132x43h 0x59 -#define VM_132x60h 0x5a -#define VM_800x600x16 0x5b -#define VM_640x400x256 0x5c -#define VM_640x480x256 0x5d -#define VM_800x600x256 0x5e -#define VM_1024x768x16 0x5f -#define VM_1024x768x4 0x60 -#define VM_768x1024x16 0x61 -#define VM_1024x768x256 0x62 - -#define VM_VGA VM_640x480x256 -#define VM_EVGA VM_800x600x256 -#define VM_SVGAportrait VM_768x1024x16 -#define VM_SVGA16 VM_1024x768x16 -#define VM_SVGA256 VM_1024x768x256 +typedef struct { + int modenumber; /* Mode number */ + int paramindex; /* Index into the parameter table */ + int type; /* Text or Graphics */ + int numcolors; /* Number of colors */ + int numpages; /* Number of display pages */ + int vrescode; /* 0 = 200, 1 = 350, 2 = 400, 3 = 480 */ + u_int32_t vmemaddr; /* Video memory address */ + char *fontname; /* Font name */ +} vmode_t; + +/* Types. 'NOMODE' is one of the 'forbidden' internal modes. */ +#define TEXT 0 +#define GRAPHICS 1 +#define NOMODE -1 + +extern vmode_t vmodelist[]; + +/* Font names */ +#define FONTVGA "vga" +#define FONT8x8 "vga8x8" +#define FONT8x14 "vga8x14" +#define FONT8x16 "vga8x16" /* same as FONTVGA */ + +/* External functions in 'video.c'. */ +extern void init_mode(int); +extern int find_vmode(int); +extern void vga_write(u_int32_t, u_int8_t); +extern void video_bios_init(void); +extern void video_init(void); +extern int vmem_pageflt(struct sigframe *); + +/* Other external variables, mostly from tty.c. Needs to be cleaned up. */ +extern int vattr; +void write_vram(void *); diff --git a/usr.bin/doscmd/vparams.h b/usr.bin/doscmd/vparams.h index 59aee81..dce9027 100644 --- a/usr.bin/doscmd/vparams.h +++ b/usr.bin/doscmd/vparams.h @@ -28,295 +28,468 @@ * SUCH DAMAGE. * * BSDI vparams.h,v 2.2 1996/04/08 19:33:13 bostic Exp + * + * $FreeBSD$ */ -unsigned char videoparams[][64] = { - { 0x28, 0x18, 0x08, 0x00, 0x08, 0x09, 0x03, 0x00, - 0x02, 0x63, 0x2d, 0x27, 0x28, 0x90, 0x2b, 0xa0, - 0xbf, 0x1f, 0x00, 0xc7, 0x06, 0x07, 0x00, 0x00, - 0x00, 0x00, 0x9c, 0x8e, 0x8f, 0x14, 0x1f, 0x96, - 0xb9, 0xa3, 0xff, 0x00, 0x01, 0x02, 0x03, 0x04, - 0x05, 0x06, 0x07, 0x10, 0x11, 0x12, 0x13, 0x14, - 0x15, 0x16, 0x17, 0x08, 0x00, 0x0f, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x10, 0x0e, 0x00, 0xff, - }, - { 0x28, 0x18, 0x08, 0x00, 0x08, 0x09, 0x03, 0x00, - 0x02, 0x63, 0x2d, 0x27, 0x28, 0x90, 0x2b, 0xa0, - 0xbf, 0x1f, 0x00, 0xc7, 0x06, 0x07, 0x00, 0x00, - 0x00, 0x00, 0x9c, 0x8e, 0x8f, 0x14, 0x1f, 0x96, - 0xb9, 0xa3, 0xff, 0x00, 0x01, 0x02, 0x03, 0x04, - 0x05, 0x06, 0x07, 0x10, 0x11, 0x12, 0x13, 0x14, - 0x15, 0x16, 0x17, 0x08, 0x00, 0x0f, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x10, 0x0e, 0x00, 0xff, - }, - { 0x50, 0x18, 0x08, 0x00, 0x10, 0x01, 0x03, 0x00, - 0x02, 0x63, 0x5f, 0x4f, 0x50, 0x82, 0x55, 0x81, - 0xbf, 0x1f, 0x00, 0xc7, 0x06, 0x07, 0x00, 0x00, - 0x00, 0x00, 0x9c, 0x8e, 0x8f, 0x28, 0x1f, 0x96, - 0xb9, 0xa3, 0xff, 0x00, 0x01, 0x02, 0x03, 0x04, - 0x05, 0x06, 0x07, 0x10, 0x11, 0x12, 0x13, 0x14, - 0x15, 0x16, 0x17, 0x08, 0x00, 0x0f, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x10, 0x0e, 0x00, 0xff, - }, - { 0x50, 0x18, 0x08, 0x00, 0x10, 0x01, 0x03, 0x00, - 0x02, 0x63, 0x5f, 0x4f, 0x50, 0x82, 0x55, 0x81, - 0xbf, 0x1f, 0x00, 0xc7, 0x06, 0x07, 0x00, 0x00, - 0x00, 0x00, 0x9c, 0x8e, 0x8f, 0x28, 0x1f, 0x96, - 0xb9, 0xa3, 0xff, 0x00, 0x01, 0x02, 0x03, 0x04, - 0x05, 0x06, 0x07, 0x10, 0x11, 0x12, 0x13, 0x14, - 0x15, 0x16, 0x17, 0x08, 0x00, 0x0f, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x10, 0x0e, 0x00, 0xff, - }, - { 0x28, 0x18, 0x08, 0x00, 0x40, 0x09, 0x03, 0x00, - 0x02, 0x63, 0x2d, 0x27, 0x28, 0x90, 0x2b, 0x80, - 0xbf, 0x1f, 0x00, 0xc1, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x9c, 0x8e, 0x8f, 0x14, 0x00, 0x96, - 0xb9, 0xa2, 0xff, 0x00, 0x13, 0x15, 0x17, 0x02, - 0x04, 0x06, 0x07, 0x10, 0x11, 0x12, 0x13, 0x14, - 0x15, 0x16, 0x17, 0x01, 0x00, 0x03, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x30, 0x0f, 0x00, 0xff, - }, - { 0x28, 0x18, 0x08, 0x00, 0x40, 0x09, 0x03, 0x00, - 0x02, 0x63, 0x2d, 0x27, 0x28, 0x90, 0x2b, 0x80, - 0xbf, 0x1f, 0x00, 0xc1, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x9c, 0x8e, 0x8f, 0x14, 0x00, 0x96, - 0xb9, 0xa2, 0xff, 0x00, 0x13, 0x15, 0x17, 0x02, - 0x04, 0x06, 0x07, 0x10, 0x11, 0x12, 0x13, 0x14, - 0x15, 0x16, 0x17, 0x01, 0x00, 0x03, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x30, 0x0f, 0x00, 0xff, - }, - { 0x50, 0x18, 0x08, 0x00, 0x40, 0x01, 0x01, 0x00, - 0x06, 0x63, 0x5f, 0x4f, 0x50, 0x82, 0x54, 0x80, - 0xbf, 0x1f, 0x00, 0xc1, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x9c, 0x8e, 0x8f, 0x28, 0x00, 0x96, - 0xb9, 0xc2, 0xff, 0x00, 0x17, 0x17, 0x17, 0x17, - 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, - 0x17, 0x17, 0x17, 0x01, 0x00, 0x01, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x0d, 0x00, 0xff, - }, - { 0x50, 0x18, 0x0e, 0x00, 0x10, 0x00, 0x03, 0x00, - 0x03, 0xa6, 0x5f, 0x4f, 0x50, 0x82, 0x55, 0x81, - 0xbf, 0x1f, 0x00, 0x4d, 0x0b, 0x0c, 0x00, 0x00, - 0x00, 0x00, 0x83, 0x85, 0x5d, 0x28, 0x0d, 0x63, - 0xba, 0xa3, 0xff, 0x00, 0x08, 0x08, 0x08, 0x08, - 0x08, 0x08, 0x08, 0x10, 0x18, 0x18, 0x18, 0x18, - 0x18, 0x18, 0x18, 0x0e, 0x00, 0x0f, 0x08, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x10, 0x0a, 0x00, 0xff, - }, - { 0x50, 0x18, 0x10, 0x00, 0x10, 0x01, 0x03, 0x00, - 0x02, 0x62, 0x5f, 0x4f, 0x50, 0x82, 0x55, 0x81, - 0xbf, 0x1f, 0x00, 0x4f, 0x0d, 0x0e, 0x00, 0x00, - 0x00, 0x00, 0x9c, 0x8e, 0x8f, 0x28, 0x0f, 0x96, - 0xb9, 0xa3, 0xff, 0x00, 0x08, 0x08, 0x08, 0x08, - 0x08, 0x08, 0x08, 0x10, 0x18, 0x18, 0x18, 0x18, - 0x18, 0x18, 0x18, 0x0a, 0x00, 0x0f, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x10, 0x0a, 0x00, 0xff, - }, - { 0x28, 0x18, 0x10, 0x00, 0x08, 0x09, 0x03, 0x00, - 0x02, 0x63, 0x2d, 0x27, 0x28, 0x90, 0x2b, 0xa0, - 0xbf, 0x1f, 0x00, 0x4f, 0x0d, 0x0e, 0x00, 0x00, - 0x00, 0x00, 0x9c, 0x8e, 0x8f, 0x14, 0x1f, 0x96, - 0xb9, 0xa3, 0xff, 0x00, 0x01, 0x02, 0x03, 0x04, - 0x05, 0x14, 0x07, 0x38, 0x39, 0x3a, 0x3b, 0x3c, - 0x3d, 0x3e, 0x3f, 0x08, 0x00, 0x0f, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x10, 0x0e, 0x00, 0xff, - }, - { 0x50, 0x18, 0x10, 0x00, 0x10, 0x01, 0x03, 0x00, - 0x02, 0x63, 0x60, 0x4f, 0x50, 0x82, 0x56, 0x82, - 0xbf, 0x1f, 0x00, 0x4f, 0x0d, 0x0e, 0x00, 0x00, - 0x00, 0x00, 0x9c, 0x8e, 0x8f, 0x28, 0x1f, 0x96, - 0xb9, 0xa3, 0xff, 0x00, 0x01, 0x02, 0x03, 0x04, - 0x05, 0x14, 0x07, 0x38, 0x39, 0x3a, 0x3b, 0x3c, - 0x3d, 0x3e, 0x3f, 0x08, 0x00, 0x0f, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x10, 0x0e, 0x00, 0xff, - }, - { 0x50, 0x00, 0x00, 0x00, 0x00, 0x29, 0x0f, 0x00, - 0x06, 0x62, 0x5f, 0x4f, 0x50, 0x82, 0x55, 0x81, - 0xbf, 0x1f, 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x9c, 0x8e, 0x8f, 0x28, 0x1f, 0x96, - 0xb9, 0xe3, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x3f, 0x01, 0x00, 0x0f, 0x00, 0x00, - 0x00, 0x0f, 0x00, 0x00, 0x08, 0x05, 0x0f, 0xff, - }, - { 0x50, 0x00, 0x00, 0x00, 0x00, 0x29, 0x0f, 0x00, - 0x06, 0x63, 0x5f, 0x4f, 0x50, 0x82, 0x55, 0x81, - 0xbf, 0x1f, 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x9c, 0x8e, 0x8f, 0x28, 0x1f, 0x96, - 0xb9, 0xe3, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x3f, 0x01, 0x00, 0x0f, 0x00, 0x00, - 0x00, 0x0f, 0x00, 0x00, 0x08, 0x05, 0x0f, 0xff, - }, - { 0x28, 0x18, 0x08, 0x00, 0x20, 0x09, 0x0f, 0x00, - 0x06, 0x63, 0x2d, 0x27, 0x28, 0x90, 0x2b, 0x80, - 0xbf, 0x1f, 0x00, 0xc0, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x9c, 0x8e, 0x8f, 0x14, 0x00, 0x96, - 0xb9, 0xe3, 0xff, 0x00, 0x01, 0x02, 0x03, 0x04, - 0x05, 0x06, 0x07, 0x10, 0x11, 0x12, 0x13, 0x14, - 0x15, 0x16, 0x17, 0x01, 0x00, 0x0f, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x0f, 0xff, - }, - { 0x50, 0x18, 0x08, 0x00, 0x40, 0x01, 0x0f, 0x00, - 0x06, 0x63, 0x5f, 0x4f, 0x50, 0x82, 0x54, 0x80, - 0xbf, 0x1f, 0x00, 0xc0, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x9c, 0x8e, 0x8f, 0x28, 0x00, 0x96, - 0xb9, 0xe3, 0xff, 0x00, 0x01, 0x02, 0x03, 0x04, - 0x05, 0x06, 0x07, 0x10, 0x11, 0x12, 0x13, 0x14, - 0x15, 0x16, 0x17, 0x01, 0x00, 0x0f, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x0f, 0xff, - }, - { 0x50, 0x18, 0x0e, 0x00, 0x80, 0x01, 0x0f, 0x00, - 0x06, 0xa2, 0x5f, 0x4f, 0x50, 0x82, 0x54, 0x80, - 0xbf, 0x1f, 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x83, 0x85, 0x5d, 0x28, 0x0f, 0x63, - 0xba, 0xe3, 0xff, 0x00, 0x08, 0x00, 0x00, 0x18, - 0x18, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, - 0x18, 0x00, 0x00, 0x0b, 0x00, 0x05, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x05, 0xff, - }, - { 0x50, 0x18, 0x0e, 0x00, 0x80, 0x01, 0x0f, 0x00, - 0x06, 0xa3, 0x5f, 0x4f, 0x50, 0x82, 0x54, 0x80, - 0xbf, 0x1f, 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x83, 0x85, 0x5d, 0x28, 0x0f, 0x63, - 0xba, 0xe3, 0xff, 0x00, 0x01, 0x02, 0x03, 0x04, - 0x05, 0x14, 0x07, 0x38, 0x39, 0x3a, 0x3b, 0x3c, - 0x3d, 0x3e, 0x3f, 0x01, 0x00, 0x0f, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x0f, 0xff, - }, - { 0x50, 0x18, 0x0e, 0x00, 0x80, 0x01, 0x0f, 0x00, - 0x06, 0xa2, 0x5f, 0x4f, 0x50, 0x82, 0x54, 0x80, - 0xbf, 0x1f, 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x83, 0x85, 0x5d, 0x28, 0x0f, 0x63, - 0xba, 0xe3, 0xff, 0x00, 0x08, 0x00, 0x00, 0x18, - 0x18, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, - 0x18, 0x00, 0x00, 0x0b, 0x00, 0x05, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x05, 0xff, - }, - { 0x50, 0x18, 0x0e, 0x00, 0x80, 0x01, 0x0f, 0x00, - 0x06, 0xa3, 0x5f, 0x4f, 0x50, 0x82, 0x54, 0x80, - 0xbf, 0x1f, 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x83, 0x85, 0x5d, 0x28, 0x0f, 0x63, - 0xba, 0xe3, 0xff, 0x00, 0x01, 0x02, 0x03, 0x04, - 0x05, 0x14, 0x07, 0x38, 0x39, 0x3a, 0x3b, 0x3c, - 0x3d, 0x3e, 0x3f, 0x01, 0x00, 0x0f, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x0f, 0xff, - }, - { 0x28, 0x18, 0x0e, 0x00, 0x08, 0x09, 0x03, 0x00, - 0x02, 0xa3, 0x2d, 0x27, 0x28, 0x90, 0x2b, 0xa0, - 0xbf, 0x1f, 0x00, 0x4d, 0x0b, 0x0c, 0x00, 0x00, - 0x00, 0x00, 0x83, 0x85, 0x5d, 0x14, 0x1f, 0x63, - 0xba, 0xa3, 0xff, 0x00, 0x01, 0x02, 0x03, 0x04, - 0x05, 0x14, 0x07, 0x38, 0x39, 0x3a, 0x3b, 0x3c, - 0x3d, 0x3e, 0x3f, 0x08, 0x00, 0x0f, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x10, 0x0e, 0x00, 0xff, - }, - { 0x28, 0x18, 0x0e, 0x00, 0x08, 0x09, 0x03, 0x00, - 0x02, 0xa3, 0x2d, 0x27, 0x28, 0x90, 0x2b, 0xa0, - 0xbf, 0x1f, 0x00, 0x4d, 0x0b, 0x0c, 0x00, 0x00, - 0x00, 0x00, 0x83, 0x85, 0x5d, 0x14, 0x1f, 0x63, - 0xba, 0xa3, 0xff, 0x00, 0x01, 0x02, 0x03, 0x04, - 0x05, 0x14, 0x07, 0x38, 0x39, 0x3a, 0x3b, 0x3c, - 0x3d, 0x3e, 0x3f, 0x08, 0x00, 0x0f, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x10, 0x0e, 0x00, 0xff, - }, - { 0x50, 0x18, 0x0e, 0x00, 0x10, 0x01, 0x03, 0x00, - 0x02, 0xa3, 0x5f, 0x4f, 0x50, 0x82, 0x55, 0x81, - 0xbf, 0x1f, 0x00, 0x4d, 0x0b, 0x0c, 0x00, 0x00, - 0x00, 0x00, 0x83, 0x85, 0x5d, 0x28, 0x1f, 0x63, - 0xba, 0xa3, 0xff, 0x00, 0x01, 0x02, 0x03, 0x04, - 0x05, 0x14, 0x07, 0x38, 0x39, 0x3a, 0x3b, 0x3c, - 0x3d, 0x3e, 0x3f, 0x08, 0x00, 0x0f, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x10, 0x0e, 0x00, 0xff, - }, - { 0x50, 0x18, 0x0e, 0x00, 0x10, 0x01, 0x03, 0x00, - 0x02, 0xa3, 0x5f, 0x4f, 0x50, 0x82, 0x55, 0x81, - 0xbf, 0x1f, 0x00, 0x4d, 0x0b, 0x0c, 0x00, 0x00, - 0x00, 0x00, 0x83, 0x85, 0x5d, 0x28, 0x1f, 0x63, - 0xba, 0xa3, 0xff, 0x00, 0x01, 0x02, 0x03, 0x04, - 0x05, 0x14, 0x07, 0x38, 0x39, 0x3a, 0x3b, 0x3c, - 0x3d, 0x3e, 0x3f, 0x08, 0x00, 0x0f, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x10, 0x0e, 0x00, 0xff, - }, - { 0x28, 0x18, 0x10, 0x00, 0x08, 0x08, 0x03, 0x00, - 0x02, 0x67, 0x2d, 0x27, 0x28, 0x90, 0x2b, 0xa0, - 0xbf, 0x1f, 0x00, 0x4f, 0x0d, 0x0e, 0x00, 0x00, - 0x00, 0x00, 0x9c, 0x8e, 0x8f, 0x14, 0x1f, 0x96, - 0xb9, 0xa3, 0xff, 0x00, 0x01, 0x02, 0x03, 0x04, - 0x05, 0x14, 0x07, 0x38, 0x39, 0x3a, 0x3b, 0x3c, - 0x3d, 0x3e, 0x3f, 0x0c, 0x00, 0x0f, 0x08, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x10, 0x0e, 0x00, 0xff, - }, - { 0x50, 0x18, 0x10, 0x00, 0x10, 0x00, 0x03, 0x00, - 0x02, 0x67, 0x5f, 0x4f, 0x50, 0x82, 0x55, 0x81, - 0xbf, 0x1f, 0x00, 0x4f, 0x0d, 0x0e, 0x00, 0x00, - 0x00, 0x00, 0x9c, 0x8e, 0x8f, 0x28, 0x1f, 0x96, - 0xb9, 0xa3, 0xff, 0x00, 0x01, 0x02, 0x03, 0x04, - 0x05, 0x14, 0x07, 0x38, 0x39, 0x3a, 0x3b, 0x3c, - 0x3d, 0x3e, 0x3f, 0x0c, 0x00, 0x0f, 0x08, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x10, 0x0e, 0x00, 0xff, - }, - { 0x50, 0x18, 0x10, 0x00, 0x10, 0x00, 0x03, 0x00, - 0x02, 0x66, 0x5f, 0x4f, 0x50, 0x82, 0x55, 0x81, - 0xbf, 0x1f, 0x00, 0x4f, 0x0d, 0x0e, 0x00, 0x00, - 0x00, 0x00, 0x9c, 0x8e, 0x8f, 0x28, 0x0f, 0x96, - 0xb9, 0xa3, 0xff, 0x00, 0x08, 0x08, 0x08, 0x08, - 0x08, 0x08, 0x08, 0x10, 0x18, 0x18, 0x18, 0x18, - 0x18, 0x18, 0x18, 0x0e, 0x00, 0x0f, 0x08, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x10, 0x0a, 0x00, 0xff, - }, - { 0x50, 0x1d, 0x10, 0x00, 0xa0, 0x01, 0x0f, 0x00, - 0x06, 0xe3, 0x5f, 0x4f, 0x50, 0x82, 0x54, 0x80, - 0x0b, 0x3e, 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0xea, 0x8c, 0xdf, 0x28, 0x00, 0xe7, - 0x04, 0xc3, 0xff, 0x00, 0x3f, 0x3f, 0x3f, 0x3f, - 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, - 0x3f, 0x3f, 0x3f, 0x01, 0x00, 0x0f, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x01, 0xff, - }, - { 0x50, 0x1d, 0x10, 0x00, 0xa0, 0x01, 0x0f, 0x00, - 0x06, 0xe3, 0x5f, 0x4f, 0x50, 0x82, 0x54, 0x80, - 0x0b, 0x3e, 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0xea, 0x8c, 0xdf, 0x28, 0x00, 0xe7, - 0x04, 0xe3, 0xff, 0x00, 0x01, 0x02, 0x03, 0x04, - 0x05, 0x14, 0x07, 0x38, 0x39, 0x3a, 0x3b, 0x3c, - 0x3d, 0x3e, 0x3f, 0x01, 0x00, 0x0f, 0x00, 0x00, - 0x80, 0x00, 0x00, 0x00, 0x00, 0x05, 0x0f, 0xff, - }, - { 0x28, 0x18, 0x08, 0x00, 0x20, 0x01, 0x0f, 0x00, - 0x0e, 0x63, 0x5f, 0x4f, 0x50, 0x82, 0x54, 0x80, - 0xbf, 0x1f, 0x00, 0x41, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x9c, 0x8e, 0x8f, 0x28, 0x40, 0x96, - 0xb9, 0xa3, 0xff, 0x00, 0x01, 0x02, 0x03, 0x04, - 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, - 0x0d, 0x0e, 0x0f, 0x41, 0x00, 0x0f, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x40, 0x05, 0x0f, 0xff, - }, - { 0x50, 0x1d, 0x10, 0x00, 0x20, 0x01, 0x03, 0x00, - 0x02, 0xe3, 0x5f, 0x4f, 0x50, 0x82, 0x57, 0x82, - 0x08, 0x3e, 0x00, 0x4f, 0x0d, 0x0e, 0x00, 0x00, - 0x00, 0x00, 0xea, 0x8f, 0xdf, 0x28, 0x00, 0xe7, - 0x04, 0xa3, 0xff, 0x00, 0x01, 0x02, 0x03, 0x04, - 0x05, 0x14, 0x07, 0x38, 0x39, 0x3a, 0x3b, 0x3c, - 0x3d, 0x3e, 0x3f, 0x08, 0x00, 0x0f, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x10, 0x0e, 0x00, 0xff, - }, - { 0x84, 0x18, 0x10, 0x00, 0x20, 0x01, 0x03, 0x00, - 0x42, 0x62, 0x9b, 0x83, 0x86, 0x9e, 0x8a, 0x1b, - 0xbf, 0x1f, 0x00, 0x4f, 0x0d, 0x0e, 0x00, 0x00, - 0x00, 0x00, 0x9c, 0x8e, 0x8f, 0x42, 0x0f, 0x96, - 0xb9, 0xa3, 0xff, 0x00, 0x08, 0x08, 0x08, 0x08, - 0x08, 0x08, 0x08, 0x10, 0x18, 0x18, 0x18, 0x18, - 0x18, 0x18, 0x18, 0x0a, 0x00, 0x0f, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x10, 0x0a, 0x00, 0xff, - }, - { 0x84, 0x18, 0x10, 0x00, 0x20, 0x01, 0x03, 0x00, - 0x42, 0x63, 0x9b, 0x83, 0x86, 0x9e, 0x8a, 0x1b, - 0xbf, 0x1f, 0x00, 0x4f, 0x0d, 0x0e, 0x00, 0x00, - 0x00, 0x00, 0x9c, 0x8e, 0x8f, 0x42, 0x0f, 0x96, - 0xb9, 0xa3, 0xff, 0x00, 0x01, 0x02, 0x03, 0x04, - 0x05, 0x14, 0x07, 0x38, 0x39, 0x3a, 0x3b, 0x3c, - 0x3d, 0x3e, 0x3f, 0x08, 0x00, 0x0f, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x10, 0x0e, 0x00, 0xff, - }, +/* Collect some default parameters for the VGA emulator in this file. This is + supposed to be included only from 'video.c' and needs some type definitions + from 'video.h'. */ + +u_int8_t videoparams[][64] = { + /* Mode 0: Text, 40x25, CGA (200 lines) */ + { 0x28, 0x18, 0x08, 0x00, 0x08, 0x09, 0x03, 0x00, + 0x02, 0x63, 0x2d, 0x27, 0x28, 0x90, 0x2b, 0xa0, + 0xbf, 0x1f, 0x00, 0xc7, 0x06, 0x07, 0x00, 0x00, + 0x00, 0x00, 0x9c, 0x8e, 0x8f, 0x14, 0x1f, 0x96, + 0xb9, 0xa3, 0xff, 0x00, 0x01, 0x02, 0x03, 0x04, + 0x05, 0x14, 0x07, 0x38, 0x39, 0x3a, 0x3b, 0x3c, + 0x3d, 0x3e, 0x3f, 0x08, 0x00, 0x0f, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x10, 0x0e, 0x00, 0xff + }, + /* Mode 1: Text, 40x25, CGA (200 lines) */ + { 0x28, 0x18, 0x08, 0x00, 0x08, 0x09, 0x03, 0x00, + 0x02, 0x63, 0x2d, 0x27, 0x28, 0x90, 0x2b, 0xa0, + 0xbf, 0x1f, 0x00, 0xc7, 0x06, 0x07, 0x00, 0x00, + 0x00, 0x00, 0x9c, 0x8e, 0x8f, 0x14, 0x1f, 0x96, + 0xb9, 0xa3, 0xff, 0x00, 0x01, 0x02, 0x03, 0x04, + 0x05, 0x14, 0x07, 0x38, 0x39, 0x3a, 0x3b, 0x3c, + 0x3d, 0x3e, 0x3f, 0x08, 0x00, 0x0f, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x10, 0x0e, 0x00, 0xff, + }, + /* Mode 2: Text, 80x25, CGA (200 lines) */ + { 0x50, 0x18, 0x08, 0x00, 0x10, 0x01, 0x03, 0x00, + 0x02, 0x63, 0x5f, 0x4f, 0x50, 0x82, 0x55, 0x81, + 0xbf, 0x1f, 0x00, 0xc7, 0x06, 0x07, 0x00, 0x00, + 0x00, 0x00, 0x9c, 0x8e, 0x8f, 0x28, 0x1f, 0x96, + 0xb9, 0xa3, 0xff, 0x00, 0x01, 0x02, 0x03, 0x04, + 0x05, 0x14, 0x07, 0x38, 0x39, 0x3a, 0x3b, 0x3c, + 0x3d, 0x3e, 0x3f, 0x08, 0x00, 0x0f, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x10, 0x0e, 0x00, 0xff, + }, + /* Mode 3: Text, 80x25, CGA (200 lines) */ + { 0x50, 0x18, 0x08, 0x00, 0x10, 0x01, 0x03, 0x00, + 0x02, 0x63, 0x5f, 0x4f, 0x50, 0x82, 0x55, 0x81, + 0xbf, 0x1f, 0x00, 0xc7, 0x06, 0x07, 0x00, 0x00, + 0x00, 0x00, 0x9c, 0x8e, 0x8f, 0x28, 0x1f, 0x96, + 0xb9, 0xa3, 0xff, 0x00, 0x01, 0x02, 0x03, 0x04, + 0x05, 0x14, 0x07, 0x38, 0x39, 0x3a, 0x3b, 0x3c, + 0x3d, 0x3e, 0x3f, 0x08, 0x00, 0x0f, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x10, 0x0e, 0x00, 0xff, + }, + /* Mode 4: Graphics, 320x200, 4 colors */ + { 0x28, 0x18, 0x08, 0x00, 0x40, 0x09, 0x03, 0x00, + 0x02, 0x63, 0x2d, 0x27, 0x28, 0x90, 0x2b, 0x80, + 0xbf, 0x1f, 0x00, 0xc1, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x9c, 0x8e, 0x8f, 0x14, 0x00, 0x96, + 0xb9, 0xa2, 0xff, 0x00, 0x13, 0x15, 0x17, 0x02, + 0x04, 0x06, 0x07, 0x10, 0x11, 0x12, 0x13, 0x14, + 0x15, 0x16, 0x17, 0x01, 0x00, 0x03, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x30, 0x0f, 0x00, 0xff, + }, + /* Mode 5: Graphics, 320x200, 4 colors */ + { 0x28, 0x18, 0x08, 0x00, 0x40, 0x09, 0x03, 0x00, + 0x02, 0x63, 0x2d, 0x27, 0x28, 0x90, 0x2b, 0x80, + 0xbf, 0x1f, 0x00, 0xc1, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x9c, 0x8e, 0x8f, 0x14, 0x00, 0x96, + 0xb9, 0xa2, 0xff, 0x00, 0x13, 0x15, 0x17, 0x02, + 0x04, 0x06, 0x07, 0x10, 0x11, 0x12, 0x13, 0x14, + 0x15, 0x16, 0x17, 0x01, 0x00, 0x03, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x30, 0x0f, 0x00, 0xff, + }, + /* Mode 6: Graphics, 640x200, 2 colors */ + { 0x50, 0x18, 0x08, 0x00, 0x40, 0x01, 0x01, 0x00, + 0x06, 0x63, 0x5f, 0x4f, 0x50, 0x82, 0x54, 0x80, + 0xbf, 0x1f, 0x00, 0xc1, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x9c, 0x8e, 0x8f, 0x28, 0x00, 0x96, + 0xb9, 0xc2, 0xff, 0x00, 0x17, 0x17, 0x17, 0x17, + 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, + 0x17, 0x17, 0x17, 0x01, 0x00, 0x01, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x0d, 0x00, 0xff, + }, + /* Mode 7: Text, 80x25, mono, MDA (350 lines) */ + { 0x50, 0x18, 0x0e, 0x00, 0x10, 0x00, 0x03, 0x00, + 0x03, 0xa6, 0x5f, 0x4f, 0x50, 0x82, 0x55, 0x81, + 0xbf, 0x1f, 0x00, 0x4d, 0x0b, 0x0c, 0x00, 0x00, + 0x00, 0x00, 0x83, 0x85, 0x5d, 0x28, 0x0d, 0x63, + 0xba, 0xa3, 0xff, 0x00, 0x08, 0x08, 0x08, 0x08, + 0x08, 0x08, 0x08, 0x10, 0x18, 0x18, 0x18, 0x18, + 0x18, 0x18, 0x18, 0x0e, 0x00, 0x0f, 0x08, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x10, 0x0a, 0x00, 0xff, + }, + /* Mode 8: reserved */ + { 0x50, 0x18, 0x10, 0x00, 0x10, 0x01, 0x03, 0x00, + 0x02, 0x62, 0x5f, 0x4f, 0x50, 0x82, 0x55, 0x81, + 0xbf, 0x1f, 0x00, 0x4f, 0x0d, 0x0e, 0x00, 0x00, + 0x00, 0x00, 0x9c, 0x8e, 0x8f, 0x28, 0x0f, 0x96, + 0xb9, 0xa3, 0xff, 0x00, 0x08, 0x08, 0x08, 0x08, + 0x08, 0x08, 0x08, 0x10, 0x18, 0x18, 0x18, 0x18, + 0x18, 0x18, 0x18, 0x0a, 0x00, 0x0f, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x10, 0x0a, 0x00, 0xff, + }, + /* Mode 9: reserved */ + { 0x28, 0x18, 0x10, 0x00, 0x08, 0x09, 0x03, 0x00, + 0x02, 0x63, 0x2d, 0x27, 0x28, 0x90, 0x2b, 0xa0, + 0xbf, 0x1f, 0x00, 0x4f, 0x0d, 0x0e, 0x00, 0x00, + 0x00, 0x00, 0x9c, 0x8e, 0x8f, 0x14, 0x1f, 0x96, + 0xb9, 0xa3, 0xff, 0x00, 0x01, 0x02, 0x03, 0x04, + 0x05, 0x14, 0x07, 0x38, 0x39, 0x3a, 0x3b, 0x3c, + 0x3d, 0x3e, 0x3f, 0x08, 0x00, 0x0f, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x10, 0x0e, 0x00, 0xff, + }, + /* Mode a: reserved */ + { 0x50, 0x18, 0x10, 0x00, 0x10, 0x01, 0x03, 0x00, + 0x02, 0x63, 0x60, 0x4f, 0x50, 0x82, 0x56, 0x82, + 0xbf, 0x1f, 0x00, 0x4f, 0x0d, 0x0e, 0x00, 0x00, + 0x00, 0x00, 0x9c, 0x8e, 0x8f, 0x28, 0x1f, 0x96, + 0xb9, 0xa3, 0xff, 0x00, 0x01, 0x02, 0x03, 0x04, + 0x05, 0x14, 0x07, 0x38, 0x39, 0x3a, 0x3b, 0x3c, + 0x3d, 0x3e, 0x3f, 0x08, 0x00, 0x0f, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x10, 0x0e, 0x00, 0xff, + }, + /* Mode b: reserved */ + { 0x50, 0x00, 0x00, 0x00, 0x00, 0x29, 0x0f, 0x00, + 0x06, 0x62, 0x5f, 0x4f, 0x50, 0x82, 0x55, 0x81, + 0xbf, 0x1f, 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x9c, 0x8e, 0x8f, 0x28, 0x1f, 0x96, + 0xb9, 0xe3, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x3f, 0x01, 0x00, 0x0f, 0x00, 0x00, + 0x00, 0x0f, 0x00, 0x00, 0x08, 0x05, 0x0f, 0xff, + }, + /* Mode c: reserved */ + { 0x50, 0x00, 0x00, 0x00, 0x00, 0x29, 0x0f, 0x00, + 0x06, 0x63, 0x5f, 0x4f, 0x50, 0x82, 0x55, 0x81, + 0xbf, 0x1f, 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x9c, 0x8e, 0x8f, 0x28, 0x1f, 0x96, + 0xb9, 0xe3, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x3f, 0x01, 0x00, 0x0f, 0x00, 0x00, + 0x00, 0x0f, 0x00, 0x00, 0x08, 0x05, 0x0f, 0xff, + }, + /* Mode d: Graphics, 320x200, 16 colors */ + { 0x28, 0x18, 0x08, 0x00, 0x20, 0x09, 0x0f, 0x00, + 0x06, 0x63, 0x2d, 0x27, 0x28, 0x90, 0x2b, 0x80, + 0xbf, 0x1f, 0x00, 0xc0, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x9c, 0x8e, 0x8f, 0x14, 0x00, 0x96, + 0xb9, 0xe3, 0xff, 0x00, 0x01, 0x02, 0x03, 0x04, + 0x05, 0x06, 0x07, 0x10, 0x11, 0x12, 0x13, 0x14, + 0x15, 0x16, 0x17, 0x01, 0x00, 0x0f, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x0f, 0xff, + }, + /* Mode e: Graphics, 640x200, 16 colors */ + { 0x50, 0x18, 0x08, 0x00, 0x40, 0x01, 0x0f, 0x00, + 0x06, 0x63, 0x5f, 0x4f, 0x50, 0x82, 0x54, 0x80, + 0xbf, 0x1f, 0x00, 0xc0, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x9c, 0x8e, 0x8f, 0x28, 0x00, 0x96, + 0xb9, 0xe3, 0xff, 0x00, 0x01, 0x02, 0x03, 0x04, + 0x05, 0x06, 0x07, 0x10, 0x11, 0x12, 0x13, 0x14, + 0x15, 0x16, 0x17, 0x01, 0x00, 0x0f, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x0f, 0xff, + }, + /* Mode f: Graphics, 640x350, mono (EGA with 64K) */ + { 0x50, 0x18, 0x0e, 0x00, 0x80, 0x01, 0x0f, 0x00, + 0x06, 0xa2, 0x5f, 0x4f, 0x50, 0x82, 0x54, 0x80, + 0xbf, 0x1f, 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x83, 0x85, 0x5d, 0x28, 0x0f, 0x63, + 0xba, 0xe3, 0xff, 0x00, 0x08, 0x00, 0x00, 0x18, + 0x18, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, + 0x18, 0x00, 0x00, 0x0b, 0x00, 0x05, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x05, 0xff, + }, + /* Mode 10: Graphics, 640x350, 4 colors (EGA with 64K) */ + { 0x50, 0x18, 0x0e, 0x00, 0x80, 0x01, 0x0f, 0x00, + 0x06, 0xa3, 0x5f, 0x4f, 0x50, 0x82, 0x54, 0x80, + 0xbf, 0x1f, 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x83, 0x85, 0x5d, 0x28, 0x0f, 0x63, + 0xba, 0xe3, 0xff, 0x00, 0x01, 0x02, 0x03, 0x04, + 0x05, 0x14, 0x07, 0x38, 0x39, 0x3a, 0x3b, 0x3c, + 0x3d, 0x3e, 0x3f, 0x01, 0x00, 0x0f, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x0f, 0xff, + }, + /* Mode f: Graphics, 640x350, mono (EGA with >64K) */ + { 0x50, 0x18, 0x0e, 0x00, 0x80, 0x01, 0x0f, 0x00, + 0x06, 0xa2, 0x5f, 0x4f, 0x50, 0x82, 0x54, 0x80, + 0xbf, 0x1f, 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x83, 0x85, 0x5d, 0x28, 0x0f, 0x63, + 0xba, 0xe3, 0xff, 0x00, 0x08, 0x00, 0x00, 0x18, + 0x18, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, + 0x18, 0x00, 0x00, 0x0b, 0x00, 0x05, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x05, 0xff, + }, + /* Mode 10: Graphics, 640x350, 16 colors (EGA with >64K) */ + { 0x50, 0x18, 0x0e, 0x00, 0x80, 0x01, 0x0f, 0x00, + 0x06, 0xa3, 0x5f, 0x4f, 0x50, 0x82, 0x54, 0x80, + 0xbf, 0x1f, 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x83, 0x85, 0x5d, 0x28, 0x0f, 0x63, + 0xba, 0xe3, 0xff, 0x00, 0x01, 0x02, 0x03, 0x04, + 0x05, 0x14, 0x07, 0x38, 0x39, 0x3a, 0x3b, 0x3c, + 0x3d, 0x3e, 0x3f, 0x01, 0x00, 0x0f, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x0f, 0xff, + }, + /* Mode 0: Text, 40x25, EGA (350 lines) */ + { 0x28, 0x18, 0x0e, 0x00, 0x08, 0x09, 0x03, 0x00, + 0x02, 0xa3, 0x2d, 0x27, 0x28, 0x90, 0x2b, 0xa0, + 0xbf, 0x1f, 0x00, 0x4d, 0x0b, 0x0c, 0x00, 0x00, + 0x00, 0x00, 0x83, 0x85, 0x5d, 0x14, 0x1f, 0x63, + 0xba, 0xa3, 0xff, 0x00, 0x01, 0x02, 0x03, 0x04, + 0x05, 0x14, 0x07, 0x38, 0x39, 0x3a, 0x3b, 0x3c, + 0x3d, 0x3e, 0x3f, 0x08, 0x00, 0x0f, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x10, 0x0e, 0x00, 0xff, + }, + /* Mode 1: Text, 40x25, EGA (350 lines) */ + { 0x28, 0x18, 0x0e, 0x00, 0x08, 0x09, 0x03, 0x00, + 0x02, 0xa3, 0x2d, 0x27, 0x28, 0x90, 0x2b, 0xa0, + 0xbf, 0x1f, 0x00, 0x4d, 0x0b, 0x0c, 0x00, 0x00, + 0x00, 0x00, 0x83, 0x85, 0x5d, 0x14, 0x1f, 0x63, + 0xba, 0xa3, 0xff, 0x00, 0x01, 0x02, 0x03, 0x04, + 0x05, 0x14, 0x07, 0x38, 0x39, 0x3a, 0x3b, 0x3c, + 0x3d, 0x3e, 0x3f, 0x08, 0x00, 0x0f, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x10, 0x0e, 0x00, 0xff, + }, + /* Mode 2: Text, 80x25, EGA (350 lines) */ + { 0x50, 0x18, 0x0e, 0x00, 0x10, 0x01, 0x03, 0x00, + 0x02, 0xa3, 0x5f, 0x4f, 0x50, 0x82, 0x55, 0x81, + 0xbf, 0x1f, 0x00, 0x4d, 0x0b, 0x0c, 0x00, 0x00, + 0x00, 0x00, 0x83, 0x85, 0x5d, 0x28, 0x1f, 0x63, + 0xba, 0xa3, 0xff, 0x00, 0x01, 0x02, 0x03, 0x04, + 0x05, 0x14, 0x07, 0x38, 0x39, 0x3a, 0x3b, 0x3c, + 0x3d, 0x3e, 0x3f, 0x08, 0x00, 0x0f, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x10, 0x0e, 0x00, 0xff, + }, + /* Mode 3: Text, 80x25, EGA (350 lines) */ + { 0x50, 0x18, 0x0e, 0x00, 0x10, 0x01, 0x03, 0x00, + 0x02, 0xa3, 0x5f, 0x4f, 0x50, 0x82, 0x55, 0x81, + 0xbf, 0x1f, 0x00, 0x4d, 0x0b, 0x0c, 0x00, 0x00, + 0x00, 0x00, 0x83, 0x85, 0x5d, 0x28, 0x1f, 0x63, + 0xba, 0xa3, 0xff, 0x00, 0x01, 0x02, 0x03, 0x04, + 0x05, 0x14, 0x07, 0x38, 0x39, 0x3a, 0x3b, 0x3c, + 0x3d, 0x3e, 0x3f, 0x08, 0x00, 0x0f, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x10, 0x0e, 0x00, 0xff, + }, + /* Modes 0, 1: Text, 40x25, VGA (400 lines) */ + { 0x28, 0x18, 0x10, 0x00, 0x08, 0x08, 0x03, 0x00, + 0x02, 0x67, 0x2d, 0x27, 0x28, 0x90, 0x2b, 0xa0, + 0xbf, 0x1f, 0x00, 0x4f, 0x0d, 0x0e, 0x00, 0x00, + 0x00, 0x00, 0x9c, 0x8e, 0x8f, 0x14, 0x1f, 0x96, + 0xb9, 0xa3, 0xff, 0x00, 0x01, 0x02, 0x03, 0x04, + 0x05, 0x14, 0x07, 0x38, 0x39, 0x3a, 0x3b, 0x3c, + 0x3d, 0x3e, 0x3f, 0x0c, 0x00, 0x0f, 0x08, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x10, 0x0e, 0x00, 0xff, + }, + /* Modes 2, 3: Text, 80x25, VGA (400 lines) */ + { 0x50, 0x18, 0x10, 0x00, 0x10, 0x00, 0x03, 0x00, + 0x02, 0x67, 0x5f, 0x4f, 0x50, 0x82, 0x55, 0x81, + 0xbf, 0x1f, 0x00, 0x4f, 0x0d, 0x0e, 0x00, 0x00, + 0x00, 0x00, 0x9c, 0x8e, 0x8f, 0x28, 0x1f, 0x96, + 0xb9, 0xa3, 0xff, 0x00, 0x01, 0x02, 0x03, 0x04, + 0x05, 0x14, 0x07, 0x38, 0x39, 0x3a, 0x3b, 0x3c, + 0x3d, 0x3e, 0x3f, 0x0c, 0x00, 0x0f, 0x08, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x10, 0x0e, 0x00, 0xff, + }, + /* Mode 7: Text, 80x25, mono, VGA (400 lines) */ + { 0x50, 0x18, 0x10, 0x00, 0x10, 0x00, 0x03, 0x00, + 0x02, 0x66, 0x5f, 0x4f, 0x50, 0x82, 0x55, 0x81, + 0xbf, 0x1f, 0x00, 0x4f, 0x0d, 0x0e, 0x00, 0x00, + 0x00, 0x00, 0x9c, 0x8e, 0x8f, 0x28, 0x0f, 0x96, + 0xb9, 0xa3, 0xff, 0x00, 0x08, 0x08, 0x08, 0x08, + 0x08, 0x08, 0x08, 0x10, 0x18, 0x18, 0x18, 0x18, + 0x18, 0x18, 0x18, 0x0e, 0x00, 0x0f, 0x08, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x10, 0x0a, 0x00, 0xff, + }, + /* Mode 11: Graphics, 640x480, 2 colors */ + { 0x50, 0x1d, 0x10, 0x00, 0xa0, 0x01, 0x0f, 0x00, + 0x06, 0xe3, 0x5f, 0x4f, 0x50, 0x82, 0x54, 0x80, + 0x0b, 0x3e, 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0xea, 0x8c, 0xdf, 0x28, 0x00, 0xe7, + 0x04, 0xc3, 0xff, 0x00, 0x3f, 0x3f, 0x3f, 0x3f, + 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, + 0x3f, 0x3f, 0x3f, 0x01, 0x00, 0x0f, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x01, 0xff, + }, + /* Mode 12: Graphics, 640x480, 16 colors */ + { 0x50, 0x1d, 0x10, 0x00, 0xa0, 0x01, 0x0f, 0x00, + 0x06, 0xe3, 0x5f, 0x4f, 0x50, 0x82, 0x54, 0x80, + 0x0b, 0x3e, 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0xea, 0x8c, 0xdf, 0x28, 0x00, 0xe7, + 0x04, 0xe3, 0xff, 0x00, 0x01, 0x02, 0x03, 0x04, + 0x05, 0x14, 0x07, 0x38, 0x39, 0x3a, 0x3b, 0x3c, + 0x3d, 0x3e, 0x3f, 0x01, 0x00, 0x0f, 0x00, 0x00, + 0x80, 0x00, 0x00, 0x00, 0x00, 0x05, 0x0f, 0xff, + }, + /* Mode 13: Graphics, 320x200, 256 colors */ + { 0x28, 0x18, 0x08, 0x00, 0x20, 0x01, 0x0f, 0x00, + 0x0e, 0x63, 0x5f, 0x4f, 0x50, 0x82, 0x54, 0x80, + 0xbf, 0x1f, 0x00, 0x41, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x9c, 0x8e, 0x8f, 0x28, 0x40, 0x96, + 0xb9, 0xa3, 0xff, 0x00, 0x01, 0x02, 0x03, 0x04, + 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, + 0x0d, 0x0e, 0x0f, 0x41, 0x00, 0x0f, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x40, 0x05, 0x0f, 0xff, + }, + { 0x50, 0x1d, 0x10, 0x00, 0x20, 0x01, 0x03, 0x00, + 0x02, 0xe3, 0x5f, 0x4f, 0x50, 0x82, 0x57, 0x82, + 0x08, 0x3e, 0x00, 0x4f, 0x0d, 0x0e, 0x00, 0x00, + 0x00, 0x00, 0xea, 0x8f, 0xdf, 0x28, 0x00, 0xe7, + 0x04, 0xa3, 0xff, 0x00, 0x01, 0x02, 0x03, 0x04, + 0x05, 0x14, 0x07, 0x38, 0x39, 0x3a, 0x3b, 0x3c, + 0x3d, 0x3e, 0x3f, 0x08, 0x00, 0x0f, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x10, 0x0e, 0x00, 0xff, + }, + { 0x84, 0x18, 0x10, 0x00, 0x20, 0x01, 0x03, 0x00, + 0x42, 0x62, 0x9b, 0x83, 0x86, 0x9e, 0x8a, 0x1b, + 0xbf, 0x1f, 0x00, 0x4f, 0x0d, 0x0e, 0x00, 0x00, + 0x00, 0x00, 0x9c, 0x8e, 0x8f, 0x42, 0x0f, 0x96, + 0xb9, 0xa3, 0xff, 0x00, 0x08, 0x08, 0x08, 0x08, + 0x08, 0x08, 0x08, 0x10, 0x18, 0x18, 0x18, 0x18, + 0x18, 0x18, 0x18, 0x0a, 0x00, 0x0f, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x10, 0x0a, 0x00, 0xff, + }, + { 0x84, 0x18, 0x10, 0x00, 0x20, 0x01, 0x03, 0x00, + 0x42, 0x63, 0x9b, 0x83, 0x86, 0x9e, 0x8a, 0x1b, + 0xbf, 0x1f, 0x00, 0x4f, 0x0d, 0x0e, 0x00, 0x00, + 0x00, 0x00, 0x9c, 0x8e, 0x8f, 0x42, 0x0f, 0x96, + 0xb9, 0xa3, 0xff, 0x00, 0x01, 0x02, 0x03, 0x04, + 0x05, 0x14, 0x07, 0x38, 0x39, 0x3a, 0x3b, 0x3c, + 0x3d, 0x3e, 0x3f, 0x08, 0x00, 0x0f, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x10, 0x0e, 0x00, 0xff, + }, +}; + +/* The default DAC table for the EGA and VGA 16 color modes. This table is + installed on startup. The values are taken from the output of 'scon -p + list'. */ +struct dac_colors dac_default64[] = { + {0, 0, 0}, {0, 0, 42}, {0, 42, 0}, {0, 42, 42}, + {42, 0, 0}, {42, 0, 42}, {42, 42, 0}, {42, 42, 42}, + {0, 0, 21}, {0, 0, 63}, {0, 42, 21}, {0, 42, 63}, + {42, 0, 21}, {42, 0, 63}, {42, 42, 21}, {42, 42, 63}, + {0, 21, 0}, {0, 21, 42}, {0, 63, 0}, {0, 63, 42}, + {42, 21, 0}, {42, 21, 42}, {42, 63, 0}, {42, 63, 42}, + {0, 21, 21}, {0, 21, 63}, {0, 63, 21}, {0, 63, 63}, + {42, 21, 21}, {42, 21, 63}, {42, 63, 21}, {42, 63, 63}, + {21, 0, 0}, {21, 0, 42}, {21, 42, 0}, {21, 42, 42}, + {63, 0, 0}, {63, 0, 42}, {63, 42, 0}, {63, 42, 42}, + {21, 0, 21}, {21, 0, 63}, {21, 42, 21}, {21, 42, 63}, + {63, 0, 21}, {63, 0, 63}, {63, 42, 21}, {63, 42, 63}, + {21, 21, 0}, {21, 21, 42}, {21, 63, 0}, {21, 63, 42}, + {63, 21, 0}, {63, 21, 42}, {63, 63, 0}, {63, 63, 42}, + {21, 21, 21}, {21, 21, 63}, {21, 63, 21}, {21, 63, 63}, + {63, 21, 21}, {63, 21, 63}, {63, 63, 21}, {63, 63, 63} +}; + +/* The default DAC table for the 256 color mode. The values are taken from the + output of 'vdacc.exe', from Michael Tischler's book ``PC intern 4''. */ +struct dac_colors dac_default256[] = { + /* 16 CGA colors */ + {0, 0, 0}, {0, 0, 42}, {0, 42, 0}, {0, 42, 42}, + {42, 0, 0}, {42, 0, 42}, {42, 21, 0}, {42, 42, 42}, + {21, 21, 21}, {21, 21, 63}, {21, 63, 21}, {21, 63, 63}, + {63, 21, 21}, {63, 21, 63}, {63, 63, 21}, {63, 63, 63}, + /* grayscale */ + {0, 0, 0}, {5, 5, 5}, {8, 8, 8}, {11, 11, 11}, + {14, 14, 14}, {17, 17, 17}, {20, 20, 20}, {24, 24, 24}, + {28, 28, 28}, {32, 32, 32}, {36, 36, 36}, {40, 40, 40}, + {45, 45, 45}, {50, 50, 50}, {56, 56, 56}, {63, 63, 63}, + /* high intensity, high saturation */ + {0, 0, 63}, {16, 0, 63}, {31, 0, 63}, {47, 0, 63}, + {63, 0, 63}, {63, 0, 47}, {63, 0, 31}, {63, 0, 16}, + {63, 63, 0}, {63, 16, 0}, {63, 31, 0}, {63, 47, 0}, + {63, 63, 0}, {47, 63, 0}, {31, 63, 0}, {16, 63, 0}, + {0, 63, 0}, {0, 63, 16}, {0, 63, 31}, {0, 63, 47}, + {0, 63, 63}, {0, 47, 63}, {0, 31, 63}, {0, 16, 63}, + /* high intensity, medium saturation */ + {31, 31, 63}, {39, 31, 63}, {47, 31, 63}, {55, 31, 63}, + {63, 31, 63}, {63, 31, 55}, {63, 31, 47}, {63, 31, 39}, + {63, 31, 31}, {63, 39, 31}, {63, 47, 31}, {63, 55, 31}, + {63, 63, 31}, {55, 63, 31}, {47, 63, 31}, {39, 63, 31}, + {31, 63, 31}, {31, 63, 39}, {31, 63, 47}, {31, 63, 55}, + {31, 63, 63}, {31, 55, 63}, {31, 47, 63}, {31, 39, 63}, + /* high intensity, low saturation */ + {45, 45, 63}, {49, 45, 63}, {54, 45, 63}, {58, 45, 63}, + {63, 45, 63}, {63, 45, 58}, {63, 45, 54}, {63, 45, 49}, + {63, 45, 45}, {63, 49, 45}, {63, 54, 45}, {63, 58, 45}, + {63, 63, 45}, {58, 63, 45}, {54, 63, 45}, {49, 63, 45}, + {45, 63, 45}, {45, 63, 49}, {45, 63, 54}, {45, 63, 58}, + {45, 63, 63}, {45, 58, 63}, {45, 54, 63}, {45, 49, 63}, + /* medium intensity, high saturation */ + {0, 0, 28}, {7, 0, 28}, {14, 0, 28}, {21, 0, 28}, + {28, 0, 28}, {28, 0, 21}, {28, 0, 14}, {28, 0, 7}, + {28, 0, 0}, {28, 7, 0}, {28, 14, 0}, {28, 21, 0}, + {28, 28, 0}, {21, 28, 0}, {14, 28, 0}, {7, 28, 0}, + {0, 28, 0}, {0, 28, 7}, {0, 28, 14}, {0, 28, 21}, + {0, 28, 28}, {0, 21, 28}, {0, 14, 28}, {0, 7, 28}, + /* medium intensity, medium saturation */ + {14, 14, 28}, {17, 14, 28}, {21, 14, 28}, {24, 14, 28}, + {28, 14, 28}, {28, 14, 24}, {28, 14, 21}, {28, 14, 17}, + {28, 14, 14}, {28, 17, 14}, {28, 21, 14}, {28, 24, 14}, + {28, 28, 14}, {24, 28, 14}, {21, 28, 14}, {17, 28, 14}, + {14, 28, 14}, {14, 28, 17}, {14, 28, 21}, {14, 28, 24}, + {14, 28, 28}, {14, 24, 28}, {14, 21, 28}, {14, 17, 28}, + /* medium intensity, low saturation */ + {20, 20, 28}, {22, 20, 28}, {24, 20, 28}, {26, 20, 28}, + {28, 20, 28}, {28, 20, 26}, {28, 20, 24}, {28, 20, 22}, + {28, 20, 20}, {28, 22, 20}, {28, 24, 20}, {28, 26, 20}, + {28, 28, 20}, {26, 28, 20}, {24, 28, 20}, {22, 28, 20}, + {20, 28, 20}, {20, 28, 22}, {20, 28, 24}, {20, 28, 26}, + {20, 28, 28}, {20, 26, 28}, {20, 24, 28}, {20, 22, 28}, + /* low intensity, high saturation */ + {0, 0, 16}, {4, 0, 16}, {8, 0, 16}, {12, 0, 16}, + {16, 0, 16}, {16, 0, 12}, {16, 0, 8}, {16, 0, 4}, + {16, 0, 0}, {16, 4, 0}, {16, 8, 0}, {16, 12, 0}, + {16, 16, 0}, {12, 16, 0}, {8, 16, 0}, {4, 16, 0}, + {0, 16, 0}, {0, 16, 4}, {0, 16, 8}, {0, 16, 12}, + {0, 16, 16}, {0, 12, 16}, {0, 8, 16}, {0, 4, 16}, + /* low intensity, medium saturation */ + {8, 8, 16}, {10, 8, 16}, {12, 8, 16}, {14, 8, 16}, + {16, 8, 16}, {16, 8, 14}, {16, 8, 12}, {16, 8, 10}, + {16, 8, 8}, {16, 10, 8}, {16, 12, 8}, {16, 14, 8}, + {16, 16, 8}, {14, 16, 8}, {12, 16, 8}, {10, 16, 8}, + {8, 16, 8}, {8, 16, 10}, {8, 16, 12}, {8, 16, 14}, + {8, 16, 16}, {8, 14, 16}, {8, 12, 16}, {8, 10, 16}, + /* low intensity, low saturation */ + {11, 11, 16}, {12, 11, 16}, {13, 11, 16}, {15, 11, 16}, + {16, 11, 16}, {16, 11, 15}, {16, 11, 13}, {16, 11, 12}, + {16, 11, 11}, {16, 12, 11}, {16, 13, 11}, {16, 15, 11}, + {16, 16, 11}, {15, 16, 11}, {13, 16, 11}, {12, 16, 11}, + {11, 16, 11}, {11, 16, 12}, {11, 16, 13}, {11, 16, 15}, + {11, 16, 16}, {11, 15, 16}, {11, 13, 16}, {11, 12, 16}, + /* black */ + {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, + {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0} +}; + +/* The Static Functionality Table, a collection of mode-independent status + info. */ +u_int8_t static_functionality_table[] = { + 0x0c, /* Video modes 0 - 7 */ + 0, /* Video modes 8 - 15 */ + 0, /* Video modes 16 - 23 */ + 0, 0, 0, 0, /* reserved */ + 4, /* 400 lines */ + 1, /* Charset memory blocks available */ + 1, /* Charset memory blocks in use */ + 0x79, /* Bit 0: all modes on all displays + 1: grayscale equivalents + 2: user-definable charsets + 3: user-definable palette + 4: CGA cursor emulation + 5: EGA palette + 6: VGA color registers + 7: color pages */ + 0x8, /* Bit 0: lightpen interface + 1: save/load video status + 2: toggle intensity/blink + 3: DCC + 4-7: reserved */ + 0, /* reserved */ + 0, /* Save Pointer functions available + Bit 0: 2 charsets + 1: Palette Save Area + 2: user-defined charset (text) + 3: user-defined charset (graphics) + 4: user-defined palette + 5: DCC + 6, 7: reserved */ + 0 /* reserved */ }; |