xref: /original-bsd/sys/news3400/fb/askrom.c (revision 4463b7c2)
1 /*
2  * Copyright (c) 1992 The Regents of the University of California.
3  * 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	7.1 (Berkeley) 06/04/92
13  */
14 
15 #include "../include/fix_machine_type.h"
16 
17 #include "nwb514.h"
18 #include "nwb251.h"
19 #include "nwb256.h"
20 
21 #if NNWB514 > 0 || NNWB251 > 0 || NNWB256 > 0
22 
23 #ifdef IPC_MRX
24 #include "../../h/param.h"
25 #include "../../iop/framebuf.h"
26 #include "../../iop/fbreg.h"
27 #else
28 #include <sys/types.h>
29 #include "../h/types.h"
30 #include "../h/param.h"
31 #include "../iop/framebuf.h"
32 #include "../iop/fbreg.h"
33 #endif
34 
35 #include "../fb/fbdefs.h"
36 
37 #include "../fb/qpdm.h"
38 
39 extern short zero[];
40 
41 extern char *ext_fnt_addr[];
42 extern char *ext_fnt24_addr[];
43 
44 int krom_enable = 0;
45 
46 caddr_t
47 autos_Krom_addr(fb, c, sr)
48 	struct fbdev *fb;
49 	register int c;
50 	lRectangle *sr;
51 {
52 	unsigned int cvcode24();
53 
54 	if ((c >= 0x20) && (c <= 0x7e)) {
55 		/*
56 		 * ASCII char
57 		 */
58 		c -= ' ';
59 		c = ((c & 0x1f) | ((c & 0xe0) << 2)) << 7;
60 		return ((caddr_t)(c + QP_KJROM + (sr->extent.y > 16 ? 0 : 96)));
61 	} else if ((c >= 0xa1) && (c <= 0xdf)) {
62 		/*
63 		 * KANA char
64 		 */
65 		if (sr->extent.y > 16)
66 			return ((caddr_t)ext_fnt24_addr[c + 64]);
67 		else
68 			return ((caddr_t)ext_fnt_addr[c + 64]);
69 	} else if ((c >= 0x2000) && (c <= 0x7fff)) {
70 		/*
71 		 * KANJI char
72 		 */
73 		switch (c & 0x7000) {
74 		case 0x2000:
75 			c = ((c & 0x1f)|((c & 0x60)<<5)|((c & 0x700)>>1))<<7;
76 			break;
77 		case 0x3000:
78 		case 0x4000:
79 			c = ((c & 0x7f)|((c & 0xf00)>>1)|((c & 0x4000)>>3))<<7;
80 			break;
81 		case 0x5000:
82 		case 0x6000:
83 			c = ((c & 0x7f)|((c & 0xf00)>>1)
84 					|((c & 0x2000)>>2)|0x1000) << 7;
85 			break;
86 		case 0x7000:
87 			c = ((c & 0x1f)|((c & 0x60)<<5)
88 					| ((c & 0x700)>>1)|0x1000) << 7;
89 			break;
90 		}
91 		return ((caddr_t)(c + QP_KJROM + (sr->extent.y > 16 ? 0 : 96)));
92 	} else {
93 		/*
94 		 * UNKNOWN char
95 		 */
96 		return ((caddr_t)zero);
97 	}
98 }
99 #endif /* NNWB514 > 0 || NNWB251 > 0 || NNWB256 > 0 */
100