358
358
UINT32 m_coin_info;
359
359
UINT32 m_mux_data;
360
DECLARE_WRITE32_MEMBER(rf5c296_io_w);
361
DECLARE_READ32_MEMBER(rf5c296_io_r);
362
DECLARE_READ32_MEMBER(rf5c296_mem_r);
363
DECLARE_WRITE32_MEMBER(rf5c296_mem_w);
364
DECLARE_READ32_MEMBER(flash_subbios_r);
365
DECLARE_WRITE32_MEMBER(flash_subbios_w);
366
DECLARE_READ32_MEMBER(flash_mn102_r);
367
DECLARE_WRITE32_MEMBER(flash_mn102_w);
368
DECLARE_READ32_MEMBER(flash_s1_r);
369
DECLARE_WRITE32_MEMBER(flash_s1_w);
370
DECLARE_READ32_MEMBER(flash_s2_r);
371
DECLARE_WRITE32_MEMBER(flash_s2_w);
372
DECLARE_READ32_MEMBER(flash_s3_r);
373
DECLARE_WRITE32_MEMBER(flash_s3_w);
374
DECLARE_READ32_MEMBER(control_r);
375
DECLARE_WRITE32_MEMBER(control_w);
376
DECLARE_WRITE32_MEMBER(control2_w);
377
DECLARE_READ32_MEMBER(control3_r);
378
DECLARE_WRITE32_MEMBER(control3_w);
379
DECLARE_READ32_MEMBER(gn_1fb70000_r);
380
DECLARE_WRITE32_MEMBER(gn_1fb70000_w);
381
DECLARE_READ32_MEMBER(hack1_r);
382
DECLARE_READ32_MEMBER(znsecsel_r);
383
DECLARE_WRITE32_MEMBER(znsecsel_w);
384
DECLARE_READ32_MEMBER(boardconfig_r);
385
DECLARE_WRITE32_MEMBER(coin_w);
386
DECLARE_READ32_MEMBER(coin_r);
387
DECLARE_READ32_MEMBER(gnet_mahjong_panel_r);
393
static WRITE32_HANDLER(rf5c296_io_w)
421
WRITE32_MEMBER(taitogn_state::rf5c296_io_w)
395
taitogn_state *state = space->machine().driver_data<taitogn_state>();
398
ide_controller32_pcmcia_w(space->machine().device(":card"), offset, data, mem_mask);
425
ide_controller32_pcmcia_w(machine().device(":card"), offset, data, mem_mask);
402
429
if(offset == 0x3e0/4) {
403
430
if(ACCESSING_BITS_0_7)
404
state->m_rf5c296_reg = data;
431
m_rf5c296_reg = data;
405
432
if(ACCESSING_BITS_8_15)
406
rf5c296_reg_w(space->machine(), state->m_rf5c296_reg, data >> 8);
433
rf5c296_reg_w(machine(), m_rf5c296_reg, data >> 8);
410
static READ32_HANDLER(rf5c296_io_r)
437
READ32_MEMBER(taitogn_state::rf5c296_io_r)
412
taitogn_state *state = space->machine().driver_data<taitogn_state>();
415
return ide_controller32_pcmcia_r(space->machine().device(":card"), offset, mem_mask);
441
return ide_controller32_pcmcia_r(machine().device(":card"), offset, mem_mask);
419
445
if(offset == 0x3e0/4) {
420
446
UINT32 res = 0xffff0000;
421
447
if(ACCESSING_BITS_0_7)
422
res |= state->m_rf5c296_reg;
448
res |= m_rf5c296_reg;
423
449
if(ACCESSING_BITS_8_15)
424
res |= rf5c296_reg_r(space->machine(), state->m_rf5c296_reg) << 8;
450
res |= rf5c296_reg_r(machine(), m_rf5c296_reg) << 8;
498
static READ32_HANDLER(flash_subbios_r)
500
taitogn_state *state = space->machine().driver_data<taitogn_state>();
502
return gen_flash_r(state->m_biosflash, offset, mem_mask);
505
static WRITE32_HANDLER(flash_subbios_w)
507
taitogn_state *state = space->machine().driver_data<taitogn_state>();
509
gen_flash_w(state->m_biosflash, offset, data, mem_mask);
512
static READ32_HANDLER(flash_mn102_r)
514
taitogn_state *state = space->machine().driver_data<taitogn_state>();
516
return gen_flash_r(state->m_pgmflash, offset, mem_mask);
519
static WRITE32_HANDLER(flash_mn102_w)
521
taitogn_state *state = space->machine().driver_data<taitogn_state>();
523
gen_flash_w(state->m_pgmflash, offset, data, mem_mask);
526
static READ32_HANDLER(flash_s1_r)
528
taitogn_state *state = space->machine().driver_data<taitogn_state>();
530
return gen_flash_r(state->m_sndflash[0], offset, mem_mask);
533
static WRITE32_HANDLER(flash_s1_w)
535
taitogn_state *state = space->machine().driver_data<taitogn_state>();
537
gen_flash_w(state->m_sndflash[0], offset, data, mem_mask);
540
static READ32_HANDLER(flash_s2_r)
542
taitogn_state *state = space->machine().driver_data<taitogn_state>();
544
return gen_flash_r(state->m_sndflash[1], offset, mem_mask);
547
static WRITE32_HANDLER(flash_s2_w)
549
taitogn_state *state = space->machine().driver_data<taitogn_state>();
551
gen_flash_w(state->m_sndflash[1], offset, data, mem_mask);
554
static READ32_HANDLER(flash_s3_r)
556
taitogn_state *state = space->machine().driver_data<taitogn_state>();
558
return gen_flash_r(state->m_sndflash[2], offset, mem_mask);
561
static WRITE32_HANDLER(flash_s3_w)
563
taitogn_state *state = space->machine().driver_data<taitogn_state>();
565
gen_flash_w(state->m_sndflash[2], offset, data, mem_mask);
523
READ32_MEMBER(taitogn_state::flash_subbios_r)
526
return gen_flash_r(m_biosflash, offset, mem_mask);
529
WRITE32_MEMBER(taitogn_state::flash_subbios_w)
532
gen_flash_w(m_biosflash, offset, data, mem_mask);
535
READ32_MEMBER(taitogn_state::flash_mn102_r)
538
return gen_flash_r(m_pgmflash, offset, mem_mask);
541
WRITE32_MEMBER(taitogn_state::flash_mn102_w)
544
gen_flash_w(m_pgmflash, offset, data, mem_mask);
547
READ32_MEMBER(taitogn_state::flash_s1_r)
550
return gen_flash_r(m_sndflash[0], offset, mem_mask);
553
WRITE32_MEMBER(taitogn_state::flash_s1_w)
556
gen_flash_w(m_sndflash[0], offset, data, mem_mask);
559
READ32_MEMBER(taitogn_state::flash_s2_r)
562
return gen_flash_r(m_sndflash[1], offset, mem_mask);
565
WRITE32_MEMBER(taitogn_state::flash_s2_w)
568
gen_flash_w(m_sndflash[1], offset, data, mem_mask);
571
READ32_MEMBER(taitogn_state::flash_s3_r)
574
return gen_flash_r(m_sndflash[2], offset, mem_mask);
577
WRITE32_MEMBER(taitogn_state::flash_s3_w)
580
gen_flash_w(m_sndflash[2], offset, data, mem_mask);
568
583
static void install_handlers(running_machine &machine, int mode)
585
taitogn_state *state = machine.driver_data<taitogn_state>();
570
586
address_space *a = machine.device("maincpu")->memory().space(AS_PROGRAM);
572
588
// Mode 0 has access to the subbios, the mn102 flash and the rf5c296 mem zone
573
a->install_legacy_readwrite_handler(0x1f000000, 0x1f1fffff, FUNC(flash_subbios_r), FUNC(flash_subbios_w));
574
a->install_legacy_readwrite_handler(0x1f200000, 0x1f2fffff, FUNC(rf5c296_mem_r), FUNC(rf5c296_mem_w));
575
a->install_legacy_readwrite_handler(0x1f300000, 0x1f37ffff, FUNC(flash_mn102_r), FUNC(flash_mn102_w));
589
a->install_readwrite_handler(0x1f000000, 0x1f1fffff, read32_delegate(FUNC(taitogn_state::flash_subbios_r),state), write32_delegate(FUNC(taitogn_state::flash_subbios_w),state));
590
a->install_readwrite_handler(0x1f200000, 0x1f2fffff, read32_delegate(FUNC(taitogn_state::rf5c296_mem_r),state), write32_delegate(FUNC(taitogn_state::rf5c296_mem_w),state));
591
a->install_readwrite_handler(0x1f300000, 0x1f37ffff, read32_delegate(FUNC(taitogn_state::flash_mn102_r),state), write32_delegate(FUNC(taitogn_state::flash_mn102_w),state));
576
592
a->nop_readwrite(0x1f380000, 0x1f5fffff);
579
595
// Mode 1 has access to the 3 samples flashes
580
a->install_legacy_readwrite_handler(0x1f000000, 0x1f1fffff, FUNC(flash_s1_r), FUNC(flash_s1_w));
581
a->install_legacy_readwrite_handler(0x1f200000, 0x1f3fffff, FUNC(flash_s2_r), FUNC(flash_s2_w));
582
a->install_legacy_readwrite_handler(0x1f400000, 0x1f5fffff, FUNC(flash_s3_r), FUNC(flash_s3_w));
596
a->install_readwrite_handler(0x1f000000, 0x1f1fffff, read32_delegate(FUNC(taitogn_state::flash_s1_r),state), write32_delegate(FUNC(taitogn_state::flash_s1_w),state));
597
a->install_readwrite_handler(0x1f200000, 0x1f3fffff, read32_delegate(FUNC(taitogn_state::flash_s2_r),state), write32_delegate(FUNC(taitogn_state::flash_s2_w),state));
598
a->install_readwrite_handler(0x1f400000, 0x1f5fffff, read32_delegate(FUNC(taitogn_state::flash_s3_r),state), write32_delegate(FUNC(taitogn_state::flash_s3_w),state));
586
602
// Misc. controls
588
static READ32_HANDLER(control_r)
604
READ32_MEMBER(taitogn_state::control_r)
590
taitogn_state *state = space->machine().driver_data<taitogn_state>();
592
// fprintf(stderr, "gn_r %08x @ %08x (%s)\n", 0x1fb00000+4*offset, mem_mask, space->machine().describe_context());
593
return state->m_control;
607
// fprintf(stderr, "gn_r %08x @ %08x (%s)\n", 0x1fb00000+4*offset, mem_mask, machine().describe_context());
596
static WRITE32_HANDLER(control_w)
611
WRITE32_MEMBER(taitogn_state::control_w)
598
taitogn_state *state = space->machine().driver_data<taitogn_state>();
601
615
// 04 = select bank
620
634
control & 0x04 ? 'f' : '-',
621
635
control & 0x02 ? '1' : '0',
622
636
control & 0x01 ? '1' : '0',
623
space->machine().describe_context());
637
machine().describe_context());
626
if((p ^ state->m_control) & 0x04)
627
install_handlers(space->machine(), state->m_control & 4 ? 1 : 0);
630
static WRITE32_HANDLER(control2_w)
632
taitogn_state *state = space->machine().driver_data<taitogn_state>();
634
COMBINE_DATA(&state->m_control2);
637
static READ32_HANDLER(control3_r)
639
taitogn_state *state = space->machine().driver_data<taitogn_state>();
641
return state->m_control3;
644
static WRITE32_HANDLER(control3_w)
646
taitogn_state *state = space->machine().driver_data<taitogn_state>();
648
COMBINE_DATA(&state->m_control3);
651
static READ32_HANDLER(gn_1fb70000_r)
640
if((p ^ m_control) & 0x04)
641
install_handlers(machine(), m_control & 4 ? 1 : 0);
644
WRITE32_MEMBER(taitogn_state::control2_w)
647
COMBINE_DATA(&m_control2);
650
READ32_MEMBER(taitogn_state::control3_r)
656
WRITE32_MEMBER(taitogn_state::control3_w)
659
COMBINE_DATA(&m_control3);
662
READ32_MEMBER(taitogn_state::gn_1fb70000_r)
653
664
// (1328) 1348 tests mask 0002, 8 times.
654
665
// Called by 1434, exit at 143c
761
static WRITE32_HANDLER( znsecsel_w )
770
WRITE32_MEMBER(taitogn_state::znsecsel_w)
763
taitogn_state *state = space->machine().driver_data<taitogn_state>();
765
COMBINE_DATA( &state->m_n_znsecsel );
767
if( ( state->m_n_znsecsel & 0x80 ) == 0 )
773
COMBINE_DATA( &m_n_znsecsel );
775
if( ( m_n_znsecsel & 0x80 ) == 0 )
769
psx_sio_install_handler( space->machine(), 0, sio_pad_handler );
770
psx_sio_input( space->machine(), 0, PSX_SIO_IN_DSR, 0 );
777
psx_sio_install_handler( machine(), 0, sio_pad_handler );
778
psx_sio_input( machine(), 0, PSX_SIO_IN_DSR, 0 );
772
else if( ( state->m_n_znsecsel & 0x08 ) == 0 )
780
else if( ( m_n_znsecsel & 0x08 ) == 0 )
774
782
znsec_start( 1 );
775
psx_sio_install_handler( space->machine(), 0, sio_znsec1_handler );
776
psx_sio_input( space->machine(), 0, PSX_SIO_IN_DSR, 0 );
783
psx_sio_install_handler( machine(), 0, sio_znsec1_handler );
784
psx_sio_input( machine(), 0, PSX_SIO_IN_DSR, 0 );
778
else if( ( state->m_n_znsecsel & 0x04 ) == 0 )
786
else if( ( m_n_znsecsel & 0x04 ) == 0 )
780
788
znsec_start( 0 );
781
psx_sio_install_handler( space->machine(), 0, sio_znsec0_handler );
782
psx_sio_input( space->machine(), 0, PSX_SIO_IN_DSR, 0 );
789
psx_sio_install_handler( machine(), 0, sio_znsec0_handler );
790
psx_sio_input( machine(), 0, PSX_SIO_IN_DSR, 0 );
786
state->m_n_dip_bit = 0;
787
state->m_b_lastclock = 1;
789
psx_sio_install_handler( space->machine(), 0, sio_dip_handler );
790
psx_sio_input( space->machine(), 0, PSX_SIO_IN_DSR, 0 );
792
state->m_dip_timer->adjust( downcast<cpu_device *>(&space->device())->cycles_to_attotime( 100 ), 1 );
797
psx_sio_install_handler( machine(), 0, sio_dip_handler );
798
psx_sio_input( machine(), 0, PSX_SIO_IN_DSR, 0 );
800
m_dip_timer->adjust( downcast<cpu_device *>(&space.device())->cycles_to_attotime( 100 ), 1 );
844
COMBINE_DATA (&state->m_coin_info);
851
COMBINE_DATA (&m_coin_info);
847
static READ32_HANDLER( coin_r )
854
READ32_MEMBER(taitogn_state::coin_r)
849
taitogn_state *state = space->machine().driver_data<taitogn_state>();
851
return state->m_coin_info;
854
860
/* mahjong panel handler (for Usagi & Mahjong Oh) */
855
static READ32_HANDLER( gnet_mahjong_panel_r )
861
READ32_MEMBER(taitogn_state::gnet_mahjong_panel_r)
857
taitogn_state *state = space->machine().driver_data<taitogn_state>();
859
state->m_mux_data = state->m_coin_info;
860
state->m_mux_data &= 0xcc;
862
switch(state->m_mux_data)
864
m_mux_data = m_coin_info;
864
case 0x04: return input_port_read(space->machine(), "KEY0");
865
case 0x08: return input_port_read(space->machine(), "KEY1");
866
case 0x40: return input_port_read(space->machine(), "KEY2");
867
case 0x80: return input_port_read(space->machine(), "KEY3");
869
case 0x04: return ioport("KEY0")->read();
870
case 0x08: return ioport("KEY1")->read();
871
case 0x40: return ioport("KEY2")->read();
872
case 0x80: return ioport("KEY3")->read();
870
875
/* mux disabled */
871
return input_port_read(space->machine(), "P4");
876
return ioport("P4")->read();
874
879
// Init and reset
889
894
psx_sio_install_handler(machine, 0, sio_pad_handler);
890
895
state->m_dip_timer = machine.scheduler().timer_alloc( FUNC(dip_timer_fired), NULL );
892
898
memset(state->m_cis, 0xff, 512);
893
if (get_disk_handle(machine, ":card") != NULL)
894
chd_get_metadata(get_disk_handle(machine, ":card"), PCMCIA_CIS_METADATA_TAG, 0, state->m_cis, 512, 0, 0, 0);
899
if (get_disk_handle(machine, ":drive_0") != NULL)
900
get_disk_handle(machine, ":drive_0")->read_metadata(PCMCIA_CIS_METADATA_TAG, 0, state->m_cis, 512, metalength);
897
903
static DRIVER_INIT( coh3002t_mp )
899
905
DRIVER_INIT_CALL(coh3002t);
900
machine.device("maincpu")->memory().space(AS_PROGRAM)->install_legacy_read_handler(0x1fa10100, 0x1fa10103, FUNC(gnet_mahjong_panel_r) );
906
taitogn_state *state = machine.driver_data<taitogn_state>();
907
machine.device("maincpu")->memory().space(AS_PROGRAM)->install_read_handler(0x1fa10100, 0x1fa10103, read32_delegate(FUNC(taitogn_state::gnet_mahjong_panel_r),state));
903
910
static MACHINE_RESET( coh3002t )
931
938
AM_RANGE(0x1fa10300, 0x1fa10303) AM_READWRITE(znsecsel_r, znsecsel_w)
932
939
AM_RANGE(0x1fa20000, 0x1fa20003) AM_READWRITE(coin_r, coin_w)
933
940
AM_RANGE(0x1fa30000, 0x1fa30003) AM_READWRITE(control3_r, control3_w)
934
AM_RANGE(0x1fa51c00, 0x1fa51dff) AM_READWRITE16(spu_r, spu_w, 0xffffffff) // systematic read at spu_address + 250000, result dropped, maybe other accesses
941
AM_RANGE(0x1fa51c00, 0x1fa51dff) AM_READWRITE16_LEGACY(spu_r, spu_w, 0xffffffff) // systematic read at spu_address + 250000, result dropped, maybe other accesses
935
942
AM_RANGE(0x1fa60000, 0x1fa60003) AM_READ(hack1_r)
936
AM_RANGE(0x1faf0000, 0x1faf07ff) AM_DEVREADWRITE8("at28c16", at28c16_r, at28c16_w, 0xffffffff) /* eeprom */
943
AM_RANGE(0x1faf0000, 0x1faf07ff) AM_DEVREADWRITE8_LEGACY("at28c16", at28c16_r, at28c16_w, 0xffffffff) /* eeprom */
937
944
AM_RANGE(0x1fb00000, 0x1fb0ffff) AM_READWRITE(rf5c296_io_r, rf5c296_io_w)
938
945
AM_RANGE(0x1fb40000, 0x1fb40003) AM_READWRITE(control_r, control_w)
939
946
AM_RANGE(0x1fb60000, 0x1fb60003) AM_WRITE(control2_w)