1 /************************************************************************/
2 /* */
3 /* CRTC �� DMAC ��� */
4 /* */
5 /************************************************************************/
6
7 #include "quasi88.h"
8 #include "crtcdmac.h"
9 #include "memory.h"
10
11 #include "screen.h"
12 #include "suspend.h"
13
14
15 /*======================================================================
16 *
17 *======================================================================*/
18
19 /* CRTC¦���鸫�����ȥ�ӥ塼�� */
20
21 #define MONO_SECRET 0x01
22 #define MONO_BLINK 0x02
23 #define MONO_REVERSE 0x04
24 #define MONO_UPPER 0x10
25 #define MONO_UNDER 0x20
26 #define MONO_GRAPH 0x80
27 #define COLOR_SWITCH 0x08
28 #define COLOR_GRAPH 0x10
29 #define COLOR_B 0x20
30 #define COLOR_R 0x40
31 #define COLOR_G 0x80
32
33 /* ����ɽ���ǻ��Ѥ��륢�ȥ�ӥ塼�� */
34
35 #define ATTR_REVERSE 0x01 /* ȿž */
36 #define ATTR_SECRET 0x02 /* ɽ��/��ɽ�� */
37 #define ATTR_UPPER 0x04 /* ���åѡ��饤�� */
38 #define ATTR_LOWER 0x08 /* ��������饤�� */
39 #define ATTR_GRAPH 0x10 /* ����ե��å��⡼�� */
40 #define ATTR_B 0x20 /* �� Blue */
41 #define ATTR_R 0x40 /* �� Reg */
42 #define ATTR_G 0x80 /* �� Green */
43
44 #define MONO_MASK 0x0f
45 #define COLOR_MASK 0xe0
46
47 /*======================================================================*/
48
49 int text_display = TEXT_ENABLE; /* �ƥ�����ɽ���ե饰 */
50
51 int blink_cycle; /* ���Ǥμ��� 8/16/24/32 */
52 int blink_counter = 0; /* �������楫���� */
53
54 int dma_wait_count = 0; /* DMA�Ǿ��륵������� */
55
56
57 static int crtc_command;
58 static int crtc_param_num;
59
60 static byte crtc_status;
61 static byte crtc_light_pen[2];
62 static byte crtc_load_cursor_position;
63
64
65 int crtc_active; /* CRTC�ξ��� 0:CRTC��ư 1:CRTC��� */
66 int crtc_intr_mask; /* CRTC�γ���ޥ��� ==3 ��ɽ�� */
67 int crtc_cursor[2]; /* ����������� ��ɽ���λ���(-1,-1) */
68 byte crtc_format[5]; /* CRTC �������Υե����ޥå� */
69
70
71 int crtc_reverse_display; /* ����ȿžɽ�� / �����̾�ɽ�� */
72
73 int crtc_skip_line; /* ����1�����Ф�ɽ�� / �����̾� */
74 int crtc_cursor_style; /* �֥�å� / ������饤�� */
75 int crtc_cursor_blink; /* �������Ǥ��� �������Ǥ��ʤ� */
76 int crtc_attr_non_separate; /* ����VRAM��ATTR ����ߤ��¤� */
77 int crtc_attr_color; /* ���ĥ��顼 ������� */
78 int crtc_attr_non_special; /* ���ĹԤν���� ATTR ���¤� */
79
80 int CRTC_SZ_LINES =20; /* ɽ�������� (20/25) */
81 #define CRTC_SZ_COLUMNS (80) /* ɽ������Կ� (80����) */
82
83 int crtc_sz_lines =20; /* ��� (20��25) */
84 int crtc_sz_columns =80; /* �Կ� (2��80) */
85 int crtc_sz_attrs =20; /* °���� (1��20) */
86 int crtc_byte_per_line=120; /* 1�Ԥ�����Υ��� �Х��ȿ� */
87 int crtc_font_height =10; /* �ե���Ȥι⤵ �ɥåȿ�(8/10)*/
88
89
90
91 /******************************************************************************
92
93 ���������������� crtc_byte_per_line ����������������
94 ������ crtc_sz_columns ������ �� crtc_sz_attrs ��
95 +-------------------------------+-------------------+
96 ��| |�� |
97 ��| +--+ �� |�� |
98 ��| | | crtc_font_height |�� |
99 | +--+ �� | |
100 CRTC_SZ_LINES| |crtc_sz_lines |
101 | | |
102 ��| |�� |
103 ��| |�� |
104 ��| |�� |
105 +-------------------------------+-------------------+
106 ������ CRTC_SZ_COLUMNS ������
107
108 crtc_sz_columns ��� 2��80
109 crtc_sz_attrs °���� 1��20
110 crtc_byte_per_line 1�Ԥ�����Υ����� columns + attrs*2
111 crtc_sz_lines �Կ� 20��25
112 crtc_font_height �ե���Ȥι⤵�ɥå��� 8/10
113 CRTC_SZ_COLUMNS ɽ�������� 80
114 CRTC_SZ_LINES ɽ������Կ� 20/25
115
116 ******************************************************************************/
117
118
119
120
121
122
123
124
125
126 /* ���ͤޤǤˡġġ� */
127 /* SORCERIAN �� 1���������� */
128 /* Marchen Veil �� ���ȥ�ӥ塼�Ȥʤ��⡼�� */
129 /* Xanadu II (E disk) �� �� */
130 /* Wizardry V �� �Υ�ȥ�ڥ���������⡼�� */
131
132
133 enum{
134 CRTC_RESET = 0,
135 CRTC_STOP_DISPLAY = 0,
136 CRTC_START_DISPLAY,
137 CRTC_SET_INTERRUPT_MASK,
138 CRTC_READ_LIGHT_PEN,
139 CRTC_LOAD_CURSOR_POSITION,
140 CRTC_RESET_INTERRUPT,
141 CRTC_RESET_COUNTERS,
142 CRTC_READ_STATUS,
143 EndofCRTC
144 };
145 #define CRTC_STATUS_VE (0x10) /* ����ɽ��ͭ�� */
146 #define CRTC_STATUS_U (0x08) /* DMA���������� */
147 #define CRTC_STATUS_N (0x04) /* �ü�����ʸ�����ȯ�� */
148 #define CRTC_STATUS_E (0x02) /* ɽ����λ���ȯ�� */
149 #define CRTC_STATUS_LP (0x01) /* �饤�ȥڥ����� */
150
151
152 /****************************************************************/
153 /* CRTC��Ʊ����������� (OUT 40H,A ... bit3) */
154 /* �ä˥��ߥ�졼�Ȥ�ɬ�פʤ������������Ȼפ��� */
155 /****************************************************************/
156 #ifdef SUPPORT_CRTC_SEND_SYNC_SIGNAL
crtc_send_sync_signal(int flag)157 void crtc_send_sync_signal( int flag )
158 {
159 }
160 #endif
161
162
163
164
165 /****************************************************************/
166 /* CRTC ���ߥ�졼����� */
167 /****************************************************************/
168
169 /*-------- ����� --------*/
170
crtc_init(void)171 void crtc_init( void )
172 {
173 crtc_out_command( CRTC_RESET << 5 );
174 crtc_out_parameter( 0xce );
175 crtc_out_parameter( 0x98 );
176 crtc_out_parameter( 0x6f );
177 crtc_out_parameter( 0x58 );
178 crtc_out_parameter( 0x53 );
179
180 crtc_out_command( CRTC_LOAD_CURSOR_POSITION << 5 );
181 crtc_out_parameter( 0 );
182 crtc_out_parameter( 0 );
183 }
184
185 /*-------- ���ޥ�����ϻ� --------*/
186
crtc_out_command(byte data)187 void crtc_out_command( byte data )
188 {
189 crtc_command = data >> 5;
190 crtc_param_num = 0;
191
192 switch( crtc_command ){
193
194 case CRTC_RESET: /* �ꥻ�å� */
195 crtc_status &= ~( CRTC_STATUS_VE | CRTC_STATUS_N | CRTC_STATUS_E );
196 crtc_active = FALSE;
197 set_text_display();
198 screen_set_dirty_all();
199 break;
200
201 case CRTC_START_DISPLAY: /* ɽ������ */
202 crtc_reverse_display = data & 0x01;
203 crtc_status |= CRTC_STATUS_VE;
204 crtc_status &= ~( CRTC_STATUS_U );
205 crtc_active = TRUE;
206 set_text_display();
207 screen_set_dirty_palette();
208 break;
209
210 case CRTC_SET_INTERRUPT_MASK:
211 crtc_intr_mask = data & 0x03;
212 set_text_display();
213 screen_set_dirty_all();
214 break;
215
216 case CRTC_READ_LIGHT_PEN:
217 crtc_status &= ~( CRTC_STATUS_LP );
218 break;
219
220 case CRTC_LOAD_CURSOR_POSITION: /* ������������ */
221 crtc_load_cursor_position = data & 0x01;
222 crtc_cursor[ 0 ] = -1;
223 crtc_cursor[ 1 ] = -1;
224 break;
225
226 case CRTC_RESET_INTERRUPT:
227 case CRTC_RESET_COUNTERS:
228 crtc_status &= ~( CRTC_STATUS_N | CRTC_STATUS_E );
229 break;
230
231 }
232 }
233
234 /*-------- �ѥ������ϻ� --------*/
235
crtc_out_parameter(byte data)236 void crtc_out_parameter( byte data )
237 {
238 switch( crtc_command ){
239 case CRTC_RESET:
240 if( crtc_param_num < 5 ){
241 crtc_format[ crtc_param_num++ ] = data;
242 }
243
244 crtc_skip_line = crtc_format[2] & 0x80; /* bool */
245
246 crtc_attr_non_separate = crtc_format[4] & 0x80; /* bool */
247 crtc_attr_color = crtc_format[4] & 0x40; /* bool */
248 crtc_attr_non_special = crtc_format[4] & 0x20; /* bool */
249
250 crtc_cursor_style =(crtc_format[2] & 0x40) ?ATTR_REVERSE :ATTR_LOWER;
251 crtc_cursor_blink = crtc_format[2] & 0x20; /* bool */
252 blink_cycle =(crtc_format[1]>>6) * 8 +8; /* 8,16,24,48*/
253
254 crtc_sz_lines =(crtc_format[1] & 0x3f) +1; /* 1��25 */
255 if ( crtc_sz_lines <= 20 ) crtc_sz_lines = 20;
256 else if( crtc_sz_lines >= 25 ) crtc_sz_lines = 25;
257 else crtc_sz_lines = 24;
258
259 crtc_sz_columns =(crtc_format[0] & 0x7f) +2; /* 2��80 */
260 if( crtc_sz_columns > 80 ) crtc_sz_columns = 80;
261
262 crtc_sz_attrs =(crtc_format[4] & 0x1f) +1; /* 1��20 */
263 if ( crtc_attr_non_special ) crtc_sz_attrs = 0;
264 else if( crtc_sz_attrs > 20 ) crtc_sz_attrs = 20;
265
266 crtc_byte_per_line = crtc_sz_columns + crtc_sz_attrs * 2; /*column+attr*/
267
268 crtc_font_height = (crtc_sz_lines>20) ? 8 : 10;
269 CRTC_SZ_LINES = (crtc_sz_lines>20) ? 25 : 20;
270
271 frameskip_blink_reset();
272 break;
273
274 case CRTC_LOAD_CURSOR_POSITION:
275 if( crtc_param_num < 2 ){
276 if( crtc_load_cursor_position ){
277 crtc_cursor[ crtc_param_num++ ] = data;
278 }else{
279 crtc_cursor[ crtc_param_num++ ] = -1;
280 }
281 }
282 break;
283
284 }
285 }
286
287 /*-------- ���ơ��������ϻ� --------*/
288
crtc_in_status(void)289 byte crtc_in_status( void )
290 {
291 return crtc_status;
292 }
293
294 /*-------- �ѥ������ϻ� --------*/
295
crtc_in_parameter(void)296 byte crtc_in_parameter( void )
297 {
298 byte data = 0xff;
299
300 switch( crtc_command ){
301 case CRTC_READ_LIGHT_PEN:
302 if( crtc_param_num < 2 ){
303 data = crtc_light_pen[ crtc_param_num++ ];
304 }
305 return data;
306 }
307
308 return 0xff;
309 }
310
311
312
313
314
315 /****************************************************************/
316 /* DMAC ���ߥ�졼����� */
317 /****************************************************************/
318
319 static int dmac_flipflop;
320 pair dmac_address[4];
321 pair dmac_counter[4];
322 int dmac_mode;
323
324
dmac_init(void)325 void dmac_init( void )
326 {
327 dmac_flipflop = 0;
328 dmac_address[0].W = 0;
329 dmac_address[1].W = 0;
330 dmac_address[2].W = 0xf3c8;
331 dmac_address[3].W = 0;
332 dmac_counter[0].W = 0;
333 dmac_counter[1].W = 0;
334 dmac_counter[2].W = 0;
335 dmac_counter[3].W = 0;
336 }
337
338
dmac_out_mode(byte data)339 void dmac_out_mode( byte data )
340 {
341 dmac_flipflop = 0;
342 dmac_mode = data;
343
344 set_text_display();
345 screen_set_dirty_all();
346 }
dmac_in_status(void)347 byte dmac_in_status( void )
348 {
349 return 0x1f;
350 }
351
352
dmac_out_address(byte addr,byte data)353 void dmac_out_address( byte addr, byte data )
354 {
355 if( dmac_flipflop==0 ) dmac_address[ addr ].B.l=data;
356 else dmac_address[ addr ].B.h=data;
357
358 dmac_flipflop ^= 0x1;
359 screen_set_dirty_all(); /* �����ϡ�addr==2�λ��Τߡġġ� */
360 }
dmac_out_counter(byte addr,byte data)361 void dmac_out_counter( byte addr, byte data )
362 {
363 if( dmac_flipflop==0 ) dmac_counter[ addr ].B.l=data;
364 else dmac_counter[ addr ].B.h=data;
365
366 dmac_flipflop ^= 0x1;
367 }
368
369
dmac_in_address(byte addr)370 byte dmac_in_address( byte addr )
371 {
372 byte data;
373
374 if( dmac_flipflop==0 ) data = dmac_address[ addr ].B.l;
375 else data = dmac_address[ addr ].B.h;
376
377 dmac_flipflop ^= 0x1;
378 return data;
379 }
dmac_in_counter(byte addr)380 byte dmac_in_counter( byte addr )
381 {
382 byte data;
383
384 if( dmac_flipflop==0 ) data = dmac_counter[ addr ].B.l;
385 else data = dmac_counter[ addr ].B.h;
386
387 dmac_flipflop ^= 0x1;
388 return data;
389 }
390
391
392 /***********************************************************************
393 * CRTC,DMAC���������ӡ�I/O 31H / 53H ���ϻ��˸Ƥ�
394 ************************************************************************/
set_text_display(void)395 void set_text_display(void)
396 {
397 if( (dmac_mode & 0x4) && (crtc_active) && crtc_intr_mask==3){
398 if( !(grph_pile & GRPH_PILE_TEXT) ){
399 text_display = TEXT_ENABLE;
400 }else{
401 if( grph_ctrl & GRPH_CTRL_COLOR )
402 text_display = TEXT_DISABLE;
403 else
404 text_display = TEXT_ATTR_ONLY;
405 }
406 }else{
407 text_display = TEXT_DISABLE;
408 }
409 }
410
411
412 /***********************************************************************
413 * ����ɽ���Τ���δؿ�
414 ************************************************************************/
415
416
417 /*======================================================================
418 * �ƥ�����VRAM�Υ��ȥ�ӥ塼�Ȥ����ѥ�������ꤹ��
419 *
420 * �Хåե���2�Ĥ��ꡢ��ߤ����ؤ��ƻ��Ѥ��롣
421 * ���̽����κݤϡ�����2�ĤΥХåե�����Ӥ����Ѳ���
422 * ���ä���ʬ���������롣
423 *
424 * ����ϡ�16bit�ǡ����8bit��ʸ�������ɡ����̤�°����
425 * ��������ե��å��⡼�ɡ���������饤��
426 * ���åѡ��饤��������åȡ���С���
427 * +---------------------+--+--+--+--+--+--+--+--+
428 * | ASCII 8bit |��|��|��|GR|LO|UP|SC|RV|
429 * +---------------------+--+--+--+--+--+--+--+--+
430 * BLINK°���ϡ���������̵�롢�������ϥ�������åȡ�
431 *
432 * ����ˡ���������å�°���ξ��� ʸ�������ɤ� 0 ���ִ����롣
433 * (ʸ��������==0��̵���Ƕ���Ȥ��Ƥ���Τ�)
434 * +---------------------+--+--+--+--+--+--+--+--+
435 * �� | ASCII == 0 |��|��|��|��|LO|UP|��|RV|
436 * +---------------------+--+--+--+--+--+--+--+--+
437 * ����ե��å��⡼�ɤȥ�������å�°����ä��Ƥ�OK������
438 * ������������åѡ��饤��С�����ͭ���ʤΤǻĤ���
439 *
440 *======================================================================*/
441
442 int text_attr_flipflop = 0;
443 Ushort text_attr_buf[2][2048]; /* ���ȥ�ӥ塼�Ⱦ��� */
444 /* �� 80ʸ��x25��=2000�����Τ����� */
445 /* ;ʬ�˻Ȥ��Τǡ�¿��˳��ݤ��롣 */
446
447
crtc_make_text_attr(void)448 void crtc_make_text_attr( void )
449 {
450 int global_attr = (ATTR_G|ATTR_R|ATTR_B);
451 int global_blink = FALSE;
452 int i, j, tmp;
453 int column, attr, attr_rest;
454 word char_start_addr, attr_start_addr;
455 word c_addr, a_addr;
456 Ushort *text_attr = &text_attr_buf[ text_attr_flipflop ][0];
457
458
459 /* CRTC �� DMAC ��ߤޤäƤ����� */
460 /* (ʸ���⥢�ȥ�ӥ塼�Ȥ�̵��) */
461
462 if( text_display==TEXT_DISABLE ){ /* ASCII=0���������ʤ� */
463 for( i=0; i<CRTC_SZ_LINES; i++ ){ /* �ǽ�������롣 */
464 for( j=0; j<CRTC_SZ_COLUMNS; j++ ){
465 *text_attr ++ = (ATTR_G|ATTR_R|ATTR_B);
466 }
467 }
468 return; /* ������ȿž�䥫�������ʤ������������ */
469 }
470
471
472
473 /* �Υȥ�ڥ����ȷ��ξ�� */
474 /* (1ʸ���֤��ˡ�VRAM��ATTR ������) */
475
476 /* �ġġ� ���ܺ����� */
477 /* CRTC������ѥ����餷�ơ�����˹Ԥ� */
478 /* �Ǹ��°����������⤢�ꤨ����������? */
479
480 if( crtc_attr_non_separate ){
481
482 char_start_addr = text_dma_addr.W;
483 attr_start_addr = text_dma_addr.W + 1;
484
485 for( i=0; i<crtc_sz_lines; i++ ){
486
487 c_addr = char_start_addr;
488 a_addr = attr_start_addr;
489
490 char_start_addr += crtc_byte_per_line;
491 attr_start_addr += crtc_byte_per_line;
492
493 for( j=0; j<CRTC_SZ_COLUMNS; j+=2 ){ /* °�������������ɤ�*/
494 attr = main_ram[ a_addr ]; /* �Ѵ�����°�����*/
495 a_addr += 2; /* ���������롣 */
496 global_attr =( global_attr & COLOR_MASK ) |
497 ((attr & MONO_GRAPH) >> 3 ) |
498 ((attr & (MONO_UNDER|MONO_UPPER|MONO_REVERSE))>>2) |
499 ((attr & MONO_SECRET) << 1 );
500
501 /* BLINK��OFF����SECRET���� */
502 if( (attr & MONO_BLINK) && ((blink_counter&0x03)==0) ){
503 global_attr |= ATTR_SECRET;
504 }
505
506 *text_attr ++ = ((Ushort)main_ram[ c_addr ++ ] << 8 ) | global_attr;
507 *text_attr ++ = ((Ushort)main_ram[ c_addr ++ ] << 8 ) | global_attr;
508
509 }
510
511 if( crtc_skip_line ){
512 if( ++i < crtc_sz_lines ){
513 for( j=0; j<CRTC_SZ_COLUMNS; j++ ){
514 *text_attr ++ = global_attr | ATTR_SECRET;
515 }
516 }
517 }
518
519 }
520 for( ; i<CRTC_SZ_LINES; i++ ){ /* �Ĥ�ιԤϡ�SECRET */
521 for( j=0; j<CRTC_SZ_COLUMNS; j++ ){ /* (24�������к�) */
522 *text_attr ++ = global_attr | ATTR_SECRET;
523 }
524 }
525
526 }else{
527
528 /* �ȥ�ڥ����ȷ��ξ�� */
529 /* (�ԤκǸ�ˡ�ATTR������) */
530
531 char_start_addr = text_dma_addr.W;
532 attr_start_addr = text_dma_addr.W + crtc_sz_columns;
533
534 for( i=0; i<crtc_sz_lines; i++ ){ /* ��ñ�̤�°������ */
535
536 c_addr = char_start_addr;
537 a_addr = attr_start_addr;
538
539 char_start_addr += crtc_byte_per_line;
540 attr_start_addr += crtc_byte_per_line;
541
542
543 attr_rest = 0; /*°������� */
544 for( j=0; j<=CRTC_SZ_COLUMNS; j++ ) text_attr[j] = 0; /* [0]��[80] */
545
546
547 for( j=0; j<crtc_sz_attrs; j++ ){ /* °����������ܤ� */
548 column = main_ram[ a_addr++ ]; /* ����˳�Ǽ */
549 attr = main_ram[ a_addr++ ];
550
551 if( j!=0 && column==0 ) column = 0x80; /* �ü����?*/
552 if( j==0 && column==0x80 ){column = 0;
553 /* global_attr = (ATTR_G|ATTR_R|ATTR_B);
554 global_blink= FALSE; }*/}
555
556 if( column==0x80 && !attr_rest ){ /* 8bit�ܤ� */
557 attr_rest = attr | 0x100; /* ���ѺѤ� */
558 } /* �ե饰 */
559 else if( column <= CRTC_SZ_COLUMNS && !text_attr[ column ] ){
560 text_attr[ column ] = attr | 0x100;
561 }
562 }
563
564
565 if( !text_attr[0] && attr_rest ){ /* �����-1�ޤ�°����*/
566 for( j=CRTC_SZ_COLUMNS; j; j-- ){ /* ͭ�����Ȥ�������*/
567 if( text_attr[j] ){ /* ������(�����ʹ� */
568 tmp = text_attr[j]; /* °����ͭ�����Ȥ���*/
569 text_attr[j] = attr_rest; /* �դ����¤��ؤ���) */
570 attr_rest = tmp;
571 }
572 }
573 text_attr[0] = attr_rest;
574 }
575
576
577 for( j=0; j<CRTC_SZ_COLUMNS; j++ ){ /* °�������������ɤ�*/
578 /* �Ѵ�����°�����*/
579 if( ( attr = *text_attr ) ){ /* ���������롣 */
580 if( crtc_attr_color ){
581 if( attr & COLOR_SWITCH ){
582 global_attr =( global_attr & MONO_MASK ) |
583 ( attr & (COLOR_G|COLOR_R|COLOR_B|COLOR_GRAPH));
584 }else{
585 global_attr =( global_attr & (COLOR_MASK|ATTR_GRAPH) ) |
586 ((attr & (MONO_UNDER|MONO_UPPER|MONO_REVERSE))>>2) |
587 ((attr & MONO_SECRET) << 1 );
588 global_blink= (attr & MONO_BLINK);
589 }
590 }else{
591 global_attr =( global_attr & COLOR_MASK ) |
592 ((attr & MONO_GRAPH) >> 3 ) |
593 ((attr & (MONO_UNDER|MONO_UPPER|MONO_REVERSE))>>2) |
594 ((attr & MONO_SECRET) << 1 );
595 global_blink= (attr & MONO_BLINK);
596 }
597 /* BLINK��OFF����SECRET���� */
598 if( global_blink && ((blink_counter&0x03)==0) ){
599 global_attr = global_attr | ATTR_SECRET;
600 }
601 }
602
603 *text_attr ++ = ((Ushort)main_ram[ c_addr ++ ] << 8 ) | global_attr;
604
605 }
606
607 if( crtc_skip_line ){ /* 1�������������*/
608 if( ++i < crtc_sz_lines ){ /* ���ιԤ�SECRET�� */
609 for( j=0; j<CRTC_SZ_COLUMNS; j++ ){ /* ���롣 */
610 *text_attr ++ = global_attr | ATTR_SECRET;
611 }
612 }
613 }
614
615 }
616
617 for( ; i<CRTC_SZ_LINES; i++ ){ /* �Ĥ�ιԤϡ�SECRET */
618 for( j=0; j<CRTC_SZ_COLUMNS; j++ ){ /* (24�������к�) */
619 *text_attr ++ = global_attr | ATTR_SECRET;
620 }
621 }
622
623 }
624
625
626
627 /* CRTC �� DMAC ��ư���Ƥ��뤱�ɡ� �ƥ����Ȥ���ɽ�� */
628 /* ��VRAM����ξ�� (���ȥ�ӥ塼�Ȥο�������ͭ��) */
629
630 if( text_display==TEXT_ATTR_ONLY ){
631
632 text_attr = &text_attr_buf[ text_attr_flipflop ][0];
633
634 for( i=0; i<CRTC_SZ_LINES; i++ ){
635 for( j=0; j<CRTC_SZ_COLUMNS; j++ ){
636 *text_attr ++ &= (ATTR_G|ATTR_R|ATTR_B);
637 }
638 }
639 return; /* ������ȿž�䥫����������ס������Ǥ���� */
640 }
641
642
643
644
645 /* ����ȿž���� */
646
647 if( crtc_reverse_display && (grph_ctrl & GRPH_CTRL_COLOR)){
648 text_attr = &text_attr_buf[ text_attr_flipflop ][0];
649 for( i=0; i<CRTC_SZ_LINES; i++ ){
650 for( j=0; j<CRTC_SZ_COLUMNS; j++ ){
651 *text_attr ++ ^= ATTR_REVERSE;
652 }
653 }
654 }
655
656 /* ��������ɽ������ */
657
658 if( 0 <= crtc_cursor[0] && crtc_cursor[0] < crtc_sz_columns &&
659 0 <= crtc_cursor[1] && crtc_cursor[1] < crtc_sz_lines ){
660 if( !crtc_cursor_blink || (blink_counter&0x01) ){
661 text_attr_buf[ text_attr_flipflop ][ crtc_cursor[1]*80 + crtc_cursor[0] ]
662 ^= crtc_cursor_style;
663 }
664 }
665
666
667 /* ��������å�°������ (ʸ�������� 0x00 ���ִ�) */
668
669 text_attr = &text_attr_buf[ text_attr_flipflop ][0];
670 for( i=0; i<CRTC_SZ_LINES; i++ ){
671 for( j=0; j<CRTC_SZ_COLUMNS; j++ ){
672 if( *text_attr & ATTR_SECRET ){ /* SECRET °���ϡ�������00�� */
673 *text_attr &= (COLOR_MASK|ATTR_UPPER|ATTR_LOWER|ATTR_REVERSE);
674 }
675 text_attr ++;
676 }
677 }
678
679 }
680
681
682
683
684
685
686 /***********************************************************************
687 * ���ꤵ�줿ʸ��������(°����ʸ��)��ꡢ�ե���Ȼ����ǡ�������������
688 *
689 * int attr �� ʸ�������ɡ� text_attr_buf[]���ͤǤ��롣
690 * T_GRYPH *gryph �� gryph->b[0]��[7] �� �ե���ȤΥӥåȥޥåפ�
691 * ��Ǽ����롣(20�Ի��ϡ�b[0]��[9]�˳�Ǽ)
692 * int *color �� �ե���Ȥο�����Ǽ����롣�ͤϡ� 8��15
693 *
694 * �����ǡ����ϡ�char 8��10�ĤʤΤ�������©�ʹ�®���Τ���� long ��
695 * �����������Ƥ��롣���Τ��ᡢ T_GRYPH �Ȥ���̯�ʷ���ȤäƤ��롣
696 * (����ס���������͡�)
697 *
698 * ��) ���ȥ�ӥ塼�Ⱦ���ɬ�פʤΤǡ�
699 * ͽ�� make_text_attr_table( ) ��Ƥ�Ǥ�������
700 ************************************************************************/
701
get_font_gryph(int attr,T_GRYPH * gryph,int * color)702 void get_font_gryph( int attr, T_GRYPH *gryph, int *color )
703 {
704 int chara;
705 bit32 *src;
706 bit32 *dst = (bit32 *)gryph;
707
708 *color = ((attr & COLOR_MASK) >> 5) | 8;
709
710
711 if( ( attr & ~(COLOR_MASK|ATTR_REVERSE) )==0 ){
712
713 if( ( attr & ATTR_REVERSE ) == 0 ){ /* ����ե���Ȼ� */
714
715 *dst++ = 0;
716 *dst++ = 0;
717 *dst = 0;
718
719 }else{ /* �٥��ե���Ȼ� */
720
721 *dst++ = 0xffffffff;
722 *dst++ = 0xffffffff;
723 *dst = 0xffffffff;
724 }
725
726 }else{ /* �̾�ե���Ȼ� */
727
728 chara = attr >> 8;
729
730 if( attr & ATTR_GRAPH )
731 src = (bit32 *)&font_rom[ (chara | 0x100)*8 ];
732 else
733 src = (bit32 *)&font_rom[ (chara )*8 ];
734
735 /* �ե���Ȥ�ޤ���������˥��ԡ� */
736 *dst++ = *src++;
737 *dst++ = *src;
738 *dst = 0;
739
740 /* °���ˤ����������ե���Ȥ�ù�*/
741 if( attr & ATTR_UPPER ) gryph->b[ 0 ] |= 0xff;
742 if( attr & ATTR_LOWER ) gryph->b[ crtc_font_height-1 ] |= 0xff;
743 if( attr & ATTR_REVERSE ){
744 dst -= 2;
745 *dst++ ^= 0xffffffff;
746 *dst++ ^= 0xffffffff;
747 *dst ^= 0xffffffff;
748 }
749 }
750 }
751
752
753
754
755
756 /***********************************************************************
757 * ���ơ��ȥ��ɡ����ơ��ȥ�����
758 ************************************************************************/
759
760 #define SID "CRTC"
761
762 static T_SUSPEND_W suspend_crtcdmac_work[]=
763 {
764 { TYPE_INT, &text_display, },
765 { TYPE_INT, &blink_cycle, },
766 { TYPE_INT, &blink_counter, },
767
768 { TYPE_INT, &dma_wait_count, },
769
770 { TYPE_INT, &crtc_command, },
771 { TYPE_INT, &crtc_param_num, },
772 { TYPE_BYTE, &crtc_status, },
773 { TYPE_BYTE, &crtc_light_pen[0], },
774 { TYPE_BYTE, &crtc_light_pen[1], },
775 { TYPE_BYTE, &crtc_load_cursor_position, },
776 { TYPE_INT, &crtc_active, },
777 { TYPE_INT, &crtc_intr_mask, },
778 { TYPE_INT, &crtc_cursor[0], },
779 { TYPE_INT, &crtc_cursor[1], },
780 { TYPE_BYTE, &crtc_format[0], },
781 { TYPE_BYTE, &crtc_format[1], },
782 { TYPE_BYTE, &crtc_format[2], },
783 { TYPE_BYTE, &crtc_format[3], },
784 { TYPE_BYTE, &crtc_format[4], },
785 { TYPE_INT, &crtc_reverse_display, },
786 { TYPE_INT, &crtc_skip_line, },
787 { TYPE_INT, &crtc_cursor_style, },
788 { TYPE_INT, &crtc_cursor_blink, },
789 { TYPE_INT, &crtc_attr_non_separate,},
790 { TYPE_INT, &crtc_attr_color, },
791 { TYPE_INT, &crtc_attr_non_special, },
792 { TYPE_INT, &CRTC_SZ_LINES, },
793 { TYPE_INT, &crtc_sz_lines, },
794 { TYPE_INT, &crtc_sz_columns, },
795 { TYPE_INT, &crtc_sz_attrs, },
796 { TYPE_INT, &crtc_byte_per_line, },
797 { TYPE_INT, &crtc_font_height, },
798
799 { TYPE_INT, &dmac_flipflop, },
800 { TYPE_PAIR, &dmac_address[0], },
801 { TYPE_PAIR, &dmac_address[1], },
802 { TYPE_PAIR, &dmac_address[2], },
803 { TYPE_PAIR, &dmac_address[3], },
804 { TYPE_PAIR, &dmac_counter[0], },
805 { TYPE_PAIR, &dmac_counter[1], },
806 { TYPE_PAIR, &dmac_counter[2], },
807 { TYPE_PAIR, &dmac_counter[3], },
808 { TYPE_INT, &dmac_mode, },
809
810 { TYPE_END, 0 },
811 };
812
813
statesave_crtcdmac(void)814 int statesave_crtcdmac( void )
815 {
816 if( statesave_table( SID, suspend_crtcdmac_work ) == STATE_OK ) return TRUE;
817 else return FALSE;
818 }
819
stateload_crtcdmac(void)820 int stateload_crtcdmac( void )
821 {
822 if( stateload_table( SID, suspend_crtcdmac_work ) == STATE_OK ) return TRUE;
823 else return FALSE;
824 }
825