Previous 15994 Revisions Next

r8742 Sunday 8th August, 2010 at 13:54:35 UTC by Angelo Salese
[PC-6001Mk2]: Hooked up some new registers, implemented timer irq masking, vector and hz divider, fixes Space Harrier sound tempo
[src/mess/drivers]pc6001.c

src/mess/drivers/pc6001.c
r8741r8742
124124static UINT8 *pc6001_video_ram;
125125static UINT8 irq_vector = 0x00;
126126static UINT8 cas_switch,sys_latch;
127static UINT8 timer_irq_mask;
127128static UINT32 cas_offset;
128129static UINT32 cas_maxsize;
130static emu_timer *timer_irq_timer;
131static UINT16 timer_hz_div;
129132/* PC6001mk2 specific */
130133static UINT8 ex_vram_bank, bgcol_bank,exgfx_text_mode,exgfx_bitmap_mode,exgfx_2bpp_mode;
131134static UINT8 bank_r0,bank_r1,gfx_bank_on,bank_w,bank_opt;
135static UINT8 timer_irq_mask2, timer_irq_vector;
132136
133137//#define CAS_LENGTH 0x1655
134138
r8741r8742
505509   }
506510
507511   sys_latch = data;
512   timer_irq_mask = data & 1;
508513   //printf("%02x\n",data);
509514}
510515
r8741r8742
600605   ADDRESS_MAP_GLOBAL_MASK(0xff)
601606   AM_RANGE(0x80, 0x80) AM_DEVREADWRITE("uart", msm8251_data_r,msm8251_data_w)
602607   AM_RANGE(0x81, 0x81) AM_DEVREADWRITE("uart", msm8251_status_r,msm8251_control_w)
603   AM_RANGE(0x90, 0x93) AM_DEVREADWRITE("ppi8255", nec_ppi8255_r, nec_ppi8255_w)
604   AM_RANGE(0xa0, 0xa0) AM_DEVWRITE("ay8910", ay8910_address_w)
605   AM_RANGE(0xa1, 0xa1) AM_DEVWRITE("ay8910", ay8910_data_w)
606   AM_RANGE(0xa2, 0xa2) AM_DEVREAD("ay8910", ay8910_r)
607   AM_RANGE(0xb0, 0xb0) AM_WRITE(pc6001_system_latch_w)
608   AM_RANGE(0x90, 0x93) AM_MIRROR(0x0c) AM_DEVREADWRITE("ppi8255", nec_ppi8255_r, nec_ppi8255_w)
609   AM_RANGE(0xa0, 0xa0) AM_MIRROR(0x0c) AM_DEVWRITE("ay8910", ay8910_address_w)
610   AM_RANGE(0xa1, 0xa1) AM_MIRROR(0x0c) AM_DEVWRITE("ay8910", ay8910_data_w)
611   AM_RANGE(0xa2, 0xa2) AM_MIRROR(0x0c) AM_DEVREAD("ay8910", ay8910_r)
612   AM_RANGE(0xa3, 0xa3) AM_MIRROR(0x0c) AM_WRITENOP
613   AM_RANGE(0xb0, 0xb0) AM_MIRROR(0x0f) AM_WRITE(pc6001_system_latch_w)
614   AM_RANGE(0xd0, 0xd3) AM_MIRROR(0x0c) AM_NOP // disk device
608615ADDRESS_MAP_END
609616
610617/*
r8741r8742
954961   }
955962
956963   sys_latch = data;
964   timer_irq_mask = data & 1;
957965   vram_bank_change(space->machine,(ex_vram_bank & 0x06) | ((sys_latch & 0x06) << 4));
958966
959967   //printf("%02x B0\n",data);
r8741r8742
9981006   bgcol_bank = (data & 7);
9991007}
10001008
1001/* this is a voice status flag, used by Chrith no Ainotabidachi (FIXME: identify and hook-up this voice synth chip) */
1002static READ8_HANDLER( voice_status_r )
1009/* voice synth is a NEC uPD7752 sound chip (currently unemulated) */
1010static READ8_HANDLER( upd7752_reg_r )
10031011{
1004   //x--- ---- status (1) not ready
1005   //-x-- ---- writes some presumably wrong data
1006   //---x ---- enables voice ROM, gives small time to fire an irq there
1007   return 0x00;
1012   switch(offset & 3)
1013   {
1014      //[0x00]: status register
1015      //x--- ---- BSY busy status (1) processing (0) stopped
1016      //-x-- ---- REQ audio parameter (1) input request (0) prohibited (???)
1017      //--x- ---- ~INT / EXT message data (1) Outside (0) Inside
1018      //---x ---- ERR error flag
1019      case 0x00: return 0x60;
1020      //[0x02]: port 0xe2 latch?
1021      case 0x02: return 0xff;
1022      //[0x03]: port 0xe3 latch?
1023      case 0x03: return 0xff;
1024   }
1025   return 0xff;
10081026}
10091027
1028static WRITE8_HANDLER( upd7752_reg_w )
1029{
1030   switch(offset & 3)
1031   {
1032      // [0x00]: audio parameter transfer
1033
1034      // [0x02]: mode set
1035      // ---- -x-- Frame periodic analysis (0) 10 ms / frame (1) 20 ms / frame
1036      // ---- --xx Utterance (tempo?) speed
1037      //        00 : NORMAL SPEED
1038      //        01 : SLOW SPEED
1039      //        10 : FAST SPEED
1040      //        11 : Setting prohibited
1041
1042      // case 0x02:
1043
1044      // case 0x03: command set
1045   }
1046}
1047
1048static WRITE8_HANDLER( pc6001m2_0xf3_w )
1049{
1050   /*
1051   x--- ---- M1 (?) wait setting
1052   -x-- ---- ROM wait setting
1053   --x- ---- RAM wait setting
1054   ---x ---- custom irq 2 address output
1055   ---- x--- custom irq 1 address output
1056   ---- -x-- timer irq mask 2 (mirror?)
1057   ---- --x- custom irq 2 mask
1058   ---- ---x custom irq 1 mask
1059   */
1060   timer_irq_mask2 = data & 4;
1061}
1062
1063static TIMER_CALLBACK(audio_callback)
1064{
1065   if(cas_switch == 0 && ((timer_irq_mask == 0) || (timer_irq_mask2 == 0)))
1066   {
1067      irq_vector = timer_irq_vector;
1068      cputag_set_input_line(machine,"maincpu", 0, ASSERT_LINE);
1069   }
1070}
1071
1072
1073static WRITE8_HANDLER( pc6001m2_timer_adj_w )
1074{
1075   timer_hz_div = data;
1076   attotime period = ATTOTIME_IN_HZ((487.5*4)/(timer_hz_div+1));
1077   timer_adjust_periodic(timer_irq_timer, period,  0, period);
1078}
1079
1080static WRITE8_HANDLER( pc6001m2_timer_irqv_w )
1081{
1082   timer_irq_vector = data;
1083}
1084
10101085static ADDRESS_MAP_START(pc6001m2_map, ADDRESS_SPACE_PROGRAM, 8)
10111086   ADDRESS_MAP_UNMAP_HIGH
10121087   AM_RANGE(0x0000, 0x1fff) AM_ROMBANK("bank1") AM_WRITE(work_ram0_w)
r8741r8742
10241099   ADDRESS_MAP_GLOBAL_MASK(0xff)
10251100   AM_RANGE(0x80, 0x80) AM_DEVREADWRITE("uart", msm8251_data_r,msm8251_data_w)
10261101   AM_RANGE(0x81, 0x81) AM_DEVREADWRITE("uart", msm8251_status_r,msm8251_control_w)
1027   AM_RANGE(0x90, 0x93) AM_DEVREADWRITE("ppi8255", nec_ppi8255_r, necmk2_ppi8255_w)
1028   AM_RANGE(0xa0, 0xa0) AM_DEVWRITE("ay8910", ay8910_address_w)
1029   AM_RANGE(0xa1, 0xa1) AM_DEVWRITE("ay8910", ay8910_data_w)
1030   AM_RANGE(0xa2, 0xa2) AM_DEVREAD("ay8910", ay8910_r)
1031   AM_RANGE(0xb0, 0xb0) AM_WRITE(pc6001m2_system_latch_w)
1102
1103   AM_RANGE(0x90, 0x93) AM_MIRROR(0x0c) AM_DEVREADWRITE("ppi8255", nec_ppi8255_r, necmk2_ppi8255_w)
1104
1105   AM_RANGE(0xa0, 0xa0) AM_MIRROR(0x0c) AM_DEVWRITE("ay8910", ay8910_address_w)
1106   AM_RANGE(0xa1, 0xa1) AM_MIRROR(0x0c) AM_DEVWRITE("ay8910", ay8910_data_w)
1107   AM_RANGE(0xa2, 0xa2) AM_MIRROR(0x0c) AM_DEVREAD("ay8910", ay8910_r)
1108   AM_RANGE(0xa3, 0xa3) AM_MIRROR(0x0c) AM_NOP
1109
1110   AM_RANGE(0xb0, 0xb0) AM_MIRROR(0x0f) AM_WRITE(pc6001m2_system_latch_w)
1111
10321112   AM_RANGE(0xc0, 0xc0) AM_WRITE(pc6001m2_col_bank_w)
10331113   AM_RANGE(0xc1, 0xc1) AM_WRITE(pc6001m2_vram_bank_w)
10341114   AM_RANGE(0xc2, 0xc2) AM_WRITE(pc6001m2_opt_bank_w)
1035   /* 0xe0 / 0xe3 is clearly voice synth related */
1036   AM_RANGE(0xe0, 0xe0) AM_READ(voice_status_r) //AM_WRITE(adpcm_w)
10371115
1116   AM_RANGE(0xd0, 0xd3) AM_MIRROR(0x0c) AM_NOP // disk device
1117
1118   AM_RANGE(0xe0, 0xe3) AM_MIRROR(0x0c) AM_READWRITE(upd7752_reg_r,upd7752_reg_w)
1119
10381120   AM_RANGE(0xf0, 0xf0) AM_WRITE(pc6001m2_bank_r0_w)
10391121   AM_RANGE(0xf1, 0xf1) AM_WRITE(pc6001m2_bank_r1_w)
10401122   AM_RANGE(0xf2, 0xf2) AM_WRITE(pc6001m2_bank_w0_w)
1041   AM_RANGE(0xf3, 0xf3) AM_WRITENOP // Chrith writes there on the intro screens, 0xc2 then 0xc7
1123   AM_RANGE(0xf3, 0xf3) AM_WRITE(pc6001m2_0xf3_w)
1124//   AM_RANGE(0xf4
1125//   AM_RANGE(0xf5
1126   AM_RANGE(0xf6, 0xf6) AM_WRITE(pc6001m2_timer_adj_w)
1127   AM_RANGE(0xf7, 0xf7) AM_WRITE(pc6001m2_timer_irqv_w)
10421128ADDRESS_MAP_END
10431129
10441130/* Input ports */
r8741r8742
13671453   }
13681454}
13691455
1370static TIMER_CALLBACK(audio_callback)
1371{
1372   if(cas_switch == 0)
1373   {
1374      irq_vector = 0x06;
1375      cputag_set_input_line(machine,"maincpu", 0, ASSERT_LINE);
1376   }
1377}
1378
13791456static TIMER_CALLBACK(keyboard_callback)
13801457{
13811458   const address_space *space = cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM);
r8741r8742
14101487
14111488static MACHINE_START(pc6001)
14121489{
1413   /* TODO: accurate timing on these (especially for the first one) */
1414   timer_pulse(machine, ATTOTIME_IN_HZ(540), NULL, 0, audio_callback);
1490   /* TODO: accurate timing on these */
14151491   timer_pulse(machine, ATTOTIME_IN_HZ(250), NULL, 0, keyboard_callback);
14161492   timer_pulse(machine, ATTOTIME_IN_HZ(160/4), NULL, 0, cassette_callback);
1493
1494   timer_hz_div = 3;
1495   {
1496      attotime period = ATTOTIME_IN_HZ((487.5*4)/(timer_hz_div+1));
1497      timer_irq_timer = timer_alloc(machine, audio_callback, NULL);
1498      timer_adjust_periodic(timer_irq_timer, period,  0, period);
1499   }
14171500}
14181501
14191502static MACHINE_RESET(pc6001)
r8741r8742
14241507   cpu_set_irq_callback(machine->device("maincpu"),pc6001_irq_callback);
14251508   cas_switch = 0;
14261509   cas_offset = 0;
1510   timer_irq_mask = 1;
1511   timer_irq_mask2 = 1;
1512   timer_irq_vector = 0x06; // actually vector is fixed in plain PC-6001
1513   timer_hz_div = 3;
14271514}
14281515
14291516static MACHINE_RESET(pc6001m2)
r8741r8742
14521539      bank_w = 0x55; //write to work ram
14531540      gfx_bank_on = 0;
14541541   }
1542
1543   timer_irq_mask = 1;
1544   timer_irq_mask2 = 1;
1545   timer_irq_vector = 0x06;
14551546}
14561547
14571548static const rgb_t defcolors[] =
r8741r8742
15691660
15701661static MACHINE_DRIVER_START( pc6001 )
15711662   /* basic machine hardware */
1572   MDRV_CPU_ADD("maincpu",Z80, 7987200 / 4)
1663   MDRV_CPU_ADD("maincpu",Z80, 7987200 / 2) // ~4 Mhz
15731664   MDRV_CPU_PROGRAM_MAP(pc6001_map)
15741665   MDRV_CPU_IO_MAP(pc6001_io)
15751666   MDRV_CPU_VBLANK_INT("screen", pc6001_interrupt)
r8741r8742
16421733   MDRV_IMPORT_FROM(pc6001m2)
16431734
16441735   /* basic machine hardware */
1645   MDRV_CPU_REPLACE("maincpu", Z80, XTAL_3_579545MHz)
1736   MDRV_CPU_REPLACE("maincpu", Z80, XTAL_3_579545MHz) //*Yes*, PC-6001 SR Z80 CPU is actually slower than older models
16461737MACHINE_DRIVER_END
16471738
16481739/* ROM definition */

Previous 15994 Revisions Next


© 1998-2018 The MESS Team