Previous 15994 Revisions Next

r8981 Tuesday 31st August, 2010 at 18:35:36 UTC by Wilbert Pol
[CPC family] Updated gate array and asic implementation to make use of the improved 6845 timing.
[src/mess/drivers]amstrad.c
[src/mess/machine]amstrad.c

src/mess/machine/amstrad.c
r8980r8981
8686   int      vsync;
8787   int      hsync;
8888   int      de;
89   int      ma;
90   int      ra;
8991
9092   /* used for timing */
9193   int      hsync_after_vsync_counter;
9294   int      hsync_counter;            /* The gate array counts CRTC HSYNC pulses using an internal 6-bit counter. */
9395
9496   /* used for drawing the screen */
97   attotime   last_draw_time;
9598   int      y;
99   UINT16   *draw_p;               /* Position in the bitmap where we are currently drawing */
100   UINT16   colour;
101   UINT16   address;
102   UINT8   *mode_lookup;
103   UINT8   data;
104   UINT8   ticks;
105   UINT8   ticks_increment;
106   UINT16   line_ticks;
107   UINT8   colour_ticks;
108   UINT8   max_colour_ticks;
96109} gate_array;
97110
98111
r8980r8981
100113 * ASIC data (CPC plus)
101114 ****************************/
102115static struct {
116   UINT8   *ram;            /* pointer to RAM used for the CPC+ ASIC memory-mapped registers */
103117   UINT8   enabled;         /* Are CPC plus features enabled/unlocked */
104118   UINT8   pri;            /* Programmable raster interrupt */
105119   UINT8   seqptr;            /* Current position in the ASIC unlocking sequence */
106120   UINT8   rmr2;            /* ROM mapping register 2 */
107121   UINT16   split_ma_base;      /* Used to handle split screen support */
108122   UINT16   split_ma_started;   /* Used to handle split screen support */
123   UINT16   vpos;            /* Current logical scanline */
124   UINT16   h_start;         /* Position where DE became active */
125   UINT16   h_end;            /* Position where DE became inactive */
126   UINT8   addr_6845;         /* We need these to store a shadow copy of R1 of the mc6845 */
127   UINT8   horiz_disp;
128   UINT8   hscroll;
109129
110130   /* DMA */
111131   UINT8   dma_status;
r8980r8981
126146static unsigned char *Aleste_RamBanks[4];
127147static int aleste_active_page[4];  // page mapped to CPU RAM (is readable?)
128148
129/* pointer to RAM used for the CPC+ ASIC memory-mapped registers */
130static UINT8 *amstrad_plus_asic_ram;
131
132149/* the hardware allows selection of 256 ROMs. Rom 0 is usually BASIC and Rom 7 is AMSDOS */
133150/* With the CPC hardware, if a expansion ROM is not connected, BASIC rom will be selected instead */
134151static unsigned char *Amstrad_ROM_Table[256];
r8980r8981
171188/* colours can be changed at any time and will take effect immediatly */
172189static UINT16 amstrad_GateArray_render_colours[17];
173190
174static mc6845_update_row_func draw_function;
191static UINT8 mode0_lookup[256];
192static UINT8 mode1_lookup[256];
193static UINT8 mode2_lookup[256];
175194
176static UINT8 mode0_lookup[256][2];
177static UINT8 mode1_lookup[256][4];
178195
179
180196/* The Amstrad CPC has a fixed palette of 27 colours generated from 3 levels of Red, Green and Blue.
181197The hardware allows selection of 32 colours, but these extra colours are copies of existing colours.*/
182198
r8980r8981
259275  Prototypes
260276*******************************************************************/
261277
262static MC6845_UPDATE_ROW( amstrad_update_row_mode0 );
263static MC6845_UPDATE_ROW( amstrad_update_row_mode1 );
264static MC6845_UPDATE_ROW( amstrad_update_row_mode2 );
265static MC6845_UPDATE_ROW( amstrad_update_row_mode3 );
266static MC6845_UPDATE_ROW( aleste_update_row_mode2 );
267static MC6845_UPDATE_ROW( aleste_update_row_mode3 );
268static MC6845_UPDATE_ROW( amstrad_plus_update_row_mode0 );
269static MC6845_UPDATE_ROW( amstrad_plus_update_row_mode1 );
270static MC6845_UPDATE_ROW( amstrad_plus_update_row_mode2 );
271static MC6845_UPDATE_ROW( amstrad_plus_update_row_mode3 );
272static MC6845_UPDATE_ROW( amstrad_plus_update_row_sprites );
278INLINE void amstrad_update_video( running_machine *machine );
279INLINE void amstrad_plus_update_video( running_machine *machine );
273280static void amstrad_rethinkMemory(running_machine *machine);
274281
275282
r8980r8981
434441
435442   for ( i = 0; i < 256; i++ )
436443   {
437      mode0_lookup[i][0] = ( ( i & 0x80 ) >> 7 ) | ( ( i & 0x20 ) >> 3 ) | ( ( i & 0x08 ) >> 2 ) | ( ( i & 0x02 ) << 2 );
438      mode0_lookup[i][1] = ( ( i & 0x40 ) >> 6 ) | ( ( i & 0x10 ) >> 2 ) | ( ( i & 0x04 ) >> 1 ) | ( ( i & 0x01 ) << 3 );
439
440      mode1_lookup[i][0] = ( ( i & 0x80 ) >> 7 ) | ( ( i & 0x08 ) >> 2 );
441      mode1_lookup[i][1] = ( ( i & 0x40 ) >> 6 ) | ( ( i & 0x04 ) >> 1 );
442      mode1_lookup[i][2] = ( ( i & 0x20 ) >> 5 ) | ( ( i & 0x02 )      );
443      mode1_lookup[i][3] = ( ( i & 0x10 ) >> 4 ) | ( ( i & 0x01 ) << 1 );
444      mode0_lookup[i] = ( ( i & 0x80 ) >> 7 ) | ( ( i & 0x20 ) >> 3 ) | ( ( i & 0x08 ) >> 2 ) | ( ( i & 0x02 ) << 2 );
445      mode1_lookup[i] = ( ( i & 0x80 ) >> 7 ) | ( ( i & 0x08 ) >> 2 );
446      mode2_lookup[i] = ( ( i & 0x80 ) >> 7 );
444447   }
445448}
446449
r8980r8981
454457      switch ( gate_array.mrer & 0x03 )
455458      {
456459      case 0:      /* Mode 0: 160x200, 16 colours */
457         draw_function = amstrad_plus_update_row_mode0;
460         gate_array.mode_lookup = mode0_lookup;
461         gate_array.max_colour_ticks = 4;
462         gate_array.ticks_increment = 1;
458463         break;
459464
460465      case 1:      /* Mode 1: 320x200, 4 colous */
461         draw_function = amstrad_plus_update_row_mode1;
466         gate_array.mode_lookup = mode1_lookup;
467         gate_array.max_colour_ticks = 2;
468         gate_array.ticks_increment = 1;
462469         break;
463470
464471      case 2:      /* Mode 2: 640x200, 2 colours */
465         draw_function = amstrad_plus_update_row_mode2;
472         gate_array.mode_lookup = mode2_lookup;
473         gate_array.max_colour_ticks = 1;
474         gate_array.ticks_increment = 1;
466475         break;
467476
468477      case 3:      /* Mode 3: 160x200, 4 colours */
469         draw_function = amstrad_plus_update_row_mode3;
478         gate_array.mode_lookup = mode0_lookup;
479         gate_array.max_colour_ticks = 4;
480         gate_array.ticks_increment = 1;
470481         break;
471482      }
472483   }
r8980r8981
478489         switch ( gate_array.mrer & 0x03 )
479490         {
480491         case 0:      /* Aleste Mode 0 (= Amstrad CPC mode 2): 640x200, 2 colours */
481            draw_function = amstrad_update_row_mode2;
492            gate_array.mode_lookup = mode2_lookup;
493            gate_array.max_colour_ticks = 1;
494            gate_array.ticks_increment = 1;
482495            break;
483496
484         case 1:      /* Aleste mode 1: 320x200, 4 colours */
485            draw_function = amstrad_update_row_mode1;
497         case 1:      /* Aleste mode 1 (= Amstrad CPC mode 1): 320x200, 4 colours */
498            gate_array.mode_lookup = mode1_lookup;
499            gate_array.max_colour_ticks = 2;
500            gate_array.ticks_increment = 1;
486501            break;
487502
488503         case 2:      /* Aleste mode 2: 4 colours */
489            draw_function = aleste_update_row_mode2;
504            gate_array.mode_lookup = mode1_lookup;
505            gate_array.max_colour_ticks = 1;
506            gate_array.ticks_increment = 2;
490507            break;
491508
492509         case 3:      /* Aleste mode 3: 16 colours */
493            draw_function = aleste_update_row_mode3;
510            gate_array.mode_lookup = mode0_lookup;
511            gate_array.max_colour_ticks = 2;
512            gate_array.ticks_increment = 2;
494513            break;
495514         }
496515      }
r8980r8981
500519         switch ( gate_array.mrer & 0x03 )
501520         {
502521         case 0:      /* Mode 0: 160x200, 16 colours */
503            draw_function = amstrad_update_row_mode0;
522            gate_array.mode_lookup = mode0_lookup;
523            gate_array.max_colour_ticks = 4;
524            gate_array.ticks_increment = 1;
504525            break;
505526
506527         case 1:      /* Mode 1: 320x200, 4 colous */
507            draw_function = amstrad_update_row_mode1;
528            gate_array.mode_lookup = mode1_lookup;
529            gate_array.max_colour_ticks = 2;
530            gate_array.ticks_increment = 1;
508531            break;
509532
510533         case 2:      /* Mode 2: 640x200, 2 colours */
511            draw_function = amstrad_update_row_mode2;
534            gate_array.mode_lookup = mode2_lookup;
535            gate_array.max_colour_ticks = 1;
536            gate_array.ticks_increment = 1;
512537            break;
513538
514539         case 3:      /* Mode 3: 160x200, 4 colours */
515            draw_function = amstrad_update_row_mode3;
540            gate_array.mode_lookup = mode0_lookup;
541            gate_array.max_colour_ticks = 4;
542            gate_array.ticks_increment = 1;
516543            break;
517544         }
518545      }
r8980r8981
546573      if ( asic.dma_prescaler[channel] == 0 )
547574      {
548575         asic.dma_pause[channel]--;
549         asic.dma_prescaler[channel] = amstrad_plus_asic_ram[0x2c02 + (4*channel)] + 1;
576         asic.dma_prescaler[channel] = asic.ram[0x2c02 + (4*channel)] + 1;
550577      }
551578      return;
552579   }
r8980r8981
587614      if (command & 0x10) // Cause interrupt
588615      {
589616         amstrad_plus_irq_cause = channel * 2;
590         amstrad_plus_asic_ram[0x2c0f] |= (0x40 >> channel);
617         asic.ram[0x2c0f] |= (0x40 >> channel);
591618         cputag_set_input_line(machine, "maincpu", 0, ASSERT_LINE);
592619         logerror("DMA %i: INT\n",channel);
593620      }
r8980r8981
618645
619646
620647/* Set the new colour from the GateArray */
621static void amstrad_vh_update_colour(int PenIndex, UINT16 hw_colour_index)
648static void amstrad_vh_update_colour(running_machine *machine, int PenIndex, UINT16 hw_colour_index)
622649{
623   int val;
624
625   amstrad_GateArray_render_colours[PenIndex] = hw_colour_index;
626
627650   if ( amstrad_system_type == SYSTEM_PLUS || amstrad_system_type == SYSTEM_GX4000 )
628651   {
652      int val;
653
654      amstrad_plus_update_video( machine );
655
629656      /* CPC+/GX4000 - normal palette changes through the Gate Array also makes the corresponding change in the ASIC palette */
630657      val = (amstrad_palette[hw_colour_index] & 0xf00000) >> 16; /* red */
631658      val |= (amstrad_palette[hw_colour_index] & 0x0000f0) >> 4; /* blue */
632      amstrad_plus_asic_ram[0x2400+PenIndex*2] = val;
659      asic.ram[0x2400+PenIndex*2] = val;
633660      val = (amstrad_palette[hw_colour_index] & 0x00f000) >> 12; /* green */
634      amstrad_plus_asic_ram[0x2401+PenIndex*2] = val;
661      asic.ram[0x2401+PenIndex*2] = val;
635662   }
636}
637
638
639static void aleste_vh_update_colour(int PenIndex, UINT16 hw_colour_index)
640{
641   amstrad_GateArray_render_colours[PenIndex] = hw_colour_index+32;
642}
643
644
645/* Mode 0: 160x200, 16 colours */
646static MC6845_UPDATE_ROW( amstrad_update_row_mode0 )
647{
648   UINT16   *p = BITMAP_ADDR16( bitmap, y, 0 );
649   int i;
650
651   for ( i = 0; i < x_count; i++ )
663   else
652664   {
653      UINT16   address = ( ( ( ma + i ) & 0x3000 ) << 2 ) | ( ( ra & 0x07 ) << 11 ) | ( ( ( ma + i ) & 0x3ff ) << 1 );
654      UINT8   data0 = messram_get_ptr(device->machine->device("messram"))[ address ];
655      UINT8   data1 = messram_get_ptr(device->machine->device("messram"))[ address + 1 ];
656      UINT16   c;
657
658      c = amstrad_GateArray_render_colours[ mode0_lookup[data0][0] ];
659      *p = c; p++; *p = c; p++; *p = c; p++; *p = c; p++;
660      c = amstrad_GateArray_render_colours[ mode0_lookup[data0][1] ];
661      *p = c; p++; *p = c; p++; *p = c; p++; *p = c; p++;
662      c = amstrad_GateArray_render_colours[ mode0_lookup[data1][0] ];
663      *p = c; p++; *p = c; p++; *p = c; p++; *p = c; p++;
664      c = amstrad_GateArray_render_colours[ mode0_lookup[data1][1] ];
665      *p = c; p++; *p = c; p++; *p = c; p++; *p = c; p++;
665      amstrad_update_video( machine );
666666   }
667   amstrad_GateArray_render_colours[PenIndex] = hw_colour_index;
667668}
668669
669670
670/* Mode 1: 320x200, 4 colous */
671static MC6845_UPDATE_ROW( amstrad_update_row_mode1 )
671static void aleste_vh_update_colour(running_machine *machine, int PenIndex, UINT16 hw_colour_index)
672672{
673   UINT16   *p = BITMAP_ADDR16( bitmap, y, 0 );
674   int i;
675
676   for ( i = 0; i < x_count; i++ )
677   {
678      UINT16   address = ( ( ( ma + i ) & 0x3000 ) << 2 ) | ( ( ra & 0x07 ) << 11 ) | ( ( ( ma + i ) & 0x3ff ) << 1 );
679      UINT8   data0 = messram_get_ptr(device->machine->device("messram"))[ address ];
680      UINT8   data1 = messram_get_ptr(device->machine->device("messram"))[ address + 1 ];
681      UINT16   c;
682
683      c = amstrad_GateArray_render_colours[ mode1_lookup[data0][0] ];
684      *p = c; p++; *p = c; p++;
685      c = amstrad_GateArray_render_colours[ mode1_lookup[data0][1] ];
686      *p = c; p++; *p = c; p++;
687      c = amstrad_GateArray_render_colours[ mode1_lookup[data0][2] ];
688      *p = c; p++; *p = c; p++;
689      c = amstrad_GateArray_render_colours[ mode1_lookup[data0][3] ];
690      *p = c; p++; *p = c; p++;
691      c = amstrad_GateArray_render_colours[ mode1_lookup[data1][0] ];
692      *p = c; p++; *p = c; p++;
693      c = amstrad_GateArray_render_colours[ mode1_lookup[data1][1] ];
694      *p = c; p++; *p = c; p++;
695      c = amstrad_GateArray_render_colours[ mode1_lookup[data1][2] ];
696      *p = c; p++; *p = c; p++;
697      c = amstrad_GateArray_render_colours[ mode1_lookup[data1][3] ];
698      *p = c; p++; *p = c; p++;
699   }
673   amstrad_update_video( machine );
674   amstrad_GateArray_render_colours[PenIndex] = hw_colour_index+32;
700675}
701676
702677
703/* Mode 2: 640x200, 2 colours */
704static MC6845_UPDATE_ROW( amstrad_update_row_mode2 )
678INLINE void amstrad_gate_array_get_video_data( running_machine *machine )
705679{
706   UINT16   *p = BITMAP_ADDR16( bitmap, y, 0 );
707   int i;
708
709   for ( i = 0; i < x_count; i++ )
710   {
711      UINT16   address = ( ( ( ma + i ) & 0x3000 ) << 2 ) | ( ( ra & 0x07 ) << 11 ) | ( ( ( ma + i ) & 0x3ff ) << 1 );
712      UINT8   data0 = messram_get_ptr(device->machine->device("messram"))[ address ];
713      UINT8   data1 = messram_get_ptr(device->machine->device("messram"))[ address + 1 ];
714
715      *p = amstrad_GateArray_render_colours[ ( data0 & 0x80 ) >> 7 ]; p++;
716      *p = amstrad_GateArray_render_colours[ ( data0 & 0x40 ) >> 6 ]; p++;
717      *p = amstrad_GateArray_render_colours[ ( data0 & 0x20 ) >> 5 ]; p++;
718      *p = amstrad_GateArray_render_colours[ ( data0 & 0x10 ) >> 4 ]; p++;
719      *p = amstrad_GateArray_render_colours[ ( data0 & 0x08 ) >> 3 ]; p++;
720      *p = amstrad_GateArray_render_colours[ ( data0 & 0x04 ) >> 2 ]; p++;
721      *p = amstrad_GateArray_render_colours[ ( data0 & 0x02 ) >> 1 ]; p++;
722      *p = amstrad_GateArray_render_colours[ ( data0 & 0x01 ) ]; p++;
723      *p = amstrad_GateArray_render_colours[ ( data1 & 0x80 ) >> 7 ]; p++;
724      *p = amstrad_GateArray_render_colours[ ( data1 & 0x40 ) >> 6 ]; p++;
725      *p = amstrad_GateArray_render_colours[ ( data1 & 0x20 ) >> 5 ]; p++;
726      *p = amstrad_GateArray_render_colours[ ( data1 & 0x10 ) >> 4 ]; p++;
727      *p = amstrad_GateArray_render_colours[ ( data1 & 0x08 ) >> 3 ]; p++;
728      *p = amstrad_GateArray_render_colours[ ( data1 & 0x04 ) >> 2 ]; p++;
729      *p = amstrad_GateArray_render_colours[ ( data1 & 0x02 ) >> 1 ]; p++;
730      *p = amstrad_GateArray_render_colours[ ( data1 & 0x01 ) ]; p++;
731   }
680   if ( aleste_mode & 0x02 )
681      gate_array.address = ( ( gate_array.ma & 0x2000 ) << 2 ) | ( ( gate_array.ra & 0x06 ) << 11 ) | ( ( gate_array.ra & 0x01 ) << 14 ) | ( ( gate_array.ma & 0x7ff ) << 1 );
682   else
683      gate_array.address = ( ( gate_array.ma & 0x3000 ) << 2 ) | ( ( gate_array.ra & 0x07 ) << 11 ) | ( ( gate_array.ma & 0x3ff ) << 1 );
684   gate_array.data = messram_get_ptr(machine->device("messram"))[ gate_array.address ];
685   gate_array.colour = amstrad_GateArray_render_colours[ gate_array.mode_lookup[gate_array.data] ];
686   gate_array.colour_ticks = gate_array.max_colour_ticks;
687   gate_array.ticks = 0;
732688}
733689
734690
735/* Mode 3: 160x200, 4 colours */
736static MC6845_UPDATE_ROW( amstrad_update_row_mode3 )
691INLINE void amstrad_update_video( running_machine *machine )
737692{
738   UINT16   *p = BITMAP_ADDR16( bitmap, y, 0 );
739   int i;
693   attotime now = timer_get_time(machine);
740694
741   for ( i = 0; i < x_count; i++ )
695   if ( gate_array.draw_p )
742696   {
743      UINT16   address = ( ( ( ma + i ) & 0x3000 ) << 2 ) | ( ( ra & 0x07 ) << 11 ) | ( ( ( ma + i ) & 0x3ff ) << 1 );
744      UINT8   data0 = messram_get_ptr(device->machine->device("messram"))[ address ];
745      UINT8   data1 = messram_get_ptr(device->machine->device("messram"))[ address + 1 ];
746      UINT16   c;
697      UINT32 cycles_passed = attotime_to_ticks( attotime_sub( now, gate_array.last_draw_time ), XTAL_16MHz );
747698
748      c = amstrad_GateArray_render_colours[ mode1_lookup[data0][0] ];
749      *p = c; p++; *p = c; p++; *p = c; p++; *p = c; p++;
750      c = amstrad_GateArray_render_colours[ mode1_lookup[data0][1] ];
751      *p = c; p++; *p = c; p++; *p = c; p++; *p = c; p++;
752      c = amstrad_GateArray_render_colours[ mode1_lookup[data1][0] ];
753      *p = c; p++; *p = c; p++; *p = c; p++; *p = c; p++;
754      c = amstrad_GateArray_render_colours[ mode1_lookup[data1][1] ];
755      *p = c; p++; *p = c; p++; *p = c; p++; *p = c; p++;
756
757   }
758}
759
760
761/* Plus Mode 0: 160x200, 16 colours */
762static MC6845_UPDATE_ROW( amstrad_plus_update_row_mode0 )
763{
764   UINT16   *p = BITMAP_ADDR16( bitmap, y, 0 );
765   UINT16   c;
766   int i;
767
768   logerror( "amstrad_plus_update_row_mode0: ma = 0x%04x, ra = %d, y = %d, x_count = %d, cursor_x = %d\n", ma, ra, y, x_count, cursor_x );
769
770   /* Apply horizontal background scrolling */
771   for ( i = amstrad_plus_asic_ram[0x2804] & 0x0f; i > 0; i-- )
772   {
773      if ( amstrad_plus_asic_ram[0x2804] & 0x80 )
699      while( cycles_passed )
774700      {
775         /* Border colour */
776         c = amstrad_plus_asic_ram[0x2420] + ( amstrad_plus_asic_ram[0x2421] << 8 );
701         if ( ! gate_array.de || ( ( aleste_mode & 0x02 ) && ! ( aleste_mode & 0x08 ) ) )
702         {
703            *gate_array.draw_p = amstrad_GateArray_render_colours[ 16 ];
704         }
705         else
706         {
707            *gate_array.draw_p = gate_array.colour;
708            gate_array.colour_ticks--;
709            if ( ! gate_array.colour_ticks )
710            {
711               gate_array.data <<= 1;
712               gate_array.colour = amstrad_GateArray_render_colours[ gate_array.mode_lookup[gate_array.data] ];
713               gate_array.colour_ticks = gate_array.max_colour_ticks;
714            }
715            gate_array.ticks += gate_array.ticks_increment;
716            switch( gate_array.ticks)
717            {
718            case 8:
719               gate_array.data = messram_get_ptr(machine->device("messram"))[ gate_array.address + 1 ];
720               gate_array.colour = amstrad_GateArray_render_colours[ gate_array.mode_lookup[gate_array.data] ];
721               break;
722            case 16:
723               gate_array.ma += 1;                  /* If we were synced with the 6845 mc6845_get_ma should return this value */
724               amstrad_gate_array_get_video_data( machine );
725               break;
726            }
727         }
728         gate_array.draw_p++;
729         cycles_passed--;
730         gate_array.line_ticks++;
731         if ( gate_array.line_ticks > gate_array.bitmap->width )
732         {
733            gate_array.draw_p = NULL;
734            cycles_passed = 0;
735         }
777736      }
778      else
779      {
780         /* Random(?) colour data */
781         c = amstrad_plus_asic_ram[0x2420] + ( amstrad_plus_asic_ram[0x2421] << 8 );
782      }
783      *p = c; p++;
784737   }
785738
786   /* Apply vertical background scrolling */
787   ra += ( ( amstrad_plus_asic_ram[0x2804] >> 4 ) & 0x07 );
788   if ( ra > 7 )
789   {
790      ma += x_count;
791   }
792
793   for ( i = 0; i < x_count; i++ )
794   {
795      UINT16   address = ( ( ( ma + i ) & 0x3000 ) << 2 ) | ( ( ra & 0x07 ) << 11 ) | ( ( ( ma + i ) & 0x3ff ) << 1 );
796      UINT16   caddr;
797      UINT8   data0 = messram_get_ptr(device->machine->device("messram"))[ address ];
798      UINT8   data1 = messram_get_ptr(device->machine->device("messram"))[ address + 1 ];
799
800      caddr = 0x2400 + mode0_lookup[data0][0] * 2;
801      c = amstrad_plus_asic_ram[caddr] + ( amstrad_plus_asic_ram[caddr+1] << 8 );
802      *p = c; p++; *p = c; p++; *p = c; p++; *p = c; p++;
803      caddr = 0x2400 + mode0_lookup[data0][1] * 2;
804      c = amstrad_plus_asic_ram[caddr] + ( amstrad_plus_asic_ram[caddr+1] << 8 );
805      *p = c; p++; *p = c; p++; *p = c; p++; *p = c; p++;
806      caddr = 0x2400 + mode0_lookup[data1][0] * 2;
807      c = amstrad_plus_asic_ram[caddr] + ( amstrad_plus_asic_ram[caddr+1] << 8 );
808      *p = c; p++; *p = c; p++; *p = c; p++; *p = c; p++;
809      caddr = 0x2400 + mode0_lookup[data1][1] * 2;
810      c = amstrad_plus_asic_ram[caddr] + ( amstrad_plus_asic_ram[caddr+1] << 8 );
811      *p = c; p++; *p = c; p++; *p = c; p++; *p = c; p++;
812   }
739   gate_array.last_draw_time = now;
813740}
814741
815742
816/* Plus Mode 1: 320x200, 4 colours */
817static MC6845_UPDATE_ROW( amstrad_plus_update_row_mode1 )
743INLINE void amstrad_plus_gate_array_get_video_data( running_machine *machine )
818744{
819   UINT16   *p = BITMAP_ADDR16( bitmap, y, 0 );
820   UINT16   c;
821   int i;
745   UINT16 caddr;
746   UINT16 ma = ( gate_array.ma - asic.split_ma_started ) + asic.split_ma_base;
747   UINT16 ra = gate_array.ra + ( ( asic.ram[0x2804] >> 4 ) & 0x07 );
822748
823   logerror( "amstrad_plus_update_row_mode1: ma = 0x%04x, ra = %d, y = %d, x_count = %d, cursor_x = %d\n", ma, ra, y, x_count, cursor_x );
824
825   /* Apply horizontal background scrolling */
826   for ( i = amstrad_plus_asic_ram[0x2804] & 0x0f; i > 0; i-- )
827   {
828      if ( amstrad_plus_asic_ram[0x2804] & 0x80 )
829      {
830         /* Border colour */
831         c = amstrad_plus_asic_ram[0x2420] + ( amstrad_plus_asic_ram[0x2421] << 8 );
832      }
833      else
834      {
835         /* Random(?) colour data */
836         c = amstrad_plus_asic_ram[0x2420] + ( amstrad_plus_asic_ram[0x2421] << 8 );
837      }
838      *p = c; p++;
839   }
840
841   /* Apply vertical background scrolling */
842   ra += ( ( amstrad_plus_asic_ram[0x2804] >> 4 ) & 0x07 );
843749   if ( ra > 7 )
844750   {
845      ma += x_count;
751      ma += asic.horiz_disp;
846752   }
847
848   for ( i = 0; i < x_count; i++ )
849   {
850      UINT16   address = ( ( ( ma + i ) & 0x3000 ) << 2 ) | ( ( ra & 0x07 ) << 11 ) | ( ( ( ma + i ) & 0x3ff ) << 1 );
851      UINT16   caddr;
852      UINT8   data0 = messram_get_ptr(device->machine->device("messram"))[ address ];
853      UINT8   data1 = messram_get_ptr(device->machine->device("messram"))[ address + 1 ];
854
855      caddr = 0x2400 + mode1_lookup[data0][0] * 2;
856      c = amstrad_plus_asic_ram[caddr] + ( amstrad_plus_asic_ram[caddr+1] << 8 );
857      *p = c; p++; *p = c; p++;
858      caddr = 0x2400 + mode1_lookup[data0][1] * 2;
859      c = amstrad_plus_asic_ram[caddr] + ( amstrad_plus_asic_ram[caddr+1] << 8 );
860      *p = c; p++; *p = c; p++;
861      caddr = 0x2400 + mode1_lookup[data0][2] * 2;
862      c = amstrad_plus_asic_ram[caddr] + ( amstrad_plus_asic_ram[caddr+1] << 8 );
863      *p = c; p++; *p = c; p++;
864      caddr = 0x2400 + mode1_lookup[data0][3] * 2;
865      c = amstrad_plus_asic_ram[caddr] + ( amstrad_plus_asic_ram[caddr+1] << 8 );
866      *p = c; p++; *p = c; p++;
867      caddr = 0x2400 + mode1_lookup[data1][0] * 2;
868      c = amstrad_plus_asic_ram[caddr] + ( amstrad_plus_asic_ram[caddr+1] << 8 );
869      *p = c; p++; *p = c; p++;
870      caddr = 0x2400 + mode1_lookup[data1][1] * 2;
871      c = amstrad_plus_asic_ram[caddr] + ( amstrad_plus_asic_ram[caddr+1] << 8 );
872      *p = c; p++; *p = c; p++;
873      caddr = 0x2400 + mode1_lookup[data1][2] * 2;
874      c = amstrad_plus_asic_ram[caddr] + ( amstrad_plus_asic_ram[caddr+1] << 8 );
875      *p = c; p++; *p = c; p++;
876      caddr = 0x2400 + mode1_lookup[data1][3] * 2;
877      c = amstrad_plus_asic_ram[caddr] + ( amstrad_plus_asic_ram[caddr+1] << 8 );
878      *p = c; p++; *p = c; p++;
879   }
753   gate_array.address = ( ( ma & 0x3000 ) << 2 ) | ( ( gate_array.ra & 0x07 ) << 11 ) | ( ( ma & 0x3ff ) << 1 );
754   gate_array.data = messram_get_ptr(machine->device("messram"))[ gate_array.address ];
755   caddr = 0x2400 + gate_array.mode_lookup[gate_array.data] * 2;
756   gate_array.colour = asic.ram[caddr] + ( asic.ram[caddr+1] << 8 );
757   gate_array.colour_ticks = gate_array.max_colour_ticks;
758   gate_array.ticks = 0;
880759}
881760
882761
883/* Plus Mode 2: 640x200, 2 colours */
884static MC6845_UPDATE_ROW( amstrad_plus_update_row_mode2 )
762INLINE void amstrad_plus_update_video( running_machine *machine )
885763{
886   UINT16   *p = BITMAP_ADDR16( bitmap, y, 0 );
887   UINT16   c;
888   int i;
764   attotime now = timer_get_time(machine);
889765
890   logerror( "amstrad_plus_update_row_mode2: ma = 0x%04x, ra = %d, y = %d, x_count = %d, cursor_x = %d\n", ma, ra, y, x_count, cursor_x );
891
892   /* Apply horizontal background scrolling */
893   for ( i = amstrad_plus_asic_ram[0x2804] & 0x0f; i > 0; i-- )
766   if ( gate_array.draw_p )
894767   {
895      if ( amstrad_plus_asic_ram[0x2804] & 0x80 )
768      UINT32 cycles_passed = attotime_to_ticks( attotime_sub( now, gate_array.last_draw_time ), XTAL_16MHz );
769
770      while( cycles_passed )
896771      {
897         /* Border colour */
898         c = amstrad_plus_asic_ram[0x2420] + ( amstrad_plus_asic_ram[0x2421] << 8 );
899      }
900      else
901      {
902         /* Random(?) colour data */
903         c = amstrad_plus_asic_ram[0x2420] + ( amstrad_plus_asic_ram[0x2421] << 8 );
904      }
905      *p = c; p++;
906   }
772         if ( ! gate_array.de )
773         {
774            *gate_array.draw_p = asic.ram[0x2420] + ( asic.ram[0x2421] << 8 );
775         }
776         else
777         {
778            *gate_array.draw_p = gate_array.colour;
907779
908   /* Apply vertical background scrolling */
909   ra += ( ( amstrad_plus_asic_ram[0x2804] >> 4 ) & 0x07 );
910   if ( ra > 7 )
911   {
912      ma += x_count;
913   }
780            if ( asic.hscroll )
781            {
782               asic.hscroll--;
783               if ( asic.hscroll == 0 )
784                  amstrad_plus_gate_array_get_video_data( machine );
785            }
786            else
787            {
788               gate_array.colour_ticks--;
789               if ( ! gate_array.colour_ticks )
790               {
791                  UINT16 caddr;
914792
915   for ( i = 0; i < x_count; i++ )
916   {
917      UINT16   address = ( ( ( ma + i ) & 0x3000 ) << 2 ) | ( ( ra & 0x07 ) << 11 ) | ( ( ( ma + i ) & 0x3ff ) << 1 );
918      UINT16   caddr;
919      UINT8   data0 = messram_get_ptr(device->machine->device("messram"))[ address ];
920      UINT8   data1 = messram_get_ptr(device->machine->device("messram"))[ address + 1 ];
793                  gate_array.data <<= 1;
794                  caddr = 0x2400 + gate_array.mode_lookup[gate_array.data] * 2;
795                  gate_array.colour = asic.ram[caddr] + ( asic.ram[caddr+1] << 8 );
796                  gate_array.colour_ticks = gate_array.max_colour_ticks;
797               }
798               gate_array.ticks += gate_array.ticks_increment;
799               switch( gate_array.ticks)
800               {
801               case 8:
802                  {
803                     UINT16 caddr;
921804
922      caddr = 0x2400 + ( ( data0 & 0x80 ) ? 2 : 0 );
923      c = amstrad_plus_asic_ram[caddr] + ( amstrad_plus_asic_ram[caddr+1] << 8 );
924      *p = c; p++;
925      caddr = 0x2400 + ( ( data0 & 0x40 ) ? 2 : 0 );
926      c = amstrad_plus_asic_ram[caddr] + ( amstrad_plus_asic_ram[caddr+1] << 8 );
927      *p = c; p++;
928      caddr = 0x2400 + ( ( data0 & 0x20 ) ? 2 : 0 );
929      c = amstrad_plus_asic_ram[caddr] + ( amstrad_plus_asic_ram[caddr+1] << 8 );
930      *p = c; p++;
931      caddr = 0x2400 + ( ( data0 & 0x10 ) ? 2 : 0 );
932      c = amstrad_plus_asic_ram[caddr] + ( amstrad_plus_asic_ram[caddr+1] << 8 );
933      *p = c; p++;
934      caddr = 0x2400 + ( ( data0 & 0x08 ) ? 2 : 0 );
935      c = amstrad_plus_asic_ram[caddr] + ( amstrad_plus_asic_ram[caddr+1] << 8 );
936      *p = c; p++;
937      caddr = 0x2400 + ( ( data0 & 0x04 ) ? 2 : 0 );
938      c = amstrad_plus_asic_ram[caddr] + ( amstrad_plus_asic_ram[caddr+1] << 8 );
939      *p = c; p++;
940      caddr = 0x2400 + ( ( data0 & 0x02 ) ? 2 : 0 );
941      c = amstrad_plus_asic_ram[caddr] + ( amstrad_plus_asic_ram[caddr+1] << 8 );
942      *p = c; p++;
943      caddr = 0x2400 + ( ( data0 & 0x01 ) ? 2 : 0 );
944      c = amstrad_plus_asic_ram[caddr] + ( amstrad_plus_asic_ram[caddr+1] << 8 );
945      *p = c; p++;
946      caddr = 0x2400 + ( ( data1 & 0x80 ) ? 2 : 0 );
947      c = amstrad_plus_asic_ram[caddr] + ( amstrad_plus_asic_ram[caddr+1] << 8 );
948      *p = c; p++;
949      caddr = 0x2400 + ( ( data1 & 0x40 ) ? 2 : 0 );
950      c = amstrad_plus_asic_ram[caddr] + ( amstrad_plus_asic_ram[caddr+1] << 8 );
951      *p = c; p++;
952      caddr = 0x2400 + ( ( data1 & 0x20 ) ? 2 : 0 );
953      c = amstrad_plus_asic_ram[caddr] + ( amstrad_plus_asic_ram[caddr+1] << 8 );
954      *p = c; p++;
955      caddr = 0x2400 + ( ( data1 & 0x10 ) ? 2 : 0 );
956      c = amstrad_plus_asic_ram[caddr] + ( amstrad_plus_asic_ram[caddr+1] << 8 );
957      *p = c; p++;
958      caddr = 0x2400 + ( ( data1 & 0x08 ) ? 2 : 0 );
959      c = amstrad_plus_asic_ram[caddr] + ( amstrad_plus_asic_ram[caddr+1] << 8 );
960      *p = c; p++;
961      caddr = 0x2400 + ( ( data1 & 0x04 ) ? 2 : 0 );
962      c = amstrad_plus_asic_ram[caddr] + ( amstrad_plus_asic_ram[caddr+1] << 8 );
963      *p = c; p++;
964      caddr = 0x2400 + ( ( data1 & 0x02 ) ? 2 : 0 );
965      c = amstrad_plus_asic_ram[caddr] + ( amstrad_plus_asic_ram[caddr+1] << 8 );
966      *p = c; p++;
967      caddr = 0x2400 + ( ( data1 & 0x01 ) ? 2 : 0 );
968      c = amstrad_plus_asic_ram[caddr] + ( amstrad_plus_asic_ram[caddr+1] << 8 );
969      *p = c; p++;
970   }
971}
972
973
974/* Plus Mode 3: 160x200, 4 colours */
975static MC6845_UPDATE_ROW( amstrad_plus_update_row_mode3 )
976{
977   UINT16   *p = BITMAP_ADDR16( bitmap, y, 0 );
978   UINT16   c;
979   int i;
980
981   logerror( "amstrad_plus_update_row_mode3: ma = 0x%04x, ra = %d, y = %d, x_count = %d, cursor_x = %d\n", ma, ra, y, x_count, cursor_x );
982
983   /* Apply horizontal background scrolling */
984   for ( i = amstrad_plus_asic_ram[0x2804] & 0x0f; i > 0; i-- )
985   {
986      if ( amstrad_plus_asic_ram[0x2804] & 0x80 )
987      {
988         /* Border colour */
989         c = amstrad_plus_asic_ram[0x2420] + ( amstrad_plus_asic_ram[0x2421] << 8 );
805                     gate_array.data = messram_get_ptr(machine->device("messram"))[ gate_array.address + 1 ];
806                     caddr = 0x2400 + gate_array.mode_lookup[gate_array.data] * 2;
807                     gate_array.colour = asic.ram[caddr] + ( asic.ram[caddr+1] << 8 );
808                  }
809                  break;
810               case 16:
811                  gate_array.ma += 1;                  /* If we were synced with the 6845 mc6845_get_ma should return this value */
812                  amstrad_plus_gate_array_get_video_data( machine );
813                  break;
814               }
815            }
816         }
817         gate_array.draw_p++;
818         cycles_passed--;
819         gate_array.line_ticks++;
820         if ( gate_array.line_ticks > gate_array.bitmap->width )
821         {
822            gate_array.draw_p = NULL;
823            cycles_passed = 0;
824         }
990825      }
991      else
992      {
993         /* Random(?) colour data */
994         c = amstrad_plus_asic_ram[0x2420] + ( amstrad_plus_asic_ram[0x2421] << 8 );
995      }
996      *p = c; p++;
997826   }
998827
999   /* Apply vertical background scrolling */
1000   ra += ( ( amstrad_plus_asic_ram[0x2804] >> 4 ) & 0x07 );
1001   if ( ra > 7 )
1002   {
1003      ma += x_count;
1004   }
1005
1006   for ( i = 0; i < x_count; i++ )
1007   {
1008      UINT16   address = ( ( ( ma + i ) & 0x3000 ) << 2 ) | ( ( ra & 0x07 ) << 11 ) | ( ( ( ma + i ) & 0x3ff ) << 1 );
1009      UINT16   caddr;
1010      UINT8   data0 = messram_get_ptr(device->machine->device("messram"))[ address ];
1011      UINT8   data1 = messram_get_ptr(device->machine->device("messram"))[ address + 1 ];
1012
1013      caddr = 0x2400 + mode1_lookup[data0][0] * 2;
1014      c = amstrad_plus_asic_ram[caddr] + ( amstrad_plus_asic_ram[caddr+1] << 8 );
1015      *p = c; p++; *p = c; p++; *p = c; p++; *p = c; p++;
1016      caddr = 0x2400 + mode1_lookup[data0][1] * 2;
1017      c = amstrad_plus_asic_ram[caddr] + ( amstrad_plus_asic_ram[caddr+1] << 8 );
1018      *p = c; p++; *p = c; p++; *p = c; p++; *p = c; p++;
1019      caddr = 0x2400 + mode1_lookup[data1][0] * 2;
1020      c = amstrad_plus_asic_ram[caddr] + ( amstrad_plus_asic_ram[caddr+1] << 8 );
1021      *p = c; p++; *p = c; p++; *p = c; p++; *p = c; p++;
1022      caddr = 0x2400 + mode1_lookup[data1][1] * 2;
1023      c = amstrad_plus_asic_ram[caddr] + ( amstrad_plus_asic_ram[caddr+1] << 8 );
1024      *p = c; p++; *p = c; p++; *p = c; p++; *p = c; p++;
1025   }
828   gate_array.last_draw_time = now;
1026829}
1027830
1028831
1029/* Plus sprites: 16 16x16 sprites, 16 colours */
1030static MC6845_UPDATE_ROW( amstrad_plus_update_row_sprites )
832INLINE void amstrad_plus_update_video_sprites( running_machine *machine )
1031833{
1032   UINT16   *p = BITMAP_ADDR16( bitmap, y, 0 );
1033   int      i;
834   UINT16   *p = BITMAP_ADDR16( gate_array.bitmap, gate_array.y, asic.h_start );
835   int i;
1034836
1035//  logerror( "amstrad_plus_update_row_sprites: ma = 0x%04x, ra = %d, y = %d, x_count = %d, cursor_x = %d\n", ma, ra, y, x_count, cursor_x );
837   if ( gate_array.y < 0 )
838      return;
1036839
1037840   for ( i = 15 * 8; i >= 0; i -= 8 )
1038841   {
1039      UINT8   xmag = ( amstrad_plus_asic_ram[ 0x2000 + i + 4 ] >> 2 ) & 0x03;
1040      UINT8   ymag = amstrad_plus_asic_ram[ 0x2000 + i + 4 ] & 0x03;
842      UINT8   xmag = ( asic.ram[ 0x2000 + i + 4 ] >> 2 ) & 0x03;
843      UINT8   ymag = asic.ram[ 0x2000 + i + 4 ] & 0x03;
1041844
1042845      /* Check if sprite is enabled */
1043846      if ( xmag && ymag )
1044847      {
1045         INT16   spr_x = amstrad_plus_asic_ram[ 0x2000 + i ] + ( amstrad_plus_asic_ram[ 0x2001 + i ] << 8 );
1046         INT16   spr_y = amstrad_plus_asic_ram[ 0x2002 + i ] + ( amstrad_plus_asic_ram[ 0x2003 + i ] << 8 );
848         INT16   spr_x = asic.ram[ 0x2000 + i ] + ( asic.ram[ 0x2001 + i ] << 8 );
849         INT16   spr_y = asic.ram[ 0x2002 + i ] + ( asic.ram[ 0x2003 + i ] << 8 );
1047850
1048851         xmag -= 1;
1049852         ymag -= 1;
1050853
1051854         /* Check if sprite would appear on this scanline */
1052         if ( spr_y <= y && y < spr_y + ( 16 << ymag ) && spr_x < 16 * x_count && spr_x + ( 16 << xmag ) > 0 )
855         if ( spr_y <= asic.vpos && asic.vpos < spr_y + ( 16 << ymag ) && spr_x < ( asic.h_end - asic.h_start ) && spr_x + ( 16 << xmag ) > 0 )
1053856         {
1054            UINT16   spr_addr = i * 32 + ( ( ( y - spr_y ) >> ymag ) * 16 );
857            UINT16   spr_addr = i * 32 + ( ( ( asic.vpos - spr_y ) >> ymag ) * 16 );
1055858            int      j, k;
1056859
1057860            for ( j = 0; j < 16; j++ )
r8980r8981
1060863               {
1061864                  INT16 x = spr_x + ( j << xmag ) + k;
1062865
1063                  if ( x >= 0 && x < 16 * x_count )
866                  if ( x >= 0 && x < ( asic.h_end - asic.h_start ) )
1064867                  {
1065                     UINT8   spr_col = ( amstrad_plus_asic_ram[ spr_addr + j ] & 0x0f ) * 2;
868                     UINT8   spr_col = ( asic.ram[ spr_addr + j ] & 0x0f ) * 2;
1066869
1067870                     if ( spr_col )
1068                        p[x] = amstrad_plus_asic_ram[ 0x2420 + spr_col ] + ( amstrad_plus_asic_ram[ 0x2421 + spr_col ] << 8 );
871                        p[x] = asic.ram[ 0x2420 + spr_col ] + ( asic.ram[ 0x2421 + spr_col ] << 8 );
1069872                  }
1070873               }
1071874            }
r8980r8981
1075878}
1076879
1077880
1078/* Aleste Mode 2: 640x200(?), 4 colours */
1079static MC6845_UPDATE_ROW( aleste_update_row_mode2 )
881static WRITE_LINE_DEVICE_HANDLER( amstrad_hsync_changed )
1080882{
1081   UINT16   *p = BITMAP_ADDR16( bitmap, y, 0 );
1082   int i;
883   amstrad_update_video( device->machine );
1083884
1084//  logerror( "aleste_update_row_mode2: ma = 0x%04x, ra = %d, y = %d, x_count = %d, cursor_x = %d\n", ma, ra, y, x_count, cursor_x );
1085
1086   for ( i = 0; i < x_count; i++ )
885   /* The gate array reacts to de-assertion of the hsycnc 6845 line */
886   if ( gate_array.hsync && !state )
1087887   {
1088      UINT16   address = ( ( ( ma + i ) & 0x2000 ) << 2 ) | ( ( ra & 0x06 ) << 11 ) | ( ( ra & 0x01 ) << 14 ) | ( ( ( ma + i ) & 0x7ff ) << 1 );
1089      UINT8   data0 = messram_get_ptr(device->machine->device("messram"))[ address ];
1090      UINT8   data1 = messram_get_ptr(device->machine->device("messram"))[ address + 1 ];
1091      UINT16   c;
1092
1093      if ( ~ aleste_mode & 0x08 )
888      gate_array.hsync_counter++;
889      /* Advance to next drawing line */
890      gate_array.y++;
891      gate_array.line_ticks = 0;
892      if ( gate_array.y >= 0 && gate_array.y < gate_array.bitmap->height )
1094893      {
1095         c = amstrad_GateArray_render_colours[ 16 ];
1096         *p = c; p++; *p = c; p++; *p = c; p++; *p = c; p++;
1097         *p = c; p++; *p = c; p++; *p = c; p++; *p = c; p++;
1098         *p = c; p++; *p = c; p++; *p = c; p++; *p = c; p++;
1099         *p = c; p++; *p = c; p++; *p = c; p++; *p = c; p++;
894         gate_array.draw_p = BITMAP_ADDR16( gate_array.bitmap, gate_array.y, 0 );
1100895      }
1101896      else
1102897      {
1103         c = amstrad_GateArray_render_colours[ mode1_lookup[data0][0] ];
1104         *p = c; p++; *p = c; p++;
1105         c = amstrad_GateArray_render_colours[ mode1_lookup[data0][1] ];
1106         *p = c; p++; *p = c; p++;
1107         c = amstrad_GateArray_render_colours[ mode1_lookup[data0][2] ];
1108         *p = c; p++; *p = c; p++;
1109         c = amstrad_GateArray_render_colours[ mode1_lookup[data0][3] ];
1110         *p = c; p++; *p = c; p++;
1111         c = amstrad_GateArray_render_colours[ mode1_lookup[data1][0] ];
1112         *p = c; p++; *p = c; p++;
1113         c = amstrad_GateArray_render_colours[ mode1_lookup[data1][1] ];
1114         *p = c; p++; *p = c; p++;
1115         c = amstrad_GateArray_render_colours[ mode1_lookup[data1][2] ];
1116         *p = c; p++; *p = c; p++;
1117         c = amstrad_GateArray_render_colours[ mode1_lookup[data1][3] ];
1118         *p = c; p++; *p = c; p++;
898         gate_array.draw_p = NULL;
1119899      }
1120   }
1121}
1122900
1123
1124/* Aleste Mode 3: 320x200, 16 colours */
1125static MC6845_UPDATE_ROW( aleste_update_row_mode3 )
1126{
1127   UINT16   *p = BITMAP_ADDR16( bitmap, y, 0 );
1128   int i;
1129
1130//  logerror( "aleste_update_row_mode3: ma = 0x%04x, ra = %d, y = %d, x_count = %d, cursor_x = %d\n", ma, ra, y, x_count, cursor_x );
1131
1132   for ( i = 0; i < x_count; i++ )
1133   {
1134      UINT16   address = ( ( ( ma + i ) & 0x2000 ) << 2 ) | ( ( ra & 0x06 ) << 11 ) | ( ( ra & 0x01 ) << 14 ) | ( ( ( ma + i ) & 0x7ff ) << 1 );
1135      UINT8   data0 = messram_get_ptr(device->machine->device("messram"))[ address ];
1136      UINT8   data1 = messram_get_ptr(device->machine->device("messram"))[ address + 1 ];
1137      UINT16   c;
1138
1139      if ( ~ aleste_mode & 0x08 )
1140      {
1141         c = amstrad_GateArray_render_colours[ 16 ];
1142         *p = c; p++; *p = c; p++; *p = c; p++; *p = c; p++;
1143         *p = c; p++; *p = c; p++; *p = c; p++; *p = c; p++;
1144         *p = c; p++; *p = c; p++; *p = c; p++; *p = c; p++;
1145         *p = c; p++; *p = c; p++; *p = c; p++; *p = c; p++;
1146      }
1147      else
1148      {
1149         c = amstrad_GateArray_render_colours[ mode0_lookup[data0][0] ];
1150         *p = c; p++; *p = c; p++; *p = c; p++; *p = c; p++;
1151         c = amstrad_GateArray_render_colours[ mode0_lookup[data0][1] ];
1152         *p = c; p++; *p = c; p++; *p = c; p++; *p = c; p++;
1153         c = amstrad_GateArray_render_colours[ mode0_lookup[data1][0] ];
1154         *p = c; p++; *p = c; p++; *p = c; p++; *p = c; p++;
1155         c = amstrad_GateArray_render_colours[ mode0_lookup[data1][1] ];
1156         *p = c; p++; *p = c; p++; *p = c; p++; *p = c; p++;
1157      }
1158   }
1159}
1160
1161
1162static MC6845_UPDATE_ROW( amstrad_update_row )
1163{
1164//  logerror( "amstrad_update_row: ma = 0x%04x, ra = %d, y = %d, x_count = %d, cursor_x = %d\n", ma, ra, y, x_count, cursor_x );
1165
1166   if ( draw_function )
1167      draw_function( device, bitmap, cliprect, ma, ra, y, x_count, cursor_x, param );
1168}
1169
1170
1171INLINE UINT16 amstrad_plus_translate_split( UINT16 ma, int y )
1172{
1173   if ( y == 0 )
1174   {
1175      asic.split_ma_base = 0x0000;
1176      asic.split_ma_started = 0x0000;
1177   }
1178   else if ( asic.enabled && amstrad_plus_asic_ram[0x2801] == y )
1179   {
1180      asic.split_ma_started = ma;
1181      asic.split_ma_base = ( amstrad_plus_asic_ram[0x2802] << 8 ) | amstrad_plus_asic_ram[0x2803];
1182   }
1183
1184   return ( ma - asic.split_ma_started ) + asic.split_ma_base;
1185}
1186
1187
1188static MC6845_UPDATE_ROW( amstrad_plus_update_row )
1189{
1190//  logerror( "amstrad_update_row: ma = 0x%04x, ra = %d, y = %d, x_count = %d, cursor_x = %d\n", ma, ra, y, x_count, cursor_x );
1191
1192   ma = amstrad_plus_translate_split( ma, y );
1193
1194   if ( draw_function )
1195      draw_function( device, bitmap, cliprect, ma, ra, y, x_count, cursor_x, param );
1196
1197   amstrad_plus_update_row_sprites( device, bitmap, cliprect, ma, ra, y, x_count, cursor_x, param );
1198}
1199
1200
1201static WRITE_LINE_DEVICE_HANDLER( amstrad_hsync_changed )
1202{
1203   /* TODO - Bring video up to date */
1204
1205   if ( ! gate_array.hsync && state )
1206   {
1207      gate_array.hsync_counter++;
1208      gate_array.y++;
1209
1210901      if ( gate_array.hsync_after_vsync_counter != 0 )  // counters still operate regardless of PRI state
1211902      {
1212903         gate_array.hsync_after_vsync_counter--;
r8980r8981
1233924
1234925static WRITE_LINE_DEVICE_HANDLER( amstrad_plus_hsync_changed )
1235926{
1236   if ( ! gate_array.hsync && state )
927   amstrad_plus_update_video( device->machine );
928
929   if ( gate_array.hsync && !state )
1237930   {
1238931      gate_array.hsync_counter++;
932      /* Advance to next drawing line */
933      gate_array.y++;
934      gate_array.line_ticks = 0;
935      if ( gate_array.y >= 0 && gate_array.y < gate_array.bitmap->height )
936      {
937         gate_array.draw_p = BITMAP_ADDR16( gate_array.bitmap, gate_array.y, 0 );
938      }
939      else
940      {
941         gate_array.draw_p = NULL;
942      }
1239943
1240944      if ( gate_array.hsync_after_vsync_counter != 0 )  // counters still operate regardless of PRI state
1241945      {
r8980r8981
1268972         // CPC+/GX4000 Programmable Raster Interrupt (disabled if &6800 in ASIC RAM is 0)
1269973         if ( asic.pri != 0 )
1270974         {
1271            if ( asic.pri == device->machine->primary_screen->vpos() )
975            if ( asic.pri == asic.vpos - 1 )
1272976            {
1273977               logerror("PRI: triggered, scanline %d\n",asic.pri);
1274978               cputag_set_input_line(device->machine, "maincpu", 0, ASSERT_LINE);
r8980r8981
1277981            }
1278982         }
1279983         // CPC+/GX4000 Split screen registers  (disabled if &6801 in ASIC RAM is 0)
1280         if(amstrad_plus_asic_ram[0x2801] != 0)
984         if(asic.ram[0x2801] != 0)
1281985         {
1282            if ( amstrad_plus_asic_ram[0x2801] == device->machine->primary_screen->vpos() )   // split occurs here (hopefully)
986            if ( asic.ram[0x2801] == asic.vpos - 1 )   // split occurs here (hopefully)
1283987            {
1284               device->machine->primary_screen->update_partial(device->machine->primary_screen->vpos() );
1285               logerror("SSCR: Split screen occured at scanline %d\n",amstrad_plus_asic_ram[0x2801]);
988               logerror("SSCR: Split screen occured at scanline %d\n",asic.ram[0x2801]);
1286989            }
1287990         }
1288991         // CPC+/GX4000 DMA channels
r8980r8981
1295998
1296999static WRITE_LINE_DEVICE_HANDLER( amstrad_vsync_changed )
12971000{
1298   /* TODO - Bring video up to date */
1001   amstrad_update_video( device->machine );
12991002
13001003   if ( ! gate_array.vsync && state )
13011004   {
r8980r8981
13041007
13051008      /* Start of new frame */
13061009      gate_array.y = -1;
1010      asic.vpos = 0;
13071011   }
13081012
13091013   gate_array.vsync = state ? 1 : 0;
13101014}
13111015
13121016
1017static WRITE_LINE_DEVICE_HANDLER( amstrad_plus_vsync_changed )
1018{
1019   amstrad_plus_update_video( device->machine );
1020
1021   if ( ! gate_array.vsync && state )
1022   {
1023      /* Reset the amstrad_CRTC_HS_After_VS_Counter */
1024      gate_array.hsync_after_vsync_counter = 2;
1025
1026      /* Start of new frame */
1027      gate_array.y = -1;
1028      asic.vpos = 0;
1029   }
1030
1031   gate_array.vsync = state ? 1 : 0;
1032}
1033
1034
13131035static WRITE_LINE_DEVICE_HANDLER( amstrad_de_changed )
13141036{
1315   /* TODO - Bring video up to date */
1037   amstrad_update_video( device->machine );
13161038
1039   if ( ! gate_array.de && state )
1040   {
1041      /* DE became active, store the starting MA and RA signals */
1042      running_device *mc6845 = device->machine->device("mc6845" );
1043
1044      gate_array.ma = mc6845_get_ma( mc6845 );
1045      gate_array.ra = mc6845_get_ra( mc6845 );
1046      amstrad_gate_array_get_video_data( device->machine );
1047   }
1048
1049   if ( gate_array.de && ! state )
1050   {
1051      asic.vpos++;
1052   }
1053
13171054   gate_array.de = state ? 1 : 0;
13181055}
13191056
13201057
1058static WRITE_LINE_DEVICE_HANDLER( amstrad_plus_de_changed )
1059{
1060   amstrad_plus_update_video( device->machine );
1061
1062   if ( ! gate_array.de && state )
1063   {
1064      /* DE became active, store the starting MA and RA signals */
1065      running_device *mc6845 = device->machine->device("mc6845" );
1066
1067      gate_array.ma = mc6845_get_ma( mc6845 );
1068      gate_array.ra = mc6845_get_ra( mc6845 );
1069      asic.h_start = gate_array.line_ticks;
1070
1071      if ( asic.vpos == 0 )
1072      {
1073         asic.split_ma_base = 0x0000;
1074         asic.split_ma_started = 0x0000;
1075      }
1076      else if ( asic.enabled && asic.ram[0x2801] != 0 && asic.ram[0x2801] == asic.vpos - 1 )
1077      {
1078         asic.split_ma_started = gate_array.ma;
1079         asic.split_ma_base = ( asic.ram[0x2802] << 8 ) | asic.ram[0x2803];
1080      }
1081
1082      gate_array.colour = asic.ram[0x2420] + ( asic.ram[0x2421] << 8 );
1083      asic.hscroll = asic.ram[0x2804] & 0x0f;
1084
1085      if ( asic.hscroll == 0 )
1086         amstrad_plus_gate_array_get_video_data( device->machine );
1087   }
1088
1089   if ( gate_array.de && ! state )
1090   {
1091      asic.h_end = gate_array.line_ticks;
1092      amstrad_plus_update_video_sprites( device->machine );
1093      asic.vpos++;
1094   }
1095
1096   gate_array.de = state ? 1 : 0;
1097}
1098
1099
13211100VIDEO_START( amstrad )
13221101{
1102   screen_device *screen = downcast<screen_device *>(machine->device("screen"));
1103
13231104   amstrad_init_lookups();
13241105
1325   draw_function = NULL;
1106   gate_array.bitmap = auto_bitmap_alloc( machine, screen->width(), screen->height(), screen->format() );
13261107   gate_array.hsync_after_vsync_counter = 2;
13271108}
13281109
13291110
13301111VIDEO_UPDATE( amstrad )
13311112{
1332   running_device *mc6845 = screen->machine->device("mc6845" );
1333   mc6845_update( mc6845, bitmap, cliprect );
1113   copybitmap( bitmap, gate_array.bitmap, 0, 0, 0, 0, cliprect );
13341114   return 0;
13351115}
13361116
13371117
13381118const mc6845_interface amstrad_mc6845_intf =
13391119{
1340   "screen",               /* screen name */
1341   16,                     /* number of pixels per video memory address */
1342   NULL,                  /* begin_update */
1343   amstrad_update_row,         /* update_row */
1344   NULL,                  /* end_update */
1345   DEVCB_LINE(amstrad_de_changed),               /* on_de_changed */
1346   DEVCB_NULL,               /* on_cur_changed */
1120   NULL,                           /* screen name */
1121   16,                              /* number of pixels per video memory address */
1122   NULL,                           /* begin_update */
1123   NULL,                           /* update_row */
1124   NULL,                           /* end_update */
1125   DEVCB_LINE(amstrad_de_changed),         /* on_de_changed */
1126   DEVCB_NULL,                        /* on_cur_changed */
13471127   DEVCB_LINE(amstrad_hsync_changed),      /* on_hsync_changed */
13481128   DEVCB_LINE(amstrad_vsync_changed),      /* on_vsync_changed */
13491129   NULL
r8980r8981
13521132
13531133const mc6845_interface amstrad_plus_mc6845_intf =
13541134{
1355   "screen",               /* screen name */
1356   16,                     /* number of pixels per video memory address */
1357   NULL,                  /* begin_update */
1358   amstrad_plus_update_row,   /* update_row */
1359   NULL,                  /* end_update */
1360   DEVCB_NULL,               /* on_de_changed */
1361   DEVCB_NULL,               /* on_cur_changed */
1362   DEVCB_LINE(amstrad_plus_hsync_changed),   /* on_hsync_changed */
1363   DEVCB_LINE(amstrad_vsync_changed),      /* on_vsync_changed */
1135   NULL,                              /* screen name */
1136   16,                                 /* number of pixels per video memory address */
1137   NULL,                              /* begin_update */
1138   NULL,                              /* update_row */
1139   NULL,                              /* end_update */
1140   DEVCB_LINE(amstrad_plus_de_changed),      /* on_de_changed */
1141   DEVCB_NULL,                           /* on_cur_changed */
1142   DEVCB_LINE(amstrad_plus_hsync_changed),      /* on_hsync_changed */
1143   DEVCB_LINE(amstrad_plus_vsync_changed),      /* on_vsync_changed */
13641144   NULL
13651145};
13661146
r8980r8981
18881668
18891669WRITE8_HANDLER( amstrad_plus_asic_4000_w )
18901670{
1891   space->machine->primary_screen->update_partial(space->machine->primary_screen->vpos());
18921671//  logerror("ASIC: Write to register at &%04x\n",offset+0x4000);
1893   amstrad_plus_asic_ram[offset] = data & 0x0f;
1672   asic.ram[offset] = data & 0x0f;
18941673}
18951674
18961675
18971676WRITE8_HANDLER( amstrad_plus_asic_6000_w )
18981677{
1899   space->machine->primary_screen->update_partial(space->machine->primary_screen->vpos());
1900   amstrad_plus_asic_ram[offset+0x2000] = data;
1678   asic.ram[offset+0x2000] = data;
19011679   if(offset >= 0x0400 && offset < 0x440 && ( offset & 0x01 ) ) // ASIC palette
19021680   {
1903      amstrad_plus_asic_ram[ offset + 0x2000 ] = data & 0x0f;
1681      asic.ram[ offset + 0x2000 ] = data & 0x0f;
19041682   }
19051683   if(offset == 0x0800)  // Programmable raster interrupt
19061684   {
r8980r8981
19091687   }
19101688   if(offset >= 0x0801 && offset <= 0x0803)  // Split screen registers
19111689   {
1912      logerror("ASIC: Split screen at line %i, address &%04x\n",amstrad_plus_asic_ram[0x2801],amstrad_plus_asic_ram[0x2803] + (amstrad_plus_asic_ram[0x2802] << 8));
1690      logerror("ASIC: Split screen at line %i, address &%04x\n",asic.ram[0x2801],asic.ram[0x2803] + (asic.ram[0x2802] << 8));
19131691   }
19141692   if(offset == 0x0804)  // Soft scroll register
19151693   {
r8980r8981
19321710   {
19331711   case 0x0c00:
19341712   case 0x0c01:
1935      asic.dma_addr[0] = (amstrad_plus_asic_ram[0x2c01] << 8) + amstrad_plus_asic_ram[0x2c00];
1713      asic.dma_addr[0] = (asic.ram[0x2c01] << 8) + asic.ram[0x2c00];
19361714      asic.dma_status &= ~0x01;
19371715      logerror("ASIC: DMA 0 address set to &%04x\n",asic.dma_addr[0]);
19381716      break;
19391717   case 0x0c04:
19401718   case 0x0c05:
1941      asic.dma_addr[1] = (amstrad_plus_asic_ram[0x2c05] << 8) + amstrad_plus_asic_ram[0x2c04];
1719      asic.dma_addr[1] = (asic.ram[0x2c05] << 8) + asic.ram[0x2c04];
19421720      asic.dma_status &= ~0x02;
19431721      logerror("ASIC: DMA 1 address set to &%04x\n",asic.dma_addr[1]);
19441722      break;
19451723   case 0x0c08:
19461724   case 0x0c09:
1947      asic.dma_addr[2] = (amstrad_plus_asic_ram[0x2c09] << 8) + amstrad_plus_asic_ram[0x2c08];
1725      asic.dma_addr[2] = (asic.ram[0x2c09] << 8) + asic.ram[0x2c08];
19481726      asic.dma_status &= ~0x04;
19491727      logerror("ASIC: DMA 2 address set to &%04x\n",asic.dma_addr[2]);
19501728      break;
r8980r8981
19681746         logerror("ASIC: DMA 0 IRQ acknowledge\n");
19691747         cputag_set_input_line(space->machine, "maincpu", 0, CLEAR_LINE);
19701748         amstrad_plus_irq_cause = 0x06;
1971         amstrad_plus_asic_ram[0x2c0f] &= ~0x40;
1749         asic.ram[0x2c0f] &= ~0x40;
19721750      }
19731751      if(data & 0x20)
19741752      {
19751753         logerror("ASIC: DMA 1 IRQ acknowledge\n");
19761754         cputag_set_input_line(space->machine, "maincpu", 0, CLEAR_LINE);
19771755         amstrad_plus_irq_cause = 0x06;
1978         amstrad_plus_asic_ram[0x2c0f] &= ~0x20;
1756         asic.ram[0x2c0f] &= ~0x20;
19791757      }
19801758      if(data & 0x10)
19811759      {
19821760         logerror("ASIC: DMA 2 IRQ acknowledge\n");
19831761         cputag_set_input_line(space->machine, "maincpu", 0, CLEAR_LINE);
19841762         amstrad_plus_irq_cause = 0x06;
1985         amstrad_plus_asic_ram[0x2c0f] &= ~0x10;
1763         asic.ram[0x2c0f] &= ~0x10;
19861764      }
19871765      break;
19881766   }
r8980r8981
19921770READ8_HANDLER( amstrad_plus_asic_4000_r )
19931771{
19941772//  logerror("RAM: read from &%04x\n",offset+0x4000);
1995   return amstrad_plus_asic_ram[offset];
1773   return asic.ram[offset];
19961774}
19971775
19981776
r8980r8981
20391817            return result;
20401818        }
20411819#endif
2042   return amstrad_plus_asic_ram[offset+0x2000];
1820   return asic.ram[offset+0x2000];
20431821}
20441822
20451823
r8980r8981
210818861   x     |
210918870   x     |*/
21101888   case 0x01:
2111      machine->primary_screen->update_partial(machine->primary_screen->vpos());
2112      amstrad_vh_update_colour( gate_array.pen_selected, (dataToGateArray & 0x1F));
1889      amstrad_vh_update_colour( machine, gate_array.pen_selected, (dataToGateArray & 0x1F));
21131890      break;
21141891
21151892/* Select screen mode and rom configuration
r8980r8981
21721949      amstrad_setUpperRom(machine);
21731950
21741951      /* b1b0 mode */
2175      machine->primary_screen->update_partial(machine->primary_screen->vpos());
21761952      amstrad_vh_update_mode();
21771953
21781954      break;
r8980r8981
22081984      amstrad_GateArray_write(space->machine, data);
22091985      break;
22101986   case 1:  // Colour select (6-bit palette)
2211      aleste_vh_update_colour( gate_array.pen_selected, data & 0x3f );
1987      aleste_vh_update_colour( space->machine, gate_array.pen_selected, data & 0x3f );
22121988      break;
22131989   case 2:  // Screen mode, Upper/Lower ROM select
22141990      amstrad_GateArray_write(space->machine, data);
r8980r8981
24952271         if (data == 0x0c && amstrad_system_type == SYSTEM_PLUS)
24962272            printer_bit8_selected = TRUE;
24972273
2274         asic.addr_6845 = data;
24982275         break;
24992276      case 0x01:      /* Write to selected internal 6845 register Write Only */
2500         space->machine->primary_screen->update_partial(space->machine->primary_screen->vpos());
2277         if ( amstrad_system_type == SYSTEM_PLUS || amstrad_system_type == SYSTEM_GX4000 )
2278            amstrad_plus_update_video( space->machine );
2279         else
2280            amstrad_update_video( space->machine );
25012281         mc6845_register_w( mc6845, 0, data );
25022282
25032283         /* printer port bit 8 */
r8980r8981
25082288            printer_bit8_selected = FALSE;
25092289         }
25102290
2291         if ( asic.addr_6845 == 0x01 )
2292            asic.horiz_disp = data;
2293
25112294         break;
25122295      default:
25132296         break;
r8980r8981
27712554   ppi_port_inputs[amstrad_ppi_PortB] = (((input_port_read(machine, "solder_links")&MANUFACTURER_NAME)<<1) | (input_port_read(machine, "solder_links")&TV_REFRESH_RATE));
27722555
27732556   if ( amstrad_system_type == SYSTEM_PLUS || amstrad_system_type == SYSTEM_GX4000 )
2774      memset(amstrad_plus_asic_ram,0,16384);  // clear ASIC RAM
2557      memset(asic.ram,0,16384);  // clear ASIC RAM
27752558
27762559   multiface_reset();
27772560}
r8980r8981
31122895   if( asic.enabled && amstrad_plus_irq_cause != 0x06 && asic.dma_clear & 0x01)
31132896   {
31142897      logerror("IRQ: Not cleared, IRQ was called by DMA [%i]\n",amstrad_plus_irq_cause);
3115      amstrad_plus_asic_ram[0x2c0f] &= ~0x80;  // not a raster interrupt, so this bit is reset
3116      return (amstrad_plus_asic_ram[0x2805] & 0xf8) | amstrad_plus_irq_cause;
2898      asic.ram[0x2c0f] &= ~0x80;  // not a raster interrupt, so this bit is reset
2899      return (asic.ram[0x2805] & 0xf8) | amstrad_plus_irq_cause;
31172900   }
31182901   cputag_set_input_line(device->machine,"maincpu", 0, CLEAR_LINE);
31192902   gate_array.hsync_counter &= 0x1F;
31202903   if ( asic.enabled )
31212904   {
31222905      if(amstrad_plus_irq_cause == 6)  // bit 7 is set "if last interrupt acknowledge cycle was caused by a raster interrupt"
3123         amstrad_plus_asic_ram[0x2c0f] |= 0x80;
2906         asic.ram[0x2c0f] |= 0x80;
31242907      else
31252908      {
3126         amstrad_plus_asic_ram[0x2c0f] &= ~0x80;
3127         amstrad_plus_asic_ram[0x2c0f] &= (0x40 >> amstrad_plus_irq_cause/2);
2909         asic.ram[0x2c0f] &= ~0x80;
2910         asic.ram[0x2c0f] &= (0x40 >> amstrad_plus_irq_cause/2);
31282911      }
3129      return (amstrad_plus_asic_ram[0x2805] & 0xf8) | amstrad_plus_irq_cause;
2912      return (asic.ram[0x2805] & 0xf8) | amstrad_plus_irq_cause;
31302913   }
31312914   return 0xFF;
31322915}
r8980r8981
33173100}
33183101
33193102
3320MACHINE_START( amstrad )
3103static TIMER_CALLBACK( cb_set_resolution )
33213104{
33223105   screen_device *screen = downcast<screen_device *>(machine->device("screen"));
3106   rectangle visarea;
3107   attoseconds_t refresh;
3108   int height;
33233109
3110   if ( input_port_read( machine, "solder_links" ) & 0x10 )
3111   {
3112      /* PAL */
3113      visarea.min_x = 32;
3114      visarea.max_x = 32 + 640 + 64 - 1;
3115      visarea.min_y = 56;
3116      visarea.max_y = 56 + 15 + 200 + 15 - 1;
3117      height = 312;
3118   }
3119   else
3120   {
3121      /* NTSC */
3122      visarea.min_x = 32;
3123      visarea.max_x = 32 + 640 + 64 - 1;
3124      visarea.min_y = 16;
3125      visarea.max_y = 16 + 15 + 200 + 15 - 1;
3126      height = 262;
3127   }
3128   refresh = HZ_TO_ATTOSECONDS( XTAL_16MHz ) * 1024 * height;
3129   screen->configure( 1024, height, visarea, refresh );
3130}
3131
3132
3133MACHINE_START( amstrad )
3134{
33243135   multiface_init(machine);
33253136   amstrad_system_type = SYSTEM_CPC;
3326
3327   gate_array.bitmap = auto_bitmap_alloc( machine, screen->width(), screen->height(), screen->format() );
33283137}
33293138
33303139
r8980r8981
33433152   amstrad_reset_machine(machine);
33443153//  amstrad_init_palette(machine);
33453154
3155   gate_array.de = 0;
3156   gate_array.draw_p = NULL;
3157   gate_array.hsync = 0;
3158   gate_array.vsync = 0;
33463159
3160   timer_set( machine, attotime_zero, NULL, 0, cb_set_resolution );
33473161}
33483162
33493163
33503164MACHINE_START( plus )
33513165{
3352   amstrad_plus_asic_ram = memory_region(machine, "user1");  // 16kB RAM for ASIC, memory-mapped registers.
3166   asic.ram = memory_region(machine, "user1");  // 16kB RAM for ASIC, memory-mapped registers.
33533167   amstrad_system_type = SYSTEM_PLUS;
33543168}
33553169
r8980r8981
33843198
33853199   amstrad_common_init(machine);
33863200   amstrad_reset_machine(machine);
3387   amstrad_plus_asic_ram[0x2805] = 0x01;  // interrupt vector is undefined at startup, except that bit 0 is always 1.
3201   asic.ram[0x2805] = 0x01;  // interrupt vector is undefined at startup, except that bit 0 is always 1.
33883202   AmstradCPC_GA_SetRamConfiguration(machine);
33893203   amstrad_GateArray_write(machine, 0x081); // Epyx World of Sports requires upper ROM to be enabled by default
33903204
33913205   //  multiface_init();
3206   timer_set( machine, attotime_zero, NULL, 0, cb_set_resolution );
33923207}
33933208
33943209MACHINE_START( gx4000 )
33953210{
3396   amstrad_plus_asic_ram = memory_region(machine, "user1");  // 16kB RAM for ASIC, memory-mapped registers.
3211   asic.ram = memory_region(machine, "user1");  // 16kB RAM for ASIC, memory-mapped registers.
33973212   amstrad_system_type = SYSTEM_GX4000;
33983213}
33993214
r8980r8981
34273242
34283243   amstrad_common_init(machine);
34293244   amstrad_reset_machine(machine);
3430   amstrad_plus_asic_ram[0x2805] = 0x01;  // interrupt vector is undefined at startup, except that bit 0 is always 1.
3245   asic.ram[0x2805] = 0x01;  // interrupt vector is undefined at startup, except that bit 0 is always 1.
34313246   AmstradCPC_GA_SetRamConfiguration(machine);
34323247   amstrad_GateArray_write(machine, 0x081); // Epyx World of Sports requires upper ROM to be enabled by default
34333248   //  multiface_init();
3249
3250   timer_set( machine, attotime_zero, NULL, 0, cb_set_resolution );
34343251}
34353252
34363253MACHINE_START( kccomp )
r8980r8981
34833300   Amstrad_ROM_Table[7] = &rom[0x018000];  // AMSDOS
34843301   amstrad_common_init(machine);
34853302   amstrad_reset_machine(machine);
3303
3304   timer_set( machine, attotime_zero, NULL, 0, cb_set_resolution );
34863305}
34873306
34883307
src/mess/drivers/amstrad.c
r8980r8981
887887    /* video hardware */
888888   MDRV_SCREEN_ADD("screen", RASTER)
889889   MDRV_SCREEN_FORMAT(BITMAP_FORMAT_INDEXED16)
890   MDRV_SCREEN_RAW_PARAMS( XTAL_16MHz, 1024, 0, 640, 312, 0, 200 )
890   MDRV_SCREEN_RAW_PARAMS( XTAL_16MHz, 1024, 32, 32 + 640 + 64, 312, 56 + 15, 200 + 15 )
891891   MDRV_VIDEO_ATTRIBUTES(VIDEO_ALWAYS_UPDATE)
892892
893893   MDRV_PALETTE_LENGTH(32)
r8980r8981
950950   /* video hardware */
951951   MDRV_SCREEN_ADD("screen", RASTER)
952952   MDRV_SCREEN_FORMAT(BITMAP_FORMAT_INDEXED16)
953   MDRV_SCREEN_RAW_PARAMS( ( XTAL_40MHz * 2 ) / 5, 1024, 0, 640, 312, 0, 200 )
953   MDRV_SCREEN_RAW_PARAMS( ( XTAL_40MHz * 2 ) / 5, 1024, 32, 32 + 640 + 64, 312, 56 + 15, 200 + 15 )
954954   MDRV_VIDEO_ATTRIBUTES(VIDEO_ALWAYS_UPDATE)
955955
956956   MDRV_PALETTE_LENGTH(4096)
r8980r8981
10061006   /* video hardware */
10071007   MDRV_SCREEN_ADD("screen", RASTER)
10081008   MDRV_SCREEN_FORMAT(BITMAP_FORMAT_INDEXED16)
1009   MDRV_SCREEN_RAW_PARAMS( ( XTAL_40MHz * 2 ) / 5, 1024, 0, 640, 312, 0, 200 )
1009   MDRV_SCREEN_RAW_PARAMS( ( XTAL_40MHz * 2 ) / 5, 1024, 32, 32 + 640 + 64, 312, 56 + 15, 200 + 15 )
10101010   MDRV_VIDEO_ATTRIBUTES(VIDEO_ALWAYS_UPDATE)
10111011
10121012   MDRV_PALETTE_LENGTH(4096)

Previous 15994 Revisions Next


© 1998-2018 The MESS Team