1 /* $Id $ */
2 /*
3 VRAM direct write routine for PC9801
4 written by A.Shirahashi, KEK
5 */
6
7 /*
8 * $Log: putline.c,v $
9 * Revision 1.3 2001/03/09 15:53:14 amura
10 * enable to really work autosave feature
11 *
12 * Revision 1.2 2001/01/20 15:47:23 amura
13 * putline() support Hojo Kanji now
14 *
15 * Revision 1.1.1.1 2000/06/27 01:47:58 amura
16 * import to CVS
17 *
18 */
19 /*
20 90.03.31 Modified by A.Shirahashi, support for 'SO' mode line
21 90.03.28 Created by A.Shirahashi
22 */
23
24 #include "config.h" /* 90.12.20 by S.Yoshida */
25 #include "def.h"
26
27 #include <dos.h>
28
29 #ifndef __TURBOC__ /* 90.04.06 by S.Yoshida */
30 #define MK_FP(seg,ofs) ((void far *) \
31 (((unsigned long)(seg) << 16) | (unsigned)(ofs)))
32
33 #define poke(a,b,c) (*((int far*)MK_FP((a),(b))) = (int)(c))
34 #define pokeb(a,b,c) (*((char far*)MK_FP((a),(b))) = (char)(c))
35 #endif /* __TURBOC__ */
36
37 #ifdef PC9801 /* 90.03.30 by S.Yoshida ("#ifdef" line only) */
38 #define iseuc1st(c) ((c) >= 0xa1 && (c) <= 0xfe)
39 #define etoj(c1, c2) {c1 &= 0x7f; c2 &= 0x7f;}
40
41 #define VRAM_SEG 0xa000
42 #define ATTR_SEG 0xa200
43
44 #define C_BLUE 0x02
45 #define C_RED 0x04
46 #define C_PURPLE 0x06
47 #define C_GREEN 0x08
48 #define C_CYAN 0xa0
49 #define C_YELLOW 0xc0
50 #define C_WHITE 0xe0
51
52 #define A_NORMAL 0x01
53 #define A_REVERSE 0x05
54
55 #define CNONE 0 /* Unknown color. */
56 #define CTEXT 1 /* Text color. */
57 #define CMODE 2 /* Mode line color. */
58
59 #ifndef TCCONIO
60 extern char *SO;
61 #endif
62
63 #ifdef HOJO_KANJI
64 #include "kinit.h" /* for TOUFU charactor */
65 #endif
66
67 VOID
68 #ifdef SS_SUPPORT /* 92.11.21 by S.Sasaki */
putline(int row,int column,unsigned char * s,unsigned char * t,short color)69 putline(int row, int column, unsigned char *s, unsigned char *t, short color)
70 #else /* not SS_SUPPORT */
71 putline(int row, int column, unsigned char *s, short color)
72 #endif /* SS_SUPPORT */
73 {
74 unsigned int dest;
75 unsigned int c1, c2;
76 int attr;
77
78 dest = 160 * (row - 1);
79 if( color == CTEXT ) {
80 attr = C_WHITE|A_NORMAL;
81 } else if( color == CMODE ) {
82 #ifdef TCCONIO
83 attr = C_WHITE|A_REVERSE;
84 #else
85 switch( atoi(SO+2) ) {
86 case 7: attr = C_WHITE|A_REVERSE; break;
87 case 17: case 31: attr = C_RED|A_NORMAL; break;
88 case 18: case 34: attr = C_BLUE|A_NORMAL; break;
89 case 19: case 35: attr = C_PURPLE|A_NORMAL; break;
90 case 20: case 32: attr = C_GREEN|A_NORMAL; break;
91 case 21: case 33: attr = C_YELLOW|A_NORMAL; break;
92 case 22: case 36: attr = C_CYAN|A_NORMAL; break;
93 case 23: case 37: attr = C_WHITE|A_NORMAL; break;
94 case 41: attr = C_RED|A_REVERSE; break;
95 case 44: attr = C_BLUE|A_REVERSE; break;
96 case 45: attr = C_PURPLE|A_REVERSE; break;
97 case 42: attr = C_GREEN|A_REVERSE; break;
98 case 43: attr = C_YELLOW|A_REVERSE; break;
99 case 46: attr = C_CYAN|A_REVERSE; break;
100 case 47: attr = C_WHITE|A_REVERSE; break;
101 default: attr = C_WHITE|A_REVERSE; break;
102 }
103 #endif
104 }
105
106 while( *s && dest < 160 * row) {
107 #ifdef HANKANA /* 92.11.21 by S.Sasaki */
108 if ( ISHANKANA(*s) ) {
109 pokeb(ATTR_SEG, dest, attr);
110 poke(VRAM_SEG, dest, *t++);
111 ++s;
112 dest += 2;
113 } else
114 #endif /* HANKANA */
115 #ifdef HOJO_KANJI
116 if ( ISHOJO(*s) ) {
117 pokeb(ATTR_SEG, dest, attr);
118 pokeb(VRAM_SEG, dest++, TOUFU1ST - 0x20);
119 pokeb(VRAM_SEG, dest++, TOUFU2ND);
120 pokeb(ATTR_SEG, dest, attr);
121 pokeb(VRAM_SEG, dest++, TOUFU1ST - 0x20);
122 pokeb(VRAM_SEG, dest++, TOUFU2ND + 0x80);
123 s += 3;
124 } else
125 #endif
126 if( iseuc1st(*s) ) {
127 c1 = *s++;
128 c2 = *s++;
129 #ifdef HANKANA /* 92.11.21 by S.Sasaki */
130 t += 2;
131 #endif /* HANKANA */
132 etoj(c1, c2);
133 pokeb(ATTR_SEG, dest, attr);
134 pokeb(VRAM_SEG, dest++, c1 - 0x20);
135 pokeb(VRAM_SEG, dest++, c2);
136 pokeb(ATTR_SEG, dest, attr);
137 pokeb(VRAM_SEG, dest++, c1 - 0x20);
138 pokeb(VRAM_SEG, dest++, c2 + 0x80);
139 } else {
140 pokeb(ATTR_SEG, dest, attr);
141 #ifdef BACKSLASH
142 if (*s == '\\') {
143 poke(VRAM_SEG, dest, 0xfc);
144 ++s;
145 } else
146 #endif /* BACKSLASH */
147 poke(VRAM_SEG, dest, *s++);
148 #ifdef HANKANA /* 92.11.21 by S.Sasaki */
149 ++t;
150 #endif /* HANKANA */
151 dest += 2;
152 }
153 }
154 }
155 #endif /* PC9801 */
156