home *** CD-ROM | disk | FTP | other *** search
- /*
- ┌────────────────────────────────────────────────────────────────────────────┐
- │jzedtchr.dmo │
- │Allow editing of a character set which can be loaded to replace the original│
- │ │
- │Usage: jzedtchr <filename> │
- │ │
- │This program allows you to edit/Create a custom character set. It is a demo │
- │of some of the library routines that I have written including and interrupt │
- │driven clock routine. │
- │ │
- │ (C) JazSoft Software by Jack A. Zucker (301) 794-5950 │
- └────────────────────────────────────────────────────────────────────────────┘
- */
-
-
- #include <jaz.h> /* define misc structs and macros */
- #include <keys.h> /* define scan codes */
- #include <jzscreen.h> /* define colors */
- #include <gscreen.h> /* define global header record */
- #include <fcntl.h> /* file stuff */
-
-
- TVECTOR gvec; /* vector to hold old clock int */
- int clock(); /* clock interrupt routine */
- gcount = 17; /* count of clock tics */
- int MONO = 1;
- char G_FILENAME[50]; /* hold global file name */
-
- static char *help[] = {
- "Clear Bit F1 | Space",
- "Set Bit F2",
- "First Char HOME",
- "Last Char END",
- "Next Char PGDN",
- "Prev Char PGUP",
- "Quick Next CTRL-PGDN",
- "Quick Prev CTRL-PGUP",
- "View Char Set ALT-V",
- "Quit w/o Saving ESC",
- "Save and Quit ALT-S",
- ""
- };
-
- #define CHARLEN 8 /* 8 bytes for each character */
- #define NUMCHARS 128 /* number of chars in table */
- #define TABLELEN NUMCHARS * CHARLEN /* number of bytes in the character table */
- #define MONOATTR 7 /* light gray on black background */
- #define COLORATTR 31 /* white letters on YELLOW back */
- #define G_ROW 8 /* starting row */
- #define G_COL 35 /* starting column */
- #define S_IWRITE 0000200 /* write permission, owner */
- #define TIMER 0x1c /* timer interrupt */
- #define COPYWRITE "JZEDTCHR (C) JazSoft 1986 by Jack A. Zucker @ 301-794-5950 |\
- CIS: 75766,1336"
-
- #define GMENU GREEN
- #define GWND CYAN
- #define GLOGO YELLOW
- #define GCHAR MAGENTA
- #define GHEADING RED
-
- #if DEBUG
- char wtable[TABLELEN];
- #endif
-
- main(argc,argv)
- int argc;
- char **argv;
- {
-
- #if ! DEBUG
- char wtable[TABLELEN]; /* hold the table entries */
- #endif
- int whandle; /* file handle */
- int w,wch,wscan;
-
- jzlogo(); /* display logo on screen */
-
- strcpy(G_FILENAME,*(++argv)); /* copy possible file name */
-
- if (! G_FILENAME[0] ) { /* no file name specified */
- jzscrprn("Filename: ",24,0,GREEN);
- wch = jzinstr(G_FILENAME,35,24,10,CYAN,60L,"\001");
- if (wch == 27 || (! G_FILENAME[0])) exit(0);
- }
-
- if ((whandle = open(G_FILENAME,0)) == -1)
- /* copy rom character set to work storage */
- movedata(0xF000,0xFA6E,getds(),wtable,TABLELEN);
- else {
- read(whandle,wtable,TABLELEN); /* read saved char set into buffer */
- close(whandle);
- }
-
- MONO = MEMB(0x40,0x49) == 7; /* get screen type */
-
- cls(7); /* clear the display screen */
-
- jzscrprn(COPYWRITE,0,2,GLOGO);
-
- jzdrwbox(G_ROW , G_COL , 10 , 10 ,GWND); /* draw box for characters */
-
- jzscrprn(" Edit Keys",2,0,GHEADING);
-
- for (w = 0 ; *help[w] ; w ++)
- jzscrprn(help[w],w+5,0,GMENU);
-
- jzgetint(TIMER,&gvec);
- jzinsint(TIMER,clock);
-
- jzscrprn("Editing:",23,0,LIGHTGRAY);
- jzscrprn(G_FILENAME,23,9,BROWN);
-
- if (editchar(wtable)) { /* edit character table */
- if ((whandle = creat(G_FILENAME,S_IWRITE)) == -1) {
- printf("Trouble opening %s",G_FILENAME);
- exit(0);
- }
- write(whandle,wtable,TABLELEN);
- close(whandle);
- }
-
- jzsetint(TIMER,gvec);
-
- if (MONO) {
- cls(7);
- printf("\nCan't view character set without color graphics adapter!");
- exit();
- }
-
- viewchar(wtable); /* view character set */
-
- jzloccur(23,0); /* end program neatly */
-
- }
-
- viewchar(ftable)
- char *ftable;
- {
- int w1,w2,wscan;
- long far *biostable = (long far *) 0x7C; /* pointer to extended char table */
- long tablesave; /* save original address */
- TWINDOW *wptr,*jzappend();
-
- tablesave = *biostable; /* save original character table */
-
- /* Now change the extended character table pointer to point to our new */
- /* character set */
-
- *biostable = (long) ((long) getds() << 16 | (int) ftable);
-
- wptr = jzappend(&g_header,31,0,0,25,80); /* save current screen */
-
- jzsetmde(6); /* go into graphics mode */
-
- w1 = 0;
- while (w1 <= 112) {
- for (w2 = 0 ; w2 < 16 ; w2 ++)
- printf("%-4c",(w1+w2) + 128);
- printf("\n");
- w1 += 16;
- }
- printext("\n\n(C) JazSoft 1986 by Jack A. Zucker @ 301-794-5950");
- printext("\n10318 Broom Lane");
- printext("\nSeabrook Md, 20706");
- printext("\nFor info regarding source code, please feel free to call");
- printext("\nor send $25.00 for over 100 source and obj files for MS/C !");
- printext("\n-Jaz");
- printext("\n\nPress <Enter> (\177) to Continue...");
-
- do ; while (jzinkey(&wscan) != 13);
-
- *biostable = tablesave; /* restore original pointer */
-
- jzsetmde(3); /* back to color graphics mode */
-
- jzrstwnd(wptr); /* restore original screen */
-
- free ((int *) wptr->buf); /* free up buffer memory */
-
- exit(0);
-
- }
-
- int editchar(ftable)
- char *ftable;
- {
- int wscan,wch;
- int wcol,wrow;
- int windex = 0;
-
- wcol = G_COL + 1;
- wrow = G_ROW + 1;
-
- displaychar(ftable+windex);
- do {
- jzloccur(G_ROW - 1,G_COL + 1);
- printf("Char %003d",windex / CHARLEN);
- jzloccur(wrow,wcol); /* position the cursor */
- if ((wch = jzinkey(&wscan)))
- switch (wch) { /* look for esc key - end */
- case ESC : return(0);
- case 32 : jzwrtchr(' ',GCHAR,1);
- wcol = min(wcol + 1,43);
- break;
- }
- else
- switch (wscan) {
- case ALT_S:
- savechar(ftable + windex);
- return(-1);
- case ALT_V:
- if (! MONO) {
- savechar(ftable + windex);
- jzsetint(TIMER,gvec); /* temporarily turn off clock */
- viewchar(ftable);
- gcount = 17;
- jzinsint(TIMER,clock); /* turn clock back on */
- }
- break;
- case F1 : jzwrtchr(' ',GCHAR,1);
- wcol = min(wcol + 1,43);
- break;
- case F2 : jzwrtchr('▒',GCHAR,1);
- wcol = min(wcol + 1,43);
- break;
- case UARR: wrow = max(9,wrow-1);
- break;
- case DARR: wrow = min(16,wrow+1);
- break;
- case LARR: wcol = max(36,wcol-1);
- break;
- case RARR: wcol = min(43,wcol+1);
- break;
- case CTRL_PGUP:
- savechar(ftable + windex);
- windex = max(0,windex - CHARLEN * CHARLEN);
- displaychar(ftable+windex);
- break;
- case CTRL_PGDN:
- savechar(ftable + windex);
- windex = min(windex + CHARLEN * CHARLEN,TABLELEN - CHARLEN);
- displaychar(ftable+windex);
- break;
- case HOME: savechar(ftable + windex);
- windex = 0;
- displaychar(0);
- break;
- case END: savechar(ftable + windex);
- windex = TABLELEN - CHARLEN;
- displaychar(ftable +TABLELEN - CHARLEN);
- break;
- case PGUP: savechar(ftable + windex);
- windex = max(0,windex - CHARLEN);
- displaychar(ftable+windex);
- break;
- case PGDN: savechar(ftable + windex);
- windex = min(windex + CHARLEN,TABLELEN - CHARLEN);
- displaychar(ftable+windex);
- break;
- }
- } while (-1);
- }
-
- displaychar(fchar)
- char *fchar;
- {
- int wcol,wrow;
- char wchar;
-
- for (wrow = 0 ; wrow < 8 ; wrow ++) { /* loop through chars in table */
- wchar = *(fchar+wrow); /* point to next character */
- for (wcol = 7 ; wcol >= 0 ; wcol --) { /* loop through 8 bits */
- jzloccur(9+wrow,36+wcol);
- jzwrtchr(wchar & 1 ? '▒' : ' ',GCHAR,1);
- wchar >>= 1;
- }
- }
- }
-
- savechar(fchar)
- char *fchar;
- {
- int wcol,wrow;
- unsigned char wbit;
- char wstr[9];
-
- for (wrow = 0 ; wrow < 8 ; wrow ++) {
- jzredscr(wstr,wrow + G_ROW + 1,G_COL + 1,8); /* read one line from screen */
- *fchar = 0; /* init to all zeros */
- wbit = 128; /* set 8th bit */
- for (wcol = 0 ; wcol < 8 ; wcol ++) {
- if (wstr[wcol] != 32) *fchar |= wbit;
- wbit >>= 1;
- }
- fchar++;
- }
- }
-
- clock()
- {
- char wstr[9];
- if (gcount >= 17) {
- jzbiostm(wstr);
- jzscrprn(wstr,2,71,GHEADING);
- gcount = 0;
- }
- else
- gcount ++;
- }
-
- printext(fstr)
- char *fstr;
- {
- while (*fstr)
- if (*fstr != '\n')
- printf("%c",(unsigned char) (*fstr++) | 0x80);
- else {
- printf("\n");
- fstr++;
- }
- }
-
-