misha@nsc.nsc.com (Michael Umansky) (07/17/87)
I was a little busy to post this, but here it is now. This is an update to recently posted FDISK program to manage partition table on a hard disk for MINIX. This is a new Makefile which should work on MINIX and has predefined MINIX as the target system. The new screen.c also has code to support limited screen control as provided by ORIGINAL tty driver of MINIX V1.1. I will soon add code to this program to make it run on PC DOS 3.x and up. I would like to know if anyone ran this on MINIX and how successful were you? enjoy ---------------------------- CUT HERE ------------------------------------------ #!/bin/sh # shar: Shell Archiver # Run the following text with /bin/sh to create: # Makefile # screen.c # This archive created: Thu Jul 16 14:15:59 1987 echo shar: extracting Makefile '(1206 characters)' sed 's/^XX//' << \SHAR_EOF > Makefile XX# XX# @(#) Makefile: version 1.6 created on 7/13/87 at 16:18:47 XX# XX XXCC = cc XXCFLAGS = -O -DMINIX XX# Bug in MINIX make prevents variable declarations within other XX# variable declarations. XX# Uncomment one SCREEN line below that applies to your system. XX# XX#SCREEN = VT100 # for terminals with VT100 capabilities XX#SCREEN = VENIX # for VENIX console XX#SCREEN = MINIX # for MINIX console XX#OPTIONS = -D${SCREEN} # -DSCCS XX#CFLAGS = -O ${OPTIONS} XX# XX#CPP = cpp XX#CPPFLAGS= -M ${OPTIONS} # this will work only for BSD 4.3 UNIX style 'cpp' XX XXSOURCES = fdisk.c input.c screen.c XX XXOBJECTS = fdisk.o input.o screen.o XX XXPROG1 = fdisk XXPROG2 = ddisk XX XXall: ${PROG1} ${PROG2} XX XX${PROG1}: ${OBJECTS} XX ${CC} -o ${PROG1} ${OBJECTS} XX XX${PROG2}: ${PROG1} XX ln ${PROG1} ${PROG2} XX XXfdisk.o: block0.h XX XXclean: XX rm -f ${OBJECTS} *.o a.out core XX XXclobber: clean XX rm -f ${PROG1} ${PROG2} XX XXdepend: XX cp Makefile Makefile.bak XX echo '# DO NOT DELETE THIS LINE - make depend uses it' >makedep XX for i in ${SOURCES} ; \ XX do \ XX ${CPP} ${CPPFLAGS} $$i >> makedep ; \ XX done XX echo '/^# DO NOT DELETE THIS LINE/,$$d' >eddep XX echo '$$r makedep' >>eddep XX echo 'w' >>eddep XX ed - Makefile < eddep XX rm eddep makedep XX XX# DO NOT DELETE THIS LINE - make depend uses it SHAR_EOF if test 1206 -ne "`wc -c Makefile`" then echo shar: error transmitting Makefile '(should have been 1206 characters)' fi echo shar: extracting screen.c '(6509 characters)' sed 's/^XX//' << \SHAR_EOF > screen.c XX/* XX** @(#) screen.c: version 1.6 created on 7/16/87 at 14:15:37 XX*/ XXstatic char _sccs_C_id_[] = XX "@(#) screen.c: version 1.6 created on 7/16/87 at 14:15:37"; XX XX#include <stdio.h> XX XX#ifdef VENIX XX#define INTRODUCER '\033' /* good old ESCAPE - ^[ */ XXchar clear[] = "\033H\033J"; /* clear and home cursor */ XXchar rvon[] = "\033\010"; /* reverse video on */ XXchar rvoff[] = "\033\007"; /* reverse video off */ XXchar hlon[] = "\033\006"; /* highlight on */ XXchar hloff[] = "\033\005"; /* highlight off */ XXchar ulon[] = "\033\004"; /* underline on */ XXchar uloff[] = "\033\003"; /* underline off */ XXchar blon[] = "\033\002"; /* blink on */ XXchar bloff[] = "\033\001"; /* blink off */ XXchar alloff[] = "\033\016"; /* all attributes off */ XX#endif /* VENIX */ XX XX#ifdef MINIX XX/* XX** The following attributes define IBM PC's screen looks. XX** XX** FG | BACKGROUND | FOREGROUND | CGA/MDA SCREEN XX** ----+---------------+---------------------+---------------------------- XX** 7 | 6 5 4 | 3 | 2 1 0 | CHAR | BKGD | SCREEN XX** BLN | RED GRN BLU | INT | RED GRN BLU | COLOR | COLOR | LOOKS XX** ----+---------------+-----+---------------+---------+---------+-------- XX** B | 0 0 0 | I | 1 1 1 | white | black | NORMAL XX** B | 1 1 1 | I | 0 0 0 | black | white | REVVID XX** B | 0 0 0 | I | 0 0 0 | black | black | NODISP XX** B | 1 1 1 | I | 1 1 1 | white | white | NODISP XX** XX** If BLN bit is SET then BLINKING is ON. XX** If INT bit is SET then HIGHLITE is ON. XX** XX** Bit combinations in the table above work the same for CGA and MDA. XX** All other combinations of R, G, and B bit values will show white XX** character on black background on MDA only. XX** XX** For CGA the following R, G, and B bit values apply: XX** XX** R G B | COLOR XX** ---------+------- XX** 0 0 0 | black XX** 0 0 1 | blue - use on MDA for FOREGROUND to get underline XX** 0 1 0 | green XX** 0 1 1 | cyan XX** 1 0 0 | red XX** 1 0 1 | magenta XX** 1 1 0 | yellow XX** 1 1 1 | white XX** XX** With INT bit SET, the above colors all become light versions of self; XX** black becomes dark grey; and, white becomes bright white (HIGHLITE). XX** Since there is no hardware underline in CGA, the character is XX** highlighted instead. XX** XX** Until MINIX's tty driver is rewritten to provide full ANSI XX** escape sequence support, the following will suffice. XX*/ XX#define INTRODUCER '\033' /* good old ESCAPE - ^[ */ XXchar clear[] = "\033 \033~0"; /* clear and home cursor */ XXchar rvon[] = "\033z\160"; /* reverse video on */ XXchar rvoff[] = "\033z\007"; /* reverse video off */ XXchar hlon[] = "\033z\017"; /* highlight on */ XXchar hloff[] = "\033z\007"; /* highlight off */ XXchar ulon[] = "\033z\160"; /* underline on */ XXchar uloff[] = "\033z\007"; /* underline off */ XXchar blon[] = "\033z\207"; /* blink on */ XXchar bloff[] = "\033z\007"; /* blink off */ XXchar alloff[] = "\033z\007"; /* all attributes off */ XX#endif /* MINIX */ XX XX#ifdef VT100 XX#define INTRODUCER '\033' /* good old ESCAPE - ^[ */ XXchar clear[] = "\033[H\033[J"; /* clear and home cursor */ XXchar rvon[] = "\033[7m"; /* reverse video on */ XXchar rvoff[] = "\033[0m"; /* reverse video off */ XXchar hlon[] = "\033[1m"; /* highlight on */ XXchar hloff[] = "\033[0m"; /* highlight off */ XXchar ulon[] = "\033[4m"; /* underline on */ XXchar uloff[] = "\033[0m"; /* underline off */ XXchar blon[] = "\033[5m"; /* blink on */ XXchar bloff[] = "\033[0m"; /* blink off */ XXchar alloff[] = "\033[0m"; /* all attributes off */ XX#endif /* VT100 */ XX XX/* XX** Position cursor. XX*/ XXcurpos(col,row) XXregister int col, row; XX{ XXchar cmd[16]; XX XX#ifdef VENIX XX sprintf(cmd,"%cY%c%c",INTRODUCER,(040 + (row - 1)),(040 + (col - 1))); XX#endif /* VENIX */ XX#ifdef MINIX XX sprintf(cmd,"%c%c%c",INTRODUCER,(040 + col),(040 + row)); XX#endif /* MINIX */ XX#ifdef VT100 XX sprintf(cmd,"%c[%d;%dH",INTRODUCER,row,col); XX#endif /* VT100 */ XX write(1,cmd,strlen(cmd)); XX} XX XX/* XX** Cursor Home. XX*/ XXchome() XX{ XX putchar(INTRODUCER); XX#ifdef MINIX XX putchar(' '); XX putchar(' '); XX#endif /* MINIX */ XX#ifdef VT100 XX putchar('['); XX#endif /* VT100 */ XX#if (VT100 || VENIX) XX putchar('H'); XX#endif /* VT100 || VENIX */ XX} XX XX/* XX** Cursor Up. XX*/ XXcup() XX{ XX#ifndef MINIX XX putchar(INTRODUCER); XX#ifdef VT100 XX putchar('['); XX#endif /* VT100 */ XX putchar('A'); XX#endif /* MINIX */ XX} XX XX/* XX** Cursor Down. XX*/ XXcdown() XX{ XX#ifdef MINIX XX putchar('\013'); /* ^K */ XX#else /* MINIX */ XX putchar(INTRODUCER); XX#ifdef VT100 XX putchar('['); XX#endif /* VT100 */ XX putchar('B'); XX#endif /* MINIX */ XX} XX XX/* XX** Cursor Right. XX*/ XXcright() XX{ XX#ifdef MINIX XX putchar('\014'); /* ^L */ XX#else /* MINIX */ XX putchar(INTRODUCER); XX#ifdef VT100 XX putchar('['); XX#endif /* VT100 */ XX putchar('C'); XX#endif /* MINIX */ XX} XX XX/* XX** Cursor Left. XX*/ XXcleft() XX{ XX#ifdef MINIX XX putchar('\b'); /* ^H */ XX#else /* MINIX */ XX putchar(INTRODUCER); XX#ifdef VT100 XX putchar('['); XX#endif /* VT100 */ XX putchar('D'); XX#endif /* MINIX */ XX} XX XX/* XX** Reverse Scroll. XX*/ XXrscroll() XX{ XX#ifdef MINIX XX putchar(INTRODUCER); XX putchar('~'); XX putchar('1'); XX#endif /* MINIX */ XX#ifdef VENIX XX putchar(INTRODUCER); XX putchar('I'); XX#endif /* VENIX */ XX} XX XX/* XX** Clear to End Of Line. XX*/ XXclreol() XX{ XX putchar(INTRODUCER); XX#ifdef MINIX XX putchar('~'); XX putchar('0'); XX#endif /* MINIX */ XX#ifdef VT100 XX putchar('['); XX#endif /* VT100 */ XX#if (VT100 || VENIX) XX putchar('K'); XX#endif /* VT100 || VENIX */ XX} XX XX/* XX** Clear to End Of Page/Screen. XX*/ XXclreop() XX{ XX putchar(INTRODUCER); XX#ifdef MINIX XX putchar('~'); XX putchar('0'); XX#endif /* MINIX */ XX#ifdef VT100 XX putchar('['); XX#endif /* VT100 */ XX#if (VT100 || VENIX) XX putchar('J'); XX#endif /* VT100 || VENIX */ XX} XX XX/* XX** Insert Line at Cursor. XX*/ XXinsline() XX{ XX#ifndef MINIX XX putchar(INTRODUCER); XX#ifdef VT100 XX putchar('['); XX#endif /* VT100 */ XX putchar('L'); XX#endif /* MINIX */ XX} XX XX/* XX** Delete Line at Cursor. XX*/ XXdelline() XX{ XX#ifndef MINIX XX putchar(INTRODUCER); XX#ifdef VT100 XX putchar('['); XX#endif /* VT100 */ XX putchar('M'); XX#endif /* MINIX */ XX} XX XX/* XX** Normal Attribute. XX*/ XXanorm() XX{ XX puts(alloff); XX} XX XX/* XX** Blink Attribute. XX*/ XXablink(on) XXregister int on; XX{ XX if (on) XX puts(blon); XX else XX puts(bloff); XX} XX XX/* XX** High Intensity Attribute. XX*/ XXahigh(on) XXregister int on; XX{ XX if (on) XX puts(hlon); XX else XX puts(hloff); XX} XX XX/* XX** Reverse Video Attribute. XX*/ XXarev(on) XXregister int on; XX{ XX if (on) XX puts(rvon); XX else XX puts(rvoff); XX} XX XX/* XX** Underline attribute. XX*/ XXauline(on) XXregister int on; XX{ XX if (on) XX puts(ulon); XX else XX puts(uloff); XX} SHAR_EOF if test 6509 -ne "`wc -c screen.c`" then echo shar: error transmitting screen.c '(should have been 6509 characters)' fi # End of shell archive exit 0 -- NAME: Michael Umansky (misha) E-MAIL: sun! ----\ hplabs! --\ pyramid! --+----> nsc!misha decwrl! --/ amdahl! -/ WORK: National Semiconductor Corporation 1135 Kern Avenue, Mail Stop - 7C266 Sunnyvale, CA 94086 (408) 721-8109 (work) HOME: 4331 Lincoln Way San Francisco, CA 94122 (415) 564-3921 (home)