xref: /original-bsd/sys/news3400/fb/askrom.c (revision 3705696b)
1 /*
2  * Copyright (c) 1992, 1993
3  *	The Regents of the University of California.  All rights reserved.
4  *
5  * This code is derived from software contributed to Berkeley by
6  * Sony Corp. and Kazumasa Utashiro of Software Research Associates, Inc.
7  *
8  * %sccs.include.redist.c%
9  *
10  * from: $Hdr: askrom.c,v 4.300 91/06/09 06:32:39 root Rel41 $ SONY
11  *
12  *	@(#)askrom.c	8.1 (Berkeley) 06/10/93
13  */
14 
15 #include "nwb514.h"
16 #include "nwb251.h"
17 #include "nwb256.h"
18 
19 #if NNWB514 > 0 || NNWB251 > 0 || NNWB256 > 0
20 
21 #ifdef IPC_MRX
22 #include "../../h/param.h"
23 #include "../../iop/framebuf.h"
24 #include "../../iop/fbreg.h"
25 #else
26 #include <sys/types.h>
27 #include <sys/param.h>
28 #include <news3400/iop/framebuf.h>
29 #include <news3400/iop/fbreg.h>
30 #endif
31 
32 #include <news3400/fb/fbdefs.h>
33 
34 #include <news3400/fb/qpdm.h>
35 
36 extern short zero[];
37 
38 extern char *ext_fnt_addr[];
39 extern char *ext_fnt24_addr[];
40 
41 int krom_enable = 0;
42 
43 caddr_t
44 autos_Krom_addr(fb, c, sr)
45 	struct fbdev *fb;
46 	register int c;
47 	lRectangle *sr;
48 {
49 	unsigned int cvcode24();
50 
51 	if ((c >= 0x20) && (c <= 0x7e)) {
52 		/*
53 		 * ASCII char
54 		 */
55 		c -= ' ';
56 		c = ((c & 0x1f) | ((c & 0xe0) << 2)) << 7;
57 		return ((caddr_t)(c + QP_KJROM + (sr->extent.y > 16 ? 0 : 96)));
58 	} else if ((c >= 0xa1) && (c <= 0xdf)) {
59 		/*
60 		 * KANA char
61 		 */
62 		if (sr->extent.y > 16)
63 			return ((caddr_t)ext_fnt24_addr[c + 64]);
64 		else
65 			return ((caddr_t)ext_fnt_addr[c + 64]);
66 	} else if ((c >= 0x2000) && (c <= 0x7fff)) {
67 		/*
68 		 * KANJI char
69 		 */
70 		switch (c & 0x7000) {
71 		case 0x2000:
72 			c = ((c & 0x1f)|((c & 0x60)<<5)|((c & 0x700)>>1))<<7;
73 			break;
74 		case 0x3000:
75 		case 0x4000:
76 			c = ((c & 0x7f)|((c & 0xf00)>>1)|((c & 0x4000)>>3))<<7;
77 			break;
78 		case 0x5000:
79 		case 0x6000:
80 			c = ((c & 0x7f)|((c & 0xf00)>>1)
81 					|((c & 0x2000)>>2)|0x1000) << 7;
82 			break;
83 		case 0x7000:
84 			c = ((c & 0x1f)|((c & 0x60)<<5)
85 					| ((c & 0x700)>>1)|0x1000) << 7;
86 			break;
87 		}
88 		return ((caddr_t)(c + QP_KJROM + (sr->extent.y > 16 ? 0 : 96)));
89 	} else {
90 		/*
91 		 * UNKNOWN char
92 		 */
93 		return ((caddr_t)zero);
94 	}
95 }
96 #endif /* NNWB514 > 0 || NNWB251 > 0 || NNWB256 > 0 */
97