Previous 15994 Revisions Next

r8918 Friday 27th August, 2010 at 13:21:16 UTC by Angelo Salese
[MZ2500]: Fixed i8255a device, implemented reset lines, removed the start-up kludges
[src/mess/drivers]mz2500.c

src/mess/drivers/mz2500.c
r8917r8918
44
55    preliminary driver by Angelo Salese
66
7   TODO:
8   - keyboard;
9   - floppy device;
10
711    memory map:
8
912    0x00000-0x3ffff Work RAM
1013    0x40000-0x5ffff CG RAM (address bitswapped?)
1114    0x60000-0x67fff "Read modify write" area (related to the CG RAM)
r8917r8918
1619    0x76000-0x77fff NOP (0x3b)
1720    0x78000-0x7ffff Phone ROM (0x3c-0x3f)
1821
19    start-up vblank irq is rst $28 (0xef), this system has mixed im 0 and im 2 (!)
20
21    after some time, clear work ram [$919] to 0 ... something to do with irqs?
22
2322****************************************************************************/
2423
2524#include "emu.h"
2625#include "cpu/z80/z80.h"
2726#include "machine/z80pio.h"
27#include "machine/i8255a.h"
2828#include "machine/wd17xx.h"
2929#include "sound/2203intf.h"
3030
r8917r8918
3838static UINT8 irq_sel,irq_vector[4];
3939static UINT8 kanji_bank;
4040
41#define WRAM_RESET 0
42#define IPL_RESET 1
43
44static void mz2500_reset(UINT8 type);
45static const UINT8 bank_reset_val[2][8] =
46{
47   { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07 },
48   { 0x34, 0x35, 0x36, 0x37, 0x04, 0x05, 0x06, 0x07 }
49};
50
4151/* video stuff*/
4252static UINT8 text_reg[0x100], text_reg_index;
4353static UINT8 text_col_size, text_font_reg;
r8917r8918
171181
172182   switch(cur_bank)
173183   {
184      case 0x34:
185      case 0x35:
186      case 0x36:
187      case 0x37:
188      {
189         // IPL ROM, WRITENOP
190         //printf("%04x %02x\n",offset+bank_num*0x2000,data);
191         break;
192      }
174193      case 0x39:
175194      {
176195         if(kanji_bank & 0x80) //kanji ROM
r8917r8918
214233
215234static WRITE8_HANDLER( mz2500_bank_addr_w )
216235{
236//   printf("%02x\n",data);
217237   bank_addr = data & 7;
218238}
219239
r8917r8918
236256
237257   bank_val[bank_addr] = data & 0x3f;
238258
259   //printf("%02x %02x\n",data & 0x3f,bank_addr);
260
239261//  if((data*2) >= 0x70)
240262//  printf("%s %02x\n",bank_name[bank_addr],bank_val[bank_addr]*2);
241263
r8917r8918
306328      case 0xdc:
307329         wd17xx_set_drive(dev,data & 3);
308330         floppy_mon_w(floppy_get_device(space->machine, data & 3), (data & 0x80) ? ASSERT_LINE : CLEAR_LINE);
309         floppy_drive_set_ready_state(floppy_get_device(space->machine, data & 3), 1,1);
331         floppy_drive_set_ready_state(floppy_get_device(space->machine, data & 3), 1,0);
310332         break;
311333      case 0xdd:
312334         wd17xx_set_side(dev,(data & 1));
r8917r8918
406428   AM_RANGE(0xcf, 0xcf) AM_WRITE(mz2500_kanji_bank_w)
407429   AM_RANGE(0xd8, 0xdb) AM_DEVREADWRITE("mb8877a", wd17xx_r, wd17xx_w)
408430   AM_RANGE(0xdc, 0xdd) AM_WRITE(mz2500_fdc_w)
409   AM_RANGE(0xe0, 0xe1) AM_DEVREADWRITE("z80pio_0", z80pio_c_r, z80pio_c_w)
410   AM_RANGE(0xe2, 0xe3) AM_DEVREADWRITE("z80pio_0", z80pio_d_r, z80pio_d_w)
431   AM_RANGE(0xe0, 0xe3) AM_DEVREADWRITE("i8255_0", i8255a_r, i8255a_w)
411432//  AM_RANGE(0xe4, 0xe7) AM_READWRITE(pit_r,pit_w)
412433   AM_RANGE(0xe8, 0xe9) AM_DEVREADWRITE("z80pio_1", z80pio_c_r, z80pio_c_w)
413434   AM_RANGE(0xea, 0xeb) AM_DEVREADWRITE("z80pio_1", z80pio_d_r, z80pio_d_w)
r8917r8918
472493   PORT_DIPSETTING(    0x80, DEF_STR( On ) )
473494INPUT_PORTS_END
474495
496static void mz2500_reset(UINT8 type)
497{
498   int i;
475499
500   for(i=0;i<8;i++)
501      bank_val[i] = bank_reset_val[type][i];
502}
503
476504static MACHINE_RESET(mz2500)
477505{
478506   UINT8 *RAM = memory_region(machine, "maincpu");
479507   UINT8 *IPL = memory_region(machine, "ipl");
480508   int i;
481509
482   bank_val[0] = 0x34;
483   bank_val[1] = 0x35;
484   bank_val[2] = 0x36;
485   bank_val[3] = 0x37;
486   bank_val[4] = 0x04;
487   bank_val[5] = 0x05;
488   bank_val[6] = 0x06;
489   bank_val[7] = 0x07;
510   mz2500_reset(IPL_RESET);
490511
491/*  memory_set_bankptr(machine, "bank0", &ROM[bank_val[0]*0x2000]);
492    memory_set_bankptr(machine, "bank1", &ROM[bank_val[1]*0x2000]);
493    memory_set_bankptr(machine, "bank2", &ROM[bank_val[2]*0x2000]);
494    memory_set_bankptr(machine, "bank3", &ROM[bank_val[3]*0x2000]);
495    memory_set_bankptr(machine, "bank4", &ROM[bank_val[4]*0x2000]);
496    memory_set_bankptr(machine, "bank5", &ROM[bank_val[5]*0x2000]);
497    memory_set_bankptr(machine, "bank6", &ROM[bank_val[6]*0x2000]);
498    memory_set_bankptr(machine, "bank7", &ROM[bank_val[7]*0x2000]);*/
512   //irq_vector[0] = 0xef; /* RST 28h - vblank */
499513
500   irq_vector[0] = 0xef; /* RST 28h - vblank */
501
502514   text_col_size = 40;
503515   text_font_reg = 0;
504516
r8917r8918
555567   cpu_set_input_line_and_vector(device, 0, HOLD_LINE, irq_vector[0]);
556568}
557569
558static WRITE8_DEVICE_HANDLER( mz2500_pio1_porta_w )
570static READ8_DEVICE_HANDLER( mz2500_porta_r )
559571{
560//  printf("%02x\n",data);
561   text_col_size = (data & 0x20) ? 80 : 40;
572   return 0xff;
562573}
563574
564static READ8_DEVICE_HANDLER( mz2500_pio0_porta_r )
575static READ8_DEVICE_HANDLER( mz2500_portb_r )
565576{
566577   return 0xff;
567578}
568579
569static READ8_DEVICE_HANDLER( mz2500_pio0_portb_r )
580static READ8_DEVICE_HANDLER( mz2500_portc_r )
570581{
571582   return 0xff;
572583}
573584
585static WRITE8_DEVICE_HANDLER( mz2500_porta_w )
586{
587}
588
589static WRITE8_DEVICE_HANDLER( mz2500_portb_w )
590{
591}
592
593static WRITE8_DEVICE_HANDLER( mz2500_portc_w )
594{
595   static UINT8 reset_lines;
596
597   /* work RAM reset */
598   if((reset_lines & 0x02) == 0x00 && (data & 0x02))
599   {
600      mz2500_reset(WRAM_RESET);
601      /* correct? */
602      cputag_set_input_line(device->machine, "maincpu", INPUT_LINE_RESET, PULSE_LINE);
603   }
604
605   /* bit 2 is speaker */
606
607   /* IPL reset */
608   if((reset_lines & 0x08) == 0x00 && (data & 0x08))
609      mz2500_reset(IPL_RESET);
610
611   reset_lines = data;
612
613   //printf("%02x\n",data);
614}
615
616static I8255A_INTERFACE( ppi8255_intf )
617{
618   DEVCB_HANDLER(mz2500_porta_r),                  /* Port A read */
619   DEVCB_HANDLER(mz2500_portb_r),                  /* Port B read */
620   DEVCB_HANDLER(mz2500_portc_r),                  /* Port C read */
621   DEVCB_HANDLER(mz2500_porta_w),                  /* Port A write */
622   DEVCB_HANDLER(mz2500_portb_w),                  /* Port B write */
623   DEVCB_HANDLER(mz2500_portc_w)                  /* Port C write */
624};
625
626static WRITE8_DEVICE_HANDLER( mz2500_pio1_porta_w )
627{
628//  printf("%02x\n",data);
629   text_col_size = (data & 0x20) ? 80 : 40;
630}
631
574632static READ8_DEVICE_HANDLER( mz2500_pio1_porta_r )
575633{
576634   static UINT8 test;
r8917r8918
579637      test = 9; //'F'
580638   else if(input_code_pressed(device->machine,KEYCODE_X))
581639      test = 'C';
582   else if(input_code_pressed(device->machine,KEYCODE_C))
640   else if(input_code_pressed(device->machine,KEYCODE_1))
583641      test = 0x31;
584   else if(input_code_pressed(device->machine,KEYCODE_V))
642   else if(input_code_pressed(device->machine,KEYCODE_2))
585643      test = 0x32;
586   else if(input_code_pressed(device->machine,KEYCODE_B))
644   else if(input_code_pressed(device->machine,KEYCODE_3))
587645      test = 0x33;
588   else if(input_code_pressed(device->machine,KEYCODE_N))
646   else if(input_code_pressed(device->machine,KEYCODE_4))
589647      test = 0x34;
590648   else
591649      test = 0xff;
r8917r8918
600658   return 0xff;
601659}
602660
603static Z80PIO_INTERFACE( mz2500_pio0_intf )
604{
605   DEVCB_NULL, //irq handler
606   DEVCB_HANDLER( mz2500_pio0_porta_r ), //port a r
607   DEVCB_NULL, //port a w
608   DEVCB_NULL, //port a ardy
609   DEVCB_HANDLER( mz2500_pio0_portb_r ), //port b r
610   DEVCB_NULL, //port b w
611   DEVCB_NULL  //port b ardy
612};
613
614661static Z80PIO_INTERFACE( mz2500_pio1_intf )
615662{
616663   DEVCB_NULL,
r8917r8918
658705
659706    MDRV_MACHINE_RESET(mz2500)
660707
661   MDRV_Z80PIO_ADD( "z80pio_0", 6000000, mz2500_pio0_intf ) // unknown clock / divider
708   MDRV_I8255A_ADD( "i8255_0", ppi8255_intf )
662709   MDRV_Z80PIO_ADD( "z80pio_1", 6000000, mz2500_pio1_intf )
663710
664711   MDRV_MB8877_ADD("mb8877a",mz2500_mb8877a_interface)

Previous 15994 Revisions Next


© 1998-2018 The MESS Team