Previous 15994 Revisions Next

r2552 Monday 5th May, 2008 at 21:16:54 UTC by Wilbert Pol
[IBMPCJR] Fixed graphics modes.
[src/mess/drivers]pc.c
[src/mess/video]pc_t1t.c pc_t1t.h

src/mess/video/pc_t1t.c
r2551r2552
9595/* Initialise the cga palette */
9696static PALETTE_INIT( pcjr )
9797{
98   const static unsigned char tga_palette[16][3] = {
98   const static unsigned char tga_palette[16][3] =
99   {
99100      { 0x00, 0x00, 0x00 }, { 0x00, 0x00, 0xaa }, { 0x00, 0xaa, 0x00 }, { 0x00, 0xaa, 0xaa },
100101      { 0xaa, 0x00, 0x00 }, { 0xaa, 0x00, 0xaa }, { 0xaa, 0x55, 0x00 }, { 0xaa, 0xaa, 0xaa },
101102      { 0x55, 0x55, 0x55 }, { 0x55, 0x55, 0xff }, { 0x55, 0xff, 0x55 }, { 0x55, 0xff, 0xff },
r2551r2552
107108      palette_set_color_rgb(machine, i, tga_palette[i][0], tga_palette[i][1], tga_palette[i][2]);
108109}
109110
110static struct {
111
112static struct
113{
111114   UINT8 mode_control, color_select;
112115   UINT8 status;
113116
r2551r2552
134137   UINT8 *chr_gen;
135138   UINT8   chr_size;
136139
140   UINT8   address_data_ff;
141
137142   mc6845_update_row_func   update_row;
138143   UINT8   hsync;
139144   UINT8   vsync;
r2551r2552
162167   videoram_size = 0x8000;
163168}
164169
165static VIDEO_UPDATE( mc6845_t1000 ) {
170static VIDEO_UPDATE( mc6845_t1000 )
171{
166172   device_config   *devconf = (device_config *) device_list_find_by_tag(screen->machine->config->devicelist, MC6845, T1000_MC6845_NAME);
167173   mc6845_update( devconf, bitmap, cliprect);
168174   return 0;
169175}
170176
171177
172static MC6845_UPDATE_ROW( t1000_text_inten_update_row ) {
178static MC6845_UPDATE_ROW( t1000_text_inten_update_row )
179{
173180   UINT16  *p = BITMAP_ADDR16(bitmap, y, 0);
174181   int i;
175182
176183   if ( y == 0 ) logerror("t1000_text_inten_update_row\n");
177   for ( i = 0; i < x_count; i++ ) {
184   for ( i = 0; i < x_count; i++ )
185   {
178186      UINT16 offset = ( ( ma + i ) << 1 ) & 0x3fff;
179187      UINT8 chr = pcjr.displayram[ offset ];
180188      UINT8 attr = pcjr.displayram[ offset +1 ];
r2551r2552
182190      UINT16 fg = attr & 0x0F;
183191      UINT16 bg = ( attr >> 4 ) & 0x07;
184192
185      if ( i == cursor_x ) {
193      if ( i == cursor_x && ( pcjr.pc_framecnt & 0x08 ) )
194      {
186195         data = 0xFF;
187196      }
188197
r2551r2552
198207}
199208
200209
201static MC6845_UPDATE_ROW( t1000_text_blink_update_row ) {
210static MC6845_UPDATE_ROW( t1000_text_blink_update_row )
211{
202212   UINT16   *p = BITMAP_ADDR16(bitmap, y, 0);
203213   int i;
204214
205   for ( i = 0; i < x_count; i++ ) {
215   for ( i = 0; i < x_count; i++ )
216   {
206217      UINT16 offset = ( ( ma + i ) << 1 ) & 0x3fff;
207218      UINT8 chr = pcjr.displayram[ offset ];
208219      UINT8 attr = pcjr.displayram[ offset +1 ];
r2551r2552
210221      UINT16 fg = attr & 0x0F;
211222      UINT16 bg = ( attr >> 4 ) & 0x07;
212223
213      if ( i == cursor_x ) {
214         data = 0xFF;
215      } else {
216         if ( ( attr & 0x80 ) && ( pcjr.pc_framecnt & 0x10 ) ) {
224      if ( i == cursor_x )
225      {
226         if ( pcjr.pc_framecnt & 0x08 )
227         {
228            data = 0xFF;
229         }
230      }
231      else
232      {
233         if ( ( attr & 0x80 ) && ( pcjr.pc_framecnt & 0x10 ) )
234         {
217235            data = 0x00;
218236         }
219237      }
r2551r2552
230248}
231249
232250
233static MC6845_UPDATE_ROW( t1000_gfx_4bpp_update_row ) {
251static MC6845_UPDATE_ROW( t1000_gfx_4bpp_update_row )
252{
234253   UINT16   *p = BITMAP_ADDR16(bitmap, y, 0);
235254   UINT8   *vid = pcjr.displayram + ( ra << 13 );
236255   int i;
237256
238   for ( i = 0; i < x_count; i++ ) {
257   for ( i = 0; i < x_count; i++ )
258   {
239259      UINT16 offset = ( ( ma + i ) << 1 ) & 0x1fff;
240260      UINT8 data = vid[ offset ];
241261
r2551r2552
254274}
255275
256276
257static MC6845_UPDATE_ROW( t1000_gfx_2bpp_update_row ) {
277static MC6845_UPDATE_ROW( t1000_gfx_2bpp_update_row )
278{
258279   UINT16  *p = BITMAP_ADDR16(bitmap, y, 0);
259280   UINT8   *vid = pcjr.displayram + ( ra << 13 );
260281   int i;
261282
262283   if ( y == 0 ) logerror("t1000_gfx_2bpp_update_row\n");
263   for ( i = 0; i < x_count; i++ ) {
284   for ( i = 0; i < x_count; i++ )
285   {
264286      UINT16 offset = ( ( ma + i ) << 1 ) & 0x1fff;
265287      UINT8 data = vid[ offset ];
266288
r2551r2552
279301}
280302
281303
282static MC6845_UPDATE_ROW( t1000_gfx_2bpp_tga_update_row ) {
304static MC6845_UPDATE_ROW( t1000_gfx_2bpp_tga_update_row )
305{
283306   UINT16   *p = BITMAP_ADDR16(bitmap, y, 0);
284307   UINT8   *vid = pcjr.displayram + ( ra << 13 );
285308   int i;
286309
287310   if ( y == 0 ) logerror("t1000_gfx_2bpp_tga_update_row\n");
288   for ( i = 0; i < x_count; i++ ) {
311   for ( i = 0; i < x_count; i++ )
312   {
289313      UINT16 offset = ( ( ma + i ) << 1 ) & 0x1fff;
290314      UINT8 data = vid[ offset ];
291315      UINT16 data2 = ( vid[ offset + 1 ] ) << 1;
r2551r2552
303327}
304328
305329
306static MC6845_UPDATE_ROW( t1000_gfx_1bpp_update_row ) {
330static MC6845_UPDATE_ROW( t1000_gfx_1bpp_update_row )
331{
307332   UINT16  *p = BITMAP_ADDR16(bitmap, y, 0);
308333   UINT8   *vid = pcjr.displayram + ( ra << 13 );
309334   UINT8   fg = pcjr.reg.data[0x11];
r2551r2552
311336   int i;
312337
313338   if ( y == 0 ) logerror("t1000_gfx_1bpp_update_row\n");
314   for ( i = 0; i < x_count; i++ ) {
339   for ( i = 0; i < x_count; i++ )
340   {
315341      UINT16 offset = ( ( ma + i ) << 1 ) & 0x1fff;
316342      UINT8 data = vid[ offset ];
317343
r2551r2552
337363   }
338364}
339365
340static MC6845_UPDATE_ROW( t1000_update_row ) {
341   if ( pcjr.update_row ) {
366static MC6845_UPDATE_ROW( t1000_update_row )
367{
368   if ( pcjr.update_row )
369   {
342370      pcjr.update_row( device, bitmap, cliprect, ma, ra, y, x_count, cursor_x, param );
343371   }
344372}
r2551r2552
352380}
353381
354382
355static void pc_t1t_mode_switch( void ) {
356   switch( pcjr.mode_control & 0x3B ) {
383static void pc_t1t_mode_switch( void )
384{
385   switch( pcjr.mode_control & 0x3B )
386   {
357387   case 0x08: case 0x09:
358388      pcjr.update_row = t1000_text_inten_update_row;
359389      break;
r2551r2552
361391      pcjr.update_row = t1000_text_blink_update_row;
362392      break;
363393   case 0x0A: case 0x0B: case 0x2A: case 0x2B:
364      switch( pcjr.bank & 0xc0 ) {
394      switch( pcjr.bank & 0xc0 )
395      {
365396      case 0x00:
366397      case 0x40:
367398         //logerror("t1t_gfx_2bpp - 1\n");
368399         pcjr.update_row = t1000_gfx_2bpp_update_row;
369         if ( pcjr.color_select ) {
400         if ( pcjr.color_select )
401         {
370402            pcjr.reg.data[0x10] = 0x00;
371403            pcjr.reg.data[0x11] = 0x0B;
372404            pcjr.reg.data[0x12] = 0x0D;
373405            pcjr.reg.data[0x13] = 0x0F;
374         } else {
406         }
407         else
408         {
375409            pcjr.reg.data[0x10] = 0x00;
376410            pcjr.reg.data[0x11] = 0x0A;
377411            pcjr.reg.data[0x12] = 0x0C;
r2551r2552
387421      break;
388422   case 0x18: case 0x19: case 0x1A: case 0x1B:
389423   case 0x38: case 0x39: case 0x3A: case 0x3B:
390      switch( pcjr.bank & 0xc0 ) {
424      switch( pcjr.bank & 0xc0 )
425      {
391426      case 0x00:
392427      case 0x40:
393428         //logerror("t1t_gfx_1bpp\n");
r2551r2552
407442}
408443
409444
445/* mode control 1 ( pcjr.reg.data[0] ) */
446/* bit0 - 0 = low bandwidth, 1 = high bandwidth */
447/* bit1 - 0 = alpha, 1 = graphics */
448/* bit2 - 0 = color, 1 = b/w */
449/* bit3 - 0 = video disable, 1 = video enable */
450/* bit4 - 1 = 16 color graphics */
451/* mode control 2 ( pcjr.reg.data[3] ) */
452/* bit1 - 1 = enable blink */
453/* bit3 - 1 = 2 color graphics */
454
455static void pc_pcjr_mode_switch( void )
456{
457   switch( pcjr.reg.data[0] & 0x1F )
458   {
459   case 0x08: case 0x09:
460   case 0x0C: case 0x0D:   /* B/W modes */
461      if ( pcjr.reg.data[3] & 0x02 )
462      {
463         pcjr.update_row = t1000_text_blink_update_row;
464      }
465      else
466      {
467         pcjr.update_row = t1000_text_inten_update_row;
468      }
469      break;
470   case 0x1A: case 0x1B:
471      pcjr.update_row = t1000_gfx_4bpp_update_row;
472      break;
473   case 0x0A: case 0x0B:
474      pcjr.update_row = t1000_gfx_2bpp_update_row;
475      break;
476   case 0x0E:
477      if ( pcjr.reg.data[3] & 0x08 )
478      {
479         pcjr.update_row = t1000_gfx_1bpp_update_row;
480      }
481      else
482      {
483         pcjr.update_row = t1000_gfx_2bpp_update_row;   /* B/W mode */
484      }
485      break;
486   default:
487      pcjr.update_row = NULL;
488      break;
489   }
490}
491
492
410493/*
411494 * 3d8 rW   T1T mode control register (see #P138)
412495 */
r2551r2552
508591    }
509592}
510593
594
595static void pc_pcjr_vga_data_w(int data)
596{
597   pcjr.reg.data[pcjr.reg.index] = data;
598
599   switch (pcjr.reg.index)
600   {
601      case 0x00:   /* mode control 1 */
602               /* bit0 - 0 = low bandwidth, 1 = high bandwidth */
603               /* bit1 - 0 = alpha, 1 = graphics */
604               /* bit2 - 0 = color, 1 = b/w */
605               /* bit3 - 0 = video disable, 1 = video enable */
606               /* bit4 - 1 = 16 color graphics */
607         pc_pcjr_mode_switch();
608         break;
609      case 0x01:   /* palette mask (bits 3-0) */
610         break;
611      case 0x02:   /* border color (bits 3-0) */
612         break;
613      case 0x03:   /* mode control 2 */
614               /* bit1 - 1 = enable blink */
615               /* bit3 - 1 = 2 color graphics */
616         pc_pcjr_mode_switch();
617         break;
618      case 0x04:   /* reset register */
619         break;
620               /* palette array */
621      case 0x10: case 0x11: case 0x12: case 0x13:
622      case 0x14: case 0x15: case 0x16: case 0x17:
623      case 0x18: case 0x19: case 0x1a: case 0x1b:
624      case 0x1c: case 0x1d: case 0x1e: case 0x1f:
625         pcjr.reg.data[pcjr.reg.index] = data & 0x0F;
626         break;
627   }
628}
629
630
511631static int pc_t1t_vga_data_r(void)
512632{
513633   int data = pcjr.reg.data[pcjr.reg.index];
r2551r2552
553673      pcjr.bank = data;
554674   /* it seems the video ram is mapped to the last 128K of main memory */
555675#if 1
556      if ((data&0xc0)==0xc0) { /* needed for lemmings */
676      if ((data&0xc0)==0xc0) /* needed for lemmings */
677      {
557678         dram = 0x80000 + ((data & 0x06) << 14);
558679         vram = 0x80000 + ((data & 0x30) << (14-3));
559      } else {
680      }
681      else
682      {
560683         dram = 0x80000 + ((data & 0x07) << 14);
561684         vram = 0x80000 + ((data & 0x38) << (14-3));
562685      }
r2551r2552
621744    }
622745}
623746
747
748WRITE8_HANDLER( pc_pcjr_w )
749{
750   device_config   *devconf;
751
752   switch( offset )
753   {
754      case 0: case 4:
755         devconf = (device_config *) device_list_find_by_tag(machine->config->devicelist, MC6845, T1000_MC6845_NAME);
756         mc6845_address_w( devconf, offset, data );
757         break;
758      case 1: case 5:
759         devconf = (device_config *) device_list_find_by_tag(machine->config->devicelist, MC6845, T1000_MC6845_NAME);
760         mc6845_register_w( devconf, offset, data );
761         break;
762      case 10:
763         if ( pcjr.address_data_ff & 0x01 )
764         {
765            pc_pcjr_vga_data_w( data );
766         }
767         else
768         {
769            pc_t1t_vga_index_w( data );
770         }
771         pcjr.address_data_ff ^= 0x01;
772         break;
773      case 11:
774         pc_t1t_lightpen_strobe_w(data);
775         break;
776      case 12:
777         break;
778      case 15:
779         pc_t1t_bank_w(data);
780         break;
781
782      default:
783         break;
784   }
785}
786
787
624788 READ8_HANDLER ( pc_T1T_r )
625789{
626790   device_config   *devconf;
r2551r2552
646810         break;
647811
648812      case 10:
813         pcjr.address_data_ff = 0;
649814         data = pc_t1t_status_r();
650815         break;
651816
r2551r2552
669834}
670835
671836
672static MC6845_ON_HSYNC_CHANGED( t1000_hsync_changed ) {
837static MC6845_ON_HSYNC_CHANGED( t1000_hsync_changed )
838{
673839   pcjr.hsync = hsync ? 0 : 1;
674840}
675841
676842
677static MC6845_ON_VSYNC_CHANGED( t1000_vsync_changed ) {
843static MC6845_ON_VSYNC_CHANGED( t1000_vsync_changed )
844{
678845   pcjr.vsync = vsync ? 8 : 0;
679   if ( vsync ) {
846   if ( vsync )
847   {
680848      pcjr.pc_framecnt++;
681849   }
682850}
683851
684static MC6845_ON_VSYNC_CHANGED( pcjr_vsync_changed ) {
852static MC6845_ON_VSYNC_CHANGED( pcjr_vsync_changed )
853{
685854   pcjr.vsync = vsync ? 8 : 0;
686   if ( vsync ) {
855   if ( vsync )
856   {
687857      pcjr.pc_framecnt++;
688858   }
689859   pic8259_set_irq_line(device_list_find_by_tag( device->machine->config->devicelist, PIC8259, "pic8259_master" ), 5, vsync);
src/mess/video/pc_t1t.h
r2551r2552
1010 READ8_HANDLER ( pc_t1t_videoram_r );
1111WRITE8_HANDLER ( pc_T1T_w );
1212 READ8_HANDLER (   pc_T1T_r );
13WRITE8_HANDLER( pc_pcjr_w );
1314
1415#endif /* PC_T1T_H */
src/mess/drivers/pc.c
r2551r2552
320320   AM_RANGE(0x0324, 0x0327) AM_READWRITE(pc_HDC2_r,            pc_HDC2_w)
321321   AM_RANGE(0x0378, 0x037f) AM_READWRITE(pc_t1t_p37x_r,         pc_t1t_p37x_w)
322322   AM_RANGE(0x03bc, 0x03be) AM_READWRITE(pc_parallelport0_r,      pc_parallelport0_w)
323   AM_RANGE(0x03d0, 0x03df) AM_READWRITE(pc_T1T_r,               pc_T1T_w)
323   AM_RANGE(0x03d0, 0x03df) AM_READWRITE(pc_T1T_r,               pc_pcjr_w)
324324   AM_RANGE(0x03f8, 0x03ff) AM_DEVREADWRITE(INS8250, "ins8250_0", ins8250_r, ins8250_w)
325325ADDRESS_MAP_END
326326

Previous 15994 Revisions Next


© 1998-2018 The MESS Team