Previous 15994 Revisions Next

r1559 Sunday 20th January, 2008 at 10:05:20 UTC by Barry Rodewald
[AMSTRAD] Added Aleste 520EX clone driver.
[docs]messnew.txt
[src/mess]messdriv.c
[src/mess/drivers]amstrad.c
[src/mess/includes]amstrad.h
[src/mess/video]amstrad.c

src/mess/includes/amstrad.h
r1558r1559
7171/* REAL AMSTRAD SCREEN WIDTH and HEIGHT */
7272#define AMSTRAD_SCREEN_WIDTH   (50*AMSTRAD_CHARACTERS*2)
7373#define AMSTRAD_SCREEN_HEIGHT   (39*AMSTRAD_CHARACTERS)
74#define ALESTE_SCREEN_WIDTH     (82*AMSTRAD_CHARACTERS)
7475
7576/* number of us cycles per frame (measured) */
7677#define AMSTRAD_US_PER_SCANLINE   64
7778#define AMSTRAD_FPS               50.080128205128205
7879
7980extern VIDEO_START( amstrad );
81extern VIDEO_START( aleste );
8082extern VIDEO_UPDATE( amstrad );
8183void amstrad_vh_execute_crtc_cycles(int);
8284void amstrad_vh_update_colour(int, int);
r1558r1559
101103/* initialise palette for 464plus, 6128plus */
102104extern PALETTE_INIT( amstrad_plus );
103105
106/**** ALESTE SPECIFIC ***/
107extern PALETTE_INIT( aleste );
108void aleste_vh_update_colour(int, int);
104109
105110#endif /* AMSTRAD_H_ */
src/mess/video/amstrad.c
r1558r1559
1616
1717#include "sound/ay8910.h"
1818
19
2019static m6845_state amstrad_vidhrdw_6845_state;
2120int prev_reg;
2221
r1558r1559
4645
4746static void amstrad_plus_handle_dma(void);
4847
48extern int aleste_mode;
49
4950#ifdef MAME_DEBUG
5051extern int amstrad_plus_lower_enabled;
5152#endif
r1558r1559
279280   }
280281}
281282
283
284/* Aleste has a 6-bit RGB palette */
285PALETTE_INIT( aleste )
286{
287   int i;
288
289   palette_set_colors(machine, 0, amstrad_palette, sizeof(amstrad_palette) / 3);
290   for(i=0; i<64; i++)
291   {
292      int r,g,b;
293
294      r = (i >> 4) & 0x03;
295      g = (i >> 2) & 0x03;
296      b = i & 0x03;
297
298      r = (r << 6);
299      g = (g << 6);
300      b = (b << 6);
301
302      palette_set_color_rgb(machine, i+32, r, g, b);
303      colortable[i+32] = i+32;  // take into account the CPC and MSX palette
304   }
305}
306
282307void amstrad_plus_setspritecolour(unsigned int off, int r, int g, int b)
283308{
284309   palette_set_color_rgb(Machine, (off/2) + 33, r, g, b);
r1558r1559
333358   }
334359}
335360
361void aleste_vh_update_colour(int PenIndex, int hw_colour_index)
362{
363/*  int cpu_cycles = ((cycles_currently_ran()>>2)-1) & 63;
364
365   logerror("color is changed(%d,%d) = %d\n",PenIndex, cpu_cycles, Machine->pens[hw_colour_index]);
366  amstrad_GateArray_colours_ischanged++;
367   amstrad_GateArray_changed_colours[cpu_cycles][PenIndex] = Machine->pens[hw_colour_index];
368*/
369   amstrad_GateArray_render_colours[PenIndex] = Machine->pens[hw_colour_index+32];
370}
371
336372/* Set the new screen mode (0,1,2,4) from the GateArray */
337373void amstrad_vh_update_mode(int new_mode)
338374{
r1558r1559
633669      return;
634670   }
635671
636  for (i=0;i<4;i++) {
672   if(aleste_mode & 0x04) // if in Aleste mode
673   {
674      if(~aleste_mode & 0x08)  // and VRAM is not active
675      {
676         amstrad_draw_screen_disabled();
677         return;
678      }
679   }
680
681   for (i=0;i<4;i++) {
637682      cpcpen = Mode1Lookup[data1& 0xFF];
638683    messpen = amstrad_GateArray_render_colours[cpcpen];
639684     plot_box(bitmap,x,y,2,1,messpen);
r1558r1559
671716      return;
672717   }
673718
719   if(aleste_mode & 0x04) // if in Aleste mode
720   {
721      if(~aleste_mode & 0x08)  // and VRAM is not active
722      {
723         amstrad_draw_screen_disabled();
724         return;
725      }
726   }
727
674728   for (i=0; i<16; i++)
675729   {
676730      cpcpen = (data>>15) & 0x01;
r1558r1559
728782   plot_box(bitmap,x+12,y,4,1,messpen);
729783}
730784
785/* Aleste mode 2: high resolution - 4 colours */
786static void aleste_draw_screen_enabled_mode_2(void)
787{
788   mame_bitmap *bitmap = amstrad_bitmap;
789
790   int ma = amstrad_CRTC_MA; // m6845_memory_address_r(0);
791   int ra = amstrad_CRTC_RA; // m6845_row_address_r(0);
792/* calc mem addr to fetch data from   based on ma, and ra */
793   unsigned int addr = (((ma>>13) & 0x01)<<15) |
794         ((ra & 0x06)<<11) |
795         ((ra & 0x01) << 14) |
796         ((ma & 0x07ff) << 1);
797
798   int x = x_screen_pos;
799   int y = y_screen_pos;
800   int i, cpcpen, messpen;
801   unsigned char data1;
802   unsigned char data2;
803
804   if(~aleste_mode & 0x08)
805   {
806      amstrad_draw_screen_disabled();
807      return;
808   }
809
810   data1 = mess_ram[addr];
811   data2 = mess_ram[addr+1];
812
813   for (i=0;i<4;i++)
814   {
815      cpcpen = Mode1Lookup[data1& 0xFF];
816      messpen = amstrad_GateArray_render_colours[cpcpen];
817        plot_box(bitmap,x,y,1,1,messpen);
818
819      cpcpen = Mode1Lookup[data2];
820      messpen = amstrad_GateArray_render_colours[cpcpen];
821        plot_box(bitmap,x+4,y,1,1,messpen);
822
823      x += 1;
824      data1 = data1<<1;
825      data2 = data2<<1;
826   }
827}
828
829/* Aleste mode 3 - medium resolution, 16 colours */
830static void aleste_draw_screen_enabled_mode_3(void)
831{
832   mame_bitmap *bitmap = amstrad_bitmap;
833
834   int ma = amstrad_CRTC_MA; // m6845_memory_address_r(0);
835   int ra = amstrad_CRTC_RA; // m6845_row_address_r(0);
836   /* calc mem addr to fetch data from   based on ma, and ra */
837   unsigned int addr = (((ma>>13) & 0x01)<<15) |
838         ((ra & 0x06)<<11) |
839         ((ra & 0x01) << 14) |
840         ((ma & 0x07ff) << 1);
841
842   int x = x_screen_pos;
843   int y = y_screen_pos;
844   int cpcpen, messpen;
845
846   unsigned char data;
847
848   if(~aleste_mode & 0x08)
849   {
850      amstrad_draw_screen_disabled();
851      return;
852   }
853
854   data = mess_ram[addr];
855
856   cpcpen = Mode0Lookup[data];
857   messpen = amstrad_GateArray_render_colours[cpcpen];
858   plot_box(bitmap,x,y,2,1,messpen);
859
860   data = data<<1;
861
862   cpcpen = Mode0Lookup[data];
863   messpen = amstrad_GateArray_render_colours[cpcpen];
864   plot_box(bitmap,x+2,y,2,1,messpen);
865
866   data = mess_ram[addr+1];
867
868   cpcpen = Mode0Lookup[data];
869   messpen = amstrad_GateArray_render_colours[cpcpen];
870   plot_box(bitmap,x+4,y,2,1,messpen);
871
872   data = data<<1;
873
874   cpcpen = Mode0Lookup[data];
875   messpen = amstrad_GateArray_render_colours[cpcpen];
876   plot_box(bitmap,x+6,y,2,1,messpen);
877
878}
879
880
881
731882/* execute crtc_execute_cycles of crtc */
732883void amstrad_vh_execute_crtc_cycles(int dummy)
733884{
885   int scrwidth = AMSTRAD_SCREEN_WIDTH;
734886   m6845_clock(); // Clock the 6845
735   if ((x_screen_pos >= 0) && (x_screen_pos < AMSTRAD_SCREEN_WIDTH) && (y_screen_pos >= 0))
887   if(aleste_mode & 0x02)
736888   {
889//      scrwidth = ALESTE_SCREEN_WIDTH;
890   }
891
892   if ((x_screen_pos >= 0) && (x_screen_pos < scrwidth) && (y_screen_pos >= 0))
893   {
737894      /* render the screen */
738895      (draw_function)();
739896   }
740   x_screen_pos += (AMSTRAD_CHARACTERS*2); // Move to next raster
897   if(aleste_mode & 0x02)  // Aleste high res mode
898      x_screen_pos += (AMSTRAD_CHARACTERS); // Move to next raster
899   else
900      x_screen_pos += (AMSTRAD_CHARACTERS*2); // Move to next raster
741901/*    }*/
742902}
743903
r1558r1559
9341094         display_update = 0;
9351095      }
9361096
937      switch (amstrad_current_mode) {
938      case 0x00:
939         draw_function = amstrad_draw_screen_enabled_mode_0;
940         break;
941      case 0x01:
942         draw_function = amstrad_draw_screen_enabled_mode_1;
943         break;
944      case 0x02:
945         draw_function = amstrad_draw_screen_enabled_mode_2;
946         break;
947      case 0x03:
948         draw_function = amstrad_draw_screen_enabled_mode_3;
949         break;
1097      if(aleste_mode & 0x02)
1098      {
1099         switch (amstrad_current_mode)
1100         {
1101         case 0x00:
1102            draw_function = amstrad_draw_screen_enabled_mode_2;
1103            break;
1104         case 0x01:
1105            draw_function = amstrad_draw_screen_enabled_mode_1;
1106            break;
1107         case 0x02:
1108            draw_function = aleste_draw_screen_enabled_mode_2;
1109            break;
1110         case 0x03:
1111            draw_function = aleste_draw_screen_enabled_mode_3;
1112            break;
1113         }
9501114      }
1115      else
1116      {
1117         switch (amstrad_current_mode)
1118         {
1119         case 0x00:
1120            draw_function = amstrad_draw_screen_enabled_mode_0;
1121            break;
1122         case 0x01:
1123            draw_function = amstrad_draw_screen_enabled_mode_1;
1124            break;
1125         case 0x02:
1126            draw_function = amstrad_draw_screen_enabled_mode_2;
1127            break;
1128         case 0x03:
1129            draw_function = amstrad_draw_screen_enabled_mode_3;
1130            break;
1131         }
1132      }
9511133      }
9521134}
9531135
r1558r1559
10761258{
10771259   rectangle rect;
10781260
1079   rect.min_x = 0;
1080   rect.max_x = AMSTRAD_SCREEN_WIDTH-1;
1081   rect.min_y = 0;
1082   rect.max_y = AMSTRAD_SCREEN_HEIGHT-1;
1261//   if(aleste_mode & 0x08)
1262//   {  // MSX video
1263//      video_update_generic_bitmapped(machine,screen,bitmap,cliprect);
1264//      return 0;
1265//   }
1266//   else
1267   {  // CPC video
1268      rect.min_x = 0;
1269      rect.max_x = AMSTRAD_SCREEN_WIDTH-1;
1270      rect.min_y = 0;
1271      rect.max_y = AMSTRAD_SCREEN_HEIGHT-1;
10831272
1084#ifdef MAME_DEBUG
1085   if(input_code_pressed(KEYCODE_Z) && amstrad_system_type != 0)
1086   {
1087      int x;
1088      for(x=0;x<32;x+=2)
1273   #ifdef MAME_DEBUG
1274      if(input_code_pressed(KEYCODE_Z) && amstrad_system_type != 0)
10891275      {
1090         amstrad_plus_asic_ram[0x2400+x] = ((x/2)<< 4) + x/2;
1091         amstrad_plus_asic_ram[0x2401+x] = x/2;
1276         int x;
1277         for(x=0;x<32;x+=2)
1278         {
1279            amstrad_plus_asic_ram[0x2400+x] = ((x/2)<< 4) + x/2;
1280            amstrad_plus_asic_ram[0x2401+x] = x/2;
1281         }
10921282      }
1283   #endif
1284      copybitmap(bitmap, amstrad_bitmap, 0,0,0,0,&rect, TRANSPARENCY_NONE,0);
1285      if(amstrad_plus_asic_enabled != 0)
1286         amstrad_plus_sprite_draw(bitmap);
1287      amstrad_scanline = y_screen_pos - 32;
1288      return 0;
10931289   }
1094#endif
1095    copybitmap(bitmap, amstrad_bitmap, 0,0,0,0,&rect, TRANSPARENCY_NONE,0);
1096   if(amstrad_plus_asic_enabled != 0)
1097      amstrad_plus_sprite_draw(bitmap);
1098   amstrad_scanline = y_screen_pos - 32;
1099   return 0;
11001290}
11011291
11021292
r1558r1559
11241314   amstrad_bitmap = auto_bitmap_alloc(AMSTRAD_SCREEN_WIDTH, AMSTRAD_SCREEN_HEIGHT, BITMAP_FORMAT_INDEXED16);
11251315   display_update = 1;
11261316}
1317
src/mess/messdriv.c
r1558r1559
211211   DRIVER( cpc6128p )   /* Amstrad CPC6128 Plus - 1990                  */
212212   DRIVER( gx4000 )    /* Amstrad GX4000 - 1990                            */
213213   DRIVER( kccomp )   /* VEB KC compact                           */
214   DRIVER( al520ex )   /* Patisonic Aleste 520EX (1993)                    */
214215TESTDRIVER( pcw8256 )   /* 198? PCW8256                              */
215216TESTDRIVER( pcw8512 )   /* 198? PCW8512                              */
216217TESTDRIVER( pcw9256 )   /* 198? PCW9256                              */
src/mess/drivers/amstrad.c
r1558r1559
5656               No Exit:  Display is wrong, but usable, uses demo-like techniques.
5757
5858
59   January 2008 - added preliminary Aleste 520EX support
60               The Aleste 520EX is a Russian clone of the CPC6128, that expands on existing video mode, and can run MSX-DOS.
61            It also adds an MC146818 RTC/NVRAM, an Intel 8253 timer, and the "Magic Sound" board, a 4-channel DMA-based
62            sample player.  Also includes a software emulation of the MSX2 VDP, used in the ports of MSX games.
63
64            Known issues:
65             - The RTC doesn't always update in setup.  It expects bit 4 of register C (Update End Interrupt) to be high.
66            - Title screens appear then disappear quickly (probably because the 8253 hasn't been plugged in yet).
67            - Some video modes display wrong (still needs some work here).
68            - Vampire Killer crashes after collecting a certain key part way through stage 1.
69            - Magic Sound isn't emulated.
70
71
5972Some bugs left :
6073----------------
6174    - CRTC all type support (0,1,2,3,4) ?
r1558r1559
7487#include "video/m6845.h"      /* CRTC display */
7588#include "machine/nec765.h"   /* for floppy disc controller */
7689#include "sound/ay8910.h"
90#include "machine/mc146818.h"  /* Aleste RTC */
7791
7892/* Devices */
7993#include "devices/dsk.h"      /* for CPCEMU style disk images */
94#include "devices/basicdsk.h"   /* for 720k MSX disk images (Aleste supports these) */
95#include "includes/msx_slot.h" 
96#include "includes/msx.h"  /* MSX floppy device load */
8097#include "devices/snapquik.h"
8198#include "devices/cartslot.h"
8299#include "devices/printer.h"
r1558r1559
108125};
109126
110127int amstrad_system_type;
128int aleste_mode;
111129static int amstrad_plus_lower;  // CPC+/GX4000 cartridge bank loaded in lower ROM area
112130static int amstrad_plus_lower_addr;  // CPC+/GX4000 lower ROM area address / ASIC register page enable
113131static int amstrad_plus_lower_enabled;  // secondary lower ROM select in use?
r1558r1559
152170
153171static unsigned char previous_amstrad_UpperRom_data;
154172static unsigned char previous_printer_data_byte;
173
174static int aleste_rtc_function;
175static int aleste_fdc_int;
176
155177/*------------------
156178  - Ram Management -
157179  ------------------*/
r1558r1559
216238
217239static void update_psg(void)
218240{
219  switch (amstrad_Psg_FunctionSelected) {
220     case 0: {/* Inactive */
221    } break;
222     case 1: {/* b6 = 1 ? : Read from selected PSG register and make the register data available to PPI Port A */
223        ppi_port_inputs[amstrad_ppi_PortA] = AY8910_read_port_0_r(0);
224     } break;
225     case 2: {/* b7 = 1 ? : Write to selected PSG register and write data to PPI Port A */
226        AY8910_write_port_0_w(0, ppi_port_outputs[amstrad_ppi_PortA]);
227     } break;
228     case 3: {/* b6 and b7 = 1 ? : The register will now be selected and the user can read from or write to it.  The register will remain selected until another is chosen.*/
229        AY8910_control_port_0_w(0, ppi_port_outputs[amstrad_ppi_PortA]);
230      prev_reg = ppi_port_outputs[amstrad_ppi_PortA];
231     } break;
241   if(aleste_mode & 0x20)  // RTC selected
242   {
243      switch(aleste_rtc_function)
244      {
245      case 0x02:  // AS
246         mc146818_port_w(0,ppi_port_outputs[amstrad_ppi_PortA]);
247         break;
248      case 0x04:  // DS write
249         mc146818_port_w(1,ppi_port_outputs[amstrad_ppi_PortA]);
250         break;
251      case 0x05:  // DS read
252         ppi_port_inputs[amstrad_ppi_PortA] = mc146818_port_r(1);
253         break;
254      }
255      return;
256   }
257  switch (amstrad_Psg_FunctionSelected)
258  {
259     case 0:
260      {/* Inactive */
261      } break;
262     case 1:
263      {/* b6 = 1 ? : Read from selected PSG register and make the register data available to PPI Port A */
264           ppi_port_inputs[amstrad_ppi_PortA] = AY8910_read_port_0_r(0);
265        }
266      break;
267     case 2:
268      {/* b7 = 1 ? : Write to selected PSG register and write data to PPI Port A */
269           AY8910_write_port_0_w(0, ppi_port_outputs[amstrad_ppi_PortA]);
270        }
271      break;
272     case 3:
273      {/* b6 and b7 = 1 ? : The register will now be selected and the user can read from or write to it.  The register will remain selected until another is chosen.*/
274           AY8910_control_port_0_w(0, ppi_port_outputs[amstrad_ppi_PortA]);
275         prev_reg = ppi_port_outputs[amstrad_ppi_PortA];
276        }
277      break;
232278     default: {
233279    } break;
234280   }
r1558r1559
238284static READ8_HANDLER ( amstrad_ppi_porta_r )
239285{
240286   update_psg();
241  return ppi_port_inputs[amstrad_ppi_PortA];
287   return ppi_port_inputs[amstrad_ppi_PortA];
242288}
243289
244290static WRITE8_HANDLER ( amstrad_ppi_porta_w )
245291{
246     ppi_port_outputs[amstrad_ppi_PortA] = data;
247    update_psg();
292   ppi_port_outputs[amstrad_ppi_PortA] = data;
293   update_psg();
248294}
249295
250296/* - Read PPI Port B -
r1558r1559
295341/*  Set b0 with VSync state from the CRTC */
296342   data |= amstrad_CRTC_VS; // m6845_vertical_sync_r(0);
297343
344   if(aleste_mode & 0x04)
345   {
346      if(aleste_fdc_int == 0)
347         data &= ~0x02;
348      else
349         data |= 0x02;
350   }
351
298352   return data;
299353}
300354
r1558r1559
326380/* get b7 and b6 (PSG Function Selected */
327381   amstrad_Psg_FunctionSelected = ((data & 0xC0)>>6);
328382
383   /* MC146818 function */
384   aleste_rtc_function = data & 0x07;
385
329386/* Perform PSG function */
330387   update_psg();
331388
r1558r1559
366423   {amstrad_ppi_portc_w}    /* port C write */
367424};
368425
426static void aleste_interrupt(int state)
427{
428   if(state == CLEAR_LINE)
429      aleste_fdc_int = 0;
430   else
431      aleste_fdc_int = 1;
432}
433
369434/* Amstrad NEC765 interface doesn't use interrupts or DMA! */
370435static const nec765_interface amstrad_nec765_interface =
371436{
r1558r1559
373438   NULL
374439};
375440
441/* Aleste uses an 8272A, with the interrupt flag visible on PPI port B */
442static const nec765_interface aleste_8272_interface =
443{
444   aleste_interrupt,
445   NULL
446};
376447
377448/* pointers to current ram configuration selected for banks */
378449static unsigned char *AmstradCPC_RamBanks[4];
450static unsigned char *Aleste_RamBanks[4];
451static int aleste_active_page[4];  // page mapped to CPU RAM (is readable?)
379452
380453/* pointer to RAM used for the CPC+ ASIC memory-mapped registers */
381454unsigned char *amstrad_plus_asic_ram;
r1558r1559
395468   {
396469      if ((amstrad_GateArray_ModeAndRomConfiguration & (1<<2)) == 0) {
397470         BankBase = &memory_region(REGION_CPU1)[0x010000];
398      } else {
399         BankBase = AmstradCPC_RamBanks[0];
471      } else
472      {
473         if(aleste_mode & 0x04)
474            BankBase = Aleste_RamBanks[0];
475         else
476            BankBase = AmstradCPC_RamBanks[0];
400477      }
401478      memory_set_bankptr(1, BankBase);
402479      memory_set_bankptr(2, BankBase+0x02000);
r1558r1559
463540{
464541   unsigned char *BankBase;
465542/* b3 : "1" Upper rom area disable or "0" Upper rom area enable */
466   if ((amstrad_GateArray_ModeAndRomConfiguration & (1<<3)) == 0) {
543   if ((amstrad_GateArray_ModeAndRomConfiguration & (1<<3)) == 0)
544   {
467545      BankBase = Amstrad_UpperRom;
468   } else {
469      BankBase = AmstradCPC_RamBanks[3];
470546   }
547   else
548   {
549      if(aleste_mode & 0x04)
550         BankBase = Aleste_RamBanks[3];
551      else
552         BankBase = AmstradCPC_RamBanks[3];
553   }
471554
472555   if (BankBase)
473556   {
r1558r1559
787870/* bank 1 - 0x04000..0x07fff */
788871   if(amstrad_system_type == SYSTEM_CPC || amstrad_plus_asic_enabled == 0)
789872   {
790      memory_set_bankptr(3, AmstradCPC_RamBanks[1]);
791      memory_set_bankptr(4, AmstradCPC_RamBanks[1]+0x2000);
792/* bank 2 - 0x08000..0x0bfff */
793      memory_set_bankptr(5, AmstradCPC_RamBanks[2]);
794      memory_set_bankptr(6, AmstradCPC_RamBanks[2]+0x2000);
873      if(aleste_mode & 0x04)
874      {
875         memory_set_bankptr(3, Aleste_RamBanks[1]);
876         memory_set_bankptr(4, Aleste_RamBanks[1]+0x2000);
877         /* bank 2 - 0x08000..0x0bfff */
878         memory_set_bankptr(5, Aleste_RamBanks[2]);
879         memory_set_bankptr(6, Aleste_RamBanks[2]+0x2000);
880      }
881      else
882      {
883         memory_set_bankptr(3, AmstradCPC_RamBanks[1]);
884         memory_set_bankptr(4, AmstradCPC_RamBanks[1]+0x2000);
885         /* bank 2 - 0x08000..0x0bfff */
886         memory_set_bankptr(5, AmstradCPC_RamBanks[2]);
887         memory_set_bankptr(6, AmstradCPC_RamBanks[2]+0x2000);
888      }
795889   }
796890   else
797891      amstrad_setLowerRom();
798892/* bank 3 - 0x0c000..0x0ffff */
799893    amstrad_setUpperRom();
800894/* other banks */
801      memory_set_bankptr(9, AmstradCPC_RamBanks[0]);
802      memory_set_bankptr(10, AmstradCPC_RamBanks[0]+0x2000);
803      memory_set_bankptr(11, AmstradCPC_RamBanks[1]);
804      memory_set_bankptr(12, AmstradCPC_RamBanks[1]+0x2000);
805      memory_set_bankptr(13, AmstradCPC_RamBanks[2]);
806      memory_set_bankptr(14, AmstradCPC_RamBanks[2]+0x2000);
807      memory_set_bankptr(15, AmstradCPC_RamBanks[3]);
808      memory_set_bankptr(16, AmstradCPC_RamBanks[3]+0x2000);
895      if(aleste_mode & 0x04)
896      {
897         memory_set_bankptr(9, Aleste_RamBanks[0]);
898         memory_set_bankptr(10, Aleste_RamBanks[0]+0x2000);
899         memory_set_bankptr(11, Aleste_RamBanks[1]);
900         memory_set_bankptr(12, Aleste_RamBanks[1]+0x2000);
901         memory_set_bankptr(13, Aleste_RamBanks[2]);
902         memory_set_bankptr(14, Aleste_RamBanks[2]+0x2000);
903         memory_set_bankptr(15, Aleste_RamBanks[3]);
904         memory_set_bankptr(16, Aleste_RamBanks[3]+0x2000);
905      }
906      else
907      {
908         memory_set_bankptr(9, AmstradCPC_RamBanks[0]);
909         memory_set_bankptr(10, AmstradCPC_RamBanks[0]+0x2000);
910         memory_set_bankptr(11, AmstradCPC_RamBanks[1]);
911         memory_set_bankptr(12, AmstradCPC_RamBanks[1]+0x2000);
912         memory_set_bankptr(13, AmstradCPC_RamBanks[2]);
913         memory_set_bankptr(14, AmstradCPC_RamBanks[2]+0x2000);
914         memory_set_bankptr(15, AmstradCPC_RamBanks[3]);
915         memory_set_bankptr(16, AmstradCPC_RamBanks[3]+0x2000);
916      }
809917
810918/* multiface hardware enabled? */
811919      if (multiface_hardware_enabled()) {
r1558r1559
838946    for (i=0;i<4;i++) {
839947       BankIndex = RamConfigurations[(ConfigurationIndex << 2) + i];
840948       BankAddr = mess_ram + (BankIndex << 14);
949      Aleste_RamBanks[i] = BankAddr;
841950       AmstradCPC_RamBanks[i] = BankAddr;
842951    }
843952  } else {/* Need to add the ram expansion configuration here ! */
r1558r1559
9921101  }
9931102}
9941103
1104void aleste_msx_mapper(int offset, int data)
1105{
1106   int page = (offset & 0x0300) >> 8;
1107   int ramptr = (data & 0x1f) * 0x4000;
1108   int rampage = data & 0x1f;
1109   int function = (data & 0xc0) >> 6;
1110
1111   // It is assumed that functions are all mapped to each port &7cff-&7fff, and b8 and b9 are only used for RAM bank location
1112   switch(function)
1113   {
1114   case 0:  // Pen select (same as Gate Array?)
1115      amstrad_GateArray_write(data);
1116      break;
1117   case 1:  // Colour select (6-bit palette)
1118      aleste_vh_update_colour(amstrad_GateArray_PenSelected,data & 0x3f);
1119      break;
1120   case 2:  // Screen mode, Upper/Lower ROM select
1121      amstrad_GateArray_write(data);
1122      break;
1123   case 3: // RAM banks
1124      switch(page)
1125      {
1126      case 0:  /* 0x0000 - 0x3fff */
1127         memory_set_bankptr(1,mess_ram+ramptr);
1128         memory_set_bankptr(2,mess_ram+ramptr+0x2000);
1129         memory_set_bankptr(9,mess_ram+ramptr);
1130         memory_set_bankptr(10,mess_ram+ramptr+0x2000);
1131         Aleste_RamBanks[0] = mess_ram+ramptr;
1132         aleste_active_page[0] = data;
1133         logerror("RAM: RAM location 0x%06x (page %02x) mapped to 0x0000\n",ramptr,rampage);
1134         break;
1135      case 1:  /* 0x4000 - 0x7fff */
1136         memory_set_bankptr(3,mess_ram+ramptr);
1137         memory_set_bankptr(4,mess_ram+ramptr+0x2000);
1138         memory_set_bankptr(11,mess_ram+ramptr);
1139         memory_set_bankptr(12,mess_ram+ramptr+0x2000);
1140         Aleste_RamBanks[1] = mess_ram+ramptr;
1141         aleste_active_page[1] = data;
1142         logerror("RAM: RAM location 0x%06x (page %02x) mapped to 0x4000\n",ramptr,rampage);
1143         break;
1144      case 2:  /* 0x8000 - 0xbfff */
1145         memory_set_bankptr(5,mess_ram+ramptr);
1146         memory_set_bankptr(6,mess_ram+ramptr+0x2000);
1147         memory_set_bankptr(13,mess_ram+ramptr);
1148         memory_set_bankptr(14,mess_ram+ramptr+0x2000);
1149         Aleste_RamBanks[2] = mess_ram+ramptr;
1150         aleste_active_page[2] = data;
1151         logerror("RAM: RAM location 0x%06x (page %02x) mapped to 0x8000\n",ramptr,rampage);
1152         break;
1153      case 3:  /* 0xc000 - 0xffff */
1154         memory_set_bankptr(7,mess_ram+ramptr);
1155         memory_set_bankptr(8,mess_ram+ramptr+0x2000);
1156         memory_set_bankptr(15,mess_ram+ramptr);
1157         memory_set_bankptr(16,mess_ram+ramptr+0x2000);
1158         Aleste_RamBanks[3] = mess_ram+ramptr;
1159         aleste_active_page[3] = data;
1160         logerror("RAM: RAM location 0x%06x (page %02x) mapped to 0xc000\n",ramptr,rampage);
1161         break;
1162      }
1163      break;
1164   }
1165}
1166
9951167/* used for loading snapshot only ! */
9961168void AmstradCPC_PALWrite(int data)
9971169{
r1558r1559
10671239   unsigned char data = 0xFF;
10681240   unsigned int r1r0 = (unsigned int)((offset & 0x0300) >> 8);
10691241   m6845_personality_t crtc_type;
1242   int page;
10701243
10711244   crtc_type = readinputportbytag_safe("crtc", 0);
10721245   m6845_set_personality(crtc_type);
10731246
1247   if(aleste_mode & 0x04)
1248   {
1249      if ((offset & (1<<15)) == 0)  // Aleste Mapper is readable?
1250      {
1251         page = (offset & 0x0300) >> 8;
1252         data = aleste_active_page[page];
1253         return data;
1254      }
1255   }
1256
10741257   /* if b14 = 0 : CRTC Read selected */
10751258   if ((offset & (1<<14)) == 0)
10761259   {
r1558r1559
11461329         }
11471330      }
11481331   }
1149  return data;
1332   return data;
11501333}
11511334
11521335/* Offset handler for write */
11531336static WRITE8_HANDLER ( AmstradCPC_WritePortHandler )
11541337{
1155  if ((offset & (1<<15)) == 0) {
1156/* if b15 = 0 and b14 = 1 : Gate-Array Write Selected*/
1157    if ((offset & (1<<14)) != 0) {
1158         amstrad_GateArray_write(data);
1159    }
1160/* if b15 = 0 : RAM Configuration Write Selected*/
1161      AmstradCPC_GA_SetRamConfiguration();
1162  }
1338   if ((offset & (1<<15)) == 0)
1339   {
1340      if(aleste_mode & 0x04) // Aleste mode
1341      {
1342         aleste_msx_mapper(offset,data);
1343      }
1344      else
1345      {
1346      /* if b15 = 0 and b14 = 1 : Gate-Array Write Selected*/
1347      if ((offset & (1<<14)) != 0)
1348               amstrad_GateArray_write(data);
1349      /* if b15 = 0 : RAM Configuration Write Selected*/
1350        AmstradCPC_GA_SetRamConfiguration();
1351      }
1352}
11631353/*The Gate-Array and CRTC can't be selected simultaneously, which would otherwise cause potential display corruption.*/
11641354/* if b14 = 0 : CRTC Write Selected*/
11651355  if ((offset & (1<<14)) == 0) {
r1558r1559
12681458         }
12691459      }
12701460   }
1461
1462/*   Aleste Extend Port:
1463      D0 - VRAM Bank 0/1 (64K)
1464      D1 - MODE 0-Norm ,1-High resolution
1465      D2 - MAPMOD 0-Amstrad ,1-Yamaha mapper
1466      D3 - MAP Page 0/1 (256K)
1467      D4 - 580WI53
1468      D5 - 0-AY8910 ,1-512WI1 */
1469   if(offset == 0xfabf)
1470   {
1471      rectangle rect;
1472      aleste_mode = data;
1473      logerror("EXTEND: Port &FABF write 0x%02x\n",data);
1474      if(data & 0x02)
1475      {
1476         // Aleste high resolution settings
1477         rect.min_x = rect.min_y = 0;
1478         rect.max_x = (ALESTE_SCREEN_WIDTH-32) - 1;
1479         rect.max_y = (AMSTRAD_SCREEN_HEIGHT-40) - 1;
1480         video_screen_configure(0,800,312,&rect,HZ_TO_ATTOSECONDS(AMSTRAD_FPS));
1481      }
1482      else
1483      {
1484         // Normal CPC video settings
1485         rect.min_x = rect.min_y = 0;
1486         rect.max_x = (AMSTRAD_SCREEN_WIDTH-32) - 1;
1487         rect.max_y = (AMSTRAD_SCREEN_HEIGHT-40) - 1;
1488         video_screen_configure(0,800,312,&rect,HZ_TO_ATTOSECONDS(AMSTRAD_FPS));
1489      }
1490   }
12711491   multiface_io_write(offset,data);
12721492}
12731493
r1558r1559
17771997
17781998static void amstrad_common_init(void)
17791999{
2000   aleste_mode = 0;
2001
17802002   amstrad_GateArray_ModeAndRomConfiguration = 0;
17812003   amstrad_GateArray_RamConfiguration = 0;
17822004   amstrad_CRTC_HS_Counter = 2;
r1558r1559
17842006
17852007   memory_install_read8_handler(0, ADDRESS_SPACE_PROGRAM, 0x0000, 0x1fff, 0, 0, MRA8_BANK1);
17862008   memory_install_read8_handler(0, ADDRESS_SPACE_PROGRAM, 0x2000, 0x3fff, 0, 0, MRA8_BANK2);
1787//  if(amstrad_system_type == SYSTEM_CPC)
1788//  {
1789      memory_install_read8_handler(0, ADDRESS_SPACE_PROGRAM, 0x4000, 0x5fff, 0, 0, MRA8_BANK3);
1790      memory_install_read8_handler(0, ADDRESS_SPACE_PROGRAM, 0x6000, 0x7fff, 0, 0, MRA8_BANK4);
1791//  }
1792//  else
1793//  {
1794//      memory_install_read8_handler(0, ADDRESS_SPACE_PROGRAM, 0x4000, 0x5fff, 0, 0, amstrad_plus_asic_4000_r);
1795//      memory_install_read8_handler(0, ADDRESS_SPACE_PROGRAM, 0x6000, 0x7fff, 0, 0, amstrad_plus_asic_6000_r);
1796//  }
2009
2010   memory_install_read8_handler(0, ADDRESS_SPACE_PROGRAM, 0x4000, 0x5fff, 0, 0, MRA8_BANK3);
2011   memory_install_read8_handler(0, ADDRESS_SPACE_PROGRAM, 0x6000, 0x7fff, 0, 0, MRA8_BANK4);
2012
17972013   memory_install_read8_handler(0, ADDRESS_SPACE_PROGRAM, 0x8000, 0x9fff, 0, 0, MRA8_BANK5);
17982014   memory_install_read8_handler(0, ADDRESS_SPACE_PROGRAM, 0xa000, 0xbfff, 0, 0, MRA8_BANK6);
17992015
r1558r1559
18022018
18032019   memory_install_write8_handler(0, ADDRESS_SPACE_PROGRAM, 0x0000, 0x1fff, 0, 0, MWA8_BANK9);
18042020   memory_install_write8_handler(0, ADDRESS_SPACE_PROGRAM, 0x2000, 0x3fff, 0, 0, MWA8_BANK10);
1805//  if(amstrad_system_type == SYSTEM_CPC)
1806//  {
1807      memory_install_write8_handler(0, ADDRESS_SPACE_PROGRAM, 0x4000, 0x5fff, 0, 0, MWA8_BANK11);
1808      memory_install_write8_handler(0, ADDRESS_SPACE_PROGRAM, 0x6000, 0x7fff, 0, 0, MWA8_BANK12);
1809//  }
1810//  else
1811//  {
1812//      memory_install_write8_handler(0, ADDRESS_SPACE_PROGRAM, 0x4000, 0x5fff, 0, 0, amstrad_plus_asic_4000_w);
1813//      memory_install_write8_handler(0, ADDRESS_SPACE_PROGRAM, 0x6000, 0x7fff, 0, 0, amstrad_plus_asic_6000_w);
1814//  }
2021
2022   memory_install_write8_handler(0, ADDRESS_SPACE_PROGRAM, 0x4000, 0x5fff, 0, 0, MWA8_BANK11);
2023   memory_install_write8_handler(0, ADDRESS_SPACE_PROGRAM, 0x6000, 0x7fff, 0, 0, MWA8_BANK12);
2024
18152025   memory_install_write8_handler(0, ADDRESS_SPACE_PROGRAM, 0x8000, 0x9fff, 0, 0, MWA8_BANK13);
18162026   memory_install_write8_handler(0, ADDRESS_SPACE_PROGRAM, 0xa000, 0xbfff, 0, 0, MWA8_BANK14);
2027
18172028   memory_install_write8_handler(0, ADDRESS_SPACE_PROGRAM, 0xc000, 0xdfff, 0, 0, MWA8_BANK15);
18182029   memory_install_write8_handler(0, ADDRESS_SPACE_PROGRAM, 0xe000, 0xffff, 0, 0, MWA8_BANK16);
18192030
r1558r1559
19952206   ppi_port_inputs[amstrad_ppi_PortB] = (1<<4) | (1<<3) | 2;
19962207}
19972208
2209static DRIVER_INIT( aleste )
2210{
2211   mc146818_init(MC146818_IGNORE_CENTURY);
2212}
19982213
2214static MACHINE_RESET( aleste )
2215{
2216   int i;
2217
2218   amstrad_system_type = SYSTEM_CPC;
2219
2220   for (i=0; i<256; i++)
2221   {
2222      Amstrad_ROM_Table[i] = &memory_region(REGION_CPU1)[0x014000];
2223   }
2224
2225   Amstrad_ROM_Table[3] = &memory_region(REGION_CPU1)[0x01c000];  // MSX-DOS / BIOS
2226   Amstrad_ROM_Table[7] = &memory_region(REGION_CPU1)[0x018000];  // AMSDOS
2227   amstrad_common_init();
2228   amstrad_reset_machine();
2229
2230   nec765_init(&aleste_8272_interface,NEC765A);
2231   floppy_drive_set_geometry(image_from_devtype_and_index(IO_FLOPPY, 0),  FLOPPY_DRIVE_DS_80);
2232   floppy_drive_set_geometry(image_from_devtype_and_index(IO_FLOPPY, 1),  FLOPPY_DRIVE_DS_80);
2233}
2234
19992235/* Memory is banked in 16k blocks. However, the multiface
20002236pages the memory in 8k blocks! The ROM can
20012237be paged into bank 0 and bank 3. */
r1558r1559
20312267   If keyboard matrix line 11-14 are selected, the byte is always &ff.
20322268   After testing on a real CPC, it is found that these never change, they always return &FF. */
20332269
2034   if (amstrad_keyboard_line > 9) {
2035    return 0xFF;
2036  } else {
2037    int amstrad_read_keyboard_line = amstrad_keyboard_line;
2038    amstrad_keyboard_line = 0xFF;
2039    return (readinputport(amstrad_read_keyboard_line) & 0xFF);
2040  }
2270   if (amstrad_keyboard_line > 10)
2271   {
2272      return 0xFF;
2273   }
2274   else
2275   {
2276      int amstrad_read_keyboard_line = amstrad_keyboard_line;
2277      if(aleste_mode == 0x08 && amstrad_keyboard_line == 10)
2278         return 0xff;
2279      amstrad_keyboard_line = 0xFF;
2280      return (readinputport(amstrad_read_keyboard_line) & 0xFF);
2281   }
20412282}
20422283
20432284static INPUT_PORTS_START( amstrad_keyboard )
r1558r1559
25592800
25602801INPUT_PORTS_END
25612802
2803static INPUT_PORTS_START(aleste)
2804   PORT_INCLUDE( amstrad_keyboard )
2805
2806   PORT_MODIFY( "keyboard_row_9" )
2807   /* Documentation marks this input as "R/L", it's purpose is unknown - I can't even find it on the keyboard */
2808   PORT_BIT(0x40, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("R  L")       PORT_CODE(KEYCODE_PGUP)
2809
2810   PORT_START_TAG( "keyboard_row_10" )
2811   PORT_BIT(0x01, IP_ACTIVE_LOW, IPT_KEYBOARD)  PORT_NAME("F1  F6")    PORT_CODE(KEYCODE_F1)
2812   PORT_BIT(0x02, IP_ACTIVE_LOW, IPT_KEYBOARD)  PORT_NAME("F2  F7")    PORT_CODE(KEYCODE_F2)
2813   PORT_BIT(0x04, IP_ACTIVE_LOW, IPT_KEYBOARD)  PORT_NAME("F3  F8")    PORT_CODE(KEYCODE_F3)
2814   PORT_BIT(0x08, IP_ACTIVE_LOW, IPT_KEYBOARD)  PORT_NAME("F4  F9")    PORT_CODE(KEYCODE_F4)
2815   PORT_BIT(0x10, IP_ACTIVE_LOW, IPT_KEYBOARD)  PORT_NAME("F5  F10")   PORT_CODE(KEYCODE_F5)
2816   PORT_BIT(0x20, IP_ACTIVE_LOW, IPT_KEYBOARD)  PORT_NAME("HELP")      PORT_CODE(KEYCODE_PGDN)
2817   PORT_BIT(0x40, IP_ACTIVE_LOW, IPT_KEYBOARD)    PORT_NAME("INS")       PORT_CODE(KEYCODE_DEL)
2818   PORT_BIT(0x80, IP_ACTIVE_LOW, IPT_KEYBOARD)  PORT_NAME("Funny looking Russian symbol")     PORT_CODE(KEYCODE_END)
2819
2820   PORT_INCLUDE( crtc_links )
2821   PORT_MODIFY("multiface")  // move Multiface II stop to F6, as the Aleste has it's own F1-F5 keys.
2822   PORT_BIT(0x02, IP_ACTIVE_HIGH, IPT_OTHER) PORT_NAME("Multiface Two's Stop Button") PORT_CODE(KEYCODE_F6)
2823INPUT_PORTS_END
2824
25622825/* --------------------
25632826   - AY8910_interface -
25642827   --------------------*/
r1558r1559
26772940   MDRV_PALETTE_INIT( amstrad_plus )
26782941MACHINE_DRIVER_END
26792942
2943static MACHINE_DRIVER_START( aleste )
2944   MDRV_IMPORT_FROM( amstrad )
2945   MDRV_MACHINE_RESET( aleste )
2946   MDRV_PALETTE_LENGTH(32+64)
2947   MDRV_COLORTABLE_LENGTH(32+64)  // standard CPC palette, and 6-bit MSX palette
2948   MDRV_PALETTE_INIT( aleste )
2949   MDRV_NVRAM_HANDLER( mc146818 )
2950MACHINE_DRIVER_END
2951
26802952/***************************************************************************
26812953
26822954  Game driver(s)
r1558r1559
26862958/* cpc6128.rom contains OS in first 16k, BASIC in second 16k */
26872959/* cpcados.rom contains Amstrad DOS */
26882960
2961/*static DEVICE_LOAD( aleste )
2962{
2963   if (device_load_basicdsk_floppy(image)==INIT_PASS)
2964   {
2965      basicdsk_set_geometry(image, 80, 2, 9, 512, 0x01, 0, FALSE);
2966      return INIT_PASS;
2967   }
2968   return INIT_FAIL;
2969}*/
26892970
26902971static void cpc6128_floppy_getinfo(const device_class *devclass, UINT32 state, union devinfo *info)
26912972{
r1558r1559
26992980   }
27002981}
27012982
2983static void aleste_floppy_getinfo(const device_class *devclass, UINT32 state, union devinfo *info)
2984{
2985   /* floppy */
2986   switch(state)
2987   {
2988      /* --- the following bits of info are returned as 64-bit signed integers --- */
2989      case DEVINFO_INT_COUNT:                     info->i = 2; break;
2990      case DEVINFO_PTR_LOAD:                     info->load = device_load_msx_floppy; break;
2991      case DEVINFO_STR_FILE_EXTENSIONS:            strcpy(info->s = device_temp_str(), "dsk"); break;
2992
2993      default:                              legacybasicdsk_device_getinfo(devclass, state, info); break;
2994   }
2995}
2996
2997
27022998static void cpc6128_cassette_getinfo(const device_class *devclass, UINT32 state, union devinfo *info)
27032999{
27043000   /* cassette */
r1558r1559
27783074   CONFIG_DEVICE(cpcplus_snapshot_getinfo)
27793075SYSTEM_CONFIG_END
27803076
3077SYSTEM_CONFIG_START(aleste)
3078   CONFIG_DEVICE(aleste_floppy_getinfo)
3079   CONFIG_DEVICE(cpc6128_cassette_getinfo)
3080   CONFIG_DEVICE(cpc6128_printer_getinfo)
3081   CONFIG_RAM_DEFAULT(2048 * 1024)  // has 2048k RAM
3082SYSTEM_CONFIG_END
27813083
27823084/* ---------------------------------------------
27833085   - Rom definition for the ROM loading system -
r1558r1559
28553157   ROM_REGION(0x4000, REGION_USER1,0)
28563158ROM_END
28573159
3160ROM_START(al520ex)
3161   ROM_REGION(0x80000, REGION_CPU1,0)
3162   ROM_LOAD("al512.bin", 0x10000, 0x10000, CRC(e8c2a9a1) )
3163
3164   ROM_REGION(0x20, REGION_USER2,0)
3165   ROM_LOAD("af.bin", 0x00, 0x20, CRC(c81fb524) )
3166
3167   ROM_REGION(0x100, REGION_USER3,0)  // RAM bank mappings
3168   ROM_LOAD("mapper.bin", 0x00, 0x100, CRC(0daebd80) )
3169
3170   ROM_REGION(0x800, REGION_USER4,0)  // Colour data
3171   ROM_LOAD("rfcoldat.bin", 0x00, 0x800, CRC(c6ace0e6) )
3172
3173   ROM_REGION(0x800, REGION_USER5,0)  // Keyboard / Video
3174   ROM_LOAD("rfvdkey.bin", 0x00, 0x800, CRC(cf2aa4b0) )
3175
3176   ROM_REGION(0x100, REGION_USER6,0)
3177   ROM_LOAD("romram.bin", 0x00, 0x100, CRC(b3ea95d7) )
3178ROM_END
3179
28583180/*    YEAR  NAME      PARENT    COMPAT  MACHINE  INPUT     INIT CONFIG   COMPANY                FULLNAME */
28593181COMP( 1984, cpc464,   0,        0,      amstrad, cpc464,   0,   cpc6128, "Amstrad plc",         "Amstrad CPC464", 0)
28603182COMP( 1985, cpc664,   cpc464,   0,      amstrad, cpc664,   0,   cpc6128, "Amstrad plc",         "Amstrad CPC664", 0)
r1558r1559
28643186COMP( 1990, cpc6128p, 0,        0,      cpcplus, plus,     0,   cpcplus, "Amstrad plc",         "Amstrad CPC6128+", 0)
28653187CONS( 1990, gx4000,   0,        0,      gx4000,  gx4000,   0,   gx4000,  "Amstrad plc",         "Amstrad GX4000", 0)
28663188COMP( 1989, kccomp,   cpc464,   0,      kccomp,  kccomp,   0,   cpc6128, "VEB Mikroelektronik", "KC Compact", 0)
2867
3189COMP( 1993, al520ex,  cpc464,   0,      aleste,  aleste, aleste,aleste,  "Patisonic",           "Aleste 520EX", GAME_IMPERFECT_SOUND)
docs/messnew.txt
r1558r1559
33New System Drivers Supported (in no particular order):
44------------------------------------------------------
55- Amstrad GX4000 [Barry Rodewald]
6- Aleste 520EX [Barry Rodewald]
67
78
8
99System Driver Changes:
1010----------------------
1111- [GAMEBOY] Small mode 0 stat bug triggering fixes.  [Wilbert Pol]

Previous 15994 Revisions Next


© 1998-2018 The MESS Team